Marked authenticateUserData() as public
[mediawiki.git] / maintenance / changePassword.php
blob591a82b3ecefb3e280ff2b5eee33fe23400353c4
1 <?php
2 /**
3 * Change the password of a given user
5 * @package MediaWiki
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 {
14 var $dbw;
15 var $user, $password;
17 function ChangePassword( $user, $password ) {
18 $this->user = User::newFromName( $user );
19 $this->password = $password;
21 $this->dbw =& wfGetDB( DB_MASTER );
24 function main() {
25 $fname = 'ChangePassword::main';
27 $this->dbw->update( 'user',
28 array(
29 'user_password' => wfEncryptPassword( $this->user->getID(), $this->password )
31 array(
32 'user_id' => $this->user->getID()
34 $fname
39 $optionsWithArgs = array( 'user', 'password' );
40 require_once 'commandLine.inc';
42 if( in_array( '--help', $argv ) )
43 wfDie(
44 "Usage: php changePassword.php [--user=user --password=password | --help]\n" .
45 "\toptions:\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'] );
52 $cp->main();