X-Git-Url: http://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2FSpecialBlockip.php;h=5da520d49bfb577816b9185b35567fd48bc1bc59;hb=0ee9a04366b22971725e45af9abd6b28827880dc;hp=f3e15342bcf0d898a234073918f7ac0fefa9510d;hpb=28ea816fbafe96825d3c35187a12cadafca6905f;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/SpecialBlockip.php b/includes/SpecialBlockip.php index f3e15342bc..5da520d49b 100644 --- a/includes/SpecialBlockip.php +++ b/includes/SpecialBlockip.php @@ -19,9 +19,14 @@ function wfSpecialBlockip() { $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( '' ); + } } /** @@ -41,17 +46,17 @@ class IPBlockForm { } 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' ) ); @@ -66,6 +71,12 @@ class IPBlockForm { $scBlockAddress = htmlspecialchars( $this->BlockAddress ); $scBlockExpiry = htmlspecialchars( $this->BlockExpiry ); $scBlockReason = htmlspecialchars( $this->BlockReason ); + + $blockExpiryFormOptions = '\n\t\t\t\t\t'; + + $token = htmlspecialchars( $wgUser->editToken() ); $wgOut->addHTML( "
@@ -79,7 +90,9 @@ class IPBlockForm { {$mIpbexpiry}: - + @@ -95,6 +108,7 @@ class IPBlockForm { +
\n" ); } @@ -147,10 +161,11 @@ class IPBlockForm { return; } - $expiry = wfUnix2Timestamp( $expiry ); + $expiry = wfTimestamp( TS_MW, $expiry ); } + if ( $this->BlockReason == '') { $this->showForm( wfMsg( 'noblockreason' ) ); return; @@ -160,16 +175,24 @@ class IPBlockForm { # 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() {