PHP judges whether the visitor is a spider or a common user

Source: Internet
Author: User

Prepare for formal SEO. The black chain code is still used, but it is a little special. Of course, test whether it is feasible first.
You need to get a PHP document to record whether the visitor is a spider or a common user. Specifically, it is determined based on php's $ _ SERVER ['HTTP _ USER_AGENT '].
The Code is as follows:
 
<? Php
$ Tmp = $ _ SERVER ['HTTP _ USER_AGENT '];
If (strpos ($ tmp, 'googlebot ')! = False ){
Echo 'Google ';
} Else if (strpos ($ tmp, 'baidider ider ')> 0 ){
Echo 'Baidu ';
} Else if (strpos ($ tmp, 'yahoo! Slurp ')! = False ){
Echo 'yahoo ';
} Else if (strpos ($ tmp, 'msnbot ')! = False ){
Echo 'msn ';
} Else if (strpos ($ tmp, 'sosospider ')! = False ){
Echo 'search ';
} Else if (strpos ($ tmp, 'yodaobot ')! = False | strpos ($ tmp, 'outfoxbot ')! = False ){
Echo 'youdao ';
} Else if (strpos ($ tmp, 'sogou web spider ')! = False | strpos ($ tmp, 'sogou Orion spider ')! = False ){
Echo 'sogou ';
} Else if (strpos ($ tmp, 'fast-webcrawler ')! = False ){
Echo 'alltheweb ';
} Else if (strpos ($ tmp, 'gaisbot ')! = False ){
Echo 'gaais ';
} Else if (strpos ($ tmp, 'ia _ archiver ')! = False ){
Echo 'Alexa ';
} Else if (strpos ($ tmp, 'altavista ')! = False ){
Echo 'maid ';
} Else if (strpos ($ tmp, 'lycos _ spider ')! = False ){
Echo 'lycos ';
} Else if (strpos ($ tmp, 'inktomi slurp ')! = False ){
Echo 'inktomi ';
}
?>
The following are from Baidu, of course, Baidu. I am only responsible for the article "pseudo-original"
 
Www.2cto.com

<? Php
$ Flag = false;
$ Tmp = $ _ SERVER ['HTTP _ USER_AGENT '];
If (strpos ($ tmp, 'googlebot ')! = False ){
$ Flag = true;
} Else if (strpos ($ tmp, 'baidider ider ')> 0 ){
$ Flag = true;
} Else if (strpos ($ tmp, 'yahoo! Slurp ')! = False ){
$ Flag = true;
} Else if (strpos ($ tmp, 'msnbot ')! = False ){
$ Flag = true;
} Else if (strpos ($ tmp, 'sosospider ')! = False ){
$ Flag = true;
} Else if (strpos ($ tmp, 'yodaobot ')! = False | strpos ($ tmp, 'outfoxbot ')! = False ){
$ Flag = true;
} Else if (strpos ($ tmp, 'sogou web spider ')! = False | strpos ($ tmp, 'sogou Orion spider ')! = False ){
$ Flag = true;
} Else if (strpos ($ tmp, 'fast-webcrawler ')! = False ){
$ Flag = true;
} Else if (strpos ($ tmp, 'gaisbot ')! = False ){
$ Flag = true;
} Else if (strpos ($ tmp, 'ia _ archiver ')! = False ){
$ Flag = true;
} Else if (strpos ($ tmp, 'altavista ')! = False ){
$ Flag = true;
} Else if (strpos ($ tmp, 'lycos _ spider ')! = False ){
$ Flag = true;
} Else if (strpos ($ tmp, 'inktomi slurp ')! = False ){
$ Flag = true;
}
If ($ flag = false ){
Header ("Location: http://www.hao123.com". $ _ SERVER ['request _ URI ']);
// Automatically go to the page corresponding to the http://www.hao123.com
// $ _ SERVER ['request _ URI '] indicates the path after the Domain Name
// Or change to header ("Location: http://www.hao123.com/abc/d.php ");
Exit ();
}
?>

From http://www.xssxss.com/fuck/505.xss

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.