Friday, April 4, 2008

Ban IP function

/* ==================================
ban ip function by http://php-busy.blogspot.com
================================== */
$iplist[] = "192.111.111.111";
$iplist[] = "10.1.1.33";
$iplist[] = "50.165.12.3"
$iplist[] = "192.168.1.23";

// Get IP
if ($_SERVER["HTTP_X_FORWARDED_FOR"])
$ip = $_SERVER["HTTP_X_FORWARDED_FOR"]; //Get proxy
else
$ip = $_SERVER["REMOTE_ADDR"]; // Get remote address

// loop for check matching between $iplist and $ip
foreach ($iplist as $key =>$val) {
if ($ip==$val)
exit();
}
?>

No comments: