r69486 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r69485‎ | r69486 | r69487 >
Date:18:32, 17 July 2010
Author:ialex
Status:ok
Tags:
Comment:
* Modified Special:Blockme to subclass UnlistedSpecialPage
* Use content language to get the user name in the "proxyblocker" and added it in $wgReservedUsernames
Modified paths:
  • /trunk/phase3/includes/AutoLoader.php (modified) (history)
  • /trunk/phase3/includes/DefaultSettings.php (modified) (history)
  • /trunk/phase3/includes/SpecialPage.php (modified) (history)
  • /trunk/phase3/includes/specials/SpecialBlockme.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/AutoLoader.php
@@ -583,6 +583,7 @@
584584 'SpecialActiveUsers' => 'includes/specials/SpecialActiveusers.php',
585585 'SpecialAllpages' => 'includes/specials/SpecialAllpages.php',
586586 'SpecialBlankpage' => 'includes/specials/SpecialBlankpage.php',
 587+ 'SpecialBlockme' => 'includes/specials/SpecialBlockme.php',
587588 'SpecialBookSources' => 'includes/specials/SpecialBooksources.php',
588589 'SpecialComparePages' => 'includes/specials/SpecialComparePages.php',
589590 'SpecialExport' => 'includes/specials/SpecialExport.php',
Index: trunk/phase3/includes/DefaultSettings.php
@@ -2753,6 +2753,7 @@
27542754 'Template namespace initialisation script', // Used in 1.2->1.3 upgrade
27552755 'msg:double-redirect-fixer', // Automatic double redirect fix
27562756 'msg:usermessage-editor', // Default user for leaving user messages
 2757+ 'msg:proxyblocker', // For Special:Blockme
27572758 );
27582759
27592760 /**
Index: trunk/phase3/includes/specials/SpecialBlockme.php
@@ -18,35 +18,37 @@
1919 */
2020
2121 /**
22 - * @file
 22+ * Implements Special:Blockme
2323 * @ingroup SpecialPage
2424 */
 25+class SpecialBlockme extends UnlistedSpecialPage {
2526
26 -function wfSpecialBlockme() {
27 - global $wgRequest, $wgBlockOpenProxies, $wgOut, $wgProxyKey;
 27+ function __construct() {
 28+ parent::__construct( 'Blockme' );
 29+ }
2830
29 - $ip = wfGetIP();
 31+ function execute( $par ) {
 32+ global $wgRequest, $wgOut, $wgBlockOpenProxies, $wgProxyKey;
3033
31 - if( !$wgBlockOpenProxies || $wgRequest->getText( 'ip' ) != md5( $ip . $wgProxyKey ) ) {
32 - $wgOut->addWikiMsg( 'proxyblocker-disabled' );
33 - return;
34 - }
 34+ $this->setHeaders();
 35+ $this->outputHeader();
3536
36 - $blockerName = wfMsg( "proxyblocker" );
37 - $reason = wfMsg( "proxyblockreason" );
 37+ $ip = wfGetIP();
 38+ if( !$wgBlockOpenProxies || $wgRequest->getText( 'ip' ) != md5( $ip . $wgProxyKey ) ) {
 39+ $wgOut->addWikiMsg( 'proxyblocker-disabled' );
 40+ return;
 41+ }
3842
39 - $u = User::newFromName( $blockerName );
40 - $id = $u->idForName();
41 - if ( !$id ) {
42 - $u = User::newFromName( $blockerName );
43 - $u->addToDatabase();
44 - $u->setPassword( bin2hex( mt_rand(0, 0x7fffffff ) ) );
45 - $u->saveSettings();
46 - $id = $u->getID();
47 - }
 43+ $user = User::newFromName( wfMsgForContent( 'proxyblocker' ) );
 44+ if ( !$user->isLoggedIn() ) {
 45+ $user->addToDatabase();
 46+ }
 47+ $id = $user->getId();
 48+ $reason = wfMsg( 'proxyblockreason' );
4849
49 - $block = new Block( $ip, 0, $id, $reason, wfTimestampNow() );
50 - $block->insert();
 50+ $block = new Block( $ip, 0, $id, $reason, wfTimestampNow() );
 51+ $block->insert();
5152
52 - $wgOut->addWikiMsg( "proxyblocksuccess" );
 53+ $wgOut->addWikiMsg( 'proxyblocksuccess' );
 54+ }
5355 }
Index: trunk/phase3/includes/SpecialPage.php
@@ -181,7 +181,7 @@
182182
183183 # Unlisted / redirects
184184 'Blankpage' => 'SpecialBlankpage',
185 - 'Blockme' => array( 'UnlistedSpecialPage', 'Blockme' ),
 185+ 'Blockme' => 'SpecialBlockme',
186186 'Emailuser' => 'SpecialEmailUser',
187187 'Listadmins' => array( 'SpecialRedirectToSpecial', 'Listadmins', 'Listusers', 'sysop' ),
188188 'Listbots' => array( 'SpecialRedirectToSpecial', 'Listbots', 'Listusers', 'bot' ),

Status & tagging log