summaryrefslogtreecommitdiff
path: root/classes/pref
diff options
context:
space:
mode:
Diffstat (limited to 'classes/pref')
-rwxr-xr-xclasses/pref/feeds.php2
-rw-r--r--classes/pref/prefs.php61
2 files changed, 62 insertions, 1 deletions
diff --git a/classes/pref/feeds.php b/classes/pref/feeds.php
index c55affd77..f672a0375 100755
--- a/classes/pref/feeds.php
+++ b/classes/pref/feeds.php
@@ -312,7 +312,7 @@ class Pref_Feeds extends Handler_Protected {
array_push($root['items'], $feed);
}
- $root['param'] = vsprintf(_ngettext('(%d feed)', '(%d feeds)', count($cat['items'])), count($cat['items']));
+ $root['param'] = vsprintf(_ngettext('(%d feed)', '(%d feeds)', count($root['items'])), count($root['items']));
}
$fl = array();
diff --git a/classes/pref/prefs.php b/classes/pref/prefs.php
index e7e7a365e..2862a84b2 100644
--- a/classes/pref/prefs.php
+++ b/classes/pref/prefs.php
@@ -122,6 +122,11 @@ class Pref_Prefs extends Handler_Protected {
$new_pw = clean($_POST["new_password"]);
$con_pw = clean($_POST["confirm_password"]);
+ if ($old_pw == $new_pw) {
+ print "ERROR: ".format_error("New password must be different from the old one.");
+ return;
+ }
+
if ($old_pw == "") {
print "ERROR: ".format_error("Old password cannot be blank.");
return;
@@ -194,6 +199,37 @@ class Pref_Prefs extends Handler_Protected {
$full_name = clean($_POST["full_name"]);
$active_uid = $_SESSION["uid"];
+ $sth = $this->pdo->prepare("SELECT email, login, full_name FROM ttrss_users WHERE id = ?");
+ $sth->execute([$active_uid]);
+
+ if ($row = $sth->fetch()) {
+ $old_email = $row["email"];
+
+ if ($old_email != $email) {
+ $mailer = new Mailer();
+
+ require_once "lib/MiniTemplator.class.php";
+
+ $tpl = new MiniTemplator;
+
+ $tpl->readTemplateFromFile("templates/mail_change_template.txt");
+
+ $tpl->setVariable('LOGIN', $row["login"]);
+ $tpl->setVariable('NEWMAIL', $email);
+ $tpl->setVariable('TTRSS_HOST', SELF_URL_PATH);
+
+ $tpl->addBlock('message');
+
+ $tpl->generateOutputToString($message);
+
+ $mailer->mail(["to_name" => $row["login"],
+ "to_address" => $row["email"],
+ "subject" => "[tt-rss] Mail address change notification",
+ "message" => $message]);
+
+ }
+ }
+
$sth = $this->pdo->prepare("UPDATE ttrss_users SET email = ?,
full_name = ? WHERE id = ?");
$sth->execute([$email, $full_name, $active_uid]);
@@ -972,6 +1008,31 @@ class Pref_Prefs extends Handler_Protected {
if ($authenticator->check_password($_SESSION["uid"], $password)) {
+ $sth = $this->pdo->prepare("SELECT email, login FROM ttrss_users WHERE id = ?");
+ $sth->execute([$_SESSION['uid']]);
+
+ if ($row = $sth->fetch()) {
+ $mailer = new Mailer();
+
+ require_once "lib/MiniTemplator.class.php";
+
+ $tpl = new MiniTemplator;
+
+ $tpl->readTemplateFromFile("templates/otp_disabled_template.txt");
+
+ $tpl->setVariable('LOGIN', $row["login"]);
+ $tpl->setVariable('TTRSS_HOST', SELF_URL_PATH);
+
+ $tpl->addBlock('message');
+
+ $tpl->generateOutputToString($message);
+
+ $mailer->mail(["to_name" => $row["login"],
+ "to_address" => $row["email"],
+ "subject" => "[tt-rss] OTP change notification",
+ "message" => $message]);
+ }
+
$sth = $this->pdo->prepare("UPDATE ttrss_users SET otp_enabled = false WHERE
id = ?");
$sth->execute([$_SESSION['uid']]);