'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',
'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
);
/**
# Unlisted / redirects
'Blankpage' => 'SpecialBlankpage',
- 'Blockme' => array( 'UnlistedSpecialPage', 'Blockme' ),
+ 'Blockme' => 'SpecialBlockme',
'Emailuser' => 'SpecialEmailUser',
'Listadmins' => array( 'SpecialRedirectToSpecial', 'Listadmins', 'Listusers', 'sysop' ),
'Listbots' => array( 'SpecialRedirectToSpecial', 'Listbots', 'Listusers', 'bot' ),
*/
/**
- * @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' );
+ }
}