Recently, I have been busy with friends chain. I also took the opportunity to learn about PR value and tried to use PHP to implement PR query. What is the GooglePR value? I will not introduce it too much here. Simply put, the higher your PR value, the more important your website is, the more popular it is, but the highest value is 10, the following code can be obtained... "> <LINKhref =" http://www.php100.com//statics/sty
Recently, I have been busy with friends chain. I also took the opportunity to learn about PR value and tried to use PHP to implement PR query.
What is the Google PR value? I will not introduce it too much here. Simply put, the higher your PR value, the more important your website is, the more popular it is, but the highest value is 10, the following code obtains the prvalue of a website.
The main code for getting the prvalue of a website using the PHP script is as follows:
The procedure is as follows:$ 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 ){
$ Int32Unit = 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 integer is undefined
// Refer to php.net/manual/en/language.types.integer.php
If ($ Check >=$ Int32Unit ){
$ Check = ($ Check-$ Int32Unit * (int) ($ Check/$ Int32Unit ));
// If the check less than-2 ^ 31
$ Check = ($ Check <-2147483648 )? ($ Check + $ Int32Unit): $ Check;
}
$ Check + = ord ($ Str {$ I });
}
Return $ Check;
}
// Genearate a hash for a url
Function HashURL ($ String ){
$ Check1 = StrToNum ($ String, 0 × 1505, 0 × 21 );
$ Check2 = StrToNum ($ String, 0, 0 × 1003F );
$ Check1 "= 2;
$ Check1 = ($ Check1 4) & 0 × 3FFFFC0) | ($ Check1 & 0 × 3F );
$ Check1 = ($ Check1 4) & 0 × 3FFC00) | ($ Check1 & 0 × 3FF );
$ Check1 = ($ Check1 4) & 0 × 3C000) | ($ Check1 & 0 × 3FFF );
$ T1 = ($ Check1 & 0 × 3C0) "4) | ($ Check1 & 0 × 3C)" 2) | ($ Check2 & 0xF0F );
$ T2 = ($ Check1 & 0xFFFFC000) 4) | ($ Check1 & 0 × 3C00) 0xA) | ($ Check2 & 0xF0F0000 );
Return ($ T1 | $ T2 );
}
// 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;
}