webcodebase.com Snippets database & Pastebin

Display google pagerank

Submitted on 18/12/2008
Authors Comment: Do you want the users to see your websites pagerank? or perhaps the pageranks of other websites? this snippet will do that.
How to use: Edit $myWebSite variable to your website. Can be placed anywhere on your page where you want to display your pagerank.
Download Snippet:
Snippet:

  1. <?php
  2. // Edit this to your website url:
  3. $myWebSite = 'http://www.unrealmedia.co.uk';
  4.  
  5. define('GMAG', 0xE6359A60);
  6.  
  7. //unsigned shift right
  8. function zeroFill($a, $b)
  9. {
  10. $z = hexdec(80000000);
  11. if ($z & $a)
  12. {
  13. $a = ($a>>1);
  14. $a &= (~$z);
  15. $a |= 0x40000000;
  16. $a = ($a>>($b-1));
  17. }
  18. else
  19. {
  20. $a = ($a>>$b);
  21. }
  22. return $a;
  23. }
  24.  
  25.  
  26. function mix($a,$b,$c) {
  27. $a -= $b; $a -= $c; $a ^= (zeroFill($c,13));
  28. $b -= $c; $b -= $a; $b ^= ($a<<8);
  29. $c -= $a; $c -= $b; $c ^= (zeroFill($b,13));
  30. $a -= $b; $a -= $c; $a ^= (zeroFill($c,12));
  31. $b -= $c; $b -= $a; $b ^= ($a<<16);
  32. $c -= $a; $c -= $b; $c ^= (zeroFill($b,5));
  33. $a -= $b; $a -= $c; $a ^= (zeroFill($c,3));
  34. $b -= $c; $b -= $a; $b ^= ($a<<10);
  35. $c -= $a; $c -= $b; $c ^= (zeroFill($b,15));
  36.  
  37. return array($a,$b,$c);
  38. }
  39.  
  40. function GCH($url, $length=null, $init=GMAG) {
  41. if(is_null($length)) {
  42. $length = sizeof($url);
  43. }
  44. $a = $b = 0x9E3779B9;
  45. $c = $init;
  46. $k = 0;
  47. $len = $length;
  48. while($len >= 12) {
  49. $a += ($url[$k+0] +($url[$k+1]<<8) +($url[$k+2]<<16) +($url[$k+3]<<24));
  50. $b += ($url[$k+4] +($url[$k+5]<<8) +($url[$k+6]<<16) +($url[$k+7]<<24));
  51. $c += ($url[$k+8] +($url[$k+9]<<8) +($url[$k+10]<<16)+($url[$k+11]<<24));
  52. $mix = mix($a,$b,$c);
  53. $a = $mix[0]; $b = $mix[1]; $c = $mix[2];
  54. $k += 12;
  55. $len -= 12;
  56. }
  57.  
  58. $c += $length;
  59. switch($len) //all the case statements fall through
  60. {
  61. case 11: $c+=($url[$k+10]<<24);
  62. case 10: $c+=($url[$k+9]<<16);
  63. case 9 : $c+=($url[$k+8]<<8);
  64. //the first byte of c is reserved for the length
  65. case 8 : $b+=($url[$k+7]<<24);
  66. case 7 : $b+=($url[$k+6]<<16);
  67. case 6 : $b+=($url[$k+5]<<8);
  68. case 5 : $b+=($url[$k+4]);
  69. case 4 : $a+=($url[$k+3]<<24);
  70. case 3 : $a+=($url[$k+2]<<16);
  71. case 2 : $a+=($url[$k+1]<<8);
  72. case 1 : $a+=($url[$k+0]);
  73. /* case 0: nothing left to add */
  74. }
  75. $mix = mix($a,$b,$c);
  76. //report the result
  77. return $mix[2];
  78. }
  79.  
  80. //converts a string into an array of integers containing the numeric value of the char
  81. function strord($string) {
  82. for($i=0;$i<strlen($string);$i++) {
  83. $result[$i] = ord($string{$i});
  84. }
  85. return $result;
  86. }
  87.  
  88. function getPR($_url) {
  89. $url = 'info:'.$_url;
  90. $ch = GCH(strord($url));
  91. $url='info:'.urlencode($_url);
  92. $pr = file("http://www.google.com/search?client=navclient-auto&ch=6$ch&ie=UTF-8&oe=UTF-8&features=Rank&q=$url");
  93. $pr_str = implode("", $pr);
  94. return substr($pr_str,strrpos($pr_str, ":")+1);
  95. }
  96.  
  97. echo "Your pagerank is: ".getPR($myWebSite);
  98. ?>

 

