MediaWiki  REL1_19
SpecialBlockme.php
Go to the documentation of this file.
00001 <?php
00029 class SpecialBlockme extends UnlistedSpecialPage {
00030 
00031         function __construct() {
00032                 parent::__construct( 'Blockme' );
00033         }
00034 
00035         function execute( $par ) {
00036                 global $wgBlockOpenProxies, $wgProxyKey;
00037 
00038                 $this->setHeaders();
00039                 $this->outputHeader();
00040 
00041                 $ip = $this->getRequest()->getIP();
00042                 if( !$wgBlockOpenProxies || $this->getRequest()->getText( 'ip' ) != md5( $ip . $wgProxyKey ) ) {
00043                         $this->getOutput()->addWikiMsg( 'proxyblocker-disabled' );
00044                         return;
00045                 }
00046 
00047                 $user = User::newFromName( $this->msg( 'proxyblocker' )->inContentLanguage()->text() );
00048                 # FIXME: newFromName could return false on a badly configured wiki.
00049                 if ( !$user->isLoggedIn() ) {
00050                         $user->addToDatabase();
00051                 }
00052 
00053                 $block = new Block();
00054                 $block->setTarget( $ip );
00055                 $block->setBlocker( $user );
00056                 $block->mReason = $this->msg( 'proxyblockreason' )->inContentLanguage()->text();
00057 
00058                 $block->insert();
00059 
00060                 $this->getOutput()->addWikiMsg( 'proxyblocksuccess' );
00061         }
00062 }