![]() |
|
|
|
|
1
2nd July 19:02
External User
Posts: 1
|
Could be my not understanding of something, but I think there is a bug in
using ip2long() and sprintf(%u) as indicated on this page: http://us4.php.net/manual/en/function.ip2long.php Look at the example below: //this conversion seems broken // $startIP_long = sprintf("%u",ip2long($QRange1)); // $endIP_long = sprintf("%u",ip2long($QRange2)); $startIP_long = ip2long($QRange1); $endIP_long = ip2long($QRange2); echo "QRange1 = ".$QRange1." and QRange2 = ".$QRange2."<BR>"; echo "startIP_long = ".$startIP_long." and endIP_long = ".$endIP_long."<BR>"; echo "startIP_long = ".long2ip($startIP_long)." and endIP_long = ".long2ip($endIP_long)."<BR>"; The first //commented block will give: QRange1 = 192.169.12.40 and QRange2 = 192.169.20.40 startIP_long = 3232304168 and endIP_long = 3232306216 startIP_long = 127.255.255.255 and endIP_long = 127.255.255.255 (wtf did the "127.255.255.255" come from?!) While the second works properly... QRange1 = 192.169.12.40 and QRange2 = 192.169.20.40 startIP_long = -1062663128 and endIP_long = -1062661080 startIP_long = 192.169.12.40 and endIP_long = 192.169.20.40 |
|
|
|
|
2
2nd July 19:03
External User
Posts: 1
|
What version of php? It works find in 4.3.3.
echo long2ip(3232304168); --- 192.169.12.40 Curt -- "My PHP key is worn out" PHP List stats since 1997: http://zirzow.dyndns.org/html/mlists/ |
|
|
|
|
4
2nd July 19:03
External User
Posts: 1
|
still works using sprintf() with 4.3.3
http://zirzow.dyndns.org/html/php/te...ng/ip2long.php Curt -- "My PHP key is worn out" PHP List stats since 1997: http://zirzow.dyndns.org/html/mlists/ |
|