Commit Diff


commit - 525cdfa64e2c1ec64553374452a333c7bacf1fba
commit + ff6266ff1d7608a7be0ff0d184249bfe213c5cc4
blob - 3c0802deb900631b3c4675baaf43641429bebc83
blob + 37ff751c4268605340fecf4ee44632f4d30909d8
--- add-alias.php
+++ add-alias.php
@@ -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'));
blob - 91bd255e556601cd778180b975f49e1aa8500247
blob + 028b6bad9e7ad99f4c0795c5fb9a8386743505c9
--- add-mailbox.php
+++ add-mailbox.php
@@ -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'));
blob - 4dc0a29c1dab8aec43a9dd43eee77cb1eecbec15 (mode 644)
blob + /dev/null
--- admin/.htaccess
+++ /dev/null
@@ -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>
blob - ac84b03d701cc7365f2d6282793103049f284b63 (mode 644)
blob + /dev/null
--- admin/add-alias.php
+++ /dev/null
@@ -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';
-?>
blob - 50b2ccbabf97cd6687472e2e5f882585ea3ad0d2 (mode 644)
blob + /dev/null
--- admin/add-mailbox.php
+++ /dev/null
@@ -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';
-?>
blob - 916eefe1429a52a9570a84e97d736f81e993d533 (mode 644)
blob + /dev/null
--- admin/admin.php
+++ /dev/null
@@ -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';
-?>
blob - 9066fb493b1686f5de6ed3fa4d3a9336343d3a83 (mode 644)
blob + /dev/null
--- admin/backup.php
+++ /dev/null
@@ -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);
-}
-?>
blob - 28c56c07122f8070c6171414b19d9cd2ef3ccf53 (mode 644)
blob + /dev/null
--- admin/delete.php
+++ /dev/null
@@ -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';
-?>
blob - 7bab9d215c4a18b587d61c4c80f1b2a970eb771f (mode 644)
blob + /dev/null
--- admin/domain.php
+++ /dev/null
@@ -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';
-?>
blob - b1c0010d68fd597c3d9724fc13e27c2108ef5889 (mode 644)
blob + /dev/null
--- admin/edit-alias.php
+++ /dev/null
@@ -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';
-?>
blob - c0f358aa906087919e73d3a81b3b211c38f5ef84 (mode 644)
blob + /dev/null
--- admin/edit-mailbox.php
+++ /dev/null
@@ -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';
-?>
blob - 383d9feba37ed2f8bff021824b9a0d81b5880358 (mode 644)
blob + /dev/null
--- admin/index.php
+++ /dev/null
@@ -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;
-?>
blob - cade867e5fd322837564676fa840e91445b193ef (mode 644)
blob + /dev/null
--- admin/list-admin.php
+++ /dev/null
@@ -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';
-?>
blob - 278f796f05ea2ee82b175e06f72f7a3dbeb3c9e1 (mode 644)
blob + /dev/null
--- admin/list-domain.php
+++ /dev/null
@@ -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';
-?>
blob - 2eb9ceda9c1700527918f7b40b279ec634d29f1d (mode 644)
blob + /dev/null
--- admin/list-virtual.php
+++ /dev/null
@@ -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';
-?>
blob - dc79b30bde105db5c54fdad7730b1b3549e9b639 (mode 644)
blob + /dev/null
--- admin/search.php
+++ /dev/null
@@ -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';
-?>
blob - b8eaec0472a850fd2abbda5d162a74f9410c6964 (mode 644)
blob + /dev/null
--- admin/viewlog.php
+++ /dev/null
@@ -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';
-?>
blob - 022631a91f0b65659be2a26f79fe02e3296ace9a
blob + 1634808ae9bf395f90353405e05e729d87e372fc
--- delete.php
+++ delete.php
@@ -13,7 +13,7 @@
 //
 // message
 //
-// Form POST / GET Variables:
+// POST / GET Variables:
 //
 // table
 // where
blob - c2715814f06f4421ba417f8e9bc0880c156735eb
blob + bb066d9a8963032a87c43a9878e759c41e88046c
--- edit-alias.php
+++ edit-alias.php
@@ -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';
 ?>
blob - f225334d4b9ded5516bcecc3bcaf5bb966ce3b4f
blob + 680e2933fd354867f4b1bac8059719b2c0476c3a
--- edit-mailbox.php
+++ edit-mailbox.php
@@ -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';
 ?>
blob - 19b6e174d591f51cd657114ac8fcb2f4a2af7f7a
blob + a8b8fec1f1b3d19d09720cc718be25cc784bb564
--- functions.inc.php
+++ functions.inc.php
@@ -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
blob - ca5d939c25a6d9cc9f0d77b59404af647a38fb19
blob + 996934468189ab5f1b256de2c5aa4e9b69a70eb5
--- index.php
+++ index.php
@@ -13,7 +13,7 @@
 //
 // -none-
 //
-// Form POST / GET Variables:
+// POST / GET Variables:
 //
 // -none-
 //
blob - 7b15caa59437af528ced68ae84deebcac13bb8ef
blob + d8bd600cb8fad464b326fbd13fb589c1d92e5ccb
--- languages/en.lang
+++ languages/en.lang
@@ -11,49 +11,46 @@ $LANG['confirm'] = 'Are you sure you want to delete th
 $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_
 $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
 $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="err
 $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 bee
 
 $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';
blob - 8ac84c406fc2599205dd1ff7f4c695168af63bfb
blob + 19cd5aef08bf48ad2c93b706bfc7fa916bc5c5cd
--- list-domain.php
+++ list-domain.php
@@ -21,8 +21,21 @@ require_once './functions.inc.php';
 include './languages/' . check_language() . '.lang';
 
 $SESSID_USERNAME = check_session();
-$list_domains = list_domains($SESSID_USERNAME);
+$PERMISSIONS = check_permissions();
 
+if ($_SERVER['REQUEST_METHOD'] == "GET") {
+	$username = filter_input(INPUT_GET, 'username', FILTER_VALIDATE_EMAIL);
+	if ($PERMISSIONS == ADMIN_RIGHTS) {
+		$list_admins = list_admins();
+		if (empty($username)) {
+			$list_domains = list_domains();
+		} else {
+			$list_domains = list_domains($username);
+		}
+	} else {
+		$list_domains = list_domains($SESSID_USERNAME);
+	}
+}
 include './templates/header.tpl';
 include './templates/menu.tpl';
 include './templates/list-domain.tpl';
blob - ce380e6f628730f871c90b7df8c95c60c2806e6f
blob + 6ec0b7d3566f22465092825dd35c3ffaa9611a12
--- list-virtual.php
+++ list-virtual.php
@@ -14,7 +14,7 @@
 // list_alias
 // list_mailbox
 //
-// Form POST / GET Variables:
+// POST / GET Variables:
 //
 // domain
 // offset
@@ -23,12 +23,18 @@ require_once './functions.inc.php';
 include './languages/' . check_language() . '.lang';
 
 $SESSID_USERNAME = check_session();
-$list_domains = list_domains($SESSID_USERNAME);
+$PERMISSIONS = check_permissions();
 
