From f43e9e97a53a0ff85e728c477e72ceaa98d3415d Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Fri, 22 Mar 2013 14:50:02 +0400 Subject: add basic password recovery thing --- classes/handler/public.php | 87 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 87 insertions(+) (limited to 'classes/handler/public.php') diff --git a/classes/handler/public.php b/classes/handler/public.php index 6b588f813..53051a1f8 100644 --- a/classes/handler/public.php +++ b/classes/handler/public.php @@ -708,5 +708,92 @@ class Handler_Public extends Handler { print json_encode(array("error" => array("code" => 7))); } + function forgotpass() { + header('Content-Type: text/html; charset=utf-8'); + print " + + Tiny Tiny RSS + + + + + + "; + + print ''; + print "

".__("Reset password")."

"; + + @$method = $_POST['method']; + + if (!$method) { + $secretkey = uniqid(); + $_SESSION["secretkey"] = $secretkey; + + print "
"; + print ""; + print ""; + print ""; + + print "
"; + print ""; + print ""; + print "
"; + + print "
"; + print ""; + print ""; + print "
"; + + print "
"; + print ""; + print ""; + print "
"; + + print "

"; + print ""; + + print "

"; + } else if ($method == 'do') { + + $secretkey = $_POST["secretkey"]; + $login = db_escape_string($this->link, $_POST["login"]); + $email = db_escape_string($this->link, $_POST["email"]); + $test = db_escape_string($this->link, $_POST["test"]); + + if (($test != 4 && $test != 'four') || !$email || !$login) { + print_error(__('Some of the required form parameters are missing or incorrect.')); + + print "

".__("Go back")."

"; + + } else if ($_SESSION["secretkey"] == $secretkey) { + + $result = db_query($this->link, "SELECT id FROM ttrss_users + WHERE login = '$login' AND email = '$email'"); + + if (db_num_rows($result) != 0) { + $id = db_fetch_result($result, 0, "id"); + + Pref_Users::resetUserPassword($this->link, $id, false); + + print "

".__("Completed.")."

"; + + } else { + print_error(__("Sorry, login and email combination not found.")); + print "

".__("Go back")."

"; + } + + } else { + print_error(__("Form secret key incorrect. Please enable cookies and try again.")); + print "

".__("Go back")."

"; + + } + + } + + print ""; + print ""; + + } + } ?> -- cgit v1.2.3