PHP获取PR值的代码
用C#写个软件,不知道谷歌的接口用C#写感觉太麻烦了
于是在csdn下载了一份代码,改成用软件查询的接口。
http://www.xssxss.com/pr.php?url=www.google.com
代码
<?php
$url= $_GET['url'];
// url get method macro.
define('G_PR_GET_TYPE_FILE', 1); // use fopen() function
define('G_PR_GET_TYPE_SOCKET', 2); // use standard fsocketopen function
// main function to be called
function getPR($_url,$gettype=G_PR_GET_TYPE_SOCKET){
$url = 'info:'.$_url;
$ch = GCH(strord($url));
$ch = NewGCH($ch);
$url=str_replace("_","%5F",'info:'.urlencode($_url));
$googlePRUrl =
"http://toolbarqueries.google.com/tbr?client=navclient-auto&ch=6"
.$ch."&ie=UTF-8&oe=UTF-8&features=Rank&q=".$url;
$pr_str = retrieveURLContent($googlePRUrl,$gettype);
return substr($pr_str,strrpos($pr_str, ":")+1);
}
//unsigned shift right
function zeroFill($a, $b){
$z = hexdec('8'.implode('',array_fill(0,PHP_INT_SIZE*2-1,'0')));
if ($z & $a){
$a = ($a>>1);
$a &= (~$z);
$a |= hexdec('4'.implode('',array_fill(0,PHP_INT_SIZE*2-1,'0')));
$a = ($a>>($b-1));
}
else{
$a = ($a>>$b);
}
return $a;
}
// discard bits beyonds 32 bit.
function trunkbitForce32bit($n){
if(PHP_INT_SIZE <= 4){
settype($n,'float');
if ( $n < 0 ) $n += 4294967296;
return $n;
}
else{
$clearbit = '';
for($i=0;$i<PHP_INT_SIZE-4;$i++){
$clearbit .= '00';
}
for($i=0;$i<4;$i++){
$clearbit .= 'ff';
}
return ($n & hexdec($clearbit));
}
}
function bigxor($m,$n){
//if(function_exists('gmp_init')){
// return floatval(gmp_strval(gmp_xor($m,$n)));
//}
//else{
return $m ^ $n;
//}
}
function mix($a,$b,$c){
$a = trunkbitForce32bit($a);
$b = trunkbitForce32bit($b);
$c = trunkbitForce32bit($c);
$a -= $b; $a = trunkbitForce32bit($a);
$a -= $c; $a = trunkbitForce32bit($a);
$a = bigxor($a,(zeroFill($c,13))); $a = trunkbitForce32bit($a);
$b -= $c; $b = trunkbitForce32bit($b);
$b -= $a; $b = trunkbitForce32bit($b);
$b = bigxor($b,trunkbitForce32bit($a<<8)); $b = trunkbitForce32bit($b);
$c -= $a; $c = trunkbitForce32bit($c);
$c -= $b; $c = trunkbitForce32bit($c);
$c = bigxor($c,(zeroFill($b,13))); $c = trunkbitForce32bit($c);
$a -= $b;$a = trunkbitForce32bit($a);
$a -= $c;$a = trunkbitForce32bit($a);
$a = bigxor($a,(zeroFill($c,12)));$a = trunkbitForce32bit($a);
相关新闻>>
- 发表评论
-
- 最新评论 更多>>