diff --git a/languages/en.lang b/languages/en.lang
index c1a30c4..76f0068 100644
--- a/languages/en.lang
+++ b/languages/en.lang
@@ -11,12 +11,11 @@ $LANG['confirm'] = 'Are you sure you want to delete this?\n';
$LANG['confirm_domain'] = 'Do you really want to delete all records for this domain?\nThis can not be undone! ';
$LANG['check_update'] = 'Check for update';
-$LANG['Login_welcome'] = 'Mail admins login here to administer your domain';
+$LANG['Login_welcome'] = 'Login to OpenSMTPD Admin';
$LANG['Login_username'] = 'Login (email)';
$LANG['Login_password'] = 'Password';
$LANG['Login_button'] = 'Login';
$LANG['Login_incorrect'] = 'Your login or password is not correct.';
-$LANG['Login_login_users'] = 'Users click here to login to the user section.';
$LANG['Menu_list_domain'] = 'List Domains';
$LANG['Menu_list_virtual'] = 'List Virtuals';
@@ -30,6 +29,8 @@ $LANG['Menu_add_alias'] = 'Add Alias';
$LANG['Menu_add_mailbox'] = 'Add Mailbox';
$LANG['Menu_viewlog'] = 'View Log';
$LANG['Menu_logout'] = 'Logout';
+$LANG['Menu_user_password'] = 'Change Password';
+$LANG['Menu_user_vacation'] = 'Auto Response';
$LANG['List_created'] = 'Created';
$LANG['List_modified'] = 'Last Modified';
@@ -188,30 +189,19 @@ $LANG['AdminEdit_admin_result_succes'] = 'Admin has been modified.';
$LANG['Role_admin_welcome'] = 'Add a new ';
$LANG['Role_admin_warning'] = '
Make sure you remove or protect this file when you are done.
';
-$LANG['UsersLogin_welcome'] = 'Mailbox users login to change your password and aliases';
-$LANG['UsersLogin_username'] = 'Login (email)';
-$LANG['UsersLogin_password'] = 'Password';
-$LANG['UsersLogin_button'] = 'Login';
-$LANG['UsersLogin_username_incorrect'] = 'Your login is not correct. Make sure that you login with your email address.';
-$LANG['UsersLogin_password_incorrect'] = 'Your password is not correct.';
-
-$LANG['UsersMenu_vacation'] = 'Auto Response';
-$LANG['UsersMenu_edit_alias'] = 'Change your forward';
-$LANG['UsersMenu_password'] = 'Change Password';
-
-$LANG['UsersVacation_welcome'] = 'Auto Response';
-$LANG['UsersVacation_welcome_text'] = 'You already have an auto response configured.';
-$LANG['UsersVacation_subject'] = 'Subject';
-$LANG['UsersVacation_subject_text'] = 'Out of Office';
-$LANG['UsersVacation_body'] = 'Body';
-$LANG['UsersVacation_body_text'] = << until .
For urgent matters you can contact .
EOM;
-$LANG['UsersVacation_button_away'] = 'Going Away';
-$LANG['UsersVacation_button_back'] = 'Coming Back';
-$LANG['UsersVacation_result_error'] = 'Unable to update your auto response settings.';
-$LANG['UsersVacation_result_succes'] = 'Your auto response has been removed.';
+$LANG['Vacation_button_away'] = 'Going Away';
+$LANG['Vacation_button_back'] = 'Coming Back';
+$LANG['Vacation_result_error'] = 'Unable to update your auto response settings.';
+$LANG['Vacation_result_succes'] = 'Your auto response has been removed.';
$LANG['Logging_alias_add'] = 'add alias';
$LANG['Logging_alias_edit'] = 'edit alias';
diff --git a/login.php b/login.php
index cd9aec8..bbbe62d 100644
--- a/login.php
+++ b/login.php
@@ -32,6 +32,15 @@ if ($_SERVER['REQUEST_METHOD'] == "POST") {
$sth->bindParam(1, $username, PDO::PARAM_STR);
$sth->execute();
$row = $sth->fetch(PDO::FETCH_ASSOC);
+ if (empty($row)) {
+ $sth = $dbh->prepare("SELECT password FROM mailbox WHERE username=?");
+ $sth->bindParam(1, $username, PDO::PARAM_STR);
+ $sth->execute();
+ $row = $sth->fetch(PDO::FETCH_ASSOC);
+ $location = "password.php";
+ } else {
+ $location = "list-domain.php";
+ }
}
if (!empty($row['password'])) {
@@ -45,8 +54,8 @@ if ($_SERVER['REQUEST_METHOD'] == "POST") {
if (empty($message)) {
session_start();
$_SESSION['sessid']['username'] = $username;
- $_SESSION['sessid']['role'] = $row['role'];
- header("Location: list-domain.php");
+ $_SESSION['sessid']['role'] = $row['role'] ?? '';
+ header("Location: $location");
exit;
}
}
diff --git a/password.php b/password.php
index d399e4e..d4739d2 100644
--- a/password.php
+++ b/password.php
@@ -24,7 +24,6 @@ include './languages/' . check_language() . '.lang';
$SESSID_USERNAME = check_session();
$ROLE = check_role();
-$SESSID_USERNAME = $SESSID_USERNAME ?? ADMIN_EMAIL;
if ($ROLE == ADMIN_ROLE) {
$list_domains = list_domains();
@@ -45,7 +44,11 @@ if ($_SERVER['REQUEST_METHOD'] == "POST") {
if (empty($message) && !empty($password_current)) {
$dbh = pdo_connect();
- $sth = $dbh->prepare("SELECT password FROM admin WHERE username=?");
+ if (count($list_domains) == 0) {
+ $sth = $dbh->prepare("SELECT password FROM mailbox WHERE username=?");
+ } else {
+ $sth = $dbh->prepare("SELECT password FROM admin WHERE username=?");
+ }
$sth->bindParam(1, $username, PDO::PARAM_STR);
$sth->execute();
$row = $sth->fetch(PDO::FETCH_COLUMN);
@@ -58,7 +61,11 @@ if ($_SERVER['REQUEST_METHOD'] == "POST") {
$hashed = bcrypt($password1);
try {
$dbh = pdo_connect();
- $sth = $dbh->prepare("UPDATE admin SET password=?,modified=NOW() WHERE username=?");
+ if (count($list_domains) == 0) {
+ $sth = $dbh->prepare("UPDATE mailbox SET password=?,modified=NOW() WHERE username=?");
+ } else {
+ $sth = $dbh->prepare("UPDATE admin SET password=?,modified=NOW() WHERE username=?");
+ }
$sth->bindParam(1, $hashed, PDO::PARAM_STR);
$sth->bindParam(2, $username, PDO::PARAM_STR);
$sth->execute();
diff --git a/templates/login.tpl b/templates/login.tpl
index 6b88d83..fc40837 100644
--- a/templates/login.tpl
+++ b/templates/login.tpl
@@ -18,9 +18,6 @@
|
-
- |
-
diff --git a/templates/menu.tpl b/templates/menu.tpl
index ec8dd14..a2d281d 100644
--- a/templates/menu.tpl
+++ b/templates/menu.tpl
@@ -1,20 +1,28 @@
diff --git a/templates/vacation.tpl b/templates/vacation.tpl
new file mode 100644
index 0000000..972975a
--- /dev/null
+++ b/templates/vacation.tpl
@@ -0,0 +1,33 @@
+
diff --git a/users/index.php b/users/index.php
index 5bf916e..67a1dda 100644
--- a/users/index.php
+++ b/users/index.php
@@ -13,7 +13,7 @@
//
// -none-
//
-// Form POST / GET Variables:
+// POST / GET Variables:
//
// -none-
//
diff --git a/users/logout.php b/users/logout.php
index 1aae1fc..24e0b03 100644
--- a/users/logout.php
+++ b/users/logout.php
@@ -13,7 +13,7 @@
//
// -none-
//
-// Form POST / GET Variables:
+// POST / GET Variables:
//
// -none-
//
diff --git a/users/password.php b/users/password.php
index 69a34fa..87b627e 100644
--- a/users/password.php
+++ b/users/password.php
@@ -13,7 +13,7 @@
//
// message
//
-// Form POST / GET Variables:
+// POST / GET Variables:
//
// password_current
// password1
diff --git a/users/vacation.php b/users/vacation.php
index 2ca242c..5d9e5f4 100644
--- a/users/vacation.php
+++ b/users/vacation.php
@@ -15,7 +15,7 @@
// tSubject
// tBody
//
-// Form POST / GET Variables:
+// POST / GET Variables:
//
// fSubject
// fBody
diff --git a/vacation.php b/vacation.php
new file mode 100644
index 0000000..41d9a7d
--- /dev/null
+++ b/vacation.php
@@ -0,0 +1,90 @@
+
+// Copyright (c) 2022 High5!
+// License Info: LICENSE.TXT
+//
+// File: vacation.php
+//
+// Template File: users_vacation.tpl
+//
+// Template Variables:
+//
+// tMessage
+// tSubject
+// tBody
+//
+// POST / GET Variables:
+//
+// fSubject
+// fBody
+//
+require_once './functions.inc.php';
+include './languages/' . check_language() . '.lang';
+
+$SESSID_USERNAME = check_session();
+$ROLE = check_role();
+
+if ($ROLE == ADMIN_ROLE) {
+ $list_domains = list_domains();
+ $list_admins = list_admins();
+} else {
+ $list_domains = list_domains($SESSID_USERNAME);
+}
+
+$USERID_DOMAIN = substr(strrchr($SESSID_USERNAME, "@"), 1);
+
+if ($_SERVER['REQUEST_METHOD'] == "GET") {
+ $dbh = pdo_connect();
+ $sth = $dbh->prepare("SELECT COUNT(*) FROM vacation WHERE email=?");
+ $sth->execute(array($SESSID_USERNAME));
+
+ if ($sth->fetchColumn() == 1) {
+ $action = 'back';
+ $message = $LANG['Vacation_welcome_text'];
+ } else {
+ $action = 'away';
+ }
+}
+
+if ($_SERVER['REQUEST_METHOD'] == "POST") {
+ $subject = filter_input(INPUT_POST, 'subject', FILTER_DEFAULT);
+ $body = filter_input(INPUT_POST, 'body', FILTER_DEFAULT);
+
+ if (!empty($_POST['back'])) {
+ $action = 'back';
+ $dbh = pdo_connect();
+ $sth = $dbh->prepare("DELETE FROM vacation WHERE email=?");
+ $sth->bindParam(1, $SESSID_USERNAME, PDO::PARAM_STR);
+ $sth->execute();
+ if ($sth->rowCount() != 1) {
+ $message = $LANG['Vacation_result_error'];
+ } else {
+ $action = 'away';
+ $essage = $LANG['Vacation_result_succes'];
+ }
+ }
+
+ if (!empty($_POST['away'])) {
+ $action = 'away';
+ try {
+ $dbh = pdo_connect();
+ $sth = $dbh->prepare("INSERT INTO vacation (email,subject,body,cache,domain,created) VALUES (?,?,?,'',?,NOW())");
+ $sth->bindParam(1, $SESSID_USERNAME, PDO::PARAM_STR);
+ $sth->bindParam(2, $subject, PDO::PARAM_STR);
+ $sth->bindParam(3, $body, PDO::PARAM_STR);
+ $sth->bindParam(4, $USERID_DOMAIN, PDO::PARAM_STR);
+ $sth->execute();
+ header("Location: vacation.php");
+ } catch(PDOException $e) {
+ $message = $LANG['Vacation_result_error'] . " " . $e->getMessage();
+ }
+ }
+
+}
+include './templates/header.tpl';
+include './templates/menu.tpl';
+include './templates/vacation.tpl';
+include './templates/footer.tpl';
+?>