The SitePoint Forums have moved.

You can now find them here.
This forum is now closed to new posts, but you can browse existing content.
You can find out more information about the move and how to open a new account (if necessary) here.
If you get stuck you can get support by emailing forums@sitepoint.com

If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

<?php
/*
This code is released unto the public domain
This script is originally from: http://www.googlecommunity.com/scripts/google-pagerank.php
It is also hosted, and was modified slightly, by: http://www.searchengineengine.com
The architecture is:
getrank($url) function - The function called externally to get the PageRank
strord($url) function - Function called by getrank() to convert the url string into a numeric

string
GoogleCH($numericstring) function - Function called by getrank() to get the checksum of the url
mix($a, $b, $c) function - Called by GoogleCH() during checksum calculation
zeroFill($a, $b) function - Called by mix() during mixing
*/

//header("Content-Type: text/plain; charset=utf-8"); //Uncommenting this makes the file downloadable rather

unavailable, or the URL is invalid, return "N/A".
//The preg_match check is a very basic url validator that only checks if the URL has a period in it.
$rankarray = explode (":", $data[2]); //There are two line breaks before the PageRank data on the Google

Warning: file(http://www.google.com/search?client=navclient-auto&ch=6-2147435329&features=Rank&q=info:www.google.com): failed to open stream: HTTP request failed! HTTP/1.0 403 Forbidden in /home/****/public_html/google.php on line 102
PageRank for www.google.com is

I think this might be more to do with Google than you as I've had the exact same problem in the past. Whilst testing a page rank script it suddenly stopped working with the same error you are getting, I think maybe Google blocks your IP after a while if you are persistently hammering it as you might do during testing. The same script that failed one day just started working a few days later as if the block had been removed.

I think this might be more to do with Google than you as I've had the exact same problem in the past. Whilst testing a page rank script it suddenly stopped working with the same error you are getting, I think maybe Google blocks your IP after a while if you are persistently hammering it as you might do during testing. The same script that failed one day just started working a few days later as if the block had been removed.

Yes that happens, but it's not the case here. The scripts are not computing the checksum value correctly on his server, so he will get a 403 error even if his server is not blocked. I can test it in my browser -- send a wrong checksum, get a 403, send a correct checksum, get pagerank info back.

Yes that happens, but it's not the case here. The scripts are not computing the checksum value correctly on his server, so he will get a 403 error even if his server is not blocked. I can test it in my browser -- send a wrong checksum, get a 403, send a correct checksum, get pagerank info back.

I have the same exact problem with only one of my servers. It works everywhere else but on one specific machine and I have verfied by remotely querying via curl that the server is NOT blocked.

As best I can tell function strord() passes the correct array elements however the function GoogleCH() function is lousing something up. I had even recompiled php to the same version as I have running on my laptop however using the same exact code on both produces different checksums.

To debug I compiled a C version (gcc pr.c) and it does in fact calculate the correct checksum.... php does not. If anyone has any ideas Id love to hear them LOL