复制代码 代码如下:
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);转载注明www.chhua.com
if (!file_exists("./log/bot.html")){
$botfile=fopen("./log/bot.html", "w");
$fileHeader="
访问查看
删除日志
";
// echoExit($botfile);转载注明www.chhua.com
fputs($botfile, $fileHeader);
fclose($botfile);
}else
{ $filesize=filesize("./log/bot.html");
if ($filesize>=100000){
$botfile=fopen("./log/bot.html", "w");
$fileHeader="
访问查看
删除日志
";
fputs($botfile, $fileHeader);
fclose($botfile);
}else {
$botfile=fopen("./log/bot.html", "a+");
}
//$size="
当前文件大小为:".$filesize."
";转载注明www.chhua.com
$useragent="
USER:".$useragent."
";
$date="
TIME:".$date."
";
$ip="
IP:".$ip."
";
$url="
URL:".$url."
";
$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 '
Googlebot';
}
if(strpos($useragent, 'msnbot') !== false){
return 'MSNbot';
}
if(strpos($useragent, 'slurp') !== false){
return '
Yahoobot';
}
if(strpos($useragent, 'baiduspider') !== false){
return '
Baiduspider';
}
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判断搜索引擎蜘蛛并自动记忆到文件的代码,包括了新科技之美女搜索引擎方面的内容,希望对PHP教程有兴趣的朋友有所帮助。
大家都在看:
应对现代浏览器限制:在网页中引导用户添加书签的实践指南
PHP如何向数组添加元素_PHP向数组中添加新元素的多种技巧
基于浏览器指纹识别技术实现跨浏览器设备唯一标识
利用浏览器指纹技术唯一识别计算机:构建跨浏览器通信的解决方案
解决PHP中“Undefined Index”错误的类型声明技巧
上文是新科技之美女搜索引擎 PHP判断搜索引擎蜘蛛并自动记忆到文件的代码的内容了,文章的版权归原作者所有,如有侵犯您的权利,请及时联系本站删除,更多相关新科技之美女搜索引擎的资讯,请关注收藏西西下载站。