* Modified Special:Blockme to subclass UnlistedSpecialPage
authorAlexandre Emsenhuber <ialex@users.mediawiki.org>
Sat, 17 Jul 2010 18:32:15 +0000 (18:32 +0000)
committerAlexandre Emsenhuber <ialex@users.mediawiki.org>
Sat, 17 Jul 2010 18:32:15 +0000 (18:32 +0000)
* Use content language to get the user name in the "proxyblocker" and added it in $wgReservedUsernames

includes/AutoLoader.php
includes/DefaultSettings.php
includes/SpecialPage.php
includes/specials/SpecialBlockme.php

index 2b4d91a..eefa393 100644 (file)
@@ -583,6 +583,7 @@ $wgAutoloadLocalClasses = array(
        'SpecialActiveUsers' => 'includes/specials/SpecialActiveusers.php',
        'SpecialAllpages' => 'includes/specials/SpecialAllpages.php',
        'SpecialBlankpage' => 'includes/specials/SpecialBlankpage.php',
+       'SpecialBlockme' => 'includes/specials/SpecialBlockme.php',
        'SpecialBookSources' => 'includes/specials/SpecialBooksources.php',
        'SpecialComparePages' => 'includes/specials/SpecialComparePages.php',
        'SpecialExport' => 'includes/specials/SpecialExport.php',
index f2ede07..505cc85 100644 (file)
@@ -2753,6 +2753,7 @@ $wgReservedUsernames = array(
        'Template namespace initialisation script', // Used in 1.2->1.3 upgrade
        'msg:double-redirect-fixer', // Automatic double redirect fix
        'msg:usermessage-editor', // Default user for leaving user messages
+       'msg:proxyblocker', // For Special:Blockme
 );
 
 /**
index 22ed55a..d192506 100644 (file)
@@ -181,7 +181,7 @@ class SpecialPage {
 
                # Unlisted / redirects
                'Blankpage'                 => 'SpecialBlankpage',
-               'Blockme'                   => array( 'UnlistedSpecialPage', 'Blockme' ),
+               'Blockme'                   => 'SpecialBlockme',
                'Emailuser'                 => 'SpecialEmailUser',
                'Listadmins'                => array( 'SpecialRedirectToSpecial', 'Listadmins', 'Listusers', 'sysop' ),
                'Listbots'                  => array( 'SpecialRedirectToSpecial', 'Listbots', 'Listusers', 'bot' ),
index 5728509..4510701 100644 (file)
  */
 
 /**
- * @file
+ * Implements Special:Blockme
  * @ingroup SpecialPage
  */
+class SpecialBlockme extends UnlistedSpecialPage {
 
-function wfSpecialBlockme() {
-       global $wgRequest, $wgBlockOpenProxies, $wgOut, $wgProxyKey;
+       function __construct() {
+               parent::__construct( 'Blockme' );
+       }
 
-       $ip = wfGetIP();
+       function execute( $par ) {
+               global $wgRequest, $wgOut, $wgBlockOpenProxies, $wgProxyKey;
 
-       if( !$wgBlockOpenProxies || $wgRequest->getText( 'ip' ) != md5( $ip . $wgProxyKey ) ) {
-               $wgOut->addWikiMsg( 'proxyblocker-disabled' );
-               return;
-       }
+               $this->setHeaders();
+               $this->outputHeader();
 
-       $blockerName = wfMsg( "proxyblocker" );
-       $reason = wfMsg( "proxyblockreason" );
-
-       $u = User::newFromName( $blockerName );
-       $id = $u->idForName();
-       if ( !$id ) {
-               $u = User::newFromName( $blockerName );
-               $u->addToDatabase();
-               $u->setPassword( bin2hex( mt_rand(0, 0x7fffffff ) ) );
-               $u->saveSettings();
-               $id = $u->getID();
-       }
+               $ip = wfGetIP();
+               if( !$wgBlockOpenProxies || $wgRequest->getText( 'ip' ) != md5( $ip . $wgProxyKey ) ) {
+                       $wgOut->addWikiMsg( 'proxyblocker-disabled' );
+                       return;
+               }
 
-       $block = new Block( $ip, 0, $id, $reason, wfTimestampNow() );
-       $block->insert();
+               $user = User::newFromName( wfMsgForContent( 'proxyblocker' ) );
+               if ( !$user->isLoggedIn() ) {
+                       $user->addToDatabase();
+               }
+               $id = $user->getId();
+               $reason = wfMsg( 'proxyblockreason' );
 
-       $wgOut->addWikiMsg( "proxyblocksuccess" );
+               $block = new Block( $ip, 0, $id, $reason, wfTimestampNow() );
+               $block->insert();
+
+               $wgOut->addWikiMsg( 'proxyblocksuccess' );
+       }
 }