+ 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\">
+ <input type=\"hidden\" name=\"op\" value=\"forgotpass\">
+ <input type=\"submit\" value=\"".__("Go back")."\">
+ </form>";
+
+ } else {
+
+ print_notice("Password reset instructions are being sent to your email address.");
+
+ $sth = $this->pdo->prepare("SELECT id FROM ttrss_users
+ WHERE login = ? AND email = ?");
+ $sth->execute([$login, $email]);
+
+ if ($row = $sth->fetch()) {
+ $id = $row["id"];
+
+ if ($id) {
+ $resetpass_token = sha1(get_random_bytes(128));
+ $resetpass_link = get_self_url_prefix() . "/public.php?op=forgotpass&hash=" . $resetpass_token .
+ "&login=" . urlencode($login);
+
+ require_once 'classes/ttrssmailer.php';
+ require_once "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 = time() . ":" . $resetpass_token;
+
+ $sth = $this->pdo->prepare("UPDATE ttrss_users
+ SET resetpass_token = ?
+ WHERE login = ? AND email = ?");
+
+ $sth->execute([$resetpass_token_full, $login, $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\">
+ <input type=\"submit\" value=\"".__("Return to Tiny Tiny RSS")."\">
+ </form>";
+
+ } else {
+ print_error(__("Sorry, login and email combination not found."));
+
+ print "<form method=\"GET\" action=\"public.php\">
+ <input type=\"hidden\" name=\"op\" value=\"forgotpass\">
+ <input type=\"submit\" value=\"".__("Go back")."\">
+ </form>";
+
+ }
+ }