Phpgooglepr value code-PHP source code

Source: Internet
Author: User
The following code gets the googlepr value and supports js call display. The code below is a piece of code to get the google prvalue and also supports js call display.

Script ec (2); script

// Require dirname (_ FILE _). '/MooPHP. php ';
Define ('gmag', 0xE6359A60 );

// Note: Get 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 ("");';
Break;
Case 2:
Echo 'document. write ("");';
Break;
Case 1:

Echo 'document. write ("");';
Break;
Default:
Echo 'document. write ("");';
Break;
}

}
Else
{
Echo 'problematic ';
}


// Include MooTemplate ("pr_index ");


// Note the function used to obtain the prvalue

// 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: // 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> 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 $;
}

// 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 $ 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 ($ );
$ B = trunkbitForce32bit ($ B );
$ C = trunkbitForce32bit ($ c );


$ A-= $ B; $ a = trunkbitForce32bit ($ );
$ A-= $ c; $ a = trunkbitForce32bit ($ );
$ A = bigxor ($ a, (zeroFill ($ c, 13); $ a = trunkbitForce32bit ($ );


$ 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-= $ c; $ a = trunkbitForce32bit ($ );
$ A = bigxor ($ a, (zeroFill ($ c, 12); $ a = trunkbitForce32bit ($ );


$ 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-= $ c; $ a = trunkbitForce32bit ($ );
$ A = bigxor ($ a, (zeroFill ($ c, 3); $ a = trunkbitForce32bit ($ );


$ 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, 13) & 7 ));

$ Prbuf = array ();
$ Prbuf [0] = $ ch;
For ($ I = 1; $ I <20; $ 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 ($ arr32 ){
$ Arr8 = array ();

For ($ I = 0; $ I <count ($ arr32); $ I ++ ){
For ($ bitOrder = $ I * 4;
$ BitOrder <= $ I * 4 + 3; $ bitOrder ++ ){
$ Arr8 [$ bitOrder] = $ arr32 [$ I] and 255;
$ Arr32 [$ I] = zeroFill ($ arr32 [$ I], 8 );
}
}

Return $ arr8;
}

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 (
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 $ 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 recommendation:

Http://tool.111cn.net/pr/pr.php can be used to query the prvalue of your website, and can also be used to display the prvalue on your website.

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.