IP range ban

git-svn-id: file:///home/shish/svn/shimmie2/trunk@746 7f39781d-f577-437e-ae19-be835c7a54ca
This commit is contained in:
shish
2008-04-01 10:57:18 +00:00
parent e469ebcb38
commit 89df1557f0
3 changed files with 21 additions and 4 deletions

View File

@ -350,6 +350,19 @@ if(!function_exists('sys_get_temp_dir')) {
}
}
// from http://uk.php.net/network
function ip_in_range($IP, $CIDR) {
list ($net, $mask) = split ("/", $CIDR);
$ip_net = ip2long ($net);
$ip_mask = ~((1 << (32 - $mask)) - 1);
$ip_ip = ip2long ($IP);
$ip_ip_net = $ip_ip & $ip_mask;
return ($ip_ip_net == $ip_net);
}
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *\
* Event API *