国产探花免费观看_亚洲丰满少妇自慰呻吟_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ā)表
主站蜘蛛池模板: 太和县| 赤壁市| 孟村| 炎陵县| 信阳市| 平原县| 西和县| 肇州县| 喜德县| 三门峡市| 沈阳市| 文山县| 微博| 海安县| 赤壁市| 大城县| 灵寿县| 阿荣旗| 斗六市| 凭祥市| 延吉市| 青阳县| 陵川县| 监利县| 开平市| 阿拉尔市| 广水市| 甘谷县| 昭苏县| 中卫市| 镇坪县| 西乌珠穆沁旗| 温宿县| 台东市| 洪雅县| 永丰县| 河北区| 寿阳县| 台中县| 通江县| 万盛区|