00001 <?php 00013 $optionsWithArgs = array( 'user', 'password' ); 00014 require_once 'commandLine.inc'; 00015 00016 $USAGE = 00017 "Usage: php changePassword.php [--user=user --password=password | --help]\n" . 00018 "\toptions:\n" . 00019 "\t\t--help show this message\n" . 00020 "\t\t--user the username to operate on\n" . 00021 "\t\t--password the password to use\n"; 00022 00023 if( in_array( '--help', $argv ) ) 00024 wfDie( $USAGE ); 00025 00026 $cp = new ChangePassword( @$options['user'], @$options['password'] ); 00027 $cp->main(); 00028 00032 class ChangePassword { 00033 var $dbw; 00034 var $user, $password; 00035 00036 function ChangePassword( $user, $password ) { 00037 global $USAGE; 00038 if( !strlen( $user ) or !strlen( $password ) ) { 00039 wfDie( $USAGE ); 00040 } 00041 00042 $this->user = User::newFromName( $user ); 00043 if ( !$this->user->getId() ) { 00044 die ( "No such user: $user\n" ); 00045 } 00046 00047 $this->password = $password; 00048 00049 $this->dbw = wfGetDB( DB_MASTER ); 00050 } 00051 00052 function main() { 00053 $this->user->setPassword( $this->password ); 00054 $this->user->saveSettings(); 00055 } 00056 }