Possibly this would work better: Allows the ban of multiple IPs, one per line.
PHP Code:
//Place this at the top of your php scripts/HTML to prevent access to those IP addresses listed.
<?php
$ip_ban = array();
$ip_ban[] = '111.111.111.111';
$ip_ban[] = '111.111.111.112';
foreach($ip_ban as $denied) {
$ip = $_SERVER['REMOTE_ADDR'];
if($ip == $denied){
echo "Access Denied! You have been banned!";
exit();
}
}
If I was to use them / this, I would use the array, and put it into like banned.php and then just call / include banned.php on the footer which is on every page or somthing...
tis a cool script, but I can never figure out how this kinda script works.
Firstly, with my service provider, my ip address changes every 5 minutes, so I can just wait a few minutes before re-accessing the site, and other people's ip addresses re-knew when they re-logon to their isps. These won't work, I'm telling you! The rest of the people will just use an ipscrambler.
If the visitor blocks cookies, you're out of luck...
I'd recommend setting them with a misleading name, so Firefox users don't think they say you're banned! (i.e. site_user). When the user visits the site, add the site_user cookie with no_c. If they're banned, add it with no_b.