Rumah > pembangunan bahagian belakang > tutorial php > 在线查询Google PR值的PHP代码

在线查询Google PR值的PHP代码

WBOY
Lepaskan: 2016-07-25 08:57:44
asal
1169 orang telah melayarinya
  1. /**

  2. * 获取Google PR值
  3. * by bbs.it-home.org
  4. */
  5. define('GOOGLE_MAGIC', 0xE6359A60);
  6. function zeroFill($a, $b)
  7. {
  8. $z = hexdec(80000000);
  9. if ($z & $a)
  10. {
  11. $a = ($a>>1);
  12. $a &= (~$z);
  13. $a |= 0x40000000;
  14. $a = ($a>>($b-1));
  15. }
  16. else
  17. {
  18. $a = ($a>>$b);
  19. }
  20. return $a;
  21. }
  22. function mix($a,$b,$c)

  23. {
  24. $a -= $b; $a -= $c; $a ^= (zeroFill($c,13));
  25. $b -= $c; $b -= $a; $b ^= ($a$c -= $a; $c -= $b; $c ^= (zeroFill($b,13));
  26. $a -= $b; $a -= $c; $a ^= (zeroFill($c,12));
  27. $b -= $c; $b -= $a; $b ^= ($a$c -= $a; $c -= $b; $c ^= (zeroFill($b,5));
  28. $a -= $b; $a -= $c; $a ^= (zeroFill($c,3));
  29. $b -= $c; $b -= $a; $b ^= ($a$c -= $a; $c -= $b; $c ^= (zeroFill($b,15));
  30. return array($a,$b,$c);
  31. }
  32. function GoogleCH($url, $length=null, $init=GOOGLE_MAGIC)

  33. {
  34. if(is_null($length))
  35. {
  36. $length = sizeof($url);
  37. }
  38. $a = $b = 0x9E3779B9;
  39. $c = $init;
  40. $k = 0;
  41. $len = $length;
  42. while($len >= 12)
  43. {
  44. $a += ($url[$k+0] +($url[$k+1]$b += ($url[$k+4] +($url[$k+5]$c += ($url[$k+8] +($url[$k+9]$mix = mix($a,$b,$c);
  45. $a = $mix[0]; $b = $mix[1]; $c = $mix[2];
  46. $k += 12;
  47. $len -= 12;
  48. }
  49. $c += $length;

  50. switch($len)
  51. {
  52. case 11: $c+=($url[$k+10]case 10: $c+=($url[$k+9]case 9 : $c+=($url[$k+8]case 8 : $b+=($url[$k+7]case 7 : $b+=($url[$k+6]case 6 : $b+=($url[$k+5]case 5 : $b+=($url[$k+4]);
  53. case 4 : $a+=($url[$k+3]case 3 : $a+=($url[$k+2]case 2 : $a+=($url[$k+1]case 1 : $a+=($url[$k+0]);
  54. }
  55. $mix = mix($a,$b,$c);
  56. return $mix[2];
  57. }
  58. function strord($string) {

  59. for($i=0;$i$result[$i] = ord($string{$i});
  60. }
  61. return $result;
  62. }
  63. function ReadPR($link)

  64. {
  65. $fp = fsockopen ("www.google.com", 80, $errno, $errstr, 30);
  66. if (!$fp)

  67. {
  68. echo "$errstr ($errno)\n";
  69. exit(1);
  70. }
  71. else
  72. {
  73. $out = "GET $link HTTP/1.0\r\n";
  74. $out .= "Host: toolbarqueries.google.com\r\n";
  75. $out .= "User-Agent: Mozilla/4.0 (compatible; GoogleToolbar 2.0.114.9-big; Linux 2.6)\r\n";
  76. $out .= "Connection: Close\r\n\r\n";
  77. fwrite($fp, $out);
  78. do{

  79. $line = fgets($fp, 128);
  80. }while ($line !== "\r\n");
  81. $data = fread($fp,8192);
  82. fclose ($fp);
  83. return $data;
  84. }
  85. }
  86. function GetPR($url)

  87. {
  88. $url ='info:'.$url;
  89. $ch = GoogleCH(strord($url));
  90. $data = ReadPR("/search?client=navclient-auto&ch=6$ch&features=Rank&q=$url");
  91. $rankarray = explode (':', $data);
  92. return $rankarray[2];
  93. }
  94. if ( isset($_POST['url']) && $_POST['url'] !== '' )

  95. {
  96. echo 'PageRank: '.GetPR($_POST['url']);
  97. }
  98. ?>
  99. Google PR值查询
  100. Google PR值查询 获取源代码

  101. URL:
复制代码


sumber:php.cn
Kenyataan Laman Web ini
Kandungan artikel ini disumbangkan secara sukarela oleh netizen, dan hak cipta adalah milik pengarang asal. Laman web ini tidak memikul tanggungjawab undang-undang yang sepadan. Jika anda menemui sebarang kandungan yang disyaki plagiarisme atau pelanggaran, sila hubungi admin@php.cn
Tutorial Popular
Lagi>
Muat turun terkini
Lagi>
kesan web
Kod sumber laman web
Bahan laman web
Templat hujung hadapan