Skip to content

Commit

Permalink
fix a bug reported by Tim de Wolf, auto type conversion is ugly
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.php.net/repository/pear/packages/Net_IPv6/trunk@75472 c90b9560-bf6c-de11-be94-00142212c4b1
  • Loading branch information
Alexander Merz committed Mar 27, 2002
1 parent f0eb601 commit ee1c8db
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions IPv6.php
Expand Up @@ -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++;
}
}
Expand All @@ -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++;
}
}
Expand Down

0 comments on commit ee1c8db

Please sign in to comment.