您好,欢迎访问一九零五行业门户网

新科技之美女搜索引擎 PHP判断搜索引擎蜘蛛并自动记忆到文件的代码

复制代码 代码如下:
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教程有兴趣的朋友有所帮助。
其它类似信息

推荐信息