getVal( 'wpUnblockAddress', $wgRequest->getVal( 'ip' ) ); $id = $wgRequest->getVal( 'id' ); $reason = $wgRequest->getText( 'wpUnblockReason' ); $action = $wgRequest->getText( 'action' ); $successip = $wgRequest->getVal( 'successip' ); $ipu = new IPUnblockForm( $ip, $id, $reason ); if( $action == 'unblock' ) { # Check permissions if( !$wgUser->isAllowed( 'block' ) ) { $wgOut->permissionRequired( 'block' ); return; } # Check for database lock if( wfReadOnly() ) { $wgOut->readOnlyPage(); return; } # Show unblock form $ipu->showForm( '' ); } elseif( $action == 'submit' && $wgRequest->wasPosted() && $wgUser->matchEditToken( $wgRequest->getVal( 'wpEditToken' ) ) ) { # Check permissions if( !$wgUser->isAllowed( 'block' ) ) { $wgOut->permissionRequired( 'block' ); return; } # Check for database lock if( wfReadOnly() ) { $wgOut->readOnlyPage(); return; } # Remove blocks and redirect user to success page $ipu->doSubmit(); } elseif( $action == 'success' ) { # Inform the user of a successful unblock # (No need to check permissions or locks here, # if something was done, then it's too late!) if ( substr( $successip, 0, 1) == '#' ) { // A block ID was unblocked $ipu->showList( $wgOut->parse( wfMsg( 'unblocked-id', $successip ) ) ); } else { // A username/IP was unblocked $ipu->showList( $wgOut->parse( wfMsg( 'unblocked', $successip ) ) ); } } else { # Just show the block list $ipu->showList( '' ); } } /** * implements Special:ipblocklist GUI * @addtogroup SpecialPage */ class IPUnblockForm { var $ip, $reason, $id; function IPUnblockForm( $ip, $id, $reason ) { $this->ip = strtr( $ip, '_', ' ' ); $this->id = $id; $this->reason = $reason; } function showForm( $err ) { global $wgOut, $wgUser, $wgSysopUserBans; $wgOut->setPagetitle( wfMsg( 'unblockip' ) ); $wgOut->addWikiText( wfMsg( 'unblockiptext' ) ); $ipa = wfMsgHtml( $wgSysopUserBans ? 'ipadressorusername' : 'ipaddress' ); $ipr = wfMsgHtml( 'ipbreason' ); $ipus = wfMsgHtml( 'ipusubmit' ); $titleObj = SpecialPage::getTitleFor( "Ipblocklist" ); $action = $titleObj->getLocalURL( "action=submit" ); if ( "" != $err ) { $wgOut->setSubtitle( wfMsg( "formerror" ) ); $wgOut->addWikitext( "{$err}\n" ); } $token = htmlspecialchars( $wgUser->editToken() ); $addressPart = false; if ( $this->id ) { $block = Block::newFromID( $this->id ); if ( $block ) { $encName = htmlspecialchars( $block->getRedactedName() ); $encId = $this->id; $addressPart = $encName . Xml::hidden( 'id', $encId ); } } if ( !$addressPart ) { $addressPart = Xml::input( 'wpUnblockAddress', 20, $this->ip, array( 'type' => 'text', 'tabindex' => '1' ) ); } $wgOut->addHTML( Xml::openElement( 'form', array( 'method' => 'post', 'action' => $action, 'id' => 'unblockip' ) ) . Xml::openElement( 'table', array( 'border' => '0' ) ). "
' . wfMsgHTML( 'ipblocklistempty' ) . '
'; } $wgOut->addHTML( $s ); } function searchForm() { global $wgTitle, $wgScript, $wgRequest; return wfElement( 'form', array( 'action' => $wgScript ), null ) . wfHidden( 'title', $wgTitle->getPrefixedDbKey() ) . wfElement( 'input', array( 'type' => 'hidden', 'name' => 'action', 'value' => 'search' ) ). wfElement( 'input', array( 'type' => 'hidden', 'name' => 'limit', 'value' => $wgRequest->getText( 'limit' ) ) ) . wfElement( 'input', array( 'name' => 'ip', 'value' => $this->ip ) ) . wfElement( 'input', array( 'type' => 'submit', 'value' => wfMsg( 'ipblocklist-submit' ) ) ) . ''; } /** * Callback function to output a block */ function formatRow( $block ) { global $wgUser, $wgLang; wfProfileIn( __METHOD__ ); static $sk=null, $msg=null; if( is_null( $sk ) ) $sk = $wgUser->getSkin(); if( is_null( $msg ) ) { $msg = array(); $keys = array( 'infiniteblock', 'expiringblock', 'contribslink', 'unblocklink', 'anononlyblock', 'createaccountblock', 'noautoblockblock' ); foreach( $keys as $key ) { $msg[$key] = wfMsgHtml( $key ); } $msg['blocklistline'] = wfMsg( 'blocklistline' ); $msg['contribslink'] = wfMsg( 'contribslink' ); } # Prepare links to the blocker's user and talk pages $blocker_id = $block->getBy(); $blocker_name = $block->getByName(); $blocker = $sk->userLink( $blocker_id, $blocker_name ); $blocker .= $sk->userToolLinks( $blocker_id, $blocker_name ); # Prepare links to the block target's user and contribs. pages (as applicable, don't do it for autoblocks) if( $block->mAuto ) { $target = $block->getRedactedName(); # Hide the IP addresses of auto-blocks; privacy } else { $target = $sk->makeLinkObj( Title::makeTitle( NS_USER, $block->mAddress ), $block->mAddress ); $target .= ' (' . $sk->makeKnownLinkObj( SpecialPage::getSafeTitleFor( 'Contributions', $block->mAddress ), $msg['contribslink'] ) . ')'; } $formattedTime = $wgLang->timeanddate( $block->mTimestamp, true ); $properties = array(); if ( $block->mExpiry === "" || $block->mExpiry === Block::infinity() ) { $properties[] = $msg['infiniteblock']; } else { $properties[] = wfMsgReplaceArgs( $msg['expiringblock'], array( $wgLang->timeanddate( $block->mExpiry, true ) ) ); } if ( $block->mAnonOnly ) { $properties[] = $msg['anononlyblock']; } if ( $block->mCreateAccount ) { $properties[] = $msg['createaccountblock']; } if (!$block->mEnableAutoblock && $block->mUser ) { $properties[] = $msg['noautoblockblock']; } $properties = implode( ', ', $properties ); $line = wfMsgReplaceArgs( $msg['blocklistline'], array( $formattedTime, $blocker, $target, $properties ) ); $unblocklink = ''; if ( $wgUser->isAllowed('block') ) { $titleObj = SpecialPage::getTitleFor( "Ipblocklist" ); $unblocklink = ' (' . $sk->makeKnownLinkObj($titleObj, $msg['unblocklink'], 'action=unblock&id=' . urlencode( $block->mId ) ) . ')'; } $comment = $sk->commentBlock( $block->mReason ); $s = "{$line} $comment"; if ( $block->mHideName ) $s = '' . $s . ''; wfProfileOut( __METHOD__ ); return "