You could do something like this:
$source = 'localhost';
if($source != 'localhost') {
echo" Error, remote MySQL connections are not allowed!";
} else {
mysql_connect('$source', 'username', 'password', 'database') or die(mysql_error());
}
Exactly how are your going to have this set up...or how do you plan on implementing this?
The script above my not be what you need.