function wfSpecialBlockip() {
global $wgUser, $wgOut, $wgRequest;
- if ( ! $wgUser->isSysop() ) {
+ if ( ! $wgUser->isAllowed('block') ) {
$wgOut->sysopRequired();
return;
}
$ipb = new IPBlockForm();
$action = $wgRequest->getVal( 'action' );
- if ( 'success' == $action ) { $ipb->showSuccess(); }
- else if ( $wgRequest->wasPosted() && 'submit' == $action ) { $ipb->doSubmit(); }
- else { $ipb->showForm( '' ); }
+ if ( 'success' == $action ) {
+ $ipb->showSuccess();
+ } else if ( $wgRequest->wasPosted() && 'submit' == $action &&
+ $wgUser->matchEditToken( $wgRequest->getVal( 'wpEditToken' ) ) ) {
+ $ipb->doSubmit();
+ } else {
+ $ipb->showForm( '' );
+ }
}
/**
}
function showForm( $err ) {
- global $wgOut, $wgUser, $wgLang, $wgDefaultBlockExpiry;
- global $wgRequest;
+ global $wgOut, $wgUser, $wgLang, $wgBlockExpiryOptions;
+ global $wgRequest, $wgSysopUserBans;
$wgOut->setPagetitle( htmlspecialchars( wfMsg( 'blockip' ) ) );
- $wgOut->addWikiText( htmlspecialchars( wfMsg( 'blockiptext' ) ) );
+ $wgOut->addWikiText( wfMsg( 'blockiptext' ) );
- if ( is_null( $this->BlockExpiry ) || $this->BlockExpiry === '' ) {
- $this->BlockExpiry = $wgDefaultBlockExpiry;
+ if($wgSysopUserBans) {
+ $mIpaddress = htmlspecialchars( wfMsg( 'ipadressorusername' ) );
+ } else {
+ $mIpaddress = htmlspecialchars( wfMsg( 'ipaddress' ) );
}
-
- $mIpaddress = htmlspecialchars( wfMsg( 'ipaddress' ) );
$mIpbexpiry = htmlspecialchars( wfMsg( 'ipbexpiry' ) );
$mIpbreason = htmlspecialchars( wfMsg( 'ipbreason' ) );
$mIpbsubmit = htmlspecialchars( wfMsg( 'ipbsubmit' ) );
$scBlockAddress = htmlspecialchars( $this->BlockAddress );
$scBlockExpiry = htmlspecialchars( $this->BlockExpiry );
$scBlockReason = htmlspecialchars( $this->BlockReason );
+
+ $blockExpiryFormOptions = '<option>' .
+ implode("</option>\n\t\t\t\t\t<option>", explode(',', $wgBlockExpiryOptions)) .
+ '</option>';
+
+ $token = htmlspecialchars( $wgUser->editToken() );
$wgOut->addHTML( "
<form id=\"blockip\" method=\"post\" action=\"{$action}\">
<tr>
<td align=\"right\">{$mIpbexpiry}:</td>
<td align=\"left\">
- <input tabindex='2' type='text' size='20' name=\"wpBlockExpiry\" value=\"{$scBlockExpiry}\" />
+ <select tabindex='2' name=\"wpBlockExpiry\">
+ $blockExpiryFormOptions
+ </select>
</td>
</tr>
<tr>
</td>
</tr>
</table>
+ <input type='hidden' name='wpEditToken' value=\"{$token}\" />
</form>\n" );
}
return;
}
- $expiry = wfUnix2Timestamp( $expiry );
+ $expiry = wfTimestamp( TS_MW, $expiry );
}
- if ( $this->BlockReason == '') {
- $this->showForm( wfMsg( 'noblockreason' ) );
- return;
- }
-
# Create block
# Note: for a user block, ipb_address is only for display purposes
$ban = new Block( $this->BlockAddress, $userId, $wgUser->getID(),
- wfStrencode( $this->BlockReason ), wfTimestampNow(), 0, $expiry );
- $ban->insert();
-
- # Make log entry
- $log = new LogPage( 'block' );
- $log->addEntry( 'block', Title::makeTitle( NS_USER, $this->BlockAddress ), $this->BlockReason );
-
- # Report to the user
- $titleObj = Title::makeTitle( NS_SPECIAL, 'Blockip' );
- $wgOut->redirect( $titleObj->getFullURL( 'action=success&ip='.$this->BlockAddress ) );
+ $this->BlockReason, wfTimestampNow(), 0, $expiry );
+
+ if (wfRunHooks('BlockIp', array(&$ban, &$wgUser))) {
+
+ $ban->insert();
+
+ wfRunHooks('BlockIpComplete', array($ban, $wgUser));
+
+ # Make log entry
+ $log = new LogPage( 'block' );
+ $log->addEntry( 'block', Title::makeTitle( NS_USER, $this->BlockAddress ),
+ $this->BlockReason, $this->BlockExpiry );
+
+ # Report to the user
+ $titleObj = Title::makeTitle( NS_SPECIAL, 'Blockip' );
+ $wgOut->redirect( $titleObj->getFullURL( 'action=success&ip=' .
+ urlencode( $this->BlockAddress ) ) );
+ }
}
function showSuccess() {