$server=getenv("HTTP_HOST");
$num=strpos($server,'taisha.org');
if($num<10&&$num== false){
exit;
}
//获取UA信息
$ua=$_SERVER['HTTP_USER_AGENT'];
//将恶意USER_AGENT存入数组
$now_ua= array('FeedDemon ','BOT/0.1 (BOT for JCE)','CrawlDaddy ','Java','Feedly','UniversalFeedParser','ApacheBench','Swiftbot','ZmEu','Indy Library','oBot','jaunty','YandexBot','AhrefsBot','MJ12bot','WinHttp','EasouSpider','HttpClient','Microsoft URL Control','YYSpider','jaunty','Python-urllib','lightDeckReports Bot');
//禁止空USER_AGENT,dedecms等主流采集程序都是空USER_AGENT,部分sql注入工具也是空USER_AGENT
if(!$ua) {
header("Content-type: text/html; charset=utf-8");
die('请勿采集本站,因为采集的站长木有小JJ!');
}else{
//判断是否是数组中存在的UA
if(in_array($ua,$now_ua)) {
header("Content-type: text/html; charset=utf-8");
die('请勿采集本站,因为采集的站长木有小JJ!');
}
}
$clientip='';
if(getenv('HTTP_CLIENT_IP')&&strcasecmp(getenv('HTTP_CLIENT_IP'),'unknown')) {
$clientip=getenv('HTTP_CLIENT_IP');
}elseif(getenv('HTTP_X_FORWARDED_FOR')&&strcasecmp(getenv('HTTP_X_FORWARDED_FOR'),'unknown')) {
$clientip=getenv('HTTP_X_FORWARDED_FOR');
}elseif(getenv('REMOTE_ADDR')&&strcasecmp(getenv('REMOTE_ADDR'),'unknown')) {
$clientip=getenv('REMOTE_ADDR');
}elseif(isset($_SERVER['REMOTE_ADDR'])&&$_SERVER['REMOTE_ADDR']&&strcasecmp($_SERVER['REMOTE_ADDR'],'unknown')) {
$clientip=$_SERVER['REMOTE_ADDR'];
}
preg_match("/[\d\.]{7,15}/", $clientip, $clientipmatches);
$clientip=$clientipmatches[0]?$clientipmatches[0]:'unknown';
$res=explode(',',$clientip);
if(in_array('103.230.123.4',$res)||in_array('211.149.244.252',$res)){
die('非法的ip地址');
}
//获取script_uri
$script_uri=getenv("SCRIPT_URI");
if($script_uri) {
if(strpos($script_uri,'taisha.org')== false) {
die('非法的访问地址');
}
}
?>