国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 開發(fā) > PHP > 正文

PHP判斷搜索引擎蜘蛛并自動記憶到文件的代碼

2024-05-04 23:15:56
字體:
供稿:網(wǎng)友

復(fù)制代碼 代碼如下:


function write_naps_bot(){
$useragent=get_naps_bot();
// echoExit($useragent);
if ($useragent=="false") return FALSE ;
date_default_timezone_set("Asia/Shanghai");
$date=date("Y-m-d H:i:s");
$ip=$_SERVER[REMOTE_ADDR];
$url="http://".$_SERVER[HTTP_HOST].$_SERVER[REQUEST_URI];
// echoExit($url);轉(zhuǎn)載注明
if (!file_exists("./log/bot.html")){
$botfile=fopen("./log/bot.html", "w");
$fileHeader="<head>
<meta http-equiv=/"Content-Type/" content=/"text/html; charset=utf-8/" />
<title>訪問查看</title>
</head>
<a href=/"../?action=delbot/">刪除日志</a><hr>
";
// echoExit($botfile);轉(zhuǎn)載注明

fputs($botfile, $fileHeader);
fclose($botfile);
}else
{ $filesize=filesize("./log/bot.html");
if ($filesize>=100000){
$botfile=fopen("./log/bot.html", "w");
$fileHeader="<head>
<meta http-equiv=/"Content-Type/" content=/"text/html; charset=utf-8/" />
<title>訪問查看</title>
</head>
<a href=/"../?action=delbot/">刪除日志</a><hr>
";
fputs($botfile, $fileHeader);
fclose($botfile);
}else {
$botfile=fopen("./log/bot.html", "a+");
}

//$size="<b>當(dāng)前文件大小為:</b>".$filesize."<br>";轉(zhuǎn)載注明

$useragent="<b>USER:</b>".$useragent."<Br>";
$date="<b>TIME:</b>".$date."<Br>";
$ip="<b>IP:</b>".$ip."<Br>";
$url="<b>URL:</b><a href='$url' target='_blank'>".$url."</a><Br><Br>";
$fileStr=$useragent.$date.$ip.$url;
fputs($botfile, $fileStr);
fclose($botfile);
}
}

function get_naps_bot() {
$useragent = strtolower($_SERVER['HTTP_USER_AGENT']);
if(strpos($useragent, 'googlebot') !== false){
return '<font color=blue>Googlebot</font>';
}
if(strpos($useragent, 'msnbot') !== false){
return 'MSNbot';
}
if(strpos($useragent, 'slurp') !== false){
return '<font color=green>Yahoobot</font>';
}
if(strpos($useragent, 'baiduspider') !== false){
return '<font color=red>Baiduspider</font>';
}
if(strpos($useragent, 'sohu-search') !== false){
return 'Sohubot';
}
if(strpos($useragent, 'lycos') !== false){
return 'Lycos';
}

if(strpos($useragent, 'robozilla') !== false){
return 'Robozilla';
}
return "false";
}

發(fā)表評論 共有條評論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 徐水县| 莎车县| 隆回县| 九龙坡区| 蓬安县| 龙里县| 汝南县| 新宾| 文成县| 雅安市| 惠水县| 大姚县| 防城港市| 喜德县| 梁平县| 黑龙江省| 马尔康县| 富川| 浦东新区| 柞水县| 德化县| 新丰县| 宿迁市| 孝感市| 余姚市| 凌海市| 海城市| 苏尼特右旗| 德兴市| 怀化市| 民县| 大宁县| 读书| 井研县| 宁城县| 灵丘县| 远安县| 承德市| 宝应县| 东海县| 卢龙县|