嘉興網(wǎng)站開(kāi)發(fā):php語(yǔ)言如何查看pr代碼和firefox如何用書簽查詢網(wǎng)站pr值?
通常情況下在chrome或者firefox都有pr查詢工具,訪問(wèn)某個(gè)網(wǎng)頁(yè)的時(shí)候,自動(dòng)顯示當(dāng)前網(wǎng)站的pr值。但并不是所有的頁(yè)面都需要查詢,于是小編弄了一個(gè)查詢pr的書簽,僅在需要查詢的時(shí)候,再點(diǎn)擊查詢。
附用php的實(shí)現(xiàn)pr思路:
<?php
$url = $_GET['url'];
$html_url = htmlspecialchars($url);
function HashURL($url)
{$SEED = "Mining PageRank is AGAINST GOOGLE'S TERMS OF SERVICE.";
$Result = 0x01020345;
for ($i=0; $i<strlen($url); $i++)
{
$Result ^= ord($SEED{$i%87}) ^ ord($url{$i});
$Result = (($Result >> 23) & 0x1FF) | $Result << 9;
}
return sprintf("8%x", $Result);
}
function pagerank($domain)
{
$StartURL = "http://toolbarqueries.google.com/tbr?client=navclient-auto&features=Rank:&q=info:";
$GoogleURL = $StartURL.$domain. '&ch='.HashURL($domain);
$fcontents = file_get_contents("$GoogleURL");
$pagerank = substr($fcontents,9);
if (!$pagerank) return "0";else return $pagerank;
}
$website = $html_url;
$website = str_replace("http://","",$website);
@ $pr = pagerank("$website");
@ date_default_timezone_set(PRC);
$now_date = date("Y年n月j日 G時(shí)i分s秒");
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>PR查詢</title>
</head>
<body>
<?php
echo '<p id="pr_info"><b>'.$html_url.'</b> 的PR為 '.$pr.' <a href="http://upload.chinaz.com//"/></a></p><p><span>查詢時(shí)間:'.$now_date.'</span></p>';
?>
</body>
</html>
javascript:
(function()%7Bvar%20d=document;var%20l=location;var%20u=l.toString();var%20s=d.createElement('script');var%20b='http://ncmofei.com/pr/';var%20n=b+'url.php?'+'&url='+encodeURIComponent(u);window.open(n);%7D)();
使用方法:
添加上面的js代碼到自己的書簽就可以了。在需要查詢pr的網(wǎng)址,直接點(diǎn)書簽即可!