renderError('General error'); } $key = addslashes(htmlspecialchars($_GET['v'])); $users = Vesta::execute(Vesta::V_LIST_SYS_USERS, 'json'); $email_matched_count = array(); /*if (strcmp($real_key, $key_sha1) != 0) { return $this->renderError('Invalid keys'); }*/ foreach ($users['data'] as $username => $user) { if ($user['RKEY'] == trim($key)) { $email_matched_count[] = array_merge(array('USERNAME' => $username), $user); } } if (isset($_POST['action']) && $_POST['action'] == 'change') { return $this->doChangePassword($email_matched_count); } return $this->showResetForm(); } protected function doChangePassword($users) { if ($_POST['secret_code'] != $_POST['confirm_secret_code']) { return $this->showResetForm('Passwords don\'t match'); } if (strlen($_POST['secret_code']) < 6) { return $this->showResetForm('Passwords is too short'); } if (strlen($_POST['secret_code']) > 255) { return $this->showResetForm('Passwords is too long'); } $success = true; foreach ($users as $user) { $rs = Vesta::execute(Vesta::V_CHANGE_SYS_USER_PASSWORD, array('USER' => $user['USERNAME'], 'PASSWORD' => $_POST['secret_code'])); if (!$rs) { $success = false; } } if (!$success) { return $this->showResetForm('Something went wrong. Please contact support.'); } return $this->showSuccessTpl(); } public function showSuccessTpl() { print <<