Permalink
Browse files

fix a bug reported by Tim de Wolf, auto type conversion is ugly

git-svn-id: http://svn.php.net/repository/pear/packages/Net_IPv6/trunk@75472 c90b9560-bf6c-de11-be94-00142212c4b1
  • Loading branch information...
Alexander Merz
Alexander Merz committed Mar 27, 2002
1 parent f0eb601 commit ee1c8dbbd1200079d5835afd94048cfbffb9873c
Showing with 3 additions and 2 deletions.
  1. +3 −2 IPv6.php
View
@@ -179,7 +179,8 @@ function checkIPv6( $ip) {
$ipv6 = explode( ':', $ipPart[0]) ;
for ($i = 0; $i < count( $ipv6); $i++) {
- if ($ipv6[$i] >= 0x0 && $ipv6[$i] <= 0xFFFF ) {
+ $dec = hexdec($ipv6[$i]);
+ if ($ipv6[$i] >= 0 && $dec <= 65535 && $ipv6[$i] == strtoupper(dechex($dec))) {
$count++;
}
}
@@ -189,7 +190,7 @@ function checkIPv6( $ip) {
$ipv4 = explode( '.',$ipPart[1]) ;
$count = 0 ;
for ($i = 0; $i < count( $ipv4); $i++) {
- if ($ipv4[$i] >= 0 && $ipv4[$i] <= 255 && preg_match("/^\d{1,3}$/", $ipv4[$i])) {
+ if ($ipv4[$i] >= 0 && (integer)$ipv4[$i] <= 255 && preg_match("/^\d{1,3}$/", $ipv4[$i])) {
$count++;
}
}

0 comments on commit ee1c8db

Please sign in to comment.