diff --git a/admin/add-alias.php b/admin/add-alias.php
index 031d7f3..bc082f0 100644
--- a/admin/add-alias.php
+++ b/admin/add-alias.php
@@ -5,27 +5,25 @@
// 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
+// message
+// address
// domain
+// goto
//
// Form POST \ GET Variables:
//
// address
-// fGoto
// 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';
$list_domains = list_domains();
@@ -67,8 +65,8 @@ if ($_SERVER['REQUEST_METHOD'] == "POST") {
}
}
}
-include("../templates/header.tpl");
-include("../templates/admin_menu.tpl");
-include("../templates/add-alias.tpl");
-include("../templates/footer.tpl");
+include '../templates/header.tpl';
+include '../templates/admin_menu.tpl';
+include '../templates/add-alias.tpl';
+include '../templates/footer.tpl';
?>
diff --git a/admin/add-mailbox.php b/admin/add-mailbox.php
index 1de342c..96b35f9 100644
--- a/admin/add-mailbox.php
+++ b/admin/add-mailbox.php
@@ -5,31 +5,27 @@
// 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:
//
// username
-// fPassword
-// fPassword2
-// fName
-// fQuota
+// password1
+// password2
+// name
// domain
-// fActive
-// fMail
//
-require_once("../functions.inc.php");
-include("../languages/" . check_language() . ".lang");
+require_once '../functions.inc.php';
+include '../languages/' . check_language() . '.lang';
$list_domains = list_domains();
@@ -90,8 +86,8 @@ if ($_SERVER['REQUEST_METHOD'] == "POST") {
}
}
}
-include("../templates/header.tpl");
-include("../templates/admin_menu.tpl");
-include("../templates/add-mailbox.tpl");
-include("../templates/footer.tpl");
+include '../templates/header.tpl';
+include '../templates/admin_menu.tpl';
+include '../templates/add-mailbox.tpl';
+include '../templates/footer.tpl';
?>
diff --git a/admin/admin.php b/admin/admin.php
index e6f9a42..f146bdd 100644
--- a/admin/admin.php
+++ b/admin/admin.php
@@ -5,26 +5,27 @@
// Copyright (c) 2022 High5!
// License Info: LICENSE.TXT
//
-// File: create-admin.php
+// File: admin.php
//
-// Template File: admin_create-admin.tpl
+// Template File: admin_admin.tpl
//
//
// Template Variables:
//
-// tMessage
-// tUsername
-// tDomains
+// action
+// message
+// username
+// domains
//
// Form POST \ GET Variables:
//
-// fUsername
-// fPassword
-// fPassword2
-// fDomains
+// username
+// password1
+// password2
+// domains
//
-require_once("../functions.inc.php");
-include("../languages/" . check_language() . ".lang");
+require_once '../functions.inc.php';
+include '../languages/' . check_language() . '.lang';
$list_domains = list_domains();
$list_admins = list_admins();
@@ -47,15 +48,15 @@ if ($_SERVER['REQUEST_METHOD'] == "POST") {
if ($action == 'add') {
if (empty($username) || in_array($username, array_column($list_admins, 'username'))) {
- $message = $PALANG['pAdminCreate_admin_username_error'];
+ $message = $PALANG['pAdminAdd_admin_username_error'];
}
if (empty($password1) || $password1 != $password2) {
- $message = $PALANG['pAdminCreate_admin_password_error'];
+ $message = $PALANG['pAdminAdd_admin_password_error'];
}
if (empty($domains['domains'])) {
- $message = $PALANG['pAdminCreate_admin_domain_error'];
+ $message = $PALANG['pAdminAdd_admin_domain_error'];
}
if (empty($message)) {
@@ -72,16 +73,16 @@ if ($_SERVER['REQUEST_METHOD'] == "POST") {
$sth->bindParam(2, $row, PDO::PARAM_STR);
$sth->execute();
}
- $message = $PALANG['pAdminCreate_admin_result_succes'] . "
($username)";
+ $message = $PALANG['pAdminAdd_admin_result_succes'] . "
($username)";
} catch(PDOException $e) {
- $message = $PALANG['pAdminCreate_admin_result_error'] . "
($username)
";
+ $message = $PALANG['pAdminAdd_admin_result_error'] . "
($username)
";
}
}
}
if (in_array($username, array_column($list_admins, 'username')) && $action == 'edit') {
if ($password1 != $password2) {
- $message = $PALANG['pAdminCreate_admin_password_error'];
+ $message = $PALANG['pAdminAdd_admin_password_error'];
}
if (empty($message)) {
try {
@@ -97,7 +98,7 @@ if ($_SERVER['REQUEST_METHOD'] == "POST") {
}
if (empty($domains['domains'])) {
- $message = $PALANG['pAdminCreate_admin_domain_error'];
+ $message = $PALANG['pAdminAdd_admin_domain_error'];
}
if (empty($message)) {
try {
@@ -127,8 +128,8 @@ if ($_SERVER['REQUEST_METHOD'] == "POST") {
}
}
}
-include("../templates/header.tpl");
-include("../templates/admin_menu.tpl");
-include("../templates/admin_admin.tpl");
-include("../templates/footer.tpl");
+include '../templates/header.tpl';
+include '../templates/admin_menu.tpl';
+include '../templates/admin_admin.tpl';
+include '../templates/footer.tpl';
?>
diff --git a/admin/delete.php b/admin/delete.php
index 962de78..6168a4c 100644
--- a/admin/delete.php
+++ b/admin/delete.php
@@ -11,7 +11,7 @@
//
// Template Variables:
//
-// tMessage
+// message
//
// Form POST \ GET Variables:
//
@@ -20,8 +20,8 @@
// delete
// domain
//
-require_once("../functions.inc.php");
-include("../languages/" . check_language() . ".lang");
+require_once '../functions.inc.php';
+include '../languages/' . check_language() . '.lang';
if ($_SERVER['REQUEST_METHOD'] == "GET") {
$table = strtolower(filter_input(INPUT_GET, 'table', FILTER_DEFAULT));
@@ -182,8 +182,8 @@ if ($_SERVER['REQUEST_METHOD'] == "GET") {
}
}
}
-include("../templates/header.tpl");
-include("../templates/admin_menu.tpl");
-include("../templates/message.tpl");
-include("../templates/footer.tpl");
+include '../templates/header.tpl';
+include '../templates/admin_menu.tpl';
+include '../templates/message.tpl';
+include '../templates/footer.tpl';
?>
diff --git a/admin/domain.php b/admin/domain.php
index 2e24f6e..cbc691e 100644
--- a/admin/domain.php
+++ b/admin/domain.php
@@ -5,28 +5,25 @@
// Copyright (c) 2022 High5!
// License Info: LICENSE.TXT
//
-// File: create-domain.php
+// File: domain.php
//
-// Template File: admin_create-domain.tpl
+// Template File: admin_domain.tpl
//
// Template Variables:
//
-// tMessage
-// tDomain
-// tDescription
-// tAliases
-// tMailboxes
-// tMaxquota
-// tDefaultaliases
+// action
+// message
+// domain
+// description
+// aliases
+// mailboxes
//
// Form POST \ GET Variables:
//
-// fDomain
-// fDescription
-// fAliases
-// fMailboxes
-// fMaxquota
-// fDefaultaliases
+// domain
+// description
+// aliases
+// mailboxes
//
require_once '../functions.inc.php';
include '../languages/' . check_language() . '.lang';
@@ -60,12 +57,12 @@ if ($_SERVER['REQUEST_METHOD'] == "POST") {
$sth->bindParam(3, $aliases, PDO::PARAM_INT);
$sth->bindParam(4, $mailboxes, PDO::PARAM_INT);
$sth->execute();
- $message = $PALANG['pAdminCreate_domain_result_succes'] . "
($domain)";
+ $message = $PALANG['pAdminAdd_domain_result_succes'] . "
($domain)";
} catch(PDOException $e) {
- $message = $PALANG['pAdminCreate_domain_result_error'] . "
($domain)
";
+ $message = $PALANG['pAdminAdd_domain_result_error'] . "
($domain)
";
}
} else {
- $message = $PALANG['pAdminCreate_domain_domain_text_error'];
+ $message = $PALANG['pAdminAdd_domain_domain_text_error'];
}
if (in_array($domain, array_column($list_domains, 'domain')) && $action == 'edit') {
diff --git a/admin/list-virtual.php-orig b/admin/list-virtual.php-orig
deleted file mode 100644
index 4896fad..0000000
--- a/admin/list-virtual.php-orig
+++ /dev/null
@@ -1,61 +0,0 @@
-
-// Copyright (c) 2022 High5!
-// License Info: LICENSE.TXT
-//
-// File: list-virtual.php
-//
-// Template File: admin_list-virtual.tpl
-//
-// Template Variables:
-//
-// list_alias
-// list_mailbox
-//
-// Form GET Variables:
-//
-// domain
-// offset
-//
-require_once '../functions.inc.php';
-include '../languages/' . check_language() . '.lang';
-
-$list_domains = list_domains();
-
-$dbh = new PDO(DB_TYPE . ':host='. DB_HOST . ';dbname='. DB_NAME , DB_USER, DB_PASS);
-
-if ($_SERVER['REQUEST_METHOD'] == "GET") {
- $offset = filter_input(INPUT_GET, 'offset', FILTER_VALIDATE_INT) ?? '0';
- $limit = PAGE_SIZE;
-
- if (count($list_domains) > 0) {
- $domain = filter_input(INPUT_GET, 'domain', FILTER_VALIDATE_DOMAIN) ?? $list_domains[0]['domain'];
- $selected_domain = array_search($domain, array_column($list_domains, 'domain'));
-
- if ($CONF['alias_control'] == "NO") {
- $sth = $dbh->prepare("SELECT alias.address,alias.goto,alias.modified FROM alias LEFT JOIN mailbox ON alias.address=mailbox.username WHERE alias.domain=? AND mailbox.maildir IS NULL ORDER BY alias.address LIMIT ?, ?");
- } else {
- $sth = $dbh->prepare("SELECT alias.address,alias.goto,alias.modified FROM alias WHERE alias.domain=? ORDER BY alias.address LIMIT ?, ?");
- }
-
- $sth->bindParam(1, $domain, PDO::PARAM_STR);
- $sth->bindParam(2, $offset, PDO::PARAM_INT);
- $sth->bindParam(3, $limit, PDO::PARAM_INT);
- $sth->execute();
- $list_alias = $sth->fetchAll();
-
- $sth = $dbh->prepare("SELECT * FROM mailbox WHERE domain=? ORDER BY username LIMIT ?, ?");
- $sth->bindParam(1, $domain, PDO::PARAM_STR);
- $sth->bindParam(2, $offset, PDO::PARAM_INT);
- $sth->bindParam(3, $limit, PDO::PARAM_INT);
- $sth->execute();
- $list_mailbox = $sth->fetchAll();
- }
-}
-include '../templates/header.tpl';
-include '../templates/admin_menu.tpl';
-include '../templates/admin_list-virtual.tpl';
-include '../templates/footer.tpl';
-?>
diff --git a/admin/search.php b/admin/search.php
index a600b2e..784210a 100644
--- a/admin/search.php
+++ b/admin/search.php
@@ -11,72 +11,36 @@
//
// Template Variables:
//
-// tAlias
-// tMailbox
+// list_alias
+// list_mailbox
//
// Form POST \ GET Variables:
//
-// fSearch
+// search
//
-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';
-$tAlias = array();
-$tMailbox = array();
+$search = filter_input(INPUT_POST, 'search', FILTER_DEFAULT);
-if ($_SERVER['REQUEST_METHOD'] == "GET") {
- if (isset($_GET['search'])) $fSearch = escape_string($_GET['search']);
+if (isset($search)) {
+ $dbh = connect_db();
+ $sth = $dbh->prepare("SELECT alias.address,alias.goto,alias.modified,alias.domain FROM alias LEFT JOIN mailbox ON alias.address=mailbox.username WHERE alias.address LIKE ? AND mailbox.maildir IS NULL ORDER BY alias.address");
+ $sth->bindValue(1, '%'.$search.'%', PDO::PARAM_STR);
+ $sth->execute();
+ $list_alias = $sth->fetchAll();
- if ($CONF['alias_control'] == "YES") {
- $query = "SELECT alias.address,alias.goto,alias.modified,alias.domain FROM alias WHERE alias.address LIKE '%$fSearch%' OR alias.goto LIKE '%$fSearch%' ORDER BY alias.address";
- } else {
- $query = "SELECT alias.address,alias.goto,alias.modified,alias.domain FROM alias LEFT JOIN mailbox ON alias.address=mailbox.username WHERE alias.address LIKE '%$fSearch%' AND mailbox.maildir IS NULL ORDER BY alias.address";
- }
-
- $result = db_query("$query");
-
- if ($result['rows'] > 0) {
- while ($row = db_array($result['result'])) {
- $tAlias[] = $row;
- }
- }
-
- $result = db_query("SELECT * FROM mailbox WHERE username LIKE '%$fSearch%' ORDER BY username");
- if ($result['rows'] > 0) {
- while ($row = db_array($result['result'])) {
- $tMailbox[] = $row;
- }
- }
+ $sth = $dbh->prepare("SELECT * FROM mailbox WHERE username LIKE ? ORDER BY username");
+ $sth->bindValue(1, '%'.$search.'%', PDO::PARAM_STR);
+ $sth->execute();
+ $list_mailbox = $sth->fetchAll();
+} else {
+ $list_alias = array();
+ $list_mailbox = array();
}
-if ($_SERVER['REQUEST_METHOD'] == "POST") {
- if (isset($_POST['search'])) $fSearch = escape_string($_POST['search']);
-
- if ($CONF['alias_control'] == "YES") {
- $query = "SELECT alias.address,alias.goto,alias.modified,alias.domain FROM alias WHERE alias.address LIKE '%$fSearch%' OR alias.goto LIKE '%$fSearch%' ORDER BY alias.address";
- } else {
- $query = "SELECT alias.address,alias.goto,alias.modified,alias.domain FROM alias LEFT JOIN mailbox ON alias.address=mailbox.username WHERE alias.address LIKE '%$fSearch%' AND mailbox.maildir IS NULL ORDER BY alias.address";
- }
-
- $result = db_query("$query");
-
- if ($result['rows'] > 0) {
- while ($row = db_array($result['result'])) {
- $tAlias[] = $row;
- }
- }
-
- $result = db_query("SELECT * FROM mailbox WHERE username LIKE '%$fSearch%' ORDER BY username");
- if ($result['rows'] > 0) {
- while ($row = db_array($result['result'])) {
- $tMailbox[] = $row;
- }
- }
-}
-include("../templates/header.tpl");
-include("../templates/admin_menu.tpl");
-include("../templates/admin_search.tpl");
-include("../templates/footer.tpl");
+include '../templates/header.tpl';
+include '../templates/admin_menu.tpl';
+include '../templates/admin_search.tpl';
+include '../templates/footer.tpl';
?>
diff --git a/functions.inc.php b/functions.inc.php
index 04de3e1..a349b60 100644
--- a/functions.inc.php
+++ b/functions.inc.php
@@ -9,7 +9,7 @@
//
if(preg_match("/functions.inc.php/", $_SERVER['SCRIPT_NAME'])) {
header("Location: login.php");
- exit;
+ die();
}
DEFINE("VERSION", "version 1.0.0");
@@ -18,8 +18,6 @@ require_once ROOT_PATH . 'conf.php';
require_once ROOT_PATH . 'config.inc.php';
require_once ROOT_PATH . 'variables.inc.php';
-$version = "1.0.0";
-
//
// Check of debug is enabled or not
//
@@ -64,9 +62,8 @@ function check_user_session() {
// Call: check_language
//
function check_language() {
- global $CONF;
// Currently only English is supported, no need to run through the check now.
- return $CONF['default_language'];
+ return DEFAULT_LANGUAGE;
}
//
@@ -176,7 +173,7 @@ function list_domains($username = null) {
$sth = $dbh->prepare('SELECT * FROM domain ORDER BY domain');
}
$sth->execute();
- $list= $sth->fetchAll();
+ $list = $sth->fetchAll();
for ($i = 0; $i < count($list); $i++) {
$sth = $dbh->prepare("SELECT COUNT(*) FROM alias WHERE domain=? AND goto NOT IN ('vmail')");
diff --git a/languages/en.lang b/languages/en.lang
index f3f27ad..9577580 100644
--- a/languages/en.lang
+++ b/languages/en.lang
@@ -182,17 +182,17 @@ $PALANG['pAdminList_virtual_mailbox_name'] = 'Name';
$PALANG['pAdminList_virtual_mailbox_modified'] = 'Last Modified';
$PALANG['pAdminList_virtual_mailbox_active'] = 'Active';
-$PALANG['pAdminCreate_domain_welcome'] = 'Add a new domain';
-$PALANG['pAdminCreate_domain_domain'] = 'Domain';
-$PALANG['pAdminCreate_domain_domain_text_error'] = 'The domain already exists.';
-$PALANG['pAdminCreate_domain_description'] = 'Description';
-$PALANG['pAdminCreate_domain_aliases'] = 'Aliases';
-$PALANG['pAdminCreate_domain_aliases_text'] = '-1 = disable | 0 = unlimited';
-$PALANG['pAdminCreate_domain_mailboxes'] = 'Mailboxes';
-$PALANG['pAdminCreate_domain_mailboxes_text'] = '-1 = disable | 0 = unlimited';
-$PALANG['pAdminCreate_domain_button'] = 'Add Domain';
-$PALANG['pAdminCreate_domain_result_error'] = 'Unable to add domain.';
-$PALANG['pAdminCreate_domain_result_succes'] = 'Domain has been added.';
+$PALANG['pAdminAdd_domain_welcome'] = 'Add a new domain';
+$PALANG['pAdminAdd_domain_domain'] = 'Domain';
+$PALANG['pAdminAdd_domain_domain_text_error'] = 'The domain already exists.';
+$PALANG['pAdminAdd_domain_description'] = 'Description';
+$PALANG['pAdminAdd_domain_aliases'] = 'Aliases';
+$PALANG['pAdminAdd_domain_aliases_text'] = '-1 = disable | 0 = unlimited';
+$PALANG['pAdminAdd_domain_mailboxes'] = 'Mailboxes';
+$PALANG['pAdminAdd_domain_mailboxes_text'] = '-1 = disable | 0 = unlimited';
+$PALANG['pAdminAdd_domain_button'] = 'Add Domain';
+$PALANG['pAdminAdd_domain_result_error'] = 'Unable to add domain.';
+$PALANG['pAdminAdd_domain_result_succes'] = 'Domain has been added.';
$PALANG['pAdminEdit_domain_welcome'] = 'Edit a domain';
$PALANG['pAdminEdit_domain_domain'] = 'Domain';
@@ -205,17 +205,17 @@ $PALANG['pAdminEdit_domain_active'] = 'Active';
$PALANG['pAdminEdit_domain_button'] = 'Edit Domain';
$PALANG['pAdminEdit_domain_result_error'] = 'Unable to modify domain.';
-$PALANG['pAdminCreate_admin_welcome'] = 'Add a new domain admin';
-$PALANG['pAdminCreate_admin_username'] = 'Admin (email address)';
-$PALANG['pAdminCreate_admin_username_error'] = 'Admin already exists or is not valid.';
-$PALANG['pAdminCreate_admin_password1'] = 'Password';
-$PALANG['pAdminCreate_admin_password2'] = 'Password (again)';
-$PALANG['pAdminCreate_admin_password_error'] = 'The passwords you supplied don\'t match, or are empty.';
-$PALANG['pAdminCreate_admin_domain_error'] = 'No domains selected.';
-$PALANG['pAdminCreate_admin_button'] = 'Add Admin';
-$PALANG['pAdminCreate_admin_result_error'] = 'Unable to add admin.';
-$PALANG['pAdminCreate_admin_result_succes'] = 'Admin has been added.';
-$PALANG['pAdminCreate_admin_address'] = 'Domain';
+$PALANG['pAdminAdd_admin_welcome'] = 'Add a new domain admin';
+$PALANG['pAdminAdd_admin_username'] = 'Admin (email address)';
+$PALANG['pAdminAdd_admin_username_error'] = 'Admin already exists or is not valid.';
+$PALANG['pAdminAdd_admin_password1'] = 'Password';
+$PALANG['pAdminAdd_admin_password2'] = 'Password (again)';
+$PALANG['pAdminAdd_admin_password_error'] = 'The passwords you supplied don\'t match, or are empty.';
+$PALANG['pAdminAdd_admin_domain_error'] = 'No domains selected.';
+$PALANG['pAdminAdd_admin_button'] = 'Add Admin';
+$PALANG['pAdminAdd_admin_result_error'] = 'Unable to add admin.';
+$PALANG['pAdminAdd_admin_result_succes'] = 'Admin has been added.';
+$PALANG['pAdminAdd_admin_address'] = 'Domain';
$PALANG['pAdminEdit_admin_welcome'] = 'Edit a domain admin';
$PALANG['pAdminEdit_admin_username'] = 'Admin';
diff --git a/templates/admin_admin.tpl b/templates/admin_admin.tpl
index 25b8a7c..6b2d2d4 100644
--- a/templates/admin_admin.tpl
+++ b/templates/admin_admin.tpl
@@ -2,22 +2,30 @@