Home > Backend Development > PHP Tutorial > 使用php记录用户通过搜索引擎进网站的关键词_PHP

使用php记录用户通过搜索引擎进网站的关键词_PHP

WBOY
Release: 2016-06-01 11:55:53
Original
1133 people have browsed it

复制代码 代码如下:
$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'=>'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)";
}

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template