Here's an adaptation of stonesour's ip_check(), with strict proxy support:
<?php
function ip_check()
{
// Addresses to block
$block_ip[0] = "64.246.30.37";
$block_ip[1] = "207.46.249.252";
$block_ip[2] = "212.143.162.198";
if (in_array($_SERVER["REMOTE_ADDR"], $block_ip))
return false;
if (in_array($_SERVER["HTTP_CLIENT_IP"], $block_ip))
return false;
if (isset($_SERVER["HTTP_X_FORWARDED_FOR"])) {
$proxy = explode(",",$_SERVER["HTTP_X_FORWARDED_FOR"]);
$proxy = str_replace(" ","",$proxy); $i = 0;
while ($proxy[$i]) {
if (in_array($proxy[$i], $block_ip))
return false;
$i++;
}
}
return true;
}
?>
This one should also ban people who use standard HTTP proxies... Note that the function returns TRUE if the user is allowed entry, and FALSE if s/he is banned.
Does anyone know how to fill the $block_ip array more efficiently?