Is it possible to block an IP (or IP range) from executing a php script? Or alternatively, causing a script to terminate if the visitor is using a defined IP.
Thanks in advance
Jeff
Sure, just add the following to the top of your script...
$bad_ip = 'xxx.xxx.xxx.xxx';
if ($REMOTE_ADDR == $bad_ip) { exit; // or return whatever error }
Everything's possible.
$bad_ip = array('255.255.255.250','255.255.255.251','255.255.255.252','255.255.255.253','255.255.255.254','255.255.255.255'); if(in_array($_SERVER['REMOTE_ADDR'],$bad_ip)) die('You have been banned from this page.');
Thanks for the replies. This will work for a few IPs, but is it possible to reject an entire block of IPs (ie/ 255.***) ?
Thanks again
if you want to block an entire ip block just tell the parser to search for xxx in the ip and if it finds it, they get blocked.
$bad_ip = $_SERVER["REMOTE_ADDR"];
if (strstr($bad_ip, "255")) {echo("die biatch.");}
chud