diff options
author | Pierre Schmitz <pierre@archlinux.de> | 2006-10-11 18:12:39 +0000 |
---|---|---|
committer | Pierre Schmitz <pierre@archlinux.de> | 2006-10-11 18:12:39 +0000 |
commit | 183851b06bd6c52f3cae5375f433da720d410447 (patch) | |
tree | a477257decbf3360127f6739c2f9d0ec57a03d39 /maintenance/changePassword.php |
MediaWiki 1.7.1 wiederhergestellt
Diffstat (limited to 'maintenance/changePassword.php')
-rw-r--r-- | maintenance/changePassword.php | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/maintenance/changePassword.php b/maintenance/changePassword.php new file mode 100644 index 00000000..591a82b3 --- /dev/null +++ b/maintenance/changePassword.php @@ -0,0 +1,53 @@ +<?php +/** + * Change the password of a given user + * + * @package MediaWiki + * @subpackage Maintenance + * + * @author Ævar Arnfjörð Bjarmason <avarab@gmail.com> + * @copyright Copyright © 2005, Ævar Arnfjörð Bjarmason + * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later + */ + +class ChangePassword { + var $dbw; + var $user, $password; + + function ChangePassword( $user, $password ) { + $this->user = User::newFromName( $user ); + $this->password = $password; + + $this->dbw =& wfGetDB( DB_MASTER ); + } + + function main() { + $fname = 'ChangePassword::main'; + + $this->dbw->update( 'user', + array( + 'user_password' => wfEncryptPassword( $this->user->getID(), $this->password ) + ), + array( + 'user_id' => $this->user->getID() + ), + $fname + ); + } +} + +$optionsWithArgs = array( 'user', 'password' ); +require_once 'commandLine.inc'; + +if( in_array( '--help', $argv ) ) + wfDie( + "Usage: php changePassword.php [--user=user --password=password | --help]\n" . + "\toptions:\n" . + "\t\t--help\tshow this message\n" . + "\t\t--user\tthe username to operate on\n" . + "\t\t--password\tthe password to use\n" + ); + +$cp = new ChangePassword( @$options['user'], @$options['password'] ); +$cp->main(); +?> |