diff --git a/add-alias.php b/add-alias.php index d3f7356..f596135 100644 --- a/add-alias.php +++ b/add-alias.php @@ -5,108 +5,74 @@ // Copyright (c) 2022 High5! // License Info: LICENSE.TXT // -// File: create-alias.php +// File: add-alias.php // -// Template File: create-alias.tpl +// Template File: add-alias.tpl // // Template Variables: // -// tMessage -// tAddress -// tGoto -// tDomain +// message +// address +// domain +// goto // // Form POST \ GET Variables: // -// fAddress -// fGoto -// fDomain +// address +// domain +// goto // -require("./functions.inc.php"); -include("./languages/" . check_language() . ".lang"); +require_once './functions.inc.php'; +include './languages/' . check_language() . '.lang'; $SESSID_USERNAME = check_session(); $list_domains = list_domains($SESSID_USERNAME); +$admin = $SESSID_USERNAME ?? ADMIN_EMAIL; if ($_SERVER['REQUEST_METHOD'] == "GET") { - $pCreate_alias_goto_text = $LANG['Create_alias_goto_text']; - - if (isset($_GET['domain'])) $tDomain = escape_string($_GET['domain']); + $domain = filter_input(INPUT_GET, 'domain', FILTER_VALIDATE_DOMAIN); + $domain_key = array_search($domain, array_column($list_domains, 'domain')); } if ($_SERVER['REQUEST_METHOD'] == "POST") { - $pCreate_alias_goto_text = $LANG['Create_alias_goto_text']; + $address = strtolower(filter_input(INPUT_POST, 'address', FILTER_DEFAULT)); + $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')); + $from = filter_var($address . '@' . $domain, FILTER_VALIDATE_EMAIL); - $fAddress = escape_string($_POST['fAddress']) . "@" . escape_string($_POST['fDomain']); - $fAddress = strtolower($fAddress); - $fGoto = escape_string($_POST['fGoto']); - $fGoto = strtolower($fGoto); - $fDomain = escape_string($_POST['fDomain']); + if (!str_contains($goto, '@')) { + $goto = $goto . "@" . $domain; + } + $goto = filter_var($goto, FILTER_VALIDATE_EMAIL); - if (!preg_match('/@/',$fGoto)) { - $fGoto = $fGoto . "@" . escape_string($_POST['fDomain']); + if ($list_domains[$domain_key]['aliases'] != 0 && $list_domains[$domain_key]['alias_count'] >= $list_domains[$domain_key]['aliases']) { + $message = $LANG['Create_alias_address_text_error2']; } - if (!check_owner($SESSID_USERNAME, $fDomain)) { - $error = 1; - $tAddress = escape_string($_POST['fAddress']); - $tGoto = $fGoto; - $tDomain = $fDomain; - $pCreate_alias_address_text = $LANG['Create_alias_address_text_error1']; + if (empty($address) || empty($goto)) { + $message = $LANG['Create_alias_address_text_error1']; } - if (!check_alias($fDomain)) { - $error = 1; - $tAddress = escape_string($_POST['fAddress']); - $tGoto = $fGoto; - $tDomain = $fDomain; - $pCreate_alias_address_text = $LANG['Create_alias_address_text_error3']; - } - - if (empty($fAddress) or !check_email($fAddress)) { - $error = 1; - $tAddress = escape_string($_POST['fAddress']); - $tGoto = $fGoto; - $tDomain = $fDomain; - $pCreate_alias_address_text = $LANG['Create_alias_address_text_error1']; - } - - if (empty($fGoto) or !check_email($fGoto)) { - $error = 1; - $tAddress = escape_string($_POST['fAddress']); - $tGoto = $fGoto; - $tDomain = $fDomain; - $pCreate_alias_goto_text = $LANG['Create_alias_goto_text_error']; - } - - if (escape_string($_POST['fAddress']) == "*") $fAddress = "@" . escape_string($_POST['fDomain']); - - $result = db_query("SELECT * FROM alias WHERE address='$fAddress'"); - if ($result['rows'] == 1) { - $error = 1; - $tAddress = escape_string($_POST['fAddress']); - $tGoto = $fGoto; - $tDomain = $fDomain; - $pCreate_alias_address_text = $LANG['Create_alias_address_text_error2']; - } - - if ($error != 1) { - if (preg_match('/^\*@(.*)$/', $fGoto, $match)) $fGoto = "@" . $match[1]; - - $result = db_query("INSERT INTO alias (address,goto,domain,created,modified) VALUES ('$fAddress','$fGoto','$fDomain',NOW(),NOW())"); - if ($result['rows'] != 1) { - $tDomain = $fDomain; - $tMessage = $LANG['Create_alias_result_error'] . "
($fAddress -> $fGoto)
\n"; - } else { - db_log($SESSID_USERNAME, $fDomain, "create alias", "$fAddress -> $fGoto"); - - $tDomain = $fDomain; - $tMessage = $LANG['Create_alias_result_succes'] . "
($fAddress -> $fGoto)
\n"; + if (empty($message) && isset($domain_key)) { + try { + $dbh = connect_db(); + $sth = $dbh->prepare("INSERT INTO alias (address,goto,domain,created,modified) VALUES (?,?,?,NOW(),NOW())"); + $sth->bindParam(1, $from, PDO::PARAM_STR); + $sth->bindParam(2, $goto, PDO::PARAM_STR); + $sth->bindParam(3, $domain, PDO::PARAM_STR); + $sth->execute(); + logging($admin, $domain, "create alias", "$from -> $goto"); + $message = $LANG['Create_alias_result_succes'] . "
($from -> $goto)
"; + $address = ''; + $goto = ''; + } catch(PDOException $e) { + $message = $LANG['Create_alias_result_error'] . "
($from -> $goto)
"; } } } -include("./templates/header.tpl"); -include("./templates/menu.tpl"); -include("./templates/add-alias.tpl"); -include("./templates/footer.tpl"); +include './templates/header.tpl'; +include './templates/menu.tpl'; +include './templates/add-alias.tpl'; +include './templates/footer.tpl'; ?> diff --git a/add-mailbox.php b/add-mailbox.php index 2369879..0cedbe4 100644 --- a/add-mailbox.php +++ b/add-mailbox.php @@ -5,187 +5,95 @@ // Copyright (c) 2022 High5! // License Info: LICENSE.TXT // -// File: create-mailbox.php +// File: add-mailbox.php // -// Template File: create-mailbox.tpl +// Template File: add-mailbox.tpl // // Template Variables: // -// tMessage -// tUsername -// tName -// tQuota -// tDomain +// message +// username +// name +// domain // // Form POST \ GET Variables: // -// fUsername -// fPassword -// fPassword2 -// fName -// fQuota -// fDomain -// fActive -// fMail +// username +// password1 +// password2 +// name +// domain // -require("./functions.inc.php"); -include("./languages/" . check_language() . ".lang"); +require_once './functions.inc.php'; +include './languages/' . check_language() . '.lang'; $SESSID_USERNAME = check_session(); $list_domains = list_domains($SESSID_USERNAME); +$admin = $SESSID_USERNAME ?? ADMIN_EMAIL; if ($_SERVER['REQUEST_METHOD'] == "GET") { - $tQuota = $CONF['maxquota']; - - $pCreate_mailbox_password_text = $LANG['Create_mailbox_password_text']; - $pCreate_mailbox_name_text = $LANG['Create_mailbox_name_text']; - $pCreate_mailbox_quota_text = $LANG['Create_mailbox_quota_text']; - - if (isset($_GET['domain'])) $tDomain = escape_string($_GET['domain']); + $domain = filter_input(INPUT_GET, 'domain', FILTER_VALIDATE_DOMAIN); + $domain_key = array_search($domain, array_column($list_domains, 'domain')); } if ($_SERVER['REQUEST_METHOD'] == "POST") { - $pCreate_mailbox_password_text = $LANG['Create_mailbox_password_text']; - $pCreate_mailbox_name_text = $LANG['Create_mailbox_name_text']; - $pCreate_mailbox_quota_text = $LANG['Create_mailbox_quota_text']; - - $fUsername = escape_string($_POST['fUsername']) . "@" . escape_string($_POST['fDomain']); - $fUsername = strtolower($fUsername); - $fPassword = escape_string($_POST['fPassword']); - $fPassword2 = escape_string($_POST['fPassword2']); - $fName = escape_string($_POST['fName']); - $fDomain = escape_string($_POST['fDomain']); - if (isset($_POST['fQuota'])) $fQuota = escape_string($_POST['fQuota']); - if (isset($_POST['fActive'])) $fActive = escape_string($_POST['fActive']); - if (isset($_POST['fMail'])) $fMail = escape_string($_POST['fMail']); + $username = strtolower(filter_input(INPUT_POST, 'username', FILTER_DEFAULT)); + $domain = filter_input(INPUT_POST, 'domain', FILTER_VALIDATE_DOMAIN); + $password1 = filter_input(INPUT_POST, 'password1', FILTER_DEFAULT); + $password2 = filter_input(INPUT_POST, 'password2', FILTER_DEFAULT); + $name = filter_input(INPUT_POST, 'name', FILTER_DEFAULT); - if (!check_owner($SESSID_USERNAME, $fDomain)) { - $error = 1; - $tUsername = escape_string($_POST['fUsername']); - $tName = $fName; - $tQuota = $fQuota; - $tDomain = $fDomain; - $pCreate_mailbox_username_text = $LANG['Create_mailbox_username_text_error1']; - } + $domain_key = array_search($domain, array_column($list_domains, 'domain')); - if (!check_mailbox($fDomain)) { - $error = 1; - $tUsername = escape_string($_POST['fUsername']); - $tName = $fName; - $tQuota = $fQuota; - $tDomain = $fDomain; - $pCreate_mailbox_username_text = $LANG['Create_mailbox_username_text_error3']; + $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']) { + $message = $LANG['Create_mailbox_username_text_error3']; } - if (empty($fUsername) or !check_email($fUsername)) { - $error = 1; - $tUsername = escape_string($_POST['fUsername']); - $tName = $fName; - $tQuota = $fQuota; - $tDomain = $fDomain; - $pCreate_mailbox_username_text = $LANG['Create_mailbox_username_text_error1']; + if (empty($username)) { + $message = $LANG['Create_mailbox_username_text_error1']; } - if (empty($fPassword) or ($fPassword != $fPassword2)) { - if ($CONF['generate_password'] == "YES") { - $fPassword = generate_password(); - } else { - $error = 1; - $tUsername = escape_string($_POST['fUsername']); - $tName = $fName; - $tQuota = $fQuota; - $tDomain = $fDomain; - $pCreate_mailbox_password_text = $LANG['Create_mailbox_password_text_error']; - } + if (empty($password1) or ($password1 != $password2)) { + $message = $LANG['Create_mailbox_password_text_error']; } - if ($CONF['quota'] == "YES") { - if (!check_quota($fQuota, $fDomain)) { - $error = 1; - $tUsername = escape_string($_POST['fUsername']); - $tName = $fName; - $tQuota = $fQuota; - $tDomain = $fDomain; - $pCreate_mailbox_quota_text = $LANG['Create_mailbox_quota_text_error']; - } - } - - $result = db_query("SELECT * FROM alias WHERE address='$fUsername'"); - if ($result['rows'] == 1) { - $error = 1; - $tUsername = escape_string($_POST['fUsername']); - $tName = $fName; - $tQuota = $fQuota; - $tDomain = $fDomain; - $pCreate_mailbox_username_text = $LANG['Create_mailbox_username_text_error2']; - } + if (empty($message) && isset($domain_key)) { + $hashed = bcrypt($password1); + $maildir = $from . "/"; - if ($error != 1) { - $password = pacrypt($fPassword); - - if ($CONF['domain_path'] == "YES") { - if ($CONF['domain_in_mailbox'] == "YES") { - $maildir = $fDomain . "/" . $fUsername . "/"; - } else { - $maildir = $fDomain . "/" . escape_string($_POST['fUsername']) . "/"; - } - } else { - $maildir = $fUsername . "/"; - } - - if (!empty($fQuota)) { - $quota = $fQuota * $CONF['quota_multiplier']; - } else { - $quota = 0; - } - - if ($fActive == "on") { - $fActive = 1; - } else { - $fActive = 0; + try { + $dbh = connect_db(); + $sth = $dbh->prepare("INSERT INTO alias (address,goto,domain,created,modified) VALUES (?,'vmail',?,NOW(),NOW())"); + $sth->bindParam(1, $from, PDO::PARAM_STR); + $sth->bindParam(2, $domain, PDO::PARAM_STR); + $sth->execute(); + $username = ''; + } catch(PDOException $e) { + $message = $LANG['Create_alias_result_error'] . "
($from) - $e
"; } - $result = db_query("INSERT INTO alias (address,goto,domain,created,modified,active) VALUES ('$fUsername','vmail','$fDomain',NOW(),NOW(),'$fActive')"); - if ($result['rows'] != 1) { - $tDomain = $fDomain; - $tMessage = $LANG['Alias_result_error'] . "
($fUsername -> $fUsername)
"; - } - - $result = db_query("INSERT INTO mailbox (username,password,name,maildir,quota,domain,created,modified,active) VALUES ('$fUsername','$password','$fName','$maildir','$quota','$fDomain',NOW(),NOW(),'$fActive')"); - if ($result['rows'] != 1) { - $tDomain = $fDomain; - $tMessage .= $LANG['Create_mailbox_result_error'] . "
($fUsername)
"; - } else { - db_log($SESSID_USERNAME, $fDomain, "create mailbox", "$fUsername"); - - $tDomain = $fDomain; - $tMessage = $LANG['Create_mailbox_result_succes'] . "
($fUsername"; - if ($CONF['generate_password'] == "YES") { - $tMessage .= " / $fPassword)
"; - } else { - $tMessage .= ")
"; - } - - $tQuota = $CONF['maxquota']; - - if ($fMail == "on") { - $fTo = $fUsername; - $fSubject = $LANG['Sendmail_subject_text']; - $fHeaders = "From: " . $SESSID_USERNAME . "\r\n"; - $fHeaders .= "Content-Type: text/plain; charset=utf-8\r\n"; - $fBody = $CONF['welcome_text']; - - if (!mail($fTo, $fSubject, $fBody, $fHeaders)) { - $tMessage .= "
" . $LANG['Sendmail_result_error'] . "
"; - } else { - $tMessage .= "
" . $LANG['Sendmail_result_succes'] . "
"; - } - } + try { + $dbh = connect_db(); + $sth = $dbh->prepare("INSERT INTO mailbox (username,password,name,maildir,domain,created,modified) VALUES (?,?,?,?,?,NOW(),NOW())"); + $sth->bindParam(1, $from, PDO::PARAM_STR); + $sth->bindParam(2, $hashed, PDO::PARAM_STR); + $sth->bindParam(3, $name, PDO::PARAM_STR); + $sth->bindParam(4, $maildir, PDO::PARAM_STR); + $sth->bindParam(5, $domain, PDO::PARAM_STR); + $sth->execute(); + logging($admin, $domain, "create mailbox", "$from"); + $message = $LANG['Create_mailbox_result_succes'] . "
($from)"; + $username = ''; + $name = ''; + } catch(PDOException $e) { + $message = $LANG['Create_alias_result_error'] . "
($from) - $e
"; } } } -include("./templates/header.tpl"); -include("./templates/menu.tpl"); -include("./templates/add-mailbox.tpl"); -include("./templates/footer.tpl"); +include './templates/header.tpl'; +include './templates/menu.tpl'; +include './templates/add-mailbox.tpl'; +include './templates/footer.tpl'; ?> diff --git a/admin/add-alias.php b/admin/add-alias.php index ac2bcff..294e565 100644 --- a/admin/add-alias.php +++ b/admin/add-alias.php @@ -26,6 +26,7 @@ require_once '../functions.inc.php'; include '../languages/' . check_language() . '.lang'; $list_domains = list_domains(); +$admin = $SESSID_USERNAME ?? ADMIN_EMAIL; if ($_SERVER['REQUEST_METHOD'] == "GET") { $domain = filter_input(INPUT_GET, 'domain', FILTER_VALIDATE_DOMAIN); @@ -36,17 +37,15 @@ if ($_SERVER['REQUEST_METHOD'] == "POST") { $address = strtolower(filter_input(INPUT_POST, 'address', FILTER_DEFAULT)); $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')); - print "$domain_key"; - $from = filter_var($address . '@' . $domain, FILTER_VALIDATE_EMAIL); + if (!str_contains($goto, '@')) { $goto = $goto . "@" . $domain; } $goto = filter_var($goto, FILTER_VALIDATE_EMAIL); - if ($list_domains[$domain_key]['alias_count'] < 0 || $list_domains[$domain_key]['alias_count'] >= $list_domains[$domain_key]['aliases']) { + if ($list_domains[$domain_key]['aliases'] != 0 && $list_domains[$domain_key]['alias_count'] >= $list_domains[$domain_key]['aliases']) { $message = $LANG['Create_alias_address_text_error2']; } @@ -54,7 +53,7 @@ if ($_SERVER['REQUEST_METHOD'] == "POST") { $message = $LANG['Create_alias_address_text_error1']; } - if (empty($message)) { + if (empty($message) && isset($domain_key)) { try { $dbh = connect_db(); $sth = $dbh->prepare("INSERT INTO alias (address,goto,domain,created,modified) VALUES (?,?,?,NOW(),NOW())"); @@ -62,12 +61,12 @@ if ($_SERVER['REQUEST_METHOD'] == "POST") { $sth->bindParam(2, $goto, PDO::PARAM_STR); $sth->bindParam(3, $domain, PDO::PARAM_STR); $sth->execute(); - logging(ADMIN_EMAIL, $domain, "create alias", "$from -> $goto"); + logging($admin, $domain, "create alias", "$from -> $goto"); $message = $LANG['Create_alias_result_succes'] . "
($from -> $goto)
"; $address = ''; $goto = ''; } catch(PDOException $e) { - $message = $LANG['Create_alias_result_error'] . "
($from -> $goto) - $e
"; + $message = $LANG['Create_alias_result_error'] . "
($from -> $goto)
"; } } } diff --git a/admin/add-mailbox.php b/admin/add-mailbox.php index d6f2fe7..95bf515 100644 --- a/admin/add-mailbox.php +++ b/admin/add-mailbox.php @@ -28,6 +28,7 @@ require_once '../functions.inc.php'; include '../languages/' . check_language() . '.lang'; $list_domains = list_domains(); +$admin = $SESSID_USERNAME ?? ADMIN_EMAIL; if ($_SERVER['REQUEST_METHOD'] == "GET") { $domain = filter_input(INPUT_GET, 'domain', FILTER_VALIDATE_DOMAIN); @@ -45,7 +46,7 @@ if ($_SERVER['REQUEST_METHOD'] == "POST") { $from = filter_var($username . '@' . $domain, FILTER_VALIDATE_EMAIL); - if ($list_domains[$domain_key]['mailbox_count'] < 0 || $list_domains[$domain_key]['mailbox_count'] >= $list_domains[$domain_key]['mailboxes']) { + if ($list_domains[$domain_key]['mailboxes'] != 0 && $list_domains[$domain_key]['mailbox_count'] >= $list_domains[$domain_key]['mailboxes']) { $message = $LANG['Create_mailbox_username_text_error3']; } @@ -57,7 +58,7 @@ if ($_SERVER['REQUEST_METHOD'] == "POST") { $message = $LANG['Create_mailbox_password_text_error']; } - if (empty($message)) { + if (empty($message) && isset($domain_key)) { $hashed = bcrypt($password1); $maildir = $from . "/"; @@ -81,7 +82,7 @@ if ($_SERVER['REQUEST_METHOD'] == "POST") { $sth->bindParam(4, $maildir, PDO::PARAM_STR); $sth->bindParam(5, $domain, PDO::PARAM_STR); $sth->execute(); - logging(ADMIN_EMAIL, $domain, "create mailbox", "$from"); + logging($admin, $domain, "create mailbox", "$from"); $message = $LANG['Create_mailbox_result_succes'] . "
($from)"; $username = ''; $name = ''; diff --git a/admin/admin.php b/admin/admin.php index 3c3e4a1..7d8b93e 100644 --- a/admin/admin.php +++ b/admin/admin.php @@ -84,7 +84,7 @@ if ($_SERVER['REQUEST_METHOD'] == "POST") { if ($password1 != $password2) { $message = $LANG['AdminAdd_admin_password_error']; } - if (!empty($password1) && empty($message)) { + if (empty($message) && !empty($password1)) { $hashed = bcrypt($password1); try { $dbh = connect_db(); diff --git a/admin/delete.php b/admin/delete.php index 85dc92c..3ffa13e 100644 --- a/admin/delete.php +++ b/admin/delete.php @@ -23,10 +23,14 @@ require_once '../functions.inc.php'; include '../languages/' . check_language() . '.lang'; +$list_domains = list_domains(); +$admin = $SESSID_USERNAME ?? ADMIN_EMAIL; + if ($_SERVER['REQUEST_METHOD'] == "GET") { $table = strtolower(filter_input(INPUT_GET, 'table', FILTER_DEFAULT)); $delete = filter_input(INPUT_GET, 'delete', FILTER_DEFAULT); - $domain = filter_input(INPUT_GET, 'domain', FILTER_DEFAULT); + $domain = filter_input(INPUT_GET, 'domain', FILTER_VALIDATE_DOMAIN); + $domain_key = array_search($domain, array_column($list_domains, 'domain')); if ($table == "domain") { try { @@ -95,6 +99,7 @@ if ($_SERVER['REQUEST_METHOD'] == "GET") { $dbh->commit(); header("Location: list-domain.php"); + exit; } catch (RuntimeException $e) { $message = $e->getMessage(); $dbh->rollBack(); @@ -130,6 +135,7 @@ if ($_SERVER['REQUEST_METHOD'] == "GET") { $dbh->commit(); header("Location: list-admin.php"); + exit; } catch (RuntimeException $e) { $message = $e->getMessage(); $dbh->rollBack(); @@ -139,7 +145,7 @@ if ($_SERVER['REQUEST_METHOD'] == "GET") { } } - if ($table == 'alias' || $table == 'mailbox') { + if (($table == 'alias' || $table == 'mailbox') && in_array($domain, array_column($list_domains, 'domain'))) { try { $dbh = connect_db(); $sth = $dbh->prepare("DELETE FROM alias WHERE address=? AND domain=?"); @@ -149,9 +155,10 @@ if ($_SERVER['REQUEST_METHOD'] == "GET") { if ($sth->rowCount() != 1) { throw new RuntimeException('alias'); } - logging(ADMIN_EMAIL, $domain, "delete alias", $delete); + 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) { @@ -167,7 +174,7 @@ if ($_SERVER['REQUEST_METHOD'] == "GET") { if ($sth->rowCount() != 1) { throw new RuntimeException('mailbox'); } - logging(ADMIN_EMAIL, $domain, "delete mailbox", $delete); + logging($admin, $domain, "delete mailbox", $delete); $sth = $dbh->prepare("DELETE FROM vacation WHERE email=? AND domain=?"); $sth->bindParam(1, $delete, PDO::PARAM_STR); @@ -175,6 +182,7 @@ 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/admin/edit-alias.php b/admin/edit-alias.php index 7f1a027..1622f6f 100644 --- a/admin/edit-alias.php +++ b/admin/edit-alias.php @@ -23,9 +23,13 @@ require_once '../functions.inc.php'; include '../languages/' . check_language() . '.lang'; +$list_domains = list_domains(); +$admin = $SESSID_USERNAME ?? ADMIN_EMAIL; + 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')); try { $dbh = connect_db(); @@ -44,6 +48,7 @@ if ($_SERVER['REQUEST_METHOD'] == "POST") { $address = strtolower(filter_input(INPUT_GET, 'address', FILTER_VALIDATE_EMAIL)); $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')); if (empty($goto)) { $goto = array(); @@ -62,7 +67,7 @@ if ($_SERVER['REQUEST_METHOD'] == "POST") { } } - if (empty($message)) { + if (empty($message) && isset($domain_key)) { try { $dbh = connect_db(); $sth = $dbh->prepare("UPDATE alias SET goto=?,modified=NOW() WHERE address=? AND domain=?"); @@ -70,7 +75,7 @@ if ($_SERVER['REQUEST_METHOD'] == "POST") { $sth->bindParam(2, $address, PDO::PARAM_STR); $sth->bindParam(3, $domain, PDO::PARAM_STR); $sth->execute(); - logging(ADMIN_EMAIL, $domain, "edit alias", "$address -> $goto"); + logging($admin, $domain, "edit alias", "$address -> $goto"); header("Location: list-virtual.php?domain=$domain"); } catch(PDOException $e) { $message = $LANG['Edit_alias_result_error']; diff --git a/admin/edit-mailbox.php b/admin/edit-mailbox.php index c85fea4..350f25d 100644 --- a/admin/edit-mailbox.php +++ b/admin/edit-mailbox.php @@ -25,6 +25,9 @@ require_once '../functions.inc.php'; include '../languages/' . check_language() . '.lang'; +$list_domains = list_domains(); +$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); @@ -53,7 +56,7 @@ if ($_SERVER['REQUEST_METHOD'] == "POST") { $message = $LANG['Edit_mailbox_password_text_error']; } - if (!empty($pqassword1) && empty($message)) { + if (empty($message) && isset($domain_key) && !empty($password1)) { $hashed = bcrypt($password1); try { $dbh = connect_db(); @@ -68,7 +71,7 @@ if ($_SERVER['REQUEST_METHOD'] == "POST") { } } - if (empty($message)) { + if (empty($message) && isset($domain_key)) { try { $dbh = connect_db(); $sth = $dbh->prepare("UPDATE mailbox SET name=?,modified=NOW() WHERE username=? AND domain=?"); @@ -76,7 +79,7 @@ if ($_SERVER['REQUEST_METHOD'] == "POST") { $sth->bindParam(2, $username, PDO::PARAM_STR); $sth->bindParam(3, $domain, PDO::PARAM_STR); $sth->execute(); - logging(ADMIN_EMAIL, $domain, "edit mailbox", $username); + logging($admin, $domain, "edit mailbox", $username); header("Location: list-virtual.php?domain=$domain"); } catch(PDOException $e) { $message = $LANG['Edit_mailbox_result_error']; diff --git a/delete.php b/delete.php index f788e5a..0b3bd42 100644 --- a/delete.php +++ b/delete.php @@ -11,67 +11,75 @@ // // Template Variables: // -// tMessage +// message // // Form POST \ GET Variables: // -// fDelete -// fDomain +// table +// where +// delete +// domain // -require("./variables.inc.php"); -require("./config.inc.php"); -require("./functions.inc.php"); -include("./languages/" . check_language() . ".lang"); +require_once './functions.inc.php'; +include './languages/' . check_language() . '.lang'; $SESSID_USERNAME = check_session(); -$list_domains = list_domains_for_admin($SESSID_USERNAME); +$list_domains = list_domains($SESSID_USERNAME); +$admin = $SESSID_USERNAME ?? ADMIN_EMAIL; if ($_SERVER['REQUEST_METHOD'] == "GET") { - if (isset($_GET['delete'])) $fDelete = escape_string($_GET['delete']); - if (isset($_GET['domain'])) $fDomain = escape_string($_GET['domain']); + $table = strtolower(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')); - if (in_array($_GET['domain'], array_column($list_domains, 'domain'))) { - #if (!check_owner($SESSID_USERNAME, $fDomain)) { - $error = 1; - $tMessage = $LANG['Delete_domain_error'] . "$fDomain!"; - } else { - - $result = db_query("DELETE FROM alias WHERE address='$fDelete' AND domain='$fDomain'"); - if ($result['rows'] != 1) { - $error = 1; - $tMessage = $LANG['Delete_delete_error'] . "$fDelete (alias)!"; - } else { - db_log($SESSID_USERNAME, $fDomain, "delete alias", $fDelete); - } - - $result = db_query("SELECT * FROM mailbox WHERE username='$fDelete' AND domain='$fDomain'"); - if ($result['rows'] == 1) { - $result = db_query("DELETE FROM mailbox WHERE username='$fDelete' AND domain='$fDomain'"); - if ($result['rows'] != 1) { - $error = 1; - $tMessage = $LANG['Delete_delete_error'] . "$fDelete (mailbox)!"; - } else { - db_query("DELETE FROM vacation WHERE email='$fDelete' AND domain='$fDomain'"); - db_log($SESSID_USERNAME, $fDomain, "delete mailbox", $fDelete); + if (($table == 'alias' || $table == 'mailbox') && in_array($domain, array_column($list_domains, 'domain'))) { + try { + $dbh = connect_db(); + $sth = $dbh->prepare("DELETE FROM alias WHERE address=? AND domain=?"); + $sth->bindParam(1, $delete, PDO::PARAM_STR); + $sth->bindParam(2, $domain, PDO::PARAM_STR); + $sth->execute(); + if ($sth->rowCount() != 1) { + throw new RuntimeException('alias'); } + 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) { + $message = $LANG['Delete_delete_error'] . "$delete (alias)! " . $e-getMessage(); + } + + 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->execute(); + if ($sth->rowCount() != 1) { + throw new RuntimeException('mailbox'); + } + logging($admin, $domain, "delete mailbox", $delete); + + $sth = $dbh->prepare("DELETE FROM vacation WHERE email=? AND domain=?"); + $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) { + $message = $LANG['Delete_delete_error'] . "$delete (mailbox)!"; } } - - if ($error != 1) { - header("Location: overview.php?domain=$fDomain"); - exit; - } - - include("./templates/header.tpl"); - include("./templates/menu.tpl"); - include("./templates/message.tpl"); - include("./templates/footer.tpl"); -} - -if ($_SERVER['REQUEST_METHOD'] == "POST") { - include("./templates/header.tpl"); - include("./templates/menu.tpl"); - include("./templates/message.tpl"); - include("./templates/footer.tpl"); } +include './templates/header.tpl'; +include './templates/menu.tpl'; +include './templates/message.tpl'; +include './templates/footer.tpl'; ?> diff --git a/edit-active.php b/edit-active.php deleted file mode 100644 index 2e9487f..0000000 --- a/edit-active.php +++ /dev/null @@ -1,54 +0,0 @@ - -// Copyright (c) 2022 High5! -// License Info: LICENSE.TXT -// -// File: edit-active.php -// -// Template File: message.tpl -// -// Template Variables: -// -// tMessage -// -// Form POST \ GET Variables: -// -// fUsername -// fDomain -// -require("./variables.inc.php"); -require("./config.inc.php"); -require("./functions.inc.php"); -include("./languages/" . check_language() . ".lang"); - -$SESSID_USERNAME = check_session(); - -if ($_SERVER['REQUEST_METHOD'] == "GET") { - if (isset($_GET['username'])) $fUsername = escape_string($_GET['username']); - if (isset($_GET['domain'])) $fDomain = escape_string($_GET['domain']); - - if (!check_owner($SESSID_USERNAME, $fDomain)) { - $error = 1; - $tMessage = $LANG['Edit_mailbox_domain_error'] . "$fDomain!"; - } else { - $result = db_query("UPDATE mailbox SET active=1-active WHERE username='$fUsername' AND domain='$fDomain'"); - if ($result['rows'] != 1) { - $error = 1; - $tMessage = $LANG['Edit_mailbox_result_error']; - } else { - db_log($SESSID_USERNAME, $fDomain, "edit active", $fUsername); - } - } - - if ($error != 1) { - header("Location: overview.php?domain=$fDomain"); - exit; - } -} -include("./templates/header.tpl"); -include("./templates/menu.tpl"); -include("./templates/message.tpl"); -include("./templates/footer.tpl"); -?> diff --git a/edit-alias.php b/edit-alias.php index fc36f8c..5a3333a 100644 --- a/edit-alias.php +++ b/edit-alias.php @@ -11,91 +11,80 @@ // // Template Variables: // -// tMessage -// tGoto +// message +// goto // // Form POST \ GET Variables: // -// fAddress -// fDomain -// fGoto +// address +// domain +// goto // -require("./variables.inc.php"); -require("./config.inc.php"); -require("./functions.inc.php"); -include("./languages/" . check_language() . ".lang"); +require_once './functions.inc.php'; +include './languages/' . check_language() . '.lang'; $SESSID_USERNAME = check_session(); +$list_domains = list_domains($SESSID_USERNAME); +$admin = $SESSID_USERNAME ?? ADMIN_EMAIL; if ($_SERVER['REQUEST_METHOD'] == "GET") { - $fAddress = escape_string($_GET['address']); - $fDomain = escape_string($_GET['domain']); + $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')); - if (check_owner($SESSID_USERNAME, $fDomain)) { - $result = db_query("SELECT * FROM alias WHERE address='$fAddress' AND domain='$fDomain'"); - if ($result['rows'] == 1) { - $row = db_array($result['result']); - $tGoto = $row['goto']; - } - } else { - $tMessage = $LANG['Edit_alias_address_error']; + 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 ($_SERVER['REQUEST_METHOD'] == "POST") { - $pEdit_alias_goto = $LANG['Edit_alias_goto']; + $address = strtolower(filter_input(INPUT_GET, 'address', FILTER_VALIDATE_EMAIL)); + $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')); - $fAddress = escape_string($_GET['address']); - $fAddress = strtolower($fAddress); - $fDomain = escape_string($_GET['domain']); - $fGoto = escape_string($_POST['fGoto']); - $fGoto = strtolower($fGoto); - - if (!check_owner($SESSID_USERNAME, $fDomain)) { - $error = 1; - $tGoto = $fGoto; - $tMessage = $LANG['Edit_alias_domain_error'] . "$fDomain"; - } - - if (empty($fGoto)) { - $error = 1; - $tGoto = $fGoto; - $tMessage = $LANG['Edit_alias_goto_text_error1']; - } - - $goto = preg_replace('/\\\r\\\n/', ',', $fGoto); - $goto = preg_replace('/\r\n/', ',', $fGoto); - $goto = preg_replace('/[\s]+/i', '', $goto); - $goto = preg_replace('/\,*$/', '', $goto); - $array = preg_split('/,/', $goto); - - if (!empty($array)) { $array_count = count($array); } - - for($i = 0; $i < $array_count; $i++) { - if (in_array("$array[$i]", $CONF['default_aliases'])) continue; - if (empty($array[$i])) continue; - if (!check_email($array[$i])) - { - $error = 1; - $tGoto = $goto; - $tMessage = $LANG['Edit_alias_goto_text_error2'] . "$array[$i]"; + if (empty($goto)) { + $goto = array(); + $message = $LANG['Edit_alias_goto_text_error1']; + } else { + $goto = preg_replace('/\\\r\\\n/', ',', $goto); + $goto = preg_replace('/\r\n/', ',', $goto); + $goto = preg_replace('/[\s]+/i', '', $goto); + $goto = preg_replace('/\,*$/', '', $goto); + $validate_goto = explode(',', $goto); + foreach ($validate_goto as $row) { + if (!filter_var($row, FILTER_VALIDATE_EMAIL)) { + $goto = explode(',', $goto); + $message = $LANG['Edit_alias_goto_text_error2'] . "$row"; + } } } - - if ($error != 1) { - $result = db_query("UPDATE alias SET goto='$goto',modified=NOW() WHERE address='$fAddress' AND domain='$fDomain'"); - if ($result['rows'] != 1) { - $tMessage = $LANG['Edit_alias_result_error']; - } else { - db_log($SESSID_USERNAME, $fDomain, "edit alias", "$fAddress -> $goto"); - - header("Location: overview.php?domain=$fDomain"); - exit; + + if (empty($message) && isset($domain_key)) { + try { + $dbh = connect_db(); + $sth = $dbh->prepare("UPDATE alias SET goto=?,modified=NOW() WHERE address=? AND domain=?"); + $sth->bindParam(1, $goto, PDO::PARAM_STR); + $sth->bindParam(2, $address, PDO::PARAM_STR); + $sth->bindParam(3, $domain, PDO::PARAM_STR); + $sth->execute(); + logging($admin, $domain, "edit alias", "$address -> $goto"); + header("Location: list-virtual.php?domain=$domain"); + } catch(PDOException $e) { + $message = $LANG['Edit_alias_result_error']; } } } -include("./templates/header.tpl"); -include("./templates/menu.tpl"); -include("./templates/edit-alias.tpl"); -include("./templates/footer.tpl"); +include './templates/header.tpl'; +include './templates/menu.tpl'; +include './templates/edit-alias.tpl'; +include './templates/footer.tpl'; ?> diff --git a/edit-mailbox.php b/edit-mailbox.php index 6a6f138..88ade1f 100644 --- a/edit-mailbox.php +++ b/edit-mailbox.php @@ -11,122 +11,84 @@ // // Template Variables: // -// tMessage -// tName -// tQuota +// message +// name // // Form POST \ GET Variables: // -// fUsername -// fDomain -// fPassword -// fPassword2 -// fName -// fQuota -// fActive +// username +// domain +// password1 +// password2 +// name // -require("./variables.inc.php"); -require("./config.inc.php"); -require("./functions.inc.php"); -include("./languages/" . check_language() . ".lang"); +require_once './functions.inc.php'; +include './languages/' . check_language() . '.lang'; $SESSID_USERNAME = check_session(); +$list_domains = list_domains($SESSID_USERNAME); +$admin = $SESSID_USERNAME ?? ADMIN_EMAIL; if ($_SERVER['REQUEST_METHOD'] == "GET") { - $fUsername = escape_string($_GET['username']); - $fDomain = escape_string($_GET['domain']); + $username = strtolower(filter_input(INPUT_GET, 'username', FILTER_DEFAULT)); + $domain = filter_input(INPUT_GET, 'domain', FILTER_VALIDATE_DOMAIN); - if (check_owner($SESSID_USERNAME, $fDomain)) { - $result = db_query("SELECT * FROM mailbox WHERE username='$fUsername' AND domain='$fDomain'"); - if ($result['rows'] == 1) { - $row = db_array($result['result']); - $tName = $row['name']; - $tQuota = $row['quota'] / $CONF['quota_multiplier']; - $tActive = $row['active']; - } - } else { - $tMessage = $LANG['Edit_mailbox_login_error']; + 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']; } - - include("./templates/header.tpl"); - include("./templates/menu.tpl"); - include("./templates/edit-mailbox.tpl"); - include("./templates/footer.tpl"); } if ($_SERVER['REQUEST_METHOD'] == "POST") { - $pEdit_mailbox_password_text = $LANG['Edit_mailbox_password_text_error']; - $pEdit_mailbox_quota_text = $LANG['Edit_mailbox_quota_text']; - - $fUsername = escape_string($_GET['username']); - $fUsername = strtolower($fUsername); - $fDomain = escape_string($_GET['domain']); - - $fPassword = escape_string($_POST['fPassword']); - $fPassword2 = escape_string($_POST['fPassword2']); - $fName = escape_string($_POST['fName']); - if (isset($_POST['fQuota'])) $fQuota = escape_string($_POST['fQuota']); - if (isset($_POST['fActive'])) $fActive = escape_string($_POST['fActive']); - - if (!check_owner($SESSID_USERNAME, $fDomain)) { - $error = 1; - $tName = $fName; - $tQuota = $fQuota; - $tActive = $fActive; - $tMessage = $LANG['Edit_mailbox_domain_error'] . "$fDomain"; + $username = strtolower(filter_input(INPUT_GET, 'username', FILTER_DEFAULT)); + $domain = filter_input(INPUT_GET, 'domain', FILTER_VALIDATE_DOMAIN); + $password1 = filter_input(INPUT_POST, 'password1', FILTER_DEFAULT); + $password2 = filter_input(INPUT_POST, 'password2', FILTER_DEFAULT); + $name = filter_input(INPUT_POST, 'name', FILTER_DEFAULT); + + if ($password1 != $password2) { + $message = $LANG['Edit_mailbox_password_text_error']; } - if ($fPassword != $fPassword2) { - $error = 1; - $tName = $fName; - $tQuota = $fQuota; - $tActive = $fActive; - $pEdit_mailbox_password_text = $LANG['Edit_mailbox_password_text_error']; + if (empty($message) && isset($domain_key) && !empty($password1)) { + $hashed = bcrypt($password1); + try { + $dbh = connect_db(); + $sth = $dbh->prepare("UPDATE mailbox SET password=?,name=?,modified=NOW() WHERE username=? AND domain=?"); + $sth->bindParam(1, $hashed, PDO::PARAM_STR); + $sth->bindParam(2, $name, PDO::PARAM_STR); + $sth->bindParam(3, $username, PDO::PARAM_STR); + $sth->bindParam(4, $domain, PDO::PARAM_STR); + $sth->execute(); + } catch(PDOException $e) { + $message = $LANG['Edit_mailbox_result_error']; + } } - if ($CONF['quota'] == "YES") { - if (!check_quota($fQuota, $fDomain)) { - $error = 1; - $tName = $fName; - $tQuota = $fQuota; - $tActive = $fActive; - $pEdit_mailbox_quota_text = $LANG['Edit_mailbox_quota_text_error']; - } + if (empty($message) && isset($domain_key)) { + try { + $dbh = connect_db(); + $sth = $dbh->prepare("UPDATE mailbox SET name=?,modified=NOW() WHERE username=? AND domain=?"); + $sth->bindParam(1, $name, PDO::PARAM_STR); + $sth->bindParam(2, $username, PDO::PARAM_STR); + $sth->bindParam(3, $domain, PDO::PARAM_STR); + $sth->execute(); + logging($admin, $domain, "edit mailbox", $username); + header("Location: list-virtual.php?domain=$domain"); + } catch(PDOException $e) { + $message = $LANG['Edit_mailbox_result_error']; + } } - - if ($error != 1) { - if (!empty($fQuota)) { - $quota = $fQuota * $CONF['quota_multiplier']; - } else { - $quota = 0; - } - - if ($fActive == "on") { - $fActive = 1; - } else { - $fActive = 0; - } - - if (empty($fPassword) and empty($fPassword2)) { - $result = db_query("UPDATE mailbox SET name='$fName',quota='$quota',modified=NOW(),active='$fActive' WHERE username='$fUsername' AND domain='$fDomain'"); - } else { - $password = pacrypt($fPassword); - $result = db_query("UPDATE mailbox SET password='$password',name='$fName',quota='$quota',modified=NOW(),active='$fActive',scheme='' WHERE username='$fUsername' AND domain='$fDomain'"); - } - - if ($result['rows'] != 1) { - $tMessage = $LANG['Edit_mailbox_result_error']; - } else { - db_log($SESSID_USERNAME, $fDomain, "edit mailbox", $fUsername); - - header("Location: overview.php?domain=$fDomain"); - exit; - } - } - - include("./templates/header.tpl"); - include("./templates/menu.tpl"); - include("./templates/edit-mailbox.tpl"); - include("./templates/footer.tpl"); } +include './templates/header.tpl'; +include './templates/menu.tpl'; +include './templates/edit-mailbox.tpl'; +include './templates/footer.tpl'; ?> diff --git a/list-domains.php b/list-domains.php deleted file mode 100644 index 7df5602..0000000 --- a/list-domains.php +++ /dev/null @@ -1,30 +0,0 @@ - -// 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-domains.tpl'; -include './templates/footer.tpl'; -?> diff --git a/list-virtuals.php b/list-virtuals.php deleted file mode 100644 index 6683e3c..0000000 --- a/list-virtuals.php +++ /dev/null @@ -1,43 +0,0 @@ - -// 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-virtuals.tpl'; -include './templates/footer.tpl'; -?> diff --git a/templates/list-domain.tpl b/templates/list-domain.tpl new file mode 100644 index 0000000..a00158a --- /dev/null +++ b/templates/list-domain.tpl @@ -0,0 +1,28 @@ +
+
+Search: +
+
+\n"; +echo " \n"; +echo "

