PHP Google PR Value code

Source: Internet
Author: User
Tags numeric value

<?php
Require DirName (__file__). '/moophp/moophp.php ';
Define (' Gmag ', 0xe6359a60);

Note to obtain and process variables that may be obtained
$site = MOOGETGPC (' site ', ' string ');
$host = ';
$style = isset ($_get[' style ')? $_get[' style ']:1;
$host = $_server[' http_host '];
$site = Str_replace (' http://', ', ', $host);

if ($site) {
$PR = GETPR ($site);
Switch ($style)
{
Case 3:
Echo ' document.write ("<a href=http://tool.111cn.net/pr/pr.php title= China web first station TARGET=_BLANK&GT;&LT;IMG Src=yun_qi _img/a '. $pr. png border=0/></a> ");
Break
Case 2:
Echo ' document.write ("<a href=http://tool.111cn.net/pr/pr.php title= China web first station TARGET=_BLANK&GT;&LT;IMG Src=yun_qi _img/b '. $pr. png border=0/></a> ");
Break
Case 1:

Echo ' document.write ("<a href=http://tool.111cn.net/pr/pr.php title= China web first station TARGET=_BLANK&GT;&LT;IMG Src=yun_qi _img/c '. $pr. png border=0/></a> ");
Break
Default
Echo ' document.write ("<a href=http://tool.111cn.net/pr/pr.php title= China web first station TARGET=_BLANK&GT;&LT;IMG Src=yun_qi _img/a '. $pr. png border=0/></a> ");
Break
}

}
Else
{
Echo ' has a problem ';
}


Include Mootemplate ("Pr_index");


Note processing functions to obtain PR value

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 is 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://64.233.161.104/search ? client=navclient-auto&ch=6 "
        $ch." &ie=utf-8&oe=utf-8&features=rank&q= ". $url;
    $PR _str = retrieveurlcontent ($GOOGLEPRURL, $gettype);
    return Intval (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);
 & nbsp;      $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 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)); $a = trunkbitforce32bit ($a);


$b-= $c; $b = Trunkbitforce32bit ($b);
$b-= $a; $b = Trunkbitforce32bit ($b);
$b = Bigxor ($b, trunkbitforce32bit ($a <<16));

$c-= $a; $c = Trunkbitforce32bit ($c);
$c-= $b; $c = Trunkbitforce32bit ($c);
$c = Bigxor ($c, (Zerofill ($b, 5)); $c = Trunkbitforce32bit ($c);

$a-= $b; $a = trunkbitforce32bit ($a);
$a-= $c; $a = trunkbitforce32bit ($a);
$a = Bigxor ($a, (Zerofill ($c, 3)); $a = trunkbitforce32bit ($a);


$b-= $c; $b = Trunkbitforce32bit ($b);
$b-= $a; $b = Trunkbitforce32bit ($b);
$b = Bigxor ($b, trunkbitforce32bit ($a <<10));

$c-= $a; $c = Trunkbitforce32bit ($c);
$c-= $b; $c = Trunkbitforce32bit ($c);
$c = Bigxor ($c, (Zerofill ($b, 15)); $c = Trunkbitforce32bit ($c);

Return Array ($a, $b, $c);
}

function Newgch ($ch) {
$ch = (Trunkbitforce32bit ($ch/7) << 2) |
((Myfmod ($ch)) & 7));

$prbuf = Array ();
$prbuf [0] = $ch;
for ($i = 1; $i < $i + +)
{
$prbuf [$i] = $prbuf [$i-1]-9;
}

$ch = GCH (C32to8bit ($PRBUF));

return $ch;
}
function Myfmod ($x, $y) {
$i = Floor ($x/$y);
Return ($x-$i * $y);
}
function C32to8bit ($arr 32) {
$arr 8 = array ();

for ($i = 0; $i < count ($arr); $i + +) {
for ($bitOrder = $i * 4;
$bitOrder <= $i * 4 + 3; $bitOrder + +) {
$arr 8[$bitOrder] = $arr 32[$i] & 255;
$arr 32[$i] = Zerofill ($arr 32[$i], 8);
}
}

return $arr 8;
}

function GCH ($url, $length =null) {
if (Is_null ($length)) {
$length = sizeof ($url);
}
$init = 0xe6359a60;

$a = 0x9e3779b9;
$b = 0X9E3779B9;
$c = 0xe6359a60;
$k = 0;
$len = $length;
$mixo = Array ();

while ($len >= 12) {
$a + + ($url [$k +0] +trunkbitforce32bit ($url [$k +1]<<8)
+trunkbitforce32bit ($url [$k +2]<<16)
+trunkbitforce32bit ($url [$k +3]<<24));
$b + + ($url [$k +4] +trunkbitforce32bit ($url [$k +5]<<8)
+trunkbitforce32bit ($url [$k +6]<<16)
+trunkbitforce32bit ($url [$k +7]<<24));
$c + + ($url [$k +8] +trunkbitforce32bit ($url [$k +9]<<8)
+trunkbitforce32bit ($url [$k +10]<<16)
+trunkbitforce32bit ($url [$k +11]<<24));
$mixo = Mix ($a, $b, $c);
$a = $mixo [0]; $b = $mixo [1]; $c = $mixo [2];
$k + 12;
$len-= 12;
}

$c + + $length;

Switch ($len) {
Case 11:
$c + + trunkbitforce32bit ($url [$k +10]<<24);

Case 10:
$c +=trunkbitforce32bit ($url [$k +9]<<16);

Case 9:
$c +=trunkbitforce32bit ($url [$k +8]<<8);

Case 8:
$b +=trunkbitforce32bit ($url [$k +7]<<24);

Case 7:
$b +=trunkbitforce32bit ($url [$k +6]<<16);

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 (
  & nbsp;         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;
}


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;
}
$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.0rn "
." Host: ". $host." Rn
." Accept: */*rn "
." User-agent:zealgetrn "
." RN ";
$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, "rnrn");
if (Is_bool ($headerend))
{
return $result;
}
else{
Return substr ($result, $headerend +4);
}
}

Webmaster Recommended:

http://tool.111cn.net/pr/pr.php can query the PR value of your site and can also call PR on your site to show Oh.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.