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()
39 $optionsWithArgs = array( 'user', 'password' );
40 require_once 'commandLine.inc';
42 if( in_array( '--help', $argv ) )
44 "Usage: php changePassword.php [--user=user --password=password | --help]\n" .
46 "\t\t--help\tshow this message\n" .
47 "\t\t--user\tthe username to operate on\n" .
48 "\t\t--password\tthe password to use\n"
51 $cp = new ChangePassword( @$options['user'], @$options['password'] );