php 屏蔽指定IP或IP段
2016.05.28 | 1615阅读 | 0条评论 | php
$denyIp = array('45.34.*','101.96.*');
$nowIp = real_ip();
foreach ($denyIp as $k=>$v)
{
if (strpos($v,'*') >0)
{
if (substr($nowIp,0,strpos($v,'*')) == substr($v,0,strpos($v,'*')))
exit();
}
elseif ($nowIp == $v)
exit();
}
发表评论