<?php
if(getspider()){
exit('假的搜索引擎!');
}
function getspider(){
$访问UA = strtolower($_SERVER['HTTP_USER_AGENT']);
$访问IP = isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : '';
if(isset($_SERVER['HTTP_X_FORWARDED_FOR'])){
$list = explode(',', $_SERVER['HTTP_X_FORWARDED_FOR']);
$访问IP = $list[0];
}
if (!ip2long($访问IP)) $访问IP = '未知IP';
$访问主机 = str_replace('.', '-', $访问IP);
if (strpos($访问UA, 'googlebot') !== false){
$解析主机 = gethostbyaddr($_SERVER['REMOTE_ADDR']);
if ($解析主机 != 'crawl-'.$访问主机.'.googlebot.com') return 'googlebot?';
}
if (strpos($访问UA, 'sogou') !== false){
$解析主机 = gethostbyaddr($_SERVER['REMOTE_ADDR']);
if ($解析主机 != 'sogouspider-'.$访问主机.'.crawl.sogou.com') return 'sogou';
}
if (strpos($useragent, 'bing') !== false){
$解析主机 = gethostbyaddr($_SERVER['REMOTE_ADDR']);
if ($解析主机 != 'msnbot-'.$访问主机.'.search.msn.com') return 'bing';
}
if (strpos($访问UA, 'baiduspider') !== false){
$解析主机 = gethostbyaddr($_SERVER['REMOTE_ADDR']);
if ($解析主机 != 'baiduspider-'.$访问主机.'.crawl.baidu.com') return 'baiduspider?';
}
return false;
}
如果文章或资源对您有帮助,欢迎打赏作者。一路走来,感谢有您!
txttool.com 说一段 esp56物联 查询128 IP查询