Comments:

  1. .umkrvkttpmh | December 11, 2008 at 18:47

    Y98Bcp <a href="http://cjqkeuyklwlq.com/">cjqkeuyklwlq</a>, [url=http://sixthakfqeqe.com/]sixthakfqeqe[/url], [link=http://wctxzcgemuan.com/]wctxzcgemuan[/link], http://fdfirqtqctvk.com/

  2. .rliuoew | December 11, 2008 at 18:47

    kMdtcM <a href="http://jlcbzfufpvwm.com/">jlcbzfufpvwm</a>, [url=http://kkpaacviasdl.com/]kkpaacviasdl[/url], [link=http://vgovlrcwignd.com/]vgovlrcwignd[/link], http://zbqorjlzxxwa.com/

  3. .efufdbvj | December 11, 2008 at 18:47

    gmsGyW <a href="http://oiwoiwchvjkk.com/">oiwoiwchvjkk</a>, [url=http://tsghhfmjpmfv.com/]tsghhfmjpmfv[/url], [link=http://pvrecuwuobuy.com/]pvrecuwuobuy[/link], http://ssuepfanykvx.com/

  4. .hmpeorgzipa | December 11, 2008 at 18:47

    Q6sm6m <a href="http://yzesvckekkrd.com/">yzesvckekkrd</a>, [url=http://aopzabubbsjx.com/]aopzabubbsjx[/url], [link=http://evakfdynwzdv.com/]evakfdynwzdv[/link], http://vxtewydvhqvz.com/

  5. .wgbhczry | December 11, 2008 at 18:47

    Wg784X <a href="http://qurocjmuovki.com/">qurocjmuovki</a>, [url=http://qzdjktnnfqlm.com/]qzdjktnnfqlm[/url], [link=http://ikqapjzqaqcv.com/]ikqapjzqaqcv[/link], http://pgpjuurlxzcv.com/

  6. .jztugq | December 11, 2008 at 18:47

    LIIn4V <a href="http://mmxzlriwhfyw.com/">mmxzlriwhfyw</a>, [url=http://kapudufgrnql.com/]kapudufgrnql[/url], [link=http://vmqrjvtzqhqz.com/]vmqrjvtzqhqz[/link], http://yrmhwdwmmpzl.com/

  7. .lvkgovsas | December 11, 2008 at 18:47

    90qRvB <a href="http://ewrzrfqenhde.com/">ewrzrfqenhde</a>, [url=http://vcrfizwouezy.com/]vcrfizwouezy[/url], [link=http://qhysceeyagxt.com/]qhysceeyagxt[/link], http://bgjsitkmlgrl.com/

  8. .zmckqql | December 11, 2008 at 18:47

    7Uz5aY <a href="http://hcntqcyvytyn.com/">hcntqcyvytyn</a>, [url=http://tjubentslruy.com/]tjubentslruy[/url], [link=http://lyzbqanzkduv.com/]lyzbqanzkduv[/link], http://wdxmoyacsyjl.com/

  9. .ldntco | December 11, 2008 at 18:47

    bgBx0i <a href="http://dbrjmlewxsqh.com/">dbrjmlewxsqh</a>, [url=http://ahrhkhqxyuxu.com/]ahrhkhqxyuxu[/url], [link=http://ilmtpsqxttcb.com/]ilmtpsqxttcb[/link], http://ezquyvqvdhhs.com/

  10. .dovkgckuoqs | December 11, 2008 at 18:47

    YesqH1 <a href="http://hcqlcresulwe.com/">hcqlcresulwe</a>, [url=http://qxundpqvisvy.com/]qxundpqvisvy[/url], [link=http://fuekkhaeadop.com/]fuekkhaeadop[/link], http://ujuuwekauzfi.com/

  11. .zkdhlrzvqn | December 11, 2008 at 18:47

    l2DnOt <a href="http://wukhgnxpxwar.com/">wukhgnxpxwar</a>, [url=http://ognhhkfeclaz.com/]ognhhkfeclaz[/url], [link=http://ieufymdyxkbb.com/]ieufymdyxkbb[/link], http://tdcoqnkjnrtt.com/


New Comment:
Name:
Comment:








Latest News

  • 30/12/09
    Webcodebase is BACK & New updates.
    Hello, Because of a jackass of a friend the main files for Webcodebase was deleted. I Thought everything was lost until i found a backup folder on my old linux box, so i restored WCB Back to its original state. The staff will continue posting snippets and fighting spam. We will also start releasing tools that web masters can use to check their scripts for vulnerabilities. These scripts will have special stars next to them and the "STAFF" tag. Please use these on your own systems only, we are NOT responsible for any damage they may do. We release them purely for educational purposes only! Thanks, Head of WCB, Arne AKA Cypher....
    [Read More]