$user = $_POST['user']; $role = $_POST['role']; $pass = $_POST['pass']; $list = array(); for ($i = 0; $i != count($user); ++$i) { $o = userAdm($user[$i]); if (is_null($o)) { continue; } $role[$i] = $role[$i] == 1; $sameRole = $o == $role[$i]; $samePass = empty($pass[$i]); if ($sameRole && $samePass) { continue; } if (userUpd($user[$i], $samePass ? null : $pass[$i], $sameRole ? null : $role[$i])) { $list[] = htmlEntUTF8($user[$i]); } } if (count($list)) { errorMessage(T_("Updated"), $list); } } function htmlRole($name, $selected) { // role $ret = "<select class=\"element select\" name=\"{$name}\">"; foreach (array(T_("Administrator") => 1, T_("User") => 0) as $role => $admin) { $ret .= "<option value=\"{$admin}\""; if ($selected == $admin) { $ret .= " selected=\"selected\"";
</li> </ul> </form> <?php // password update if (!$authRealm) { // password update if (isset($_POST['changepw']) && !empty($_POST['oldpw']) && !empty($_POST['newpw']) && !empty($_POST['newpw2'])) { // create user if ($_POST['newpw'] !== $_POST['newpw2']) { errorMessage(T_("Password change"), T_("New passwords don't match! Password unchanged.")); } elseif (!userCheck($auth['name'], $_POST['oldpw'])) { errorMessage(T_("Password change"), T_("Old password doesn't match! Password unchanged.")); } else { userUpd($auth['name'], $_POST['newpw']); infoMessage(T_("Password change"), T_("Password successfully changed.")); } } ?> <form action="<?php echo $ref; ?> " method="post" onsubmit="validate(event);"> <ul> <h3><?php echo T_("Password"); ?> </h3> <li>
if (!userAdd($user, $pass, $admin)) { die("cannot add user '{$user}'\n"); } exit(0); } if ($argv[1] == 'rst' && $argc > 3 && $argc < 6) { $user = $argv[2]; $admin = !strcasecmp($argv[3], "true"); $pass = $argc > 4 ? $argv[4] : false; if (!userUpd($user, $pass, $admin)) { die("cannot reset user '{$user}'\n"); } exit(0); } if ($argv[1] == 'passwd' && $argc > 2 && $argc < 5) { $user = $argv[2]; $pass = $argc > 3 ? $argv[3] : false; if (!userUpd($user, $pass)) { die("cannot reset password for '{$user}'\n"); } exit(0); } if ($argv[1] == 'rm' && $argc > 2) { $user = $argv[2]; if (!userDel($user)) { die("cannot remove user '{$user}'\n"); } exit(0); } echo "{$argv['0']}: bad arguments, see {$argv['0']} help\n"; exit(2);