/
update_password.php
47 lines (38 loc) · 1.13 KB
/
update_password.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
<?php
/**
* CLI script to update a user password
*/
if (strtolower(php_sapi_name()) !== 'cli') {
die("Must be run from the command line\n");
}
if (is_array($argv) && count($argv) == 3) {
$user = $argv[1];
$pass = $argv[2];
}
else {
die("Incorrect usage\n\nphp ./scripts/update_password.php <username> <password>\n\n");
}
/* debug mode has to be set to something or include files will die() */
define('DEBUG_MODE', false);
/* determine current absolute path used for require statements */
define('APP_PATH', dirname(dirname(__FILE__)).'/');
define('VENDOR_PATH', APP_PATH.'vendor/');
define('WEB_ROOT', '');
/* get the framework */
require APP_PATH.'lib/framework.php';
/* get config object */
$config = new Hm_Site_Config_File(APP_PATH.'hm3.rc');
/* check config for db auth */
if ($config->get('auth_type') != 'DB') {
die("Incorrect usage\n\nThis script only works if DB auth is enabled in your site configuration\n\n");
}
$auth = new Hm_Auth_DB($config);
if ($user && $pass) {
if ($auth->change_pass($user, $pass)) {
die("Password Updated\n\n");
}
else {
die("An error occured\n\n");
}
}
?>