Get Google PR value of PHP code _php instance

Source: Internet
Author: User
Tags php code
Update Blog today after the program, suddenly found that the PR bar on Google Toolbar added a little, but has been the Google Toolbar on the PR because of the buffering problem, so that the current display of the PR value is not necessarily the current page of the PR value, so go check, find blog site (http:// mlsx.xplore.cn/) PR value rose to 3, but the home page (http://mlsx.xplore.cn) or 2. Rattling, celebrate.

But Glemir this morning told me his blog has been to 3, so I am a little jealous, and think of Rachel's blog, they update are not my diligent, but their PR basically do not need my poor. I have come to the conclusion of two personal comforts:

1 Rachel's PR is the same as mine, because his travel log is popular, I do not have his handwriting.

2 Glemir PR rose faster than mine, that is because he used a good blog program--wordpress

Haha, laugh at yourself.

To get to the point, posted on Google's PR value code, the statement is not I wrote, but modified, checksum algorithm for the time being not known.

Demo Code click here
Copy Code code as follows:

<?php
Define (' Google_magic ', 0xe6359a60);
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;
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)
{
Case: $c + + ($url [$k +10]<<24);
Case: $c + + ($url [$k +9]<<16);
Case 9: $c + + ($url [$k +8]<<8);
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]);
}
$mix = Mix ($a, $b, $c);
return $mix [2];
}

function Strord ($string) {
for ($i =0; $i <strlen ($string); $i + +) {
$result [$i] = Ord ($string {$i});
}
return $result;
}

function READPR ($link)
{
$fp = Fsockopen ("www.google.com", $errno, $errstr, 30);

if (! $fp)
{
echo "$errstr ($errno) \ n";
Exit (1);
}
Else
{
$out = "Get $link http/1.0\r\n";
$out. = "host:toolbarqueries.google.com\r\n";
$out. = "user-agent:mozilla/4.0 (compatible; Googletoolbar 2.0.114.9-big; Linux 2.6) \ r \ n ";
$out. = "connection:close\r\n\r\n";
Fwrite ($fp, $out);

do{
$line = fgets ($fp, 128);
}while ($line!== "\ r \ n");
$data = Fread ($fp, 8192);
Fclose ($FP);
return $data;
}
}

function Getpr ($url)
{
$url = ' info: '. $url;
$ch = Googlech (Strord ($url));
$data = READPR ("/search?client=navclient-auto&ch=6$ch&features=rank&q= $url");
$rankarray = Explode (': ', $data);
return $rankarray [2];
}

if (isset ($_post[' url ')) && $_post[' url ']!== ')
{
Echo ' PageRank: '. GETPR ($_post[' url '));
}
?>
<body>google PR Value Query <a href= ' Pr.phps ' > Get source code </a>

<form action= ' method= ' post ' ><br/>
Url:<input name= ' url ' value= ' http://' type= ' text ' size=40>
<input name= ' submit ' type= ' submit ' value= ' get PR ' >
</form></body>

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.