123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354 |
- <?php
- define('INSTALLDIR', dirname(__DIR__));
- define('PUBLICDIR', INSTALLDIR . DIRECTORY_SEPARATOR . 'public');
- $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);
- }
- try {
- $user = User::getByNickname($nickname);
- $user->setPassword($password);
- } catch (NoSuchUserException $e) {
- print $e->getMessage();
- exit(1);
- }
- print "Password for user '$nickname' updated.\n";
|