View Single Post
Old 06-29-2004, 07:16 AM   #116
Unregistered
Nameless Being
 
Updated by Alex and Bill Zeller.

PHP Code:
<?php
header
("Content-Type: text/plain; charset=utf-8");
/*
* Written by Alex Stapleton
*
* With thanks to Vijay "Cyberax" Bhatter
*   and Andy Doctorow. Probably wouldn't
*   of been possible without their input.
*  
*  PHP code reduction and minor error
*   checking by Bill Zeller
*
*  This code is released into the public domain.
*/

function shr($a$b){ // unsigned shift right
    
return (2147483648 $a)?((($a>>1) & 
~
2147483648)|0x40000000)>>($b-1):($a>>$b);
}

function 
mix(&$x) {
  for(
$a=array(array(13,8,13),array(12,16,5),array(3,10,15)),$i=0;$i<3;$i++)
    for(
$j=0;$j<3;$j++,$d=$x[0]<<($a[$i][1]))
      
$x[$j]=($x[$j]-$x[($j+1)%3]-$x[($j+2)%3])^($j==1?$d:shr($x[($j+2)%3],$a[$i][$j]));
}

function 
GoogleCH($url) {
    
$url array_slice(unpack('c*','info:'.$url),0);
    
$x = array(0x9E3779B90x9E3779B90xE6359A60);
    for(
$k=0,$len=$length=sizeof($url);$len>=12;$k+=12,$len-=12){
        
$u=array_slice($url,$k);
        for(
$i=0;$i<4;$i++)
            for(
$j=0;$j<3;$j++)
                
$x[$j] += $u[$j*4+$i]<<(8*$i);
        
mix($x);
    }
    
$u array_slice($url,$k);
    for(
$l=$len,$x[2]+=$length,$i=0;$i<&& $l<12;$i++)
        for(
$j=0;$j<3;$j++)
            
$x[$j]+=$l>($j*4+$i)?$u[$j*4+$i]<<(8*$i):0;
    
mix($x);
    return 
sprintf('6%u'$x[2]);
}

// [url]http://www.example.com/[/url] - Checksum: 6540747202
$url $_GET['url'];
echo 
"url:\t$url\n";
$ch GoogleCH($url);
echo 
"ch:\t$ch\n";
$url 'info:'.urlencode($url);
$link 
"http://www.google.com/search?client=navclient-auto&ch=6$ch&ie=UTF-8&oe=UTF-8&features=Rank&q=$url";
print(
"\n\nPage Rank URL: $link");
?>
  Reply With Quote