Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> pagerank
-Guest-
post
Post #1





Goście







weźmy na przyklad taką stronę:
http://pr.blogflux.com/pr3.php?s=http://www.wp.pl
efekt: PR 7/10

i teraz pytanie: jak wygląda skrypt w pr3.php?
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
Vogel
post
Post #2





Grupa: Zarejestrowani
Postów: 402
Pomógł: 0
Dołączył: 20.01.2003

Ostrzeżenie: (0%)
-----


na boga. google i po chwili mialem dzialajacy:

  1. <html>
  2. <body style="font-family:verdana;font-size:13px">
  3. <?php
  4. /* 
  5. This code is released unto the public domain 
  6.  
  7. Raistlin Majere euclide@email.it 
  8.  
  9. */
  10. define('GOOGLE_MAGIC', 0xE6359A60);
  11.  
  12. //unsigned shift right
  13. function zeroFill($a, $b)
  14. {
  15. $z = hexdec(80000000);
  16. if ($z & $a)
  17. {
  18. $a = ($a>>1);
  19. $a &= (~$z);
  20. $a |= 0x40000000;
  21. $a = ($a>>($b-1));
  22. }
  23. else
  24. {
  25. $a = ($a>>$b);
  26. }
  27. return $a;
  28. }
  29.  
  30.  
  31. function mix($a,$b,$c) {
  32. $a -= $b; $a -= $c; $a ^= (zeroFill($c,13));
  33. $b -= $c; $b -= $a; $b ^= ($a<<8);
  34. $c -= $a; $c -= $b; $c ^= (zeroFill($b,13));
  35. $a -= $b; $a -= $c; $a ^= (zeroFill($c,12));
  36. $b -= $c; $b -= $a; $b ^= ($a<<16);
  37. $c -= $a; $c -= $b; $c ^= (zeroFill($b,5));
  38. $a -= $b; $a -= $c; $a ^= (zeroFill($c,3)); 
  39. $b -= $c; $b -= $a; $b ^= ($a<<10);
  40. $c -= $a; $c -= $b; $c ^= (zeroFill($b,15));
  41.  
  42. return array($a,$b,$c);
  43. }
  44.  
  45. function GoogleCH($url, $length=null, $init=GOOGLE_MAGIC) {
  46. if(is_null($length)) {
  47. $length = sizeof($url);
  48. }
  49. $a = $b = 0x9E3779B9;
  50. $c = $init;
  51. $k = 0;
  52. $len = $length;
  53. while($len >= 12) {
  54. $a += ($url[$k+0] +($url[$k+1]<<8) +($url[$k+2]<<16) +($url[$k+3]<<24));
  55. $b += ($url[$k+4] +($url[$k+5]<<8) +($url[$k+6]<<16) +($url[$k+7]<<24));
  56. $c += ($url[$k+8] +($url[$k+9]<<8) +($url[$k+10]<<16)+($url[$k+11]<<24));
  57. $mix = mix($a,$b,$c);
  58. $a = $mix[0]; $b = $mix[1]; $c = $mix[2];
  59. $k += 12;
  60. $len -= 12;
  61. }
  62.  
  63. $c += $length;
  64. switch($len) /* all the case statements fall through */
  65. {
  66. case 11: $c+=($url[$k+10]<<24);
  67. case 10: $c+=($url[$k+9]<<16);
  68. case 9 : $c+=($url[$k+8]<<8);
  69. /* the first byte of c is reserved for the length */
  70. case 8 : $b+=($url[$k+7]<<24);
  71. case 7 : $b+=($url[$k+6]<<16);
  72. case 6 : $b+=($url[$k+5]<<8);
  73. case 5 : $b+=($url[$k+4]);
  74. case 4 : $a+=($url[$k+3]<<24);
  75. case 3 : $a+=($url[$k+2]<<16);
  76. case 2 : $a+=($url[$k+1]<<8);
  77. case 1 : $a+=($url[$k+0]);
  78. /* case 0: nothing left to add */
  79. }
  80. $mix = mix($a,$b,$c);
  81. /*-------------------------------------------- report the result */
  82. return $mix[2];
  83. }
  84.  
  85. //converts a string into an array of integers containing the numeric value of the 
    char
  86. function strord($string) {
  87. for($i=0;$i<strlen($string);$i++) {
  88. $result[$i] = ord($string{$i});
  89. }
  90. return $result;
  91. }
  92.  
  93. function get_pr($url) {
  94. $result=array("",-1);
  95.  
  96. if (($url.""!="")&&($url.""!="http://")):
  97. // check for protocol 
  98. if (substr(strtolower($url),0,7)!="http://"):
  99. $url="http://".$url;
  100. endif;
  101.  
  102. $url="info:".$url;
  103. $checksum=GoogleCH(strord($url));
  104. $google_url=sprintf("http://www.google.com/search?client=navclient-auto&ch=6%u&features=Rank&q=".$url,$checksum); // url to get from google 
  105.  
  106. $contents="";
  107. // let's get ranking 
  108. // this way could cause problems because the Browser Useragent is not set... 
  109. if ($handle=fopen($google_url,"rb")):
  110. while(true):
  111. $data=fread($handle,8192);
  112. if (strlen($data)==0):
  113. break;
  114. endif;
  115. $contents.=$data;
  116. endwhile;
  117. fclose($handle);
  118. else:
  119. $contents="Connection unavailable";
  120. endif;
  121.  
  122. $result[0]=$contents;
  123. // Rank_1:1:0 = 0 
  124. // Rank_1:1:5 = 5 
  125. // Rank_1:1:9 = 9 
  126. // Rank_1:2:10 = 10 etc 
  127. $p=explode(":",$contents);
  128. if (isset($p[2])):
  129. $result[1]=$p[2];
  130. endif;
  131. endif;
  132.  
  133. return $result;
  134. }
  135.  
  136. // GET IT ! 
  137. $pr=get_pr($_GET["url"]);
  138. $output=$pr[0];
  139. $pagerank=$pr[1];
  140. ?>
  141. <br>
  142. <form method="get" action="?r=<?=time()?>">
  143. <center>
  144. <table style="font-family:verdana;font-size:13px">
  145. <tr>
  146. <td valign="top"><b>Url</b></td>
  147. <td valign="top"><?=$_GET['url']?></td>
  148. </tr>
  149. <tr>
  150. <td valign="top"><b>Page<br>Rank</b></td>
  151. <td valign="top" style="color:red"><b><?=$pagerank?></b></td>
  152. </tr>
  153. <tr>
  154. <td valign="top"><b>Google<br>output</b></td>
  155. <td valign="top"><div style="overflow:auto;width:250px;height:150px;background-color:#eeeeee;border:1px solid #aaaaaa"><?=$output?></div></td>
  156. </tr>
  157. </table>
  158.  
  159. <br>
  160.  
  161. <input type="text" name="url" size="80" value="<?=isset($_GET['url'])?$_GET['url']:"http://"?>"><br>
  162. <input type="submit">
  163.  
  164. </center>
  165. </form>
  166. </body>
  167. </html>
Go to the top of the page
+Quote Post

Posty w temacie


Reply to this topicStart new topic
2 Użytkowników czyta ten temat (2 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 4.10.2025 - 15:47