查GOOGLE pr值的函数

查GOOGLE pr值的函数,怎么用呢?<br /> <br /> &lt;?php<br /> //下面的函数用于查pr<br /> function zeroFill($a, $b) <br /> { <br /> $z = hexdec(80000000); <br /> if ($z &amp; $a) <br /> { <br /> $a = ($a&gt;&gt;1); <br /> $a &amp;= (~$z); <br /> $a |= 0x40000000; <br /> $a = ($a&gt;&gt;($b-1)); <br /> } <br /> else <br /> { <br /> $a = ($a&gt;&gt;$b); <br /> } <br /> return $a; <br /> } <br /> <br /> function mix($a,$b,$c) <br /> { <br /> $a -= $b; $a -= $c; $a ^= (zeroFill($c,13)); <br /> $b -= $c; $b -= $a; $b ^= ($a&lt;&lt;8); <br /> $c -= $a; $c -= $b; $c ^= (zeroFill($b,13)); <br /> $a -= $b; $a -= $c; $a ^= (zeroFill($c,12)); <br /> $b -= $c; $b -= $a; $b ^= ($a&lt;&lt;16); <br /> $c -= $a; $c -= $b; $c ^= (zeroFill($b,5)); <br /> $a -= $b; $a -= $c; $a ^= (zeroFill($c,3)); <br /> $b -= $c; $b -= $a; $b ^= ($a&lt;&lt;10); <br /> $c -= $a; $c -= $b; $c ^= (zeroFill($b,15)); <br /> return array($a,$b,$c); <br /> } <br /> <br /> function GoogleCH($url, $length=null, $init=GOOGLE_MAGIC) <br /> { <br /> if(is_null($length)) <br /> { <br /> $length = sizeof($url); <br /> } <br /> $a = $b = 0x9E3779B9; <br /> $c = $init; <br /> $k = 0; <br /> $len = $length; <br /> while($len &gt;= 12) <br /> { <br /> $a += ($url[$k+0] +($url[$k+1]&lt;&lt;8) +($url[$k+2]&lt;&lt;16) +($url[$k+3]&lt;&lt;24)); <br /> $b += ($url[$k+4] +($url[$k+5]&lt;&lt;8) +($url[$k+6]&lt;&lt;16) +($url[$k+7]&lt;&lt;24)); <br /> $c += ($url[$k+8] +($url[$k+9]&lt;&lt;8) +($url[$k+10]&lt;&lt;16)+($url[$k+11]&lt;&lt;24)); <br /> $mix = mix($a,$b,$c); <br /> $a = $mix[0]; $b = $mix[1]; $c = $mix[2]; <br /> $k += 12; <br /> $len -= 12; <br /> } <br /> $c += $length; <br /> switch($len) <br /> { <br /> case 11: $c+=($url[$k+10]&lt;&lt;24); <br /> case 10: $c+=($url[$k+9]&lt;&lt;16); <br /> case 9 : $c+=($url[$k+8]&lt;&lt;8); <br /> case 8 : $b+=($url[$k+7]&lt;&lt;24); <br /> case 7 : $b+=($url[$k+6]&lt;&lt;16); <br /> case 6 : $b+=($url[$k+5]&lt;&lt;8); <br /> case 5 : $b+=($url[$k+4]); <br /> case 4 : $a+=($url[$k+3]&lt;&lt;24); <br /> case 3 : $a+=($url[$k+2]&lt;&lt;16); <br /> case 2 : $a+=($url[$k+1]&lt;&lt;8); <br /> case 1 : $a+=($url[$k+0]); <br /> } <br /> $mix = mix($a,$b,$c); <br /> return $mix[2]; <br /> } <br /> <br /> function strord($string) { <br /> for($i=0;$i&lt;strlen($string);$i++) { <br /> $result[$i] = ord($string{$i}); <br /> } <br /> return $result; <br /> } <br /> <br /> function ReadPR($link) <br /> { <br /> $fp = fsockopen (&quot;www.google.com&quot;, 80, $errno, $errstr, 30); <br /> if (!$fp) <br /> { <br /> echo &quot;$errstr ($errno)\n&quot;; <br /> exit(1); <br /> } <br /> else <br /> { <br /> $out = &quot;GET $link HTTP/1.0\r\n&quot;; <br /> $out .= &quot;Host: toolbarqueries.google.com\r\n&quot;; <br /> $out .= &quot;User-Agent: Mozilla/4.0 (compatible; GoogleToolbar 2.0.114.9-big; Linux 2.6)\r\n&quot;; <br /> $out .= &quot;Connection: Close\r\n\r\n&quot;; <br /> fwrite($fp, $out); <br /> do{ <br /> $line = fgets($fp, 128); <br /> }while ($line !== &quot;\r\n&quot;); <br /> $data = fread($fp,8192); <br /> fclose ($fp); <br /> return $data; <br /> } <br /> }<br /> <br /> function GetPR($url) <br /> { <br /> $url ='info:'.$url; <br /> $ch = GoogleCH(strord($url)); <br /> $data = ReadPR(&quot;/search?client=navclient-auto&amp;ch=6$ch&amp;features=Rank&amp;q=$url&quot;);<br /> $data = str_replace(&quot;1ex}div.nav A {font-size&quot;,&quot;&quot;,$data ); <br /> $rankarray = explode (':', $data); <br /> if(trim($rankarray[2])!=&quot;&quot;){<br /> return $rankarray[2];<br /> }<br /> else<br /> return &quot;0&quot;;<br /> } <br /> ?&gt;
RangeTime:0.005971s
RangeMem:207.52 KB
返回顶部 留言