bugfix: if the upload path is absolute, don't prepend the server URL
[lhc/web/wiklou.git] / includes / SpecialIpblocklist.php
index f4547df..492f78d 100644 (file)
@@ -1,7 +1,14 @@
 <?php
-
-function wfSpecialIpblocklist()
-{
+/**
+ *
+ * @package MediaWiki
+ * @subpackage SpecialPage
+ */
+
+/**
+ * @todo document
+ */
+function wfSpecialIpblocklist() {
        global $wgUser, $wgOut, $wgRequest;
        
        $ip = $wgRequest->getVal( 'wpUnblockAddress', $wgRequest->getVal( 'ip' ) );
@@ -11,10 +18,11 @@ function wfSpecialIpblocklist()
        $ipu = new IPUnblockForm( $ip, $reason );
 
        if ( "success" == $action ) {
-               $msg = wfMsg( "ipusuccess", $ip );
+               $msg = wfMsg( "ipusuccess", htmlspecialchars( $ip ) );
                $ipu->showList( $msg );
-       } else if ( "submit" == $action && $wgRequest->wasPosted() ) {
-               if ( ! $wgUser->isSysop() ) {
+       } else if ( "submit" == $action && $wgRequest->wasPosted() &&
+               $wgUser->matchEditToken( $wgRequest->getVal( 'wpEditToken' ) ) ) {
+               if ( ! $wgUser->isAllowed('block') ) {
                        $wgOut->sysopRequired();
                        return;
                }
@@ -26,6 +34,11 @@ function wfSpecialIpblocklist()
        }
 }
 
+/**
+ * 
+ * @package MediaWiki
+ * @subpackage SpecialPage
+ */
 class IPUnblockForm {
        var $ip, $reason;
        
@@ -49,29 +62,38 @@ class IPUnblockForm {
 
                if ( "" != $err ) {
                        $wgOut->setSubtitle( wfMsg( "formerror" ) );
-                       $wgOut->addHTML( "<p><font color='red' size='+1'>{$err}</font>\n" );
+                       $wgOut->addHTML( "<p class='error'>{$err}</p>\n" );
                }
+               $token = htmlspecialchars( $wgUser->editToken() );
                
-               $wgOut->addHTML( "<p>
+               $wgOut->addHTML( "
 <form id=\"unblockip\" method=\"post\" action=\"{$action}\">
-<table border=0><tr>
-<td align=right>{$ipa}:</td>
-<td align=left>
-<input tabindex=1 type=text size=20 name=\"wpUnblockAddress\" value=\"" . htmlspecialchars( $this->ip ) . "\">
-</td></tr><tr>
-<td align=right>{$ipr}:</td>
-<td align=left>
-<input tabindex=1 type=text size=40 name=\"wpUnblockReason\" value=\"" . htmlspecialchars( $this->reason ) . "\">
-</td></tr><tr>
-<td>&nbsp;</td><td align=left>
-<input tabindex=2 type=submit name=\"wpBlock\" value=\"{$ipus}\">
-</td></tr></table>
+       <table border='0'>
+               <tr>
+                       <td align='right'>{$ipa}:</td>
+                       <td align='left'>
+                               <input tabindex='1' type='text' size='20' name=\"wpUnblockAddress\" value=\"" . htmlspecialchars( $this->ip ) . "\" />
+                       </td>
+               </tr>
+               <tr>
+                       <td align='right'>{$ipr}:</td>
+                       <td align='left'>
+                               <input tabindex='1' type='text' size='40' name=\"wpUnblockReason\" value=\"" . htmlspecialchars( $this->reason ) . "\" />
+                       </td>
+               </tr>
+               <tr>
+                       <td>&nbsp;</td>
+                       <td align='left'>
+                               <input tabindex='2' type='submit' name=\"wpBlock\" value=\"{$ipus}\" />
+                       </td>
+               </tr>
+       </table>
+       <input type='hidden' name='wpEditToken' value=\"{$token}\" />
 </form>\n" );
 
        }
        
-       function doSubmit()
-       {
+       function doSubmit() {
                global $wgOut, $wgUser, $wgLang;
 
                $block = new Block();
@@ -88,9 +110,8 @@ class IPUnblockForm {
                $block->delete();
 
                # Make log entry
-               $log = new LogPage( wfMsg( "blocklogpage" ), wfMsg( "blocklogtext" ) );
-               $action = wfMsg( "unblocklogentry", $this->ip );
-               $log->addEntry( $action, $this->reason );
+               $log = new LogPage( 'block' );
+               $log->addEntry( 'unblock', Title::makeTitle( NS_USER, $this->ip ), $this->reason );
 
                # Report to the user
                $titleObj = Title::makeTitle( NS_SPECIAL, "Ipblocklist" );
@@ -98,8 +119,7 @@ class IPUnblockForm {
                $wgOut->redirect( $success );
        }
 
-       function showList( $msg )
-       {
+       function showList( $msg ) {
                global $wgOut;
                
                $wgOut->setPagetitle( wfMsg( "ipblocklist" ) );
@@ -112,9 +132,11 @@ class IPUnblockForm {
        }
 }
 
-# Callback function to output a block
+/**
+ * Callback function to output a block
+ */
 function wfAddRow( $block, $tag ) {
-       global $wgOut, $wgUser, $wgLang;
+       global $wgOut, $wgUser, $wgLang, $wgContLang;
 
        $sk = $wgUser->getSkin();
 
@@ -122,7 +144,7 @@ function wfAddRow( $block, $tag ) {
        $addr = $block->mAuto ? "#{$block->mId}" : $block->mAddress;
 
        $name = User::whoIs( $block->mBy );
-       $ulink = $sk->makeKnownLink( $wgLang->getNsText( Namespace::getUser() ). ":{$name}", $name );
+       $ulink = $sk->makeKnownLinkObj( Title::makeTitle( NS_USER, $name ), $name );
        $formattedTime = $wgLang->timeanddate( $block->mTimestamp, true );
        
        if ( $block->mExpiry === "" ) {
@@ -142,17 +164,14 @@ function wfAddRow( $block, $tag ) {
                $wgOut->addHTML( " ({$clink})" );
        }
 
-       if ( $wgUser->isSysop() ) {
+       if ( $wgUser->isAllowed('block') ) {
                $titleObj = Title::makeTitle( NS_SPECIAL, "Ipblocklist" );
                $ublink = "<a href=\"" . 
                  $titleObj->escapeLocalURL( "action=unblock&ip=" . urlencode( $addr ) ) . "\">" .
                  wfMsg( "unblocklink" ) . "</a>";
                $wgOut->addHTML( " ({$ublink})" );
        }
-       if ( "" != $block->mReason ) {
-               $wgOut->addHTML( " <em>(" . wfEscapeHTML( $block->mReason ) .
-                 ")</em>" );
-       }
+       $wgOut->addHTML( $sk->commentBlock( $block->mReason ) );
        $wgOut->addHTML( "</li>\n" );
 }