merge admin + superadmin
This commit is contained in:
parent
525cdfa64e
commit
ff6266ff1d
|
@ -16,7 +16,7 @@
|
|||
// domain
|
||||
// goto
|
||||
//
|
||||
// Form POST / GET Variables:
|
||||
// POST / GET Variables:
|
||||
//
|
||||
// address
|
||||
// domain
|
||||
|
@ -26,9 +26,16 @@ require_once './functions.inc.php';
|
|||
include './languages/' . check_language() . '.lang';
|
||||
|
||||
$SESSID_USERNAME = check_session();
|
||||
$list_domains = list_domains($SESSID_USERNAME);
|
||||
$PERMISSIONS = check_permissions();
|
||||
$admin = $SESSID_USERNAME ?? ADMIN_EMAIL;
|
||||
|
||||
if ($PERMISSIONS == ADMIN_RIGHTS) {
|
||||
$list_domains = list_domains();
|
||||
$list_admins = list_admins();
|
||||
} else {
|
||||
$list_domains = list_domains($SESSID_USERNAME);
|
||||
}
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] == "GET") {
|
||||
$domain = filter_input(INPUT_GET, 'domain', FILTER_VALIDATE_DOMAIN);
|
||||
$domain_key = array_search($domain, array_column($list_domains, 'domain'));
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
// name
|
||||
// domain
|
||||
//
|
||||
// Form POST / GET Variables:
|
||||
// POST / GET Variables:
|
||||
//
|
||||
// username
|
||||
// password1
|
||||
|
@ -28,9 +28,16 @@ require_once './functions.inc.php';
|
|||
include './languages/' . check_language() . '.lang';
|
||||
|
||||
$SESSID_USERNAME = check_session();
|
||||
$list_domains = list_domains($SESSID_USERNAME);
|
||||
$PERMISSIONS = check_permissions();
|
||||
$admin = $SESSID_USERNAME ?? ADMIN_EMAIL;
|
||||
|
||||
if ($PERMISSIONS == ADMIN_RIGHTS) {
|
||||
$list_domains = list_domains();
|
||||
$list_admins = list_admins();
|
||||
} else {
|
||||
$list_domains = list_domains($SESSID_USERNAME);
|
||||
}
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] == "GET") {
|
||||
$domain = filter_input(INPUT_GET, 'domain', FILTER_VALIDATE_DOMAIN);
|
||||
$domain_key = array_search($domain, array_column($list_domains, 'domain'));
|
||||
|
|
|
@ -1,8 +0,0 @@
|
|||
AuthUserFile /usr/local/www/mailadmin.high5.net/admin/.htpasswd
|
||||
AuthGroupFile /dev/null
|
||||
AuthName "Postfix Admin"
|
||||
AuthType Basic
|
||||
|
||||
<limit GET POST>
|
||||
require valid-user
|
||||
</limit>
|
|
@ -1,79 +0,0 @@
|
|||
<?php
|
||||
//
|
||||
// OpenSMTPD Admin
|
||||
// by Mischa Peters <mischa at high5 dot nl>
|
||||
// Copyright (c) 2022 High5!
|
||||
// License Info: LICENSE.TXT
|
||||
//
|
||||
// File: add-alias.php
|
||||
//
|
||||
// Template File: add-alias.tpl
|
||||
//
|
||||
// Template Variables:
|
||||
//
|
||||
// message
|
||||
// address
|
||||
// domain
|
||||
// goto
|
||||
//
|
||||
// Form POST / GET Variables:
|
||||
//
|
||||
// address
|
||||
// domain
|
||||
// goto
|
||||
//
|
||||
require_once '../functions.inc.php';
|
||||
include '../languages/' . check_language() . '.lang';
|
||||
|
||||
$list_domains = list_domains();
|
||||
$admin = $SESSID_USERNAME ?? ADMIN_EMAIL;
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] == "GET") {
|
||||
$domain = filter_input(INPUT_GET, 'domain', FILTER_VALIDATE_DOMAIN);
|
||||
$domain_key = array_search($domain, array_column($list_domains, 'domain'));
|
||||
$domain_exist = in_array($domain, array_column($list_domains, 'domain'));
|
||||
}
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] == "POST") {
|
||||
$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'));
|
||||
$domain_exist = in_array($domain, array_column($list_domains, 'domain'));
|
||||
$from = filter_var($address . '@' . $domain, FILTER_VALIDATE_EMAIL);
|
||||
|
||||
if (!str_contains($goto, '@')) {
|
||||
$goto = $goto . "@" . $domain;
|
||||
}
|
||||
$goto = filter_var($goto, FILTER_VALIDATE_EMAIL);
|
||||
|
||||
if ($list_domains[$domain_key]['aliases'] != 0 && $list_domains[$domain_key]['alias_count'] >= $list_domains[$domain_key]['aliases']) {
|
||||
$message = $LANG['Add_alias_address_text_error2'];
|
||||
}
|
||||
|
||||
if (empty($address) || empty($goto)) {
|
||||
$message = $LANG['Add_alias_address_text_error1'];
|
||||
}
|
||||
|
||||
if ($domain_exist && empty($message)) {
|
||||
try {
|
||||
$dbh = pdo_connect();
|
||||
$sth = $dbh->prepare("INSERT INTO alias (address,goto,domain,created,modified) VALUES (?,?,?,NOW(),NOW())");
|
||||
$sth->bindParam(1, $from, PDO::PARAM_STR);
|
||||
$sth->bindParam(2, $goto, PDO::PARAM_STR);
|
||||
$sth->bindParam(3, $domain, PDO::PARAM_STR);
|
||||
$sth->execute();
|
||||
logging($admin, $domain, $LANG['Logging_alias_add'], "$from -> $goto");
|
||||
$message = $LANG['Add_alias_result_succes'] . "<br />($from -> $goto)</br />";
|
||||
$address = '';
|
||||
$goto = '';
|
||||
} catch(PDOException $e) {
|
||||
$message = $LANG['Add_alias_result_error'] . "<br />($from -> $goto)<br />";
|
||||
}
|
||||
}
|
||||
}
|
||||
include '../templates/header.tpl';
|
||||
include '../templates/admin_menu.tpl';
|
||||
include '../templates/add-alias.tpl';
|
||||
include '../templates/footer.tpl';
|
||||
?>
|
|
@ -1,98 +0,0 @@
|
|||
<?php
|
||||
//
|
||||
// OpenSMTPD Admin
|
||||
// by Mischa Peters <mischa at high5 dot nl>
|
||||
// Copyright (c) 2022 High5!
|
||||
// License Info: LICENSE.TXT
|
||||
//
|
||||
// File: add-mailbox.php
|
||||
//
|
||||
// Template File: add-mailbox.tpl
|
||||
//
|
||||
// Template Variables:
|
||||
//
|
||||
// message
|
||||
// username
|
||||
// name
|
||||
// domain
|
||||
//
|
||||
// Form POST / GET Variables:
|
||||
//
|
||||
// username
|
||||
// password1
|
||||
// password2
|
||||
// name
|
||||
// domain
|
||||
//
|
||||
require_once '../functions.inc.php';
|
||||
include '../languages/' . check_language() . '.lang';
|
||||
|
||||
$list_domains = list_domains();
|
||||
$admin = $SESSID_USERNAME ?? ADMIN_EMAIL;
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] == "GET") {
|
||||
$domain = filter_input(INPUT_GET, 'domain', FILTER_VALIDATE_DOMAIN);
|
||||
$domain_key = array_search($domain, array_column($list_domains, 'domain'));
|
||||
$domain_exist = in_array($domain, array_column($list_domains, 'domain'));
|
||||
}
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] == "POST") {
|
||||
$username = strtolower(filter_input(INPUT_POST, 'username', FILTER_DEFAULT));
|
||||
$domain = filter_input(INPUT_POST, 'domain', FILTER_VALIDATE_DOMAIN);
|
||||
$password1 = filter_input(INPUT_POST, 'password1', FILTER_DEFAULT);
|
||||
$password2 = filter_input(INPUT_POST, 'password2', FILTER_DEFAULT);
|
||||
$name = filter_input(INPUT_POST, 'name', FILTER_DEFAULT);
|
||||
$domain_key = array_search($domain, array_column($list_domains, 'domain'));
|
||||
$domain_exist = in_array($domain, array_column($list_domains, 'domain'));
|
||||
$from = filter_var($username . '@' . $domain, FILTER_VALIDATE_EMAIL);
|
||||
|
||||
if ($list_domains[$domain_key]['mailboxes'] != 0 && $list_domains[$domain_key]['mailbox_count'] >= $list_domains[$domain_key]['mailboxes']) {
|
||||
$message = $LANG['Add_mailbox_username_text_error3'];
|
||||
}
|
||||
|
||||
if (empty($username)) {
|
||||
$message = $LANG['Add_mailbox_username_text_error1'];
|
||||
}
|
||||
|
||||
if (empty($password1) or ($password1 != $password2)) {
|
||||
$message = $LANG['Add_mailbox_password_text_error'];
|
||||
}
|
||||
|
||||
if ($domain_exist && empty($message)) {
|
||||
$hashed = bcrypt($password1);
|
||||
$maildir = $from . "/";
|
||||
|
||||
try {
|
||||
$dbh = pdo_connect();
|
||||
$sth = $dbh->prepare("INSERT INTO alias (address,goto,domain,created,modified) VALUES (?,'vmail',?,NOW(),NOW())");
|
||||
$sth->bindParam(1, $from, PDO::PARAM_STR);
|
||||
$sth->bindParam(2, $domain, PDO::PARAM_STR);
|
||||
$sth->execute();
|
||||
$username = '';
|
||||
} catch(PDOException $e) {
|
||||
$message = $LANG['Add_alias_result_error'] . "<br />($from) - $e<br />";
|
||||
}
|
||||
|
||||
try {
|
||||
$dbh = pdo_connect();
|
||||
$sth = $dbh->prepare("INSERT INTO mailbox (username,password,name,maildir,domain,created,modified) VALUES (?,?,?,?,?,NOW(),NOW())");
|
||||
$sth->bindParam(1, $from, PDO::PARAM_STR);
|
||||
$sth->bindParam(2, $hashed, PDO::PARAM_STR);
|
||||
$sth->bindParam(3, $name, PDO::PARAM_STR);
|
||||
$sth->bindParam(4, $maildir, PDO::PARAM_STR);
|
||||
$sth->bindParam(5, $domain, PDO::PARAM_STR);
|
||||
$sth->execute();
|
||||
logging($admin, $domain, $LANG['Logging_mailbox_add'], "$from");
|
||||
$message = $LANG['Add_mailbox_result_succes'] . "<br />($from)";
|
||||
$username = '';
|
||||
$name = '';
|
||||
} catch(PDOException $e) {
|
||||
$message = $LANG['Add_alias_result_error'] . "<br />($from) - $e<br />";
|
||||
}
|
||||
}
|
||||
}
|
||||
include '../templates/header.tpl';
|
||||
include '../templates/admin_menu.tpl';
|
||||
include '../templates/add-mailbox.tpl';
|
||||
include '../templates/footer.tpl';
|
||||
?>
|
135
admin/admin.php
135
admin/admin.php
|
@ -1,135 +0,0 @@
|
|||
<?php
|
||||
//
|
||||
// OpenSMTPD Admin
|
||||
// by Mischa Peters <mischa at high5 dot nl>
|
||||
// Copyright (c) 2022 High5!
|
||||
// License Info: LICENSE.TXT
|
||||
//
|
||||
// File: admin.php
|
||||
//
|
||||
// Template File: admin_admin.tpl
|
||||
//
|
||||
//
|
||||
// Template Variables:
|
||||
//
|
||||
// action
|
||||
// message
|
||||
// username
|
||||
// domains
|
||||
//
|
||||
// Form POST / GET Variables:
|
||||
//
|
||||
// username
|
||||
// password1
|
||||
// password2
|
||||
// domains
|
||||
//
|
||||
require_once '../functions.inc.php';
|
||||
include '../languages/' . check_language() . '.lang';
|
||||
|
||||
$list_domains = list_domains();
|
||||
$list_admins = list_admins();
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] == "GET") {
|
||||
$action = filter_input(INPUT_GET, 'action', FILTER_DEFAULT) ?? 'add';
|
||||
if ($action == 'edit') {
|
||||
$username = filter_input(INPUT_GET, 'username', FILTER_VALIDATE_EMAIL);
|
||||
$domains['domains'] = array_column(list_domains($username), 'domain');
|
||||
}
|
||||
}
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] == "POST") {
|
||||
$action = filter_input(INPUT_GET, 'action', FILTER_DEFAULT) ?? 'add';
|
||||
$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 ($action == 'add') {
|
||||
if (empty($username) || in_array($username, array_column($list_admins, 'username'))) {
|
||||
$message = $LANG['AdminAdd_admin_username_error'];
|
||||
}
|
||||
|
||||
if (empty($password1) || $password1 != $password2) {
|
||||
$message = $LANG['AdminAdd_admin_password_error'];
|
||||
}
|
||||
|
||||
if (empty($domains['domains'])) {
|
||||
$message = $LANG['AdminAdd_admin_domain_error'];
|
||||
}
|
||||
|
||||
if (empty($message)) {
|
||||
$hashed = bcrypt($password1);
|
||||
try {
|
||||
$dbh = pdo_connect();
|
||||
$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 = $LANG['AdminAdd_admin_result_succes'] . "<br />($username)</br />";
|
||||
} catch(PDOException $e) {
|
||||
$message = $LANG['AdminAdd_admin_result_error'] . "<br />($username)<br />";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (in_array($username, array_column($list_admins, 'username')) && $action == 'edit') {
|
||||
if ($password1 != $password2) {
|
||||
$message = $LANG['AdminAdd_admin_password_error'];
|
||||
}
|
||||
if (empty($message) && !empty($password1)) {
|
||||
$hashed = bcrypt($password1);
|
||||
try {
|
||||
$dbh = pdo_connect();
|
||||
$sth = $dbh->prepare("UPDATE admin SET password=?,modified=NOW() WHERE username=?");
|
||||
$sth->bindParam(1, $hashed, PDO::PARAM_STR);
|
||||
$sth->bindParam(2, $username, PDO::PARAM_STR);
|
||||
$sth->execute();
|
||||
} catch(PDOException $e) {
|
||||
$message = $LANG['AdminEdit_admin_result_error'] . "<br />($username)<br />";
|
||||
}
|
||||
}
|
||||
|
||||
if (empty($domains['domains'])) {
|
||||
$message = $LANG['AdminAdd_admin_domain_error'];
|
||||
}
|
||||
if (empty($message)) {
|
||||
try {
|
||||
$dbh = pdo_connect();
|
||||
$sth = $dbh->prepare("SELECT COUNT(*) FROM domain_admins WHERE username=?");
|
||||
$sth->execute(array($username));
|
||||
$count_domain_admins = $sth->fetchColumn();
|
||||
|
||||
$sth = $dbh->prepare("DELETE FROM domain_admins WHERE username=?");
|
||||
$sth->execute(array($username));
|
||||
if ($sth->rowCount() != $count_domain_admins) {
|
||||
throw new RuntimeException('Unable to delete entries from the domain_admins table.');
|
||||
}
|
||||
|
||||
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();
|
||||
}
|
||||
header("Location: list-admin.php");
|
||||
} catch (RuntimeException $e) {
|
||||
$message = $LANG['AdminEdit_admin_result_error'];
|
||||
} catch (PDOException $e) {
|
||||
$message = $LANG['AdminEdit_admin_result_error'];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
include '../templates/header.tpl';
|
||||
include '../templates/admin_menu.tpl';
|
||||
include '../templates/admin_admin.tpl';
|
||||
include '../templates/footer.tpl';
|
||||
?>
|
|
@ -1,68 +0,0 @@
|
|||
<?php
|
||||
//
|
||||
// OpenSMTPD Admin
|
||||
// by Mischa Peters <mischa at high5 dot nl>
|
||||
// Copyright (c) 2022 High5!
|
||||
// License Info: LICENSE.TXT
|
||||
//
|
||||
// File: backup.php
|
||||
//
|
||||
// Template File: -none-
|
||||
//
|
||||
// Template Variables:
|
||||
//
|
||||
// -none-
|
||||
//
|
||||
// Form POST / GET Variables:
|
||||
//
|
||||
// -none-
|
||||
//
|
||||
require_once '../functions.inc.php';
|
||||
include '../languages/' . check_language() . '.lang';
|
||||
date_default_timezone_set('Europe/Amsterdam');
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] == "GET") {
|
||||
umask(077);
|
||||
$filename = "opensmtpadmin-" . date("Ymd") . "-" . getmypid() . ".sql";
|
||||
$backup = "/tmp" . $filename;
|
||||
$header = "#\n# OpenSMTPD Admin " . VERSION . "\n# Date: " . date("D M j G:i:s T Y") . "\n#\n";
|
||||
$tables = array('admin','alias','domain','domain_admins','log','mailbox','vacation');
|
||||
|
||||
if (!$fh = fopen($backup, 'w')) {
|
||||
$message = "<div class=\"error_msg\">Cannot open file ($backup)</div>";
|
||||
include '../templates/header.tpl';
|
||||
include '../templates/admin_menu.tpl';
|
||||
include '../templates/message.tpl';
|
||||
include '../templates/footer.tpl';
|
||||
} else {
|
||||
fwrite($fh, $header);
|
||||
$dbh = pdo_connect();
|
||||
foreach ($tables as $table) {
|
||||
$sth = $dbh->query("SHOW CREATE TABLE $table");
|
||||
$row = $sth->fetch(PDO::FETCH_ASSOC);
|
||||
fwrite ($fh, $row['Create Table']. "\n\n");
|
||||
}
|
||||
|
||||
foreach ($tables as $table) {
|
||||
$sth = $dbh->query("SELECT * FROM $table");
|
||||
while ($row = $sth->fetch(PDO::FETCH_ASSOC)) {
|
||||
foreach ($row as $k => $v) {
|
||||
$keys[] = $k;
|
||||
$values[] = $v;
|
||||
}
|
||||
fwrite($fh, "INSERT INTO ". $table . " (". implode (',',$keys) . ") VALUES ('" . implode ('\',\'',$values) . "')\n");
|
||||
$keys = array();
|
||||
$values = array();
|
||||
}
|
||||
}
|
||||
}
|
||||
header("Content-Type: application/octet-stream");
|
||||
header("Content-Disposition: attachment; filename=\"$filename\"");
|
||||
header("Content-Transfer-Encoding: binary");
|
||||
header("Content-Length: " . filesize("$backup"));
|
||||
header("Content-Description: OpenSMTPD Admin");
|
||||
$download_backup = fopen("$backup", "r");
|
||||
unlink("$backup");
|
||||
fpassthru($download_backup);
|
||||
}
|
||||
?>
|
193
admin/delete.php
193
admin/delete.php
|
@ -1,193 +0,0 @@
|
|||
<?php
|
||||
//
|
||||
// OpenSMTPD Admin
|
||||
// by Mischa Peters <mischa at high5 dot nl>
|
||||
// Copyright (c) 2022 High5!
|
||||
// License Info: LICENSE.TXT
|
||||
//
|
||||
// File: delete.php
|
||||
//
|
||||
// Template File: message.tpl
|
||||
//
|
||||
// Template Variables:
|
||||
//
|
||||
// message
|
||||
//
|
||||
// Form POST / GET Variables:
|
||||
//
|
||||
// table
|
||||
// where
|
||||
// delete
|
||||
// domain
|
||||
//
|
||||
require_once '../functions.inc.php';
|
||||
include '../languages/' . check_language() . '.lang';
|
||||
|
||||
$list_domains = list_domains();
|
||||
$admin = $SESSID_USERNAME ?? ADMIN_EMAIL;
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] == "GET") {
|
||||
$table = filter_input(INPUT_GET, 'table', FILTER_DEFAULT);
|
||||
$delete = filter_input(INPUT_GET, 'delete', FILTER_DEFAULT);
|
||||
$domain = filter_input(INPUT_GET, 'domain', FILTER_VALIDATE_DOMAIN);
|
||||
$domain_key = array_search($domain, array_column($list_domains, 'domain'));
|
||||
$domain_exist = in_array($domain, array_column($list_domains, 'domain'));
|
||||
|
||||
if ($domain_exist && $table == "domain") {
|
||||
try {
|
||||
$dbh = pdo_connect();
|
||||
$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 ($table == "admin") {
|
||||
try {
|
||||
$dbh = pdo_connect();
|
||||
$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();
|
||||
$dbh->rollBack();
|
||||
}
|
||||
}
|
||||
|
||||
if ($domain_exist && ($table == 'alias' || $table == 'mailbox')) {
|
||||
try {
|
||||
$dbh = pdo_connect();
|
||||
$sth = $dbh->prepare("DELETE FROM alias WHERE address=? AND domain=?");
|
||||
$sth->bindParam(1, $delete, PDO::PARAM_STR);
|
||||
$sth->bindParam(2, $domain, PDO::PARAM_STR);
|
||||
$sth->execute();
|
||||
if ($sth->rowCount() != 1) {
|
||||
throw new RuntimeException('alias');
|
||||
}
|
||||
logging($admin, $domain, $LANG['Logging_alias_delete'], $delete);
|
||||
|
||||
header("Location: list-virtual.php?domain=$domain");
|
||||
} catch (RuntimeException $e) {
|
||||
$message = $LANG['Delete_delete_error'] . "<b>$delete</b> (" . $e->getMessage() . ")!</span>";
|
||||
} catch (PDOException $e) {
|
||||
$message = $LANG['Delete_delete_error'] . "<b>$delete</b> (alias)!</span> " . $e-getMessage();
|
||||
}
|
||||
|
||||
try {
|
||||
$dbh = pdo_connect();
|
||||
$sth = $dbh->prepare("DELETE FROM mailbox WHERE username=? AND domain=?");
|
||||
$sth->bindParam(1, $delete, PDO::PARAM_STR);
|
||||
$sth->bindParam(2, $domain, PDO::PARAM_STR);
|
||||
$sth->execute();
|
||||
if ($sth->rowCount() != 1) {
|
||||
throw new RuntimeException('mailbox');
|
||||
}
|
||||
logging($admin, $domain, $LANG['Logging_mailbox_delete'], $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 = $LANG['Delete_delete_error'] . "<b>$delete</b> (" . $e->getMessage() . ")!</span>";
|
||||
} catch (PDOException $e) {
|
||||
$message = $LANG['Delete_delete_error'] . "<b>$delete</b> (mailbox)!</span>";
|
||||
}
|
||||
}
|
||||
}
|
||||
include '../templates/header.tpl';
|
||||
include '../templates/admin_menu.tpl';
|
||||
include '../templates/message.tpl';
|
||||
include '../templates/footer.tpl';
|
||||
?>
|
|
@ -1,88 +0,0 @@
|
|||
<?php
|
||||
//
|
||||
// OpenSMTPD Admin
|
||||
// by Mischa Peters <mischa at high5 dot nl>
|
||||
// Copyright (c) 2022 High5!
|
||||
// License Info: LICENSE.TXT
|
||||
//
|
||||
// File: domain.php
|
||||
//
|
||||
// Template File: admin_domain.tpl
|
||||
//
|
||||
// Template Variables:
|
||||
//
|
||||
// action
|
||||
// message
|
||||
// domain
|
||||
// description
|
||||
// aliases
|
||||
// mailboxes
|
||||
//
|
||||
// Form POST / GET Variables:
|
||||
//
|
||||
// domain
|
||||
// description
|
||||
// aliases
|
||||
// mailboxes
|
||||
//
|
||||
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) ?? 'add';
|
||||
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) ?? 'add';
|
||||
$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 = pdo_connect();
|
||||
$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 = $LANG['AdminAdd_domain_result_succes'] . "<br />($domain)</br />";
|
||||
} catch(PDOException $e) {
|
||||
$message = $LANG['AdminAdd_domain_result_error'] . "<br />($domain)<br />";
|
||||
}
|
||||
} else {
|
||||
$message = $LANG['AdminAdd_domain_domain_text_error'];
|
||||
}
|
||||
|
||||
if (in_array($domain, array_column($list_domains, 'domain')) && $action == 'edit') {
|
||||
try {
|
||||
$dbh = pdo_connect();
|
||||
$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 = $LANG['AdminEdit_domain_result_error'];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
include '../templates/header.tpl';
|
||||
include '../templates/admin_menu.tpl';
|
||||
include '../templates/admin_domain.tpl';
|
||||
include '../templates/footer.tpl';
|
||||
?>
|
|
@ -1,93 +0,0 @@
|
|||
<?php
|
||||
//
|
||||
// OpenSMTPD Admin
|
||||
// by Mischa Peters <mischa at high5 dot nl>
|
||||
// Copyright (c) 2022 High5!
|
||||
// License Info: LICENSE.TXT
|
||||
//
|
||||
// File: edit-alias.php
|
||||
//
|
||||
// Template File: edit-alias.tpl
|
||||
//
|
||||
// Template Variables:
|
||||
//
|
||||
// message
|
||||
// goto
|
||||
//
|
||||
// Form POST / GET Variables:
|
||||
//
|
||||
// address
|
||||
// domain
|
||||
// goto
|
||||
//
|
||||
require_once '../functions.inc.php';
|
||||
include '../languages/' . check_language() . '.lang';
|
||||
|
||||
$list_domains = list_domains();
|
||||
$admin = $SESSID_USERNAME ?? ADMIN_EMAIL;
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] == "GET") {
|
||||
$address = filter_input(INPUT_GET, 'address', FILTER_VALIDATE_EMAIL);
|
||||
$domain = filter_input(INPUT_GET, 'domain', FILTER_VALIDATE_DOMAIN);
|
||||
$domain_key = array_search($domain, array_column($list_domains, 'domain'));
|
||||
$domain_exist = in_array($domain, array_column($list_domains, 'domain'));
|
||||
|
||||
if ($domain_exist) {
|
||||
try {
|
||||
$dbh = pdo_connect();
|
||||
$sth = $dbh->prepare("SELECT goto FROM alias WHERE address=? AND domain=?");
|
||||
$sth->bindParam(1, $address, PDO::PARAM_STR);
|
||||
$sth->bindParam(2, $domain, PDO::PARAM_STR);
|
||||
$sth->execute();
|
||||
$goto = $sth->fetch(PDO::FETCH_COLUMN);
|
||||
$goto = explode(',', $goto);
|
||||
} catch(PDOException $e) {
|
||||
$message = $LANG['Edit_alias_address_error'];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] == "POST") {
|
||||
$address = strtolower(filter_input(INPUT_GET, 'address', FILTER_VALIDATE_EMAIL));
|
||||
$domain = strtolower(filter_input(INPUT_GET, 'domain', FILTER_VALIDATE_DOMAIN));
|
||||
$goto = strtolower(filter_input(INPUT_POST, 'goto', FILTER_DEFAULT));
|
||||
$domain_key = array_search($domain, array_column($list_domains, 'domain'));
|
||||
$domain_exist = in_array($domain, array_column($list_domains, 'domain'));
|
||||
|
||||
if (empty($goto)) {
|
||||
$goto = array();
|
||||
$message = $LANG['Edit_alias_goto_text_error1'];
|
||||
} else {
|
||||
$goto = preg_replace('/\\\r\\\n/', ',', $goto);
|
||||
$goto = preg_replace('/\r\n/', ',', $goto);
|
||||
$goto = preg_replace('/[\s]+/i', '', $goto);
|
||||
$goto = preg_replace('/\,*$/', '', $goto);
|
||||
$validate_goto = explode(',', $goto);
|
||||
foreach ($validate_goto as $row) {
|
||||
if (!filter_var($row, FILTER_VALIDATE_EMAIL)) {
|
||||
$goto = explode(',', $goto);
|
||||
$message = $LANG['Edit_alias_goto_text_error2'] . "$row</div>";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($domain_exist && empty($message)) {
|
||||
try {
|
||||
$dbh = pdo_connect();
|
||||
$sth = $dbh->prepare("UPDATE alias SET goto=?,modified=NOW() WHERE address=? AND domain=?");
|
||||
$sth->bindParam(1, $goto, PDO::PARAM_STR);
|
||||
$sth->bindParam(2, $address, PDO::PARAM_STR);
|
||||
$sth->bindParam(3, $domain, PDO::PARAM_STR);
|
||||
$sth->execute();
|
||||
logging($admin, $domain, $LANG['Logging_alias_edit'], "$address -> $goto");
|
||||
header("Location: list-virtual.php?domain=$domain");
|
||||
} catch(PDOException $e) {
|
||||
$message = $LANG['Edit_alias_result_error'];
|
||||
}
|
||||
}
|
||||
}
|
||||
include '../templates/header.tpl';
|
||||
include '../templates/admin_menu.tpl';
|
||||
include '../templates/edit-alias.tpl';
|
||||
include '../templates/footer.tpl';
|
||||
?>
|
|
@ -1,99 +0,0 @@
|
|||
<?php
|
||||
//
|
||||
// OpenSMTPD Admin
|
||||
// by Mischa Peters <mischa at high5 dot nl>
|
||||
// Copyright (c) 2022 High5!
|
||||
// License Info: LICENSE.TXT
|
||||
//
|
||||
// File: edit-mailbox.php
|
||||
//
|
||||
// Template File: edit-mailbox.tpl
|
||||
//
|
||||
// Template Variables:
|
||||
//
|
||||
// message
|
||||
// name
|
||||
//
|
||||
// Form POST / GET Variables:
|
||||
//
|
||||
// username
|
||||
// domain
|
||||
// password1
|
||||
// password2
|
||||
// name
|
||||
//
|
||||
require_once '../functions.inc.php';
|
||||
include '../languages/' . check_language() . '.lang';
|
||||
|
||||
$list_domains = list_domains();
|
||||
$admin = $SESSID_USERNAME ?? ADMIN_EMAIL;
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] == "GET") {
|
||||
$username = strtolower(filter_input(INPUT_GET, 'username', FILTER_DEFAULT));
|
||||
$domain = filter_input(INPUT_GET, 'domain', FILTER_VALIDATE_DOMAIN);
|
||||
$domain_key = array_search($domain, array_column($list_domains, 'domain'));
|
||||
$domain_exist = in_array($domain, array_column($list_domains, 'domain'));
|
||||
|
||||
if ($domain_exist) {
|
||||
try {
|
||||
$dbh = pdo_connect();
|
||||
$sth = $dbh->prepare("SELECT * FROM mailbox WHERE username=? AND domain=?");
|
||||
$sth->bindParam(1, $username, PDO::PARAM_STR);
|
||||
$sth->bindParam(2, $domain, PDO::PARAM_STR);
|
||||
$sth->execute();
|
||||
$mailbox_details = $sth->fetch();
|
||||
$name = $mailbox_details['name'];
|
||||
} catch(PDOException $e) {
|
||||
$message = $LANG['Edit_mailbox_login_error'];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] == "POST") {
|
||||
$username = strtolower(filter_input(INPUT_GET, 'username', FILTER_DEFAULT));
|
||||
$domain = filter_input(INPUT_GET, 'domain', FILTER_VALIDATE_DOMAIN);
|
||||
$password1 = filter_input(INPUT_POST, 'password1', FILTER_DEFAULT);
|
||||
$password2 = filter_input(INPUT_POST, 'password2', FILTER_DEFAULT);
|
||||
$name = filter_input(INPUT_POST, 'name', FILTER_DEFAULT);
|
||||
$domain_key = array_search($domain, array_column($list_domains, 'domain'));
|
||||
$domain_exist = in_array($domain, array_column($list_domains, 'domain'));
|
||||
|
||||
if ($password1 != $password2) {
|
||||
$message = $LANG['Edit_mailbox_password_text_error'];
|
||||
}
|
||||
|
||||
if (empty($message) && isset($domain_key) && !empty($password1)) {
|
||||
$hashed = bcrypt($password1);
|
||||
try {
|
||||
$dbh = pdo_connect();
|
||||
$sth = $dbh->prepare("UPDATE mailbox SET password=?,name=?,modified=NOW() WHERE username=? AND domain=?");
|
||||
$sth->bindParam(1, $hashed, PDO::PARAM_STR);
|
||||
$sth->bindParam(2, $name, PDO::PARAM_STR);
|
||||
$sth->bindParam(3, $username, PDO::PARAM_STR);
|
||||
$sth->bindParam(4, $domain, PDO::PARAM_STR);
|
||||
$sth->execute();
|
||||
} catch(PDOException $e) {
|
||||
$message = $LANG['Edit_mailbox_result_error'];
|
||||
}
|
||||
}
|
||||
|
||||
if ($domain_exist && empty($message)) {
|
||||
try {
|
||||
$dbh = pdo_connect();
|
||||
$sth = $dbh->prepare("UPDATE mailbox SET name=?,modified=NOW() WHERE username=? AND domain=?");
|
||||
$sth->bindParam(1, $name, PDO::PARAM_STR);
|
||||
$sth->bindParam(2, $username, PDO::PARAM_STR);
|
||||
$sth->bindParam(3, $domain, PDO::PARAM_STR);
|
||||
$sth->execute();
|
||||
logging($admin, $domain, $LANG['Logging_mailbox_edit'], $username);
|
||||
header("Location: list-virtual.php?domain=$domain");
|
||||
} catch(PDOException $e) {
|
||||
$message = $LANG['Edit_mailbox_result_error'];
|
||||
}
|
||||
}
|
||||
}
|
||||
include '../templates/header.tpl';
|
||||
include '../templates/admin_menu.tpl';
|
||||
include '../templates/edit-mailbox.tpl';
|
||||
include '../templates/footer.tpl';
|
||||
?>
|
|
@ -1,22 +0,0 @@
|
|||
<?php
|
||||
//
|
||||
// OpenSMTPD Admin
|
||||
// by Mischa Peters <mischa at high5 dot nl>
|
||||
// Copyright (c) 2022 High5!
|
||||
// License Info: LICENSE.TXT
|
||||
//
|
||||
// File: index.php
|
||||
//
|
||||
// Template File: -none-
|
||||
//
|
||||
// Template Variables:
|
||||
//
|
||||
// -none-
|
||||
//
|
||||
// Form POST / GET Variables:
|
||||
//
|
||||
// -none-
|
||||
//
|
||||
header ("Location: list-domain.php");
|
||||
exit;
|
||||
?>
|
|
@ -1,29 +0,0 @@
|
|||
<?php
|
||||
//
|
||||
// OpenSMTPD Admin
|
||||
// by Mischa Peters <mischa at high5 dot nl>
|
||||
// Copyright (c) 2022 High5!
|
||||
// License Info: LICENSE.TXT
|
||||
//
|
||||
// File: list-admin.php
|
||||
//
|
||||
// Template File: list-admin.tpl
|
||||
//
|
||||
// Template Variables:
|
||||
//
|
||||
// list_admins
|
||||
//
|
||||
// Form POST / GET Variables:
|
||||
//
|
||||
// -none-
|
||||
//
|
||||
require '../functions.inc.php';
|
||||
include '../languages/' . check_language() . '.lang';
|
||||
|
||||
$list_admins = list_admins();
|
||||
|
||||
include '../templates/header.tpl';
|
||||
include '../templates/admin_menu.tpl';
|
||||
include '../templates/admin_list-admin.tpl';
|
||||
include '../templates/footer.tpl';
|
||||
?>
|
|
@ -1,36 +0,0 @@
|
|||
<?php
|
||||
//
|
||||
// OpenSMTPD Admin
|
||||
// by Mischa Peters <mischa at high5 dot nl>
|
||||
// Copyright (c) 2022 High5!
|
||||
// License Info: LICENSE.TXT
|
||||
//
|
||||
// File: list-domain.php
|
||||
//
|
||||
// Template File: admin_list-domain.tpl
|
||||
//
|
||||
// Template Variables:
|
||||
//
|
||||
// list_domains
|
||||
//
|
||||
// Form POST / GET Variables:
|
||||
//
|
||||
// username
|
||||
//
|
||||
require_once '../functions.inc.php';
|
||||
include '../languages/' . check_language() . '.lang';
|
||||
|
||||
$list_admins = list_admins();
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] == "GET") {
|
||||
$username = filter_input(INPUT_GET, 'username', FILTER_VALIDATE_EMAIL);
|
||||
$list_domains = list_domains($username);
|
||||
} else {
|
||||
$list_domains = list_domains();
|
||||
}
|
||||
|
||||
include '../templates/header.tpl';
|
||||
include '../templates/admin_menu.tpl';
|
||||
include '../templates/admin_list-domain.tpl';
|
||||
include '../templates/footer.tpl';
|
||||
?>
|
|
@ -1,42 +0,0 @@
|
|||
<?php
|
||||
//
|
||||
// OpenSMTPD Admin
|
||||
// by Mischa Peters <mischa at high5 dot nl>
|
||||
// Copyright (c) 2022 High5!
|
||||
// License Info: LICENSE.TXT
|
||||
//
|
||||
// File: list-virtual.php
|
||||
//
|
||||
// Template File: admin_list-virtual.tpl
|
||||
//
|
||||
// Template Variables:
|
||||
//
|
||||
// list_alias
|
||||
// list_mailbox
|
||||
//
|
||||
// Form POST / GET Variables:
|
||||
//
|
||||
// domain
|
||||
// offset
|
||||
//
|
||||
require_once '../functions.inc.php';
|
||||
include '../languages/' . check_language() . '.lang';
|
||||
|
||||
$list_domains = list_domains();
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] == "GET") {
|
||||
$offset = filter_input(INPUT_GET, 'offset', FILTER_VALIDATE_INT) ?? '0';
|
||||
$limit = PAGE_SIZE;
|
||||
if (count($list_domains) > 0) {
|
||||
$domain = filter_input(INPUT_GET, 'domain', FILTER_VALIDATE_DOMAIN) ?? $list_domains[0]['domain'];
|
||||
$domain_key = array_search($domain, array_column($list_domains, 'domain'));
|
||||
$list_alias = list_aliases($domain, $offset, $limit);
|
||||
$list_mailbox = list_mailboxes($domain, $offset, $limit);
|
||||
}
|
||||
}
|
||||
|
||||
include '../templates/header.tpl';
|
||||
include '../templates/admin_menu.tpl';
|
||||
include '../templates/admin_list-virtual.tpl';
|
||||
include '../templates/footer.tpl';
|
||||
?>
|
|
@ -1,59 +0,0 @@
|
|||
<?php
|
||||
//
|
||||
// OpenSMTPD Admin
|
||||
// by Mischa Peters <mischa at high5 dot nl>
|
||||
// Copyright (c) 2022 High5!
|
||||
// License Info: LICENSE.TXT
|
||||
//
|
||||
// File: search.php
|
||||
//
|
||||
// Template File: search.tpl
|
||||
//
|
||||
// Template Variables:
|
||||
//
|
||||
// list_alias
|
||||
// list_mailbox
|
||||
//
|
||||
// Form POST / GET Variables:
|
||||
//
|
||||
// search
|
||||
//
|
||||
require_once '../functions.inc.php';
|
||||
include '../languages/' . check_language() . '.lang';
|
||||
|
||||
$list_domains = list_domains();
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] == "POST") {
|
||||
$search = filter_input(INPUT_POST, 'search', FILTER_DEFAULT);
|
||||
|
||||
if (isset($search)) {
|
||||
$dbh = pdo_connect();
|
||||
$sth = $dbh->prepare("SELECT alias.address,alias.goto,alias.modified,alias.domain FROM alias LEFT JOIN mailbox ON alias.address=mailbox.username WHERE alias.address LIKE ? AND mailbox.maildir IS NULL ORDER BY alias.address");
|
||||
$sth->bindValue(1, '%'.$search.'%', PDO::PARAM_STR);
|
||||
$sth->execute();
|
||||
$list_alias = $sth->fetchAll();
|
||||
foreach ($list_alias as $key => $value) {
|
||||
if (!in_array($value['domain'], array_column($list_domains, 'domain'))) {
|
||||
unset($list_alias[$key]);
|
||||
}
|
||||
}
|
||||
|
||||
$sth = $dbh->prepare("SELECT * FROM mailbox WHERE username LIKE ? ORDER BY username");
|
||||
$sth->bindValue(1, '%'.$search.'%', PDO::PARAM_STR);
|
||||
$sth->execute();
|
||||
$list_mailbox = $sth->fetchAll();
|
||||
foreach ($list_mailbox as $key => $value) {
|
||||
if (!in_array($value['domain'], array_column($list_domains, 'domain'))) {
|
||||
unset($list_mailbox[$key]);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$list_alias = array();
|
||||
$list_mailbox = array();
|
||||
}
|
||||
}
|
||||
include '../templates/header.tpl';
|
||||
include '../templates/admin_menu.tpl';
|
||||
include '../templates/search.tpl';
|
||||
include '../templates/footer.tpl';
|
||||
?>
|
|
@ -1,43 +0,0 @@
|
|||
<?php
|
||||
//
|
||||
// OpenSMTPD Admin
|
||||
// by Mischa Peters <mischa at high5 dot nl>
|
||||
// Copyright (c) 2022 High5!
|
||||
// License Info: LICENSE.TXT
|
||||
//
|
||||
// File: viewlog.php
|
||||
//
|
||||
// Template File: viewlog.tpl
|
||||
//
|
||||
// Template Variables:
|
||||
//
|
||||
// log
|
||||
//
|
||||
// Form POST / GET Variables:
|
||||
//
|
||||
// domain
|
||||
//
|
||||
require_once '../functions.inc.php';
|
||||
include '../languages/' . check_language() . '.lang';
|
||||
|
||||
$list_domains = list_domains();
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] == "GET") {
|
||||
$domain = filter_input(INPUT_GET, 'domain', FILTER_VALIDATE_DOMAIN) ?? $list_domains[0]['domain'];
|
||||
$domain_key = array_search($domain, array_column($list_domains, 'domain'));
|
||||
$domain_exist = in_array($domain, array_column($list_domains, 'domain'));
|
||||
|
||||
if ($domain_exist) {
|
||||
$dbh = pdo_connect();
|
||||
$sth = $dbh->prepare("SELECT * FROM log WHERE domain=? ORDER BY timestamp DESC LIMIT 10");
|
||||
$sth->bindParam(1, $domain, PDO::PARAM_STR);
|
||||
$sth->execute();
|
||||
$log = $sth->fetchAll();
|
||||
}
|
||||
}
|
||||
|
||||
include '../templates/header.tpl';
|
||||
include '../templates/admin_menu.tpl';
|
||||
include '../templates/viewlog.tpl';
|
||||
include '../templates/footer.tpl';
|
||||
?>
|
|
@ -13,7 +13,7 @@
|
|||
//
|
||||
// message
|
||||
//
|
||||
// Form POST / GET Variables:
|
||||
// POST / GET Variables:
|
||||
//
|
||||
// table
|
||||
// where
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
// message
|
||||
// goto
|
||||
//
|
||||
// Form POST / GET Variables:
|
||||
// POST / GET Variables:
|
||||
//
|
||||
// address
|
||||
// domain
|
||||
|
@ -24,9 +24,16 @@ require_once './functions.inc.php';
|
|||
include './languages/' . check_language() . '.lang';
|
||||
|
||||
$SESSID_USERNAME = check_session();
|
||||
$list_domains = list_domains($SESSID_USERNAME);
|
||||
$PERMISSIONS = check_permissions();
|
||||
$admin = $SESSID_USERNAME ?? ADMIN_EMAIL;
|
||||
|
||||
if ($PERMISSIONS == ADMIN_RIGHTS) {
|
||||
$list_domains = list_domains();
|
||||
$list_admins = list_admins();
|
||||
} else {
|
||||
$list_domains = list_domains($SESSID_USERNAME);
|
||||
}
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] == "GET") {
|
||||
$address = filter_input(INPUT_GET, 'address', FILTER_VALIDATE_EMAIL);
|
||||
$domain = filter_input(INPUT_GET, 'domain', FILTER_VALIDATE_DOMAIN);
|
||||
|
@ -88,7 +95,7 @@ if ($_SERVER['REQUEST_METHOD'] == "POST") {
|
|||
}
|
||||
}
|
||||
include './templates/header.tpl';
|
||||
include './templates/admin_menu.tpl';
|
||||
include './templates/menu.tpl';
|
||||
include './templates/edit-alias.tpl';
|
||||
include './templates/footer.tpl';
|
||||
?>
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
// message
|
||||
// name
|
||||
//
|
||||
// Form POST / GET Variables:
|
||||
// POST / GET Variables:
|
||||
//
|
||||
// username
|
||||
// domain
|
||||
|
@ -26,9 +26,16 @@ require_once './functions.inc.php';
|
|||
include './languages/' . check_language() . '.lang';
|
||||
|
||||
$SESSID_USERNAME = check_session();
|
||||
$list_domains = list_domains($SESSID_USERNAME);
|
||||
$PERMISSIONS = check_permissions();
|
||||
$admin = $SESSID_USERNAME ?? ADMIN_EMAIL;
|
||||
|
||||
if ($PERMISSIONS == ADMIN_RIGHTS) {
|
||||
$list_domains = list_domains();
|
||||
$list_admins = list_admins();
|
||||
} else {
|
||||
$list_domains = list_domains($SESSID_USERNAME);
|
||||
}
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] == "GET") {
|
||||
$username = strtolower(filter_input(INPUT_GET, 'username', FILTER_DEFAULT));
|
||||
$domain = filter_input(INPUT_GET, 'domain', FILTER_VALIDATE_DOMAIN);
|
||||
|
@ -94,7 +101,7 @@ if ($_SERVER['REQUEST_METHOD'] == "POST") {
|
|||
}
|
||||
}
|
||||
include './templates/header.tpl';
|
||||
include './templates/admin_menu.tpl';
|
||||
include './templates/menu.tpl';
|
||||
include './templates/edit-mailbox.tpl';
|
||||
include './templates/footer.tpl';
|
||||
?>
|
||||
|
|
|
@ -43,6 +43,12 @@ function check_session($session = "sessid") {
|
|||
return $_SESSION[$session]['username'];
|
||||
}
|
||||
|
||||
function check_permissions($session = "sessid") {
|
||||
if (!empty($_SESSION[$session]['rights'])) {
|
||||
return $_SESSION[$session]['rights'];
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// check_language
|
||||
// Action: checks what language the browser uses
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
//
|
||||
// -none-
|
||||
//
|
||||
// Form POST / GET Variables:
|
||||
// POST / GET Variables:
|
||||
//
|
||||
// -none-
|
||||
//
|
||||
|
|
|
@ -11,49 +11,46 @@ $LANG['confirm'] = 'Are you sure you want to delete this?\n';
|
|||
$LANG['confirm_domain'] = 'Do you really want to delete all records for this domain?\nThis can not be undone! ';
|
||||
$LANG['check_update'] = 'Check for update';
|
||||
|
||||
$LANG['Login_welcome'] = 'Mail admins login here to administer your domain.';
|
||||
$LANG['Login_welcome'] = 'Mail admins login here to administer your domain';
|
||||
$LANG['Login_username'] = 'Login (email)';
|
||||
$LANG['Login_password'] = 'Password';
|
||||
$LANG['Login_button'] = 'Login';
|
||||
$LANG['Login_incorrect'] = '<span class="error_msg">Your login or password is not correct.</span>';
|
||||
$LANG['Login_login_users'] = 'Users click here to login to the user section.';
|
||||
|
||||
$LANG['Menu_overview'] = 'List Domains';
|
||||
$LANG['Menu_create_alias'] = 'Add Alias';
|
||||
$LANG['Menu_create_mailbox'] = 'Add Mailbox';
|
||||
$LANG['Menu_list_domain'] = 'List Domains';
|
||||
$LANG['Menu_list_virtual'] = 'List Virtuals';
|
||||
$LANG['Menu_add_alias'] = 'Add Alias';
|
||||
$LANG['Menu_add_mailbox'] = 'Add Mailbox';
|
||||
$LANG['Menu_sendmail'] = 'Send Email';
|
||||
$LANG['Menu_password'] = 'Password';
|
||||
$LANG['Menu_viewlog'] = 'View Log';
|
||||
$LANG['Menu_logout'] = 'Logout';
|
||||
|
||||
$LANG['Overview_disabled'] = 'Disabled';
|
||||
$LANG['Overview_unlimited'] = 'Unlimited';
|
||||
$LANG['Overview_title'] = ':: Defined Domains';
|
||||
$LANG['Overview_up_arrow'] = 'Go Top';
|
||||
$LANG['Overview_right_arrow'] = 'Next Page';
|
||||
$LANG['Overview_left_arrow'] = 'Previus Page';
|
||||
$LANG['Overview_alias_title'] = ':: Alias';
|
||||
$LANG['Overview_mailbox_title'] = ':: Mailboxes';
|
||||
$LANG['Overview_button'] = 'Go';
|
||||
$LANG['Overview_welcome'] = 'Overview for ';
|
||||
$LANG['Overview_alias_alias_count'] = 'Aliases';
|
||||
$LANG['Overview_alias_mailbox_count'] = 'Mailboxes';
|
||||
$LANG['Overview_alias_address'] = 'From';
|
||||
$LANG['Overview_alias_goto'] = 'To';
|
||||
$LANG['Overview_alias_modified'] = 'Last Modified';
|
||||
$LANG['Overview_mailbox_username'] = 'Email';
|
||||
$LANG['Overview_mailbox_name'] = 'Name';
|
||||
$LANG['Overview_mailbox_modified'] = 'Last Modified';
|
||||
$LANG['List_modified'] = 'Last Modified';
|
||||
$LANG['List_button'] = 'Go';
|
||||
$LANG['List_up_arrow'] = 'Top';
|
||||
$LANG['List_right_arrow'] = 'Next Page';
|
||||
$LANG['List_left_arrow'] = 'Previous Page';
|
||||
|
||||
$LANG['Overview_get_domain'] = 'Domain';
|
||||
$LANG['Overview_get_aliases'] = 'Aliases';
|
||||
$LANG['Overview_get_mailboxes'] = 'Mailboxes';
|
||||
$LANG['Overview_get_modified'] = 'Last Modified';
|
||||
$LANG['List_domain_domain'] = 'Domain';
|
||||
$LANG['List_domain_description'] = 'Description';
|
||||
$LANG['List_domain_aliases'] = 'Aliases';
|
||||
$LANG['List_domain_mailboxes'] = 'Mailboxes';
|
||||
$LANG['List_domain_unlimited'] = 'unlimited';
|
||||
|
||||
$LANG['List_virtual_welcome'] = 'Overview for ';
|
||||
$LANG['List_virtual_alias_title'] = ':: Alias';
|
||||
$LANG['List_virtual_alias_address'] = 'From';
|
||||
$LANG['List_virtual_alias_goto'] = 'To';
|
||||
$LANG['List_virtual_mailbox_title'] = ':: Mailboxes';
|
||||
$LANG['List_virtual_mailbox_username'] = 'Email';
|
||||
$LANG['List_virtual_mailbox_name'] = 'Name';
|
||||
|
||||
$LANG['Delete_delete_error'] = '<span class="error_msg">Unable to delete the entry ';
|
||||
$LANG['Delete_domain_error'] = '<span class="error_msg">This domain is not yours ';
|
||||
|
||||
$LANG['Add_alias_welcome'] = 'Create a new alias for your domain.';
|
||||
$LANG['Add_alias_welcome'] = 'Create a new alias for your domain';
|
||||
$LANG['Add_alias_address'] = 'Alias';
|
||||
$LANG['Add_alias_address_text_error1'] = '<span class="error_msg">The ALIAS or TO is not valid.</span>';
|
||||
$LANG['Add_alias_address_text_error2'] = '<span class="error_msg">You have reached your limit to create aliases.</span>';
|
||||
|
@ -64,7 +61,7 @@ $LANG['Add_alias_result_error'] = '<span class="error_msg">This email address al
|
|||
$LANG['Add_alias_result_succes'] = 'The alias has been added to the alias table.';
|
||||
$LANG['Add_alias_catchall_text'] = 'To create a catch-all use an "*" as alias.<br />For domain to domain forwarding use "*@domain.tld" as to.';
|
||||
|
||||
$LANG['Edit_alias_welcome'] = 'Edit an alias for your domain.<br />One entry per line.';
|
||||
$LANG['Edit_alias_welcome'] = 'Edit an alias for your domain<br />one entry per line';
|
||||
$LANG['Edit_alias_address'] = 'Alias';
|
||||
$LANG['Edit_alias_address_error'] = '<span class="error_msg">Unable to locate alias.</span>';
|
||||
$LANG['Edit_alias_goto'] = 'To';
|
||||
|
@ -74,7 +71,7 @@ $LANG['Edit_alias_domain_error'] = '<span class="error_msg">This domain is not y
|
|||
$LANG['Edit_alias_button'] = 'Edit Alias';
|
||||
$LANG['Edit_alias_result_error'] = '<span class="error_msg">Unable to modify the alias.</span>';
|
||||
|
||||
$LANG['Add_mailbox_welcome'] = 'Create a new mailbox for your domain.';
|
||||
$LANG['Add_mailbox_welcome'] = 'Create a new mailbox for your domain';
|
||||
$LANG['Add_mailbox_username'] = 'Username';
|
||||
$LANG['Add_mailbox_username_text_error1'] = '<span class="error_msg">The USERNAME is not valid.</span>';
|
||||
$LANG['Add_mailbox_username_text_error2'] = '<span class="error_msg">This email address already exists, please choose a different one.</span>';
|
||||
|
@ -90,7 +87,7 @@ $LANG['Add_mailbox_button'] = 'Add Mailbox';
|
|||
$LANG['Add_mailbox_result_error'] = '<span class="error_msg">Unable to add the mailbox to the mailbox table.</span>';
|
||||
$LANG['Add_mailbox_result_succes'] = 'The mailbox has been added to the mailbox table.';
|
||||
|
||||
$LANG['Edit_mailbox_welcome'] = 'Edit a mailbox for your domain.';
|
||||
$LANG['Edit_mailbox_welcome'] = 'Edit a mailbox for your domain';
|
||||
$LANG['Edit_mailbox_username'] = 'Username';
|
||||
$LANG['Edit_mailbox_username_error'] = '<span class="error_msg">Unable to locate mailbox.</span>';
|
||||
$LANG['Edit_mailbox_password'] = 'New Password';
|
||||
|
@ -101,7 +98,7 @@ $LANG['Edit_mailbox_domain_error'] = '<span class="error_msg">This domain is not
|
|||
$LANG['Edit_mailbox_button'] = 'Edit Mailbox';
|
||||
$LANG['Edit_mailbox_result_error'] = '<span class="error_msg">Unable to modify the mailbox.</span>';
|
||||
|
||||
$LANG['Password_welcome'] = 'Change your login password.';
|
||||
$LANG['Password_welcome'] = 'Change your login password';
|
||||
$LANG['Password_admin'] = 'Login';
|
||||
$LANG['Password_admin_text_error'] = '<span class="error_msg">The LOGIN that you supplied doesn\'t match a mailbox.</span>';
|
||||
$LANG['Password_password_current'] = 'Current Password';
|
||||
|
@ -122,7 +119,7 @@ $LANG['Viewlog_data'] = 'Data';
|
|||
$LANG['Viewlog_button'] = 'Go';
|
||||
$LANG['Viewlog_result_error'] = '<span class="error_msg">Unable to find the logs.</span>';
|
||||
|
||||
$LANG['Sendmail_welcome'] = 'Send an email.';
|
||||
$LANG['Sendmail_welcome'] = 'Send an email';
|
||||
$LANG['Sendmail_admin'] = 'From';
|
||||
$LANG['Sendmail_to'] = 'To';
|
||||
$LANG['Sendmail_to_text_error'] = '<span class="error_msg">TO is empty or is not a valid email address.</span>';
|
||||
|
@ -136,7 +133,6 @@ $LANG['Sendmail_result_succes'] = 'The mailbox has been created.';
|
|||
|
||||
$LANG['AdminMenu_list_domain'] = 'List Domains';
|
||||
$LANG['AdminMenu_list_admin'] = 'List Admins';
|
||||
$LANG['AdminMenu_list_virtual'] = 'List Virtuals';
|
||||
$LANG['AdminMenu_viewlog'] = 'View Log';
|
||||
$LANG['AdminMenu_backup'] = 'Backup';
|
||||
$LANG['AdminMenu_create_domain_admins'] = 'Domain Admins';
|
||||
|
@ -210,7 +206,7 @@ $LANG['AdminEdit_admin_button'] = 'Edit Admin';
|
|||
$LANG['AdminEdit_admin_result_error'] = '<span class="error_msg">Unable to modify admin.</span>';
|
||||
$LANG['AdminEdit_admin_result_succes'] = 'Admin has been modified.';
|
||||
|
||||
$LANG['UsersLogin_welcome'] = 'Mailbox users login to change your password and aliases.';
|
||||
$LANG['UsersLogin_welcome'] = 'Mailbox users login to change your password and aliases';
|
||||
$LANG['UsersLogin_username'] = 'Login (email)';
|
||||
$LANG['UsersLogin_password'] = 'Password';
|
||||
$LANG['UsersLogin_button'] = 'Login';
|
||||
|
@ -221,7 +217,7 @@ $LANG['UsersMenu_vacation'] = 'Auto Response';
|
|||
$LANG['UsersMenu_edit_alias'] = 'Change your forward';
|
||||
$LANG['UsersMenu_password'] = 'Change Password';
|
||||
|
||||
$LANG['UsersVacation_welcome'] = 'Auto Response.';
|
||||
$LANG['UsersVacation_welcome'] = 'Auto Response';
|
||||
$LANG['UsersVacation_welcome_text'] = 'You already have an auto response configured.';
|
||||
$LANG['UsersVacation_subject'] = 'Subject';
|
||||
$LANG['UsersVacation_subject_text'] = 'Out of Office';
|
||||
|
|