From: Alexandre Emsenhuber Date: Sat, 17 Jul 2010 18:32:15 +0000 (+0000) Subject: * Modified Special:Blockme to subclass UnlistedSpecialPage X-Git-Tag: 1.31.0-rc.0~36116 X-Git-Url: https://git.cyclocoop.org/%7B%24admin_url%7Dmembres/supprimer.php?a=commitdiff_plain;h=47df637812ba13057a4a823d292fb77c4a1b5200;p=lhc%2Fweb%2Fwiklou.git * Modified Special:Blockme to subclass UnlistedSpecialPage * Use content language to get the user name in the "proxyblocker" and added it in $wgReservedUsernames --- diff --git a/includes/AutoLoader.php b/includes/AutoLoader.php index 2b4d91a915..eefa39335b 100644 --- a/includes/AutoLoader.php +++ b/includes/AutoLoader.php @@ -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', diff --git a/includes/DefaultSettings.php b/includes/DefaultSettings.php index f2ede07b43..505cc85fb1 100644 --- a/includes/DefaultSettings.php +++ b/includes/DefaultSettings.php @@ -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 ); /** diff --git a/includes/SpecialPage.php b/includes/SpecialPage.php index 22ed55a977..d192506c47 100644 --- a/includes/SpecialPage.php +++ b/includes/SpecialPage.php @@ -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' ), diff --git a/includes/specials/SpecialBlockme.php b/includes/specials/SpecialBlockme.php index 5728509fbc..4510701202 100644 --- a/includes/specials/SpecialBlockme.php +++ b/includes/specials/SpecialBlockme.php @@ -18,35 +18,37 @@ */ /** - * @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' ); + } }