Index: trunk/phase3/includes/api/ApiQueryBlocks.php |
— | — | @@ -42,10 +42,6 @@ |
43 | 43 | } |
44 | 44 | |
45 | 45 | public function execute() { |
46 | | - $this->run(); |
47 | | - } |
48 | | - |
49 | | - private function run() { |
50 | 46 | global $wgUser; |
51 | 47 | |
52 | 48 | $params = $this->extractRequestParams(); |
— | — | @@ -92,12 +88,12 @@ |
93 | 89 | $this->addOption('LIMIT', $params['limit'] + 1); |
94 | 90 | $this->addWhereRange('ipb_timestamp', $params['dir'], $params['start'], $params['end']); |
95 | 91 | if(isset($params['ids'])) |
96 | | - $this->addWhere(array('ipb_id' => $params['ids'])); |
| 92 | + $this->addWhereFld('ipb_id', $params['ids']); |
97 | 93 | if(isset($params['users'])) |
98 | 94 | { |
99 | 95 | foreach((array)$params['users'] as $u) |
100 | 96 | $this->prepareUsername($u); |
101 | | - $this->addWhere(array('ipb_address' => $this->usernames)); |
| 97 | + $this->addWhereFld('ipb_address', $this->usernames); |
102 | 98 | } |
103 | 99 | if(isset($params['ip'])) |
104 | 100 | { |
— | — | @@ -120,7 +116,7 @@ |
121 | 117 | )); |
122 | 118 | } |
123 | 119 | if(!$wgUser->isAllowed('suppress')) |
124 | | - $this->addWhere(array('ipb_deleted' => 0)); |
| 120 | + $this->addWhereFld('ipb_deleted', 0); |
125 | 121 | |
126 | 122 | // Purge expired entries on one in every 10 queries |
127 | 123 | if(!mt_rand(0, 10)) |
— | — | @@ -131,7 +127,7 @@ |
132 | 128 | $count = 0; |
133 | 129 | while($row = $res->fetchObject()) |
134 | 130 | { |
135 | | - if($count++ == $params['limit']) |
| 131 | + if(++$count > $params['limit']) |
136 | 132 | { |
137 | 133 | // We've had enough |
138 | 134 | $this->setContinueEnumParameter('start', wfTimestamp(TS_ISO_8601, $row->ipb_timestamp)); |
— | — | @@ -141,13 +137,9 @@ |
142 | 138 | if($fld_id) |
143 | 139 | $block['id'] = $row->ipb_id; |
144 | 140 | if($fld_user && !$row->ipb_auto) |
145 | | - { |
146 | 141 | $block['user'] = $row->ipb_address; |
147 | | - } |
148 | 142 | if($fld_by) |
149 | | - { |
150 | 143 | $block['by'] = $row->user_name; |
151 | | - } |
152 | 144 | if($fld_timestamp) |
153 | 145 | $block['timestamp'] = wfTimestamp(TS_ISO_8601, $row->ipb_timestamp); |
154 | 146 | if($fld_expiry) |
— | — | @@ -197,13 +189,14 @@ |
198 | 190 | { |
199 | 191 | // Converts a hexadecimal IP to nnn.nnn.nnn.nnn format |
200 | 192 | $dec = wfBaseConvert($ip, 16, 10); |
201 | | - $parts[0] = (int)($dec / (256*256*256)); |
202 | | - $dec %= 256*256*256; |
203 | | - $parts[1] = (int)($dec / (256*256)); |
204 | | - $dec %= 256*256; |
205 | | - $parts[2] = (int)($dec / 256); |
206 | 193 | $parts[3] = $dec % 256; |
207 | | - return implode('.', $parts); |
| 194 | + $dec /= 256; |
| 195 | + $parts[2] = $dec % 256; |
| 196 | + $dec /= 256; |
| 197 | + $parts[1] = $dec % 256; |
| 198 | + $dec /= 256; |
| 199 | + $parts[0] = $dec % 256; |
| 200 | + return implode('.', array_reverse($parts)); |
208 | 201 | } |
209 | 202 | |
210 | 203 | public function getAllowedParams() { |