zotero_selfhost/change_password

39 lines
649 B
Plaintext
Raw Permalink Normal View History

2017-07-30 16:33:11 -04:00
#!/usr/local/bin/php
<?
set_include_path("../include");
require("header.inc.php");
if (empty($argv[1])) {
die("Usage: $argv[0] " . '$username $password' . "\n");
}
$username = $argv[1];
$password = $argv[2];
$docRoot = str_replace($_SERVER['SCRIPT_NAME'], '', __FILE__);
echo $docRoot;
echo "changing password for user $username\n";
$passwordhash = md5($password, PASSWORD_DEFAULT);
Zotero_DB::beginTransaction();
$sql = "SET NAMES UTF8;";
Zotero_DB::query($sql);
$sql = "UPDATE zotero_www.users SET password=? WHERE username=?";
Zotero_DB::query($sql, array($passwordhash,$username));
Zotero_DB::commit();
?>