1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162 |
- <?php
- define('INSTALLDIR', realpath(dirname(__FILE__) . '/..'));
- $helptext = <<<END_OF_PASSWORD_HELP
- setpassword.php <username> <password>
- Sets the password of user with name <username> to <password>
- END_OF_PASSWORD_HELP;
- require_once INSTALLDIR.'/scripts/commandline.inc';
- if (count($args) < 2) {
- show_help();
- }
- $nickname = $args[0];
- $password = $args[1];
- if (mb_strlen($password) < 6) {
- print "Password must be 6 characters or more.\n";
- exit(1);
- }
- $user = User::getKV('nickname', $nickname);
- if (!$user) {
- print "No such user '$nickname'.\n";
- exit(1);
- }
- $original = clone($user);
- $user->password = common_munge_password($password, $user->id);
- if (!$user->update($original)) {
- print "Error updating user '$nickname'.\n";
- exit(1);
- } else {
- print "Password for user '$nickname' updated.\n";
- exit(0);
- }
|