PHP记录用户通过搜索引擎进网站的关键词并给出相关结果
程序员文章站
2022-05-19 18:43:33
...
本文章给大家介绍PHP记录用户通过搜索引擎进网站的关键词并给出相关结果,有需要了解的同学可进入参考,下面是进入你网站的情况的相关实现代码,更多的,大家自己拓展,代码如下:
'word', 'google.com' => 'q', 'sina.com.cn' => 'word', 'sohu.com' => 'word', 'msn.com' => 'q', 'bing.com' => 'q', '163.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)"; } ?> 上面的代码实现不了根据用户来的词给出相关结果,下面我来再进行调上面的函数,代码如下: > 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; // 判断 if (isset($search_engines[$ref])) { $delim = $search_engines[$ref]; } return $delim; } function ls_get_refer() { // 判断前一页面的 URL 地址 $queryString = $_GET['referer']; $queryString = unescape($queryString); if (!isset($queryString) || ($queryString == '')) return false; $referer_info = parse_url($queryString); $referer = $referer_info['host']; //去除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 utf8 if (!yxiao_seems_utf8($terms)) { $terms = iconv("GBK", "UTF-8//IGNORE", $terms); } return $terms; } if (ls_getinfo('isref')) { document . write('');
本文地址:
转载随意,但请附上文章地址:-)
上一篇: 存储过程与触发器的应用