lopez86100 Posted April 14, 2007 Share Posted April 14, 2007 I've found php code that checks google PR. On my machine it works nice (PHP version 4). After switching it to PHP5 it started to generate another checksum and the same happens on my web server (three different versions of PHP and 3 different checksums) :/ The checksum is held in $ch variable. here is the code. <?php define('GOOGLE_MAGIC', 0xE6359A60); //unsigned shift right 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<<; $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]<< +($url[$k+2]<<16) +($url[$k+3]<<24)); $b += ($url[$k+4] +($url[$k+5]<< +($url[$k+6]<<16) +($url[$k+7]<<24)); $c += ($url[$k+8] +($url[$k+9]<< +($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]<<; /* 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]<<; 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]<<; 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<strlen($string);$i++) { $result[$i] = ord($string{$i}); } return $result; } function getrank($url) { $url = 'info:'.$url; $ch = GoogleCH(strord($url)); $file = "http://www.google.com/search?client=navclient-auto&ch=6$ch&features=Rank&q=$url"; $data = file($file); $rankarray = explode (':', $data[2]); $rank = $rankarray[2]; return $rank; } echo getrank("example.com"); ?> Quote Link to comment Share on other sites More sharing options...
Glyde Posted April 14, 2007 Share Posted April 14, 2007 Well, I can't give you a valid reason for why the algorithm would change on different PHP versions. What I can tell you is that what you are doing is technically illegal, not that you'll really get in trouble for it. Just letting you know; however, that using a "cracked" version of Google's toolbar algorithm is far against their copyrights. Quote Link to comment Share on other sites More sharing options...
AndyB Posted April 14, 2007 Share Posted April 14, 2007 http://www.google.com/codesearch?q=page+rank&hl=en&btnG=Search+Code Presumably code listed on Google's codesearch is OK to recycle. Quote Link to comment Share on other sites More sharing options...
Glyde Posted April 14, 2007 Share Posted April 14, 2007 http://www.google.com/codesearch?q=page+rank&hl=en&btnG=Search+Code Presumably code listed on Google's codesearch is OK to recycle. You can find crack websites on Google search, does that mean they're legal? You can find porn if you're 13 years old on Google...but guess what, it's still not legal. I think we can agree that Google does not and is unable to monitor all of their indexed pages. Just think about it logically, this script uses an algorithm that was intended for use only in the Google toolbar, hence why PR was never made public in the first place. Anyways, I'm not here to argue, I was just letting him know that it is in fact against Google's rules. If they didn't care, they wouldn't have made an algorithm in the first place, and would have made the page rank easier to access...but they didn't. They kept it within the toolbar and protected it with an algorithm. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.