From: Daniel Friesen Date: Fri, 11 Feb 2011 02:46:08 +0000 (+0000) Subject: Add a new maintenance script to reset the user_token of all users if you think someon... X-Git-Tag: 1.31.0-rc.0~32053 X-Git-Url: https://git.cyclocoop.org/%27.WWW_URL.%27admin/?a=commitdiff_plain;h=51cdf2eb149631d8240a4be05fcfe7a24d39928f;p=lhc%2Fweb%2Fwiklou.git Add a new maintenance script to reset the user_token of all users if you think someone got ahold of your user table. --- diff --git a/maintenance/resetUserTokens.php b/maintenance/resetUserTokens.php new file mode 100644 index 0000000000..52407f4d4d --- /dev/null +++ b/maintenance/resetUserTokens.php @@ -0,0 +1,82 @@ + + */ + +require_once( dirname( __FILE__ ) . '/Maintenance.php' ); + +class ResetUserTokens extends Maintenance { + public function __construct() { + parent::__construct(); + $this->mDescription = "Reset the user_token of all users on the wiki. Note that this may log some of them out."; + $this->addOption( 'nowarn', "Hides the 5 seconds warning", false, false ); + $this->addOption( 'quiet', "Do not print what is happening", false, false ); + } + + public function execute() { + $nowarn = $this->getOption( 'nowarn' ); + $quiet = $this->getOption( 'quiet' ); + + if ( !$nowarn ) { + echo <<select( 'user', + array( 'user_id' ), + array(), + __METHOD__ + ); + + foreach ( $result as $id ) { + $user = User::newFromId( $id->user_id ); + + $username = $user->getName(); + + if ( !$quiet ) { + echo "Resetting user_token for $username: "; + } + + // Change value + $user->setToken(); + $user->saveSettings(); + + if ( !$quiet ) { + echo " OK\n"; + } + + } + + } +} + +$maintClass = "ResetUserTokens"; +require_once( RUN_MAINTENANCE_IF_MAIN );