日期:2012-05-19 浏览次数:20559 次
取自国外编程开发技术论坛里的代码,最新Google PR查询工具GoogleCH函数核心代码,获取最新的GOOGLE PR值.
代码如下.
[code]<?php
define('GOOGLE_MAGIC', 0xE6359A60);
function obtainPR($data)
{
$ret = array();
$parser = xml_parser_create();
xml_parser_set_option($parser,XML_OPTION_CASE_FOLDING,0);
xml_parser_set_option($parser,XML_OPTION_SKIP_WHITE,1);
xml_parse_into_struct($parser,$data,$values,$tags);
xml_parser_free($parser);
$hash_stack = array();
foreach ($values as $key => $val)
{
switch ($val['type'])
{
case 'complete':
array_push($hash_stack, $val['tag']);
$type = implode($hash_stack, "][");
if ($type == "RK")
{
$PageRank = $val[value];
}
array_pop($hash_stack);
break;
}//swhitch
}//foreach
return $PageRank;
}//obtainPR
//unsigned shift right
function zeroFill($a, $b)
{
$z = hexdec(80000000);
if ($z & $a)
{
$a = ($a>>1);
$a &= (~$z);
$a = 0x40000000;
$a = ($a>>($b-1));
}
else
{
$a = ($a>>$b);
}
return $a;
}
function mix($a,$b,$c) {
$a -= $b; $a -= $c; $a ^= (zeroFill($c,13));
$b -= $c; $b -= $a; $b ^= ($a<<8);
$c -= $a; $c -= $b; $c ^= (zeroFill($b,13));
$a -= $b; $a -= $c; $a ^= (zeroFill($c,12));
$b -= $c; $b -= $a; $b ^= ($a<<16);
$c -= $a; $c -= $b; $c ^= (zeroFill($b,5));
$a -= $b; $a -= $c; $a ^= (zeroFill($c,3));
$b -= $c; $b -= $a; $b ^= ($a<<10);
$c -= $a; $c -= $b; $c ^= (zeroFill($b,15));
return array($a,$b,$c);
}
function GoogleCH($url, $length=null, $init=GOOGLE_MAGIC) {
if(is_null($length)) {
$length = sizeof($url);
}
$a = $b = 0x9E3779B9;
$c = $init;
$k = 0;
$len = $length;