• 欢迎访问搞代码网站,推荐使用最新版火狐浏览器和Chrome浏览器访问本网站!
  • 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏搞代码吧

页面中嵌入google的pagerank显示_PHP

php 搞代码 3年前 (2022-01-25) 29次浏览 已收录 0个评论

Google

代码如下:

  1. <?php
  2. /**
  3. * blog.hd001.com Google PageRank Generator
  4. *
  5. *
  6. * @link: http://blog.hd001.com
  7. * @author: Pasio & superspice
  8. * @version: 0.1
  9. */
  10. @error_reporting(E_ALL ^ E_NOTICE);
  11. define(‘GOOGLE_MAGIC’, 0xE6359A60);
  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>>($b1));
  22. }
  23. else
  24. {
  25. $a = ($a>>$b);
  26. }
  27. return $a;
  28. }
  29. function mix($a,$b,$c) {
  30. $a -= $b; $a -= $c; $a ^= (zeroFill($c,13));
  31. $b -= $c; $b -= $a; $b ^= ($a<<8);
  32. $c -= $a; $c -= $b; $c ^= (zeroFill($b,13));
  33. $a -= $b; $a -= $c; $a ^= (zeroFill($c,12));
  34. $b -= $c; $b -= $a; $b ^= ($a<<16);
  35. $c -= $a; $c -= $b; $c ^= (zeroFill($b,5));
  36. $a -= $b; $a -= $c; $a ^= (zeroFill($c,3));
  37. $b -= $c; $b -= $a; $b ^= ($a<<10);
  38. $c -= $a; $c -= $b; $c ^= (zeroFill($b,15));
  39. return array($a,$b,$c);
  40. }
  41. function GoogleCH($url, $length=null, $init=GOOGLE_MAGIC) {
  42. if(is_null($length)) {
  43. $length = sizeof($url);
  44. }
  45. $a = $b = 0x9E3779B9;
  46. $c = $init;
  47. $k = 0;
  48. $len = $length;
  49. while($len >= 12) {
  50. $a += ($url[$k+0] +($url[$k+1]<<8) +($url[$k+2]<<16) +($url[$k+3]<<24));
  51. $b += ($url[$k+4] +($url[$k+5]<<8) +($url[$k+6]<<16) +($url[$k+7]<<24));
  52. $c += ($url[$k+8] +($url[$k+9]<<8) +($url[$k+10]<<16)+($url[$k+11]<<24));
  53. $mix = mix($a,$b,$c);
  54. $a = $mix[0]; $b = $mix[1]; $c = $mix[2];
  55. $k += 12;
  56. $len -= 12;
  57. }
  58. $c += $length;
  59. switch($len) /* all the case statements fall through */
  60. {
  61. case 11: $c+=($url[$k+10]<<24);
  62. case 10: $c+=($url[$k+9]<<16);
  63. case 9 : $c+=($url[$k+8]<<8);
  64. /* the first byte of c is reserved for the length */
  65. case 8 : $b+=($url[$k+7]<<24);
  66. case 7 : $b+=($url[$k+6]<<16);
  67. case 6 : $b+=($url[$k+5]<<8);
  68. case 5 : $b+=($url[$k+4]);
  69. case 4 : $a+=($url[$k+3]<<24);
  70. case 3 : $a+=($url[$k+2]<<16);
  71. case 2 : $a+=($url[$k+1]<<8);
  72. case 1 : $a+=($url[$k+0]);
  73. /* case 0: nothing left to add */
  74. }
  75. $mix = mix($a,$b,$c);
  76. /*——————————————– report the result */
  77. return $mix[2];
  78. }
  79. //converts a string into an array of integers containing the numeric value of the char
  80. function strord($string) {
  81. for($i=0;$i<strlen($string);$i++) {
  82. $result[$i] = ord($string{$i});
  83. }
  84. return $result;
  85. }
  86. // http://www.example.com/ – Checksum: 6540747202
  87. if (!isset($_GET[‘url’]))
  88. {
  89. $url_o = $_SERVER[‘HTTP_REFERER’];
  90. }
  91. else
  92. {
  93. $url_o = $_GET[‘url’];
  94. }
  95. $url_o = explode(“?”, $url_o);
  96. $url_o = $url_o[0];
  97. $url = ‘info:’.$url_o;
  98. $ch = GoogleCH(strord($url));
  99. $url =‘info:’.urlencode($url_o);
  100. $cache_filename = “prcache/”.urlencode($url_o).“.pagerank”;
  101. // check exists of cache file, if not exists, create it
  102. if(!file_exists($cache_filename) || (file_exists($cache_filename) && filemtime($cache_filename) < time() – 86400))
  103. {
  104. $url = http://toolbarqueries.google.com/search?client=navclient-auto&ch=6$ch&ie=UTF-8&oe=UTF-8&features=Rank&q=$url&#8221;;
  105. $result = @file_get_contents($url);
  106. $tmp = @explode(“:”, $result);
  107. $rank = intval($tmp[2]);
  108. $handle = fopen ($cache_filename, “w”);
  109. flock($handle, LOCK_EX);
  110. fwrite($handle, $rank);
  111. flock($handle, LOCK_UN);
  112. fclose($handle);
  113. }
  114. $pagerank = @file_get_contents($cache_filename);
  115. $pagerank = 2;
  116. $width = 6 * $pagerank;
  117. $width_ = 6 * (10$pagerank);
  118. echo “document.writeln(‘<table width=\”80\” border=0 cellpadding=\”0\” cellspacing=\”0\” style=\”font-size:12px\”>
    <td align=
    \”center\”>PageRank<table width=\”80\” cellpadding=\”0\” cellspacing=\”1\” bgcolor=\”#CCCCCC\” height=\”10\” style=\”font-size:11px\”><tr bgcolor=\”#FFFFFF\”><td width=\”62\”>\”/imgs/bar.gif\” width=\”$width\” height=\”20\”>\”/imgs/space.gif\” width=\”$width_\” height=\”20\”>

    <td align=\”center\” style=\”color:red\”>$pagerank

    ‘);”;


搞代码网(gaodaima.com)提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请说明详细缘由并提供版权或权益证明然后发送到邮箱[email protected],我们会在看到邮件的第一时间内为您处理,或直接联系QQ:872152909。本网站采用BY-NC-SA协议进行授权
转载请注明原文链接:页面中嵌入google的pagerank显示_PHP
喜欢 (0)
[搞代码]
分享 (0)
发表我的评论
取消评论

表情 贴图 加粗 删除线 居中 斜体 签到

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址