From foreign programming Development Technology Forum code, the latest Google PR query tool Googlech function core code, get the latest Google PR value.
The code is as follows.
[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);
&nb sp; if ($z & $a)
{
& nbsp; $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;
while ($len >= 12) {
$a + + ($url [$k +0] + ($url [$k +1]<<8) + ($url [+2]<<16) + ($k [$url +3]<<24)];
$b + + ($url [$k +4] + ($url [$k +5]<<8) + ($url [+6]<<16) + ($k [$url +7]<<24)];
$c + + ($url [$k +8] + ($url [$k +9]<<8) + ($url [+10]<<16) + ($k [$url +11]<<24)];
$mix = Mix ($a, $b, $c);
$a = $mix [0]; $b = $mix [1]; $c = $mix [2];
$k + 12;
$len-= 12;
}
$c + + $length;
Switch ($len)/* All statements fall through * *
{
Case: $c + + ($url [$k +10]<<24);
Case: $c + + ($url [$k +9]<<16);
Case 9: $c + + ($url [$k +8]<<8);
/* the ' the ' of ' C is ' reserved for the length * *
Case 8: $b + + ($url [$k +7]<<24);
Case 7: $b + + ($url [$k +6]<<16);
Case 6: $b + + ($url [$k +5]<<8);
Case 5: $b + + ($url [$k +4]);
Case 4: $a + + ($url [$k +3]<<24);
Case 3: $a + + ($url [$k +2]<<16);
Case 2: $a + + ($url [$k +1]<<8);
Case 1: $a + + ($url [$k +0]);
/* Case 0:nothing left to add * *
}
$mix = Mix ($a, $b, $c);
* *--------------------------------------------The result
return $mix [2];
}
Converts a string into an array of integers containing the numeric value of the Char
function Strord ($string) {
for ($i =0; $i <strlen ($string); $i + +) {
$result [$i] = Ord ($string {$i});
}
return $result;
}
Converts an array of the bit integers into a array with 8 bit values. Equivalent to (BYTE *) Arr32
function C32to8bit ($arr 32) {
for ($i =0; $i <count ($arr); $i + +) {
for ($bitOrder = $i *4; $bitOrder <= $i *4+3; $bitOrder + +) {
$arr 8[$bitOrder]= $arr 32[$i]&255;
$arr 32[$i]=zerofill ($arr 32[$i], 8);
}
}
return $arr 8;
}
http://www.example.com/-checksum:6540747202
Print ("<b>url ... $url </b>\n");
$url = ' info: '. $url;
$ch = Googlech (Strord ($url));
$url _to_parse = sprintf ("http://toolbarqueries.google.com/search?client=navclient-auto&ch=6%u&ie= utf-8&oe=utf-8&q=%s ", $ch, $url);
$value = OBTAINPR (file_get_contents ($url _to_parse));
printf (<li> <u>checksum <2.0.114:</u> ...). 6%u ... <a href= $url _to_parse>link</a> .... PR = $value \ n ", $ch);
$ch =sprintf ("%u", $ch);
//New since Toolbar 2.0.114
$ch = ((($ch/7) << 2) (((int) fmod ($ch)));
$prbuf = Array ();
$prbuf [0] = $ch;
for ($i = 1; $i < $i + +) {
$prbuf [$i] = $prbuf [$i -1]-9;
}
$ch = Googlech (C32to8bit ($PRBUF), 80);
$url _to_parse = sprintf ("http://toolbarqueries.google.com/search?client=navclient-auto&ch=6%u&ie=UTF-8 &oe=utf-8&q=%s ", $ch, $url);
$value = OBTAINPR (file_get_contents ($url _to_parse));
//
printf ("<li> <u>checksum >=2.0.114:</u> ..... 6%u ... <a href= $url _to_parse>link</a> .... PR = $value \ n ", $ch);
? >[/code]