nasrax

Code: Google Page Rank Checker

Oct 4th, 2017
29
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 4.90 KB | None | 0 0
  1. // For more codes and secrets vist:
  2.  ==> http://quamiller.com/5V7J
  3.  
  4. <form action="" method="post">
  5.     <table align="center" style="width: 359px; height: 81px;border: 2px  dashed #000066;">
  6.         <tr>
  7.             <td  style="background-color: #DDFFFF;width: 57px">URL:</td>
  8.             <td  style="background-color: #DDFFFF;width: 112px">
  9.             <input name="url" type="text" style="width: 289px; height: 23px" value="http://"></td>
  10.         </tr>
  11.         <tr>
  12.             <td  style="width: 57px">&nbsp;</td>
  13.             <td style="width: 112px">
  14.         <input name="Submit1" style="width: 133px; height: 29px;" type="submit" value="Find Page Rank"></td>
  15.         </tr>
  16.     </table>
  17. </form>
  18.  
  19. <?php
  20. if (isset($_POST['url'])){
  21.     $pgr=new GooglePageRankChecker;
  22.     $url=$_POST['url'];
  23.     $rank = $pgr->getRank($url);
  24.     echo '
  25.         <p style="text-align: center;"><span style="font-size: 20pt;color: #0000FF; border-style:dotted;border-width: 1px;background-color: #FFFFCC;
  26.         "><a href="'.$url.'">'.$url.'</a></span><br>
  27.         <span style="font-size: 18pt;color: #0000FF;border-style:dotted;border-width: 1px;background-color: #FFFFCC;">&nbsp;&nbsp;The Page Rank is:&nbsp;'.$rank.'&nbsp;&nbsp;</span></p>
  28.     ';
  29. }
  30.  
  31.  
  32. class GooglePageRankChecker {
  33.  
  34.   // Track the instance
  35.   private static $instance;
  36.  
  37.   // Constructor
  38.   function getRank($page) {
  39.     // Create the instance, if one isn't created yet
  40.     if(!isset(self::$instance)) {
  41.       self::$instance = new self();
  42.     }
  43.     // Return the result
  44.     return self::$instance->check($page);
  45.   }
  46.  
  47.   // Convert string to a number
  48.   function stringToNumber($string,$check,$magic) {
  49.     $int32 = 4294967296;  // 2^32
  50.       $length = strlen($string);
  51.       for ($i = 0; $i < $length; $i++) {
  52.           $check *= $magic;
  53.           //If the float is beyond the boundaries of integer (usually +/- 2.15e+9 = 2^31),
  54.           //  the result of converting to integer is undefined
  55.           //  refer to http://www.php.net/manual/en/language.types.integer.php
  56.           if($check >= $int32) {
  57.               $check = ($check - $int32 * (int) ($check / $int32));
  58.               //if the check less than -2^31
  59.               $check = ($check < -($int32 / 2)) ? ($check + $int32) : $check;
  60.           }
  61.           $check += ord($string{$i});
  62.       }
  63.       return $check;
  64.   }
  65.  
  66.   // Create a url hash
  67.   function createHash($string) {
  68.     $check1 = $this->stringToNumber($string, 0x1505, 0x21);
  69.       $check2 = $this->stringToNumber($string, 0, 0x1003F);
  70.  
  71.     $factor = 4;
  72.     $halfFactor = $factor/2;
  73.  
  74.       $check1 >>= $halfFactor;
  75.       $check1 = (($check1 >> $factor) & 0x3FFFFC0 ) | ($check1 & 0x3F);
  76.       $check1 = (($check1 >> $factor) & 0x3FFC00 ) | ($check1 & 0x3FF);
  77.       $check1 = (($check1 >> $factor) & 0x3C000 ) | ($check1 & 0x3FFF);  
  78.  
  79.       $calc1 = (((($check1 & 0x3C0) << $factor) | ($check1 & 0x3C)) << $halfFactor ) | ($check2 & 0xF0F );
  80.       $calc2 = (((($check1 & 0xFFFFC000) << $factor) | ($check1 & 0x3C00)) << 0xA) | ($check2 & 0xF0F0000 );
  81.  
  82.       return ($calc1 | $calc2);
  83.   }
  84.  
  85.   // Create checksum for hash
  86.   function checkHash($hashNumber)
  87.   {
  88.       $check = 0;
  89.     $flag = 0;
  90.  
  91.     $hashString = sprintf('%u', $hashNumber) ;
  92.     $length = strlen($hashString);
  93.  
  94.     for ($i = $length - 1;  $i >= 0;  $i --) {
  95.       $r = $hashString{$i};
  96.       if(1 === ($flag % 2)) {
  97.         $r += $r;
  98.         $r = (int)($r / 10) + ($r % 10);
  99.       }
  100.       $check += $r;
  101.       $flag ++;
  102.     }
  103.  
  104.     $check %= 10;
  105.     if(0 !== $check) {
  106.       $check = 10 - $check;
  107.       if(1 === ($flag % 2) ) {
  108.         if(1 === ($check % 2)) {
  109.           $check += 9;
  110.         }
  111.         $check >>= 1;
  112.       }
  113.     }
  114.  
  115.     return '7'.$check.$hashString;
  116.   }
  117.  
  118.   function check($page) {
  119.  
  120.     // Open a socket to the toolbarqueries address, used by Google Toolbar
  121.     $socket = fsockopen("toolbarqueries.google.com", 80, $errno, $errstr, 30);
  122.  
  123.     // If a connection can be established
  124.     if($socket) {
  125.       // Prep socket headers
  126.       $out = "GET /tbr?client=navclient-auto&ch=".$this->checkHash($this->createHash($page)).
  127.               "&features=Rank&q=info:".$page."&num=100&filter=0 HTTP/1.1\r\n";
  128.       $out .= "Host: toolbarqueries.google.com\r\n";
  129.       $out .= "User-Agent: Mozilla/4.0 (compatible; GoogleToolbar 2.0.114-big; Windows XP 5.1)\r\n";
  130.       $out .= "Connection: Close\r\n\r\n";
  131.  
  132.       // Write settings to the socket
  133.       fwrite($socket, $out);
  134.  
  135.       // When a response is received...
  136.       $result = "";
  137.       while(!feof($socket)) {
  138.         $data = fgets($socket, 128);
  139.         $pos = strpos($data, "Rank_");
  140.         if($pos !== false){
  141.           $pagerank = substr($data, $pos + 9);
  142.           $result += $pagerank;
  143.         }
  144.       }
  145.       // Close the connection
  146.       fclose($socket);
  147.  
  148.       // Return the rank!
  149.       return $result;
  150.     }
  151.   }
  152. }
  153. ?>
  154.  
  155. <br><font face="Tahoma"><a target="_blank" href="http://www.phpfreecode.com/"><span style="font-size: 8pt; text-decoration: none">PHP Free Code</span></a></font>
Add Comment
Please, Sign In to add comment