Forum Moderators: coopster
<?php
$banned_ip = array();
$banned_ip[] = '111.111.111.111';
$banned_ip[] = '111.111.111.112';
$banned_ip[] = '111.111.111.113';
$banned_ip[] = '111.111.111.114';
foreach($banned_ip as $banned) {
$ip = $_SERVER['REMOTE_ADDR'];
if($ip == $banned){
echo "You have been banned!";
exit();
}
}
// rest of PHP Script here!
?>
Welcome to WebmasterWorld [webmasterworld.com]!
I can't answer your question, but I do want to point out two things that may help in the long run:
First, make sure your final script returns a 403-Forbidden HTTP response header to the client. If it is a robotic client, then that is all it will understand, since it won't 'read' your message.
Second, take the $ip = $_SERVER['REMOTE_ADDR']; line out of the loop and move it up. There is no reason to query the server variable list each time through the loop, and doing so will only slow things down.
Jim