|
||||||||||
|
|||||||
| GoogleCommunity Sponsor |
Use coupon "forum" for 50% Off! |
![]() |
|
|
LinkBack | Thread Tools | Display Modes |
|
|
#1 (permalink) |
|
Noogle
![]() Join Date: Sep 2006
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
![]() |
PageRank Lookup PHP Script - Error 403
I have the php script that used to be on this site, but I modified it a little. The site says that there are some problems on certain servers I was wondering what that was down to.brbrFor some reason when I use the script I appear to get the a 403 error from google, however the ch that is generated seems to be incorrect compaired to the one generated by the pagerank in the toolbar.brbrhere is the code I am using:br
Code:
<?phpbr/ageRank Lookup v0.2br//original: http://www.googlecommunity.com/s/google-pagerank.phpbrbr$googlehost="toolbarqueries.google.com];brbrdefine('GOOGLE_MAGIC', 0xE6359A60); brbr//unsigned shift right brfunction zeroFill($a, $b) br{ br $z = hexdec(80000000); //echo $z;br if ($z & $a) br { br $a = ($a>>1); br $a &= (~$z); br $a |= 0x40000000; br $a = ($a>>($b-1)); br } br else br { br $a = ($a>>$b); br } br return $a; br}brbrfunction mix($a,$b,$c) { br $a -= $b; $a -= $c; $a ^= (zeroFill($c,13)); br $b -= $c; $b -= $a; $b ^= ($a<<8); br $c -= $a; $c -= $b; $c ^= (zeroFill($b,13)); br $a -= $b; $a -= $c; $a ^= (zeroFill($c,12)); br $b -= $c; $b -= $a; $b ^= ($a<<16); br $c -= $a; $c -= $b; $c ^= (zeroFill($b,5)); br $a -= $b; $a -= $c; $a ^= (zeroFill($c,3)); br $b -= $c; $b -= $a; $b ^= ($a<<10); br $c -= $a; $c -= $b; $c ^= (zeroFill($b,15)); br br return array($a,$b,$c); brbr} brbrfunction GoogleCH($url, $length=null, $init=GOOGLE_MAGIC) { br if(is_null($length)) { br $length = sizeof($url); br } br $a = $b = 0x9E3779B9; br $c = $init;br $k = 0; br $len = $length; br while($len >= 12) { br $a += ($url[$k+0] +($url[$k+1]<<8) +($url[$k+2]<<16) +($url[$k+3]<<24)); br $b += ($url[$k+4] +($url[$k+5]<<8) +($url[$k+6]<<16) +($url[$k+7]<<24)); br $c += ($url[$k+8] +($url[$k+9]<<8) +($url[$k+10]<<16)+($url[$k+11]<<24)); br $mix = mix($a,$b,$c); br $a = $mix[0]; $b = $mix[1]; $c = $mix[2]; br $k += 12; br $len -= 12; br } brbr $c += $length; br switch($len) /* all the case statements fall through */ br { br case 11: $c+=($url[$k+10]<<24); br case 10: $c+=($url[$k+9]<<16); br case 9 : $c+=($url[$k+8]<<8); br /* the first byte of c is reserved for the length */ br case 8 : $b+=($url[$k+7]<<24); br case 7 : $b+=($url[$k+6]<<16); br case 6 : $b+=($url[$k+5]<<8); br case 5 : $b+=($url[$k+4]); br case 4 : $a+=($url[$k+3]<<24); br case 3 : $a+=($url[$k+2]<<16); br case 2 : $a+=($url[$k+1]<<8); br case 1 : $a+=($url[$k+0]); br /* case 0: nothing left to add */ br }br $mix = mix($a,$b,$c); //echo $mix[0];br //report resultbr return $mix[2]; br} brbr//converts a string into an array of integers containing the numeric value of the char brfunction strord($string) { br for($i=0;$i<strlen($string);$i++) { br $result[$i] = ord($string{$i}); br } br return $result; brbr}brbr//http://www.example.com/ == 6540747202 brbrfunction getch($url) {br return "6" . GoogleCH(strord("info:" . $url));br}brbrfunction getpr($url) {br global $googlehost;br $ch = getch($url);br $fp = fsockopen($googlehost, 80, $errno, $errstr, 30);br if ($fp) {br $out = "GET /search?client=navclient-auto&ch=$ch&features=Rank&q=info:$url HTTP/1.1\r\n";br echo "<pre>$out</pre>\n";br $out .= "User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.0.6) Gecko/20060728 Firefox/1.5.0.6\r\n";br $out .= "Host: $googlehost\r\n";br $out .= "Connection: Close\r\n\r\n";br br fwrite($fp, $out);br br //$pagerank = substr(fgets($fp, 128), 4);br //echo $pagerank;br while (!feof($fp)) {br $data = fgets($fp, 128);br echo $data;br $pos = strpos($data, "Rank_");br if($pos === false){} else{br $pagerank = substr($data, $pos + 9);br return $pagerank;br }br }br //else { echo "$errstr ($errno)<br />\n"; }br fclose($fp);br } //echo "ch: 6".$ch;br}brbrfunction pagerank($url) {br $pr=str_replace("\n","",getpr($url));br $prpos=40*$pr/10;br $prneg=40-$prpos;br $pagerank="PageRank: $pr/10";br return '<a href="'.$url.'" title="'.$pagerank.'"><img src="http://www.google.com/images/pos.gif" width='.$prpos.' height=4 border=0 alt="'.$pagerank.'"><img src="http://www.google.com/images/neg.gif" width='.$prneg.' height=4 border=0 alt="'.$pagerank.'"></a>';br}brbr/*brif ((!$_POST) && (!$_GET)) { echo '<form action="" method="post"><input name="url" type="text"><input type="submit" name="Submit" value="Submit"></form>'; }brelse {br brbr if (isset($_REQUEST["url"])) {br $url=$_REQUEST["url"];br if (!preg_match("/^(http:\/\/)?([^\/]+)/i", $url)) { die; }br }br br $url="http://www.example.com/";br header("Content-Type: text/plain; charset=utf-8"); echo 'PageRank: '.getpr($url);br echo pagerank($url);br}br*/brif (isset($_GET['url'])) { echo pagerank($_GET['url']); }brbr//echo file_get_contents("http://www.google.com/search?client=navclient-auto&ch=6-242005025&features=Rank&q=info:http%3A//www.hm2k.org/");brbr?>
Code:
brpreGET /search?client=navclient-auto&ch=6-820446282&features=Rank&q=info:http://www.hm2k.org/ HTTP/1.1br/pre HTTP/1.1 403 Forbidden Content-Type: text/html Server: GWS/2.1 Content-Length: 4378 Date: Thu, 14 Sep 2006 15:56:10 GMT script!--var rc=403;//--/scripttable border="0" cellpadding="2" cellspacing="0" width="100%"td rowspan="3" nowrap="nowrap" width="1%"bfont color="#0039b6" face="times" size="10"G/fontfont color="#c41200" face="times" size="10"o/fontfont color="#f3c518" face="times" size="10"o/fontfont color="#0039b6" face="times" size="10"g/fontfont color="#30a72f" face="times" size="10"l/fontfont color="#c41200" face="times" size="10"e/font/btdtrtd bgcolor="#3366cc"font color="#ffffff" face="arial,sans-serif"bError/b/fonttrtd/tbody/tableblockquoteh1Forbidden/h1Your client does not have permission to get URL code/search?client=navclient-auto&ch=6-820446282&features=Rank&q=info:http://www.hm2k.org//code from this server. (Client IP address: 87.117.209.202)brbr Please see Google's Terms of Service posted at http://www.google.com/terms_of_service.html brbrpIf you believe that you have received this response in error, please a href="http://www.google.com/support/bin/request.py?contact_type=user&hl=en"report/a your problem. However, please make sure to take a look at our Terms of Service (http://www.google.com/terms_of_service.html). In your email, please send us the bentire/b code displayed below. Please also send us any information you may know about how you are performing your Google searches-- for example, "I'm using the Opera browser on Linux to do searches from home. My Internet access is through a dial-up account I have with the FooCorp ISP." or "I'm using the Konqueror browser on Linux to search from my job at myFoo.com. My machine's IP address is 10.20.30.40, but all of myFoo's web traffic goes through some kind of proxy server whose IP address is 10.11.12.13." (If you don't know any information like this, that's OK. But this kind of information can help us track down problems, so please tell us what you can.)/ppWe will use all this information to diagnose the problem, and we'll hopefully have you back up and searching with Google again quickly!/p pPlease note that although we read all the email we receive, we are not always able to send a personal response to each and every email. So don't despair if you don't hear back from us!/p pAlso note that if you do not send us the bentire/b code below, iwe will not be able to help you/i./ppBest wishes,brThe Google Teambr/pblockquote/+/+/+/+/+/+/+/+/+/+/+/+/+/+/+/+/+/+/+/+/+/+/+/+/br XRgYxRvnLFnOtyQHUQIeR9JvN-C47je95tbLnwL6QujynxBHqbr Fi8mp50IEFPBYBOqTYt8kChTQkF1LaiTXGm16rl0eGfZX3VQBbr 53ZpwDZCBmUdewM0e_He4a9VGDG9SNY64XfS0kAfNP5oSY0QFbr 34OJuKT0b9EA-ASEfCurIHSB_mgDVBrfgGp-k-d24B1CW2kjgbr txPBjCzOx91_Ku4pBiaUKzoBB0ffqTQZGFcc7iMm9-8lzLqPwbr MHCLff644vA6t1Hnhh4PgzzJ3ND8V7gMd6Z_gYsTRk38pPlwbbr cfDJ_NrzpNDX9Zua0iC42vZjXZNybHowyjSLw47wZMgmZapyZbr Ukyih_hXYB_skRdbSmO9J3SvjmJPx8lwhwG1S-DAEUuj3ZmQMbr A3ylAP72l3VQ4igjp0INhxhgdC2wP1LDjfAP2syS8Jsl4YLA0br U0V207kgAHRcvOMkYprb1LWPV6k1IJlPfStkefGymMHtkM_Wibr rcB8IgGpMO3aLoMgHUNHl8V3wcsPJqyJHPG--MB3aMmxJbfwVbr ZooHGDVnhmnWhOD-VYq0-uoevzfHoD8MgHcp5BI2MJtrxfY9Zbr DUEibr +/+/+/+/+/+/+/+/+/+/+/+/+/+/+/+/+/+/+/+/+/+/+/+/+br/blockquote /blockquotetable cellpadding="0" cellspacing="0" width="100%"td bgcolor="#3366cc"img alt="" height="4" width="1"/tbody/tablea href="http://www.hm2k.org/" title="PageRank: /10"img src="http://www.google.com/images/pos.gif" alt="PageRank: /10" border="0" height="4" width="0"img src="http://www.google.com/images/neg.gif" alt="PageRank: /10" border="0" height="4" width="40"/a |
|
|
|
|
Sponsored Links
|
|
|
|
#2 (permalink) |
|
Noogle
![]() Join Date: Sep 2006
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
![]() |
After looking at the following link:
http://66.249.93.104/search?q=cache:...ient=firefox-a It seems the problem is down to the way the ch is generated by certain versions of PHP, and the way they handle bitwise operations. Does anyone have any clue how to fix such a problem other than to use another scripting language to generate the ch (such as perl). |
|
|
|
|
|
#3 (permalink) |
|
Noogle
![]() Join Date: Sep 2006
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
![]() |
I found more information about this script and this issue here: http://www.mobileread.com/forums/showthread.php?t=1670
It is meant to be fixed, however it clearly isn't. My Server information: Operating system CentOS Linux Kernel version 2.6.8-022stab078.14-smp Machine Type i686 Apache version 1.3.37 (Unix) PERL version 5.8.7 PHP version 4.4.4 MySQL version 4.1.21-standard cPanel Build 10.8.2-RELEASE 119 If you think you can resolve this problem, I will give you an account on my server to attempt a solution. |
|
|
|
|
|
#5 (permalink) |
|
Noogle
![]() Join Date: Sep 2006
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
![]() |
Here's my solution... http://www.hm2k.com/projects/pagerank/
|
|
|
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Always about Pagerank Script Malfunctions | diliberto | Web Design, Coding & Programming Forum | 1 | 12-04-2006 10:00 AM |
| Google PageRank Script | asgsoft | Web Design, Coding & Programming Forum | 14 | 08-01-2006 06:17 AM |
| Pagerank script problem | pdstein | All About Google | 5 | 12-13-2005 02:34 PM |
| Pagerank script problem | pdstein | All About Google | 5 | 01-01-1970 12:21 PM |