* @param $par String title fragment
*/
public function execute( $par ) {
- global $wgUser, $wgOut, $wgRequest;
+ global $wgOut, $wgRequest;
$this->setHeaders();
$this->outputHeader();
$par = $wgRequest->getVal( 'ip', $par );
$this->target = trim( $wgRequest->getVal( 'wpTarget', $par ) );
- $this->options = $wgRequest->getArray( 'wpOptions' );
+ $this->options = $wgRequest->getArray( 'wpOptions', array() );
$action = $wgRequest->getText( 'action' );
$fields = array(
'Target' => array(
'type' => 'text',
- 'label-message' => 'ipaddressorusername',
+ 'label-message' => 'ipadressorusername',
'tabindex' => '1',
'size' => '45',
),
wfMsg( 'blocklist-userblocks' ) => 'userblocks',
wfMsg( 'blocklist-tempblocks' ) => 'tempblocks',
wfMsg( 'blocklist-addressblocks' ) => 'addressblocks',
+ wfMsg( 'blocklist-rangeblocks' ) => 'rangeblocks',
),
- 'cssclass' => 'mw-htmlform-multiselect-flatlist',
+ 'flatlist' => true,
),
);
- $form = new HTMLForm( $fields );
- $form->setTitle( $this->getTitle() );
+ $form = new HTMLForm( $fields, $this->getContext() );
$form->setMethod( 'get' );
$form->setWrapperLegend( wfMsg( 'ipblocklist-legend' ) );
$form->setSubmitText( wfMsg( 'ipblocklist-submit' ) );
$form->prepareForm();
-
+
$form->displayForm( '' );
$this->showList();
}
- /**
- * Get the component of an IP address which is certain to be the same between an IP
- * address and a rangeblock containing that IP address.
- * @todo: should be in IP.php??
- * @param $ip String
- * @return String
- */
- protected static function getIpFragment( $ip ){
- global $wgBlockCIDRLimit;
- if( IP::isIPv4( $ip ) ){
- $hexAddress = IP::toHex( $ip );
- return substr( $hexAddress, 0, wfBaseconvert( $wgBlockCIDRLimit['IPv4'], 10, 16 ) );
- } elseif( IP::isIPv6( $ip ) ) {
- $hexAddress = substr( IP::toHex( $ip ), 2 );
- return 'v6-' . substr( $hexAddress, 0, wfBaseconvert( $wgBlockCIDRLimit['IPv6'], 10, 16 ) );
- } else {
- return null;
- }
- }
-
function showList() {
global $wgOut, $wgUser;
break;
case Block::TYPE_IP:
- case BLock::TYPE_RANGE:
+ case Block::TYPE_RANGE:
list( $start, $end ) = IP::parseRange( $target );
- # Per bug 14634, we want to include relevant active rangeblocks; for
- # rangeblocks, we want to include larger ranges which enclose the given
- # range. We know that all blocks must be smaller than $wgBlockCIDRLimit,
- # so we can improve performance by filtering on a LIKE clause
- $chunk = self::getIpFragment( $start );
$dbr = wfGetDB( DB_SLAVE );
- $like = $dbr->buildLike( $chunk, $dbr->anyString() );
-
- # Fairly hard to make a malicious SQL statement out of hex characters,
- # but stranger things have happened...
- $safeStart = $dbr->addQuotes( IP::toHex( $start ) );
- $safeEnd = $dbr->addQuotes( IP::toHex( $end ) );
- $safeTarget = $dbr->addQuotes( IP::toHex( $target ) );
-
- # TODO: abstract this away
- $conds[] = "(ipb_address = $safeTarget) OR
- (ipb_range_start $like AND ipb_range_start <= $safeStart AND ipb_range_end >= $safeEnd)";
+ $conds[] = $dbr->makeList(
+ array(
+ 'ipb_address' => $target,
+ Block::getRangeCond( $start, $end )
+ ),
+ LIST_OR
+ );
$conds['ipb_auto'] = 0;
break;
if( in_array( 'addressblocks', $this->options ) ) {
$conds[] = "ipb_user != 0 OR ipb_range_end > ipb_range_start";
}
+ if( in_array( 'rangeblocks', $this->options ) ) {
+ $conds[] = "ipb_range_end = ipb_range_start";
+ }
# Check for other blocks, i.e. global/tor blocks
$otherBlockLink = array();
}
function getFieldNames() {
- global $wgUser;
static $headers = null;
if ( $headers == array() ) {
}
function formatValue( $name, $value ) {
- global $wgOut, $wgLang, $wgUser;
+ global $wgLang, $wgUser;
static $sk, $msg;
if ( empty( $sk ) ) {
- $sk = $wgUser->getSkin();
+ $sk = $this->getSkin();
$msg = array(
'anononlyblock',
'createaccountblock',
'blocklist-nousertalk',
'unblocklink',
'change-blocklink',
+ 'infiniteblock',
);
$msg = array_combine( $msg, array_map( 'wfMessage', $msg ) );
}
case 'ipb_target':
if( $row->ipb_auto ){
- $formatted = wfMessage( 'autoblockid', $row->ipb_id );
+ $formatted = wfMessage( 'autoblockid', $row->ipb_id )->parse();
} else {
list( $target, $type ) = Block::parseTarget( $row->ipb_address );
switch( $type ){
break;
case 'ipb_expiry':
- $formatted = $wgLang->timeanddate( $value );
+ $formatted = $wgLang->formatExpiry( $value );
if( $wgUser->isAllowed( 'block' ) ){
if( $row->ipb_auto ){
$links[] = $sk->linkKnown(
$formatted .= ' ' . Html::rawElement(
'span',
array( 'class' => 'mw-blocklist-actions' ),
- "[{$wgLang->pipeList($links)}]"
+ wfMsg( 'parentheses', $wgLang->pipeList( $links ) )
);
}
break;
}
function getTitle() {
- return $this->mPage->getTitle();
+ return $this->page->getTitle();
}
}