The Developer Day | Staying Curious

TAG | pagerank





If you found this blog post on while searching for a php google page rank class implementation that works on non windows machines then it is your lucky day! You found it! Congratulations!

To my knowledge this is the first available php google page rank retrieval implementation that works on any platform. We have spent hours searching for such a thing online but we couldn’t find it. There are some php google pagerank tools online, they all work, but they are all limited to windows machines.

Why is so you might ask? Well originally the google pagerank retrieval algorigthm is not public. But google made a browser plugin that was able to calculate the google pagerank for any website you visit. So some freaky geeks dissasembled that plugin and got their hands on the google page rank calculation implementation.  Then this implementation was ported to various languages such as Javascript, PHP. The google page rank implementation is sort of protected by calculating a “unique” hash of the given URL. And here the MAGIC begins.

To calculate this hash the algorithm overflows 32bit integers on XOR operations. Aaaand.. 32bit XOR overflows work quite differently on windows and linux in PHP! If you overflow a 32bit integer on windows it just truncates the result to 32 left most bits and returns a new integer. SMART! And on linux XOR overflow just returns the MAX INTEGER value. What did we do? Oh.. We created a simple class to simulate windows 32bit XOR operations overflow using the PHP gmp extension. Tadam! We have also cleaned up the code, documented and made it look shiny ;)

You can download  and use it at your own will. I hope this will help you. If it did just leave a comment and say thanks because we are such nice guys to help you out ;)

To use the class try:

echo GooglePageRank::get("");

Happy Programmers Day!

p.s  Google™ search engine and PageRank™ algorithm are the trademarks of Google Inc.

Update: PageRank class relies on the GMP extension which is not always enabled by default. On Linux Ubuntu it comes as a separate package php5-gmp.

, , , Hide

Find it!

Theme Design by