Get Google official PR php source code

Source: Internet
Author: User
Sweet... ihackeditfurtherandputaformfieldintheresoyoucanpunchtheurltobecheckedinclutheform. mismatch, dropaline. lookforwardtoseehowthiswor Google

Sweet ..

I hacked it further and put a form field in there so you can punch the url to be checked into the form.

Im only a newbie php whiz so any if any of the pros see anything that needs some attention, drop a line.

Look forward to see how this works for everyone.

PHP Code:


If (isset ($ _ GET ['getpr']) {


// Edit this to your website url:
$ MyWebSite = ($ _ POST ['URL']);

Define ('gmag', 0xE6359A60 );

// Unsigned shift right
Function zeroFill ($ a, $ B)
{
$ Z = hexdec (80000000 );
If ($ z & $)
{
$ A = ($ a> 1 );
$ A & = (~ $ Z );
$ A | = 0x40000000;
$ A = ($ a >>( $ B-1 ));
}
Else
{
$ A = ($ a >>$ B );
}
Return $;
}


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 GCH ($ url, $ length = null, $ init = GMAG ){
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 [$ k + 2] <16) + ($ url [$ k + 3] <24 ));
$ B + = ($ url [$ k + 4] + ($ url [$ k + 5] <8) + ($ url [$ k + 6] <16) + ($ url [$ k + 7] <24 ));
$ C + = ($ url [$ k + 8] + ($ url [$ k + 9] <8) + ($ url [$ k + 10] <16) + ($ url [$ k + 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 the case statements fall through */
{
Case 11: $ c ++ = ($ url [$ k + 10] <24 );
Case 10: $ c ++ = ($ url [$ k + 9] <16 );
Case 9: $ c ++ = ($ url [$ k + 8] <8 );
/* The first byte 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 );
/* ------------------------------------------ Report 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 $ Result [$ I] = ord ($ string {$ I });
}
Return $ result;
}

Function getPR ($ _ url ){
$ Url = 'info: '. $ _ url;
$ Ch = GCH (strord ($ url ));
$ Url = 'info: '. urlencode ($ _ url );
$ Pr = file ("http://www.google.com/search? Client = navclient-auto & ch = 6 $ ch & ie = UTF-8 & oe = UTF-8 & features = Rank & q = $ url ");
$ Pr_str = implode ("", $ pr );
Return substr ($ pr_str, strrpos ($ pr_str, ":") + 1 );
}

Echo"
The PR of ". $ myWebSite." is: ". getPR ($ myWebSite );
Echo"
Click here to Check another URL ";

} Else {

Echo"Enter URL to check PR (include http ://)";
Echo "";
}
?>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.