function getpagerank($url) { $fp = @fsockopen("toolbarqueries.google.com", 80, $errno, $errstr, 30); if (!$fp) { echo "Fehler: {$errstr} ({$errno})<br />\n"; } else { $out = "GET /tbr?client=navclient-auto&ch=" . CheckHash(HashURL($url)) . "&features=Rank&q=info:" . $url . "&num=100&filter=0 HTTP/1.1\r\n"; $out .= "Host: toolbarqueries.google.com\r\n"; $out .= "User-Agent: Mozilla/4.0 (compatible; GoogleToolbar 2.0.114-big; Windows XP 5.1)\r\n"; $out .= "Connection: Close\r\n\r\n"; fwrite($fp, $out); //$pagerank = substr(fgets($fp, 128), 4); //echo $pagerank; while (!feof($fp)) { $data = fgets($fp, 128); // echo $data; $pos = strpos($data, "Rank_"); if ($pos === false) { } else { $pagerank = substr($data, $pos + 9); return $pagerank; } } fclose($fp); } }
/** * Куча функций, чтобы определить Google Pagerank */ function get_google_pagerank($url) { $query = "http://toolbarqueries.google.com/tbr?client=navclient-auto&ch=" . CheckHash(HashURL($url)) . "&features=Rank&q=info:" . $url . "&num=100&filter=0"; $data = file_get_contents($query); $pos = strpos($data, "Rank_"); if ($pos === false) { } else { $pagerank = substr($data, $pos + 9); return $pagerank; } }
function Gonten_prget($domain) { $GontenPRURL = "http://www.google.com/search?client=navclient-auto&features=Rank:&q=info:" . $domain . '&ch=' . HashURL($domain); $prstr = file_get_contents($GontenPRURL); $pagerank = substr($prstr, 9); if ($pagerank) { return $pagerank; } else { return "0"; } }
function GetPR($url) { $gurl = "http://www.google.com/search?client=navclient-auto&features=Rank:&q=info:" . $url . '&ch=' . HashURL($url); $gcontent = @file_get_contents($gurl); if (strlen($gcontent) == 11) { return substr($gcontent, 9, 1); } elseif (strlen($gcontent) == 12) { return substr($gcontent, 9, 2); } else { return 0; } }
function getch($url) { return CheckHash(HashURL($url)); }
ob_start(); locate_template(array($template), true, false); $posts = ob_get_contents(); ob_end_clean(); return $posts; } function stf_pagerank($atts) { function CheckHash($Hashnum) { $CheckByte = 0; $Flag = 0; $HashStr = sprintf('%u', $Hashnum); $length = strlen($HashStr); for ($i = $length - 1; $i >= 0; $i--) { $Re = $HashStr[$i]; if (1 === $Flag % 2) { $Re += $Re; $Re = (int) ($Re / 10) + $Re % 10; } $CheckByte += $Re; $Flag++; } $CheckByte %= 10; if (0 !== $CheckByte) { $CheckByte = 10 - $CheckByte; if (1 === $Flag % 2) { if (1 === $CheckByte % 2) { $CheckByte += 9; } $CheckByte >>= 1; } } return '7' . $CheckByte . $HashStr; } function HashURL($String) { function StrToNum($Str, $Check, $Magic) { $Int32Unit = 4294967296; // 2^32 $length = strlen($Str); for ($i = 0; $i < $length; $i++) { $Check *= $Magic; //If the float is beyond the boundaries of integer (usually +/- 2.15e+9 = 2^31), // the result of converting to integer is undefined // refer to http://www.php.net/manual/en/language.types.integer.php if ($Check >= $Int32Unit) { $Check = $Check - $Int32Unit * (int) ($Check / $Int32Unit); //if the check less than -2^31 $Check = $Check < -2147483648 ? $Check + $Int32Unit : $Check; } $Check += ord($Str[$i]); } return $Check; } $Check1 = StrToNum($String, 0x1505, 0x21); $Check2 = StrToNum($String, 0, 0x1003f); $Check1 >>= 2; $Check1 = $Check1 >> 4 & 0x3ffffc0 | $Check1 & 0x3f; $Check1 = $Check1 >> 4 & 0x3ffc00 | $Check1 & 0x3ff; $Check1 = $Check1 >> 4 & 0x3c000 | $Check1 & 0x3fff; $T1 = (($Check1 & 0x3c0) << 4 | $Check1 & 0x3c) << 2 | $Check2 & 0xf0f; $T2 = (($Check1 & 0xffffc000) << 4 | $Check1 & 0x3c00) << 0xa | $Check2 & 0xf0f0000; return $T1 | $T2; } extract(shortcode_atts(array('url' => get_bloginfo('url')), $atts)); $pagerank = 0; if (false === ($pagerank = get_transient('pr_' + md5($url)))) { $query = "http://toolbarqueries.google.com/search?client=navclient-auto&ch=" . CheckHash(HashURL($url)) . "&features=Rank&q=info:" . $url . "&num=100&filter=0"; $request = new WP_Http(); $result = $request->request($query); $pos = strpos($result['body'], "Rank_"); if ($pos === false) { } else { $pagerank = substr($result['body'], $pos + 9); } set_transient('pr_' + md5($url), $pagerank, 60 * 60 * 24); // 24 hours } $output = '<div class="pagerank button" title="Google PageRank ™">';