模拟Google ToolBar直接提交PageRank请求
作者:佚名 文章来源:网络 更新时间
:2008-7-7 17:41:33
l[$k+10]<<24);
case 10: $c+=($url[$k+9]<<16);
case 9 : $c+=($url[$k+8]<<8);
/* the first byte of c is reserved for the length */
case 8 : $b+=($url[$k+7]<<24);
case 7 : $b+=($url[$k+6]<<16);
case 6 : $b+=($url[$k+5]<<8);
case 5 : $b+=($url[$k+4]);
case 4 : $a+=($url[$k+3]<<24);
case 3 : $a+=($url[$k+2]<<16);
case 2 : $a+=($url[$k+1]<<8);
case 1 : $a+=($url[$k+0]);
/* case 0: nothing left to add */
}
$mix = mix($a,$b,$c);
/*-------------------------------------------- report the result */
return $mix[2];
}
//converts a string into an array of integers containing the numeric value of the char
function strord($string) {
for($i=0;$i<strlen($string);$i++) {
$result[$i] = ord($string{$i});
}
return $result;
}
function ReadPR($link)
{
$fp = fsockopen ("www.google.com", 80, $errno, $errstr, 30);
//$ip = gethostbyname("www.google.com");
//$fp = fsockopen ($ip, 80, $errno, $errstr, 30);
if (!$fp)
{
echo "$errstr ($errno)\n";
exit(1);
}
else
{
//$out = "GET $link HTTP/1.1\r\n";
$out = "GET $link HTTP/1.0\r\n";
$out .= "Host: toolbarqueries.google.com\r\n";
$out .= "User-Agent: Mozilla/4.0 (compatible; GoogleToolbar 2.0.114.9-big; Windows 5.2)\r\n";
$out .= "Connection: Close\r\n\r\n";
fwrite($fp, $out);
//while (!feof($fp))
// echo fgets ($fp,128);
do{
$line = fgets($fp, 128);
}while ($line !== "\r\n");
$data = fread($fp,8192);
fclose ($fp);
return $data;
}
}
function GetPR($url)
{
$url ='info:'.$url;
$ch = GoogleCH(strord($url));
$data = ReadPR("/search?client=navclient-auto&ch=6$ch&features=Rank&q=$url");
$rankarray = explode (':', $data);
return $rankarray[2];
}
$provider = '<br /><br /><small>Provided by <a h ref="http://www.lan27.com/" target="_blank">lan27.com</ a></s mall>';
if ( isset($_POST['url']) && $_POST['url'] !== '' )
{
echo 'PageRank: '.GetPR($_POST['url']).$provider;
}
else
{
echo "<html><title>Get PageRank From Google.com</title><body>PageRank(PR) Querying Script< br / >";
echo "<form action='' method='post'>"."<br/>URL:<input name='url' value='http://' type='text' size=40>";
echo "<input name='submit' type='submit' value='GetPR'></form>".$provider."</body></html>";
}
?>
【相关文章:】
PHP读取RSS feed源代码(带注释,可读取多个源)
Apache+php+mysql安装与配置图解(最新版)
Apache与PHP的整合过程
PHP原版HTML编码器溢出问题的解决
用PHPINFO来实现PHP的配置统计过程
新手如何使用PHP创建RSS阅读器
半小时精通PHP正则表达式
PHP网页制作常用的正则表达式
PHP+MYSQL+Javascript数据库查询结果的动态显示
如何在Linux下装PHP+JSP
【发表评论】【打印此文】【关闭窗口】【点击数: 】
case 10: $c+=($url[$k+9]<<16);
case 9 : $c+=($url[$k+8]<<8);
/* the first byte of c is reserved for the length */
case 8 : $b+=($url[$k+7]<<24);
case 7 : $b+=($url[$k+6]<<16);
case 6 : $b+=($url[$k+5]<<8);
case 5 : $b+=($url[$k+4]);
case 4 : $a+=($url[$k+3]<<24);
case 3 : $a+=($url[$k+2]<<16);
case 2 : $a+=($url[$k+1]<<8);
case 1 : $a+=($url[$k+0]);
/* case 0: nothing left to add */
}
$mix = mix($a,$b,$c);
/*-------------------------------------------- report the result */
return $mix[2];
}
//converts a string into an array of integers containing the numeric value of the char
function strord($string) {
for($i=0;$i<strlen($string);$i++) {
$result[$i] = ord($string{$i});
}
return $result;
}
function ReadPR($link)
{
$fp = fsockopen ("www.google.com", 80, $errno, $errstr, 30);
//$ip = gethostbyname("www.google.com");
//$fp = fsockopen ($ip, 80, $errno, $errstr, 30);
if (!$fp)
{
echo "$errstr ($errno)\n";
exit(1);
}
else
{
//$out = "GET $link HTTP/1.1\r\n";
$out = "GET $link HTTP/1.0\r\n";
$out .= "Host: toolbarqueries.google.com\r\n";
$out .= "User-Agent: Mozilla/4.0 (compatible; GoogleToolbar 2.0.114.9-big; Windows 5.2)\r\n";
$out .= "Connection: Close\r\n\r\n";
fwrite($fp, $out);
//while (!feof($fp))
// echo fgets ($fp,128);
do{
$line = fgets($fp, 128);
}while ($line !== "\r\n");
$data = fread($fp,8192);
fclose ($fp);
return $data;
}
}
function GetPR($url)
{
$url ='info:'.$url;
$ch = GoogleCH(strord($url));
$data = ReadPR("/search?client=navclient-auto&ch=6$ch&features=Rank&q=$url");
$rankarray = explode (':', $data);
return $rankarray[2];
}
$provider = '<br /><br /><small>Provided by <a h ref="http://www.lan27.com/" target="_blank">lan27.com</ a></s mall>';
if ( isset($_POST['url']) && $_POST['url'] !== '' )
{
echo 'PageRank: '.GetPR($_POST['url']).$provider;
}
else
{
echo "<html><title>Get PageRank From Google.com</title><body>PageRank(PR) Querying Script< br / >";
echo "<form action='' method='post'>"."<br/>URL:<input name='url' value='http://' type='text' size=40>";
echo "<input name='submit' type='submit' value='GetPR'></form>".$provider."</body></html>";
}
?>
【相关文章:】
PHP读取RSS feed源代码(带注释,可读取多个源)
Apache+php+mysql安装与配置图解(最新版)
Apache与PHP的整合过程
PHP原版HTML编码器溢出问题的解决
用PHPINFO来实现PHP的配置统计过程
新手如何使用PHP创建RSS阅读器
半小时精通PHP正则表达式
PHP网页制作常用的正则表达式
PHP+MYSQL+Javascript数据库查询结果的动态显示
如何在Linux下装PHP+JSP
【发表评论】【打印此文】【关闭窗口】【点击数: 】
★好玩的休闲小游戏★
网友评论:
数据载入中,请稍后……
