Function get_user_browser () { If (empty ($ _ SERVER ['http _ USER_AGENT ']) {// When the browser does not send the Visitor's Information Return ''; } $ Agent = $ _ SERVER ['http _ USER_AGENT ']; $ Browser = ''; $ Browser_ver = ''; If (preg_match ('/MSIEs ([^ s |;] +)/I', $ agent, $ regs )) { $ Browser = 'Internet Explorer '; // when MSIE is matched, the room that gets the number is in the array $ regs. $ Browser_ver = $ regs [1]; } Elseif (preg_match ('/FireFox/([^ s] +)/I', $ agent, $ regs )) { $ Browser = 'Firefox '; // When FireFox/is matched, obtain the digit that follows $ Browser_ver = $ regs [1]; } Elseif (preg_match ('/Maxthon/I', $ agent, $ regs )) { $ Browser = '(Internet Explorer'. $ browser_ver. ') Maxthon '; $ Browser_ver = ''; } Elseif (preg_match ('/Opera [s |/] ([^ s] +)/I', $ agent, $ regs )) { $ Browser = 'Opera '; $ Browser_ver = $ regs [1]; } Elseif (preg_match ('/OmniWeb/(v *) ([^ s |;] +)/I', $ agent, $ regs )) { $ Browser = 'omniweb '; $ Browser_ver = $ regs [2]; } Elseif (preg_match ('/Netscape ([d] *)/([^ s] +)/I', $ agent, $ regs )) { $ Browser = 'Netscape '; $ Browser_ver = $ regs [2]; } Elseif (preg_match ('/safari/([^ s] +)/I', $ agent, $ regs )) { $ Browser = 'Safari '; $ Browser_ver = $ regs [1]; } Elseif (preg_match ('/NetCaptors ([^ s |;] +)/I', $ agent, $ regs )) { $ Browser = '(Internet Explorer'. $ browser_ver. ') NetCaptor '; $ Browser_ver = $ regs [1]; } Elseif (preg_match ('/Lynx/([^ s] +)/I', $ agent, $ regs )) { $ Browser = 'Lynx '; $ Browser_ver = $ regs [1]; } If (! Empty ($ browser )) { Return addslashes ($ browser. ''. $ browser_ver); // escape quotation marks } Else { Return 'unknow browser '; } } Determine if it is a spider
Function is_spider ($ record = true) // You can check whether the image is a spider. { Static $ spider = NULL; If ($ spider! = NULL) { Return $ spider ;// } If (empty ($ _ SERVER ['http _ USER_AGENT ']) { $ Spider = ''; Return ''; } $ Searchengine_bot = array ( 'Googlebot ', 'Mediapartners-google ', 'Baidider Ider + ', 'Msnbot ', 'Yodaobot ', 'Yahoo! Slurp ;', 'Yahoo! Slurp china ;', 'Askspider ', 'Sogou web spider ', 'Sogou push spider' ); $ Searchengine_name = array ( 'Google ', 'Google adsens ', 'Baidu ', 'MSN ', 'Yodao ', 'Yahoo ', 'Yahoo China ', 'Iask ', 'Sogou ', 'Sogou' ); $ Spider = strtolower ($ _ SERVER ['http _ USER_AGENT ']); // Convert the user's browser information to lowercase letters. Foreach ($ searchengine_bot AS $ key => $ value) { If (strpos ($ spider, $ value )! = False) // The value is definitely not equal to the value of 0. { $ Spider = $ searchengine_name [$ key]; // return the corresponding seo/seo.html "target =" _ blank "> Search Engine Name Return $ spider; } } $ Spider = ''; Return ''; } |