3 * Change the password of a given user
6 * @subpackage 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 class ChangePassword
{
17 function ChangePassword( $user, $password ) {
18 $this->user
= User
::newFromName( $user );
19 $this->password
= $password;
21 $this->dbw
=& wfGetDB( DB_MASTER
);
25 $fname = 'ChangePassword::main';
27 $this->dbw
->update( 'user',
29 'user_password' => wfEncryptPassword( $this->user
->getID(), $this->password
)
32 'user_id' => $this->user
->getID()
38 if ( in_array( '--help', $argv ) )
40 "Usage: php changePassword.php [--user=user --password=password | --help]\n" .
42 "\t\t--help\tshow this message\n" .
43 "\t\t--user\tthe username to operate on\n" .
44 "\t\t--password\tthe password to use\n"
47 $optionsWithArgs = array( 'user', 'password' );
48 require_once 'commandLine.inc';
50 $cp = new ChangePassword( @$options['user'], @$options['password'] );