]> scripts.mit.edu Git - autoinstallsdev/mediawiki.git/blob - includes/SpecialBlockme.php
MediaWiki 1.11.0-scripts
[autoinstallsdev/mediawiki.git] / includes / SpecialBlockme.php
1 <?php
2 /**
3  *
4  * @addtogroup SpecialPage
5  */
6
7 /**
8  *
9  */
10 function wfSpecialBlockme() {
11         global $wgRequest, $wgBlockOpenProxies, $wgOut, $wgProxyKey;
12
13         $ip = wfGetIP();
14         
15         if( !$wgBlockOpenProxies || $wgRequest->getText( 'ip' ) != md5( $ip . $wgProxyKey ) ) {
16                 $wgOut->addWikiText( wfMsg( 'disabled' ) );
17                 return;
18         }
19
20         $blockerName = wfMsg( "proxyblocker" );
21         $reason = wfMsg( "proxyblockreason" );
22         $success = wfMsg( "proxyblocksuccess" );
23
24         $u = User::newFromName( $blockerName );
25         $id = $u->idForName();
26         if ( !$id ) {
27                 $u = User::newFromName( $blockerName );
28                 $u->addToDatabase();
29                 $u->setPassword( bin2hex( mt_rand(0, 0x7fffffff ) ) );
30                 $u->saveSettings();
31                 $id = $u->getID();
32         }
33
34         $block = new Block( $ip, 0, $id, $reason, wfTimestampNow() );
35         $block->insert();
36
37         $wgOut->addWikiText( $success );
38 }
39