6 public function filter($ip_list, $ip = NULL)
8 if(!$ip) $ip = $_SERVER[
'REMOTE_ADDR'];
9 $long_ip = ip2long($ip);
10 foreach($ip_list as $filter_ip)
12 $range = explode(
'-', $filter_ip);
15 $star_pos = strpos($filter_ip,
'*');
16 if($star_pos !== FALSE )
18 if(strncmp($filter_ip, $ip, $star_pos)===0)
return true;
20 else if(strcmp($filter_ip, $ip)===0)
25 else if(ip2long($range[0]) <= $long_ip && ip2long($range[1]) >= $long_ip)
64 (?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)
67 (?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}
68 (?:-(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){1}
69 (?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}
73 (?:\.(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)|\*)){3}
77 $regex = str_replace(array(
"\r\n",
"\n",
"\r",
"\t",
" "),
'', $regex);
79 foreach($ip_list as $i => $ip)
81 preg_match($regex, $ip, $matches);
82 if(!count($matches))
return false;
validate($ip_list=array())
filter($ip_list, $ip=NULL)