Index: trunk/phase3/includes/IP.php |
— | — | @@ -154,19 +154,19 @@ |
155 | 155 | |
156 | 156 | /** |
157 | 157 | * Given an unsigned integer, returns an IPv6 address in octet notation |
158 | | - * @param $ip integer IP address. |
| 158 | + * @param $ip_int integer IP address. |
159 | 159 | * @return string |
160 | 160 | */ |
161 | 161 | public static function toOctet( $ip_int ) { |
162 | | - // Convert to padded uppercase hex |
163 | | - $ip_hex = wfBaseConvert($ip_int, 10, 16, 32, false); |
164 | | - // Separate into 8 octets |
165 | | - $ip_oct = substr( $ip_hex, 0, 4 ); |
166 | | - for ($n=1; $n < 8; $n++) { |
167 | | - $ip_oct .= ':' . substr($ip_hex, 4*$n, 4); |
168 | | - } |
169 | | - // NO leading zeroes |
170 | | - $ip_oct = preg_replace( '/(^|:)0+' . RE_IPV6_WORD . '/', '$1$2', $ip_oct ); |
| 162 | + // Convert to padded uppercase hex |
| 163 | + $ip_hex = wfBaseConvert($ip_int, 10, 16, 32, false); |
| 164 | + // Separate into 8 octets |
| 165 | + $ip_oct = substr( $ip_hex, 0, 4 ); |
| 166 | + for ($n=1; $n < 8; $n++) { |
| 167 | + $ip_oct .= ':' . substr($ip_hex, 4*$n, 4); |
| 168 | + } |
| 169 | + // NO leading zeroes |
| 170 | + $ip_oct = preg_replace( '/(^|:)0+' . RE_IPV6_WORD . '/', '$1$2', $ip_oct ); |
171 | 171 | return $ip_oct; |
172 | 172 | } |
173 | 173 | |
— | — | @@ -183,19 +183,19 @@ |
184 | 184 | |
185 | 185 | /** |
186 | 186 | * Given a hexadecimal number, returns to an IPv6 address in octet notation |
187 | | - * @param $ip string hex IP |
| 187 | + * @param $ip_hex string hex IP |
188 | 188 | * @return string |
189 | 189 | */ |
190 | 190 | public static function hextoOctet( $ip_hex ) { |
191 | | - // Convert to padded uppercase hex |
192 | | - $ip_hex = str_pad( strtoupper($ip_hex), 32, '0'); |
193 | | - // Separate into 8 octets |
194 | | - $ip_oct = substr( $ip_hex, 0, 4 ); |
195 | | - for ($n=1; $n < 8; $n++) { |
196 | | - $ip_oct .= ':' . substr($ip_hex, 4*$n, 4); |
197 | | - } |
198 | | - // NO leading zeroes |
199 | | - $ip_oct = preg_replace( '/(^|:)0+' . RE_IPV6_WORD . '/', '$1$2', $ip_oct ); |
| 191 | + // Convert to padded uppercase hex |
| 192 | + $ip_hex = str_pad( strtoupper($ip_hex), 32, '0'); |
| 193 | + // Separate into 8 octets |
| 194 | + $ip_oct = substr( $ip_hex, 0, 4 ); |
| 195 | + for ($n=1; $n < 8; $n++) { |
| 196 | + $ip_oct .= ':' . substr($ip_hex, 4*$n, 4); |
| 197 | + } |
| 198 | + // NO leading zeroes |
| 199 | + $ip_oct = preg_replace( '/(^|:)0+' . RE_IPV6_WORD . '/', '$1$2', $ip_oct ); |
200 | 200 | return $ip_oct; |
201 | 201 | } |
202 | 202 | |
— | — | @@ -357,7 +357,7 @@ |
358 | 358 | * Split out an IP block as an array of 4 bytes and a mask, |
359 | 359 | * return false if it can't be determined |
360 | 360 | * |
361 | | - * @param $ip string A quad dotted/octet IP address |
| 361 | + * @param $ipblock string A quad dotted/octet IP address |
362 | 362 | * @return array |
363 | 363 | */ |
364 | 364 | public static function toArray( $ipblock ) { |