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
karawan
post
Post #2





Grupa: Zarejestrowani
Postów: 10
Pomógł: 0
Dołączył: 15.05.2005

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


No i właśnie skrypt przytoczony nie działa na niektórych serwerach poniżej daję skrypt który dziala:
jest to związane z 32 bitowa obsługą w funkcji mix,
dodatna zostana funkcja
function toInt32

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


wywołanie
  1. <?php
  2. getPR('www.strona.pl')
  3. ?>


Ten post edytował karawan 14.06.2006, 22:22:37
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: 25.08.2025 - 09:20