extra domain checks

This commit is contained in:
mischa 2022-09-04 14:04:56 +00:00
parent 91a50b5119
commit 826796d161
17 changed files with 185 additions and 81 deletions

View File

@ -32,6 +32,7 @@ $admin = $SESSID_USERNAME ?? ADMIN_EMAIL;
if ($_SERVER['REQUEST_METHOD'] == "GET") {
$domain = filter_input(INPUT_GET, 'domain', FILTER_VALIDATE_DOMAIN);
$domain_key = array_search($domain, array_column($list_domains, 'domain'));
$domain_exist = in_array($domain, array_column($list_domains, 'domain'));
}
if ($_SERVER['REQUEST_METHOD'] == "POST") {
@ -39,6 +40,7 @@ if ($_SERVER['REQUEST_METHOD'] == "POST") {
$domain = filter_input(INPUT_POST, 'domain', FILTER_VALIDATE_DOMAIN);
$goto = strtolower(filter_input(INPUT_POST, 'goto', FILTER_DEFAULT));
$domain_key = array_search($domain, array_column($list_domains, 'domain'));
$domain_exist = in_array($domain, array_column($list_domains, 'domain'));
$from = filter_var($address . '@' . $domain, FILTER_VALIDATE_EMAIL);
if (!str_contains($goto, '@')) {
@ -54,7 +56,7 @@ if ($_SERVER['REQUEST_METHOD'] == "POST") {
$message = $LANG['Create_alias_address_text_error1'];
}
if (empty($message) && isset($domain_key)) {
if ($domain_exist && empty($message)) {
try {
$dbh = connect_db();
$sth = $dbh->prepare("INSERT INTO alias (address,goto,domain,created,modified) VALUES (?,?,?,NOW(),NOW())");

View File

@ -34,6 +34,7 @@ $admin = $SESSID_USERNAME ?? ADMIN_EMAIL;
if ($_SERVER['REQUEST_METHOD'] == "GET") {
$domain = filter_input(INPUT_GET, 'domain', FILTER_VALIDATE_DOMAIN);
$domain_key = array_search($domain, array_column($list_domains, 'domain'));
$domain_exist = in_array($domain, array_column($list_domains, 'domain'));
}
if ($_SERVER['REQUEST_METHOD'] == "POST") {
@ -42,9 +43,8 @@ if ($_SERVER['REQUEST_METHOD'] == "POST") {
$password1 = filter_input(INPUT_POST, 'password1', FILTER_DEFAULT);
$password2 = filter_input(INPUT_POST, 'password2', FILTER_DEFAULT);
$name = filter_input(INPUT_POST, 'name', FILTER_DEFAULT);
$domain_key = array_search($domain, array_column($list_domains, 'domain'));
$domain_exist = in_array($domain, array_column($list_domains, 'domain'));
$from = filter_var($username . '@' . $domain, FILTER_VALIDATE_EMAIL);
if ($list_domains[$domain_key]['mailboxes'] != 0 && $list_domains[$domain_key]['mailbox_count'] >= $list_domains[$domain_key]['mailboxes']) {
@ -59,7 +59,7 @@ if ($_SERVER['REQUEST_METHOD'] == "POST") {
$message = $LANG['Create_mailbox_password_text_error'];
}
if (empty($message) && isset($domain_key)) {
if ($domain_exist && empty($message)) {
$hashed = bcrypt($password1);
$maildir = $from . "/";

View File

@ -31,6 +31,7 @@ $admin = $SESSID_USERNAME ?? ADMIN_EMAIL;
if ($_SERVER['REQUEST_METHOD'] == "GET") {
$domain = filter_input(INPUT_GET, 'domain', FILTER_VALIDATE_DOMAIN);
$domain_key = array_search($domain, array_column($list_domains, 'domain'));
$domain_exist = in_array($domain, array_column($list_domains, 'domain'));
}
if ($_SERVER['REQUEST_METHOD'] == "POST") {
@ -38,6 +39,7 @@ if ($_SERVER['REQUEST_METHOD'] == "POST") {
$domain = filter_input(INPUT_POST, 'domain', FILTER_VALIDATE_DOMAIN);
$goto = strtolower(filter_input(INPUT_POST, 'goto', FILTER_DEFAULT));
$domain_key = array_search($domain, array_column($list_domains, 'domain'));
$domain_exist = in_array($domain, array_column($list_domains, 'domain'));
$from = filter_var($address . '@' . $domain, FILTER_VALIDATE_EMAIL);
if (!str_contains($goto, '@')) {
@ -53,7 +55,7 @@ if ($_SERVER['REQUEST_METHOD'] == "POST") {
$message = $LANG['Create_alias_address_text_error1'];
}
if (empty($message) && isset($domain_key)) {
if ($domain_exist && empty($message)) {
try {
$dbh = connect_db();
$sth = $dbh->prepare("INSERT INTO alias (address,goto,domain,created,modified) VALUES (?,?,?,NOW(),NOW())");

View File

@ -33,6 +33,7 @@ $admin = $SESSID_USERNAME ?? ADMIN_EMAIL;
if ($_SERVER['REQUEST_METHOD'] == "GET") {
$domain = filter_input(INPUT_GET, 'domain', FILTER_VALIDATE_DOMAIN);
$domain_key = array_search($domain, array_column($list_domains, 'domain'));
$domain_exist = in_array($domain, array_column($list_domains, 'domain'));
}
if ($_SERVER['REQUEST_METHOD'] == "POST") {
@ -41,9 +42,8 @@ if ($_SERVER['REQUEST_METHOD'] == "POST") {
$password1 = filter_input(INPUT_POST, 'password1', FILTER_DEFAULT);
$password2 = filter_input(INPUT_POST, 'password2', FILTER_DEFAULT);
$name = filter_input(INPUT_POST, 'name', FILTER_DEFAULT);
$domain_key = array_search($domain, array_column($list_domains, 'domain'));
$domain_exist = in_array($domain, array_column($list_domains, 'domain'));
$from = filter_var($username . '@' . $domain, FILTER_VALIDATE_EMAIL);
if ($list_domains[$domain_key]['mailboxes'] != 0 && $list_domains[$domain_key]['mailbox_count'] >= $list_domains[$domain_key]['mailboxes']) {
@ -58,7 +58,7 @@ if ($_SERVER['REQUEST_METHOD'] == "POST") {
$message = $LANG['Create_mailbox_password_text_error'];
}
if (empty($message) && isset($domain_key)) {
if ($domain_exist && empty($message)) {
$hashed = bcrypt($password1);
$maildir = $from . "/";

View File

@ -27,12 +27,13 @@ $list_domains = list_domains();
$admin = $SESSID_USERNAME ?? ADMIN_EMAIL;
if ($_SERVER['REQUEST_METHOD'] == "GET") {
$table = strtolower(filter_input(INPUT_GET, 'table', FILTER_DEFAULT));
$table = filter_input(INPUT_GET, 'table', FILTER_DEFAULT);
$delete = filter_input(INPUT_GET, 'delete', FILTER_DEFAULT);
$domain = filter_input(INPUT_GET, 'domain', FILTER_VALIDATE_DOMAIN);
$domain_key = array_search($domain, array_column($list_domains, 'domain'));
$domain_exist = in_array($domain, array_column($list_domains, 'domain'));
if ($table == "domain") {
if ($domain_exist && $table == "domain") {
try {
$dbh = connect_db();
$dbh->beginTransaction();
@ -99,7 +100,6 @@ if ($_SERVER['REQUEST_METHOD'] == "GET") {
$dbh->commit();
header("Location: list-domain.php");
exit;
} catch (RuntimeException $e) {
$message = $e->getMessage();
$dbh->rollBack();
@ -135,7 +135,6 @@ if ($_SERVER['REQUEST_METHOD'] == "GET") {
$dbh->commit();
header("Location: list-admin.php");
exit;
} catch (RuntimeException $e) {
$message = $e->getMessage();
$dbh->rollBack();
@ -145,7 +144,7 @@ if ($_SERVER['REQUEST_METHOD'] == "GET") {
}
}
if (($table == 'alias' || $table == 'mailbox') && in_array($domain, array_column($list_domains, 'domain'))) {
if ($domain_exist && ($table == 'alias' || $table == 'mailbox')) {
try {
$dbh = connect_db();
$sth = $dbh->prepare("DELETE FROM alias WHERE address=? AND domain=?");
@ -158,7 +157,6 @@ if ($_SERVER['REQUEST_METHOD'] == "GET") {
logging($admin, $domain, "delete alias", $delete);
header("Location: list-virtual.php?domain=$domain");
exit;
} catch (RuntimeException $e) {
$message = $LANG['Delete_delete_error'] . "<b>$delete</b> (" . $e->getMessage() . ")!</span>";
} catch (PDOException $e) {
@ -180,9 +178,7 @@ if ($_SERVER['REQUEST_METHOD'] == "GET") {
$sth->bindParam(1, $delete, PDO::PARAM_STR);
$sth->bindParam(2, $domain, PDO::PARAM_STR);
$sth->execute();
header("Location: list-virtual.php?domain=$domain");
exit;
} catch (RuntimeException $e) {
$message = $LANG['Delete_delete_error'] . "<b>$delete</b> (" . $e->getMessage() . ")!</span>";
} catch (PDOException $e) {

View File

@ -30,17 +30,20 @@ if ($_SERVER['REQUEST_METHOD'] == "GET") {
$address = filter_input(INPUT_GET, 'address', FILTER_VALIDATE_EMAIL);
$domain = filter_input(INPUT_GET, 'domain', FILTER_VALIDATE_DOMAIN);
$domain_key = array_search($domain, array_column($list_domains, 'domain'));
$domain_exist = in_array($domain, array_column($list_domains, 'domain'));
try {
$dbh = connect_db();
$sth = $dbh->prepare("SELECT goto FROM alias WHERE address=? AND domain=?");
$sth->bindParam(1, $address, PDO::PARAM_STR);
$sth->bindParam(2, $domain, PDO::PARAM_STR);
$sth->execute();
$goto = $sth->fetch(PDO::FETCH_COLUMN);
$goto = explode(',', $goto);
} catch(PDOException $e) {
$message = $LANG['Edit_alias_address_error'];
if ($domain_exist) {
try {
$dbh = connect_db();
$sth = $dbh->prepare("SELECT goto FROM alias WHERE address=? AND domain=?");
$sth->bindParam(1, $address, PDO::PARAM_STR);
$sth->bindParam(2, $domain, PDO::PARAM_STR);
$sth->execute();
$goto = $sth->fetch(PDO::FETCH_COLUMN);
$goto = explode(',', $goto);
} catch(PDOException $e) {
$message = $LANG['Edit_alias_address_error'];
}
}
}
@ -49,6 +52,7 @@ if ($_SERVER['REQUEST_METHOD'] == "POST") {
$domain = strtolower(filter_input(INPUT_GET, 'domain', FILTER_VALIDATE_DOMAIN));
$goto = strtolower(filter_input(INPUT_POST, 'goto', FILTER_DEFAULT));
$domain_key = array_search($domain, array_column($list_domains, 'domain'));
$domain_exist = in_array($domain, array_column($list_domains, 'domain'));
if (empty($goto)) {
$goto = array();
@ -67,7 +71,7 @@ if ($_SERVER['REQUEST_METHOD'] == "POST") {
}
}
if (empty($message) && isset($domain_key)) {
if ($domain_exist && empty($message)) {
try {
$dbh = connect_db();
$sth = $dbh->prepare("UPDATE alias SET goto=?,modified=NOW() WHERE address=? AND domain=?");

View File

@ -31,17 +31,21 @@ $admin = $SESSID_USERNAME ?? ADMIN_EMAIL;
if ($_SERVER['REQUEST_METHOD'] == "GET") {
$username = strtolower(filter_input(INPUT_GET, 'username', FILTER_DEFAULT));
$domain = filter_input(INPUT_GET, 'domain', FILTER_VALIDATE_DOMAIN);
$domain_key = array_search($domain, array_column($list_domains, 'domain'));
$domain_exist = in_array($domain, array_column($list_domains, 'domain'));
try {
$dbh = connect_db();
$sth = $dbh->prepare("SELECT * FROM mailbox WHERE username=? AND domain=?");
$sth->bindParam(1, $username, PDO::PARAM_STR);
$sth->bindParam(2, $domain, PDO::PARAM_STR);
$sth->execute();
$mailbox_details = $sth->fetch();
$name = $mailbox_details['name'];
} catch(PDOException $e) {
$message = $LANG['Edit_mailbox_login_error'];
if ($domain_exist) {
try {
$dbh = connect_db();
$sth = $dbh->prepare("SELECT * FROM mailbox WHERE username=? AND domain=?");
$sth->bindParam(1, $username, PDO::PARAM_STR);
$sth->bindParam(2, $domain, PDO::PARAM_STR);
$sth->execute();
$mailbox_details = $sth->fetch();
$name = $mailbox_details['name'];
} catch(PDOException $e) {
$message = $LANG['Edit_mailbox_login_error'];
}
}
}
@ -51,6 +55,8 @@ if ($_SERVER['REQUEST_METHOD'] == "POST") {
$password1 = filter_input(INPUT_POST, 'password1', FILTER_DEFAULT);
$password2 = filter_input(INPUT_POST, 'password2', FILTER_DEFAULT);
$name = filter_input(INPUT_POST, 'name', FILTER_DEFAULT);
$domain_key = array_search($domain, array_column($list_domains, 'domain'));
$domain_exist = in_array($domain, array_column($list_domains, 'domain'));
if ($password1 != $password2) {
$message = $LANG['Edit_mailbox_password_text_error'];
@ -71,7 +77,7 @@ if ($_SERVER['REQUEST_METHOD'] == "POST") {
}
}
if (empty($message) && isset($domain_key)) {
if ($domain_exist && empty($message)) {
try {
$dbh = connect_db();
$sth = $dbh->prepare("UPDATE mailbox SET name=?,modified=NOW() WHERE username=? AND domain=?");

View File

@ -25,11 +25,15 @@ $list_domains = list_domains();
if ($_SERVER['REQUEST_METHOD'] == "GET") {
$domain = filter_input(INPUT_GET, 'domain', FILTER_VALIDATE_DOMAIN) ?? $list_domains[0]['domain'];
$domain_key = array_search($domain, array_column($list_domains, 'domain'));
$dbh = connect_db();
$sth = $dbh->prepare("SELECT * FROM log WHERE domain=? ORDER BY timestamp DESC LIMIT 10");
$sth->bindParam(1, $domain, PDO::PARAM_STR);
$sth->execute();
$log = $sth->fetchAll();
$domain_exist = in_array($domain, array_column($list_domains, 'domain'));
if ($domain_exist) {
$dbh = connect_db();
$sth = $dbh->prepare("SELECT * FROM log WHERE domain=? ORDER BY timestamp DESC LIMIT 10");
$sth->bindParam(1, $domain, PDO::PARAM_STR);
$sth->execute();
$log = $sth->fetchAll();
}
}
include '../templates/header.tpl';

View File

@ -28,12 +28,13 @@ $list_domains = list_domains($SESSID_USERNAME);
$admin = $SESSID_USERNAME ?? ADMIN_EMAIL;
if ($_SERVER['REQUEST_METHOD'] == "GET") {
$table = strtolower(filter_input(INPUT_GET, 'table', FILTER_DEFAULT));
$table = filter_input(INPUT_GET, 'table', FILTER_DEFAULT);
$delete = filter_input(INPUT_GET, 'delete', FILTER_DEFAULT);
$domain = filter_input(INPUT_GET, 'domain', FILTER_VALIDATE_DOMAIN);
$domain_key = array_search($domain, array_column($list_domains, 'domain'));
$domain_exist = in_array($domain, array_column($list_domains, 'domain'));
if (($table == 'alias' || $table == 'mailbox') && in_array($domain, array_column($list_domains, 'domain'))) {
if ($domain_exist && ($table == 'alias' || $table == 'mailbox')) {
try {
$dbh = connect_db();
$sth = $dbh->prepare("DELETE FROM alias WHERE address=? AND domain=?");
@ -46,7 +47,6 @@ if ($_SERVER['REQUEST_METHOD'] == "GET") {
logging($admin, $domain, "delete alias", $delete);
header("Location: list-virtual.php?domain=$domain");
exit;
} catch (RuntimeException $e) {
$message = $LANG['Delete_delete_error'] . "<b>$delete</b> (" . $e->getMessage() . ")!</span>";
} catch (PDOException $e) {
@ -55,6 +55,11 @@ if ($_SERVER['REQUEST_METHOD'] == "GET") {
try {
$dbh = connect_db();
$sth = $dbh->prepare("DELETE FROM mailbox WHERE username=? AND domain=?");
$sth->bindParam(1, $delete, PDO::PARAM_STR);
$sth->bindParam(2, $domain, PDO::PARAM_STR);
$sth = $dbh->prepare("DELETE FROM mailbox WHERE username=? AND domain=?");
$sth->bindParam(1, $delete, PDO::PARAM_STR);
$sth->bindParam(2, $domain, PDO::PARAM_STR);
@ -70,7 +75,6 @@ if ($_SERVER['REQUEST_METHOD'] == "GET") {
$sth->execute();
header("Location: list-virtual.php?domain=$domain");
exit;
} catch (RuntimeException $e) {
$message = $LANG['Delete_delete_error'] . "<b>$delete</b> (" . $e->getMessage() . ")!</span>";
} catch (PDOException $e) {

View File

@ -31,17 +31,20 @@ if ($_SERVER['REQUEST_METHOD'] == "GET") {
$address = filter_input(INPUT_GET, 'address', FILTER_VALIDATE_EMAIL);
$domain = filter_input(INPUT_GET, 'domain', FILTER_VALIDATE_DOMAIN);
$domain_key = array_search($domain, array_column($list_domains, 'domain'));
$domain_exist = in_array($domain, array_column($list_domains, 'domain'));
try {
$dbh = connect_db();
$sth = $dbh->prepare("SELECT goto FROM alias WHERE address=? AND domain=?");
$sth->bindParam(1, $address, PDO::PARAM_STR);
$sth->bindParam(2, $domain, PDO::PARAM_STR);
$sth->execute();
$goto = $sth->fetch(PDO::FETCH_COLUMN);
$goto = explode(',', $goto);
} catch(PDOException $e) {
$message = $LANG['Edit_alias_address_error'];
if ($domain_exist) {
try {
$dbh = connect_db();
$sth = $dbh->prepare("SELECT goto FROM alias WHERE address=? AND domain=?");
$sth->bindParam(1, $address, PDO::PARAM_STR);
$sth->bindParam(2, $domain, PDO::PARAM_STR);
$sth->execute();
$goto = $sth->fetch(PDO::FETCH_COLUMN);
$goto = explode(',', $goto);
} catch(PDOException $e) {
$message = $LANG['Edit_alias_address_error'];
}
}
}
@ -50,6 +53,7 @@ if ($_SERVER['REQUEST_METHOD'] == "POST") {
$domain = strtolower(filter_input(INPUT_GET, 'domain', FILTER_VALIDATE_DOMAIN));
$goto = strtolower(filter_input(INPUT_POST, 'goto', FILTER_DEFAULT));
$domain_key = array_search($domain, array_column($list_domains, 'domain'));
$domain_exist = in_array($domain, array_column($list_domains, 'domain'));
if (empty($goto)) {
$goto = array();
@ -68,7 +72,7 @@ if ($_SERVER['REQUEST_METHOD'] == "POST") {
}
}
if (empty($message) && isset($domain_key)) {
if ($domain_exist && empty($message)) {
try {
$dbh = connect_db();
$sth = $dbh->prepare("UPDATE alias SET goto=?,modified=NOW() WHERE address=? AND domain=?");
@ -84,7 +88,7 @@ if ($_SERVER['REQUEST_METHOD'] == "POST") {
}
}
include './templates/header.tpl';
include './templates/menu.tpl';
include './templates/admin_menu.tpl';
include './templates/edit-alias.tpl';
include './templates/footer.tpl';
?>

View File

@ -32,17 +32,21 @@ $admin = $SESSID_USERNAME ?? ADMIN_EMAIL;
if ($_SERVER['REQUEST_METHOD'] == "GET") {
$username = strtolower(filter_input(INPUT_GET, 'username', FILTER_DEFAULT));
$domain = filter_input(INPUT_GET, 'domain', FILTER_VALIDATE_DOMAIN);
$domain_key = array_search($domain, array_column($list_domains, 'domain'));
$domain_exist = in_array($domain, array_column($list_domains, 'domain'));
try {
$dbh = connect_db();
$sth = $dbh->prepare("SELECT * FROM mailbox WHERE username=? AND domain=?");
$sth->bindParam(1, $username, PDO::PARAM_STR);
$sth->bindParam(2, $domain, PDO::PARAM_STR);
$sth->execute();
$mailbox_details = $sth->fetch();
$name = $mailbox_details['name'];
} catch(PDOException $e) {
$message = $LANG['Edit_mailbox_login_error'];
if ($domain_exist) {
try {
$dbh = connect_db();
$sth = $dbh->prepare("SELECT * FROM mailbox WHERE username=? AND domain=?");
$sth->bindParam(1, $username, PDO::PARAM_STR);
$sth->bindParam(2, $domain, PDO::PARAM_STR);
$sth->execute();
$mailbox_details = $sth->fetch();
$name = $mailbox_details['name'];
} catch(PDOException $e) {
$message = $LANG['Edit_mailbox_login_error'];
}
}
}
@ -52,6 +56,8 @@ if ($_SERVER['REQUEST_METHOD'] == "POST") {
$password1 = filter_input(INPUT_POST, 'password1', FILTER_DEFAULT);
$password2 = filter_input(INPUT_POST, 'password2', FILTER_DEFAULT);
$name = filter_input(INPUT_POST, 'name', FILTER_DEFAULT);
$domain_key = array_search($domain, array_column($list_domains, 'domain'));
$domain_exist = in_array($domain, array_column($list_domains, 'domain'));
if ($password1 != $password2) {
$message = $LANG['Edit_mailbox_password_text_error'];
@ -72,7 +78,7 @@ if ($_SERVER['REQUEST_METHOD'] == "POST") {
}
}
if (empty($message) && isset($domain_key)) {
if ($domain_exist && empty($message)) {
try {
$dbh = connect_db();
$sth = $dbh->prepare("UPDATE mailbox SET name=?,modified=NOW() WHERE username=? AND domain=?");
@ -88,7 +94,7 @@ if ($_SERVER['REQUEST_METHOD'] == "POST") {
}
}
include './templates/header.tpl';
include './templates/menu.tpl';
include './templates/admin_menu.tpl';
include './templates/edit-mailbox.tpl';
include './templates/footer.tpl';
?>

30
list-domain.php Normal file
View File

@ -0,0 +1,30 @@
<?php
//
// OpenSMTPD Admin
// by Mischa Peters <mischa at high5 dot nl>
// Copyright (c) 2022 High5!
// License Info: LICENSE.TXT
//
// File: list-domains.php
//
// Template File: list-domains.tpl
//
// Template variables:
//
// list_domains
//
// GET / POST variables:
//
// -none-
//
require_once './functions.inc.php';
include './languages/' . check_language() . '.lang';
$SESSID_USERNAME = check_session();
$list_domains = list_domains($SESSID_USERNAME);
include './templates/header.tpl';
include './templates/menu.tpl';
include './templates/list-domain.tpl';
include './templates/footer.tpl';
?>

43
list-virtual.php Normal file
View File

@ -0,0 +1,43 @@
<?php
//
// OpenSMTPD Admin
// by Mischa Peters <mischa at high5 dot nl>
// Copyright (c) 2022 High5!
// License Info: LICENSE.TXT
//
// File: list-virtual.php
//
// Template File: list-virtual.tpl
//
// Template Variables:
//
// list_alias
// list_mailbox
//
// Form POST \ GET Variables:
//
// domain
// offset
//
require_once './functions.inc.php';
include './languages/' . check_language() . '.lang';
$SESSID_USERNAME = check_session();
$list_domains = list_domains($SESSID_USERNAME);
if ($_SERVER['REQUEST_METHOD'] == "GET") {
$offset = filter_input(INPUT_GET, 'offset', FILTER_VALIDATE_INT) ?? '0';
$limit = PAGE_SIZE;
$domain = filter_input(INPUT_GET, 'domain', FILTER_VALIDATE_DOMAIN);
if (in_array($domain, array_column($list_domains, 'domain'))) {
$domain_key = array_search($domain, array_column($list_domains, 'domain'));
$list_alias = list_aliases($domain, $offset, $limit);
$list_mailbox = list_mailboxes($domain, $offset, $limit);
}
}
include './templates/header.tpl';
include './templates/menu.tpl';
include './templates/list-virtual.tpl';
include './templates/footer.tpl';
?>

View File

@ -1,7 +1,7 @@
<div id="main_menu">
<table>
<tr>
<td nowrap><a target="_top" href="list-domains.php"><?php echo $LANG['Menu_overview']; ?></a></td>
<td nowrap><a target="_top" href="list-domain.php"><?php echo $LANG['Menu_overview']; ?></a></td>
<td><?php echo $LANG['Main_overview']; ?></td>
</tr>
<tr>

View File

@ -24,7 +24,7 @@ if (count($tAlias) > 0) {
echo " <td>" . preg_replace("/,/", "<br>", $tAlias[$i]['goto']) . "</td>\n";
echo " <td>" . $tAlias[$i]['modified'] . "</td>\n";
echo " <td><a href=\"edit-alias.php?address=" . $tAlias[$i]['address'] . "&domain=" . $tAlias[$i]['domain'] . "\">" . $LANG['edit'] . "</a></td>\n";
echo " <td><a href=\"delete.php?delete=" . $tAlias[$i]['address'] . "&domain=" . $tAlias[$i]['domain'] . "\"onclick=\"return confirm ('" . $LANG['confirm'] . $LANG['Overview_get_aliases'] . ": ". $tAlias[$i]['address'] . "')\">" . $LANG['del'] . "</a></td>\n";
echo " <td><a href=\"delete.php?table=alias&delete=" . $tAlias[$i]['address'] . "&domain=" . $tAlias[$i]['domain'] . "\"onclick=\"return confirm ('" . $LANG['confirm'] . $LANG['Overview_get_aliases'] . ": ". $tAlias[$i]['address'] . "')\">" . $LANG['del'] . "</a></td>\n";
echo " </tr>\n";
}
}
@ -40,7 +40,6 @@ if (count($tMailbox) > 0) {
echo " <tr class=\"header\">\n";
echo " <td>" . $LANG['Overview_mailbox_username'] . "</td>\n";
echo " <td>" . $LANG['Overview_mailbox_name'] . "</td>\n";
if ($CONF['quota'] == 'YES') echo " <td>" . $LANG['Overview_mailbox_quota'] . "</td>\n";
echo " <td>" . $LANG['Overview_mailbox_modified'] . "</td>\n";
echo " <td>" . $LANG['Overview_mailbox_active'] . "</td>\n";
echo " <td colspan=\"2\">&nbsp;</td>\n";
@ -52,7 +51,7 @@ if (count($tMailbox) > 0) {
echo " <td>" . $tMailbox[$i]['username'] . "</td>\n";
echo " <td>" . $tMailbox[$i]['name'] . "</td>\n";
echo " <td><a href=\"edit-mailbox.php?username=" . $tMailbox[$i]['username'] . "&domain=" . $tMailbox[$i]['domain'] . "\">" . $LANG['edit'] . "</a></td>\n";
echo " <td><a href=\"delete.php?delete=" . $tMailbox[$i]['username'] . "&domain=" . $tMailbox[$i]['domain'] . "\"onclick=\"return confirm ('" . $LANG['confirm'] . $LANG['Overview_get_mailboxes'] . ": ". $tMailbox[$i]['username'] . "')\">" . $LANG['del'] . "</a></td>\n";
echo " <td><a href=\"delete.php?table=mailbox&delete=" . $tMailbox[$i]['username'] . "&domain=" . $tMailbox[$i]['domain'] . "\"onclick=\"return confirm ('" . $LANG['confirm'] . $LANG['Overview_get_mailboxes'] . ": ". $tMailbox[$i]['username'] . "')\">" . $LANG['del'] . "</a></td>\n";
echo " </tr>\n";
}
}

View File

@ -15,7 +15,7 @@ if (count($list_domains) > 0) {
</form>
</div>
<?php
if (count($log) > 0) {
if (count($log ?? array()) > 0) {
echo "<table id=\"log_table\">\n";
echo " <tr>\n";
echo " <td colspan=\"5\"><h3>".$LANG['Viewlog_welcome']." ".$domain."</h3></td>\n";

View File

@ -26,11 +26,15 @@ $list_domains = list_domains($SESSID_USERNAME);
if ($_SERVER['REQUEST_METHOD'] == "GET") {
$domain = filter_input(INPUT_GET, 'domain', FILTER_VALIDATE_DOMAIN) ?? $list_domains[0]['domain'];
$domain_key = array_search($domain, array_column($list_domains, 'domain'));
$dbh = connect_db();
$sth = $dbh->prepare("SELECT * FROM log WHERE domain=? ORDER BY timestamp DESC LIMIT 10");
$sth->bindParam(1, $domain, PDO::PARAM_STR);
$sth->execute();
$log = $sth->fetchAll();
$domain_exist = in_array($domain, array_column($list_domains, 'domain'));
if ($domain_exist) {
$dbh = connect_db();
$sth = $dbh->prepare("SELECT * FROM log WHERE domain=? ORDER BY timestamp DESC LIMIT 10");
$sth->bindParam(1, $domain, PDO::PARAM_STR);
$sth->execute();
$log = $sth->fetchAll();
}
}
include './templates/header.tpl';