r43081 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r43080‎ | r43081 | r43082 >
Date:16:50, 2 November 2008
Author:catrope
Status:old
Tags:
Comment:
API: Move ApiQueryBlocks::convertHexIP() to IP::hexToIP() per Werdna's comment on r43040
Modified paths:
  • /trunk/phase3/includes/IP.php (modified) (history)
  • /trunk/phase3/includes/api/ApiQueryBlocks.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/api/ApiQueryBlocks.php
@@ -148,8 +148,8 @@
149149 $block['reason'] = $row->ipb_reason;
150150 if($fld_range)
151151 {
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);
154154 }
155155 if($fld_flags)
156156 {
@@ -185,19 +185,6 @@
186186 $this->usernames[] = $name;
187187 }
188188
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 -
202189 public function getAllowedParams() {
203190 return array (
204191 'start' => array(
Index: trunk/phase3/includes/IP.php
@@ -168,6 +168,24 @@
169169 $ip_oct = preg_replace( '/(^|:)0+' . RE_IPV6_WORD . '/', '$1$2', $ip_oct );
170170 return $ip_oct;
171171 }
 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+ }
172190
173191 /**
174192 * Convert a network specification in IPv6 CIDR notation to an integer network and a number of bits

Follow-up revisions

RevisionCommit summaryAuthorDate
r43082Followup on r43081: GlobalBlocking toocatrope16:52, 2 November 2008

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r43040GlobalBlocking: Add list=globalblocks API module, which is basically just a t...catrope22:25, 1 November 2008

Status & tagging log