Home >Backend Development >PHP Tutorial >Google PR query interface checksum new algorithm page 1/2_PHP tutorial

Google PR query interface checksum new algorithm page 1/2_PHP tutorial

WBOY
WBOYOriginal
2016-07-21 15:48:02972browse

Instead, there is a large Google terms_of_service error message such as "In your email, please send us the entire code displayed below". It seems that the original interface has become invalid.

But the extension SearchStatus I installed on the Firefox toolbar can still parse the PR value of each visited page normally. I found the SearchStatus plug-in package and unpacked it to look at the source code. Sure enough, a different verification was used. In the code generation algorithm, after the original checksum is generated, another calculation is required. The correct ch parameter is obtained after two calculations.

So after transforming the ready-made js code, the new PHP version of the Google PageRank query interface method came out. After local testing, whoever wants to send it to the server gets a damn terms_of_service error message. I typed out the checksum calculation process step by step and found that the numbers on the local computer and on the server were different after several right shifts. Then I realized that the server is a 64-bit machine, and the bits that should be cut out after shifting under the 32-bit system are still alive and well there. A trunkbitForce32bit method is added to mask the high bits of the values ​​after all arithmetic operations, which solves the problem of redundant bits in 64-bit systems. As a result, it is incompatible when running in a 32-bit Linux environment. The reason is that when PHP overflows during arithmetic processing, it will automatically try to convert int to float. When a negative number overflow occurs, this operation can correctly preserve precision under Windows, but there is a problem under Linux.

The following code:

$a = -4294967295;
echo dechex($a)."
n";
if ( $a < 0 ) $a += 4294967296;
echo dechex($a)."
n";

The first echo can correctly output the negative number low 32 under Windows bit's complement, and on a 32-bit Linux machine, the maximum negative number that can be represented by the int type is 0x80000000. Only by adding a large integer outside the integer range to the overflowed negative number in a tricky way to offset the overflow can the lower 32 bits be restored to what they should be.

Using these unconventional means, we finally created this updated version of the PHP script implementation (including complete code) of the Google PR value query interface that is compatible with Linux32/Linux64/Windows.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/319839.htmlTechArticleReplaced by a large section of Google such as "In your email, please send us the entire code displayed below" terms_of_service error message. It seems that the original interface has expired...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn