Copy Code code as follows:
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); reprint Annotated www.chhua.com
if (!file_exists ("./log/bot.html")) {
$botfile =fopen ("./log/bot.html", "w");
$fileHeader = "<meta http-equiv=\ "content-type\" content=\ "text/html; Charset=utf-8\ "/>
<title> Access View </title>
<a href=\ ". /?action=delbot\ "> Delete log </a>";
Echoexit ($botfile); reprint Annotated www.chhua.com
Fputs ($botfile, $fileHeader);
Fclose ($botfile);
}else
{$filesize =filesize ("./log/bot.html");
if ($filesize >=100000) {
$botfile =fopen ("./log/bot.html", "w");
$fileHeader = "<meta http-equiv=\ "content-type\" content=\ "text/html; Charset=utf-8\ "/>
<title> Access View </title>
<a href=\ ". /?action=delbot\ "> Delete log </a>";
Fputs ($botfile, $fileHeader);
Fclose ($botfile);
}else {
$botfile =fopen ("./log/bot.html", "A +");
}
$size = "<b> Current file size is:</b>". $filesize. " <br> "; reprint marked 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";
}