commit - 81954500f3ed7441609824a68d21351f0f875155
commit + 461ed9a53b7c9de7dff3b543bb45460bee4cb085
blob - 29144aee14ec66f8f8f960a6cc68c425168cdf23
blob + 6da9fc0a22a2280cc39ec0f3351d99b66d1bde7b
--- .gitignore
+++ .gitignore
+conf.php
config.inc.php
admin/.htpasswd
blob - /dev/null
blob + 89039a31eda8192a52a50a5c1c3ef37bc186c73f (mode 644)
--- /dev/null
+++ admin/add-admin.php
+<?php
+//
+// OpenSMTPD Admin
+// by Mischa Peters <mischa at high5 dot nl>
+// Copyright (c) 2022 High5!
+// License Info: LICENSE.TXT
+//
+// File: create-admin.php
+//
+// Template File: admin_create-admin.tpl
+//
+//
+// Template Variables:
+//
+// tMessage
+// tUsername
+// tDomains
+//
+// Form POST \ GET Variables:
+//
+// fUsername
+// fPassword
+// fPassword2
+// fDomains
+//
+require("../variables.inc.php");
+require("../config.inc.php");
+require("../functions.inc.php");
+include("../languages/" . check_language() . ".lang");
+
+$list_domains = list_domains();
+$list_admins = list_admins();
+
+if ($_SERVER['REQUEST_METHOD'] == "POST") {
+ $username = filter_input(INPUT_POST, 'username', FILTER_VALIDATE_EMAIL);
+ $password1 = filter_input(INPUT_POST, 'password1', FILTER_DEFAULT);
+ $password2 = filter_input(INPUT_POST, 'password2', FILTER_DEFAULT);
+ $domains = filter_input_array(INPUT_POST, array('domains' => array('filter' => FILTER_VALIDATE_DOMAIN, 'flags' => FILTER_REQUIRE_ARRAY)));
+
+ if (empty($username) || in_array($username, array_column($list_admins, 'username'))) {
+ $message = $PALANG['pAdminCreate_admin_username_error'];
+ }
+
+ if (empty($password1) or ($password1 != $password2)) {
+ $message = $PALANG['pAdminCreate_admin_password_error'];
+ }
+
+ if (empty($domains['domains'])) {
+ $message = $PALANG['pAdminCreate_admin_domain_error'];
+ }
+
+ if (empty($message)) {
+ $hashed = bcrypt($password1);
+ try {
+ $dbh = connect_db();
+ $sth = $dbh->prepare("INSERT INTO admin (username,password,created,modified) VALUES (?,?,NOW(),NOW())");
+ $sth->bindParam(1, $username, PDO::PARAM_STR);
+ $sth->bindParam(2, $hashed, PDO::PARAM_STR);
+ $sth->execute();
+ foreach ($domains['domains'] as $row) {
+ $sth = $dbh->prepare("INSERT INTO domain_admins (username,domain,created) VALUES (?,?,NOW())");
+ $sth->bindParam(1, $username, PDO::PARAM_STR);
+ $sth->bindParam(2, $row, PDO::PARAM_STR);
+ $sth->execute();
+ }
+ $message = $PALANG['pAdminCreate_admin_result_succes'] . "<br />($username)</br />";
+ } catch(PDOException $e) {
+ $message = $PALANG['pAdminCreate_admin_result_error'] . "<br />($username)<br />";
+ }
+ }
+
+}
+include("../templates/header.tpl");
+include("../templates/admin_menu.tpl");
+include("../templates/admin_create-admin.tpl");
+include("../templates/footer.tpl");
+?>
blob - fa28d2fca200acdc3a03579bd6d78d6d5b382085
blob + 292d8ff983e2fb803d970b1976576648cce4c362
--- admin/create-admin.php
+++ admin/create-admin.php
include("../languages/" . check_language() . ".lang");
$list_domains = list_domains();
+$list_admins = list_admins();
-if ($_SERVER['REQUEST_METHOD'] == "GET") {
- $pAdminCreate_admin_username_text = $PALANG['pAdminCreate_admin_username_text'];
- $tDomains = array();
-
- include("../templates/header.tpl");
- include("../templates/admin_menu.tpl");
- include("../templates/admin_create-admin.tpl");
- include("../templates/footer.tpl");
-}
-
if ($_SERVER['REQUEST_METHOD'] == "POST") {
- $fUsername = escape_string($_POST['fUsername']);
- $fPassword = escape_string($_POST['fPassword']);
- $fPassword2 = escape_string($_POST['fPassword2']);
- if (isset($_POST['fDomains'])) $tDomains = $_POST['fDomains'];
+ $username = filter_input(INPUT_POST, 'username', FILTER_VALIDATE_EMAIL);
+ $password1 = filter_input(INPUT_POST, 'password1', FILTER_DEFAULT);
+ $password2 = filter_input(INPUT_POST, 'password2', FILTER_DEFAULT);
+ $domains = filter_input_array(INPUT_POST, array('domains' => array('filter' => FILTER_VALIDATE_DOMAIN, 'flags' => FILTER_REQUIRE_ARRAY)));
- if (!check_email($fUsername)) {
- $error = 1;
- $tUsername = escape_string($_POST['fUsername']);
- if (isset($_POST['fDomains'])) $tDomains = $_POST['fDomains'];
- $pAdminCreate_admin_username_text = $PALANG['pAdminCreate_admin_username_text_error1'];
+ if (empty($username) || in_array($username, array_column($list_admins, 'username'))) {
+ $message = $PALANG['pAdminCreate_admin_username_error'];
}
- if (empty($fUsername) or admin_exist($fUsername)) {
- $error = 1;
- $tUsername = escape_string($_POST['fUsername']);
- if (isset($_POST['fDomains'])) $tDomains = $_POST['fDomains'];
- $pAdminCreate_admin_username_text = $PALANG['pAdminCreate_admin_username_text_error2'];
+ if (empty($password1) or ($password1 != $password2)) {
+ $message = $PALANG['pAdminCreate_admin_password_error'];
}
-
- if (empty($fPassword) or ($fPassword != $fPassword2)) {
- $error = 1;
- $tUsername = escape_string($_POST['fUsername']);
- if (isset($_POST['fDomains'])) $tDomains = $_POST['fDomains'];
- $pAdminCreate_admin_username_text = $PALANG['pAdminCreate_admin_username_text'];
- $pAdminCreate_admin_password_text = $PALANG['pAdminCreate_admin_password_text_error'];
+
+ if (empty($domains['domains'])) {
+ $message = $PALANG['pAdminCreate_admin_domain_error'];
}
- if ($error != 1) {
- $password = pacrypt("$fPassword");
- $pAdminCreate_admin_username_text = $PALANG['pAdminCreate_admin_username_text'];
-
-
- $result = db_query("INSERT INTO admin (username,password,created,modified) VALUES ('$fUsername','$password',NOW(),NOW())");
- if ($result['rows'] != 1) {
- $tMessage = $PALANG['pAdminCreate_admin_result_error'] . "<br />($fUsername)<br />";
- } else {
- if (!empty($tDomains[0])) {
- for ($i = 0; $i < count($tDomains); $i++) {
- $domain = $tDomains[$i];
- $result = db_query("INSERT INTO domain_admins (username,domain,created) VALUES ('$fUsername','$domain',NOW())");
- }
+ if (empty($message)) {
+ $hashed = bcrypt($password1);
+ try {
+ $dbh = connect_db();
+ $sth = $dbh->prepare("INSERT INTO admin (username,password,created,modified) VALUES (?,?,NOW(),NOW())");
+ $sth->bindParam(1, $username, PDO::PARAM_STR);
+ $sth->bindParam(2, $hashed, PDO::PARAM_STR);
+ $sth->execute();
+ foreach ($domains['domains'] as $row) {
+ $sth = $dbh->prepare("INSERT INTO domain_admins (username,domain,created) VALUES (?,?,NOW())");
+ $sth->bindParam(1, $username, PDO::PARAM_STR);
+ $sth->bindParam(2, $row, PDO::PARAM_STR);
+ $sth->execute();
}
- $tMessage = $PALANG['pAdminCreate_admin_result_succes'] . "<br />($fUsername)</br />";
- }
+ $message = $PALANG['pAdminCreate_admin_result_succes'] . "<br />($username)</br />";
+ } catch(PDOException $e) {
+ $message = $PALANG['pAdminCreate_admin_result_error'] . "<br />($username)<br />";
+ }
}
- include("../templates/header.tpl");
- include("../templates/admin_menu.tpl");
- include("../templates/admin_create-admin.tpl");
- include("../templates/footer.tpl");
}
+include("../templates/header.tpl");
+include("../templates/admin_menu.tpl");
+include("../templates/admin_create-admin.tpl");
+include("../templates/footer.tpl");
?>
blob - 6c54a20be4d06984f5e0b38ba4a22742bee208f2
blob + d66b1a58124ec160f945fded5242b99f1d37cc89
--- admin/create-alias.php
+++ admin/create-alias.php
// tMessage
// tAddress
// tGoto
-// tDomain
+// domain
//
// Form POST \ GET Variables:
//
-// fAddress
+// address
// fGoto
-// fDomain
+// domain
//
require("../variables.inc.php");
require("../config.inc.php");
$list_domains = list_domains();
-if ($_SERVER['REQUEST_METHOD'] == "GET") {
- $pCreate_alias_goto_text = $PALANG['pCreate_alias_goto_text'];
-
- if (isset($_GET['domain'])) $tDomain = escape_string($_GET['domain']);
-}
-
if ($_SERVER['REQUEST_METHOD'] == "POST") {
- $pCreate_alias_goto_text = $PALANG['pCreate_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'));
- $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 (!preg_match('/@/',$fGoto)) {
- $fGoto = $fGoto . "@" . escape_string($_POST['fDomain']);
+ $from = filter_var($address . '@' . $domain, FILTER_VALIDATE_EMAIL);
+ if (!str_contains($goto, '@')) {
+ $goto = $goto . "@" . $domain;
}
-
- if (!check_alias($fDomain)) {
- $error = 1;
- $tAddress = escape_string($_POST['fAddress']);
- $tGoto = $fGoto;
- $tDomain = $fDomain;
- $pCreate_alias_address_text = $PALANG['pCreate_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 = $PALANG['pCreate_alias_address_text_error1'];
- }
+ $goto = filter_var($goto, FILTER_VALIDATE_EMAIL);
- if (empty($fGoto) or !check_email($fGoto))
- {
- $error = 1;
- $tAddress = escape_string($_POST['fAddress']);
- $tGoto = $fGoto;
- $tDomain = $fDomain;
- $pCreate_alias_goto_text = $PALANG['pCreate_alias_goto_text_error'];
+ if ($list_domains[$domain_key]['alias_count'] < 0 || $list_domains[$domain_key]['alias_count'] >= $list_domains[$domain_key]['aliases']) {
+ $message = $PALANG['pCreate_alias_address_text_error2'];
}
- 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 = $PALANG['pCreate_alias_address_text_error2'];
+ if (empty($address) || empty($goto)) {
+ $message = $PALANG['pCreate_alias_address_text_error1'];
}
- 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 = $PALANG['pCreate_alias_result_error'] . "<br />($fAddress -> $fGoto)<br />";
- } else {
- db_log($CONF['admin_email'], $fDomain, "create alias", "$fAddress -> $fGoto");
-
- $tDomain = $fDomain;
- $tMessage = $PALANG['pCreate_alias_result_succes'] . "<br />($fAddress -> $fGoto)</br />";
+ if (empty($message)) {
+ 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_EMAIL, $domain, "create alias", "$from -> $goto");
+ $message = $PALANG['pCreate_alias_result_succes'] . "<br />($from -> $goto)</br />";
+ $address = '';
+ $goto = '';
+ } catch(PDOException $e) {
+ $message = $PALANG['pCreate_alias_result_error'] . "<br />($from -> $goto) - $e<br />";
}
}
}
blob - cd5ed76efe610f1286d548fd3e5542f7f0c9fb26
blob + 81f855d525d9b14946d07009fa0f0f89d37613fe
--- admin/create-domain.php
+++ admin/create-domain.php
// fMaxquota
// fDefaultaliases
//
-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';
-if ($_SERVER['REQUEST_METHOD'] == "GET") {
- $tAliases = $CONF['aliases'];
- $tMailboxes = $CONF['mailboxes'];
- $tMaxquota = $CONF['maxquota'];
-}
-
if ($_SERVER['REQUEST_METHOD'] == "POST") {
- $fDomain = escape_string($_POST['fDomain']);
- !empty($_POST['fDescription']) ? $fDescription = escape_string($_POST['fDescription']) : $fDescription = "No Description";
- $fAliases = escape_string($_POST['fAliases']);
- $fMailboxes = escape_string($_POST['fMailboxes']);
- !empty($_POST['fMaxquota']) ? $fMaxquota = escape_string($_POST['fMaxquota']) : $fMaxquota = "0";
- !empty($_POST['fTransport']) ? $fTransport = escape_string($_POST['fTransport']) : $fTransport = "virtual";
- if (isset($_POST['fDefaultaliases'])) $fDefaultaliases = escape_string($_POST['fDefaultaliases']);
- isset($_POST['fBackupmx']) ? $fBackupmx = escape_string($_POST['fBackupmx']) : $fBackupmx = "0";
- if (empty($fDomain) or domain_exist($fDomain)) {
- $error = 1;
- $tDomain = escape_string($_POST['fDomain']);
- $tDescription = escape_string($_POST['fDescription']);
- $tAliases = escape_string($_POST['fAliases']);
- $tMailboxes = escape_string($_POST['fMailboxes']);
- if (isset($_POST['fMaxquota'])) $tMaxquota = escape_string($_POST['fMaxquota']);
- if (isset($_POST['fTransport'])) $tTransport = escape_string($_POST['fTransport']);
- if (isset($_POST['fDefaultaliases'])) $tDefaultaliases = escape_string($_POST['fDefaultaliases']);
- if (isset($_POST['fBackupmx'])) $tBackupmx = escape_string($_POST['fBackupmx']);
- $pAdminCreate_domain_domain_text = $PALANG['pAdminCreate_domain_domain_text_error'];
- }
-
- if ($error != 1) {
- $tAliases = $CONF['aliases'];
- $tMailboxes = $CONF['mailboxes'];
- $tMaxquota = $CONF['maxquota'];
+ $list_domains = list_domains();
- if ($fBackupmx == "on") {
- $fAliases = -1;
- $fMailboxes = -1;
- $fMaxquota = -1;
- $fBackupmx = 1;
- } else {
- $fBackupmx = 0;
+ $domain = strtolower(filter_input(INPUT_POST, 'domain', FILTER_VALIDATE_DOMAIN));
+ $description = filter_input(INPUT_POST, 'description', FILTER_CALLBACK, array('options' => 'htmlspecialchars'));
+ $aliases = filter_input(INPUT_POST, 'aliases', FILTER_VALIDATE_INT);
+ $mailboxes = filter_input(INPUT_POST, 'mailboxes', FILTER_VALIDATE_INT);
+
+ if (!in_array($domain, array_column($list_domains, 'domain'))) {
+ try {
+ $dbh = connect_db();
+ $sth = $dbh->prepare("INSERT INTO domain (domain,description,aliases,mailboxes,created,modified) VALUES (?,?,?,?,NOW(),NOW())");
+ $sth->bindParam(1, $domain, PDO::PARAM_STR);
+ $sth->bindParam(2, $description, PDO::PARAM_STR);
+ $sth->bindParam(3, $aliases, PDO::PARAM_INT);
+ $sth->bindParam(4, $mailboxes, PDO::PARAM_INT);
+ $sth->execute();
+ $message = $PALANG['pAdminCreate_domain_result_succes'] . "<br />($domain)</br />";
+ } catch(PDOException $e) {
+ $message = $PALANG['pAdminCreate_domain_result_error'] . "<br />($domain)<br />";
}
-
- $result = db_query("INSERT INTO domain (domain,description,aliases,mailboxes,maxquota,transport,backupmx,created,modified) VALUES ('$fDomain','$fDescription',$fAliases,$fMailboxes,$fMaxquota,'$fTransport',$fBackupmx,NOW(),NOW())");
- if ($result['rows'] != 1) {
- $tMessage = $PALANG['pAdminCreate_domain_result_error'] . "<br />($fDomain)<br />";
- } else {
- if ($fDefaultaliases == "on") {
- foreach ($CONF['default_aliases'] as $address=>$goto) {
- $address = $address . "@" . $fDomain;
- $result = db_query("INSERT INTO alias (address,goto,domain,created,modified) VALUES ('$address','$goto','$fDomain',NOW(),NOW())");
- }
- }
- $tMessage = $PALANG['pAdminCreate_domain_result_succes'] . "<br />($fDomain)</br />";
- }
+ } else {
+ $message = $PALANG['pAdminCreate_domain_domain_text_error'];
}
}
-include("../templates/header.tpl");
-include("../templates/admin_menu.tpl");
-include("../templates/admin_create-domain.tpl");
-include("../templates/footer.tpl");
+
+include '../templates/header.tpl';
+include '../templates/admin_menu.tpl';
+include '../templates/admin_create-domain.tpl';
+include '../templates/footer.tpl';
?>
blob - a36a41f0d9a0ddd9445c89ed8d9d20bc65a658f3
blob + 59f8fa92ecc0def2a5b0875b2fc8fa19e9df228b
--- admin/delete.php
+++ admin/delete.php
//
// Form POST \ GET Variables:
//
-// fTable
-// fWhere
-// fDelete
-// fDomain
+// table
+// where
+// delete
+// domain
//
-require("../variables.inc.php");
-require("../config.inc.php");
-require("../functions.inc.php");
+require_once("../functions.inc.php");
include("../languages/" . check_language() . ".lang");
if ($_SERVER['REQUEST_METHOD'] == "GET") {
- if (isset($_GET['table'])) $fTable = escape_string($_GET['table']);
- if (isset($_GET['where'])) $fWhere = escape_string($_GET['where']);
- if (isset($_GET['delete'])) $fDelete = escape_string($_GET['delete']);
- if (isset($_GET['domain'])) $fDomain = escape_string($_GET['domain']);
-
- if (empty($fTable)) {
- $error = 1;
- }
-
- if ($fTable == "domain") {
- $result_domain = db_delete("domain",$fWhere,$fDelete);
- $result_domain_admins = db_delete("domain_admins",$fWhere,$fDelete);
- $result_alias = db_delete("alias",$fWhere,$fDelete);
- $result_mailbox = db_delete("mailbox",$fWhere,$fDelete);
- $result_log = db_delete("log",$fWhere,$fDelete);
- if ($CONF['vacation'] == "YES") {
- $result_vacation = db_delete("vacation",$fWhere,$fDelete);
- }
+ $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);
- if (!($result_domain == 1) and ($result_domain_admins >= 0) and ($result_alias >= 0) and ($result_mailbox >= 0) and ($result_vacation >= 0)) {
- $error = 1;
- $tMessage = $PALANG['pAdminDelete_domain_error'];
- } else {
- $url = "list-domain.php";
+ if ($table == "domain") {
+ try {
+ $dbh = connect_db();
+ $dbh->beginTransaction();
+
+ $sth = $dbh->prepare("SELECT COUNT(*) FROM log WHERE domain=?");
+ $sth->execute(array($domain));
+ $count_log = $sth->fetchColumn();
+
+ $sth = $dbh->prepare("DELETE FROM log WHERE domain=?");
+ $sth->execute(array($domain));
+ if ($sth->rowCount() != $count_log) {
+ throw new RuntimeException('Unable to delete entries from the logs table.');
+ }
+
+ $sth = $dbh->prepare("SELECT COUNT(*) FROM vacation WHERE domain=?");
+ $sth->execute(array($domain));
+ $count_vacation = $sth->fetchColumn();
+
+ $sth = $dbh->prepare("DELETE FROM vacation WHERE domain=?");
+ $sth->execute(array($domain));
+ if ($sth->rowCount() != $count_vacation) {
+ throw new RuntimeException('Unable to delete entries from the vacation table.');
+ }
+
+ $sth = $dbh->prepare("SELECT COUNT(*) FROM alias WHERE domain=?");
+ $sth->execute(array($domain));
+ $count_alias = $sth->fetchColumn();
+
+ $sth = $dbh->prepare("DELETE FROM alias WHERE domain=?");
+ $sth->execute(array($domain));
+ if ($sth->rowCount() != $count_alias) {
+ throw new RuntimeException('Unable to delete entries from the alias table.');
+ }
+
+ $sth = $dbh->prepare("SELECT COUNT(*) FROM mailbox WHERE domain=?");
+ $sth->execute(array($domain));
+ $count_mailbox = $sth->fetchColumn();
+
+ $sth = $dbh->prepare("DELETE FROM mailbox WHERE domain=?");
+ $sth->execute(array($domain));
+ if ($sth->rowCount() != $count_mailbox) {
+ throw new RuntimeException('Unable to delete entries from the mailbox table.');
+ }
+
+ $sth = $dbh->prepare("SELECT COUNT(*) FROM domain_admins WHERE domain=?");
+ $sth->execute(array($domain));
+ $count_domain_admins = $sth->fetchColumn();
+
+ $sth = $dbh->prepare("DELETE FROM domain_admins WHERE domain=?");
+ $sth->execute(array($domain));
+ if ($sth->rowCount() != $count_domain_admins) {
+ throw new RuntimeException('Unable to delete entries from the domain_admins table.');
+ }
+
+ $sth = $dbh->prepare("SELECT COUNT(*) FROM domain WHERE domain=?");
+ $sth->execute(array($domain));
+ $count_domain = $sth->fetchColumn();
+
+ $sth = $dbh->prepare("DELETE FROM domain WHERE domain=?");
+ $sth->execute(array($domain));
+ if ($sth->rowCount() != $count_domain) {
+ throw new RuntimeException('Unable to delete entry from the domain table.');
+ }
+
+ $dbh->commit();
+ header("Location: list-domain.php");
+ } catch (RuntimeException $e) {
+ $message = $e->getMessage();
+ $dbh->rollBack();
+ } catch (PDOException $e) {
+ $message = $e->getMessage();
}
}
- if ($fTable == "admin") {
- $result_admin = db_delete("admin",$fWhere,$fDelete);
- $result_domain_admins = db_delete("domain_admins",$fWhere,$fDelete);
-
- if (!($result_admin == 1) and ($result_domain_admins >= 0)) {
- $error = 1;
- $tMessage = $PALANG['pAdminDelete_admin_error'];
- } else {
- $url = "list-admin.php";
+ if ($table == "admin") {
+ try {
+ $dbh = connect_db();
+ $dbh->beginTransaction();
+
+ $sth = $dbh->prepare("SELECT COUNT(*) FROM admin WHERE username=?");
+ $sth->execute(array($delete));
+ $count_admin = $sth->fetchColumn();
+
+ $sth = $dbh->prepare("DELETE FROM admin WHERE username=?");
+ $sth->execute(array($delete));
+ if ($sth->rowCount() != $count_admin) {
+ throw new RuntimeException('Unable to delete entry from the admin table.');
+ }
+
+ $sth = $dbh->prepare("SELECT COUNT(*) FROM domain_admins WHERE username=?");
+ $sth->execute(array($delete));
+ $count_domain_admins = $sth->fetchColumn();
+
+ $sth = $dbh->prepare("DELETE FROM domain_admins WHERE username=?");
+ $sth->execute(array($delete));
+ if ($sth->rowCount() != $count_domain_admins) {
+ throw new RuntimeException('Unable to delete entries from the domain_admins table.');
+ }
+
+ $dbh->commit();
+ header("Location: list-admin.php");
+ } catch (RuntimeException $e) {
+ $message = $e->getMessage();
+ $dbh->rollBack();
+ } catch (PDOException $e) {
+ $message = $e->getMessage();
}
}
- if ($fTable == "alias" or $fTable == "mailbox") {
- $result = db_query("DELETE FROM alias WHERE address='$fDelete' AND domain='$fDomain'");
- if ($result['rows'] != 1) {
- $error = 1;
- $tMessage = $PALANG['pDelete_delete_error'] . "<b>$fDelete</b> (alias)!</div>";
- } else {
- $url = "list-virtual.php?domain=$fDomain";
- db_log($CONF['admin_email'], $fDomain, "delete alias", $fDelete);
+ if ($table == 'alias' || $table == 'mailbox') {
+ 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_EMAIL, $domain, "delete alias", $delete);
+
+ header("Location: list-virtual.php?domain=$domain");
+ } catch (RuntimeException $e) {
+ $message = $PALANG['pDelete_delete_error'] . "<b>$delete</b> (" . $e->getMessage() . ")!</span>";
+ } catch (PDOException $e) {
+ $message = $PALANG['pDelete_delete_error'] . "<b>$delete</b> (alias)!</span> " . $e-getMessage();
}
- $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 = $PALANG['pDelete_delete_error'] . "<b>$fDelete</b> (mailbox)!</div>";
- } else {
- $url = "list-virtual.php?domain=$fDomain";
- db_query("DELETE FROM vacation WHERE email='$fDelete' AND domain='$fDomain'");
- db_log($CONF['admin_email'], $fDomain, "delete mailbox", $fDelete);
+ 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_EMAIL, $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");
+ } catch (RuntimeException $e) {
+ $message = $PALANG['pDelete_delete_error'] . "<b>$delete</b> (" . $e->getMessage() . ")!</span>";
+ } catch (PDOException $e) {
+ $message = $PALANG['pDelete_delete_error'] . "<b>$delete</b> (mailbox)!</span>";
}
}
-
- if ($error != 1) {
- header("Location: $url");
- exit;
- }
}
include("../templates/header.tpl");
include("../templates/admin_menu.tpl");
blob - /dev/null
blob + 9055b22c145c4f51fb791c36623d7dc3461ca01f (mode 644)
--- /dev/null
+++ admin/domain.php
+<?php
+//
+// OpenSMTPD Admin
+// by Mischa Peters <mischa at high5 dot nl>
+// Copyright (c) 2022 High5!
+// License Info: LICENSE.TXT
+//
+// File: create-domain.php
+//
+// Template File: admin_create-domain.tpl
+//
+// Template Variables:
+//
+// tMessage
+// tDomain
+// tDescription
+// tAliases
+// tMailboxes
+// tMaxquota
+// tDefaultaliases
+//
+// Form POST \ GET Variables:
+//
+// fDomain
+// fDescription
+// fAliases
+// fMailboxes
+// fMaxquota
+// fDefaultaliases
+//
+require_once '../functions.inc.php';
+include '../languages/' . check_language() . '.lang';
+
+$list_domains = list_domains();
+
+if ($_SERVER['REQUEST_METHOD'] == "GET") {
+ $action = filter_input(INPUT_GET, 'action', FILTER_DEFAULT) ?? 'new';
+ if ($action == 'edit') {
+ $domain = filter_input(INPUT_GET, 'domain', FILTER_VALIDATE_DOMAIN);
+ $domain_key = array_search($domain, array_column($list_domains, 'domain'));
+ $description = $list_domains[$domain_key]['description'];
+ $aliases = $list_domains[$domain_key]['aliases'];
+ $mailboxes = $list_domains[$domain_key]['mailboxes'];
+ }
+}
+
+if ($_SERVER['REQUEST_METHOD'] == "POST") {
+ $action = filter_input(INPUT_GET, 'action', FILTER_DEFAULT) ?? 'new';
+ $domain = strtolower(filter_input(INPUT_POST, 'domain', FILTER_VALIDATE_DOMAIN));
+ $description = filter_input(INPUT_POST, 'description', FILTER_CALLBACK, array('options' => 'htmlspecialchars'));
+ $aliases = filter_input(INPUT_POST, 'aliases', FILTER_VALIDATE_INT);
+ $mailboxes = filter_input(INPUT_POST, 'mailboxes', FILTER_VALIDATE_INT);
+
+ if (!in_array($domain, array_column($list_domains, 'domain'))) {
+ try {
+ $dbh = connect_db();
+ $sth = $dbh->prepare("INSERT INTO domain (domain,description,aliases,mailboxes,created,modified) VALUES (?,?,?,?,NOW(),NOW())");
+ $sth->bindParam(1, $domain, PDO::PARAM_STR);
+ $sth->bindParam(2, $description, PDO::PARAM_STR);
+ $sth->bindParam(3, $aliases, PDO::PARAM_INT);
+ $sth->bindParam(4, $mailboxes, PDO::PARAM_INT);
+ $sth->execute();
+ $message = $PALANG['pAdminCreate_domain_result_succes'] . "<br />($domain)</br />";
+ } catch(PDOException $e) {
+ $message = $PALANG['pAdminCreate_domain_result_error'] . "<br />($domain)<br />";
+ }
+ } else {
+ $message = $PALANG['pAdminCreate_domain_domain_text_error'];
+ }
+
+ if (in_array($domain, array_column($list_domains, 'domain')) && $action == 'edit') {
+ try {
+ $dbh = connect_db();
+ $sth = $dbh->prepare("UPDATE domain SET description=?,aliases=?,mailboxes=?,modified=NOW() WHERE domain=?");
+ $sth->bindParam(1, $description, PDO::PARAM_STR);
+ $sth->bindParam(2, $aliases, PDO::PARAM_INT);
+ $sth->bindParam(3, $mailboxes, PDO::PARAM_INT);
+ $sth->bindParam(4, $domain, PDO::PARAM_STR);
+ $sth->execute();
+ header("Location: list-domain.php");
+ } catch(PDOException $e) {
+ $message = $PALANG['pAdminEdit_domain_result_error'];
+ }
+ }
+}
+
+include '../templates/header.tpl';
+include '../templates/admin_menu.tpl';
+include '../templates/admin_domain.tpl';
+include '../templates/footer.tpl';
+?>
blob - 351ba00448d694c074ed164916d34b939d8de54d
blob + d725e1c5ecc499e70b7ea20644fcc691a3aad014
--- admin/edit-domain.php
+++ admin/edit-domain.php
// fMaxquota
// fActive
//
-require("../variables.inc.php");
-require("../config.inc.php");
require("../functions.inc.php");
include("../languages/" . check_language() . ".lang");
+$list_domains = list_domains();
+
if ($_SERVER['REQUEST_METHOD'] == "GET") {
- $domain = escape_string($_GET['domain']);
- $domain_properties = get_domain_properties($domain);
-
- $tDescription = $domain_properties['description'];
- $tAliases = $domain_properties['aliases'];
- $tMailboxes = $domain_properties['mailboxes'];
- $tMaxquota = $domain_properties['maxquota'];
- $tTransport = $domain_properties['transport'];
- $tBackupmx = $domain_properties['backupmx'];
- $tActive = $domain_properties['active'];
+ $action = filter_input(INPUT_GET, 'action', FILTER_DEFAULT);
+ $domain = filter_input(INPUT_GET, 'domain', FILTER_VALIDATE_DOMAIN);
+ $domain_key = array_search($domain, array_column($list_domains, 'domain'));
+ $description = $list_domains[$domain_key]['description'];
+ $aliases = $list_domains[$domain_key]['aliases'];
+ $mailboxes = $list_domains[$domain_key]['mailboxes'];
}
if ($_SERVER['REQUEST_METHOD'] == "POST") {
$fDescription = escape_string($_POST['fDescription']);
$fAliases = escape_string($_POST['fAliases']);
$fMailboxes = escape_string($_POST['fMailboxes']);
- if (isset($_POST['fMaxquote']) ? $fMaxquota = escape_string($_POST['fMaxquota']) : $fMaxquota = "0");
- if (isset($_POST['fTransport'])) $fTransport = escape_string($_POST['fTransport']);
- if (isset($_POST['fBackupmx'])) $fBackupmx = escape_string($_POST['fBackupmx']);
- if (isset($_POST['fActive'])) $fActive = escape_string($_POST['fActive']);
- if ($fBackupmx == "on") {
- $fAliases = -1;
- $fMailboxes = -1;
- $fMaxquota = -1;
- $fBackupmx = 1;
- } else {
- $fBackupmx = 0;
- }
-
- $fActive = ($fActive == "on" ? 1 : 0);
$result = db_query("UPDATE domain SET description='$fDescription',aliases='$fAliases',mailboxes='$fMailboxes',maxquota='$fMaxquota',transport='$fTransport',backupmx='$fBackupmx',active='$fActive',modified=NOW() WHERE domain='$domain'");
if ($result['rows'] == 1) {
}
include("../templates/header.tpl");
include("../templates/admin_menu.tpl");
-include("../templates/admin_edit-domain.tpl");
+include("../templates/admin_add-domain.tpl");
include("../templates/footer.tpl");
?>
blob - e2f96c721e7581314c2a0f4c3c45c8d5063a1466
blob + d2ab8eb90cee982dcc343a3803ac31862571fe89
--- admin/list-admin.php
+++ admin/list-admin.php
//
// Template Variables:
//
-// -none-
+// list_admins
//
// Form POST \ GET Variables:
//
// -none-
//
-require("../variables.inc.php");
-require("../config.inc.php");
-require("../functions.inc.php");
-include("../languages/" . check_language() . ".lang");
+require '../functions.inc.php';
+include '../languages/' . check_language() . '.lang';
$list_admins = list_admins();
-if (!empty($list_admins)) {
- $list_admins_count = count($list_admins);
- if ((is_array($list_admins) and $list_admins_count > 0)) {
- for ($i = 0; $i < $list_admins_count; $i++) {
- $admin_properties[$i] = get_admin_properties($list_admins[$i]);
- }
- }
-}
-
-include("../templates/header.tpl");
-include("../templates/admin_menu.tpl");
-include("../templates/admin_list-admin.tpl");
-include("../templates/footer.tpl");
+include '../templates/header.tpl';
+include '../templates/admin_menu.tpl';
+include '../templates/admin_list-admin.tpl';
+include '../templates/footer.tpl';
?>
blob - 185ba574954c51c7ca64f93005e8e3f41feb8bc4
blob + 560f8c63730e48fe1b24ccf2a3ad91142563acd1
--- admin/list-domain.php
+++ admin/list-domain.php
//
// Template Variables:
//
-// -none-
+// list_domains
//
-// Form POST \ GET Variables:
+// Form GET Variables:
//
-// fUsername
+// username
//
-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_admins = list_admins();
if ($_SERVER['REQUEST_METHOD'] == "GET") {
- if (isset($_GET['username'])) {
- $fUsername = escape_string($_GET['username']);
-
- $list_domains = list_domains_for_admin($fUsername);
- if ($list_domains != 0) {
- for ($i = 0; $i < count($list_domains); $i++) {
- $domain_properties[$i] = get_domain_properties($list_domains[$i]);
- }
- }
- } else {
- $list_domains = list_domains();
- if ((is_array($list_domains) and count($list_domains) > 0)) {
- for ($i = 0; $i < count($list_domains); $i++) {
- $domain_properties[$i] = get_domain_properties($list_domains[$i]);
- }
- }
- }
+ $username = filter_input(INPUT_GET, 'username', FILTER_VALIDATE_EMAIL);
+ $list_domains = list_domains($username);
+} else {
+ $list_domains = list_domains();
}
-if ($_SERVER['REQUEST_METHOD'] == "POST") {
- $fUsername = escape_string($_POST['fUsername']);
-
- $list_domains = list_domains_for_admin($fUsername);
- if (!empty($list_domains)) {
- for ($i = 0; $i < count($list_domains); $i++) {
- $domain_properties[$i] = get_domain_properties($list_domains[$i]);
- }
- }
-}
-include("../templates/header.tpl");
-include("../templates/admin_menu.tpl");
-include("../templates/admin_list-domain.tpl");
-include("../templates/footer.tpl");
+include '../templates/header.tpl';
+include '../templates/admin_menu.tpl';
+include '../templates/admin_list-domain.tpl';
+include '../templates/footer.tpl';
?>
blob - 3f86a84ff7d40303e6544819f5f6c491b31d126c
blob + 0f84adaee1988711ada6fcfc8114036f00ab0fba
--- admin/list-virtual.php
+++ admin/list-virtual.php
//
// Template Variables:
//
-// tMessage
-// tAlias
-// tMailbox
+// list_alias
+// list_mailbox
//
-// Form POST \ GET Variables:
+// Form GET Variables:
//
-// fDomain
+// domain
+// offset
//
-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();
-$tAlias = array();
-$tMailbox = array();
-
if ($_SERVER['REQUEST_METHOD'] == "GET") {
- $fDisplay = 0;
- $page_size = $CONF['page_size'];
-
- if (isset($_GET['domain'])) $fDomain = escape_string($_GET['domain']);
- if (isset($_GET['limit'])) $fDisplay = escape_string($_GET['limit']);
-
- if ((is_array($list_domains) and count($list_domains) > 0)) if (empty($fDomain)) $fDomain = $list_domains[0];
-
- $limit = get_domain_properties($fDomain);
-
- if ((is_array($list_domains) and count($list_domains) > 0)) if (empty($fDomain)) $fDomain = $list_domains[1];
-
- if ($CONF['alias_control'] == "YES") {
- $query = "SELECT alias.address,alias.goto,alias.modified FROM alias WHERE alias.domain='$fDomain' ORDER BY alias.address LIMIT $fDisplay, $page_size";
- } else {
- $query = "SELECT alias.address,alias.goto,alias.modified FROM alias LEFT JOIN mailbox ON alias.address=mailbox.username WHERE alias.domain='$fDomain' AND mailbox.maildir IS NULL ORDER BY alias.address LIMIT $fDisplay, $page_size";
+ $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'));
+ $list_alias = list_aliases($domain, $offset, $limit);
+ $list_mailbox = list_mailboxes($domain, $offset, $limit);
}
-
- $result = db_query("$query");
- if ($result['rows'] > 0) {
- while ($row = db_array($result['result'])) {
- $tAlias[] = $row;
- }
- }
-
- $result = db_query("SELECT * FROM mailbox WHERE domain='$fDomain' ORDER BY username LIMIT $fDisplay, $page_size");
- if ($result['rows'] > 0) {
- while ($row = db_array($result['result'])) {
- $tMailbox[] = $row;
- }
- }
-
- if (isset($limit)) {
- if ($fDisplay >= $page_size) {
- $tDisplay_back_show = 1;
- $tDisplay_back = $fDisplay - $page_size;
- }
- if (($limit['alias_count'] > $page_size) or ($limit['mailbox_count'] > $page_size)) {
- $tDisplay_up_show = 1;
- }
- if ((($fDisplay + $page_size) < $limit['alias_count']) or (($fDisplay + $page_size) < $limit['mailbox_count'])) {
- $tDisplay_next_show = 1;
- $tDisplay_next = $fDisplay + $page_size;
- }
- }
}
-if ($_SERVER['REQUEST_METHOD'] == "POST") {
- $fDisplay = 0;
- $page_size = $CONF['page_size'];
-
- $fDomain = escape_string($_POST['fDomain']);
- if (isset($_POST['limit'])) $fDisplay = escape_string($_POST['limit']);
-
- $limit = get_domain_properties($fDomain);
-
- if ($CONF['alias_control'] == "YES") {
- $query = "SELECT alias.address,alias.goto,alias.modified FROM alias WHERE alias.domain='$fDomain' ORDER BY alias.address LIMIT $fDisplay, $page_size";
- } else {
- $query = "SELECT alias.address,alias.goto,alias.modified FROM alias LEFT JOIN mailbox ON alias.address=mailbox.username WHERE alias.domain='$fDomain' AND mailbox.maildir IS NULL ORDER BY alias.address LIMIT $fDisplay, $page_size";
- }
-
- $result = db_query("$query");
- if ($result['rows'] > 0) {
- while ($row = db_array($result['result'])) {
- $tAlias[] = $row;
- }
- }
-
- $result = db_query("SELECT * FROM mailbox WHERE domain='$fDomain' ORDER BY username LIMIT $fDisplay, $page_size");
- if ($result['rows'] > 0) {
- while ($row = db_array($result['result'])) {
- $tMailbox[] = $row;
- }
- }
-
- if (isset($limit)) {
- if ($fDisplay >= $page_size) {
- $tDisplay_back_show = 1;
- $tDisplay_back = $fDisplay - $page_size;
- }
- if (($limit['alias_count'] > $page_size) or ($limit['mailbox_count'] > $page_size)) {
- $tDisplay_up_show = 1;
- }
- if ((($fDisplay + $page_size) < $limit['alias_count']) or (($fDisplay + $page_size) < $limit['mailbox_count'])) {
- $tDisplay_next_show = 1;
- $tDisplay_next = $fDisplay + $page_size;
- }
- }
-}
-include("../templates/header.tpl");
-include("../templates/admin_menu.tpl");
-include("../templates/admin_list-virtual.tpl");
-include("../templates/footer.tpl");
+include '../templates/header.tpl';
+include '../templates/admin_menu.tpl';
+include '../templates/admin_list-virtual.tpl';
+include '../templates/footer.tpl';
?>
blob - 6fddc13292e78fa25154677d9f25b0303f89eb70
blob + fc9be7c398879dce9757eb523daed8fa5df04379
--- delete.php
+++ delete.php
include("./languages/" . check_language() . ".lang");
$SESSID_USERNAME = check_session();
+$list_domains = list_domains_for_admin($SESSID_USERNAME);
if ($_SERVER['REQUEST_METHOD'] == "GET") {
if (isset($_GET['delete'])) $fDelete = escape_string($_GET['delete']);
if (isset($_GET['domain'])) $fDomain = escape_string($_GET['domain']);
- if (!check_owner($SESSID_USERNAME, $fDomain)) {
+ if (in_array($_GET['domain'], array_column($list_domains, 'domain'))) {
+ #if (!check_owner($SESSID_USERNAME, $fDomain)) {
$error = 1;
$tMessage = $PALANG['pDelete_domain_error'] . "<b>$fDomain</b>!</div>";
} else {
blob - 6c9036f8a16227900dcd99c605be43801ec89f63
blob + 04de3e1f2306fcaea3c16ddf15641aaa14b26170
--- functions.inc.php
+++ functions.inc.php
exit;
}
+DEFINE("VERSION", "version 1.0.0");
+DEFINE('ROOT_PATH', dirname(__FILE__) . '/');
+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
//
-if ($CONF['debug'] == 'true') {
+if (DEBUG == 'true') {
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
return $escaped_string;
}
-//
-// get_domain_properties
-// Action: Get all the properties of a domain.
-// Call: get_domain_properties(string domain)
-//
-function get_domain_properties($domain) {
- global $CONF;
- $list = array();
-
- $result = db_query("SELECT COUNT(*) FROM alias WHERE domain='$domain'");
- $row = db_row($result['result']);
- $list['alias_count'] = $row[0];
-
- $result = db_query("SELECT COUNT(*) FROM mailbox WHERE domain='$domain'");
- $row = db_row($result['result']);
- $list['mailbox_count'] = $row[0];
- if ($CONF['alias_control'] == "NO") {
- $list['alias_count'] = $list['alias_count'] - $list['mailbox_count'];
- } else {
- $list['alias_count'] = $list['alias_count'];
- }
-
- $result = db_query("SELECT * FROM domain WHERE domain='$domain'");
- $row = db_array($result['result']);
- $list['description'] = $row['description'];
- $list['aliases'] = $row['aliases'];
- $list['mailboxes'] = $row['mailboxes'];
- $list['maxquota'] = $row['maxquota'];
- $list['transport'] = $row['transport'];
- $list['backupmx'] = $row['backupmx'];
- $list['created'] = $row['created'];
- $list['modified'] = $row['modified'];
- $list['active'] = $row['active'];
- if ($CONF['database_type'] == "pgsql") {
- if ($row['active'] == "t")
- {
- $list['active'] = 1;
- } else {
- $list['active'] = 0;
- }
-
- if ($row['backupmx'] == "t") {
- $list['backupmx'] = 1;
- } else {
- $list['backupmx'] = 0;
- }
- } else {
- $list['active'] = $row['active'];
- $list['backupmx'] = $row['backupmx'];
- }
- return $list;
-}
-
//
// check_alias
// Action: Checks if the domain is still able to create aliases.
return true;
}
}
-
//
-// check_quota
-// Action: Checks if the user is creating a mailbox with the correct quota
-// Call: check_quota(string domain)
+// connect_db
+// Action: make db connection
+// Call: connect_db()
//
-function check_quota($quota, $domain) {
- $limit = get_domain_properties($domain);
- if ($limit['maxquota'] == 0) {
- return true;
+function connect_db() {
+ try {
+ $dbh = new PDO(DB_TYPE . ':host='. DB_HOST . ';dbname='. DB_NAME , DB_USER, DB_PASS, array(PDO::ATTR_PERSISTENT => true));
+ $dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
+ return $dbh;
+ } catch (PDOException $e) {
+ echo 'Connection failed: ' . $e;
+ die();
}
- if (($limit['maxquota'] < 0) and ($quota < 0)) {
- return true;
- }
- if (($limit['maxquota'] > 0) and ($quota == 0)) {
- return false;
- }
- if ($quota > $limit['maxquota']) {
- return false;
- } else {
- return true;
- }
}
//
-// check_owner
-// Action: Checks if the admin is the owner of the domain.
-// Call: check_owner(string admin, string domain)
+// list_domains
+// Action: List all available domains.
+// Call: list_domains(string admin (optional))
//
-function check_owner($username, $domain) {
- $result = db_query("SELECT * FROM domain_admins WHERE username='$username' AND domain='$domain' AND active='1'");
- if ($result['rows'] != 1) {
- return false;
+function list_domains($username = null) {
+ $dbh = connect_db();
+ if (isset($username)) {
+ $sth = $dbh->prepare("SELECT * FROM domain INNER JOIN domain_admins ON domain.domain=domain_admins.domain WHERE domain_admins.username=? ORDER BY domain_admins.domain");
+ $sth->bindParam(1, $username, PDO::PARAM_STR);
} else {
- return true;
+ $sth = $dbh->prepare('SELECT * FROM domain ORDER BY domain');
}
+ $sth->execute();
+ $list= $sth->fetchAll();
+
+ for ($i = 0; $i < count($list); $i++) {
+ $sth = $dbh->prepare("SELECT COUNT(*) FROM alias WHERE domain=? AND goto NOT IN ('vmail')");
+ $sth->bindParam(1, $list[$i]['domain'], PDO::PARAM_STR);
+ $sth->execute();
+ $list[$i]['alias_count'] = $sth->fetchColumn();
+
+ $sth = $dbh->prepare("SELECT COUNT(*) FROM mailbox WHERE domain=?");
+ $sth->bindParam(1, $list[$i]['domain'], PDO::PARAM_STR);
+ $sth->execute();
+ $list[$i]['mailbox_count'] = $sth->fetchColumn();
+ }
+ return $list;
}
//
-// list_domains_for_admin
-// Action: Lists all the domains for an admin.
-// Call: list_domains_for_admin(string admin)
+// list_aliases
+// Action: List all available aliases for domain.
+// Call: list_aliases(string domain, int offset)
//
-function list_domains_for_admin($username) {
- $list = array();
-
- $result = db_query("SELECT * FROM domain LEFT JOIN domain_admins ON domain.domain=domain_admins.domain WHERE domain_admins.username='$username' AND domain.active='1' AND domain.backupmx='0' ORDER BY domain_admins.domain");
- if ($result['rows'] > 0) {
- $i = 0;
- while ($row = db_array($result['result'])) {
- $list[$i] = $row['domain'];
- $i++;
- }
+function list_aliases($domain, $offset, $limit) {
+ $dbh = connect_db();
+ if (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 = $sth->fetchAll();
return $list;
}
//
-// list_domains
-// Action: List all available domains.
-// Call: list_domains()
+// list_mailboxes
+// Action: List all available mailboxes for domain.
+// Call: list_mailboxes(string domaini, int offset)
//
-function list_domains() {
- $list = array();
-
- $result = db_query("SELECT * FROM domain ORDER BY domain");
- if ($result['rows'] > 0) {
- $i = 0;
- while ($row = db_array($result['result'])) {
- $list[$i] = $row['domain'];
- $i++;
- }
- }
+function list_mailboxes($domain, $offset, $limit) {
+ $dbh = connect_db();
+ $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 = $sth->fetchAll();
return $list;
}
// Action: Lists all the admins
// Call: list_admins()
//
-// was admin_list_admins
-//
function list_admins() {
- $list = array();
-
- $result = db_query("SELECT * FROM admin ORDER BY username");
- if ($result['rows'] > 0) {
- $i = 0;
- while ($row = db_array($result['result'])) {
- $list[$i] = $row['username'];
- $i++;
- }
- }
- return $list;
-}
+ $dbh = new PDO(DB_TYPE . ':host='. DB_HOST . ';dbname='. DB_NAME , DB_USER, DB_PASS);
+ $sth = $dbh->prepare('SELECT * FROM admin ORDER BY username');
+ $sth->execute();
+ $list = $sth->fetchAll();
-//
-// get_admin_properties
-// Action: Get all the admin properties.
-// Call: get_admin_properties(string admin)
-function get_admin_properties($username) {
- $list = array();
-
- $result = db_query("SELECT COUNT(*) FROM domain_admins WHERE username='$username'");
- $row = db_row($result['result']);
- $list['domain_count'] = $row[0];
-
- $result = db_query("SELECT * FROM admin WHERE username='$username'");
- $row = db_array($result['result']);
- $list['created'] = $row['created'];
- $list['modified'] = $row['modified'];
- $list['active'] = $row['active'];
+ for ($i = 0; $i < count($list); $i++) {
+ $sth = $dbh->prepare("SELECT COUNT(*) FROM domain_admins WHERE username=?");
+ $sth->bindParam(1, $list[$i]['username'], PDO::PARAM_STR);
+ $sth->execute();
+ $list[$i]['domain_count'] = $sth->fetchColumn();
+ }
return $list;
}
}
//
-// pacrypt
-// Action: Encrypts password based on config settings
-// Call: pacrypt(string cleartextpassword)
+// bcrypt
+// Action: Hashs the password with bcrypt
+// Call: bcrypt(string cleartextpassword)
//
-function pacrypt($pw, $pw_db="") {
- global $CONF;
- $password = "";
-
- if ($CONF['encrypt'] == 'bcrypt') {
- $options = ['cost' => 8];
- $password = password_hash($pw, PASSWORD_BCRYPT, $options);
- $password = preg_replace('/\$2y\$/', '\$2b\$', $password);
- }
- return $password;
+function bcrypt($password) {
+ $options = ['cost' => 8];
+ $hashed = password_hash($password, PASSWORD_BCRYPT, $options);
+ $hashed = preg_replace('/\$2y\$/', '\$2b\$', $hashed);
+ return $hashed;
}
//
}
}
- if ($CONF['database_type'] == "pgsql") {
- if(function_exists("pg_connect")) {
- $connect_string = "host=" . $CONF['database_host'] . " dbname=" . $CONF['database_name'] . " user=" . $CONF['database_user'] . " password=" . $CONF['database_password'];
- $link = @pg_connect($connect_string) or die("<p />DEBUG INFORMATION:<br />Connect: " . pg_last_error() . "$DEBUG_TEXT");
- } else {
- print "<p />DEBUG INFORMATION:<br />PostgreSQL functions not available!<br />database_type = 'pgsql' in config.inc.php, are you using a different database? $DEBUG_TEXT";
- die;
- }
- }
-
if ($link) {
return $link;
} else {
}
if ($CONF['database_type'] == "mysqli") $result = @mysqli_query($link, $query) or die("<p />DEBUG INFORMATION:<br />Invalid query: " . mysqli_error($link) . "$DEBUG_TEXT");
- if ($CONF['database_type'] == "pgsql") {
- if (preg_match("/LIMIT/i", $query)) {
- $search = "/LIMIT(\w+), (\w+)/";
- $replace = "LIMIT \$2 OFFSET \$1";
- $query = preg_replace($search, $replace, $query);
- }
- $result = @pg_query($link, $query) or die("<p />DEBUG INFORMATION:<br />Invalid query: " . pg_last_error() . "$DEBUG_TEXT");
- }
if (preg_match("/^SELECT/i", $query)) {
// if $query was a SELECT statement check the number of rows with [database_type]_num_rows().
if ($CONF['database_type'] == "mysqli") $number_rows = mysqli_num_rows($result);
- if ($CONF['database_type'] == "pgsql") $number_rows = pg_num_rows($result);
} else {
// if $query was something else, UPDATE, DELETE or INSERT check the number of rows with
// [database_type]_affected_rows().
if ($CONF['database_type'] == "mysqli") $number_rows = mysqli_affected_rows($link);
- if ($CONF['database_type'] == "pgsql") $number_rows = pg_affected_rows($result);
}
if ($CONF['database_type'] == "mysqli") mysqli_close($link);
- if ($CONF['database_type'] == "pgsql") pg_close($link);
$return = array(
"result" => $result,
global $CONF;
$row = "";
if ($CONF['database_type'] == "mysqli") $row = mysqli_fetch_row($result);
- if ($CONF['database_type'] == "pgsql") $row = pg_fetch_row($result);
return $row;
}
global $CONF;
$row = "";
if ($CONF['database_type'] == "mysqli") $row = mysqli_fetch_array($result);
- if ($CONF['database_type'] == "pgsql") $row = pg_fetch_array($result);
return $row;
}
global $CONF;
$row = "";
if ($CONF['database_type'] == "mysqli") $row = mysqli_fetch_assoc($result);
- if ($CONF['database_type'] == "pgsql") $row = pg_fetch_assoc($result);
return $row;
}
}
}
+// logging
+// Action: Logs actions from admin
+// Call: logging(string username, string domain, string action, string data)
//
+function logging($username, $domain, $action, $data) {
+ $remote_addr = $_SERVER['HTTP_X_CLIENTIP'] ?? $_SERVER['REMOTE_ADDR'];
+ $username = $username . ' (' . $remote_addr . ')';
+ if (LOGGING == 'YES') {
+ $dbh = connect_db();
+ $sth = $dbh->prepare("INSERT INTO log (timestamp,username,domain,action,data) VALUES (NOW(),?,?,?,?)");
+ $sth->bindParam(1, $username, PDO::PARAM_STR);
+ $sth->bindParam(2, $domain, PDO::PARAM_STR);
+ $sth->bindParam(3, $action, PDO::PARAM_STR);
+ $sth->bindParam(4, $data, PDO::PARAM_STR);
+ $sth->execute();
+ }
+}
+//
// db_log
// Action: Logs actions from admin
// Call: db_log(string username, string domain, string action, string data)
//
function db_log($username, $domain, $action, $data) {
global $CONF;
- if (!empty($_SERVER['HTTP_X_CLIENTIP'])) {
+ if (isset($_SERVER['HTTP_X_CLIENTIP'])) {
$REMOTE_ADDR = $_SERVER['HTTP_X_CLIENTIP'];
} else {
$REMOTE_ADDR = $_SERVER['REMOTE_ADDR'];
blob - f7692b819f249b36ee4c354fa686920dc755c3a9
blob + f3f27ade1f9fcf403514a6c15f85d24dfa5dc515
--- languages/en.lang
+++ languages/en.lang
$PALANG['NO'] = 'NO';
$PALANG['edit'] = 'edit';
$PALANG['del'] = 'del';
-$PALANG['confirm'] = 'Are you sure you want to delete this?\n';
-$PALANG['confirm_domain'] = 'Do you really want to delete all records for this domain? This can not be undone!\n';
+$PALANG['confirm'] = 'Are you sure you want to delete this?';
+$PALANG['confirm_domain'] = 'Do you really want to delete all records for this domain? This can not be undone!';
$PALANG['check_update'] = 'Check for update';
$PALANG['pLogin_welcome'] = 'Mail admins login here to administer your domain.';
$PALANG['pOverview_alias_modified'] = 'Last Modified';
$PALANG['pOverview_mailbox_username'] = 'Email';
$PALANG['pOverview_mailbox_name'] = 'Name';
-$PALANG['pOverview_mailbox_quota'] = 'Quota (MB)';
$PALANG['pOverview_mailbox_modified'] = 'Last Modified';
$PALANG['pOverview_mailbox_active'] = 'Active';
$PALANG['pOverview_get_domain'] = 'Domain';
$PALANG['pOverview_get_aliases'] = 'Aliases';
$PALANG['pOverview_get_mailboxes'] = 'Mailboxes';
-$PALANG['pOverview_get_quota'] = 'Mailbox Quota (MB)';
$PALANG['pOverview_get_modified'] = 'Last Modified';
$PALANG['pDelete_delete_error'] = '<span class="error_msg">Unable to delete the entry ';
$PALANG['pCreate_alias_welcome'] = 'Create a new alias for your domain.';
$PALANG['pCreate_alias_address'] = 'Alias';
-$PALANG['pCreate_alias_address_text_error1'] = '<br /><span class="error_msg">The ALIAS is not valid.</span>';
-$PALANG['pCreate_alias_address_text_error2'] = '<br /><span class="error_msg">This email address already exists, please choose a different one.</span>';
-$PALANG['pCreate_alias_address_text_error3'] = '<br /><span class="error_msg">You have reached your limit to create aliases.</span>';
+$PALANG['pCreate_alias_address_text_error1'] = '<span class="error_msg">The ALIAS or TO is not valid.</span>';
+$PALANG['pCreate_alias_address_text_error2'] = '<span class="error_msg">You have reached your limit to create aliases.</span>';
$PALANG['pCreate_alias_goto'] = 'To';
$PALANG['pCreate_alias_button'] = 'Add Alias';
$PALANG['pCreate_alias_goto_text'] = 'Where the mail needs to be send to.';
-$PALANG['pCreate_alias_goto_text_error'] = 'Where the email needs to go.<br /><span class="error_msg">The TO is not valid.</span>';
-$PALANG['pCreate_alias_result_error'] = '<span class="error_msg">Unable to add the alias to the alias table.</span>';
+$PALANG['pCreate_alias_result_error'] = '<span class="error_msg">This email address already exists, unable to add to the alias table.</span>';
$PALANG['pCreate_alias_result_succes'] = 'The alias has been added to the alias table.';
$PALANG['pCreate_alias_catchall_text'] = 'To create a catch-all use an "*" as alias.<br />For domain to domain forwarding use "*@domain.tld" as to.';
$PALANG['pCreate_mailbox_welcome'] = 'Create a new mailbox for your domain.';
$PALANG['pCreate_mailbox_username'] = 'Username';
-$PALANG['pCreate_mailbox_username_text_error1'] = '<br /><span class="error_msg">The EMAIL is not valid.</span>';
-$PALANG['pCreate_mailbox_username_text_error2'] = '<br /><span class="error_msg">This email address already exists, please choose a different one.</span>';
-$PALANG['pCreate_mailbox_username_text_error3'] = '<br /><span class="error_msg">You have reached your limit to create mailboxes.</span>';
+$PALANG['pCreate_mailbox_username_text_error1'] = '<span class="error_msg">The USERNAME is not valid.</span>';
+$PALANG['pCreate_mailbox_username_text_error2'] = '<span class="error_msg">This email address already exists, please choose a different one.</span>';
+$PALANG['pCreate_mailbox_username_text_error3'] = '<span class="error_msg">You have reached your limit to create mailboxes.</span>';
$PALANG['pCreate_mailbox_password'] = 'Password';
$PALANG['pCreate_mailbox_password2'] = 'Password (again)';
$PALANG['pCreate_mailbox_password_text'] = 'Password for POP3/IMAP';
-$PALANG['pCreate_mailbox_password_text_error'] = 'Password for POP3/IMAP<br /><span class="error_msg">The passwords that you supplied don\'t match, or are empty.</span>';
+$PALANG['pCreate_mailbox_password_text_error'] = '<span class="error_msg">The passwords that you supplied don\'t match, or are empty.</span>';
$PALANG['pCreate_mailbox_name'] = 'Name';
$PALANG['pCreate_mailbox_name_text'] = 'Full name';
-$PALANG['pCreate_mailbox_quota'] = 'Quota';
-$PALANG['pCreate_mailbox_quota_text'] = 'MB';
-$PALANG['pCreate_mailbox_quota_text_error'] = 'MB<br /><span class="error_msg">The quota that you specified is to high.</span>';
$PALANG['pCreate_mailbox_active'] = 'Active';
$PALANG['pCreate_mailbox_mail'] = 'Create mailbox';
$PALANG['pCreate_mailbox_button'] = 'Add Mailbox';
$PALANG['pEdit_mailbox_password2'] = 'New Password (again)';
$PALANG['pEdit_mailbox_password_text_error'] = '<span class="error_msg">The passwords that you supplied don\'t match.</span>';
$PALANG['pEdit_mailbox_name'] = 'Name';
-$PALANG['pEdit_mailbox_quota'] = 'Quota';
-$PALANG['pEdit_mailbox_quota_text'] = 'MB';
-$PALANG['pEdit_mailbox_quota_text_error'] = 'MB<br /><span class="error_msg">The quota that you specified is to high.</span>';
$PALANG['pEdit_mailbox_domain_error'] = '<span class="error_msg">This domain is not yours: ';
$PALANG['pEdit_mailbox_button'] = 'Edit Mailbox';
$PALANG['pEdit_mailbox_result_error'] = '<span class="error_msg">Unable to modify the mailbox.</span>';
$PALANG['pAdminList_domain_description'] = 'Description';
$PALANG['pAdminList_domain_aliases'] = 'Aliases';
$PALANG['pAdminList_domain_mailboxes'] = 'Mailboxes';
-$PALANG['pAdminList_domain_maxquota'] = 'Quota (MB)';
-$PALANG['pAdminList_domain_transport'] = 'Transport';
-$PALANG['pAdminList_domain_backupmx'] = 'Backup MX';
$PALANG['pAdminList_domain_modified'] = 'Last Modified';
$PALANG['pAdminList_domain_active'] = 'Active';
$PALANG['pAdminList_virtual_alias_modified'] = 'Last Modified';
$PALANG['pAdminList_virtual_mailbox_username'] = 'Email';
$PALANG['pAdminList_virtual_mailbox_name'] = 'Name';
-$PALANG['pAdminList_virtual_mailbox_quota'] = 'Quota (MB)';
$PALANG['pAdminList_virtual_mailbox_modified'] = 'Last Modified';
$PALANG['pAdminList_virtual_mailbox_active'] = 'Active';
$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_maxquota'] = 'Max Quota';
-$PALANG['pAdminCreate_domain_maxquota_text'] = 'MB<br /> -1 = disable | 0 = unlimited';
-$PALANG['pAdminCreate_domain_transport'] = 'Transport';
-$PALANG['pAdminCreate_domain_transport_text'] = 'Define transport';
-$PALANG['pAdminCreate_domain_defaultaliases'] = 'Add default mail aliases';
-$PALANG['pAdminCreate_domain_backupmx'] = 'Mail server is backup MX';
$PALANG['pAdminCreate_domain_button'] = 'Add Domain';
$PALANG['pAdminCreate_domain_result_error'] = '<span class="error_msg">Unable to add domain.</span>';
$PALANG['pAdminCreate_domain_result_succes'] = 'Domain has been added.';
$PALANG['pAdminEdit_domain_aliases_text'] = '-1 = disable | 0 = unlimited';
$PALANG['pAdminEdit_domain_mailboxes'] = 'Mailboxes';
$PALANG['pAdminEdit_domain_mailboxes_text'] = '-1 = disable | 0 = unlimited';
-$PALANG['pAdminEdit_domain_maxquota'] = 'Max Quota';
-$PALANG['pAdminEdit_domain_maxquota_text'] = 'MB<br /> -1 = disable | 0 = unlimited';
-$PALANG['pAdminEdit_domain_transport'] = 'Transport';
-$PALANG['pAdminEdit_domain_transport_text'] = 'Define transport';
-$PALANG['pAdminEdit_domain_backupmx'] = 'Mail server is backup MX';
$PALANG['pAdminEdit_domain_active'] = 'Active';
$PALANG['pAdminEdit_domain_button'] = 'Edit Domain';
$PALANG['pAdminEdit_domain_result_error'] = '<span class="error_msg">Unable to modify domain.</span>';
$PALANG['pAdminCreate_admin_welcome'] = 'Add a new domain admin';
-$PALANG['pAdminCreate_admin_username'] = 'Admin';
-$PALANG['pAdminCreate_admin_username_text'] = 'email address';
-$PALANG['pAdminCreate_admin_username_text_error1'] = 'Email address<br /><span class="error_msg">Admin is not a valid email address.</span>';
-$PALANG['pAdminCreate_admin_username_text_error2'] = 'Email address<br /><span class="error_msg">The admin already exists or is not valid</span>';
-$PALANG['pAdminCreate_admin_password'] = 'Password';
+$PALANG['pAdminCreate_admin_username'] = 'Admin (email address)';
+$PALANG['pAdminCreate_admin_username_error'] = '<span class="error_msg">Admin already exists or is not valid.</span>';
+$PALANG['pAdminCreate_admin_password1'] = 'Password';
$PALANG['pAdminCreate_admin_password2'] = 'Password (again)';
-$PALANG['pAdminCreate_admin_password_text_error'] = '<span class="error_msg">The passwords that you supplied don\'t match, or are empty.</span>';
+$PALANG['pAdminCreate_admin_password_error'] = '<span class="error_msg">The passwords you supplied don\'t match, or are empty.</span>';
+$PALANG['pAdminCreate_admin_domain_error'] = '<span class="error_msg">No domains selected.</span>';
$PALANG['pAdminCreate_admin_button'] = 'Add Admin';
$PALANG['pAdminCreate_admin_result_error'] = '<span class="error_msg">Unable to add admin.</span>';
$PALANG['pAdminCreate_admin_result_succes'] = 'Admin has been added.';
blob - 412495dc5381afaa6b006b9a7a3c692ba6532ed2
blob + 87e30838630b78c0f2bf69812d2070b44a4be7b4
--- login.php
+++ login.php
//
// Template File: login.tpl
//
-// Template Variables:
+// Template variables:
//
// tMessage
// tUsername
//
-// Form POST \ GET Variables:
+// GET / POST variables:
//
// fUsername
// fPassword
blob - 16df579ccc8af9e7ba0b6fb1ce4e8cd82314275f
blob + a40318394ac407ade924f5a853f29beaffe5f577
--- overview.php
+++ overview.php
// fDomain
// limit
//
-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';
+include './templates/header.tpl';
+include './templates/menu.tpl';
$SESSID_USERNAME = check_session();
-$list_domains = list_domains_for_admin($SESSID_USERNAME);
+$list_domains = list_domains($SESSID_USERNAME);
-$tAlias = array();
-$tMailbox = array();
-
-if ($_SERVER['REQUEST_METHOD'] == "GET") {
- $fDisplay = 0;
- $page_size = $CONF['page_size'];
-
- if (isset($_GET['domain'])) $fDomain = escape_string($_GET['domain']);
- if (isset($_GET['limit'])) $fDisplay = escape_string($_GET['limit']);
-
- if (check_owner($SESSID_USERNAME, $fDomain)) {
- $limit = get_domain_properties($fDomain);
-
- if ($CONF['alias_control'] == "YES") {
- $query = "SELECT alias.address,alias.goto,alias.modified FROM alias WHERE alias.domain='$fDomain' ORDER BY alias.address LIMIT $fDisplay, $page_size";
- } else {
- $query = "SELECT alias.address,alias.goto,alias.modified FROM alias LEFT JOIN mailbox ON alias.address=mailbox.username WHERE alias.domain='$fDomain' AND mailbox.maildir IS NULL ORDER BY alias.address LIMIT $fDisplay, $page_size";
- }
-
- $result = db_query("$query");
- if ($result['rows'] > 0) {
- while ($row = db_array($result['result'])) {
- $tAlias[] = $row;
- }
- }
-
- $result = db_query("SELECT * FROM mailbox WHERE domain='$fDomain' ORDER BY username LIMIT $fDisplay, $page_size");
- if ($result['rows'] > 0) {
- while ($row = db_array($result['result'])) {
- $tMailbox[] = $row;
- }
- }
- $template = "overview.tpl";
- } else {
- $template = "overview-get.tpl";
- }
-
- $tDomain = $fDomain;
-
- if (isset($limit)) {
- if ($fDisplay >= $page_size) {
- $tDisplay_back_show = 1;
- $tDisplay_back = $fDisplay - $page_size;
- }
- if (($limit['alias_count'] > $page_size) or ($limit['mailbox_count'] > $page_size)) {
- $tDisplay_up_show = 1;
- }
- if ((($fDisplay + $page_size) < $limit['alias_count']) or (($fDisplay + $page_size) < $limit['mailbox_count'])) {
- $tDisplay_next_show = 1;
- $tDisplay_next = $fDisplay + $page_size;
- }
- }
- include("./templates/header.tpl");
- include("./templates/menu.tpl");
- include("./templates/$template");
- include("./templates/footer.tpl");
-}
-
-if ($_SERVER['REQUEST_METHOD'] == "POST") {
- $fDisplay = 0;
- $page_size = $CONF['page_size'];
-
- if (isset($_POST['limit'])) $fDisplay = escape_string($_POST['limit']);
-
- if (check_owner($SESSID_USERNAME, escape_string($_POST['fDomain']))) {
- $fDomain = escape_string($_POST['fDomain']);
-
- $limit = get_domain_properties($fDomain);
-
- if ($CONF['alias_control'] == "YES") {
- $query = "SELECT alias.address,alias.goto,alias.modified FROM alias WHERE alias.domain='$fDomain' ORDER BY alias.address LIMIT $fDisplay, $page_size";
- } else {
- $query = "SELECT alias.address,alias.goto,alias.modified FROM alias LEFT JOIN mailbox ON alias.address=mailbox.username WHERE alias.domain='$fDomain' AND mailbox.maildir IS NULL ORDER BY alias.address LIMIT $fDisplay, $page_size";
- }
-
- $result = db_query("$query");
- if ($result['rows'] > 0) {
- while ($row = db_array($result['result'])) {
- $tAlias[] = $row;
- }
- }
-
- $result = db_query("SELECT * FROM mailbox WHERE domain='$fDomain' ORDER BY username LIMIT $fDisplay, $page_size");
- if ($result['rows'] > 0) {
- while ($row = db_array($result['result'])) {
- $tMailbox[] = $row;
- }
- }
- }
-
- if (isset($limit)) {
- if ($fDisplay >= $page_size) {
- $tDisplay_back_show = 1;
- $tDisplay_back = $fDisplay - $page_size;
- }
- if (($limit['alias_count'] > $page_size) or ($limit['mailbox_count'] > $page_size)) {
- $tDisplay_up_show = 1;
- }
- if ((($fDisplay + $page_size) < $limit['alias_count']) or (($fDisplay + $page_size) < $limit['mailbox_count'])) {
- $tDisplay_next_show = 1;
- $tDisplay_next = $fDisplay + $page_size;
- }
- }
- include("./templates/header.tpl");
- include("./templates/menu.tpl");
- include("./templates/overview.tpl");
- include("./templates/footer.tpl");
-}
+include './templates/list-domains.tpl';
+include './templates/footer.tpl';
?>
blob - 1cc1dc76516ee95fc41149306e19ca66193cb8b6
blob + 5b6c8099f4783ec61bc522ed31c16682805d6ae7
--- setup.php
+++ setup.php
$html .= '</tr><tr>';
$html .= '<td><strong>SQL support:</strong></td>';
$html .= (extension_loaded('mysqli')) ? '<td><span style="color:green;">MySQL/MariaDB</span>' : '<td><span style="color:red;">MySQL/MariaDB</span>';
-$html .= (extension_loaded('pgsql')) ? ' - <span style="color:green;">PostgreSQL</span> (change the database_type if you want to use PostgreSQL)</td>' : ' - <span style="color:red;">PostgreSQL</span></td>';
$html .= '</tr><tr>';
$html .= '<td><strong>Functions:</strong></td>';
$html .= (extension_loaded('pcre')) ? '<td><span style="color:green;">pcre</span>' : '<td><span style="color:red;">pcre</span>';
blob - 779666dd033ecc149584a759fa59de1a120da0d9
blob + 0b35034feab122a422b5736429b276b18b0177ab
--- stylesheet.css
+++ stylesheet.css
}
#login_header {
- width: 800px;
+ width: 1024px;
margin: 0 auto;
padding-bottom: 10px;
text-align: left;
}
#menu {
- width: 800px;
+ width: 1024px;
margin: 0 auto;
padding-top: 10px;
}
#main_menu, #edit_form {
- width: 800px;
+ width: 960px;
margin: 0 auto;
}
}
#overview, #admin_domains, #admin_virtual {
- width: 800px;
+ width: 1024px;
margin: 0 auto;
background: #AFE1A6; /*#9ACD32;*/
border: 1px solid #bbb;
#nav_bar {
text-align: right;
- width: 800px;
+ width: 1024px;
margin: 0 auto;
}
#alias_table, #mailbox_table, #overview_table, #log_table, #admin_table {
- width: 800px;
+ width: 1024px;
margin: 0px auto;
border: 1px solid #efefef;
}
}
#footer {
- width: 800px;
+ width: 1024px;
margin: 20px auto;
border-top: 1px solid #bbbbbb;
background: #efefef;
blob - 3bdc8e206e7fa7c7f9900ebaf710bb26c8e15793
blob + 25b8a7c6ceca391b97aa285b34ab3119e84967eb
--- templates/admin_create-admin.tpl
+++ templates/admin_create-admin.tpl
<form name="create_admin" method="post">
<table>
<tr>
- <td colspan="3"><h3><?php print $PALANG['pAdminCreate_admin_welcome']; ?></h3></td>
+ <td colspan="2"><h3><?php echo $PALANG['pAdminCreate_admin_welcome']; ?></h3></td>
</tr>
<tr>
- <td><?php print $PALANG['pAdminCreate_admin_username'] . ":"; ?></td>
- <td><input class="flat" type="text" name="fUsername" value="<?php print $tUsername; ?>" /></td>
- <td><?php print $pAdminCreate_admin_username_text; ?></td>
+ <td><?php echo $PALANG['pAdminCreate_admin_username'] . ":"; ?></td>
+ <td><input class="flat" type="text" name="username" value="<?php echo $username ?? ''; ?>" /></td>
</tr>
<tr>
- <td><?php print $PALANG['pAdminCreate_admin_password'] . ":"; ?></td>
- <td><input class="flat" type="password" name="fPassword" /></td>
- <td><?php print $pAdminCreate_admin_password_text; ?></td>
+ <td><?php echo $PALANG['pAdminCreate_admin_password1'] . ":"; ?></td>
+ <td><input class="flat" type="password" name="password1" /></td>
</tr>
<tr>
- <td><?php print $PALANG['pAdminCreate_admin_password2'] . ":"; ?></td>
- <td><input class="flat" type="password" name="fPassword2" /></td>
- <td> </td>
+ <td><?php echo $PALANG['pAdminCreate_admin_password2'] . ":"; ?></td>
+ <td><input class="flat" type="password" name="password2" /></td>
</tr>
<tr>
- <td><?php print $PALANG['pAdminCreate_admin_address'] . ":"; ?></td>
+ <td><?php echo $PALANG['pAdminCreate_admin_address'] . ":"; ?></td>
<td>
- <select name="fDomains[]" size="10" multiple="multiple">
+ <select name="domains[]" size="10" multiple="multiple">
<?php
- for ($i = 0; $i < count($list_domains); $i++) {
- if (in_array($list_domains[$i], $tDomains)) {
- print "<option value=\"" . $list_domains[$i] . "\" selected=\"selected\">" . $list_domains[$i] . "</option>\n";
- } else {
- print "<option value=\"" . $list_domains[$i] . "\">" . $list_domains[$i] . "</option>\n";
- }
+ foreach ($list_domains as $row) {
+ echo '<option value="' . $row['domain'] . '"';
+ if (isset($domains['domains']) && in_array($row['domain'], $domains['domains'])) echo ' selected';
+ echo ">" . $row['domain'] . "</option>\n";
}
?>
</select>
</td>
- <td> </td>
</tr>
<tr>
- <td colspan="3" class="hlp_center"><input class="button" type="submit" name="submit" value="<?php print $PALANG['pAdminCreate_admin_button']; ?>" /></td>
+ <td colspan="2" class="hlp_center"><input class="button" type="submit" name="submit" value="<?php echo $PALANG['pAdminCreate_admin_button']; ?>" /></td>
</tr>
<tr>
- <td colspan="3" class="standout"><?php print $tMessage; ?></td>
+ <td colspan="2" class="standout"><?php echo $message ?? ' '; ?></td>
</tr>
</table>
</form>
blob - /dev/null
blob + 25b8a7c6ceca391b97aa285b34ab3119e84967eb (mode 644)
--- /dev/null
+++ templates/admin_add-admin.tpl
+<div id="edit_form">
+<form name="create_admin" method="post">
+<table>
+ <tr>
+ <td colspan="2"><h3><?php echo $PALANG['pAdminCreate_admin_welcome']; ?></h3></td>
+ </tr>
+ <tr>
+ <td><?php echo $PALANG['pAdminCreate_admin_username'] . ":"; ?></td>
+ <td><input class="flat" type="text" name="username" value="<?php echo $username ?? ''; ?>" /></td>
+ </tr>
+ <tr>
+ <td><?php echo $PALANG['pAdminCreate_admin_password1'] . ":"; ?></td>
+ <td><input class="flat" type="password" name="password1" /></td>
+ </tr>
+ <tr>
+ <td><?php echo $PALANG['pAdminCreate_admin_password2'] . ":"; ?></td>
+ <td><input class="flat" type="password" name="password2" /></td>
+ </tr>
+ <tr>
+ <td><?php echo $PALANG['pAdminCreate_admin_address'] . ":"; ?></td>
+ <td>
+ <select name="domains[]" size="10" multiple="multiple">
+ <?php
+ foreach ($list_domains as $row) {
+ echo '<option value="' . $row['domain'] . '"';
+ if (isset($domains['domains']) && in_array($row['domain'], $domains['domains'])) echo ' selected';
+ echo ">" . $row['domain'] . "</option>\n";
+ }
+ ?>
+ </select>
+ </td>
+ </tr>
+ <tr>
+ <td colspan="2" class="hlp_center"><input class="button" type="submit" name="submit" value="<?php echo $PALANG['pAdminCreate_admin_button']; ?>" /></td>
+ </tr>
+ <tr>
+ <td colspan="2" class="standout"><?php echo $message ?? ' '; ?></td>
+ </tr>
+</table>
+</form>
+</div>
blob - 9e0efb87e4410a01eec2a1123ce75979f93a2d77
blob + 19e89e69be451daa5f5d2ad1cc3667ae646b4a52
--- templates/admin_create-domain.tpl
+++ templates/admin_create-domain.tpl
<form name="create_domain" method="post">
<table>
<tr>
- <td colspan="3"><h3><?php print $PALANG['pAdminCreate_domain_welcome']; ?></h3></td>
+ <td colspan="3"><h3><?php echo $PALANG['pAdminCreate_domain_welcome']; ?></h3></td>
</tr>
<tr>
- <td><?php print $PALANG['pAdminCreate_domain_domain'] . ":"; ?></td>
- <td><input class="flat" type="text" name="fDomain" value="<?php print $tDomain; ?>" /></td>
- <td><?php print $pAdminCreate_domain_domain_text; ?></td>
+ <td><?php echo $PALANG['pAdminCreate_domain_domain'] . ":"; ?></td>
+ <td><input class="flat" type="text" name="domain" value="<?php echo $domain ?? ''; ?>" /></td>
+ <td><?php echo $pAdminCreate_domain_domain_text; ?></td>
</tr>
<tr>
- <td><?php print $PALANG['pAdminCreate_domain_description'] . ":"; ?></td>
- <td><input class="flat" type="text" name="fDescription" value="<?php print $tDescription; ?>" /></td>
+ <td><?php echo $PALANG['pAdminCreate_domain_description'] . ":"; ?></td>
+ <td><input class="flat" type="text" name="description" value="<?php echo $description ?? ''; ?>" /></td>
<td> </td>
</tr>
<tr>
- <td><?php print $PALANG['pAdminCreate_domain_aliases'] . ":"; ?></td>
- <td><input class="flat" type="text" name="fAliases" value="<?php print $tAliases; ?>" /></td>
- <td><?php print $PALANG['pAdminCreate_domain_aliases_text']; ?></td>
+ <td><?php echo $PALANG['pAdminCreate_domain_aliases'] . ":"; ?></td>
+ <td><input class="flat" type="text" name="aliases" value="<?php echo $aliases ?? ALIASES; ?>" /></td>
+ <td><?php echo $PALANG['pAdminCreate_domain_aliases_text']; ?></td>
</tr>
<tr>
- <td><?php print $PALANG['pAdminCreate_domain_mailboxes'] . ":"; ?></td>
- <td><input class="flat" type="text" name="fMailboxes" value="<?php print $tMailboxes; ?>" /></td>
- <td><?php print $PALANG['pAdminCreate_domain_mailboxes_text']; ?></td>
+ <td><?php echo $PALANG['pAdminCreate_domain_mailboxes'] . ":"; ?></td>
+ <td><input class="flat" type="text" name="mailboxes" value="<?php echo $mailboxes ?? MAILBOXES; ?>" /></td>
+ <td><?php echo $PALANG['pAdminCreate_domain_mailboxes_text']; ?></td>
</tr>
- <?php if ($CONF['quota'] == 'YES') { ?>
<tr>
- <td><?php print $PALANG['pAdminCreate_domain_maxquota'] . ":"; ?></td>
- <td><input class="flat" type="text" name="fMaxquota" value="<?php print $tMaxquota; ?>" /></td>
- <td><?php print $PALANG['pAdminCreate_domain_maxquota_text']; ?></td>
+ <td colspan="3" class="hlp_center"><input class="button" type="submit" name="submit" value="<?php echo $PALANG['pAdminCreate_domain_button']; ?>" /></td>
</tr>
- <?php } if ($CONF['transport'] == 'YES') { ?>
<tr>
- <td><?php print $PALANG['pAdminCreate_domain_transport'] . ":"; ?></td>
- <td><input class="flat" type="text" name="fTransport" value="<?php print $tTransport; ?>" /></td>
- <td><?php print $PALANG['pAdminCreate_domain_transport_text']; ?></td>
+ <td colspan="3" class="standout"><?php echo $message ?? ''; ?></td>
</tr>
- <?php } ?>
- <tr>
- <td><?php print $PALANG['pAdminCreate_domain_defaultaliases'] . ":"; ?></td>
- <td><?php $checked = (!empty($tDefaultaliases)) ? 'checked' : ''; ?>
- <input class="flat" type="checkbox" name="fDefaultaliases" <?php print $checked; ?> />
- </td>
- <td><?php print $pAdminCreate_domain_defaultaliases_text; ?></td>
- </tr>
- <tr>
- <td><?php print $PALANG['pAdminCreate_domain_backupmx'] . ":"; ?></td>
- <td><?php $checked = (!empty($tBackupmx)) ? 'checked' : ''; ?>
- <input class="flat" type="checkbox" name="fBackupmx" <?php print $checked; ?> />
- </td>
- <td> </td>
- </tr>
- <tr>
- <td colspan="3" class="hlp_center"><input class="button" type="submit" name="submit" value="<?php print $PALANG['pAdminCreate_domain_button']; ?>" /></td>
- </tr>
- <tr>
- <td colspan="3" class="standout"><?php print $tMessage; ?></td>
- </tr>
</table>
</form>
</div>
blob - 8c640173b4ef1eb60b2d847ecc2da1a39480b332
blob + 14c636b6e381dcc108acadc5bd916153c81e3815
--- templates/admin_edit-domain.tpl
+++ templates/admin_edit-domain.tpl
</tr>
<tr>
<td><?php print $PALANG['pAdminEdit_domain_description'] . ":"; ?></td>
- <td><input class="flat" type="text" name="fDescription" value="<?php print htmlspecialchars($tDescription, ENT_QUOTES); ?>" /></td>
+ <td><input class="flat" type="text" name="description" value="<?php print $description ?? ''; ?>" /></td>
<td> </td>
</tr>
<tr>
<td><?php print $PALANG['pAdminEdit_domain_aliases'] . ":"; ?></td>
- <td><input class="flat" type="text" name="fAliases" value="<?php print $tAliases; ?>" /></td>
+ <td><input class="flat" type="text" name="aliases" value="<?php print $aliases; ?>" /></td>
<td><?php print $PALANG['pAdminEdit_domain_aliases_text']; ?></td>
</tr>
<tr>
<td><?php print $PALANG['pAdminEdit_domain_mailboxes'] . ":"; ?></td>
- <td><input class="flat" type="text" name="fMailboxes" value="<?php print $tMailboxes; ?>" /></td>
+ <td><input class="flat" type="text" name="mailboxes" value="<?php print $mailboxes; ?>" /></td>
<td><?php print $PALANG['pAdminEdit_domain_mailboxes_text']; ?></td>
</tr>
- <?php if ($CONF['quota'] == 'YES') { ?>
<tr>
- <td><?php print $PALANG['pAdminEdit_domain_maxquota'] . ":"; ?></td>
- <td><input class="flat" type="text" name="fMaxquota" value="<?php print $tMaxquota; ?>" /></td>
- <td><?php print $PALANG['pAdminEdit_domain_maxquota_text']; ?></td>
- </tr>
- <?php } if ($CONF['transport'] == 'YES') { ?>
- <tr>
- <td><?php print $PALANG['pAdminEdit_domain_transport'] . ":"; ?></td>
- <td><input class="flat" type="text" name="fTransport" value="<?php print $tTransport; ?>" /></td>
- <td><?php $PALANG['pAdminEdit_domain_transport_text']; ?></td>
- </tr>
- <?php } ?>
- <tr>
- <td><?php print $PALANG['pAdminEdit_domain_backupmx'] . ":"; ?></td>
- <td><?php $checked = (!empty($tBackupmx)) ? 'checked' : ''; ?>
- <input class="flat" type="checkbox" name="fBackupmx" <?php print $checked; ?> /></td>
- <td> </td>
- </tr>
- <tr>
- <td><?php print $PALANG['pAdminEdit_domain_active'] . ":"; ?></td>
- <td><?php $checked = (!empty($tActive)) ? 'checked' : ''; ?>
- <input class="flat" type="checkbox" name="fActive" <?php print $checked; ?> /></td>
- <td> </td>
- </tr>
- <tr>
<td colspan="3" class="hlp_center"><input type="submit" class="button" name="submit" value="<?php print $PALANG['pAdminEdit_domain_button']; ?>" /></td>
</tr>
<tr>
- <td colspan="3" class="standout"><?php print $tMessage; ?></td>
+ <td colspan="3" class="standout"><?php print $message; ?></td>
</tr>
</table>
</form>
blob - 9d031a2aca1d65b42edeeceab5837987d5e15177
blob + c713c518267d5e988bf67a9f390484477cf67363
--- templates/admin_list-admin.tpl
+++ templates/admin_list-admin.tpl
<?php
-if (!empty($list_admins)) {
- $list_admins_count = count($list_admins);
+if (count($list_admins) > 0) {
- if (is_array($list_admins) && $list_admins_count > 0) {
- print "<table id=\"admin_table\">\n";
- print " <tr class=\"header\">\n";
- print " <td>" . $PALANG['pAdminList_admin_username'] . "</td>\n";
- print " <td>" . $PALANG['pAdminList_admin_count'] . "</td>\n";
- print " <td>" . $PALANG['pAdminList_admin_modified'] . "</td>\n";
- print " <td>" . $PALANG['pAdminList_admin_active'] . "</td>\n";
- print " <td colspan=\"2\"> </td>\n";
- print " </tr>\n";
+ echo "<table id=\"admin_table\">\n";
+ echo " <tr class=\"header\">\n";
+ echo " <td>" . $PALANG['pAdminList_admin_username'] . "</td>\n";
+ echo " <td>" . $PALANG['pAdminList_admin_count'] . "</td>\n";
+ echo " <td>" . $PALANG['pAdminList_admin_modified'] . "</td>\n";
+ echo " <td>" . $PALANG['pAdminList_admin_active'] . "</td>\n";
+ echo " <td colspan=\"2\"> </td>\n";
+ echo " </tr>\n";
- for ($i = 0; $i < $list_admins_count; $i++) {
- if ((is_array($list_admins) and $list_admins_count > 0)) {
- print " <tr class=\"hilightoff\" onMouseOver=\"className='hilighton';\" onMouseOut=\"className='hilightoff';\">\n";
- print " <td><a href=\"list-domain.php?username=" . $list_admins[$i] . "\">" . $list_admins[$i] . "</a></td>";
- print " <td>" . $admin_properties[$i]['domain_count'] . "</td>";
- print " <td>" . $admin_properties[$i]['modified'] . "</td>";
- $active = ($admin_properties[$i]['active'] == 1) ? $PALANG['YES'] : $PALANG['NO'];
- print " <td><a href=\"edit-active-admin.php?username=" . $list_admins[$i] . "\">" . $active . "</a></td>";
- print " <td><a href=\"edit-admin.php?username=" . $list_admins[$i] . "\">" . $PALANG['edit'] . "</a></td>";
- print " <td><a href=\"delete.php?table=admin&where=username&delete=" . $list_admins[$i] . "\" onclick=\"return confirm ('" . $PALANG['confirm'] . $PALANG['pAdminList_admin_username'] . ": " . $list_admins[$i] . "')\">" . $PALANG['del'] . "</a></td>";
- print " </tr>\n";
- }
- }
- print "</table>\n";
+ foreach ($list_admins as $row) {
+
+ echo " <tr class=\"hilightoff\" onMouseOver=\"className='hilighton';\" onMouseOut=\"className='hilightoff';\">\n";
+ echo " <td><a href=\"list-domain.php?username=" . $row['username'] . "\">" . $row['username'] . "</a></td>";
+ echo " <td>" . $row['domain_count'] . "</td>";
+ echo " <td>" . $row['modified'] . "</td>";
+ $active = ($row['active'] == 1) ? $PALANG['YES'] : $PALANG['NO'];
+ echo " <td><a href=\"edit-active-admin.php?username=" . $row['username'] . "\">" . $active . "</a></td>";
+ echo " <td><a href=\"edit-admin.php?username=" . $row['username'] . "\">" . $PALANG['edit'] . "</a></td>";
+ echo " <td><a href=\"delete.php?table=admin&where=username&delete=" . $row['username'] . "\" onclick=\"return confirm ('" . $PALANG['confirm'] . $PALANG['pAdminList_admin_username'] . ": " . $row['username'] . "')\">" . $PALANG['del'] . "</a></td>";
+ echo " </tr>\n";
}
+ echo "</table>\n";
}
?>
blob - a19af99a3c05e24856837dd3177db8a7eb1446c7
blob + 18a57a0b4555a6f2028021ce94093f405e4abad3
--- templates/admin_list-domain.tpl
+++ templates/admin_list-domain.tpl
<div id="overview">
-<form name="list_domain" method="post">
-<select name="fUsername" onChange="this.form.submit()";>
+<form name="list_domain" method="get">
+<select name=username onChange="this.form.submit()";>
<?php
-if (!empty($list_admins)) {
- for ($i = 0; $i < count($list_admins); $i++) {
- if ($fUsername == $list_admins[$i]) {
- print "<option value=\"" . $list_admins[$i] . "\" selected>" . $list_admins[$i] . "</option>\n";
- } else {
- print "<option value=\"" . $list_admins[$i] . "\">" . $list_admins[$i] . "</option>\n";
- }
+if (count($list_admins) > 0) {
+ foreach ($list_admins as $row) {
+ echo '<option value="' . $row['username'] . '"';
+ if (isset($_GET['username']) && $_GET['username'] == $row['username']) echo ' selected';
+ echo ">" . $row['username'] . "</option>\n";
}
}
?>
</select>
-<input class="button" type="submit" name="go" value="<?php print $PALANG['pOverview_button']; ?>" />
+<input class="button" type="submit" name="go" value="<?php echo $PALANG['pOverview_button']; ?>" />
</form>
<form name="search" method="post" action="search.php">
-<input type="textbox" name="search" size="10">
+<input type="textbox" name="search" size="25">
</form>
</div>
-
<?php
if (count($list_domains) > 0) {
- print "<table id=\"admin_table\">\n";
- print " <tr class=\"header\">\n";
- print " <td>" . $PALANG['pAdminList_domain_domain'] . "</td>\n";
- print " <td>" . $PALANG['pAdminList_domain_description'] . "</td>\n";
- print " <td>" . $PALANG['pAdminList_domain_aliases'] . "</td>\n";
- print " <td>" . $PALANG['pAdminList_domain_mailboxes'] . "</td>\n";
- if ($CONF['quota'] == 'YES') print " <td>" . $PALANG['pAdminList_domain_maxquota'] . "</td>\n";
- if ($CONF['transport'] == 'YES') print " <td>" . $PALANG['pAdminList_domain_transport'] . "</td>\n";
- print " <td>" . $PALANG['pAdminList_domain_backupmx'] . "</td>\n";
- print " <td>" . $PALANG['pAdminList_domain_modified'] . "</td>\n";
- print " <td>" . $PALANG['pAdminList_domain_active'] . "</td>\n";
- print " <td colspan=\"2\"> </td>\n";
- print " </tr>\n";
-
- for ($i = 0; $i < count($list_domains); $i++) {
- if ((is_array($list_domains) and count($list_domains) > 0)) {
- print " <tr class=\"hilightoff\" onMouseOver=\"className='hilighton';\" onMouseOut=\"className='hilightoff';\">\n";
- print "<td><a href=\"list-virtual.php?domain=" . $list_domains[$i] . "\">" . $list_domains[$i] . "</a></td>";
- print "<td>" . $domain_properties[$i]['description'] . "</td>";
- print "<td>" . $domain_properties[$i]['alias_count'] . " / " . $domain_properties[$i]['aliases'] . "</td>";
- print "<td>" . $domain_properties[$i]['mailbox_count'] . " / " . $domain_properties[$i]['mailboxes'] . "</td>";
- if ($CONF['quota'] == 'YES') print "<td>" . $domain_properties[$i]['maxquota'] . "</td>";
- if ($CONF['transport'] == 'YES') print "<td>" . $domain_properties[$i]['transport'] . "</td>";
- $backupmx = ($domain_properties[$i]['backupmx'] == 1) ? $PALANG['YES'] : $PALANG['NO'];
- print "<td>$backupmx</td>";
- print "<td>" . $domain_properties[$i]['modified'] . "</td>";
- $active = ($domain_properties[$i]['active'] == 1) ? $PALANG['YES'] : $PALANG['NO'];
- print "<td><a href=\"edit-active-domain.php?domain=" . $list_domains[$i] . "\">" . $active . "</a></td>";
- print "<td><a href=\"edit-domain.php?domain=" . $list_domains[$i] . "\">" . $PALANG['edit'] . "</a></td>";
- print "<td><a href=\"delete.php?table=domain&where=domain&delete=" . $list_domains[$i] . "\" onclick=\"return confirm ('" . $PALANG['confirm_domain'] . $PALANG['pAdminList_admin_domain'] . ": " . $list_domains[$i] . "')\">" . $PALANG['del'] . "</a></td>";
- print "</tr>\n";
- }
+ echo "<table id=\"admin_table\">\n";
+ echo " <tr class=\"header\">\n";
+ echo " <td>" . $PALANG['pAdminList_domain_domain'] . "</td>\n";
+ echo " <td>" . $PALANG['pAdminList_domain_description'] . "</td>\n";
+ echo " <td>" . $PALANG['pAdminList_domain_aliases'] . "</td>\n";
+ echo " <td>" . $PALANG['pAdminList_domain_mailboxes'] . "</td>\n";
+ echo " <td>" . $PALANG['pAdminList_domain_modified'] . "</td>\n";
+ echo " <td colspan=\"2\"> </td>\n";
+ echo " </tr>\n";
+ foreach ($list_domains as $row) {
+ echo " <tr class=\"hilightoff\" onMouseOver=\"className='hilighton';\" onMouseOut=\"className='hilightoff';\">\n";
+ echo "<td><a href=\"list-virtual.php?domain=" . $row['domain'] . "\">" . $row['domain'] . "</a></td>";
+ echo "<td>" . $row['description'] . "</td>";
+ echo "<td>" . $row['alias_count'] . " / " . $row['aliases'] . "</td>";
+ echo "<td>" . $row['mailbox_count'] . " / " . $row['mailboxes'] . "</td>";
+ echo "<td>" . $row['modified'] . "</td>";
+ $active = ($row['active'] == 1) ? $PALANG['YES'] : $PALANG['NO'];
+ echo "<td><a href=\"domain.php?action=edit&domain=" . $row['domain'] . "\">" . $PALANG['edit'] . "</a></td>";
+ echo "<td><a href=\"delete.php?table=domain&domain=" . $row['domain'] . "\" onclick=\"return confirm ('" . $PALANG['confirm_domain'] . $PALANG['pAdminList_admin_domain'] . ": " . $row['domain'] . "')\">" . $PALANG['del'] . "</a></td>";
+ echo "</tr>\n";
}
- print "</table>\n";
+ echo "</table>\n";
}
?>
blob - a2c391c1df0c2358ef87a177ba02c6080b6c6407
blob + 3e35140fb3fa2a2080eabdb53145424929998b04
--- templates/admin_list-virtual.tpl
+++ templates/admin_list-virtual.tpl
<div id="admin_virtual">
-<form name="list_virtual" method="post">
-<select name="fDomain" onChange="this.form.submit()";>
+<form name="list_virtual" method="get">
+<select name="domain" onChange="this.form.submit()";>
<?php
-for ($i = 0; $i < count($list_domains); $i++) {
- if ($fDomain == $list_domains[$i]) {
- print "<option value=\"$list_domains[$i]\" selected>$list_domains[$i]</option>\n";
- } else {
- print "<option value=\"$list_domains[$i]\">$list_domains[$i]</option>\n";
+if (count($list_domains) > 0) {
+ foreach ($list_domains as $row) {
+ echo '<option value="' . $row['domain'] . '"';
+ if ($list_domains[$selected_domain]['domain'] == $row['domain']) echo ' selected';
+ echo ">" . $row['domain'] . "</option>\n";
}
}
?>
<input type="hidden" name="limit" value="0">
<input type="submit" name="go" value="<?php print $PALANG['pAdminList_virtual_button']; ?>" />
</form>
-<h4><?php print $PALANG['pAdminList_virtual_welcome'] . $fDomain; ?></h4>
-<p><?php print $PALANG['pAdminList_virtual_alias_alias_count'] . ": " . $limit['alias_count'] . " / " . $limit['aliases']; ?></p>
-<p><?php print $PALANG['pAdminList_virtual_alias_mailbox_count'] . ": " . $limit['mailbox_count'] . " / " . $limit['mailboxes']; ?></p>
+
+<h4><?php print $PALANG['pAdminList_virtual_welcome'] . $domain; ?></h4>
+<p><?php print $PALANG['pAdminList_virtual_alias_alias_count'] . ": " . $list_domains[$selected_domain]['alias_count'] . " / " . $list_domains[$selected_domain]['aliases']; ?></p>
+<p><?php print $PALANG['pAdminList_virtual_alias_mailbox_count'] . ": " . $list_domains[$selected_domain]['mailbox_count'] . " / " . $list_domains[$selected_domain]['mailboxes']; ?></p>
+
<form name="search" method="post" action="search.php">
-<input type="textbox" name="search" size="10">
+<input type="textbox" name="search" size="25">
</form>
</div>
<?php
-print "<div id=\"nav_bar\">\n";
-if ($tDisplay_back_show == 1) {
- print "<a href=\"list-virtual.php?domain=$fDomain&limit=$tDisplay_back\"><img border=\"0\" src=\"../images/arrow-l.png\" title=\"" . $PALANG['pOverview_left_arrow'] . "\" alt=\"" . $PALANG['pOverview_left_arrow'] . "\"></a>\n";
-}
-if ($tDisplay_up_show == 1) {
- print "<a href=\"list-virtual.php?domain=$fDomain&limit=0\"><img border=\"0\" src=\"../images/arrow-u.png\" title=\"" . $PALANG['pOverview_up_arrow'] . "\" alt=\"" . $PALANG['pOverview_up_arrow'] . "\"></a>\n";
+if ($list_domains[$selected_domain]['alias_count'] > $limit || $list_domains[$selected_domain]['mailbox_count'] > $limit) {
+ echo "<div id=\"nav_bar\">\n";
+ if ($offset >= $limit) {
+
+ echo "<a href=\"list-virtual.php?domain=" . $list_domains[$selected_domain]['domain'] . "&offset=" . ($offset - $limit) . "\"><img border=\"0\" src=\"../images/arrow-l.png\" title=\"" . $PALANG['pOverview_left_arrow'] . "\"></a>\n";
+ }
+ if (($list_domains[$selected_domain]['alias_count'] > $limit) || ($list_domains[$selected_domain]['mailbox_count'] > $limit)) {
+
+ echo "<a href=\"list-virtual.php?domain=" . $list_domains[$selected_domain]['domain'] . "&offset=0\"><img border=\"0\" src=\"../images/arrow-u.png\" title=\"" . $PALANG['pOverview_up_arrow'] . "\"></a>\n";
+ }
+ if ((($offset + $limit) < $list_domains[$selected_domain]['alias_count']) || (($offset + $limit) < $list_domains[$selected_domain]['mailbox_count'])) {
+ echo "<a href=\"list-virtual.php?domain=" . $list_domains[$selected_domain]['domain'] . "&offset=" . ($offset + $limit) . "\"><img border=\"0\" src=\"../images/arrow-r.png\" title=\"" . $PALANG['pOverview_right_arrow'] . "\"></a>\n";
+ }
+ echo "</div>\n";
}
-if ($tDisplay_next_show == 1) {
- print "<a href=\"list-virtual.php?domain=$fDomain&limit=$tDisplay_next\"><img border=\"0\" src=\"../images/arrow-r.png\" title=\"" . $PALANG['pOverview_right_arrow'] . "\" alt=\"" . $PALANG['pOverview_right_arrow'] . "\"></a>\n";
-}
-print "</div>\n";
-if (count($tAlias) > 0) {
+if (count($list_alias) > 0) {
print "<table id=\"alias_table\">\n";
print " <tr>\n";
print " <td colspan=\"5\"><h3>" . $PALANG['pOverview_alias_title'] . "</h3></td>";
print " <td colspan=\"2\"> </td>\n";
print " </tr>\n";
- for ($i = 0; $i < count($tAlias); $i++) {
- if ((is_array($tAlias) and count($tAlias) > 0)) {
+ foreach ($list_alias as $row) {
print " <tr class=\"hilightoff\" onMouseOver=\"className='hilighton';\" onMouseOut=\"className='hilightoff';\">\n";
- print " <td>" . $tAlias[$i]['address'] . "</td>\n";
- print " <td>" . preg_replace("/,/", "<br>", $tAlias[$i]['goto']) . "</td>\n";
- print " <td>" . $tAlias[$i]['modified'] . "</td>\n";
- print " <td><a href=\"edit-alias.php?address=" . urlencode($tAlias[$i]['address']) . "&domain=$fDomain" . "\">" . $PALANG['edit'] . "</a></td>\n";
- print " <td><a href=\"delete.php?table=alias" . "&delete=" . urlencode($tAlias[$i]['address']) . "&domain=$fDomain" . "\"onclick=\"return confirm ('" . $PALANG['confirm'] . $PALANG['pOverview_get_aliases'] . ": ". $tAlias[$i]['address'] . "')\">" . $PALANG['del'] . "</a></td>\n";
+ print " <td>" . $row['address'] . "</td>\n";
+ print " <td>" . preg_replace("/,/", "<br>", $row['goto']) . "</td>\n";
+ print " <td>" . $row['modified'] . "</td>\n";
+ print " <td><a href=\"edit-alias.php?address=" . urlencode($row['address']) . "&domain=" . $list_domains[$selected_domain]['domain'] . "\">" . $PALANG['edit'] . "</a></td>\n";
+ print " <td><a href=\"delete.php?table=alias" . "&delete=" . urlencode($row['address']) . "&domain=" . $list_domains[$selected_domain]['domain'] . "\"onclick=\"return confirm ('" . $PALANG['confirm'] . $PALANG['pOverview_get_aliases'] . ": ". $row['address'] . "')\">" . $PALANG['del'] . "</a></td>\n";
print " </tr>\n";
- }
}
print "</table>\n";
}
-if (count($tMailbox) > 0) {
+if (count($list_mailbox) > 0) {
print "<table id=\"mailbox_table\">\n";
print " <tr>\n";
print " <td colspan=\"7\"><h3>" . $PALANG['pOverview_mailbox_title'] . "</h3></td>";
print " <td colspan=\"2\"> </td>\n";
print " </tr>\n";
- for ($i = 0; $i < count($tMailbox); $i++) {
- if ((is_array($tMailbox) and count($tMailbox) > 0)) {
+ foreach ($list_mailbox as $row) {
print " <tr class=\"hilightoff\" onMouseOver=\"className='hilighton';\" onMouseOut=\"className='hilightoff';\">\n";
- print " <td>" . $tMailbox[$i]['username'] . "</td>\n";
- print " <td>" . $tMailbox[$i]['name'] . "</td>\n";
- if ($CONF['quota'] == 'YES') print " <td>" . $tMailbox[$i]['quota'] / $CONF['quota_multiplier'] . "</td>\n";
- print " <td>" . $tMailbox[$i]['modified'] . "</td>\n";
- $active = ($tMailbox[$i]['active'] == 1) ? $PALANG['YES'] : $PALANG['NO'];
- print " <td><a href=\"edit-active.php?username=" . urlencode($tMailbox[$i]['username']) . "&domain=$fDomain" . "\">" . $active . "</a></td>\n";
- print " <td><a href=\"edit-mailbox.php?username=" . urlencode($tMailbox[$i]['username']) . "&domain=$fDomain" . "\">" . $PALANG['edit'] . "</a></td>\n";
- print " <td><a href=\"delete.php?table=mailbox" . "&delete=" . urlencode($tMailbox[$i]['username']) . "&domain=$fDomain" . "\"onclick=\"return confirm ('" . $PALANG['confirm'] . $PALANG['pOverview_get_mailboxes'] . ": ". $tMailbox[$i]['username'] . "')\">" . $PALANG['del'] . "</a></td>\n";
+ print " <td>" . $row['username'] . "</td>\n";
+ print " <td>" . $row['name'] . "</td>\n";
+ print " <td>" . $row['modified'] . "</td>\n";
+ $active = ($row['active'] == 1) ? $PALANG['YES'] : $PALANG['NO'];
+ print " <td><a href=\"edit-active.php?username=" . urlencode($row['username']) . "&domain=" . $list_domains[$selected_domain]['domain'] . "\">" . $active . "</a></td>\n";
+ print " <td><a href=\"edit-mailbox.php?username=" . urlencode($row['username']) . "&domain=" . $list_domains[$selected_domain]['domain'] . "\">" . $PALANG['edit'] . "</a></td>\n";
+ print " <td><a href=\"delete.php?table=mailbox" . "&delete=" . urlencode($row['username']) . "&domain=" . $list_domains[$selected_domain]['domain'] . "\"onclick=\"return confirm ('" . $PALANG['confirm'] . $PALANG['pOverview_get_mailboxes'] . ": ". $row['username'] . "')\">" . $PALANG['del'] . "</a></td>\n";
print " </tr>\n";
- }
}
print "</table>\n";
}
blob - 9437ae62732372dd406441030766a276aeae1678
blob + 54f7e3d94bd940e1f09d6868a257a4d80f47f0ef
--- templates/admin_menu.tpl
+++ templates/admin_menu.tpl
<div id="menu">
<ul>
- <li><a target="_top" href="list-admin.php"><?php print $PALANG['pAdminMenu_list_admin']; ?></a></li>
- <li><a target="_top" href="list-domain.php"><?php print $PALANG['pAdminMenu_list_domain']; ?></a></li>
- <li><a target="_top" href="list-virtual.php"><?php print $PALANG['pAdminMenu_list_virtual']; ?></a></li>
- <li><a target="_top" href="viewlog.php"><?php print $PALANG['pAdminMenu_viewlog']; ?></a></li>
- <li><a target="_top" href="backup.php"><?php print $PALANG['pAdminMenu_backup']; ?></a></li>
- <li><a target="_top" href="create-domain.php"><?php print $PALANG['pAdminMenu_create_domain']; ?></a></li>
- <li><a target="_top" href="create-admin.php"><?php print $PALANG['pAdminMenu_create_admin']; ?></a></li>
- <?php $url = "create-alias.php"; if (isset($_GET['domain'])) $url .= "?domain=" . $_GET['domain']; ?>
- <li><a target="_top" href="<?php print $url; ?>"><?php print $PALANG['pAdminMenu_create_alias']; ?></a></li>
- <?php $url = "create-mailbox.php"; if (isset($_GET['domain'])) $url .= "?domain=" . $_GET['domain']; ?>
- <li><a target="_top" href="<?php print $url; ?>"><?php print $PALANG['pAdminMenu_create_mailbox']; ?></a></li>
+ <li><a target="_top" href="list-admin.php"><?php echo $PALANG['pAdminMenu_list_admin']; ?></a></li>
+ <li><a target="_top" href="list-domain.php"><?php echo $PALANG['pAdminMenu_list_domain']; ?></a></li>
+ <li><a target="_top" href="list-virtual.php"><?php echo $PALANG['pAdminMenu_list_virtual']; ?></a></li>
+ <li><a target="_top" href="viewlog.php"><?php echo $PALANG['pAdminMenu_viewlog']; ?></a></li>
+ <li><a target="_top" href="backup.php"><?php echo $PALANG['pAdminMenu_backup']; ?></a></li>
+ <li><a target="_top" href="domain.php"><?php echo $PALANG['pAdminMenu_create_domain']; ?></a></li>
+ <li><a target="_top" href="add-admin.php"><?php echo $PALANG['pAdminMenu_create_admin']; ?></a></li>
+ <li><a target="_top" href="add-alias.php<?php if (isset($domain)) echo '?domain=' . $domain; ?>"><?php echo $PALANG['pAdminMenu_create_alias']; ?></a></li>
+ <li><a target="_top" href="add-mailbox.php<?php if (isset($domain)) echo '?domain=' . $domain; ?>"><?php echo $PALANG['pAdminMenu_create_mailbox']; ?></a></li>
</ul>
</div>
-<?php
-if (file_exists(realpath("../motd-admin.txt"))) {
- print "<div id=\"motd\">\n";
- include("../motd-admin.txt");
- print "</div>";
-}
-?>
blob - 384b8b2f191de0fbca2fcd72b4a9f069b442a999
blob + c8ca0b248b7181b22151e86ad5eb04de535b6005
--- templates/create-alias.tpl
+++ templates/create-alias.tpl
<form name="create_alias" method="post">
<table>
<tr>
- <td colspan="3"><h3><?php print $PALANG['pCreate_alias_welcome']; ?></h3></td>
+ <td colspan="3"><h3><?php echo $PALANG['pCreate_alias_welcome']; ?></h3></td>
</tr>
<tr>
- <td><?php print $PALANG['pCreate_alias_address']; ?></td>
- <td><input class="flat" type="text" name="fAddress" value="<?php print $tAddress; ?>" /></td>
+ <td><?php echo $PALANG['pCreate_alias_address']; ?></td>
+ <td><input class="flat" type="text" name="address" value="<?php echo $address ?? ''; ?>" /></td>
<td>
- <select class="flat" name="fDomain">
+ <select class="flat" name="domain">
<?php
- for ($i = 0; $i < count($list_domains); $i++) {
- if ($tDomain == $list_domains[$i]) {
- print "<option value=\"$list_domains[$i]\" selected>$list_domains[$i]</option>\n";
- } else {
- print "<option value=\"$list_domains[$i]\">$list_domains[$i]</option>\n";
- }
- }
+
+ foreach ($list_domains as $row) {
+ echo '<option value="' . $row['domain'] . '"';
+ if (isset($domain) && $domain == $row['domain']) echo ' selected';
+ echo ">" . $row['domain'] . "</option>\n";
+ }
?>
</select>
- <?php print $pCreate_alias_address_text; ?>
</td>
</tr>
<tr>
- <td><?php print $PALANG['pCreate_alias_goto'] . ":"; ?></td>
- <td><input class="flat" type="text" name="fGoto" value="<?php print $tGoto; ?>" /></td>
- <td><?php print $pCreate_alias_goto_text; ?></td>
+ <td><?php echo $PALANG['pCreate_alias_goto'] . ":"; ?></td>
+ <td><input class="flat" type="text" name="goto" value="<?php echo $goto ?? ''; ?>" /></td>
+ <td><?php echo $PALANG['pCreate_alias_goto_text']; ?></td>
</tr>
<tr>
- <td colspan="3" class="hlp_center"><input class="button" type="submit" name="submit" value="<?php print $PALANG['pCreate_alias_button']; ?>" /></td>
+ <td colspan="3" class="hlp_center"><input class="button" type="submit" name="submit" value="<?php echo $PALANG['pCreate_alias_button']; ?>" /></td>
</tr>
<tr>
- <td colspan="3" class="standout"><?php print $tMessage; ?></td>
+ <td colspan="3" class="standout"><?php echo $message ?? ' '; ?></td>
</tr>
- <tr>
- <td colspan="3" class="help_text"><?php print $PALANG['pCreate_alias_catchall_text']; ?></td>
- </tr>
</table>
</div>
blob - 47328c811a27fd4fd8dc93decb8445763c1b16d0
blob + 1e2d5f25331c32ee1b488077fc9632ea076e8e2c
--- templates/footer.tpl
+++ templates/footer.tpl
<div id="footer">
-<a href="https://git.high5.nl/opensmtpdadmin/">OpenSMTPD Admin <?php print $version; ?></a>
+<a href="https://git.high5.nl/opensmtpdadmin/">OpenSMTPD Admin <?php echo VERSION ?></a>
<?php
if (($CONF['show_footer_text'] == "YES") and ($CONF['footer_link'])) {
print " | ";
blob - 51b9c0100973d6201eab4e10a6cb601823b3644c
blob + 19e083edbeb83c073a2009fe914d25047da1a658
--- templates/main.tpl
+++ templates/main.tpl
<div id="main_menu">
<table>
<tr>
- <td nowrap><a target="_top" href="overview.php"><?php print $PALANG['pMenu_overview']; ?></a></td>
+ <td nowrap><a target="_top" href="list-domains.php"><?php print $PALANG['pMenu_overview']; ?></a></td>
<td><?php print $PALANG['pMain_overview']; ?></td>
</tr>
<tr>
<td><?php print $PALANG['pMain_logout']; ?></td>
</tr>
</table>
-</div>
+/div>
blob - a38efffcbeb15d611687dd1a5b114b6cef093844
blob + 7b49e1a86794d0751396d6da00ee4c3cf3533e06
--- templates/menu.tpl
+++ templates/menu.tpl
<div id="menu">
<ul>
- <li><a target="_top" href="overview.php"><?php print $PALANG['pMenu_overview']; ?></a></li>
- <?php $url = "create-alias.php"; if (isset($_GET['domain'])) $url .= "?domain=" . $_GET['domain']; ?>
- <li><a target="_top" href="<?php print $url; ?>"><?php print $PALANG['pMenu_create_alias']; ?></a></li>
- <?php $url = "create-mailbox.php"; if (isset($_GET['domain'])) $url .= "?domain=" . $_GET['domain']; ?>
- <li><a target="_top" href="<?php print $url; ?>"><?php print $PALANG['pMenu_create_mailbox']; ?></a></li>
+ <li><a target="_top" href="list-domains.php"><?php print $PALANG['pMenu_overview']; ?></a></li>
+ <li><a target="_top" href="create-alias.php<?php if (isset($domain)) echo '?domain=' . $domain; ?>"><?php echo $PALANG['pMenu_create_alias']; ?></a></li>
+ <li><a target="_top" href="create-mailbox.php<?php if (isset($domain)) echo '?domain=' . $domain; ?>"><?php echo $PALANG['pMenu_create_mailbox']; ?></a></li>
<li><a target="_top" href="sendmail.php"><?php print $PALANG['pMenu_sendmail']; ?></a></li>
<li><a target="_top" href="password.php"><?php print $PALANG['pMenu_password']; ?></a></li>
<li><a target="_top" href="viewlog.php"><?php print $PALANG['pMenu_viewlog']; ?></a></li>
blob - be874e8d2180be9f49f98ef4d290d391efe5ce90
blob + 7d2fa98d8b83653a82feb89ac585cc25e2d0df5f
--- templates/message.tpl
+++ templates/message.tpl
-<?php print $tMessage; ?>
+<?php print $message ?? ''; ?>
blob - f1008d8ab91792a4506cb966e3615e9c7de3ac04
blob + 60992c2bc09dabd5c05aff76a6119c53e6e6b04c
--- templates/overview.tpl
+++ templates/overview.tpl
<div id="overview">
-<form name="overview" method="post">
-<select name="fDomain" onChange="this.form.submit()";>
+<form name="overview" method="get">
+<select class="flat" name="domain" onChange="this.form.submit()";>
<?php
-if ($limit['aliases'] == 0) $limit['aliases'] = $PALANG['pOverview_unlimited'];
-if ($limit['mailboxes'] == 0) $limit['mailboxes'] = $PALANG['pOverview_unlimited'];
-if ($limit['maxquota'] == 0) $limit['maxquota'] = $PALANG['pOverview_unlimited'];
-if ($limit['aliases'] < 0) $limit['aliases'] = $PALANG['pOverview_disabled'];
-if ($limit['mailboxes'] < 0) $limit['mailboxes'] = $PALANG['pOverview_disabled'];
-if ($limit['maxquota'] < 0) $limit['maxquota'] = $PALANG['pOverview_disabled'];
-
-for ($i = 0; $i < count($list_domains); $i++) {
- if ($fDomain == $list_domains[$i]) {
- print "<option value=\"$list_domains[$i]\" selected>$list_domains[$i]</option>\n";
- } else {
- print "<option value=\"$list_domains[$i]\">$list_domains[$i]</option>\n";
+if (count($list_domains) > 0) {
+ foreach ($list_domains as $row) {
+ echo '<option value="' . $row['domain'] . '"';
+ if (isset($_GET['domain']) && $_GET['domain'] == $row['domain']) echo ' selected';
+ echo ">" . $row['domain'] . "</option>\n";
}
}
+if ($list_domains[$selected_domain]['aliases'] == 0) $list_domains[$selected_domain]['aliases'] = $PALANG['pOverview_unlimited'];
+if ($list_domains[$selected_domain]['aliases'] < 0) $list_domains[$selected_domain]['aliases'] = $PALANG['pOverview_disabled'];
+if ($list_domains[$selected_domain]['mailboxes'] == 0) $list_domains[$selected_domain]['mailboxes'] = $PALANG['pOverview_unlimited'];
+if ($list_domains[$selected_domain]['mailboxes'] < 0) $list_domains[$selected_domain]['mailboxes'] = $PALANG['pOverview_disabled'];
+if ($list_domains[$selected_domain]['maxquota'] == 0) $list_domains[$selected_domain]['maxquota'] = $PALANG['pOverview_unlimited'];
+if ($list_domains[$selected_domain]['maxquota'] < 0) $list_domains[$selected_domain]['maxquota'] = $PALANG['pOverview_disabled'];
?>
</select>
-<input type="hidden" name="limit" value="0">
-<input class="button" type="submit" name="go" value="<?php print $PALANG['pOverview_button']; ?>" />
+<input type="hidden" name="offset" value="0">
+<input class="button" type="submit" name="go" value="<?php echo $PALANG['pOverview_button']; ?>" />
</form>
-<h4><?php print $PALANG['pOverview_welcome'] . $fDomain; ?></h4>
-<p><?php print $PALANG['pOverview_alias_alias_count'] . ": " . $limit['alias_count'] . " / " . $limit['aliases']; ?></p>
-<p><?php print $PALANG['pOverview_alias_mailbox_count'] . ": " . $limit['mailbox_count'] . " / " . $limit['mailboxes']; ?></p>
+
+<h4><?php echo $PALANG['pOverview_welcome'] . $_GET['domain']; ?></h4>
+<p><?php echo $PALANG['pOverview_alias_alias_count'] . ": " . $list_domains[$selected_domain]['alias_count'] . " / " . $list_domains[$selected_domain]['aliases']; ?></p>
+<p><?php echo $PALANG['pOverview_alias_mailbox_count'] . ": " . $list_domains[$selected_domain]['mailbox_count'] . " / " . $list_domains[$selected_domain]['mailboxes']; ?></p>
+
<form name="search" method="post" action="search.php">
-<input type="textbox" name="search" size="10">
+<input type="textbox" name="search" size="25">
</form>
</div>
-
<?php
-print "<div id=\"nav_bar\">\n";
-if ($tDisplay_back_show == 1) print "<a href=\"overview.php?domain=$fDomain&limit=$tDisplay_back\"><img border=\"0\" src=\"images/arrow-l.png\" title=\"" . $PALANG['pOverview_left_arrow'] . "\" alt=\"" . $PALANG['pOverview_left_arrow'] . "\"></a>\n";
-if ($tDisplay_up_show == 1) print "<a href=\"overview.php?domain=$fDomain&limit=0\"><img border=\"0\" src=\"images/arrow-u.png\" title=\"" . $PALANG['pOverview_up_arrow']."\" alt=\"" . $PALANG['pOverview_up_arrow'] . "\"></a>\n";
-if ($tDisplay_next_show == 1) print "<a href=\"overview.php?domain=$fDomain&limit=$tDisplay_next\"><img border=\"0\" src=\"images/arrow-r.png\" title=\"" . $PALANG['pOverview_right_arrow'] . "\" alt=\"" . $PALANG['pOverview_right_arrow'] . "\"></a>\n";
-print "</div>\n";
+if ($list_domains[$selected_domain]['alias_count'] > $limit || $list_domains[$selected_domain]['mailbox_count'] > $limit) {
+ echo "<div id=\"nav_bar\">\n";
+ if ($offset >= $limit) {
-if (count($tAlias) > 0) {
- print "<table id=\"alias_table\">\n";
- print " <tr>\n";
- print " <td colspan=\"5\"><h3>".$PALANG['pOverview_alias_title']."</h3></td>";
- print " </tr>";
- print " <tr class=\"header\">\n";
- print " <td>" . $PALANG['pOverview_alias_address'] . "</td>\n";
- print " <td>" . $PALANG['pOverview_alias_goto'] . "</td>\n";
- print " <td>" . $PALANG['pOverview_alias_modified'] . "</td>\n";
- print " <td colspan=\"2\"> </td>\n";
- print " </tr>\n";
+ echo "<a href=\"overview.php?domain=" . $_GET['domain'] . "&offset=" . ($offset - $limit) . "\"><img border=\"0\" src=\"images/arrow-l.png\" title=\"" . $PALANG['pOverview_left_arrow'] . "\"></a>\n";
+ }
+ if (($list_domains[$selected_domain]['alias_count'] > $limit) || ($list_domains[$selected_domain]['mailbox_count'] > $limit)) {
- for ($i = 0; $i < count($tAlias); $i++) {
- if ((is_array($tAlias) and count($tAlias) > 0)) {
- print " <tr class=\"hilightoff\" onMouseOver=\"className='hilighton';\" onMouseOut=\"className='hilightoff';\">\n";
- print " <td>" . $tAlias[$i]['address'] . "</td>\n";
- print " <td>" . preg_replace("/,/", "<br>", $tAlias[$i]['goto']) . "</td>\n";
- print " <td>" . $tAlias[$i]['modified'] . "</td>\n";
+ echo "<a href=\"overview.php?domain=" . $_GET['domain'] . "&offset=0\"><img border=\"0\" src=\"images/arrow-u.png\" title=\"" . $PALANG['pOverview_up_arrow'] . "\"></a>\n";
+ }
+ if ((($offset + $limit) < $list_domains[$selected_domain]['alias_count']) || (($offset + $limit) < $list_domains[$selected_domain]['mailbox_count'])) {
+ echo "<a href=\"overview.php?domain=" . $_GET['domain'] . "&offset=" . ($offset + $limit) . "\"><img border=\"0\" src=\"images/arrow-r.png\" title=\"" . $PALANG['pOverview_right_arrow'] . "\"></a>\n";
+ }
+ echo "</div>\n";
+}
+if (count($list_alias) > 0) {
+ echo "<table id=\"alias_table\">\n";
+ echo " <tr>\n";
+ echo " <td colspan=\"5\"><h3>".$PALANG['pOverview_alias_title']."</h3></td>";
+ echo " </tr>";
+ echo " <tr class=\"header\">\n";
+ echo " <td>" . $PALANG['pOverview_alias_address'] . "</td>\n";
+ echo " <td>" . $PALANG['pOverview_alias_goto'] . "</td>\n";
+ echo " <td>" . $PALANG['pOverview_alias_modified'] . "</td>\n";
+ echo " <td colspan=\"2\"> </td>\n";
+ echo " </tr>\n";
+
+ foreach ($list_alias as $row) {
+ echo " <tr class=\"hilightoff\" onMouseOver=\"className='hilighton';\" onMouseOut=\"className='hilightoff';\">\n";
+ echo " <td>" . $row['address'] . "</td>\n";
+ echo " <td>" . preg_replace("/,/", "<br>", $row['goto']) . "</td>\n";
+ echo " <td>" . $row['modified'] . "</td>\n";
+
if ($CONF['special_alias_control'] == 'YES') {
- print " <td><a href=\"edit-alias.php?address=" . urlencode($tAlias[$i]['address']) . "&domain=$fDomain" . "\">" . $PALANG['edit'] . "</a></td>\n";
- print " <td><a href=\"delete.php?delete=" . urlencode($tAlias[$i]['address']) . "&domain=$fDomain" . "\"onclick=\"return confirm ('" . $PALANG['confirm'] . $PALANG['pOverview_get_aliases'] . ": ". $tAlias[$i]['address'] . "')\">" . $PALANG['del'] . "</a></td>\n";
+ echo " <td><a href=\"edit-alias.php?address=" . urlencode($row['address']) . "&domain=fDomain" . "\">" . $PALANG['edit'] . "</a></td>\n";
+ echo " <td><a href=\"delete.php?delete=" . urlencode($row['address']) . "&domain=$fDomain" . "\"onclick=\"return confirm ('" . $PALANG['confirm'] . $PALANG['pOverview_get_aliases'] . ": ". $row['address'] . "')\">" . $PALANG['del'] . "</a></td>\n";
} else {
- if (!in_array($tAlias[$i]['goto'], $CONF['default_aliases'])) {
- print " <td><a href=\"edit-alias.php?address=" . urlencode($tAlias[$i]['address']) . "&domain=$fDomain" . "\">" . $PALANG['edit'] . "</a></td>\n";
- print " <td><a href=\"delete.php?delete=" . urlencode($tAlias[$i]['address']) . "&domain=$fDomain" . "\"onclick=\"return confirm ('" . $PALANG['confirm'] . $PALANG['pOverview_get_aliases'] . ": ". $tAlias[$i]['address'] . "')\">" . $PALANG['del'] . "</a></td>\n";
+ if (!in_array($row['goto'], $CONF['default_aliases'])) {
+ echo " <td><a href=\"edit-alias.php?address=" . urlencode($row['address']) . "&domain=fDomain" . "\">" . $PALANG['edit'] . "</a></td>\n";
+ echo " <td><a href=\"delete.php?delete=" . urlencode($row['address']) . "&domain=fDomain" . "\"onclick=\"return confirm ('" . $PALANG['confirm'] . $PALANG['pOverview_get_aliases'] . ": ". $row['address'] . "')\">" . $PALANG['del'] . "</a></td>\n";
} else {
- print " <td> </td>\n";
- print " <td> </td>\n";
+ echo " <td> </td>\n";
+ echo " <td> </td>\n";
}
}
- print " </tr>\n";
- }
+ echo " </tr>\n";
}
- print "</table>\n";
+ echo "</table>\n";
}
-if (count($tMailbox) > 0) {
- print "<table id=\"mailbox_table\">\n";
- print " <tr>\n";
- print " <td colspan=\"7\"><h3>".$PALANG['pOverview_mailbox_title']."</h3></td>";
- print " </tr>";
- print " <tr class=\"header\">\n";
- print " <td>" . $PALANG['pOverview_mailbox_username'] . "</td>\n";
- print " <td>" . $PALANG['pOverview_mailbox_name'] . "</td>\n";
- if ($CONF['quota'] == 'YES') print " <td>" . $PALANG['pOverview_mailbox_quota'] . "</td>\n";
- print " <td>" . $PALANG['pOverview_mailbox_modified'] . "</td>\n";
- print " <td>" . $PALANG['pOverview_mailbox_active'] . "</td>\n";
- print " <td colspan=\"2\"> </td>\n";
- print " </tr>\n";
+if (count($list_mailbox) > 0) {
+ echo "<table id=\"mailbox_table\">\n";
+ echo " <tr>\n";
+ echo " <td colspan=\"7\"><h3>".$PALANG['pOverview_mailbox_title']."</h3></td>";
+ echo " </tr>";
+ echo " <tr class=\"header\">\n";
+ echo " <td>" . $PALANG['pOverview_mailbox_username'] . "</td>\n";
+ echo " <td>" . $PALANG['pOverview_mailbox_name'] . "</td>\n";
+ echo " <td>" . $PALANG['pOverview_mailbox_modified'] . "</td>\n";
+ echo " <td>" . $PALANG['pOverview_mailbox_active'] . "</td>\n";
+ echo " <td colspan=\"2\"> </td>\n";
+ echo " </tr>\n";
- for ($i = 0; $i < count($tMailbox); $i++) {
- if ((is_array($tMailbox) and count($tMailbox) > 0)) {
- print " <tr class=\"hilightoff\" onMouseOver=\"className='hilighton';\" onMouseOut=\"className='hilightoff';\">\n";
- print " <td>" . $tMailbox[$i]['username'] . "</td>\n";
- print " <td>" . $tMailbox[$i]['name'] . "</td>\n";
- if ($CONF['quota'] == 'YES') {
- print " <td>";
- if ($tMailbox[$i]['quota'] == 0) {
- print $PALANG['pOverview_unlimited'];
- } elseif ($tMailbox[$i]['quota'] < 0) {
- print $PALANG['pOverview_disabled'];
- } else {
- print $tMailbox[$i]['quota'] / $CONF['quota_multiplier'];
- }
- print "</td>\n";
- }
- print " <td>" . $tMailbox[$i]['modified'] . "</td>\n";
- $active = ($tMailbox[$i]['active'] == 1) ? $PALANG['YES'] : $PALANG['NO'];
- print " <td><a href=\"edit-active.php?username=" . urlencode($tMailbox[$i]['username']) . "&domain=$fDomain" . "\">" . $active . "</a></td>\n";
- print " <td><a href=\"edit-mailbox.php?username=" . urlencode($tMailbox[$i]['username']) . "&domain=$fDomain" . "\">" . $PALANG['edit'] . "</a></td>\n";
- print " <td><a href=\"delete.php?delete=" . urlencode($tMailbox[$i]['username']) . "&domain=$fDomain" . "\"onclick=\"return confirm ('" . $PALANG['confirm'] . $PALANG['pOverview_get_mailboxes'] . ": ". $tMailbox[$i]['username'] . "')\">" . $PALANG['del'] . "</a></td>\n";
- print " </tr>\n";
- }
+ foreach ($list_mailbox as $row) {
+ echo " <tr class=\"hilightoff\" onMouseOver=\"className='hilighton';\" onMouseOut=\"className='hilightoff';\">\n";
+ echo " <td>" . $row['username'] . "</td>\n";
+ echo " <td>" . $row['name'] . "</td>\n";
+ echo " <td>" . $row['modified'] . "</td>\n";
+ $active = ($row['active'] == 1) ? $PALANG['YES'] : $PALANG['NO'];
+ echo " <td><a href=\"edit-active.php?username=" . urlencode($row['username']) . "&domain=$fDomain" . "\">" . $active . "</a></td>\n";
+ echo " <td><a href=\"edit-mailbox.php?username=" . urlencode($row['username']) . "&domain=$fDomain" . "\">" . $PALANG['edit'] . "</a></td>\n";
+ echo " <td><a href=\"delete.php?delete=" . urlencode($row['username']) . "&domain=$fDomain" . "\"onclick=\"return confirm ('" . $PALANG['confirm'] . $PALANG['pOverview_get_mailboxes'] . ": ". $row['username'] . "')\">" . $PALANG['del'] . "</a></td>\n";
+ echo " </tr>\n";
}
- print "</table>\n";
+ echo "</table>\n";
}
?>