色尼玛亚洲综合影院,亚洲3atv精品一区二区三区,麻豆freexxxx性91精品,欧美在线91

PHP判斷搜索引擎蜘蛛并自動(dò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)載注明www.chhua.com
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>訪問(wèn)查看</title>
</head>
<a href=/"../?action=delbot/">刪除日志</a><hr>
";
// echoExit($botfile);轉(zhuǎn)載注明www.chhua.com

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>訪問(wèn)查看</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)載注明www.chhua.com

$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";
}

php技術(shù)PHP判斷搜索引擎蜘蛛并自動(dòng)記憶到文件的代碼,轉(zhuǎn)載需保留來(lái)源!

鄭重聲明:本文版權(quán)歸原作者所有,轉(zhuǎn)載文章僅為傳播更多信息之目的,如作者信息標(biāo)記有誤,請(qǐng)第一時(shí)間聯(lián)系我們修改或刪除,多謝。

主站蜘蛛池模板: 清镇市| 廊坊市| 乌苏市| 榆林市| 吉林省| 横峰县| 夹江县| 玉林市| 宜州市| 阿荣旗| 娱乐| 弥勒县| 崇仁县| 绵阳市| 兴隆县| 黄梅县| 宁明县| 竹北市| 尚义县| 玉田县| 通化市| 泰州市| 金山区| 汕尾市| 高邮市| 库伦旗| 石景山区| 仙居县| 桑植县| 林甸县| 临西县| 蓬溪县| 宜阳县| 泽库县| 邵武市| 兴隆县| 即墨市| 咸丰县| 上林县| 澄城县| 和硕县|