您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

使用php显示搜索引擎来的关键词_PHP教程

2024/5/27 2:28:41发布16次查看
以下是相关实现代码:
复制代码 代码如下:
> 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   $c = ord($str[$i]);
  if ($c    $n = 0; # 0bbbbbbb
  elseif (($c & 0xe0) == 0xc0) $n = 1; # 110bbbbb
  elseif (($c & 0xf0) == 0xe0) $n = 2; # 1110bbbb
  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    if ((++ $i == $length) || ((ord($str[$i]) & 0xc0) != 0x80))
    return false;
  }
 }
 return true;
}
function ls_get_terms($d) {
 //取得查询值
 $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,\+\.]+/', $query);
 $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('更多搜索结果:document.write('title=查看的搜索结果 rel=nofollow>')
document.write('
');
http://www.bkjia.com/phpjc/735237.htmlwww.bkjia.comtruehttp://www.bkjia.com/phpjc/735237.htmltecharticle以下是相关实现代码: 复制代码 代码如下: ?php /* plugin name: display-search-keywords plugin uri: http://www.imyxiao.com/1531.html description: 当访客通过搜索...
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product