Index: trunk/phase3/includes/specials/SpecialIpblocklist.php |
— | — | @@ -78,6 +78,7 @@ |
79 | 79 | $this->hideuserblocks = $wgRequest->getBool( 'hideuserblocks' ); |
80 | 80 | $this->hidetempblocks = $wgRequest->getBool( 'hidetempblocks' ); |
81 | 81 | $this->hideaddressblocks = $wgRequest->getBool( 'hideaddressblocks' ); |
| 82 | + $this->scanRange = $wgRequest->getBool( 'range' ); |
82 | 83 | } |
83 | 84 | |
84 | 85 | /** |
— | — | @@ -162,8 +163,7 @@ |
163 | 164 | * @return array array(message key, parameters) on failure, empty array on success |
164 | 165 | */ |
165 | 166 | |
166 | | - static function doUnblock(&$id, &$ip, &$reason, &$range = null) |
167 | | - { |
| 167 | + static function doUnblock(&$id, &$ip, &$reason, &$range = null) { |
168 | 168 | if ( $id ) { |
169 | 169 | $block = Block::newFromID( $id ); |
170 | 170 | if ( !$block ) { |
— | — | @@ -245,10 +245,20 @@ |
246 | 246 | // No extra conditions |
247 | 247 | } elseif ( substr( $this->ip, 0, 1 ) == '#' ) { |
248 | 248 | $conds['ipb_id'] = substr( $this->ip, 1 ); |
| 249 | + // Single IPs |
249 | 250 | } elseif ( IP::isIPAddress($this->ip) && strpos($this->ip,'/') === false ) { |
250 | | - $conds['ipb_address'] = IP::sanitizeIP($this->ip); |
| 251 | + if( $this->scanRange && $iaddr = IP::toHex($this->ip) ) { |
| 252 | + # Only scan ranges which start in this /16, this improves search speed |
| 253 | + # Blocks should not cross a /16 boundary. |
| 254 | + $range = substr( $iaddr, 0, 4 ); |
| 255 | + $conds[] = "(ipb_address = '" . IP::sanitizeIP($this->ip) . "') OR |
| 256 | + (ipb_range_start LIKE '$range%' AND ipb_range_start <= '$iaddr' AND ipb_range_end >= '$iaddr')"; |
| 257 | + } else { |
| 258 | + $conds['ipb_address'] = IP::sanitizeIP($this->ip); |
| 259 | + } |
251 | 260 | $conds['ipb_auto'] = 0; |
252 | | - } elseif( IP::isIPAddress($this->ip) ) { |
| 261 | + // IP range |
| 262 | + } elseif ( IP::isIPAddress($this->ip) ) { |
253 | 263 | $conds['ipb_address'] = Block::normaliseRange( $this->ip ); |
254 | 264 | $conds['ipb_auto'] = 0; |
255 | 265 | } else { |
— | — | @@ -298,8 +308,9 @@ |
299 | 309 | Xml::openElement( 'fieldset' ) . |
300 | 310 | Xml::element( 'legend', null, wfMsg( 'ipblocklist-legend' ) ) . |
301 | 311 | Xml::inputLabel( wfMsg( 'ipblocklist-username' ), 'ip', 'ip', /* size */ false, $this->ip ) . |
302 | | - ' ' . |
303 | | - Xml::submitButton( wfMsg( 'ipblocklist-submit' ) ) . |
| 312 | + '<br/>' . |
| 313 | + Xml::checkLabel( wfMsg('ipblocklist-scanrange'), 'range', 'range', $this->scanRange ) . |
| 314 | + ' ' . Xml::submitButton( wfMsg( 'ipblocklist-submit' ) ) . |
304 | 315 | Xml::closeElement( 'fieldset' ) |
305 | 316 | ); |
306 | 317 | } |
Index: trunk/phase3/languages/messages/MessagesEn.php |
— | — | @@ -2566,6 +2566,7 @@ |
2567 | 2567 | 'ipblocklist-sh-userblocks' => '$1 account blocks', |
2568 | 2568 | 'ipblocklist-sh-tempblocks' => '$1 temporary blocks', |
2569 | 2569 | 'ipblocklist-sh-addressblocks' => '$1 single IP blocks', |
| 2570 | +'ipblocklist-scanrange' => 'For IPs, include all blocks that affect the address', |
2570 | 2571 | 'ipblocklist-summary' => '', # do not translate or duplicate this message to other languages |
2571 | 2572 | 'ipblocklist-submit' => 'Search', |
2572 | 2573 | 'blocklistline' => '$1, $2 blocked $3 ($4)', |