commit - 623bc77304c24a46e1e3ab03463a879b67f6664d
commit + bbe1f7564bdbccc83182f3cc9f3746738d905254
blob - c1a30c4dc620b7b6f913f9ac8e51fe9c6e81af62
blob + 76f006869fd14b0aa27676c93e0dc649bb77c3f0
--- languages/en.lang
+++ languages/en.lang
$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'] = '<span class="error_msg">Your login or password is not correct.</span>';
-$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';
$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';
$LANG['Role_admin_welcome'] = 'Add a new ';
$LANG['Role_admin_warning'] = '<h3>Make sure you remove or protect this file when you are done.</h3>';
-$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'] = <<<EOM
+$LANG['Vacation_welcome'] = 'Auto Response';
+$LANG['Vacation_welcome_text'] = 'Auto response is set.';
+$LANG['Vacation_subject'] = 'Subject';
+$LANG['Vacation_subject_text'] = 'Out of Office';
+$LANG['Vacation_body'] = 'Body';
+$LANG['Vacation_body_text'] = <<<EOM
I will be away from <date> until <date>.
For urgent matters you can contact <contact person>.
EOM;
-$LANG['UsersVacation_button_away'] = 'Going Away';
-$LANG['UsersVacation_button_back'] = 'Coming Back';
-$LANG['UsersVacation_result_error'] = '<span class="error_msg">Unable to update your auto response settings.</span>';
-$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'] = '<span class="error_msg">Unable to update your auto response settings.</span>';
+$LANG['Vacation_result_succes'] = 'Your auto response has been removed.';
$LANG['Logging_alias_add'] = 'add alias';
$LANG['Logging_alias_edit'] = 'edit alias';
blob - cd9aec8316dda5c5ead72be1545f432d1868f007
blob + bbbe62d1b7fb896d078962e739b04b71cf224151
--- login.php
+++ login.php
$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'])) {
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;
}
}
blob - d399e4ea572433b60e81a8ca67036bb642480247
blob + d4739d21eb9e007493abe9ac582564972b9e5688
--- password.php
+++ password.php
$SESSID_USERNAME = check_session();
$ROLE = check_role();
-$SESSID_USERNAME = $SESSID_USERNAME ?? ADMIN_EMAIL;
if ($ROLE == ADMIN_ROLE) {
$list_domains = list_domains();
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);
$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();
blob - 6b88d83083eaf94e26ebe26ad847e0b272f6325a
blob + fc408378d170034225147a7a2c39aea1049c562e
--- templates/login.tpl
+++ templates/login.tpl
<tr>
<td colspan="2" class="standout"><?php echo $message ?? ' '; ?></td>
</tr>
- <tr>
- <td colspan="2"><a href="users/"><?php echo $LANG['Login_login_users']; ?></a></td>
- </tr>
</table>
</form>
</div>
blob - ec8dd143f81858f0155d476f8e9a3aaec8867d46
blob + a2d281dcbf0bc6ce0673835e99ab7b15919ee465
--- templates/menu.tpl
+++ templates/menu.tpl
<div id="menu">
<ul>
- <li><a target="_top" href="list-domain.php"><?php echo $LANG['Menu_list_domain']; ?></a></li>
- <li><a target="_top" href="list-virtual.php"><?php echo $LANG['Menu_list_virtual']; ?></a></li>
-
- <?php if ($ROLE == ADMIN_ROLE) { ?>
- <li><a target="_top" href="list-admin.php"><?php echo $LANG['Menu_list_admin']; ?></a></li>
- <li><a target="_top" href="backup.php"><?php echo $LANG['Menu_backup']; ?></a></li>
- <li><a target="_top" href="domain.php"><?php echo $LANG['Menu_add_domain']; ?></a></li>
- <li><a target="_top" href="admin.php"><?php echo $LANG['Menu_add_admin']; ?></a></li>
+ <?php if (count($list_domains) == 0) { ?>
+ <li><a target="_top" href="password.php"><?php echo $LANG['Menu_user_password']; ?></a></li>
+ <?php if (VACATION == "YES") { ?>
+ <li><a target="_top" href="vacation.php"><?php echo $LANG['Menu_user_vacation']; ?></a></li>
+ <?php } ?>
<?php } else {?>
- <li><a target="_top" href="sendmail.php"><?php echo $LANG['Menu_sendmail']; ?></a></li>
- <li><a target="_top" href="password.php"><?php echo $LANG['Menu_password']; ?></a></li>
+
+ <li><a target="_top" href="list-domain.php"><?php echo $LANG['Menu_list_domain']; ?></a></li>
+ <li><a target="_top" href="list-virtual.php"><?php echo $LANG['Menu_list_virtual']; ?></a></li>
+
+ <?php if ($ROLE == ADMIN_ROLE) { ?>
+ <li><a target="_top" href="list-admin.php"><?php echo $LANG['Menu_list_admin']; ?></a></li>
+ <li><a target="_top" href="backup.php"><?php echo $LANG['Menu_backup']; ?></a></li>
+ <li><a target="_top" href="domain.php"><?php echo $LANG['Menu_add_domain']; ?></a></li>
+ <li><a target="_top" href="admin.php"><?php echo $LANG['Menu_add_admin']; ?></a></li>
+ <?php } else {?>
+ <li><a target="_top" href="sendmail.php"><?php echo $LANG['Menu_sendmail']; ?></a></li>
+ <li><a target="_top" href="password.php"><?php echo $LANG['Menu_password']; ?></a></li>
+ <?php } ?>
+ <li><a target="_top" href="add-alias.php<?php if (isset($domain)) echo '?domain=' . $domain; ?>"><?php echo $LANG['Menu_add_alias']; ?></a></li>
+ <li><a target="_top" href="add-mailbox.php<?php if (isset($domain)) echo '?domain=' . $domain; ?>"><?php echo $LANG['Menu_add_mailbox']; ?></a></li>
+ <li><a target="_top" href="viewlog.php"><?php echo $LANG['Menu_viewlog']; ?></a></li>
<?php } ?>
- <li><a target="_top" href="add-alias.php<?php if (isset($domain)) echo '?domain=' . $domain; ?>"><?php echo $LANG['Menu_add_alias']; ?></a></li>
- <li><a target="_top" href="add-mailbox.php<?php if (isset($domain)) echo '?domain=' . $domain; ?>"><?php echo $LANG['Menu_add_mailbox']; ?></a></li>
- <li><a target="_top" href="viewlog.php"><?php echo $LANG['Menu_viewlog']; ?></a></li>
<li><a target="_top" href="logout.php"><?php echo $LANG['Menu_logout']; ?></a></li>
</ul>
</div>
blob - /dev/null
blob + 972975a6a5cd488fdb5d1d8d51b1dab83fc73c1f (mode 644)
--- /dev/null
+++ templates/vacation.tpl
+<div id="edit_form">
+<form name="vacation" method="post">
+<table>
+ <tr>
+ <td colspan="3"><h3><?php echo $LANG['Vacation_welcome']; ?></h3></td>
+ </tr>
+ <?php if ($action == 'away') { ?>
+ <tr>
+ <td><?php echo $LANG['Vacation_subject'] . ":"; ?></td>
+ <td><input type="text" name="subject" value="<?php echo $LANG['Vacation_subject_text']; ?>" /></td>
+ <td> </td>
+ </tr>
+ <tr>
+ <td><?php echo $LANG['Vacation_body'] . ":"; ?></td>
+ <td>
+<textarea rows="10" cols="80" name="body">
+<?php echo $LANG['Vacation_body_text']; ?>
+</textarea>
+ </td>
+ <td> </td>
+ </tr>
+ <tr>
+ <td colspan="3" class="hlp_center"><input class="button" type="submit" name="away" value="<?php echo $LANG['Vacation_button_away']; ?>" /></td>
+ <?php } else { ?>
+ <td colspan="3" class="hlp_center"><input class="button" type="submit" name="back" value="<?php echo $LANG['Vacation_button_back']; ?>" /></td>
+ <?php } ?>
+ </tr>
+ <tr>
+ <td colspan="3" class="standout"><?php echo $message ?? ' '; ?></td>
+ </tr>
+</table>
+</form>
+</div>
blob - 5bf916e3c907148acf47addf549c59254b231962
blob + 67a1ddaecb18dce35c55dc2a8fc5294b7680c726
--- users/index.php
+++ users/index.php
//
// -none-
//
-// Form POST / GET Variables:
+// POST / GET Variables:
//
// -none-
//
blob - 1aae1fcb58717edd1815064391cc7999c46763b3
blob + 24e0b0365b5411a3415d0fcced83b25847a4945a
--- users/logout.php
+++ users/logout.php
//
// -none-
//
-// Form POST / GET Variables:
+// POST / GET Variables:
//
// -none-
//
blob - 69a34facf2dcad6449b83ca82aab1a3f440a54d2
blob + 87b627ee58519db4df9926f112f499ec5264f982
--- users/password.php
+++ users/password.php
//
// message
//
-// Form POST / GET Variables:
+// POST / GET Variables:
//
// password_current
// password1
blob - 2ca242c85c7b52a02e36c8e1f564b879560473bd
blob + 5d9e5f44a9319bf0fc99edeb0a3441c11895cb96
--- users/vacation.php
+++ users/vacation.php
// tSubject
// tBody
//
-// Form POST / GET Variables:
+// POST / GET Variables:
//
// fSubject
// fBody
blob - /dev/null
blob + 41d9a7de208a84829e71555d585196a3312a5795 (mode 644)
--- /dev/null
+++ vacation.php
+<?php
+//
+// OpenSMTPD Admin
+// by Mischa Peters <mischa at high5 dot nl>
+// 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';
+?>