• Sábado 21 de Diciembre de 2024, 10:19

Autor Tema:  Elgoog  (Leído 1134 veces)

RadicalEd

  • Moderador
  • ******
  • Mensajes: 2430
  • Nacionalidad: co
    • Ver Perfil
Elgoog
« en: Sábado 26 de Febrero de 2005, 23:53 »
0
:unsure: Pfff Ahora como buscamos :blink:
elgooG
A y este es el algoritmo del PageRank de Google
Código: Text
  1. <?php
  2. header("Content-Type: text/plain; charset=utf-8");
  3. define('GOOGLE_MAGIC', 0xE6359A60);
  4. function zeroFill($a, $b) {
  5. $z = hexdec(80000000);
  6. if ($z & $a) {
  7. $a = ($a>>1);
  8. $a &= (~$z);
  9. $a |= 0x40000000;
  10. $a = ($a>>($b-1));
  11. } else {
  12. $a = ($a>>$b);
  13. }
  14. return $a;
  15. }
  16. function mix($a,$b,$c) {
  17. $a -= $b; $a -= $c; $a ^= (zeroFill($c,13));
  18. $b -= $c; $b -= $a; $b ^= ($a<<8);
  19. $c -= $a; $c -= $b; $c ^= (zeroFill($b,13));
  20. $a -= $b; $a -= $c; $a ^= (zeroFill($c,12));
  21. $b -= $c; $b -= $a; $b ^= ($a<<16);
  22. $c -= $a; $c -= $b; $c ^= (zeroFill($b,5));
  23. $a -= $b; $a -= $c; $a ^= (zeroFill($c,3));
  24. $b -= $c; $b -= $a; $b ^= ($a<<10);
  25. $c -= $a; $c -= $b; $c ^= (zeroFill($b,15));
  26. return array($a,$b,$c);
  27. }
  28. function GoogleCH($url, $length=null, $init=GOOGLE_MAGIC) {
  29. if(is_null($length)) {
  30. $length = sizeof($url);
  31. }
  32. $a = $b = 0x9E3779B9;
  33. $c = $init;
  34. $k = 0;
  35. $len = $length;
  36. while($len >= 12) {
  37. $a += ($url[$k+0] +($url[$k+1]<<8) +($url[$k+2]<<16) +($url[$k+3]<<24));
  38. $b += ($url[$k+4] +($url[$k+5]<<8) +($url[$k+6]<<16) +($url[$k+7]<<24));
  39. $c += ($url[$k+8] +($url[$k+9]<<8) +($url[$k+10]<<16)+($url[$k+11]<<24));
  40. $mix = mix($a,$b,$c);
  41. $a = $mix[0]; $b = $mix[1]; $c = $mix[2];
  42. $k += 12;
  43. $len -= 12;
  44. }
  45. $c += $length;
  46. switch($len) {
  47. case 11: $c+=($url[$k+10]<<24);
  48. case 10: $c+=($url[$k+9]<<16);
  49. case 9 : $c+=($url[$k+8]<<8);
  50. case 8 : $b+=($url[$k+7]<<24);
  51. case 7 : $b+=($url[$k+6]<<16);
  52. case 6 : $b+=($url[$k+5]<<8);
  53. case 5 : $b+=($url[$k+4]);
  54. case 4 : $a+=($url[$k+3]<<24);
  55. case 3 : $a+=($url[$k+2]<<16);
  56. case 2 : $a+=($url[$k+1]<<8);
  57. case 1 : $a+=($url[$k+0]);
  58. }
  59. $mix = mix($a,$b,$c);
  60. return $mix[2];
  61. }
  62. function strord($string) {
  63. for($i=0;$i
  64. $result[$i] = ord($string{$i});
  65. }
  66. return $result;
  67. }
  68. function c32to8bit($arr32) {
  69. for($i=0;$i
  70. for ($bitOrder=$i*4;$bitOrder<=$i*4+3;$bitOrder++) {
  71. $arr8[$bitOrder]=$arr32[$i]&255;
  72. $arr32[$i]=zeroFill($arr32[$i], 8);
  73. }
  74. }
  75. return $arr8;
  76. }
  77. $url =' info:'.$_GET['url'];
  78. print(url:\t{$_GET['url']}\n);
  79. $ch = GoogleCH(strord($url));
  80. printf(Checksum ><2.0.114:\t6%u\n",$ch);
  81. $ch=sprintf("%u", $ch);
  82. $ch = ((($ch/7) << 2) | (((int)fmod($ch,13))&7));
  83. $prbuf = array();
  84. $prbuf[0] = $ch;
  85. for($i = 1; $i < 20; $i++) {
  86. $prbuf[$i] = $prbuf[$i-1]-9;
  87. }
  88. $ch = GoogleCH(c32to8bit($prbuf), 80);
  89. printf("Checksum >=2.0.114:\t6%u\n",$ch);
  90. ?>
  91.  
  92.  
El pasado son solo recuerdos, el futuro son solo sueños