PHP获取PR值的代码(3)
case 6 :
$b+=trunkbitForce32bit($url[$k+5]<<8);
case 5 :
$b+=trunkbitForce32bit($url[$k+4]);
case 4 :
$a+=trunkbitForce32bit($url[$k+3]<<24);
case 3 :
$a+=trunkbitForce32bit($url[$k+2]<<16);
case 2 :
$a+=trunkbitForce32bit($url[$k+1]<<8);
case 1 :
$a+=trunkbitForce32bit($url[$k+0]);
}
$mixo = mix( $a, $b, $c );
$mixo[2] = trunkbitForce32bit($mixo[2]);
if( $mixo[2] < 0 ){
return (
hexdec('1'.
implode('',
array_fill(0,PHP_INT_SIZE*2,'0')))
+ $mixo[2] );
}
else{
return $mixo[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;
}
// return url page content or false if failed.
function retrieveURLContent($url,$gettype){
switch($gettype){
case G_PR_GET_TYPE_FILE:
return retrieveURLContentByFile($url);
break;
default:
return retrieveURLContentBySocket($url);
break;
}
}
function retrieveURLContentByFile($url){
$fd = @fopen($url,"r");
if(!$fd){
return false;
} www.2cto.com
$result = "";
while($buffer = fgets($fd, 4096)) {
$result .= $buffer;
}
fclose($fd);
return $result;
}
function retrieveURLContentBySocket($url,
$host="",
$port=80,
$timeout=30){
if($host == ""){
if(!($pos = strpos($url,'://'))){
return false;
}
$host = substr( $url,
$pos+3,
strpos($url,'/',$pos+3) - $pos - 3);
$uri = substr($url,strpos($url,'/',$pos+3));
}
else{
$uri = $url;
}
$request = "GET ".$uri." HTTP/1.0\r\n"
."Host: ".$host."\r\n"
."Accept: */*\r\n"
."User-Agent: ZealGet\r\n"
."\r\n";
$sHnd = @fsockopen ($host, $port, $errno, $errstr, $timeout);
if(!$sHnd){
return false;
}
@fputs ($sHnd, $request);
// Get source
$result = "";
while (!feof($sHnd)){
$result .= fgets($sHnd,4096);
}
fclose($sHnd);
$headerend = strpos($result,"\r\n\r\n");
if (is_bool($headerend))
{
return $result;
}
else{
return substr($result,$headerend+4);
}
}
echo getPR($url);
?>
摘自Shine的圣天堂-〃敏〃
相关新闻>>
- 发表评论
-
- 最新评论 更多>>