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 the match to the MSIE, the acquisition of the number of the room in the array $regs $browser _ver = $regs [1]; } ElseIf (Preg_match ('/firefox/([^s]+)/I ', $agent, $regs)) { $browser = ' FireFox '; When matching to firefox/, get the number part 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 Quotes } Else { Return ' Unknow browser '; } } Judging whether it's a spider
function Is_spider ($record = true)//Judging whether it 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 ', ' Baiduspider+ ', ' MSNBot ', ' Yodaobot ', ' Yahoo! slurp; ', ' Yahoo! Slurp China; ', ' Iaskspider ', ' Sogou web Spider ', ' Sogou push spider ' ); $searchengine _name = Array ( ' GOOGLE ', ' GOOGLE ADSENSE ', ' BAIDU ', ' MSN ', ' Yodao ', ' YAHOO ', ' Yahoo China ', ' Iask ', ' SOGOU ', ' SOGOU ' ); $spider = Strtolower ($_server[' http_user_agent '); Turn user browser information into lowercase foreach ($searchengine _bot as $key = $value) { if (Strpos ($spider, $value)!== false)//absolute not equal to avoid the case where the string appears to be 0 { $spider = $searchengine _name[$key]; Returns the corresponding seo/seo.html "target=" _blank "> Search engine Name return $spider; } } $spider = "; Return '; } |