ID: 37590 User updated by: jesse at eonstreet dot com Reported By: jesse at eonstreet dot com Status: Bogus Bug Type: *Math Functions Operating System: Windows Xp / FC 3 PHP Version: 5.1.4 New Comment:
Is there a specific extension that governs this type of math functions? Maybe a library needs updating or I didn't enable it when I compiled. Thanks for your help. Previous Comments: ------------------------------------------------------------------------ [2006-05-26 13:48:16] jesse at eonstreet dot com Confirmed. I have just up graded on a FC2 machine from 5.0.4 to 5.1.4 and the result is correct. Well, back to the investigation as to why every server but my production server gives the correct value :( ------------------------------------------------------------------------ [2006-05-26 06:39:47] [EMAIL PROTECTED] >Something has changed in 5.1.x that no longer produces the correct value. Your server has changed. ------------------------------------------------------------------------ [2006-05-25 18:58:30] judas dot iscariote at gmail dot com your first test returns "-4738672007" on Linux 64 bit. PHP_5_2 CVS. ------------------------------------------------------------------------ [2006-05-25 16:31:32] jesse at eonstreet dot com Here is the code that had worked under 5.0.4 Windows / linux: <?php define('GOOGLE_MAGIC', 0xE6359A60); class googleTools{ public static $url; public function __construct($url = false){ } public function GoogleCH($url, $length=null, $init=GOOGLE_MAGIC) { if(is_null($length)) { $length = sizeof($url); } $a = $b = 0x9E3779B9; $c = $init; $k = 0; $len = $length; while($len >= 12) { $a += ($url[$k+0] +($url[$k+1]<<8) +($url[$k+2]<<16) +($url[$k+3]<<24)); $b += ($url[$k+4] +($url[$k+5]<<8) +($url[$k+6]<<16) +($url[$k+7]<<24)); $c += ($url[$k+8] +($url[$k+9]<<8) +($url[$k+10]<<16)+($url[$k+11]<<24)); $mix = googleTools::mix($a,$b,$c); $a = $mix[0]; $b = $mix[1]; $c = $mix[2]; $k += 12; $len -= 12; } $c += $length; switch($len) /* all the case statements fall through */ { case 11: $c+=($url[$k+10]<<24); case 10: $c+=($url[$k+9]<<16); case 9 : $c+=($url[$k+8]<<8); /* the first byte of c is reserved for the length */ case 8 : $b+=($url[$k+7]<<24); case 7 : $b+=($url[$k+6]<<16); case 6 : $b+=($url[$k+5]<<8); case 5 : $b+=($url[$k+4]); case 4 : $a+=($url[$k+3]<<24); case 3 : $a+=($url[$k+2]<<16); case 2 : $a+=($url[$k+1]<<8); case 1 : $a+=($url[$k+0]); /* case 0: nothing left to add */ } $mix = googleTools::mix($a,$b,$c); /*-------------------------------------------- report the result */ return $mix[2]; } public function doGetRank($url) { $url = 'info:'.$url; $GoogleCH = googleTools::GoogleCH(googleTools::strord($url)); $url = urlencode($url); $file = "http://www.google.com/search?client=navclient-auto&ch=6$GoogleCH&features=Rank&q=$url"; //$data = file($file); $ch = curl_init(); // initialize curl handle curl_setopt($ch, CURLOPT_URL,$file); // set url to post to curl_setopt($ch, CURLOPT_FAILONERROR, 1); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);// allow redirects curl_setopt($ch, CURLOPT_RETURNTRANSFER,1); // return into a variable curl_setopt($ch, CURLOPT_TIMEOUT, 25); // times out after 4s $data = curl_exec($ch); // run the whole process curl_close($ch); $rankarray = explode (':', $data); $rank = $rankarray[2]; return $rank; } //converts a string into an array of integers containing the numeric value of the char private function strord($string) { for($i=0;$i<strlen($string);$i++) { $result[$i] = ord($string{$i}); $strResult .= $i ."-".$result[$i]; } // echo "<br>".$strResult."<br>"; return $result; } //unsigned shift right private function zeroFill($a, $b) { $aTemp =$a; $z = hexdec(80000000); if ($z & $a) { $a = ($a>>1); $a &= (~$z); $a |= 0x40000000; $a = ($a>>($b-1)); } else { $a = ($a>>$b); } return $a; } private function mix($a,$b,$c) { $a -= $b; $a -= $c; $aTemp = $a; $a ^= (googleTools::zeroFill($c,13)); $b -= $c; $b -= $a; $b ^= ($a<<8); $c -= $a; $c -= $b; $c ^= (googleTools::zeroFill($b,13)); $a -= $b; $a -= $c; $a ^= (googleTools::zeroFill($c,12)); $b -= $c; $b -= $a; $b ^= ($a<<16); $c -= $a; $c -= $b; $c ^= (googleTools::zeroFill($b,5)); $a -= $b; $a -= $c; $a ^= (googleTools::zeroFill($c,3)); $b -= $c; $b -= $a; $b ^= ($a<<10); $c -= $a; $c -= $b; $c ^= (googleTools::zeroFill($b,15)); $arr = array($a,$b,$c); print_a($arr); return $arr; } } ?> ------------------------------------------------------------------------ [2006-05-25 13:28:30] jesse at eonstreet dot com Yes, they are dependent to a point. But in 5.0.4 they returned the same end value. Something has changed in 5.1.x that no longer produces the correct value. ------------------------------------------------------------------------ The remainder of the comments for this report are too long. To view the rest of the comments, please view the bug report online at http://bugs.php.net/37590 -- Edit this bug report at http://bugs.php.net/?id=37590&edit=1