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

?php/** PNG图片接口文件** 那不是一个免费程序**
@开拓时间:20100109* @开发者:张旭
[email]cszx2007@gmail.com[/email]* @版本:1.0*
@版权:张旭持有*/interface zxpngInterface{ /*生成图片(图片宽度,
图片中度, 图片内容卡塔尔*/ function build($width, $height, $content);}/**
PNG图片生成程序** 那不是一个免费程序** @开垦时间:2010年7月8日
18:14* @开发者:zx* @版本:1.0* @版权:张旭持有*/class zxpng
implements zxpngInterface{ private $kernel; /* * 库主要调整文件 * * @var
kernel * @access private */ private $status; /* * 管理状态表明 * *
@var bool * @access private */ private $info; /* * png图片消息集结
* * @var array *澳门新葡亰平台游戏网站 , @access private */ public function
__construct($kernel) { $this-kernel = $kernel; } /*生成图片(图片宽度,
图片中度, 图片内容卡塔尔国*/ public function build($width, $height, $content)
{ self::createBackground($width, $height); $contentLength =
strlen($content); $table = self::table( ); $space = 12; for($i = 0; $i
$contentLength; $i++) { self::draw($table[$content[$i]], $width,
$height, $space); $space += 12; } self::crcTable( ); $data =
self::headTag( ); $data .= self::ihdr($width, $height); $data .=
self::idat($width, $height); $data .= self::iend( ); return($data); }
/*始建背景颜色(宽度, 中度卡塔尔*/ private function createBackground($width,
$height) { $rnd1 = mt_rand(90, 0); $rnd2 = mt_rand(90, 0); $rnd3 =
mt_rand(90, 0); $data = ”; for($i = 0; $i $height; $i++) { for($j = 0;
$j $width; $j++) { $data .= chr((($i * $j) + $width + $height + $rnd1)
255) . chr($rnd2 255) . chr($rnd3 255); } } return(self::save(‘img’,
$data)); } /*绘图像素点(x, y, 宽度, 高度, r, g, b, 像素大小State of Qatar*/ private
function drawPixel($x, $y, $width, $height, $r=0, $g=0, $b=0, $size=1) {
$img = self::read(‘img’); $offset = 3 * ($width * $y + $x); for($i =
0; $i $size;) { $img[$offset + $i] = chr($r); $i++; $img[$offset +
$i] = chr($g); $i++; $img[$offset + $i] = chr($b); $i++; }
return(self::save(‘img’, $img)); } /*绘制字符(字模, 宽度, 高度,
间距卡塔尔*/ private function draw($table, $width, $height, $space=16) {
for($i = 0; $i 16; $i++) { for($j = 0; $j 8; $j++) { if(($table[$i] (7

以下是不非亲非故系贯彻代码:

  • $j)) 0x01) { self::drawPixel($space + $j, $i + 2, $width, $height,
    255, 255, 255, 1); } } } return(true); } /*ascii码字模表*/ private
    function table( ) { $ascii = array ( ‘0’ =
    array(0x00,0x00,0x38,0x6C,0xC6,0xC6,0xD6,0xD6,0xC6,0xC6,0x6C,0x38,0x00,0x00,0x00,0x00),
    ‘1’ =
    array(0x00,0x00,0x18,0x38,0x78,0x18,0x18,0x18,0x18,0x18,0x18,0x7E,0x00,0x00,0x00,0x00),
    ‘2’ =
    array(0x00,0x00,0x7C,0xC6,0x06,0x0C,0x18,0x30,0x60,0xC0,0xC6,0xFE,0x00,0x00,0x00,0x00),
    ‘3’ =
    array(0x00,0x00,0x7C,0xC6,0x06,0x06,0x3C,0x06,0x06,0x06,0xC6,0x7C,0x00,0x00,0x00,0x00),
    ‘4’ =
    array(0x00,0x00,0x0C,0x1C,0x3C,0x6C,0xCC,0xFE,0x0C,0x0C,0x0C,0x1E,0x00,0x00,0x00,0x00),
    ‘5’ =
    array(0x00,0x00,0xFE,0xC0,0xC0,0xC0,0xFC,0x06,0x06,0x06,0xC6,0x7C,0x00,0x00,0x00,0x00),
    ‘6’ =
    array(0x00,0x00,0x38,0x60,0xC0,0xC0,0xFC,0xC6,0xC6,0xC6,0xC6,0x7C,0x00,0x00,0x00,0x00),
    ‘7’ =
    array(0x00,0x00,0xFE,0xC6,0x06,0x06,0x0C,0x18,0x30,0x30,0x30,0x30,0x00,0x00,0x00,0x00),
    ‘8’ =
    array(0x00,0x00,0x7C,0xC6,0xC6,0xC6,0x7C,0xC6,0xC6,0xC6,0xC6,0x7C,0x00,0x00,0x00,0x00),
    ‘9’ =
    array(0x00,0x00,0x7C,0xC6,0xC6,0xC6,0x7E,0x06,0x06,0x06,0x0C,0x78,0x00,0x00,0x00,0x00),
    ‘A’ =
    array(0x00,0x00,0x10,0x38,0x6C,0xC6,0xC6,0xFE,0xC6,0xC6,0xC6,0xC6,0x00,0x00,0x00,0x00),
    ‘B’ =
    array(0x00,0x00,0xFC,0x66,0x66,0x66,0x7C,0x66,0x66,0x66,0x66,0xFC,0x00,0x00,0x00,0x00),
    ‘C’ =
    array(0x00,0x00,0x3C,0x66,0xC2,0xC0,0xC0,0xC0,0xC0,0xC2,0x66,0x3C,0x00,0x00,0x00,0x00),
    ‘D’ =
    array(0x00,0x00,0xF8,0x6C,0x66,0x66,0x66,0x66,0x66,0x66,0x6C,0xF8,0x00,0x00,0x00,0x00),
    ‘E’ =
    array(0x00,0x00,0xFE,0x66,0x62,0x68,0x78,0x68,0x60,0x62,0x66,0xFE,0x00,0x00,0x00,0x00),
    ‘F’ =
    array(0x00,0x00,0xFE,0x66,0x62,0x68,0x78,0x68,0x60,0x60,0x60,0xF0,0x00,0x00,0x00,0x00),
    ‘G’ =
    array(0x00,0x00,0x3C,0x66,0xC2,0xC0,0xC0,0xDE,0xC6,0xC6,0x66,0x3A,0x00,0x00,0x00,0x00),
    ‘H’ =
    array(0x00,0x00,0xC6,0xC6,0xC6,0xC6,0xFE,0xC6,0xC6,0xC6,0xC6,0xC6,0x00,0x00,0x00,0x00),
    ‘I’ =
    array(0x00,0x00,0x3C,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x3C,0x00,0x00,0x00,0x00),
    ‘J’ =
    array(0x00,0x00,0x1E,0x0C,0x0C,0x0C,0x0C,0x0C,0xCC,0xCC,0xCC,0x78,0x00,0x00,0x00,0x00),
    ‘K’ =
    array(0x00,0x00,0xE6,0x66,0x66,0x6C,0x78,0x78,0x6C,0x66,0x66,0xE6,0x00,0x00,0x00,0x00),
    ‘L’ =
    array(0x00,0x00,0xF0,0x60,0x60,0x60,0x60,0x60,0x60,0x62,0x66,0xFE,0x00,0x00,0x00,0x00),
    ‘M’ =
    array(0x00,0x00,0xC6,0xEE,0xFE,0xFE,0xD6,0xC6,0xC6,0xC6,0xC6,0xC6,0x00,0x00,0x00,0x00),
    ‘N’ =
    array(0x00,0x00,0xC6,0xE6,0xF6,0xFE,0xDE,0xCE,0xC6,0xC6,0xC6,0xC6,0x00,0x00,0x00,0x00),
    ‘O’ =
    array(0x00,0x00,0x7C,0xC6,0xC6,0xC6,0xC6,0xC6,0xC6,0xC6,0xC6,0x7C,0x00,0x00,0x00,0x00),
    ‘P’ =
    array(0x00,0x00,0xFC,0x66,0x66,0x66,0x7C,0x60,0x60,0x60,0x60,0xF0,0x00,0x00,0x00,0x00),
    ‘Q’ =
    array(0x00,0x00,0x7C,0xC6,0xC6,0xC6,0xC6,0xC6,0xC6,0xD6,0xDE,0x7C,0x0C,0x0E,0x00,0x00),
    ‘R’ =
    array(0x00,0x00,0xFC,0x66,0x66,0x66,0x7C,0x6C,0x66,0x66,0x66,0xE6,0x00,0x00,0x00,0x00),
    ‘S’ =
    array(0x00,0x00,0x7C,0xC6,0xC6,0x60,0x38,0x0C,0x06,0xC6,0xC6,0x7C,0x00,0x00,0x00,0x00),
    ‘T’ =
    array(0x00,0x00,0x7E,0x7E,0x5A,0x18,0x18,0x18,0x18,0x18,0x18,0x3C,0x00,0x00,0x00,0x00),
    ‘U’ =
    array(0x00,0x00,0xC6,0xC6,0xC6,0xC6,0xC6,0xC6,0xC6,0xC6,0xC6,0x7C,0x00,0x00,0x00,0x00),
    ‘V’ =
    array(0x00,0x00,0xC6,0xC6,0xC6,0xC6,0xC6,0xC6,0xC6,0x6C,0x38,0x10,0x00,0x00,0x00,0x00),
    ‘W’ =
    array(0x00,0x00,0xC6,0xC6,0xC6,0xC6,0xD6,0xD6,0xD6,0xFE,0xEE,0x6C,0x00,0x00,0x00,0x00),
    ‘X’ =
    array(0x00,0x00,0xC6,0xC6,0x6C,0x7C,0x38,0x38,0x7C,0x6C,0xC6,0xC6,0x00,0x00,0x00,0x00),
    ‘Y’ =
    array(0x00,0x00,0x66,0x66,0x66,0x66,0x3C,0x18,0x18,0x18,0x18,0x3C,0x00,0x00,0x00,0x00),
    ‘Z’ =
    array(0x00,0x00,0xFE,0xC6,0x86,0x0C,0x18,0x30,0x60,0xC2,0xC6,0xFE,0x00,0x00,0x00,0x00),
    ‘a’ =
    array(0x00,0x00,0x00,0x00,0x00,0x78,0x0C,0x7C,0xCC,0xCC,0xCC,0x76,0x00,0x00,0x00,0x00),
    ‘b’ =
    array(0x00,0x00,0xE0,0x60,0x60,0x78,0x6C,0x66,0x66,0x66,0x66,0x7C,0x00,0x00,0x00,0x00),
    ‘c’ =
    array(0x00,0x00,0x00,0x00,0x00,0x7C,0xC6,0xC0,0xC0,0xC0,0xC6,0x7C,0x00,0x00,0x00,0x00),
    ‘d’ =
    array(0x00,0x00,0x1C,0x0C,0x0C,0x3C,0x6C,0xCC,0xCC,0xCC,0xCC,0x76,0x00,0x00,0x00,0x00),
    ‘e’ =
    array(0x00,0x00,0x00,0x00,0x00,0x7C,0xC6,0xFE,0xC0,0xC0,0xC6,0x7C,0x00,0x00,0x00,0x00),
    ‘f’ =
    array(0x00,0x00,0x38,0x6C,0x64,0x60,0xF0,0x60,0x60,0x60,0x60,0xF0,0x00,0x00,0x00,0x00),
    ‘g’ =
    array(0x00,0x00,0x00,0x00,0x00,0x76,0xCC,0xCC,0xCC,0xCC,0xCC,0x7C,0x0C,0xCC,0x78,0x00),
    ‘h’ =
    array(0x00,0x00,0xE0,0x60,0x60,0x6C,0x76,0x66,0x66,0x66,0x66,0xE6,0x00,0x00,0x00,0x00),
    ‘i’ =
    array(0x00,0x00,0x18,0x18,0x00,0x38,0x18,0x18,0x18,0x18,0x18,0x3C,0x00,0x00,0x00,0x00),
    ‘j’ =
    array(0x00,0x00,0x06,0x06,0x00,0x0E,0x06,0x06,0x06,0x06,0x06,0x06,0x66,0x66,0x3C,0x00),
    ‘k’ =
    array(0x00,0x00,0xE0,0x60,0x60,0x66,0x6C,0x78,0x78,0x6C,0x66,0xE6,0x00,0x00,0x00,0x00),
    ‘l’ =
    array(0x00,0x00,0x38,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x3C,0x00,0x00,0x00,0x00),
    ‘m’ =
    array(0x00,0x00,0x00,0x00,0x00,0xEC,0xFE,0xD6,0xD6,0xD6,0xD6,0xC6,0x00,0x00,0x00,0x00),
    ‘n’ =
    array(0x00,0x00,0x00,0x00,0x00,0xDC,0x66,0x66,0x66,0x66,0x66,0x66,0x00,0x00,0x00,0x00),
    ‘o’ =
    array(0x00,0x00,0x00,0x00,0x00,0x7C,0xC6,0xC6,0xC6,0xC6,0xC6,0x7C,0x00,0x00,0x00,0x00),
    ‘p’ =
    array(0x00,0x00,0x00,0x00,0x00,0xDC,0x66,0x66,0x66,0x66,0x66,0x7C,0x60,0x60,0xF0,0x00),
    ‘q’ =
    array(0x00,0x00,0x00,0x00,0x00,0x76,0xCC,0xCC,0xCC,0xCC,0xCC,0x7C,0x0C,0x0C,0x1E,0x00),
    ‘r’ =
    array(0x00,0x00,0x00,0x00,0x00,0xDC,0x76,0x66,0x60,0x60,0x60,0xF0,0x00,0x00,0x00,0x00),
    ‘s’ =
    array(0x00,0x00,0x00,0x00,0x00,0x7C,0xC6,0x60,0x38,0x0C,0xC6,0x7C,0x00,0x00,0x00,0x00),
    ‘t’ =
    array(0x00,0x00,0x10,0x30,0x30,0xFC,0x30,0x30,0x30,0x30,0x36,0x1C,0x00,0x00,0x00,0x00),
    ‘u’ =
    array(0x00,0x00,0x00,0x00,0x00,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0x76,0x00,0x00,0x00,0x00),
    ‘v’ =
    array(0x00,0x00,0x00,0x00,0x00,0x66,0x66,0x66,0x66,0x66,0x3C,0x18,0x00,0x00,0x00,0x00),
    ‘w’ =
    array(0x00,0x00,0x00,0x00,0x00,0xC6,0xC6,0xD6,0xD6,0xD6,0xFE,0x6C,0x00,0x00,0x00,0x00),
    ‘x’ =
    array(0x00,0x00,0x00,0x00,0x00,0xC6,0x6C,0x38,0x38,0x38,0x6C,0xC6,0x00,0x00,0x00,0x00),
    ‘y’ =
    array(0x00,0x00,0x00,0x00,0x00,0xC6,0xC6,0xC6,0xC6,0xC6,0xC6,0x7E,0x06,0x0C,0xF8,0x00),
    ‘z’ =
    array(0x00,0x00,0x00,0x00,0x00,0xFE,0xCC,0x18,0x30,0x60,0xC6,0xFE,0x00,0x00,0x00,0x00)
    ); return($ascii); } /*创建CRC校验表*/ private function crcTable( ) {
    $z = -306674912; // = 0xedb88320 for ($n = 0; $n 256; $n++) { $c = $n;
    for($k = 0; $k 8; $k++) { $c = ($c 1) ? $z ^ (($c 1) 0x7fffffff) : ($c
    1) 0x7fffffff; } $crcTable[$n] = $c; } return(self::save(‘crcTable’,
    $crcTable)); } /*png图片文件头*/ private function headTag( ) {
    return(pack(c*, 137, 80, 78, 71, 13, 10, 26, 10)); }
    /*IHD科雷傲数据块新闻(宽度, 中度State of Qatar*/ private function ihdr($width, $height)
    { $body = pack(c*, ($width 24) 255, ($width 16) 255, ($width 8) 255,
    $width 255, ($height 24) 255, ($height 16) 255, ($height 8) 255, $height
    255, self::depth( ), self::type( ), 0, 0, 0); return(self::chunk($body,
    IHDR)); } /*图像深度*/ private function depth( ) { return(8); }
    /*图像类型*/ private function type( ) { return(2); } /*数据块(数据,
    类型)*/ private function chunk($data, $type) { $len = strlen($data);
    $chunk = pack(c*, ($len 24) 255, ($len 16) 255, ($len 8) 255, $len 255)
    . $type . $data; $c = $z = 16777215 | 255 24; $chunkLength =
    strlen($chunk); $crcTable = self::read(‘crcTable’); for ($i = 4; $i
    $chunkLength; $i++) { $z8 = ($z 8) 0xffffff; $z = $crcTable[($z ^
    ord($chunk[$i])) 0xff] ^ $z8; } $crc = $c ^ $z; $chunk .= chr(($crc
    24) 255) . chr(($crc 16) 255) . chr(($crc 8) 255) . chr($crc 255);
    return($chunk); } /*IDAT数据块(宽度, 高度)*/ private function
    idat($width, $height) { $data = self::read(‘img’); $body = ”; $k = 0;
    for($h = 0; $h $height; $h++) { $body .= chr(0); for($w = 0; $w $width
    * 3; $w++) { $body .= $data[$k++]; } }
    return(self::chunk(self::idatHead($width, $height) . $body .
    self::adler($body), IDAT)); } /*IDAT头信息(宽度, 高度)*/ private
    function idatHead($width, $height) { $len = ($width * 3 + 1) *
    $height; return(pack(c*, 0x78, 0x01, 1, $len 255, ($len 8) 255, 255 –
    ($len 255), 255 – (($len 8) 255))); } /*测算adler32码(内容数据卡塔尔(قطر‎*/
    private function adler($data) { $dataLen = strlen($data); $s1 = 1; $s2 =
    0; for($i = 0; $i $dataLen; $i++) { $s1 = ($s1 + ord($data[$i])) %
    65521; $s2 = ($s2 + $s1) % 65521; } $adler = ($s2 16) | $s1;
    return(chr(($adler 24) 255) . chr(($adler 16) 255) . chr(($adler 8) 255)
    . chr($adler 255)); } /*iend*/ private function iend( ) {
    return(self::chunk(”, IEND)); } /*保存(字段名, 值)*/ private function
    save($field, $value) { $this-info[$field] = $value; return(true); }
    /*读取(字段名)*/ private function read($field) {
    return($this-info[$field]); } public function __destruct( ) { }}?

复制代码 代码如下:
/*
Plugin Name: display-search-keywords
Plugin URI:
Description:
当访客通过查找引擎来到你的博客,那几个插件能够显得访客找寻的首要词
Version: 1.0
Author:仰肖
*/
function unescape($str) {
 $ret = ”;
 $len = strlen($str);
 for ($i = 0; $i < $len; $i++) {
  if ($str[$i] == ‘%’ && $str[$i +1] == ‘u’) {
   $val = hexdec(substr($str, $i +2, 4));
   if ($val < 0x7f)
    $ret .= chr($val);
   else
    if ($val < 0x800)
     $ret .= chr(0xc0 | ($val >> 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() {
 // 决断前一页面包车型客车 U奥德赛L 地址
 $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 < $length; $i++) {
  $c = ord($str[$i]);
  if ($c < 0x80)
   $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 < $n; $j++) { # n bytes matching 10bbbbbb follow
?
   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”>;%20?%3E)
‘)
document.write(‘

<>’);

You can leave a response, or trackback from your own site.

Leave a Reply

网站地图xml地图