This article introduces, PHP implementation can record search engine Routing and keyword of a piece of code, there is a need for friends reference. Code:
' Baidu ', ' Google. ' = ' Google ', ' Soso. ' = ' Search ', ' Sogou. ' = ' Sogou ', ' www.so.com ', ' ['] ', '/wd= ' (' baidu ' = ' ^&]* '//') ', ' google ' = '/q= ' ([^&]*)/I ', ' =array ') ' = ' '/q= (. *)/I ', ' sogou ' = '/query= ' ([^&]*)/I ', ' search ' = ' = '/w= ([^&]*)/I '); foreach ($spier as $k + $v) {if (Strpos ( $url, $k) {Preg_match ("{$q [$v]}", $url, $b); if ($v = = ' Search ' | | $v = = ' Sogou ') {$keywords =iconv (' GBK ', ' UTF-8 ', UrlDecode ($b [1])); }else{$keywords =urldecode ($b [1]);} echo "keyword from {$v}:". $keywords;}}} $url =$_server[' Http_referer ']; This is put to the head of the website to get the visiting address of Keywords ($url);//record user search engine keyword code//record users through common search engine search keywords $rfr = $_server[' Http_referer '];//if (! $rfr $RFR = ' http://'. $_server[' Http_host '];if ($RFR) {$p =parse_url ($RFR); Parse_str ($p [' query '], $PA); $p [' HOST ']= Strtolower ($p [' Host ']); $arr _sd_key=array (' baidu.com ' = ' word ', ' google.com ' and ' Q ', ' sina.com.cn ' = ' word ', ' sohu.com ' + ' word ', ' MSN.com ' + ' Q ', ' bing.com ' = ' Q ', ' 163.com ' = ' Q ', ' yahoo.com ' and ' P '; $keyword = "; $sengine = $p [' Host ']; foreach ($arr _sd_Key as $se = = $KWD) {if (Strpos ($p [' Host '], $se)!==false) {$keyword = $pa [$KWD]; $sengine = $se; break;}} $sql = "INSERT INTO Visit_log (DOMAIN,KEY_WORD,CT) ";}? > |