Guest User

Untitled

a guest
Nov 8th, 2011
231
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.59 KB | None | 0 0
  1. <?
  2. //Функция определение Гугла ПР
  3. $googlehost='toolbarqueries.google.com';
  4. $googleua='Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.0.6) Gecko/20060728 Firefox/1.5';
  5.  
  6. function StrToNum($Str, $Check, $Magic) {
  7. $Int32Unit = 4294967296;
  8.  
  9. $length = strlen($Str);
  10. for ($i = 0; $i < $length; $i++) {
  11. $Check *= $Magic;
  12. if ($Check >= $Int32Unit) {
  13. $Check = ($Check - $Int32Unit * (int) ($Check / $Int32Unit));
  14. $Check = ($Check < -2147483648) ? ($Check + $Int32Unit) : $Check;
  15. }
  16. $Check += ord($Str{$i});
  17. }
  18. return $Check;
  19. }
  20.  
  21. function HashURL($String) {
  22. $Check1 = StrToNum($String, 0x1505, 0x21);
  23. $Check2 = StrToNum($String, 0, 0x1003F);
  24.  
  25. $Check1 >>= 2;
  26. $Check1 = (($Check1 >> 4) & 0x3FFFFC0 ) | ($Check1 & 0x3F);
  27. $Check1 = (($Check1 >> 4) & 0x3FFC00 ) | ($Check1 & 0x3FF);
  28. $Check1 = (($Check1 >> 4) & 0x3C000 ) | ($Check1 & 0x3FFF);
  29.  
  30. $T1 = (((($Check1 & 0x3C0) << 4) | ($Check1 & 0x3C)) <<2 ) | ($Check2 & 0xF0F );
  31. $T2 = (((($Check1 & 0xFFFFC000) << 4) | ($Check1 & 0x3C00)) << 0xA) | ($Check2 & 0xF0F0000 );
  32.  
  33. return ($T1 | $T2);
  34. }
  35.  
  36. function CheckHash($Hashnum) {
  37. $CheckByte = 0;
  38. $Flag = 0;
  39.  
  40. $HashStr = sprintf('%u', $Hashnum) ;
  41. $length = strlen($HashStr);
  42.  
  43. for ($i = $length - 1; $i >= 0; $i --) {
  44. $Re = $HashStr{$i};
  45. if (1 === ($Flag % 2)) {
  46. $Re += $Re;
  47. $Re = (int)($Re / 10) + ($Re % 10);
  48. }
  49. $CheckByte += $Re;
  50. $Flag ++;
  51. }
  52.  
  53. $CheckByte %= 10;
  54. if (0 !== $CheckByte) {
  55. $CheckByte = 10 - $CheckByte;
  56. if (1 === ($Flag % 2) ) {
  57. if (1 === ($CheckByte % 2)) {
  58. $CheckByte += 9;
  59. }
  60. $CheckByte >>= 1;
  61. }
  62. }
  63.  
  64. return '7'.$CheckByte.$HashStr;
  65. }
  66.  
  67. function getch($url) { return CheckHash(HashURL($url)); }
  68.  
  69. function getpr($url) {
  70. global $googlehost,$googleua;
  71. $ch = getch($url);
  72. $fp = fsockopen($googlehost, 80, $errno, $errstr, 30);
  73. if ($fp) {
  74. $out = "GET /search?client=navclient-auto&ch=$ch&features=Rank&q=info:$url HTTP/1.1\r\n";
  75. $out .= "User-Agent: $googleua\r\n";
  76. $out .= "Host: $googlehost\r\n";
  77. $out .= "Connection: Close\r\n\r\n";
  78.  
  79. fwrite($fp, $out);
  80. while (!feof($fp)) {
  81. $data = fgets($fp, 128);
  82. $pos = strpos($data, "Rank_");
  83. if($pos === false){} else{
  84. $pr=substr($data, $pos + 9);
  85. $pr=trim($pr);
  86. $pr=str_replace("\n",'',$pr);
  87. return $pr;
  88. }
  89. }
  90. fclose($fp);
  91. }
  92. }
  93. //Функция определения Яндекс ТИца
  94. function getBarCY($_url) {
  95. $_uri = "http://bar-navig.yandex.ru/u?ver=2&url=".urlencode("http://".$_url)."&show=1";
  96. $fd = @fopen($_uri, "r");
  97. if ($fd) {
  98. while ($buffer = fgets($fd, 4096)) $haystack.=$buffer;
  99. fclose($fd);
  100. preg_match("/<tcy rang=\"(.*)\" value=\"(.*)\"\/>/isU",
  101. $haystack,$cy);
  102. return (int) $cy[2];
  103. } else return 0;
  104. }
  105.  
  106. function outin_links($url) {
  107. $in_links = array();
  108. $out_links = array();
  109.  
  110. // HOST адреса страницы для проверки полных ссылок на локальность
  111. $url_host = parse_url($url, PHP_URL_HOST);
  112. if ( preg_match('/^www\./i', $url_host) ) $url_host = substr($url_host, 4);
  113.  
  114. $html = @file_get_contents($url);
  115. if ( false===$html ) return false;
  116.  
  117. $xml = new DOMDocument();
  118. @$xml->loadHTML($html);
  119.  
  120. // Получаем объектно ориентированный массив тегов A из HTML
  121. $links = $xml->getElementsByTagName('a');
  122. if ( count($links)<1 ) return false;
  123.  
  124. foreach ( $links as $link ) :
  125. // У тега A нет атрибута href
  126. if ( !$link->hasAttribute('href') ) continue;
  127.  
  128. $href = $link->getAttribute('href');
  129. if ( empty($href) ) continue;
  130.  
  131. // Если адрес ссылки начинается с "http://" или "https://"
  132. if ( preg_match('/^http(s)?:\/\//i', $href) ) {
  133. $href_host = parse_url($href, PHP_URL_HOST);
  134. if ( preg_match('/^www\./i', $href_host) ) $href_host = substr($href_host, 4);
  135.  
  136. // Если HOST указанного адреса страницы и хост ссылки совпадают
  137. if ( preg_match('/^' . preg_quote($url_host) . '$/i', $href_host) ) $in_links[] = $href; else $out_links[] = $href;
  138. } else $in_links[] = $href;
  139. endforeach;
  140.  
  141. return array($in_links, $out_links);
  142. }
  143.  
  144. ?>
  145.  
Advertisement
Add Comment
Please, Sign In to add comment