diff --git a/add-alias.php b/add-alias.php index f596135..6deb5e9 100644 --- a/add-alias.php +++ b/add-alias.php @@ -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())"); diff --git a/add-mailbox.php b/add-mailbox.php index 0cedbe4..a435ec2 100644 --- a/add-mailbox.php +++ b/add-mailbox.php @@ -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 . "/"; diff --git a/admin/add-alias.php b/admin/add-alias.php index 294e565..85ea0fb 100644 --- a/admin/add-alias.php +++ b/admin/add-alias.php @@ -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())"); diff --git a/admin/add-mailbox.php b/admin/add-mailbox.php index 95bf515..df39f76 100644 --- a/admin/add-mailbox.php +++ b/admin/add-mailbox.php @@ -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 . "/"; diff --git a/admin/delete.php b/admin/delete.php index 3ffa13e..3f1097d 100644 --- a/admin/delete.php +++ b/admin/delete.php @@ -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'] . "$delete (" . $e->getMessage() . ")!"; } 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'] . "$delete (" . $e->getMessage() . ")!"; } catch (PDOException $e) { diff --git a/admin/edit-alias.php b/admin/edit-alias.php index 1622f6f..03d550c 100644 --- a/admin/edit-alias.php +++ b/admin/edit-alias.php @@ -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=?"); diff --git a/admin/edit-mailbox.php b/admin/edit-mailbox.php index 350f25d..01e60db 100644 --- a/admin/edit-mailbox.php +++ b/admin/edit-mailbox.php @@ -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=?"); diff --git a/admin/viewlog.php b/admin/viewlog.php index 40d9de4..574bd08 100644 --- a/admin/viewlog.php +++ b/admin/viewlog.php @@ -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'; diff --git a/delete.php b/delete.php index 0b3bd42..7d753a9 100644 --- a/delete.php +++ b/delete.php @@ -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'] . "$delete (" . $e->getMessage() . ")!"; } 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'] . "$delete (" . $e->getMessage() . ")!"; } catch (PDOException $e) { diff --git a/edit-alias.php b/edit-alias.php index 5a3333a..7ae5c6c 100644 --- a/edit-alias.php +++ b/edit-alias.php @@ -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'; ?> diff --git a/edit-mailbox.php b/edit-mailbox.php index 88ade1f..6bddeb3 100644 --- a/edit-mailbox.php +++ b/edit-mailbox.php @@ -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'; ?> diff --git a/list-domain.php b/list-domain.php new file mode 100644 index 0000000..8ac84c4 --- /dev/null +++ b/list-domain.php @@ -0,0 +1,30 @@ + +// 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'; +?> diff --git a/list-virtual.php b/list-virtual.php new file mode 100644 index 0000000..9c79c8f --- /dev/null +++ b/list-virtual.php @@ -0,0 +1,43 @@ + +// 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'; +?> diff --git a/templates/main.tpl b/templates/main.tpl index 8ee12b0..71745f5 100644 --- a/templates/main.tpl +++ b/templates/main.tpl @@ -1,7 +1,7 @@