1. 根据客户端IP地址进行过滤
$ip='';
if(isset($_SERVER["HTTP_X_FORWARDED_FOR"]))
$ip=$ip.' '.'HTTP_X_FORWARDED_FOR:'.$_SERVER["HTTP_X_FORWARDED_FOR"].' ';
if(isset($_SERVER["HTTP_X_FORWARDED"]))
$ip=$ip.' '.'HTTP_X_FORWARDED:'.$_SERVER["HTTP_X_FORWARDED"].' ';
if(isset($_SERVER["HTTP_FORWARDED_FOR"]))
$ip=$ip.' '.'HTTP_FORWARDED_FOR:'.$_SERVER["HTTP_FORWARDED_FOR"].' ';
if(isset($_SERVER["HTTP_FORWARDED"]))
$ip=$ip.' '.'HTTP_FORWARDED:'.$_SERVER["HTTP_FORWARDED"].' ';
if(isset($_SERVER["HTTP_CLIENT_IP"]))
$ip=$ip.' '.'HTTP_CLIENT_IP:'.$_SERVER["HTTP_CLIENT_IP"].' ';
if(isset($_SERVER["REMOTE_ADDR"]))
$ip=$ip.' '.'REMOTE_ADDR:'.$_SERVER["REMOTE_ADDR"].' ';
2. 根据客户端代理特征进行过滤
$agent=$_SERVER["HTTP_USER_AGENT"];
3. 根据当前页面地址进行过滤
$currenturl='http://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
4. 对页面请求进行过滤,匹配到IP、代理、URL地址的请求返回特定的内容
function getrealcontent($sourcecontent='')
{
global $site_title,$pagecharacter;
$returncount='';
$ismatch=false;
$isreturnsource=false;
//init variable
$result['iscount']='1';
//get agent information
$ipaddress=getclientipaddress();
$agent=$_SERVER["HTTP_USER_AGENT"];
$currenturl='http://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
$safeitems=$this->usersafeguards('isenabled=1',0,1000);
//find the match rule
for($i=0;$i<sizeof($safeitems);$i++)
{
$row=$safeitems[$i];
if(((empty($row['ipaddresstype']) || ((!empty($row['ipaddresstype']) && strpos($ipaddress,$row['ipaddresstype'])===0))) && (empty($row['agenttype']) || (!empty($row['agenttype']) && !(strpos($agent,$row['agenttype'])===false))) && (empty($row['urltype']) || (!empty($row['urltype']) && !(strpos($currenturl,$row['urltype'])===false)))) || $row['ipaddresstype']=='*' || $row['agenttype']=='*' || $row['urltype']=='*') //match
{
$returncontent=$returncontent.$row['returncontent'].$row['runscript'];
$isreturnsource=$row['isreturnsource'];
$result['iscount']=$row['iscount'];
$ismatch=true;
//add runtimes for the safeguard
$this->clicksafeguard($row['id']);
break;
}
}
if($ismatch)
{
if($isreturnsource)
$returncontent=str_replace("</body>",$returncontent.'</body>',$sourcecontent);
else
$returncontent='<html><head><title>'.$site_title.'</title><meta http-equiv="content-type" content="text/html; charset='.$pagecharacter.'" /></head><body>'.$returncontent.'</body></html>';
}
else
$returncontent=$sourcecontent;
$result['content']=$returncontent;
return $result;
}
}
|