r22203 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r22202‎ | r22203 | r22204 >
Date:14:36, 16 May 2007
Author:greg
Status:old
Tags:
Comment:
Give feedback on wrong/missing args, and for invalid user.
Modified paths:
  • /trunk/phase3/maintenance/changePassword.php (modified) (history)

Diff [purge]

Index: trunk/phase3/maintenance/changePassword.php
@@ -9,12 +9,37 @@
1010 * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later
1111 */
1212
 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+
1329 class ChangePassword {
1430 var $dbw;
1531 var $user, $password;
1632
1733 function ChangePassword( $user, $password ) {
 34+ global $USAGE;
 35+ if( !strlen( $user ) or !strlen( $password ) ) {
 36+ wfDie( $USAGE );
 37+ }
 38+
1839 $this->user = User::newFromName( $user );
 40+ if ( !$this->user->getID() ) {
 41+ die ( "No such user: $user\n" );
 42+ }
 43+
1944 $this->password = $password;
2045
2146 $this->dbw = wfGetDB( DB_MASTER );
@@ -35,18 +60,4 @@
3661 }
3762 }
3863
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();
5364 ?>