SpecialBlockme.php 783 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. <?php
  2. /**
  3. * @file
  4. * @ingroup SpecialPage
  5. */
  6. /**
  7. *
  8. */
  9. function wfSpecialBlockme() {
  10. global $wgRequest, $wgBlockOpenProxies, $wgOut, $wgProxyKey;
  11. $ip = wfGetIP();
  12. if( !$wgBlockOpenProxies || $wgRequest->getText( 'ip' ) != md5( $ip . $wgProxyKey ) ) {
  13. $wgOut->addWikiMsg( 'proxyblocker-disabled' );
  14. return;
  15. }
  16. $blockerName = wfMsg( "proxyblocker" );
  17. $reason = wfMsg( "proxyblockreason" );
  18. $u = User::newFromName( $blockerName );
  19. $id = $u->idForName();
  20. if ( !$id ) {
  21. $u = User::newFromName( $blockerName );
  22. $u->addToDatabase();
  23. $u->setPassword( bin2hex( mt_rand(0, 0x7fffffff ) ) );
  24. $u->saveSettings();
  25. $id = $u->getID();
  26. }
  27. $block = new Block( $ip, 0, $id, $reason, wfTimestampNow() );
  28. $block->insert();
  29. $wgOut->addWikiMsg( "proxyblocksuccess" );
  30. }