Recently has been busy friends chain, but also the opportunity to learn about PR value related knowledge, try to implement PR query PHP.
Google PR value is what this does not do too much introduction, simply say is your PR value higher representative of your site more important more popular, but the highest value of 10, the following code can get a website PR value.
The main code to get the PR value of a website using PHP script is as follows:
The procedure is as follows: <?php
$googlehost = "toolbarqueries.google.com";
$googleua = "mozilla/5.0" (Windows; U Windows NT 5.1; En-us; rv:1.8.0.6) gecko/20060728 firefox/1.5 ";
Echo GETPR
Convert a string to a 32-bit integer
function Strtonum ($Str, $Check, $Magic) {
$Int 32Unit = 4294967296; 2^32
$length = strlen ($STR);
for ($i = 0; $i < $length; $i + +) {
$Check *= $Magic;
If the float is beyond the boundaries of integer (usually-+-2.15e+9 = 2^31),
The result of converting to the-integer is undefined
Refer to Php.net/manual/en/language.types.integer.php
if ($Check >= $Int 32Unit) {
$Check = ($Check-$Int 32Unit * (int) ($Check/$Int 32Unit));
If the check less than-2^31
$Check = ($Check <-2147483648)? ($Check + $Int 32Unit): $Check;
}
$Check + + ord ($Str {$i});
}
return $Check;
}
Genearate a hash for a URL
function Hashurl ($String) {
$Check 1 = strtonum ($String, 0x1505, 0x21);
$Check 2 = strtonum ($String, 0, 0x1003f);
$Check 1 "= 2;
$Check 1 = (($Check 1, 4) & 0X3FFFFC0) ($Check 1 & 0x3f);
$Check 1 = (($Check 1, 4) & 0X3FFC00) ($Check 1 & 0x3ff);
$Check 1 = (($Check 1, 4) & 0x3c000) ($Check 1 & 0x3fff);
$T 1 = ((($Check 1 & 0x3c0) 4) ($Check 1 & 0x3c)) (2) ($Check 2 & 0xf0f);
$T 2 = ((($Check 1 & 0xffffc000) 4) ($Check 1 & 0x3c00)) 0xA ($Check 2 & 0xf0f0000);
Return ($T 1 $T 2);
}
Genearate a checksum for the hash string
function Checkhash ($Hashnum) {
$CheckByte = 0;
$Flag = 0;
$HASHSTR = sprintf ('%u ', $Hashnum);
$length = strlen ($HASHSTR);
for ($i = $length-1; $i >= 0; $i –) {
$Re = $HashStr {$i};
if (1 = = ($Flag% 2)) {
$Re + + $Re;
$Re = (int) ($Re/10) + ($Re% 10);
}
$CheckByte + + $Re;
$Flag + +;
}
$CheckByte%= 10;
if (0!== $CheckByte) {
$CheckByte = 10-$CheckByte;
if (1 = = ($Flag% 2)) {
if (1 = = ($CheckByte% 2)) {
$CheckByte + 9;
}
$CheckByte "= 1;
}
}
Return "7" $CheckByte. $HashStr;
}