Index: trunk/phase3/includes/api/ApiQueryBlocks.php |
— | — | @@ -148,8 +148,8 @@ |
149 | 149 | $block['reason'] = $row->ipb_reason; |
150 | 150 | if($fld_range) |
151 | 151 | { |
152 | | - $block['rangestart'] = self::convertHexIP($row->ipb_range_start); |
153 | | - $block['rangeend'] = self::convertHexIP($row->ipb_range_end); |
| 152 | + $block['rangestart'] = IP::hexToIP($row->ipb_range_start); |
| 153 | + $block['rangeend'] = IP::hexToIP($row->ipb_range_end); |
154 | 154 | } |
155 | 155 | if($fld_flags) |
156 | 156 | { |
— | — | @@ -185,19 +185,6 @@ |
186 | 186 | $this->usernames[] = $name; |
187 | 187 | } |
188 | 188 | |
189 | | - protected static function convertHexIP($ip) |
190 | | - { |
191 | | - // Converts a hexadecimal IP to nnn.nnn.nnn.nnn format |
192 | | - $dec = wfBaseConvert($ip, 16, 10); |
193 | | - $parts[3] = $dec % 256; |
194 | | - $dec /= 256; |
195 | | - $parts[2] = $dec % 256; |
196 | | - $dec /= 256; |
197 | | - $parts[1] = $dec % 256; |
198 | | - $parts[0] = $dec / 256; |
199 | | - return implode('.', array_reverse($parts)); |
200 | | - } |
201 | | - |
202 | 189 | public function getAllowedParams() { |
203 | 190 | return array ( |
204 | 191 | 'start' => array( |
Index: trunk/phase3/includes/IP.php |
— | — | @@ -168,6 +168,24 @@ |
169 | 169 | $ip_oct = preg_replace( '/(^|:)0+' . RE_IPV6_WORD . '/', '$1$2', $ip_oct ); |
170 | 170 | return $ip_oct; |
171 | 171 | } |
| 172 | + |
| 173 | + /** |
| 174 | + * Converts a hexadecimal number to an IPv4 address in octet notation |
| 175 | + * @param $ip string Hex IP |
| 176 | + * @return string |
| 177 | + */ |
| 178 | + public static function hexToIP($ip) |
| 179 | + { |
| 180 | + // Converts a hexadecimal IP to nnn.nnn.nnn.nnn format |
| 181 | + $dec = wfBaseConvert($ip, 16, 10); |
| 182 | + $parts[3] = $dec % 256; |
| 183 | + $dec /= 256; |
| 184 | + $parts[2] = $dec % 256; |
| 185 | + $dec /= 256; |
| 186 | + $parts[1] = $dec % 256; |
| 187 | + $parts[0] = $dec / 256; |
| 188 | + return implode('.', array_reverse($parts)); |
| 189 | + } |
172 | 190 | |
173 | 191 | /** |
174 | 192 | * Convert a network specification in IPv6 CIDR notation to an integer network and a number of bits |