* Reorganised the includes directory, creating subdirectories db, parser and specials
[lhc/web/wiklou.git] / includes / specials / Blockme.php
1 <?php
2 /**
3 * @file
4 * @ingroup 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->addWikiMsg( 'proxyblocker-disabled' );
17 return;
18 }
19
20 $blockerName = wfMsg( "proxyblocker" );
21 $reason = wfMsg( "proxyblockreason" );
22
23 $u = User::newFromName( $blockerName );
24 $id = $u->idForName();
25 if ( !$id ) {
26 $u = User::newFromName( $blockerName );
27 $u->addToDatabase();
28 $u->setPassword( bin2hex( mt_rand(0, 0x7fffffff ) ) );
29 $u->saveSettings();
30 $id = $u->getID();
31 }
32
33 $block = new Block( $ip, 0, $id, $reason, wfTimestampNow() );
34 $block->insert();
35
36 $wgOut->addWikiMsg( "proxyblocksuccess" );
37 }