Index: trunk/phase3/includes/IP.php |
— | — | @@ -176,13 +176,13 @@ |
177 | 177 | if ( $network === false ) { |
178 | 178 | $start = $end = false; |
179 | 179 | } else { |
180 | | - $start = wfBaseConvert( $network, 10, 16, 1, false ); |
| 180 | + $start = wfBaseConvert( $network, 10, 16, 32, false ); |
181 | 181 | # Turn network to binary (again) |
182 | 182 | $end = wfBaseConvert( $network, 10, 2, 128 ); |
183 | 183 | # Truncate the last (128-$bits) bits and replace them with ones |
184 | 184 | $end = str_pad( substr( $end, 0, $bits ), 128, 1, STR_PAD_RIGHT ); |
185 | 185 | # Convert to hex |
186 | | - $end = wfBaseConvert( $end, 2, 16, 1, false ); |
| 186 | + $end = wfBaseConvert( $end, 2, 16, 32, false ); |
187 | 187 | } |
188 | 188 | } elseif ( strpos( $range, '-' ) !== false ) { |
189 | 189 | # Explicit range |
— | — | @@ -191,8 +191,8 @@ |
192 | 192 | if ( $start > $end ) { |
193 | 193 | $start = $end = false; |
194 | 194 | } 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 ); |
197 | 197 | } |
198 | 198 | } else { |
199 | 199 | # Single IP |
— | — | @@ -285,14 +285,13 @@ |
286 | 286 | * function for an IPv6 address will be prefixed with "v6-", a non- |
287 | 287 | * hexadecimal string which sorts after the IPv4 addresses. |
288 | 288 | * |
289 | | - * @param $ip Quad dotted IP address. |
| 289 | + * @param $ip Quad dotted/octet IP address. |
290 | 290 | * @return hexidecimal |
291 | 291 | */ |
292 | 292 | 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 ); |
295 | 294 | 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 ); |
297 | 296 | } |
298 | 297 | return $n; |
299 | 298 | } |