+if ($PERMISSIONS == ADMIN_RIGHTS) {
+	$list_domains = list_domains();
+} else {
+	$list_domains = list_domains($SESSID_USERNAME);
+}
+
 if ($_SERVER['REQUEST_METHOD'] == "GET") {
 	$offset = filter_input(INPUT_GET, 'offset', FILTER_VALIDATE_INT) ?? '0';
 	$limit = PAGE_SIZE;
-	$domain = filter_input(INPUT_GET, 'domain', FILTER_VALIDATE_DOMAIN);
+	$domain = filter_input(INPUT_GET, 'domain', FILTER_VALIDATE_DOMAIN) ?? $list_domains[0]['domain'];
 	if (in_array($domain, array_column($list_domains, 'domain'))) {
 		$domain_key = array_search($domain, array_column($list_domains, 'domain'));
 		$list_alias = list_aliases($domain, $offset, $limit);
blob - f1b237b6f00d04ab9be50a33d00429b3f02fba06
blob + ad4aeadcf5cc1e1200f7e49441edce11405dcb9a
--- login.php
+++ login.php
@@ -28,24 +28,24 @@ if ($_SERVER['REQUEST_METHOD'] == "POST") {
 
 	if (!empty($username) && !empty($password)) {
 		$dbh = pdo_connect();
-		$sth = $dbh->prepare("SELECT password FROM admin WHERE username=?");
+		$sth = $dbh->prepare("SELECT password,rights FROM admin WHERE username=?");
 		$sth->bindParam(1, $username, PDO::PARAM_STR);
 		$sth->execute();
-		$row = $sth->fetch(PDO::FETCH_COLUMN);
+		$row = $sth->fetch(PDO::FETCH_ASSOC);
 	}
 
-	if (!empty($row)) {
-		if (!password_verify($password, $row)) {
+	if (!empty($row['password'])) {
+		if (!password_verify($password, $row['password'])) {
 			$message = $LANG['Login_incorrect'];
 		}
 	} else {
 		$message = $LANG['Login_incorrect'];
 	}
 
-
 	if (empty($message)) {
 		session_start();
 		$_SESSION['sessid']['username'] = $username;
+		$_SESSION['sessid']['rights'] = $row['rights'];
 		header("Location: list-domain.php");
 		exit;
 	}
blob - f837b1776658c32ec16c9a2f72de7c469435c2c4
blob + bcfabf05da448a6ae5076ca2da58fc1a1d96da1e
--- logout.php
+++ logout.php
@@ -13,7 +13,7 @@
 //
 // -none-
 //
-// Form POST / GET Variables:
+// POST / GET Variables:
 //
 // -none-
 //
blob - 5f9280c041ab6bcaa1a8a1c58b7d730e50558fd8
blob + a597172c03bf95525956d0b877448bffcd79f9ce
--- password.php
+++ password.php
@@ -13,7 +13,7 @@
 //
 // message
 //
-// Form POST / GET Variables:
+// POST / GET Variables:
 //
 // password_current
 // password1
@@ -23,7 +23,16 @@ require_once './functions.inc.php';
 include './languages/' . check_language() . '.lang';
 
 $SESSID_USERNAME = check_session();
+$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'] == "POST") {
 	$username = $SESSID_USERNAME;
 	$password_current = filter_input(INPUT_POST, 'password_current', FILTER_DEFAULT);
blob - 7cb06466725898b7383d183ac0821e77f4ad5f1f
blob + 51dafff050d3c5f25d6d11d8600ba77a2a61748a
--- search.php
+++ search.php
@@ -14,7 +14,7 @@
 // list_alias
 // list_mailbox
 //
-// Form POST / GET Variables:
+// POST / GET Variables:
 //
 // search
 //
@@ -22,8 +22,14 @@ require_once './functions.inc.php';
 include './languages/' . check_language() . '.lang';
 
 $SESSID_USERNAME = check_session();
-$list_domains = list_domains($SESSID_USERNAME);
+$PERMISSIONS = check_permissions();
 
+if ($PERMISSIONS == ADMIN_RIGHTS) {
+	$list_domains = list_domains();
+} else {
+	$list_domains = list_domains($SESSID_USERNAME);
+}
+
 if ($_SERVER['REQUEST_METHOD'] == "POST") {
 	$search = filter_input(INPUT_POST, 'search', FILTER_DEFAULT);
 
blob - 18a49431b5d3e75c638e0a2722b25aefdc636d5f
blob + a6ba63080a514d06ea46613c42df70513c1a60ec
--- sendmail.php
+++ sendmail.php
@@ -16,7 +16,7 @@
 // subject
 // body
 //
-// Form POST / GET Variables:
+// POST / GET Variables:
 //
 // to
 // subject
@@ -26,7 +26,16 @@ require_once './functions.inc.php';
 include './languages/' . check_language() . '.lang';
 
 $SESSID_USERNAME = check_session();
+$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'] == "POST") {
         $to = strtolower(filter_input(INPUT_POST, 'to', FILTER_VALIDATE_EMAIL));
         $subject = filter_input(INPUT_POST, 'subject', FILTER_DEFAULT);
blob - 0b35034feab122a422b5736429b276b18b0177ab
blob + b81f4900f42c05985eca197b04069eac339466c0
--- stylesheet.css
+++ stylesheet.css
@@ -163,7 +163,7 @@ a:visited, a:active {
 	border-left: 4px solid #40B33C;
 }
 
-#overview, #admin_domains, #admin_virtual {
+#overview {
 	width: 1024px;
 	margin: 0 auto;
 	background: #AFE1A6; /*#9ACD32;*/
blob - 1f4cdcf033783374b6646bf32a151a76fe3cd663
blob + 4be8b032a36eb71cc27c65a7043adc5827b630d1
--- templates/add-alias.tpl
+++ templates/add-alias.tpl
@@ -13,7 +13,7 @@
                 foreach ($list_domains as $row) {
                         echo '<option value="' . $row['domain'] . '"';
 			if ($list_domains[$domain_key]['domain'] == $row['domain']) echo ' selected';
-                        echo ">" . $row['domain'] . "</option>\n";
+                        echo ">" . $row['domain'] . "</option>";
                 }
 		?>
 		</select>
blob - 26f3cce983e8e0253c22ba89fa4cdd4a2f620f57
blob + fb174ffdf792c2778421cc290a9bd8eb21036c1b
--- templates/add-mailbox.tpl
+++ templates/add-mailbox.tpl
@@ -13,7 +13,7 @@
                 foreach ($list_domains as $row) {
                         echo '<option value="' . $row['domain'] . '"';
 			if ($list_domains[$domain_key]['domain'] == $row['domain']) echo ' selected';
-                        echo ">" . $row['domain'] . "</option>\n";
+                        echo ">" . $row['domain'] . "</option>";
                 }
 		?>
 		</select>
blob - 4c92fb928b4616c125361570706225453d9233c4
blob + 53fd0ee6f6608b0ada1b3213bb8bc7fcab1a0318
--- templates/admin_admin.tpl
+++ templates/admin_admin.tpl
@@ -32,7 +32,7 @@
 		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";
+			echo ">" . $row['domain'] . "</option>";
 		}
 		?>
 		</select>
blob - 47d31ee2c6687843f1a01abe9f6255859a729c5c
blob + 4020f6026f3a6e2bad7850fe005da36a3467bee1
--- templates/admin_list-admin.tpl
+++ templates/admin_list-admin.tpl
@@ -1,24 +1,24 @@
 <?php 
 if (count($list_admins) > 0) {
 
-	echo "<table id=\"admin_table\">\n";
-	echo "	<tr class=\"header\">\n";
-	echo "		<td>" . $LANG['AdminList_admin_username'] . "</td>\n";
-	echo "		<td>" . $LANG['AdminList_admin_count'] . "</td>\n";
-	echo "		<td>" . $LANG['AdminList_admin_modified'] . "</td>\n";
-	echo "		<td colspan=\"2\">&nbsp;</td>\n";
-	echo "	</tr>\n";
+	echo "<table id=\"admin_table\">";
+	echo "	<tr class=\"header\">";
+	echo "		<td>" . $LANG['AdminList_admin_username'] . "</td>";
+	echo "		<td>" . $LANG['AdminList_admin_count'] . "</td>";
+	echo "		<td>" . $LANG['AdminList_admin_modified'] . "</td>";
+	echo "		<td colspan=\"2\">&nbsp;</td>";
+	echo "	</tr>";
 
         foreach ($list_admins as $row) {
 
-		echo "	<tr class=\"hilightoff\" onMouseOver=\"className='hilighton';\" onMouseOut=\"className='hilightoff';\">\n";
+		echo "	<tr class=\"hilightoff\" onMouseOver=\"className='hilighton';\" onMouseOut=\"className='hilightoff';\">";
 		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>";
 		echo "		<td><a href=\"admin.php?action=edit&username=" . $row['username'] . "\">" . $LANG['edit'] . "</a></td>";
 		echo "		<td><a href=\"delete.php?table=admin&where=username&delete=" . $row['username'] . "\" onclick=\"return confirm ('" . $LANG['confirm'] . $LANG['AdminList_admin_username'] . ": " . $row['username'] . "')\">" . $LANG['del'] . "</a></td>";
-		echo "	</tr>\n";
+		echo "	</tr>";
 	}
-	echo "</table>\n";
+	echo "</table>";
 }
 ?>
blob - 366f82fc4edbb5b5fe12d15467486f830996758b
blob + 5bf5a8b8d48c28f1c85cb1fe6494388c7bcda74c
--- templates/admin_list-domain.tpl
+++ templates/admin_list-domain.tpl
@@ -1,12 +1,12 @@
 <div id="overview">
 <form name="list_domain" method="get">
-<select name=username onChange="this.form.submit()";>
+<select name="username" onChange="this.form.submit()";>
 <?php
 if (count($list_admins) > 0) {
 	foreach ($list_admins as $row) {
 		echo '<option value="' . $row['username'] . '"';
 		if (isset($username) && $username  == $row['username']) echo ' selected';
-		echo ">" . $row['username'] . "</option>\n";
+		echo ">" . $row['username'] . "</option>";
 	}
 }
 ?>
@@ -19,17 +19,17 @@ if (count($list_admins) > 0) {
 </div>
 <?php 
 if (count($list_domains) > 0) {
-	echo "<table id=\"admin_table\">\n";
-	echo "	<tr class=\"header\">\n";
-	echo "		<td>" . $LANG['AdminList_domain_domain'] . "</td>\n";
-	echo "		<td>" . $LANG['AdminList_domain_description'] . "</td>\n";
-	echo "		<td>" . $LANG['AdminList_domain_aliases'] . "</td>\n";
-	echo "		<td>" . $LANG['AdminList_domain_mailboxes'] . "</td>\n";
-	echo "		<td>" . $LANG['AdminList_domain_modified'] . "</td>\n";
-	echo "		<td colspan=\"2\">&nbsp;</td>\n";
-	echo "	</tr>\n";
+	echo "<table id=\"admin_table\">";
+	echo "	<tr class=\"header\">";
+	echo "		<td>" . $LANG['AdminList_domain_domain'] . "</td>";
+	echo "		<td>" . $LANG['AdminList_domain_description'] . "</td>";
+	echo "		<td>" . $LANG['AdminList_domain_aliases'] . "</td>";
+	echo "		<td>" . $LANG['AdminList_domain_mailboxes'] . "</td>";
+	echo "		<td>" . $LANG['AdminList_domain_modified'] . "</td>";
+	echo "		<td colspan=\"2\">&nbsp;</td>";
+	echo "	</tr>";
 	foreach ($list_domains as $row) {
-		echo "	<tr class=\"hilightoff\" onMouseOver=\"className='hilighton';\" onMouseOut=\"className='hilightoff';\">\n";
+		echo "	<tr class=\"hilightoff\" onMouseOver=\"className='hilighton';\" onMouseOut=\"className='hilightoff';\">";
 		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>";
@@ -37,9 +37,8 @@ if (count($list_domains) > 0) {
 		echo "<td>" . $row['modified'] . "</td>";
 		echo "<td><a href=\"domain.php?action=edit&domain=" . $row['domain'] . "\">" . $LANG['edit'] . "</a></td>";
 		echo "<td><a href=\"delete.php?table=domain&domain=" . $row['domain'] . "\" onclick=\"return confirm ('" . $LANG['confirm_domain'] . $LANG['AdminList_admin_domain'] . ": " . $row['domain'] . "')\">" . $LANG['del'] . "</a></td>";
-		echo "</tr>\n";
+		echo "</tr>";
 	}
-
-	echo "</table>\n";
+	echo "</table>";
 }
 ?>
blob - 6688e7d0a016517a1eb2c616fc1eded79967bc47
blob + 6a15e0a0e59406bc889b7d779518d0f5d2d997ca
--- templates/admin_list-virtual.tpl
+++ templates/admin_list-virtual.tpl
@@ -6,7 +6,7 @@ if (count($list_domains) > 0) {
 	foreach ($list_domains as $row) {
 		echo '<option value="' . $row['domain'] . '"';
 		if ($list_domains[$domain_key]['domain'] == $row['domain']) echo ' selected';
-		echo ">" . $row['domain'] . "</option>\n";
+		echo ">" . $row['domain'] . "</option>";
 	}
 }
 ?>
@@ -26,65 +26,65 @@ if (count($list_domains) > 0) {
 
 <?php 
 if ($list_domains[$domain_key]['alias_count'] > $limit || $list_domains[$domain_key]['mailbox_count'] > $limit) {
-	echo "<div id=\"nav_bar\">\n";
+	echo "<div id=\"nav_bar\">";
 	if ($offset >= $limit) {
 
-		echo "<a href=\"list-virtual.php?domain=" . $list_domains[$domain_key]['domain'] . "&offset=" . ($offset - $limit) . "\"><img border=\"0\" src=\"../images/arrow-l.png\" title=\"" . $LANG['Overview_left_arrow'] . "\"></a>\n";
+		echo "<a href=\"list-virtual.php?domain=" . $list_domains[$domain_key]['domain'] . "&offset=" . ($offset - $limit) . "\"><img border=\"0\" src=\"../images/arrow-l.png\" title=\"" . $LANG['Overview_left_arrow'] . "\"></a>";
 	}
 	if (($list_domains[$domain_key]['alias_count'] > $limit) || ($list_domains[$domain_key]['mailbox_count'] > $limit)) {
 
-		echo "<a href=\"list-virtual.php?domain=" . $list_domains[$domain_key]['domain'] . "&offset=0\"><img border=\"0\" src=\"../images/arrow-u.png\" title=\"" . $LANG['Overview_up_arrow'] . "\"></a>\n";
+		echo "<a href=\"list-virtual.php?domain=" . $list_domains[$domain_key]['domain'] . "&offset=0\"><img border=\"0\" src=\"../images/arrow-u.png\" title=\"" . $LANG['Overview_up_arrow'] . "\"></a>";
 	}		
 	if ((($offset + $limit) < $list_domains[$domain_key]['alias_count']) || (($offset + $limit) < $list_domains[$domain_key]['mailbox_count'])) {
-		echo "<a href=\"list-virtual.php?domain=" . $list_domains[$domain_key]['domain'] . "&offset=" . ($offset + $limit) . "\"><img border=\"0\" src=\"../images/arrow-r.png\" title=\"" . $LANG['Overview_right_arrow'] . "\"></a>\n";
+		echo "<a href=\"list-virtual.php?domain=" . $list_domains[$domain_key]['domain'] . "&offset=" . ($offset + $limit) . "\"><img border=\"0\" src=\"../images/arrow-r.png\" title=\"" . $LANG['Overview_right_arrow'] . "\"></a>";
 	}
-	echo "</div>\n";
+	echo "</div>";
 }
 if (count($list_alias) > 0) {
-	echo "<table id=\"alias_table\">\n";
-	echo "	<tr>\n";
+	echo "<table id=\"alias_table\">";
+	echo "	<tr>";
 	echo "		<td colspan=\"5\"><h3>" . $LANG['Overview_alias_title'] . "</h3></td>";
 	echo "	</tr>";
-	echo "	<tr class=\"header\">\n";
-	echo "		<td>" . $LANG['AdminList_virtual_alias_address'] . "</td>\n";
-	echo "		<td>" . $LANG['AdminList_virtual_alias_goto'] . "</td>\n";
-	echo "		<td>" . $LANG['AdminList_virtual_alias_modified'] . "</td>\n";
-	echo "		<td colspan=\"2\">&nbsp;</td>\n";
-	echo "	</tr>\n";
+	echo "	<tr class=\"header\">";
+	echo "		<td>" . $LANG['AdminList_virtual_alias_address'] . "</td>";
+	echo "		<td>" . $LANG['AdminList_virtual_alias_goto'] . "</td>";
+	echo "		<td>" . $LANG['AdminList_virtual_alias_modified'] . "</td>";
+	echo "		<td colspan=\"2\">&nbsp;</td>";
+	echo "	</tr>";
 
         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";
-			echo "		<td><a href=\"edit-alias.php?address=" . $row['address'] . "&domain=" . $list_domains[$domain_key]['domain'] . "\">" . $LANG['edit'] . "</a></td>\n";
-			echo "		<td><a href=\"delete.php?table=alias" . "&delete=" . $row['address'] . "&domain=" . $list_domains[$domain_key]['domain'] . "\"onclick=\"return confirm ('" . $LANG['confirm'] . $LANG['Overview_get_aliases'] . ": ". $row['address'] . "')\">" . $LANG['del'] . "</a></td>\n";
-			echo "	</tr>\n";
+			echo "	<tr class=\"hilightoff\" onMouseOver=\"className='hilighton';\" onMouseOut=\"className='hilightoff';\">";
+			echo "		<td>" . $row['address'] . "</td>";
+			echo "		<td>" . preg_replace("/,/", "<br>", $row['goto']) . "</td>";
+			echo "		<td>" . $row['modified'] . "</td>";
+			echo "		<td><a href=\"edit-alias.php?address=" . $row['address'] . "&domain=" . $list_domains[$domain_key]['domain'] . "\">" . $LANG['edit'] . "</a></td>";
+			echo "		<td><a href=\"delete.php?table=alias" . "&delete=" . $row['address'] . "&domain=" . $list_domains[$domain_key]['domain'] . "\"onclick=\"return confirm ('" . $LANG['confirm'] . $LANG['Overview_get_aliases'] . ": ". $row['address'] . "')\">" . $LANG['del'] . "</a></td>";
+			echo "	</tr>";
 	}
-	echo "</table>\n";
+	echo "</table>";
 }
 
 if (count($list_mailbox) > 0) {
-	echo "<table id=\"mailbox_table\">\n";
-	echo "	<tr>\n";
+	echo "<table id=\"mailbox_table\">";
+	echo "	<tr>";
 	echo "		<td colspan=\"7\"><h3>" . $LANG['Overview_mailbox_title'] . "</h3></td>";
 	echo "	</tr>";
-	echo "	<tr class=\"header\">\n";
-	echo "		<td>" . $LANG['AdminList_virtual_mailbox_username'] . "</td>\n";
-	echo "		<td>" . $LANG['AdminList_virtual_mailbox_name'] . "</td>\n";
-	echo "		<td>" . $LANG['AdminList_virtual_mailbox_modified'] . "</td>\n";
-	echo "		<td colspan=\"2\">&nbsp;</td>\n";
-	echo "	</tr>\n";
+	echo "	<tr class=\"header\">";
+	echo "		<td>" . $LANG['AdminList_virtual_mailbox_username'] . "</td>";
+	echo "		<td>" . $LANG['AdminList_virtual_mailbox_name'] . "</td>";
+	echo "		<td>" . $LANG['AdminList_virtual_mailbox_modified'] . "</td>";
+	echo "		<td colspan=\"2\">&nbsp;</td>";
+	echo "	</tr>";
 
         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";
-			echo "		<td><a href=\"edit-mailbox.php?username=" . $row['username'] . "&domain=" . $list_domains[$domain_key]['domain'] . "\">" . $LANG['edit'] . "</a></td>\n";
-			echo "		<td><a href=\"delete.php?table=mailbox" . "&delete=" . $row['username'] . "&domain=" . $list_domains[$domain_key]['domain'] . "\"onclick=\"return confirm ('" . $LANG['confirm'] . $LANG['Overview_get_mailboxes'] . ": ". $row['username'] . "')\">" . $LANG['del'] . "</a></td>\n";
-			echo "	</tr>\n";
+			echo "	<tr class=\"hilightoff\" onMouseOver=\"className='hilighton';\" onMouseOut=\"className='hilightoff';\">";
+			echo "		<td>" . $row['username'] . "</td>";
+			echo "		<td>" . $row['name'] . "</td>";
+			echo "		<td>" . $row['modified'] . "</td>";
+			echo "		<td><a href=\"edit-mailbox.php?username=" . $row['username'] . "&domain=" . $list_domains[$domain_key]['domain'] . "\">" . $LANG['edit'] . "</a></td>";
+			echo "		<td><a href=\"delete.php?table=mailbox" . "&delete=" . $row['username'] . "&domain=" . $list_domains[$domain_key]['domain'] . "\"onclick=\"return confirm ('" . $LANG['confirm'] . $LANG['Overview_get_mailboxes'] . ": ". $row['username'] . "')\">" . $LANG['del'] . "</a></td>";
+			echo "	</tr>";
 	}
-	echo "</table>\n";
+	echo "</table>";
 }
 ?>
blob - b9eda7a36b84fb08ff0ae03e5b77428fa0b59343
blob + bfe8370ded8ff62c6c9cec6a9871399ca70d8c4f
--- templates/admin_menu.tpl
+++ templates/admin_menu.tpl
@@ -3,10 +3,13 @@
 	<li><a target="_top" href="list-domain.php"><?php echo $LANG['AdminMenu_list_domain']; ?></a></li>
 	<li><a target="_top" href="list-admin.php"><?php echo $LANG['AdminMenu_list_admin']; ?></a></li>
 	<li><a target="_top" href="list-virtual.php"><?php echo $LANG['AdminMenu_list_virtual']; ?></a></li>
+
 	<li><a target="_top" href="viewlog.php"><?php echo $LANG['AdminMenu_viewlog']; ?></a></li>
+
 	<li><a target="_top" href="backup.php"><?php echo $LANG['AdminMenu_backup']; ?></a></li>
 	<li><a target="_top" href="domain.php"><?php echo $LANG['AdminMenu_create_domain']; ?></a></li>
 	<li><a target="_top" href="admin.php"><?php echo $LANG['AdminMenu_create_admin']; ?></a></li>
+
 	<li><a target="_top" href="add-alias.php<?php if (isset($domain)) echo '?domain=' . $domain; ?>"><?php echo $LANG['AdminMenu_create_alias']; ?></a></li>
 	<li><a target="_top" href="add-mailbox.php<?php if (isset($domain)) echo '?domain=' . $domain; ?>"><?php echo $LANG['AdminMenu_create_mailbox']; ?></a></li>
 </ul>
blob - 30313b2fc934fb75b8eea968c4fa12f0af39f3de
blob + 8ee1dc7d55b553f5859d543670d8dbe0e01640b7
--- templates/edit-alias.tpl
+++ templates/edit-alias.tpl
@@ -14,7 +14,7 @@
 <textarea class="flat" rows="10" cols="60" name="goto">
 <?php
 foreach ($goto as $row) {
-	echo "$row\n";
+	echo "$row";
 }
 ?>
 </textarea>
blob - 4fbca6c39204634150099bd9e08df85f53076e90
blob + 40fdfe3ba4d966fba92900446e1b3c3a644a57e7
--- templates/footer.tpl
+++ templates/footer.tpl
@@ -3,7 +3,7 @@
 <?php
 if (SHOW_FOOTER == "YES" && FOOTER_LINK) {
 	echo "&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;";
-	echo "<a href=\"" . FOOTER_LINK . "\">" . FOOTER_TEXT . "</a>\n";
+	echo "<a href=\"" . FOOTER_LINK . "\">" . FOOTER_TEXT . "</a>";
 }
 ?>
 </div>
blob - fbd66492481ac086bde873ff90882d409908f2e2
blob + 705f4dcf0d08f08d1c69f50807339cde18728447
--- templates/header.tpl
+++ templates/header.tpl
@@ -11,8 +11,8 @@
 <meta http-equiv="Content-Type" content="text/html; charset=<?php echo isset($LANG['charset']) ? $LANG['charset'] : 'iso-8859-1' ?>" />
 <meta name="viewport" content="width=device-width, initial-scale=1">
 <?php
-if (file_exists(realpath("./stylesheet.css"))) echo "<link rel=\"stylesheet\" href=\"stylesheet.css\">\n";
-if (file_exists(realpath("../stylesheet.css"))) echo "<link rel=\"stylesheet\" href=\"../stylesheet.css\">\n";
+if (file_exists(realpath("./stylesheet.css"))) echo "<link rel=\"stylesheet\" href=\"stylesheet.css\">";
+if (file_exists(realpath("../stylesheet.css"))) echo "<link rel=\"stylesheet\" href=\"../stylesheet.css\">";
 ?>
 <title>OpenSMTPD Admin - <?php echo $_SERVER['HTTP_HOST']; ?></title>
 </head>
@@ -20,15 +20,15 @@ if (file_exists(realpath("../stylesheet.css"))) echo "
 <div id="login_header">
 <?php
 if (file_exists(realpath("./stylesheet.css"))) {
-	echo "<img id=\"login_header_logo\" src=\"images/postbox.png\" />\n";
-	echo "<img id=\"login_header_logo\" height=\"30px\" src=\"images/opensmtpdadmin.png\" />\n";
+	echo "<img id=\"login_header_logo\" src=\"images/postbox.png\" />";
+	echo "<img id=\"login_header_logo\" height=\"30px\" src=\"images/opensmtpdadmin.png\" />";
 }
 if (file_exists(realpath("../stylesheet.css"))) {
-	echo "<img id=\"login_header_logo\" src=\"../images/postbox.png\" />\n";
-	echo "<img id=\"login_header_logo\" height=\"30px\"% src=\"../images/opensmtpdadmin.png\" />\n";
+	echo "<img id=\"login_header_logo\" src=\"../images/postbox.png\" />";
+	echo "<img id=\"login_header_logo\" height=\"30px\"% src=\"../images/opensmtpdadmin.png\" />";
 }
 if (SHOW_HEADER == "YES" && HEADER_TEXT) {
-	echo "<h2>" . HEADER_TEXT . "</h2>\n";
+	echo "<h2>" . HEADER_TEXT . "</h2>";
 }
 ?>
 </div>
blob - a00158ad2fc2f8746e70aded25f224872dade863
blob + f3f1a1b3c0c7d75a94baa051249b2b82ef4ad35f
--- templates/list-domain.tpl
+++ templates/list-domain.tpl
@@ -1,28 +1,47 @@
 <div id="overview">
+<?php if ($PERMISSIONS == ADMIN_RIGHTS) { ?>
+<form name="list_domain" method="get">
+<select name="username" onChange="this.form.submit()";>
+<?php
+if (count($list_admins) > 0) {
+	foreach ($list_admins as $row) {
+		echo '<option value="' . $row['username'] . '"';
+		if (isset($username) && $username  == $row['username']) echo ' selected';
+		echo ">" . $row['username'] . "</option>";
+	}
+}
+?>
+</select>
+<input class="button" type="submit" name="go" value="<?php echo $LANG['List_button']; ?>" />
+<?php } ?>
 <form name="search" method="post" action="search.php">
 Search: <input type="textbox" name="search" size="25">
 </form>
 </div>
 <?php
-echo "<table id=\"overview_table\">\n";
-echo "	<tr>\n";
-echo "		<td colspan=\"5\"><h3>".$LANG['Overview_title']."</h3></td>";
-echo "	</tr>";
-echo "	<tr class=\"header\">\n";
-echo "		<td>" . $LANG['Overview_get_domain'] . "</td>\n";
-echo "		<td>" . $LANG['Overview_get_aliases'] . "</td>\n";
-echo "		<td>" . $LANG['Overview_get_mailboxes'] . "</td>\n";
-echo "	</tr>\n";
-foreach ($list_domains as $row) {
-	if ($row['aliases'] == 0) $row['aliases'] = $LANG['Overview_unlimited'];
-	if ($row['mailboxes'] == 0) $row['mailboxes'] = $LANG['Overview_unlimited'];
-	if ($row['aliases'] < 0) $row['aliases'] = $LANG['Overview_disabled'];
-	if ($row['mailboxes'] < 0) $row['mailboxes'] = $LANG['Overview_disabled'];
-	echo "	<tr class=\"hilightoff\" onMouseOver=\"className='hilighton';\" onMouseOut=\"className='hilightoff';\">\n";
-	echo "		<td><a href=\"list-virtual.php?domain=" . $row['domain'] . "\">" . $row['domain'] . "</a></td>\n";
-	echo "		<td>" . $row['alias_count'] . " / " . $row['aliases'] . "</td>\n";
-	echo "		<td>" . $row['mailbox_count'] . " / " . $row['mailboxes'] . "</td>\n";
-	echo "	</tr>\n";
+if (count($list_domains) > 0) {
+	echo "<table id=\"admin_table\">";
+	echo "<tr class=\"header\">";
+	echo "<td>" . $LANG['List_domain_domain'] . "</td>";
+	echo "<td>" . $LANG['List_domain_description'] . "</td>";
+	echo "<td>" . $LANG['List_domain_aliases'] . "</td>";
+	echo "<td>" . $LANG['List_domain_mailboxes'] . "</td>";
+	echo "<td>" . $LANG['List_modified'] . "</td>";
+	if ($PERMISSIONS == ADMIN_RIGHTS) echo "<td colspan=\"2\">&nbsp;</td>";
+	echo "</tr>";
+	foreach ($list_domains as $row) {
+		if ($row['aliases'] == 0) $row['aliases'] = $LANG['List_domain_unlimited'];
+		if ($row['mailboxes'] == 0) $row['mailboxes'] = $LANG['List_domain_unlimited'];
+		echo "<tr class=\"hilightoff\" onMouseOver=\"className='hilighton';\" onMouseOut=\"className='hilightoff';\">";
+		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>";
+		if ($PERMISSIONS == ADMIN_RIGHTS) echo "<td><a href=\"domain.php?action=edit&domain=" . $row['domain'] . "\">" . $LANG['edit'] . "</a></td>";
+		if ($PERMISSIONS == ADMIN_RIGHTS) echo "<td><a href=\"delete.php?table=domain&domain=" . $row['domain'] . "\" onclick=\"return confirm ('" . $LANG['confirm_domain'] . $LANG['List_domain_domain'] . ": " . $row['domain'] . "')\">" . $LANG['del'] . "</a></td>";
+		echo "	</tr>";
+	}
+echo "</table>";
 }
-echo "</table>\n";
-?>
+
blob - 93c7bd6d0c57d4eb950c3985d6926396d32ee534
blob + 557aabb4eeec367b43f51bad6b638b8b8dcc4189
--- templates/list-virtual.tpl
+++ templates/list-virtual.tpl
@@ -6,22 +6,20 @@ if (count($list_domains) > 0) {
 	foreach ($list_domains as $row) {
 		echo '<option value="' . $row['domain'] . '"';
 		if ($list_domains[$domain_key]['domain'] == $row['domain']) echo ' selected';
-		echo ">" . $row['domain'] . "</option>\n";
+		echo ">" . $row['domain'] . "</option>";
 	}
 }
-if ($list_domains[$domain_key]['aliases'] == 0) $list_domains[$domain_key]['aliases'] = $LANG['Overview_unlimited'];
-if ($list_domains[$domain_key]['aliases'] < 0) $list_domains[$domain_key]['aliases'] = $LANG['Overview_disabled'];
-if ($list_domains[$domain_key]['mailboxes'] == 0) $list_domains[$domain_key]['mailboxes'] = $LANG['Overview_unlimited'];
-if ($list_domains[$domain_key]['mailboxes'] < 0) $list_domains[$domain_key]['mailboxes'] = $LANG['Overview_disabled'];
+if ($list_domains[$domain_key]['aliases'] == 0) $list_domains[$domain_key]['aliases'] = $LANG['List_domain_unlimited'];
+if ($list_domains[$domain_key]['mailboxes'] == 0) $list_domains[$domain_key]['mailboxes'] = $LANG['List_domain_unlimited'];
 ?>
 </select>
 <input type="hidden" name="offset" value="0">
-<input class="button" type="submit" name="go" value="<?php echo $LANG['Overview_button']; ?>" />
+<input class="button" type="submit" name="go" value="<?php echo $LANG['List_button']; ?>" />
 </form>
 
-<h4><?php echo $LANG['Overview_welcome'] . $domain; ?></h4>
-<p><?php echo $LANG['Overview_alias_alias_count'] . ": " . $list_domains[$domain_key]['alias_count'] . " / " . $list_domains[$domain_key]['aliases']; ?></p>
-<p><?php echo $LANG['Overview_alias_mailbox_count'] . ": " . $list_domains[$domain_key]['mailbox_count'] . " / " . $list_domains[$domain_key]['mailboxes']; ?></p>
+<h4><?php echo $LANG['List_virtual_welcome'] . $domain; ?></h4>
+<p><?php echo $LANG['List_domain_aliases'] . ": " . $list_domains[$domain_key]['alias_count'] . " / " . $list_domains[$domain_key]['aliases']; ?></p>
+<p><?php echo $LANG['List_domain_mailboxes'] . ": " . $list_domains[$domain_key]['mailbox_count'] . " / " . $list_domains[$domain_key]['mailboxes']; ?></p>
 
 <form name="search" method="post" action="search.php">
 <input type="textbox" name="search" size="25">
@@ -29,66 +27,66 @@ if ($list_domains[$domain_key]['mailboxes'] < 0) $list
 </div>
 <?php
 if ($list_domains[$domain_key]['alias_count'] > $limit || $list_domains[$domain_key]['mailbox_count'] > $limit) {
-	echo "<div id=\"nav_bar\">\n";
+	echo "<div id=\"nav_bar\">";
 	if ($offset >= $limit) {
 
-		echo "<a href=\"list-virtual.php?domain=" . $_GET['domain'] . "&offset=" . ($offset - $limit) . "\"><img border=\"0\" src=\"images/arrow-l.png\" title=\"" . $LANG['Overview_left_arrow'] . "\"></a>\n";
+		echo "<a href=\"list-virtual.php?domain=" . $_GET['domain'] . "&offset=" . ($offset - $limit) . "\"><img border=\"0\" src=\"images/arrow-l.png\" title=\"" . $LANG['List_left_arrow'] . "\"></a>";
 	}
 	if (($list_domains[$domain_key]['alias_count'] > $limit) || ($list_domains[$domain_key]['mailbox_count'] > $limit)) {
 
-		echo "<a href=\"list-virtual.php?domain=" . $_GET['domain'] . "&offset=0\"><img border=\"0\" src=\"images/arrow-u.png\" title=\"" . $LANG['Overview_up_arrow'] . "\"></a>\n";
+		echo "<a href=\"list-virtual.php?domain=" . $_GET['domain'] . "&offset=0\"><img border=\"0\" src=\"images/arrow-u.png\" title=\"" . $LANG['List_up_arrow'] . "\"></a>";
 	}		
 	if ((($offset + $limit) < $list_domains[$domain_key]['alias_count']) || (($offset + $limit) < $list_domains[$domain_key]['mailbox_count'])) {
-		echo "<a href=\"list-virtual.php?domain=" . $_GET['domain'] . "&offset=" . ($offset + $limit) . "\"><img border=\"0\" src=\"images/arrow-r.png\" title=\"" . $LANG['Overview_right_arrow'] . "\"></a>\n";
+		echo "<a href=\"list-virtual.php?domain=" . $_GET['domain'] . "&offset=" . ($offset + $limit) . "\"><img border=\"0\" src=\"images/arrow-r.png\" title=\"" . $LANG['List_right_arrow'] . "\"></a>";
 	}
-	echo "</div>\n";
+	echo "</div>";
 }
 
 if (count($list_alias) > 0) {
-	echo "<table id=\"alias_table\">\n";
-	echo "	<tr>\n";
-	echo "		<td colspan=\"5\"><h3>".$LANG['Overview_alias_title']."</h3></td>";
-	echo "	</tr>";
-	echo "	<tr class=\"header\">\n";
-	echo "		<td>" . $LANG['Overview_alias_address'] . "</td>\n";
-	echo "		<td>" . $LANG['Overview_alias_goto'] . "</td>\n";
-	echo "		<td>" . $LANG['Overview_alias_modified'] . "</td>\n";
-	echo "		<td colspan=\"2\">&nbsp;</td>\n";
-	echo "	</tr>\n";
+	echo "<table id=\"alias_table\">";
+	echo "<tr>";
+	echo "<td colspan=\"5\"><h3>" . $LANG['List_virtual_alias_title'] . "</h3></td>";
+	echo "</tr>";
+	echo "<tr class=\"header\">";
+	echo "<td>" . $LANG['List_virtual_alias_address'] . "</td>";
+	echo "<td>" . $LANG['List_virtual_alias_goto'] . "</td>";
+	echo "<td>" . $LANG['List_modified'] . "</td>";
+	echo "<td colspan=\"2\">&nbsp;</td>";
+	echo "</tr>";
 
         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";
-			echo "		<td><a href=\"edit-alias.php?address=" . $row['address'] . "&domain=" . $list_domains[$domain_key]['domain'] . "\">" . $LANG['edit'] . "</a></td>\n";
-			echo "		<td><a href=\"delete.php?table=alias&delete=" . $row['address'] . "&domain=" . $list_domains[$domain_key]['domain'] . "\"onclick=\"return confirm ('" . $LANG['confirm'] . $LANG['Overview_get_aliases'] . ": ". $row['address'] . "')\">" . $LANG['del'] . "</a></td>\n";
-			echo "	</tr>\n";
+			echo "<tr class=\"hilightoff\" onMouseOver=\"className='hilighton';\" onMouseOut=\"className='hilightoff';\">";
+			echo "<td>" . $row['address'] . "</td>";
+			echo "<td>" . preg_replace("/,/", "<br>", $row['goto']) . "</td>";
+			echo "<td>" . $row['modified'] . "</td>";
+			echo "<td><a href=\"edit-alias.php?address=" . $row['address'] . "&domain=" . $list_domains[$domain_key]['domain'] . "\">" . $LANG['edit'] . "</a></td>";
+			echo "<td><a href=\"delete.php?table=alias&delete=" . $row['address'] . "&domain=" . $list_domains[$domain_key]['domain'] . "\"onclick=\"return confirm ('" . $LANG['confirm'] . $LANG['List_domain_aliases'] . ": ". $row['address'] . "')\">" . $LANG['del'] . "</a></td>";
+			echo "</tr>";
 	}
-	echo "</table>\n";
+	echo "</table>";
 }
 
 if (count($list_mailbox) > 0) {
-	echo "<table id=\"mailbox_table\">\n";
-	echo "	<tr>\n";
-	echo "		<td colspan=\"7\"><h3>".$LANG['Overview_mailbox_title']."</h3></td>";
-	echo "	</tr>";
-	echo "	<tr class=\"header\">\n";
-	echo "		<td>" . $LANG['Overview_mailbox_username'] . "</td>\n";
-	echo "		<td>" . $LANG['Overview_mailbox_name'] . "</td>\n";
-	echo "		<td>" . $LANG['Overview_mailbox_modified'] . "</td>\n";
-	echo "		<td colspan=\"2\">&nbsp;</td>\n";
-	echo "	</tr>\n";
+	echo "<table id=\"mailbox_table\">";
+	echo "<tr>";
+	echo "<td colspan=\"7\"><h3>" . $LANG['List_virtual_mailbox_title'] . "</h3></td>";
+	echo "</tr>";
+	echo "<tr class=\"header\">";
+	echo "<td>" . $LANG['List_virtual_mailbox_username'] . "</td>";
+	echo "<td>" . $LANG['List_virtual_mailbox_name'] . "</td>";
+	echo "<td>" . $LANG['List_modified'] . "</td>";
+	echo "<td colspan=\"2\">&nbsp;</td>";
+	echo "</tr>";
 
         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";
-			echo "		<td><a href=\"edit-mailbox.php?username=" . $row['username'] . "&domain=" . $list_domains[$domain_key]['domain'] . "\">" . $LANG['edit'] . "</a></td>\n";
-			echo "		<td><a href=\"delete.php?table=mailbox&delete=" . $row['username'] . "&domain=" . $list_domains[$domain_key]['domain'] . "\"onclick=\"return confirm ('" . $LANG['confirm'] . $LANG['Overview_get_mailboxes'] . ": ". $row['username'] . "')\">" . $LANG['del'] . "</a></td>\n";
-			echo "	</tr>\n";
+			echo "<tr class=\"hilightoff\" onMouseOver=\"className='hilighton';\" onMouseOut=\"className='hilightoff';\">";
+			echo "<td>" . $row['username'] . "</td>";
+			echo "<td>" . $row['name'] . "</td>";
+			echo "<td>" . $row['modified'] . "</td>";
+			echo "<td><a href=\"edit-mailbox.php?username=" . $row['username'] . "&domain=" . $list_domains[$domain_key]['domain'] . "\">" . $LANG['edit'] . "</a></td>";
+			echo "<td><a href=\"delete.php?table=mailbox&delete=" . $row['username'] . "&domain=" . $list_domains[$domain_key]['domain'] . "\"onclick=\"return confirm ('" . $LANG['confirm'] . $LANG['List_domain_mailboxes'] . ": ". $row['username'] . "')\">" . $LANG['del'] . "</a></td>";
+			echo "</tr>";
 	}
-	echo "</table>\n";
+	echo "</table>";
 }
 ?>
blob - 20902c0ac9e8c295fde8ae69e9a9694b3d6139f1
blob + 09fed86fc168becfac0e9280d12578c30e748c76
--- templates/menu.tpl
+++ templates/menu.tpl
@@ -1,17 +1,27 @@
 <div id="menu">
 <ul>
-	<li><a target="_top" href="list-domain.php"><?php echo $LANG['Menu_overview']; ?></a></li>
-	<li><a target="_top" href="add-alias.php<?php if (isset($domain)) echo '?domain=' . $domain; ?>"><?php echo $LANG['Menu_create_alias']; ?></a></li>
-	<li><a target="_top" href="add-mailbox.php<?php if (isset($domain)) echo '?domain=' . $domain; ?>"><?php echo $LANG['Menu_create_mailbox']; ?></a></li>
+	<li><a target="_top" href="list-domain.php"><?php echo $LANG['Menu_list_domain']; ?></a></li>
+	<li><a target="_top" href="list-virtual.php"><?php echo $LANG['Menu_list_virtual']; ?></a></li>
+
+	<?php if ($PERMISSIONS == ADMIN_RIGHTS) { ?>
+	<li><a target="_top" href="list-admin.php"><?php echo $LANG['AdminMenu_list_admin']; ?></a></li>
+	<li><a target="_top" href="backup.php"><?php echo $LANG['AdminMenu_backup']; ?></a></li>
+	<li><a target="_top" href="domain.php"><?php echo $LANG['AdminMenu_create_domain']; ?></a></li>
+	<li><a target="_top" href="admin.php"><?php echo $LANG['AdminMenu_create_admin']; ?></a></li>
+	<?php } else {?>
 	<li><a target="_top" href="sendmail.php"><?php echo $LANG['Menu_sendmail']; ?></a></li>
 	<li><a target="_top" href="password.php"><?php echo $LANG['Menu_password']; ?></a></li>
+	<?php } ?>
+
+	<li><a target="_top" href="add-alias.php<?php if (isset($domain)) echo '?domain=' . $domain; ?>"><?php echo $LANG['Menu_add_alias']; ?></a></li>
+	<li><a target="_top" href="add-mailbox.php<?php if (isset($domain)) echo '?domain=' . $domain; ?>"><?php echo $LANG['Menu_add_mailbox']; ?></a></li>
 	<li><a target="_top" href="viewlog.php"><?php echo $LANG['Menu_viewlog']; ?></a></li>
 	<li><a target="_top" href="logout.php"><?php echo $LANG['Menu_logout']; ?></a></li>
 </ul>
 </div>
 <?php
 if (file_exists(realpath("motd.txt"))) {
-	echo "<div id=\"motd\">\n";
+	echo "<div id=\"motd\">";
 	include("motd.txt");
 	echo "</div>";
 }
blob - 5ceca7e55c1f51c6901eaa6c07f8b6a3c8bf31ba
blob + 04e4f62bbbc99f3d8fb9775a55c2f591d15bc494
--- templates/search.tpl
+++ templates/search.tpl
@@ -6,50 +6,50 @@
 </div>
 <?php
 if (count($list_alias) > 0) {
-	echo "<table id=\"alias_table\">\n";
-	echo "	<tr>\n";
-	echo "		<td colspan=\"5\"><h3>".$LANG['Overview_alias_title']."</h3></td>";
+	echo "<table id=\"alias_table\">";
+	echo "	<tr>";
+	echo "		<td colspan=\"5\"><h3>" . $LANG['List_virtual_alias_title'] . "</h3></td>";
 	echo "	</tr>";
-	echo "	<tr class=\"header\">\n";
-	echo "		<td>" . $LANG['Overview_alias_address'] . "</td>\n";
-	echo "		<td>" . $LANG['Overview_alias_goto'] . "</td>\n";
-	echo "		<td>" . $LANG['Overview_alias_modified'] . "</td>\n";
-	echo "		<td colspan=\"2\">&nbsp;</td>\n";
-	echo "	</tr>\n";
+	echo "	<tr class=\"header\">";
+	echo "		<td>" . $LANG['List_virtual_alias_address'] . "</td>";
+	echo "		<td>" . $LANG['List_virtual_alias_goto'] . "</td>";
+	echo "		<td>" . $LANG['List_modified'] . "</td>";
+	echo "		<td colspan=\"2\">&nbsp;</td>";
+	echo "	</tr>";
 
         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";
-		echo "		<td><a href=\"edit-alias.php?action=edit&address=" . $row['address'] . "&domain=" . $row['domain'] . "\">" . $LANG['edit'] . "</a></td>\n";
-		echo "		<td><a href=\"delete.php?table=alias&delete=" . $row['address'] . "&domain=" . $row['domain'] . "\"onclick=\"return confirm ('" . $LANG['confirm'] . $LANG['Overview_get_aliases'] . ": ". $row['address'] . "')\">" . $LANG['del'] . "</a></td>\n";
-		echo "	</tr>\n";
+		echo "	<tr class=\"hilightoff\" onMouseOver=\"className='hilighton';\" onMouseOut=\"className='hilightoff';\">";
+		echo "		<td>" . $row['address'] . "</td>";
+		echo "		<td>" . preg_replace("/,/", "<br>", $row['goto']) . "</td>";
+		echo "		<td>" . $row['modified'] . "</td>";
+		echo "		<td><a href=\"edit-alias.php?action=edit&address=" . $row['address'] . "&domain=" . $row['domain'] . "\">" . $LANG['edit'] . "</a></td>";
+		echo "		<td><a href=\"delete.php?table=alias&delete=" . $row['address'] . "&domain=" . $row['domain'] . "\"onclick=\"return confirm ('" . $LANG['confirm'] . $LANG['List_domain_aliases'] . ": ". $row['address'] . "')\">" . $LANG['del'] . "</a></td>";
+		echo "	</tr>";
 	}
-	echo "</table>\n";
+	echo "</table>";
 }
 
 if (count($list_mailbox) > 0) {
-	echo "<table id=\"mailbox_table\">\n";
-	echo "	<tr>\n";
-	echo "		<td colspan=\"7\"><h3>".$LANG['Overview_mailbox_title']."</h3></td>";
+	echo "<table id=\"mailbox_table\">";
+	echo "	<tr>";
+	echo "		<td colspan=\"7\"><h3>" . $LANG['List_virtual_mailbox_title'] . "</h3></td>";
 	echo "	</tr>";
-	echo "	<tr class=\"header\">\n";
-	echo "		<td>" . $LANG['Overview_mailbox_username'] . "</td>\n";
-	echo "		<td>" . $LANG['Overview_mailbox_name'] . "</td>\n";
-	echo "		<td>" . $LANG['Overview_mailbox_modified'] . "</td>\n";
-	echo "		<td colspan=\"2\">&nbsp;</td>\n";
-	echo "	</tr>\n";
+	echo "	<tr class=\"header\">";
+	echo "		<td>" . $LANG['List_virtual_mailbox_username'] . "</td>";
+	echo "		<td>" . $LANG['List_virtual_mailbox_name'] . "</td>";
+	echo "		<td>" . $LANG['List_modified'] . "</td>";
+	echo "		<td colspan=\"2\">&nbsp;</td>";
+	echo "	</tr>";
 
 		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";
-		echo "		<td><a href=\"edit-mailbox.php?action=edit&username=" . $row['username'] . "&domain=" . $row['domain'] . "\">" . $LANG['edit'] . "</a></td>\n";
-		echo "		<td><a href=\"delete.php?table=mailbox&delete=" . $row['username'] . "&domain=" . $row['domain'] . "\"onclick=\"return confirm ('" . $LANG['confirm'] . $LANG['Overview_get_mailboxes'] . ": ". $row['username'] . "')\">" . $LANG['del'] . "</a></td>\n";
-		echo "	</tr>\n";
+		echo "	<tr class=\"hilightoff\" onMouseOver=\"className='hilighton';\" onMouseOut=\"className='hilightoff';\">";
+		echo "		<td>" . $row['username'] . "</td>";
+		echo "		<td>" . $row['name'] . "</td>";
+		echo "		<td>" . $row['modified'] . "</td>";
+		echo "		<td><a href=\"edit-mailbox.php?action=edit&username=" . $row['username'] . "&domain=" . $row['domain'] . "\">" . $LANG['edit'] . "</a></td>";
+		echo "		<td><a href=\"delete.php?table=mailbox&delete=" . $row['username'] . "&domain=" . $row['domain'] . "\"onclick=\"return confirm ('" . $LANG['confirm'] . $LANG['List_domain_mailboxes'] . ": ". $row['username'] . "')\">" . $LANG['del'] . "</a></td>";
+		echo "	</tr>";
 	}
-	echo "</table>\n";
+	echo "</table>";
 }
 ?>
blob - c599a2d3653065fad3cfd0ae768de4a0b5133b56
blob + 191db98a7e429b438b560c0bcc0a3764115ea435
--- templates/users_menu.tpl
+++ templates/users_menu.tpl
@@ -10,7 +10,7 @@
 
 <?php 
 if (file_exists(realpath("../motd-users.txt"))) {
-	echo "<div id=\"motd\">\n";
+	echo "<div id=\"motd\">";
 	include("../motd-users.txt");
 	echo "</div>";
 }
blob - 33a8b1ea6dffb9d70aebc966cf047580a3605e59
blob + d6b6755953aa4df5c0f7c1e32125096ef9c9477f
--- templates/viewlog.tpl
+++ templates/viewlog.tpl
@@ -6,7 +6,7 @@ if (count($list_domains) > 0) {
 	foreach ($list_domains as $row) {
 		echo '<option value="' . $row['domain'] . '"';
 		if ($list_domains[$domain_key]['domain'] == $row['domain']) echo ' selected';
-		echo ">" . $row['domain'] . "</option>\n";
+		echo ">" . $row['domain'] . "</option>";
 	}
 }
 ?>
@@ -16,29 +16,29 @@ if (count($list_domains) > 0) {
 </div>
 <?php 
 if (count($log ?? array()) > 0) {
-	echo "<table id=\"log_table\">\n";
-	echo "	<tr>\n";
-	echo "		<td colspan=\"5\"><h3>".$LANG['Viewlog_welcome']." ".$domain."</h3></td>\n";
-	echo "	</tr>\n";
-	echo "	<tr class=\"header\">\n";
-	echo "		<td>" . $LANG['Viewlog_timestamp'] . "</td>\n";
-	echo "		<td>" . $LANG['Viewlog_username'] . "</td>\n";
-	echo "		<td>" . $LANG['Viewlog_domain'] . "</td>\n";
-	echo "		<td>" . $LANG['Viewlog_action'] . "</td>\n";
-	echo "		<td>" . $LANG['Viewlog_data'] . "</td>\n";
-	echo "	</tr>\n";
+	echo "<table id=\"log_table\">";
+	echo "	<tr>";
+	echo "		<td colspan=\"5\"><h3>".$LANG['Viewlog_welcome']." ".$domain."</h3></td>";
+	echo "	</tr>";
+	echo "	<tr class=\"header\">";
+	echo "		<td>" . $LANG['Viewlog_timestamp'] . "</td>";
+	echo "		<td>" . $LANG['Viewlog_username'] . "</td>";
+	echo "		<td>" . $LANG['Viewlog_domain'] . "</td>";
+	echo "		<td>" . $LANG['Viewlog_action'] . "</td>";
+	echo "		<td>" . $LANG['Viewlog_data'] . "</td>";
+	echo "	</tr>";
 
 	foreach ($log as $row) {
 		if (strlen($row['data']) > 35) $row['data'] = substr($row['data'], 0, 35) . " ...";
-		echo "	<tr class=\"hilightoff\" onMouseOver=\"className='hilighton';\" onMouseOut=\"className='hilightoff';\">\n";
-		echo "		<td nowrap>" . $row['timestamp'] . "</td>\n";
-		echo "		<td nowrap>" . $row['username'] . "</td>\n";
-		echo "		<td nowrap>" . $row['domain'] . "</td>\n";
-		echo "		<td nowrap>" . $row['action'] . "</td>\n";
-		echo "		<td nowrap>" . $row['data'] . "</td>\n";
-		echo "	</tr>\n";
+		echo "	<tr class=\"hilightoff\" onMouseOver=\"className='hilighton';\" onMouseOut=\"className='hilightoff';\">";
+		echo "		<td nowrap>" . $row['timestamp'] . "</td>";
+		echo "		<td nowrap>" . $row['username'] . "</td>";
+		echo "		<td nowrap>" . $row['domain'] . "</td>";
+		echo "		<td nowrap>" . $row['action'] . "</td>";
+		echo "		<td nowrap>" . $row['data'] . "</td>";
+		echo "	</tr>";
 	}
-	echo "</table>\n";
-	echo "<p />\n";
+	echo "</table>";
+	echo "<p />";
 }
 ?>
blob - 6ccfcb46d477c60b9f47672563dc9e4f306ea4d4
blob + 18a826bbd612cdef1f42fe985af62fe5ff0aa57e
--- viewlog.php
+++ viewlog.php
@@ -13,7 +13,7 @@
 //
 // log
 //
-// Form POST / GET Variables:
+// POST / GET Variables:
 //
 // domain
 //
@@ -21,8 +21,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) ?? $list_domains[0]['domain'];
 	$domain_key = array_search($domain, array_column($list_domains, 'domain'));