Ban certain IP addresses
Using this handy codesnippet you can easily ban several troublemakers from your website. Please note though that this is far from foolproof, and people can very easily get around it, by using a proxy or changing their IP address (e.g. dial-up users, AOL users, etc).
$banned_ip = array();
$banned_ip[] = '111.111.111.110'; // first IP
$banned_ip[] = '111.111.111.111'; // second IP
$banned_ip[] = '111.111.111.112'; // third IP, just add more if you need
foreach($banned_ip as $banned) {
$ip = $_SERVER['REMOTE_ADDR'];
if($ip == $banned){
echo "You have been banned! Sorry!";
exit();
}
}
// The rest of your PHP script goes here
?>