diff options
Diffstat (limited to 'includes/specials/SpecialBlockme.php')
-rw-r--r-- | includes/specials/SpecialBlockme.php | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/includes/specials/SpecialBlockme.php b/includes/specials/SpecialBlockme.php new file mode 100644 index 00000000..f222e3c6 --- /dev/null +++ b/includes/specials/SpecialBlockme.php @@ -0,0 +1,37 @@ +<?php +/** + * @file + * @ingroup SpecialPage + */ + +/** + * + */ +function wfSpecialBlockme() { + global $wgRequest, $wgBlockOpenProxies, $wgOut, $wgProxyKey; + + $ip = wfGetIP(); + + if( !$wgBlockOpenProxies || $wgRequest->getText( 'ip' ) != md5( $ip . $wgProxyKey ) ) { + $wgOut->addWikiMsg( 'proxyblocker-disabled' ); + return; + } + + $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(); + } + + $block = new Block( $ip, 0, $id, $reason, wfTimestampNow() ); + $block->insert(); + + $wgOut->addWikiMsg( "proxyblocksuccess" ); +} |