Remove unused parameter
[mediawiki.git] / maintenance / changePassword.php
blobd43703768b6f6292b621f58069ec3956baa8482d
1 <?php
2 /**
3 * Change the password of a given user
5 * @file
6 * @ingroup Maintenance
8 * @author Ævar Arnfjörð Bjarmason <avarab@gmail.com>
9 * @copyright Copyright © 2005, Ævar Arnfjörð Bjarmason
10 * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later
13 $optionsWithArgs = array( 'user', 'password' );
14 require_once 'commandLine.inc';
16 $USAGE =
17 "Usage: php changePassword.php [--user=user --password=password | --help]\n" .
18 "\toptions:\n" .
19 "\t\t--help show this message\n" .
20 "\t\t--user the username to operate on\n" .
21 "\t\t--password the password to use\n";
23 if( in_array( '--help', $argv ) )
24 wfDie( $USAGE );
26 $cp = new ChangePassword( @$options['user'], @$options['password'] );
27 $cp->main();
29 /**
30 * @ingroup Maintenance
32 class ChangePassword {
33 var $dbw;
34 var $user, $password;
36 function ChangePassword( $user, $password ) {
37 global $USAGE;
38 if( !strlen( $user ) or !strlen( $password ) ) {
39 wfDie( $USAGE );
42 $this->user = User::newFromName( $user );
43 if ( !$this->user->getId() ) {
44 die ( "No such user: $user\n" );
47 $this->password = $password;
49 $this->dbw = wfGetDB( DB_MASTER );
52 function main() {
53 $fname = 'ChangePassword::main';
55 $this->user->setPassword( $this->password );
56 $this->user->saveSettings();