php pagerank checker script


/ Published in: PHP
Save to your folder(s)

how to get php pagerank checker script, simple class.


Copy this code and paste it in your HTML
  1. //========================== pagerank_checker.php
  2. <?php
  3.  
  4. class GooglePR {
  5. public function get_google_pagerank($url) {
  6. $query="http://toolbarqueries.google.com/tbr?client=navclient-auto&ch=".
  7. $this->CheckHash($this->HashURL($url)). "&features=Rank&q=info:".$url."&num=100&filter=0";
  8. // echo $query;
  9. $data=file_get_contents($query);
  10. $pos = strpos($data, "Rank_");
  11. if($pos === false){} else{
  12. $pagerank = substr($data, $pos + 9);
  13. return $pagerank;
  14. }
  15. }
  16.  
  17. public function StrToNum($Str, $Check, $Magic){
  18. $Int32Unit = 4294967296; // 2^32
  19. $length = strlen($Str);
  20. for ($i = 0; $i < $length; $i++) {
  21. $Check *= $Magic;
  22. if ($Check >= $Int32Unit) {
  23. $Check = ($Check - $Int32Unit * (int) ($Check / $Int32Unit));
  24. $Check = ($Check < -2147483648) ? ($Check + $Int32Unit) : $Check;
  25. }
  26. $Check += ord($Str{$i});
  27. }
  28. return $Check;
  29. }
  30.  
  31. public function HashURL($String) {
  32. $Check1 = $this->StrToNum($String, 0x1505, 0x21);
  33. $Check2 = $this->StrToNum($String, 0, 0x1003F);
  34. $Check1 >>= 2;
  35. $Check1 = (($Check1 >> 4) & 0x3FFFFC0 ) | ($Check1 & 0x3F);
  36. $Check1 = (($Check1 >> 4) & 0x3FFC00 ) | ($Check1 & 0x3FF);
  37. $Check1 = (($Check1 >> 4) & 0x3C000 ) | ($Check1 & 0x3FFF);
  38. $T1 =(((($Check1 & 0x3C0) << 4) | ($Check1 & 0x3C)) <<2 ) | ($Check2 & 0xF0F );
  39. $T2 =(((($Check1 & 0xFFFFC000)<< 4)| ($Check1 & 0x3C00))<< 0xA)| ($Check2 & 0xF0F0000);
  40. return ($T1 | $T2);
  41. }
  42.  
  43. public function CheckHash($Hashnum){
  44. $CheckByte = 0;
  45. $Flag = 0;
  46. $HashStr = sprintf('%u', $Hashnum) ;
  47. $length = strlen($HashStr);
  48. for ($i = $length - 1; $i >= 0; $i --) {
  49. $Re = $HashStr{$i};
  50. if (1 === ($Flag % 2)) {
  51. $Re += $Re;
  52. $Re = (int)($Re / 10) + ($Re % 10);
  53. }
  54. $CheckByte += $Re;
  55. $Flag ++;
  56. }
  57. $CheckByte %= 10;
  58. if (0 !== $CheckByte) {
  59. $CheckByte = 10 - $CheckByte;
  60. if (1 === ($Flag % 2) ) {
  61. if (1 === ($CheckByte % 2)) {
  62. $CheckByte += 9;
  63. }
  64. $CheckByte >>= 1;
  65. }
  66. }
  67. return '7'.$CheckByte.$HashStr;
  68. }
  69. }
  70. ?>
  71.  
  72. //==================== test.php
  73. <?php
  74.  
  75. include "pagerank_checker.php";
  76.  
  77. $url='http://www.facebook.com';
  78. $pr = new GooglePR();
  79. echo "$url has PageRank: ". $pr->get_google_pagerank($url) ;
  80.  
  81. ?>

URL: http://function-code.blogspot.com/2014/11/php-pagerank-checker-script.html

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.