lobas Posted December 31, 2006 Share Posted December 31, 2006 I have this script in php which gives me this error, this script checks google for page rank of a site, it works if i run this in xampp on localhost but not on my webhost,this is the error:toolbarqueries.google.com Warning: file(http://toolbarqueries.google.com/search?client=navclient-auto&ch=61146224719&features=Rank&q=info:http://site.com) [function.file]: failed to open stream: HTTP request failed! HTTP/1.0 403 Forbidden in /home/lobas/public_html/check-pagerank/footer.php on line 116[code]<?php/* This code is released unto the public domain This code was modified by Andrew Smith (http://o.thisdomainwasfree.com)*///Configuration// You can add or remove data centres here$DataCentres=array('toolbarqueries.google.com','64.233.161.99','64.233.167.99','64.233.179.99','66.102.7.99','66.102.9.99','66.102.11.99','72.14.207.99','216.239.37.99','216.239.39.99','216.239.53.99','216.239.57.99','216.239.59.99');?><HTML><HEAD><TITLE>Page Rank Checker</TITLE><STYLE TYPE="text/css">BODY,TABLE { font-family: Verdana; font-size: 11px;}</STYLE><BODY><div align="center"><h1>Page Rank Checker</h1><?phpdefine('GOOGLE_MAGIC', 0xE6359A60);//unsigned shift rightfunction 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[$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 charfunction strord($string) { for($i=0;$i<strlen($string);$i++) { $result[$i] = ord($string{$i}); } return $result;}function getrank($url,$dc) {$url = 'info:'.$url;$ch = GoogleCH(strord($url));$file = "http://".$dc."/search?client=navclient-auto&ch=6$ch&features=Rank&q=$url";$data = file($file);$rankarray = explode (':', $data[2]);$rank = $rankarray[2];return $rank;}?><form action="" method="POST">URL: <input type="text" name="url" /><input type="submit" value="rank" /></form><br /><?phpif($_POST['url']){ ?> <table border="0" cellspacing="1" cellpadding="3" align="center" width="300"> <tr bgcolor="#EEEEEE"><td align="center" width="200"><b>Data Centre</b></td><td colspan="2" width="100" align="center"><b>Page Rank</b></td></tr> <?Php if(substr($_POST['url'],0,7)!="http://") { $url="http://".$_POST['url']; } else { $url=$_POST['url']; } foreach($DataCentres as $dc) { ?> <tr><td><?php echo $dc; ?></td><td align='center'><?php echo getrank($url,$dc); ?></td></tr> <?php } ?> </table> <?php} else{ ?> <?php}?><!-- It would be nice if you left this link back in, but you don't have to :)--><p style="font-size: 9px;">Created by <a href="http://o.thisdomainwasfree.com">Andrew Smith</a></p></div></BODY></HTML>[/code] Link to comment https://forums.phpfreaks.com/topic/32331-php-error-with-page-rank-script/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.