Localisation updates from http://translatewiki.net.
[mediawiki.git] / maintenance / resetUserTokens.php
blob241d6328c83fcdeae9c6d2e8a05d9715d17c4f6a
1 <?php
2 /**
3 * Reset the user_token for all users on the wiki. Useful if you believe
4 * that your user table was acidentally leaked to an external source.
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License along
17 * with this program; if not, write to the Free Software Foundation, Inc.,
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19 * http://www.gnu.org/copyleft/gpl.html
21 * @file
22 * @ingroup Maintenance
23 * @author Daniel Friesen <mediawiki@danielfriesen.name>
26 require_once __DIR__ . '/Maintenance.php';
28 /**
29 * Maintenance script to reset the user_token for all users on the wiki.
31 * @ingroup Maintenance
33 class ResetUserTokens extends Maintenance {
34 public function __construct() {
35 parent::__construct();
36 $this->mDescription = "Reset the user_token of all users on the wiki. Note that this may log some of them out.";
37 $this->addOption( 'nowarn', "Hides the 5 seconds warning", false, false );
40 public function execute() {
42 if ( !$this->getOption( 'nowarn' ) ) {
43 $this->output( "The script is about to reset the user_token for ALL USERS in the database.\n" );
44 $this->output( "This may log some of them out and is not necessary unless you believe your\n" );
45 $this->output( "user table has been compromised.\n" );
46 $this->output( "\n" );
47 $this->output( "Abort with control-c in the next five seconds (skip this countdown with --nowarn) ... " );
48 wfCountDown( 5 );
51 // We list user by user_id from one of the slave database
52 $dbr = wfGetDB( DB_SLAVE );
53 $result = $dbr->select( 'user',
54 array( 'user_id' ),
55 array(),
56 __METHOD__
59 foreach ( $result as $id ) {
60 $user = User::newFromId( $id->user_id );
62 $username = $user->getName();
64 $this->output( "Resetting user_token for $username: " );
66 // Change value
67 $user->setToken();
68 $user->saveSettings();
70 $this->output( " OK\n" );
77 $maintClass = "ResetUserTokens";
78 require_once RUN_MAINTENANCE_IF_MAIN;