".$LANG['Overview_title']."

"; +echo " "; +echo " \n"; +echo " " . $LANG['Overview_get_domain'] . "\n"; +echo " " . $LANG['Overview_get_aliases'] . "\n"; +echo " " . $LANG['Overview_get_mailboxes'] . "\n"; +echo " \n"; +foreach ($list_domains as $row) { + if ($row['aliases'] == 0) $row['aliases'] = $LANG['Overview_unlimited']; + if ($row['mailboxes'] == 0) $row['mailboxes'] = $LANG['Overview_unlimited']; + if ($row['aliases'] < 0) $row['aliases'] = $LANG['Overview_disabled']; + if ($row['mailboxes'] < 0) $row['mailboxes'] = $LANG['Overview_disabled']; + echo " \n"; + echo " " . $row['domain'] . "\n"; + echo " " . $row['alias_count'] . " / " . $row['aliases'] . "\n"; + echo " " . $row['mailbox_count'] . " / " . $row['mailboxes'] . "\n"; + echo " \n"; +} +echo "\n"; +?> diff --git a/templates/list-domains.tpl b/templates/list-domains.tpl index 45a9ed4..a00158a 100644 --- a/templates/list-domains.tpl +++ b/templates/list-domains.tpl @@ -19,7 +19,7 @@ foreach ($list_domains as $row) { if ($row['aliases'] < 0) $row['aliases'] = $LANG['Overview_disabled']; if ($row['mailboxes'] < 0) $row['mailboxes'] = $LANG['Overview_disabled']; echo " \n"; - echo " " . $row['domain'] . "\n"; + echo " " . $row['domain'] . "\n"; echo " " . $row['alias_count'] . " / " . $row['aliases'] . "\n"; echo " " . $row['mailbox_count'] . " / " . $row['mailboxes'] . "\n"; echo " \n"; diff --git a/templates/menu.tpl b/templates/menu.tpl index 8e65d72..20902c0 100644 --- a/templates/menu.tpl +++ b/templates/menu.tpl @@ -1,6 +1,6 @@