Index: trunk/phase3/maintenance/changePassword.php |
— | — | @@ -9,12 +9,37 @@ |
10 | 10 | * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later |
11 | 11 | */ |
12 | 12 | |
| 13 | +$optionsWithArgs = array( 'user', 'password' ); |
| 14 | +require_once 'commandLine.inc'; |
| 15 | + |
| 16 | +$USAGE = |
| 17 | + "Usage: php changePassword.php [--user=user --password=password | --help]\n" . |
| 18 | + "\toptions:\n" . |
| 19 | + "\t\t--help show this message\n" . |
| 20 | + "\t\t--user the username to operate on\n" . |
| 21 | + "\t\t--password the password to use\n"; |
| 22 | + |
| 23 | +if( in_array( '--help', $argv ) ) |
| 24 | + wfDie( $USAGE ); |
| 25 | + |
| 26 | +$cp = new ChangePassword( @$options['user'], @$options['password'] ); |
| 27 | +$cp->main(); |
| 28 | + |
13 | 29 | class ChangePassword { |
14 | 30 | var $dbw; |
15 | 31 | var $user, $password; |
16 | 32 | |
17 | 33 | function ChangePassword( $user, $password ) { |
| 34 | + global $USAGE; |
| 35 | + if( !strlen( $user ) or !strlen( $password ) ) { |
| 36 | + wfDie( $USAGE ); |
| 37 | + } |
| 38 | + |
18 | 39 | $this->user = User::newFromName( $user ); |
| 40 | + if ( !$this->user->getID() ) { |
| 41 | + die ( "No such user: $user\n" ); |
| 42 | + } |
| 43 | + |
19 | 44 | $this->password = $password; |
20 | 45 | |
21 | 46 | $this->dbw = wfGetDB( DB_MASTER ); |
— | — | @@ -35,18 +60,4 @@ |
36 | 61 | } |
37 | 62 | } |
38 | 63 | |
39 | | -$optionsWithArgs = array( 'user', 'password' ); |
40 | | -require_once 'commandLine.inc'; |
41 | | - |
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" |
49 | | - ); |
50 | | - |
51 | | -$cp = new ChangePassword( @$options['user'], @$options['password'] ); |
52 | | -$cp->main(); |
53 | 64 | ?> |