r20360 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r20359‎ | r20360 | r20361 >
Date:07:15, 12 March 2007
Author:aaron
Status:old
Tags:
Comment:
*Fix typos :(
Modified paths:
  • /trunk/phase3/includes/IP.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/IP.php
@@ -253,15 +253,17 @@
254254 * Split out an IP block as an array of 4 bytes and a mask,
255255 * return false if it can't be determined
256256 *
257 - * @parameter $ip string A quad dotted IP address
 257+ * @parameter $ip string A quad dotted/octet IP address
258258 * @return array
259259 */
260260 public static function toArray( $ipblock ) {
261261 $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 {
263267 return false;
264 - } else {
265 - return $matches;
266268 }
267269 }
268270
@@ -277,7 +279,7 @@
278280 * @return hexidecimal
279281 */
280282 public static function toHex( $ip ) {
281 - // Use IPv6 function if we have an that sort of IP
 283+ // Use IPv6 functions if needed
282284 $n = ( self::isIPv6($ip) ) ? self::toUnsigned6( $ip ) : self::toUnsigned( $ip );
283285 if ( $n !== false ) {
284286 $n = sprintf( '%08X', $n );
@@ -293,7 +295,7 @@
294296 * @return integer
295297 */
296298 public static function toUnsigned( $ip ) {
297 - // Use IPv6 function if we have an that sort of IP
 299+ // Use IPv6 functions if needed
298300 if ( self::isIPv6( $ip ) ) {
299301 return toUnsigned6( $ip );
300302 }
@@ -366,8 +368,8 @@
367369 * @return array(string, int)
368370 */
369371 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 ) ) {
372374 return self::parseRange6( $range );
373375 }
374376 if ( strpos( $range, '/' ) !== false ) {