Index: trunk/phase3/includes/IP.php |
— | — | @@ -253,15 +253,17 @@ |
254 | 254 | * Split out an IP block as an array of 4 bytes and a mask, |
255 | 255 | * return false if it can't be determined |
256 | 256 | * |
257 | | - * @parameter $ip string A quad dotted IP address |
| 257 | + * @parameter $ip string A quad dotted/octet IP address |
258 | 258 | * @return array |
259 | 259 | */ |
260 | 260 | public static function toArray( $ipblock ) { |
261 | 261 | $matches = array(); |
262 | | - if(! preg_match( '/^' . RE_IP_ADD . '(?:\/(?:'.RE_IP_PREFIX.'))?' . '$/', $ipblock, $matches ) ) { |
| 262 | + if( preg_match( '/^' . RE_IP_ADD . '(?:\/(?:'.RE_IP_PREFIX.'))?' . '$/', $ipblock, $matches ) ) { |
| 263 | + return $matches; |
| 264 | + } else if ( preg_match( '/^' . RE_IPV6_ADD . '(?:\/(?:'.RE_IPV6_PREFIX.'))?' . '$/', $ipblock, $matches ) ) { |
| 265 | + return $matches; |
| 266 | + } else { |
263 | 267 | return false; |
264 | | - } else { |
265 | | - return $matches; |
266 | 268 | } |
267 | 269 | } |
268 | 270 | |
— | — | @@ -277,7 +279,7 @@ |
278 | 280 | * @return hexidecimal |
279 | 281 | */ |
280 | 282 | public static function toHex( $ip ) { |
281 | | - // Use IPv6 function if we have an that sort of IP |
| 283 | + // Use IPv6 functions if needed |
282 | 284 | $n = ( self::isIPv6($ip) ) ? self::toUnsigned6( $ip ) : self::toUnsigned( $ip ); |
283 | 285 | if ( $n !== false ) { |
284 | 286 | $n = sprintf( '%08X', $n ); |
— | — | @@ -293,7 +295,7 @@ |
294 | 296 | * @return integer |
295 | 297 | */ |
296 | 298 | public static function toUnsigned( $ip ) { |
297 | | - // Use IPv6 function if we have an that sort of IP |
| 299 | + // Use IPv6 functions if needed |
298 | 300 | if ( self::isIPv6( $ip ) ) { |
299 | 301 | return toUnsigned6( $ip ); |
300 | 302 | } |
— | — | @@ -366,8 +368,8 @@ |
367 | 369 | * @return array(string, int) |
368 | 370 | */ |
369 | 371 | public static function parseRange( $range ) { |
370 | | - // Use IPv6 function if we have an that sort of IP |
371 | | - if ( self::isIPv6( $ip ) ) { |
| 372 | + // Use IPv6 functions if needed |
| 373 | + if ( self::isIPv6( $range ) ) { |
372 | 374 | return self::parseRange6( $range ); |
373 | 375 | } |
374 | 376 | if ( strpos( $range, '/' ) !== false ) { |