r20383 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r20382‎ | r20383 | r20384 >
Date:09:25, 13 March 2007
Author:aaron
Status:old
Tags:
Comment:
*Padding for indexing
Modified paths:
  • /trunk/phase3/includes/IP.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/IP.php
@@ -176,13 +176,13 @@
177177 if ( $network === false ) {
178178 $start = $end = false;
179179 } else {
180 - $start = wfBaseConvert( $network, 10, 16, 1, false );
 180+ $start = wfBaseConvert( $network, 10, 16, 32, false );
181181 # Turn network to binary (again)
182182 $end = wfBaseConvert( $network, 10, 2, 128 );
183183 # Truncate the last (128-$bits) bits and replace them with ones
184184 $end = str_pad( substr( $end, 0, $bits ), 128, 1, STR_PAD_RIGHT );
185185 # Convert to hex
186 - $end = wfBaseConvert( $end, 2, 16, 1, false );
 186+ $end = wfBaseConvert( $end, 2, 16, 32, false );
187187 }
188188 } elseif ( strpos( $range, '-' ) !== false ) {
189189 # Explicit range
@@ -191,8 +191,8 @@
192192 if ( $start > $end ) {
193193 $start = $end = false;
194194 } else {
195 - $start = wfBaseConvert( $start, 10, 16, 1, false );
196 - $end = wfBaseConvert( $end, 10, 16, 1, false );
 195+ $start = wfBaseConvert( $start, 10, 16, 32, false );
 196+ $end = wfBaseConvert( $end, 10, 16, 32, false );
197197 }
198198 } else {
199199 # Single IP
@@ -285,14 +285,13 @@
286286 * function for an IPv6 address will be prefixed with "v6-", a non-
287287 * hexadecimal string which sorts after the IPv4 addresses.
288288 *
289 - * @param $ip Quad dotted IP address.
 289+ * @param $ip Quad dotted/octet IP address.
290290 * @return hexidecimal
291291 */
292292 public static function toHex( $ip ) {
293 - // Use IPv6 functions if needed
294 - $n = ( self::isIPv6($ip) ) ? self::toUnsigned6( $ip ) : self::toUnsigned( $ip );
 293+ $n = self::toUnsigned( $ip );
295294 if ( $n !== false ) {
296 - $n = wfBaseConvert( $n, 10, 16, 1, false );
 295+ $n = ( self::isIPv6($ip) ) ? wfBaseConvert( $n, 10, 16, 32, false ) : wfBaseConvert( $n, 10, 16, 8, false );
297296 }
298297 return $n;
299298 }