function change_password($newpass, $newpass_rep) { $pass_ok = check_new_pass($newpass, $newpass_rep); if ($pass_ok === true) { $pass_hash = gen_pass_hash($newpass); write_pass_hash_to_db($pass_hash, $this->uid); return true; } else { return false; } }
} else { // make mailbox_limit dummy for "if" $mailbox_limit = 0; } $pass = $_POST['password']; $pass_rep = $_POST['password_repeat']; if (!empty($username) && !empty($domain) && !empty($mailbox_limit)) { // Check if user already exists $user_exists = $db->query("SELECT `" . DBC_USERS_USERNAME . "`, `" . DBC_USERS_DOMAIN . "` FROM `" . DBT_USERS . "` WHERE `" . DBC_USERS_USERNAME . "` = '{$username}' AND `" . DBC_USERS_DOMAIN . "` = '{$domain}';"); if ($user_exists->num_rows == 0) { // All fields filled with content // Check passwords $pass_ok = check_new_pass($pass, $pass_rep); if ($pass_ok === true) { // Password is okay ... continue $pass_hash = gen_pass_hash($pass); // Differ between version with mailbox_limit and version without if (defined('DBC_USERS_MAILBOXLIMIT')) { $sql = "INSERT INTO `" . DBT_USERS . "` (`" . DBC_USERS_USERNAME . "`, `" . DBC_USERS_DOMAIN . "`, `" . DBC_USERS_PASSWORD . "`, `" . DBC_USERS_MAILBOXLIMIT . "`) VALUES ('{$username}', '{$domain}', '{$pass_hash}', '{$mailbox_limit}')"; } else { $sql = "INSERT INTO `" . DBT_USERS . "` (`" . DBC_USERS_USERNAME . "`, `" . DBC_USERS_DOMAIN . "`, `" . DBC_USERS_PASSWORD . "`) VALUES ('{$username}', '{$domain}', '{$pass_hash}')"; } if (!($result = $db->query($sql))) { dbError($db->error); } // Redirect user to user list redirect("admin/listusers/?created=1"); } else { // Password not okay add_message("fail", $PASS_ERR_MSG); }