function forgotpass() { startup_gettext(); header('Content-Type: text/html; charset=utf-8'); print "<html><head><title>Tiny Tiny RSS</title>"; stylesheet_tag("css/utility.css"); javascript_tag("lib/prototype.js"); print "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\"/>\n\t\t\t</head><body id='forgotpass'>"; print '<div class="floatingLogo"><img src="images/logo_small.png"></div>'; print "<h1>" . __("Password recovery") . "</h1>"; print "<div class='content'>"; @($method = $_POST['method']); if (!$method) { print_notice(__("You will need to provide valid account name and email. New password will be sent on your email address.")); print "<form method='POST' action='public.php'>"; print "<input type='hidden' name='method' value='do'>"; print "<input type='hidden' name='op' value='forgotpass'>"; print "<fieldset>"; print "<label>" . __("Login:"******"</label>"; print "<input type='text' name='login' value='' required>"; print "</fieldset>"; print "<fieldset>"; print "<label>" . __("Email:") . "</label>"; print "<input type='email' name='email' value='' required>"; print "</fieldset>"; print "<fieldset>"; print "<label>" . __("How much is two plus two:") . "</label>"; print "<input type='text' name='test' value='' required>"; print "</fieldset>"; print "<p/>"; print "<button type='submit'>" . __("Reset password") . "</button>"; print "</form>"; } else { if ($method == 'do') { $login = $this->dbh->escape_string($_POST["login"]); $email = $this->dbh->escape_string($_POST["email"]); $test = $this->dbh->escape_string($_POST["test"]); if ($test != 4 && $test != 'four' || !$email || !$login) { print_error(__('Some of the required form parameters are missing or incorrect.')); print "<form method=\"GET\" action=\"public.php\">\n\t\t\t\t\t<input type=\"hidden\" name=\"op\" value=\"forgotpass\">\n\t\t\t\t\t<input type=\"submit\" value=\"" . __("Go back") . "\">\n\t\t\t\t\t</form>"; } else { $result = $this->dbh->query("SELECT id FROM ttrss_users\n\t\t\t\t\tWHERE login = '******' AND email = '{$email}'"); if ($this->dbh->num_rows($result) != 0) { $id = $this->dbh->fetch_result($result, 0, "id"); Pref_Users::resetUserPassword($id, false); print "<p>"; print "<p>" . "Completed." . "</p>"; print "<form method=\"GET\" action=\"index.php\">\n\t\t\t\t\t\t<input type=\"submit\" value=\"" . __("Return to Tiny Tiny RSS") . "\">\n\t\t\t\t\t\t</form>"; } else { print_error(__("Sorry, login and email combination not found.")); print "<form method=\"GET\" action=\"public.php\">\n\t\t\t\t\t\t<input type=\"hidden\" name=\"op\" value=\"forgotpass\">\n\t\t\t\t\t\t<input type=\"submit\" value=\"" . __("Go back") . "\">\n\t\t\t\t\t\t</form>"; } } } } print "</div>"; print "</body>"; print "</html>"; }
function resetPass() { $uid = $this->dbh->escape_string($_REQUEST["id"]); Pref_Users::resetUserPassword($uid, true); }
function forgotpass() { startup_gettext(); @($hash = $_REQUEST["hash"]); header('Content-Type: text/html; charset=utf-8'); print "<html><head><title>Tiny Tiny RSS</title>\n\t\t<link rel=\"shortcut icon\" type=\"image/png\" href=\"images/favicon.png\">\n\t\t<link rel=\"icon\" type=\"image/png\" sizes=\"72x72\" href=\"images/favicon-72px.png\">"; echo stylesheet_tag("css/utility.css"); echo javascript_tag("lib/prototype.js"); print "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\"/>\n\t\t\t</head><body id='forgotpass'>"; print '<div class="floatingLogo"><img src="images/logo_small.png"></div>'; print "<h1>" . __("Password recovery") . "</h1>"; print "<div class='content'>"; @($method = $_POST['method']); if ($hash) { $login = $_REQUEST["login"]; if ($login) { $result = $this->dbh->query("SELECT id, resetpass_token FROM ttrss_users\n\t\t\t\t\tWHERE login = '******'"); if ($this->dbh->num_rows($result) != 0) { $id = $this->dbh->fetch_result($result, 0, "id"); $resetpass_token_full = $this->dbh->fetch_result($result, 0, "resetpass_token"); list($timestamp, $resetpass_token) = explode(":", $resetpass_token_full); if ($timestamp && $resetpass_token && $timestamp >= time() - 15 * 60 * 60 && $resetpass_token == $hash) { $result = $this->dbh->query("UPDATE ttrss_users SET resetpass_token = NULL\n\t\t\t\t\t\t\t\tWHERE id = {$id}"); Pref_Users::resetUserPassword($id, true); print "<p>" . "Completed." . "</p>"; } else { print_error("Some of the information provided is missing or incorrect."); } } else { print_error("Some of the information provided is missing or incorrect."); } } else { print_error("Some of the information provided is missing or incorrect."); } print "<form method=\"GET\" action=\"index.php\">\n\t\t\t\t<input type=\"submit\" value=\"" . __("Return to Tiny Tiny RSS") . "\">\n\t\t\t\t</form>"; } else { if (!$method) { print_notice(__("You will need to provide valid account name and email. A password reset link will be sent to your email address.")); print "<form method='POST' action='public.php'>"; print "<input type='hidden' name='method' value='do'>"; print "<input type='hidden' name='op' value='forgotpass'>"; print "<fieldset>"; print "<label>" . __("Login:"******"</label>"; print "<input type='text' name='login' value='' required>"; print "</fieldset>"; print "<fieldset>"; print "<label>" . __("Email:") . "</label>"; print "<input type='email' name='email' value='' required>"; print "</fieldset>"; print "<fieldset>"; print "<label>" . __("How much is two plus two:") . "</label>"; print "<input type='text' name='test' value='' required>"; print "</fieldset>"; print "<p/>"; print "<button type='submit'>" . __("Reset password") . "</button>"; print "</form>"; } else { if ($method == 'do') { $login = $this->dbh->escape_string($_POST["login"]); $email = $this->dbh->escape_string($_POST["email"]); $test = $this->dbh->escape_string($_POST["test"]); if ($test != 4 && $test != 'four' || !$email || !$login) { print_error(__('Some of the required form parameters are missing or incorrect.')); print "<form method=\"GET\" action=\"public.php\">\n\t\t\t\t\t<input type=\"hidden\" name=\"op\" value=\"forgotpass\">\n\t\t\t\t\t<input type=\"submit\" value=\"" . __("Go back") . "\">\n\t\t\t\t\t</form>"; } else { print_notice("Password reset instructions are being sent to your email address."); $result = $this->dbh->query("SELECT id FROM ttrss_users\n\t\t\t\t\tWHERE login = '******' AND email = '{$email}'"); if ($this->dbh->num_rows($result) != 0) { $id = $this->dbh->fetch_result($result, 0, "id"); if ($id) { $resetpass_token = sha1(get_random_bytes(128)); $resetpass_link = get_self_url_prefix() . "/public.php?op=forgotpass&hash=" . $resetpass_token . "&login="******"lib/MiniTemplator.class.php"; $tpl = new MiniTemplator(); $tpl->readTemplateFromFile("templates/resetpass_link_template.txt"); $tpl->setVariable('LOGIN', $login); $tpl->setVariable('RESETPASS_LINK', $resetpass_link); $tpl->addBlock('message'); $message = ""; $tpl->generateOutputToString($message); $mail = new ttrssMailer(); $rc = $mail->quickMail($email, $login, __("[tt-rss] Password reset request"), $message, false); if (!$rc) { print_error($mail->ErrorInfo); } $resetpass_token_full = $this->dbh->escape_string(time() . ":" . $resetpass_token); $result = $this->dbh->query("UPDATE ttrss_users\n\t\t\t\t\t\t\tSET resetpass_token = '{$resetpass_token_full}'\n\t\t\t\t\t\t\tWHERE login = '******' AND email = '{$email}'"); //Pref_Users::resetUserPassword($id, false); print "<p>"; print "<p>" . "Completed." . "</p>"; } else { print_error("User ID not found."); } print "<form method=\"GET\" action=\"index.php\">\n\t\t\t\t\t\t<input type=\"submit\" value=\"" . __("Return to Tiny Tiny RSS") . "\">\n\t\t\t\t\t\t</form>"; } else { print_error(__("Sorry, login and email combination not found.")); print "<form method=\"GET\" action=\"public.php\">\n\t\t\t\t\t\t<input type=\"hidden\" name=\"op\" value=\"forgotpass\">\n\t\t\t\t\t\t<input type=\"submit\" value=\"" . __("Go back") . "\">\n\t\t\t\t\t\t</form>"; } } } } } print "</div>"; print "</body>"; print "</html>"; }