3 * Change the password of a given user
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';
17 "Usage: php changePassword.php [--user=user --password=password | --help]\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 ) )
26 $cp = new ChangePassword( @$options['user'], @$options['password'] );
30 * @ingroup Maintenance
32 class ChangePassword
{
36 function ChangePassword( $user, $password ) {
38 if( !strlen( $user ) or !strlen( $password ) ) {
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
);
53 $fname = 'ChangePassword::main';
55 $this->user
->setPassword( $this->password
);
56 $this->user
->saveSettings();