ID: 14018 Updated by: sterling Reported By: [EMAIL PROTECTED] Old Status: Open Status: Closed Bug Type: Network related Operating System: Linux PHP Version: 4.0.6 New Comment:
They work in the current CVS of php Previous Comments: ------------------------------------------------------------------------ [2001-11-11 13:15:58] [EMAIL PROTECTED] Actually the my fix for this problem is on the PHP side, not in the PHP-code it self: function jk_ip2long ($ip) { preg_match("#^([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$#", $ip, $a); $long = $a[1] << 24 | $a[2] << 16 | $a[3] << 8 | $a[4] << 0; ## handling negative urls if($long < 0) $long += pow(2,32); return $long; } ## long2ip function jk_long2ip ($long) { ## handle long value which should be signed in PHP but are unsigned if ($long > 0x7fffffff) { ## although this code seems to be useless, it does what we want $l = ($long - 0x7fffffff) - 1; $long = -(0x7fffffff - $l) - 1; } $ip3 = sprintf("%d.%d.%d.%d", $long >> 24 & 0xff, $long >> 16 & 0xff, $long >> 8 & 0xff, $long >> 0 & 0xff ); return $ip3; } You can see a working example at http://jan.kneschke.de/projects/phpbugs/ip2long.php ------------------------------------------------------------------------ Edit this bug report at http://bugs.php.net/?id=14018&edit=1 -- PHP Development Mailing List <http://www.php.net/> To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]