This article introduces PHP to record keywords that users enter the website through search engines and provides relevant results. if you need to know, you can go to the reference page, the following is the implementation code for accessing your website. For more information, see the code below :? Php $ rf... this article introduces PHP to record keywords that users enter the website through search engines and provides relevant results. if you need to know, you can go to the reference page, the following is the implementation code for accessing your website. For more information, see the code below:
'Word', 'google. com '=> 'Q', 'sina .com.cn' => 'word', 'sohu. com '=> 'word', 'MSN. com '=> 'Q', 'Bing. com '=> 'Q', '2017. com '=> 'Q', 'Yahoo. com '=> '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) ";}?> The above code does not provide relevant results based on the user's words. next I will call the above function. the code is as follows:
> 6 )). chr (0x80 | ($ val & 0x3f); else $ ret. = chr (0xe0 | ($ val> 12 )). chr (0x80 | ($ val> 6) & 0x3f )). chr (0x80 | ($ val & 0x3f); $ I + = 5;} else if ($ str [$ I] = '%') {$ ret. = urldecode (substr ($ str, $ I, 3); $ I + = 2;} else $ ret. = $ str [$ I];} return $ ret;} function ls_get_delim ($ ref) {$ search_engines = array ('Google .com.hk '=> 'Q ', 'Google .com.tw '=> 'Q', 'Go .google.com' => 'Q', 'google. com '=> 'Q', 'blogsearch .google.com '=> 'Q', 'CN .bing.com' => 'Q', 'One .cn.yahoo.com '=> 'P', 'Baidu. com '=> 'wd', 'soso. com '=> 'W', 'youdao. com '=> 'Q', 'sogou. com '=> 'query'); $ delim = false; // judge if (isset ($ search_engines [$ ref]) {$ delim = $ search_engines [$ ref];} return $ delim;} function ls_get_refer () {// Determine the URL address of the previous page $ queryString =$ _ GET ['referer']; $ queryString = unescape ($ queryString); if (! Isset ($ queryString) | ($ queryString = '') return false; $ referer_info = parse_url ($ queryString); $ referer = $ referer_info ['host']; // Remove www. if (substr ($ referer, 0, 4) = 'www. ') $ referer = substr ($ referer, 4); return $ referer;} function ls_getinfo ($ what) {$ referer = ls_get_refer (); if (! $ Referer) return false; $ delimiter = ls_get_delim ($ referer); if ($ delimiter) {$ terms = ls_get_terms ($ delimiter ); if ($ what = 'isref '& $ terms! = '') {Return true;} if ($ what = 'terms') {echo $ terms;} return false;} function yxiao_seems_utf8 ($ str) {$ length = strlen ($ str); for ($ I = 0; $ I <$ length; $ I ++) {$ c = ord ($ str [$ I]); if ($ c <0x80) $ n = 0; // 0 bbbbbbb elseif ($ c & 0xE0) = 0xC0) $ n = 1; // 110 bbbbb elseif ($ c & 0xF0) = 0xE0) $ n = 2; // 1110 bbbb elseif ($ c & 0xF8) = 0xF0) $ n = 3; // 11110bbb elseif ($ c & 0xFC) = 0xF8) $ N = 4; // 111110bb elseif ($ c & 0xFE) = 0xFC) $ n = 5; // 1111110b else return false; // Does not match any model for ($ j = 0; $ j <$ n; $ j ++) {// n bytes matching 10 bbbbbb follow? If (+ + $ I = $ length) | (ord ($ str [$ I]) & 0xC0 )! = 0x80) return false;} return true;} function ls_get_terms ($ d) {// Obtain the query value $ queryString = $ _ GET ['referer']; $ queryString = unescape ($ queryString); $ query_str = parse_url ($ queryString); parse_str ($ query_str [query], $ query_str); $ query = $ query_str [$ d]; $ query = urldecode ($ query); $ query = str_replace ("'", '', $ query); $ query = str_replace ('"','', $ query); $ query_array = preg_split ('/[s, +.] +/', $ qu Ery); $ query_terms = implode ('', $ query_array); $ terms = htmlspecialchars ($ query_terms); // gbk-> utf8 if (! Yxiao_seems_utf8 ($ terms) {$ terms = iconv ("GBK", "UTF-8 // IGNORE", $ terms);} return $ terms ;} if (ls_getinfo ('isref ') {document. write ('') Document. write (' more search results: ') Document. write ('
'); <? Php}
Address:
Reprinted at will, but please attach the article address :-)