New technology beauty Search engine PHP judge search engine spider and automatically memory to the file code

Source: Internet
Author: User
Copy CodeThe code is 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 = "

<title>Access to view</title>

Delete Log
";
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 = "

<title>Access to view</title>

Delete Log
";
Fputs ($botfile, $fileHeader);
Fclose ($botfile);
}else {
$botfile =fopen ("./log/bot.html", "A +");
}
$size = "The current file size is:". $filesize."
"; Reproduced annotated 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";
}

The above introduces the new science and technology of beauty search engine PHP judge search engine spiders and automatically remember the code, including the new technology of beauty search engine aspects of the content, I hope that the PHP tutorial interested in a friend helpful.

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.