Commit Diff


commit - 91a50b5119b24205f634c33d83ef9e2b4e94646d
commit + 826796d1612618f6edef40bf344e83e70da2a378
blob - f596135405f2ecd8c1dff449a0fff46c68d4a884
blob + 6deb5e9852bfa424c9867e7bf155b249a3433905
--- add-alias.php
+++ add-alias.php
@@ -32,6 +32,7 @@ $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") {
@@ -39,6 +40,7 @@ if ($_SERVER['REQUEST_METHOD'] == "POST") {
 	$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, '@')) {
@@ -54,7 +56,7 @@ if ($_SERVER['REQUEST_METHOD'] == "POST") {
 		$message = $LANG['Create_alias_address_text_error1'];
 	}
 
-	if (empty($message) && isset($domain_key)) {
+	if ($domain_exist && empty($message)) {
 		try {
 			$dbh = connect_db();
 			$sth = $dbh->prepare("INSERT INTO alias (address,goto,domain,created,modified) VALUES (?,?,?,NOW(),NOW())");
blob - 0cedbe468ba4d9f8f3bfec125a792d8a1db25820
blob + a435ec2e2c48ed027b2587eb6bb4ab4829d354b8
--- add-mailbox.php
+++ add-mailbox.php
@@ -34,6 +34,7 @@ $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") {
@@ -42,9 +43,8 @@ if ($_SERVER['REQUEST_METHOD'] == "POST") {
 	$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']) {
@@ -59,7 +59,7 @@ if ($_SERVER['REQUEST_METHOD'] == "POST") {
 		$message = $LANG['Create_mailbox_password_text_error'];
 	}
 
-	if (empty($message) && isset($domain_key)) {
+	if ($domain_exist && empty($message)) {
 		$hashed = bcrypt($password1);
 		$maildir = $from . "/";
 
blob - 294e56589b62367aca06c0e9f05480cbd474ba5c
blob + 85ea0fb54974b8ce8c2fc728b8fdf8a3a0d6599a
--- admin/add-alias.php
+++ admin/add-alias.php
@@ -31,6 +31,7 @@ $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") {
@@ -38,6 +39,7 @@ if ($_SERVER['REQUEST_METHOD'] == "POST") {
 	$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, '@')) {
@@ -53,7 +55,7 @@ if ($_SERVER['REQUEST_METHOD'] == "POST") {
 		$message = $LANG['Create_alias_address_text_error1'];
 	}
 
-	if (empty($message) && isset($domain_key)) {
+	if ($domain_exist && empty($message)) {
 		try {
 			$dbh = connect_db();
 			$sth = $dbh->prepare("INSERT INTO alias (address,goto,domain,created,modified) VALUES (?,?,?,NOW(),NOW())");
blob - 95bf5159986ec9155e2e01491c9a833a64ec24ca
blob + df39f7677d4de5f231e8506790400b2184c90abb
--- admin/add-mailbox.php
+++ admin/add-mailbox.php
@@ -33,6 +33,7 @@ $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") {
@@ -41,9 +42,8 @@ if ($_SERVER['REQUEST_METHOD'] == "POST") {
 	$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']) {
@@ -58,7 +58,7 @@ if ($_SERVER['REQUEST_METHOD'] == "POST") {
 		$message = $LANG['Create_mailbox_password_text_error'];
 	}
 
-	if (empty($message) && isset($domain_key)) {
+	if ($domain_exist && empty($message)) {
 		$hashed = bcrypt($password1);
 		$maildir = $from . "/";
 
blob - 3ffa13e5f71e8f480397b030e9b444d42fca2e3c
blob + 3f1097d052e174f73af2431e1f32945c64c570ed
--- admin/delete.php
+++ admin/delete.php
@@ -27,12 +27,13 @@ $list_domains = list_domains();
 $admin = $SESSID_USERNAME ?? ADMIN_EMAIL;
 
 if ($_SERVER['REQUEST_METHOD'] == "GET") {
-        $table = strtolower(filter_input(INPUT_GET, 'table', FILTER_DEFAULT));
+        $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 ($table == "domain") {
+	if ($domain_exist && $table == "domain") {
 		try {
 			$dbh = connect_db();
 			$dbh->beginTransaction();
@@ -99,7 +100,6 @@ if ($_SERVER['REQUEST_METHOD'] == "GET") {
 
 			$dbh->commit();
 			header("Location: list-domain.php");
-			exit;
 		} catch (RuntimeException $e) {
 			$message =  $e->getMessage();
 			$dbh->rollBack();
@@ -135,7 +135,6 @@ if ($_SERVER['REQUEST_METHOD'] == "GET") {
 
 			$dbh->commit();
 			header("Location: list-admin.php");
-			exit;
 		} catch (RuntimeException $e) {
 			$message =  $e->getMessage();
 			$dbh->rollBack();
@@ -145,7 +144,7 @@ if ($_SERVER['REQUEST_METHOD'] == "GET") {
 		}
 	}
 
-	if (($table == 'alias' || $table == 'mailbox') && in_array($domain, array_column($list_domains, 'domain'))) {
+	if ($domain_exist && ($table == 'alias' || $table == 'mailbox')) {
 		try {
 			$dbh = connect_db();
 			$sth = $dbh->prepare("DELETE FROM alias WHERE address=? AND domain=?");
@@ -158,7 +157,6 @@ if ($_SERVER['REQUEST_METHOD'] == "GET") {
 			logging($admin, $domain, "delete alias", $delete);
 
 			header("Location: list-virtual.php?domain=$domain");
-			exit;
 		} catch (RuntimeException $e) {
 			$message = $LANG['Delete_delete_error'] . "<b>$delete</b> (" . $e->getMessage() . ")!</span>";
 		} catch (PDOException $e) {
@@ -180,9 +178,7 @@ if ($_SERVER['REQUEST_METHOD'] == "GET") {
 			$sth->bindParam(1, $delete, PDO::PARAM_STR);
 			$sth->bindParam(2, $domain, PDO::PARAM_STR);
 			$sth->execute();
-
 			header("Location: list-virtual.php?domain=$domain");
-			exit;
 		} catch (RuntimeException $e) {
 			$message = $LANG['Delete_delete_error'] . "<b>$delete</b> (" . $e->getMessage() . ")!</span>";
 		} catch (PDOException $e) {
blob - 1622f6f8c57769ad5b3184689db3ae6507ea16e0
blob + 03d550c2fb0306a1ac6134d3661bc69166b43766
--- admin/edit-alias.php
+++ admin/edit-alias.php
@@ -30,17 +30,20 @@ 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'));
 
-	try {
-		$dbh = connect_db();
-		$sth = $dbh->prepare("SELECT goto FROM alias WHERE address=? AND domain=?");
-		$sth->bindParam(1, $address, PDO::PARAM_STR);
-		$sth->bindParam(2, $domain, PDO::PARAM_STR);
-		$sth->execute();
-		$goto = $sth->fetch(PDO::FETCH_COLUMN);
-		$goto = explode(',', $goto);
-	} catch(PDOException $e) {
-		$message = $LANG['Edit_alias_address_error'];
+	if ($domain_exist) {
+		try {
+			$dbh = connect_db();
+			$sth = $dbh->prepare("SELECT goto FROM alias WHERE address=? AND domain=?");
+			$sth->bindParam(1, $address, PDO::PARAM_STR);
+			$sth->bindParam(2, $domain, PDO::PARAM_STR);
+			$sth->execute();
+			$goto = $sth->fetch(PDO::FETCH_COLUMN);
+			$goto = explode(',', $goto);
+		} catch(PDOException $e) {
+			$message = $LANG['Edit_alias_address_error'];
+		}
 	}
 }
 
@@ -49,6 +52,7 @@ if ($_SERVER['REQUEST_METHOD'] == "POST") {
 	$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();
@@ -67,7 +71,7 @@ if ($_SERVER['REQUEST_METHOD'] == "POST") {
 		}
 	}
 
-	if (empty($message) && isset($domain_key)) {
+	if ($domain_exist && empty($message)) {
 		try {
 			$dbh = connect_db();
 			$sth = $dbh->prepare("UPDATE alias SET goto=?,modified=NOW() WHERE address=? AND domain=?");
blob - 350f25d1ed76be281939270fbbd3c28b6e5d33ae
blob + 01e60dbaea9985658642113aabf09ac15c1352df
--- admin/edit-mailbox.php
+++ admin/edit-mailbox.php
@@ -31,17 +31,21 @@ $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'));
 
-	try {
-		$dbh = connect_db();
-		$sth = $dbh->prepare("SELECT * FROM mailbox WHERE username=? AND domain=?");
-		$sth->bindParam(1, $username, PDO::PARAM_STR);
-		$sth->bindParam(2, $domain, PDO::PARAM_STR);
-		$sth->execute();
-		$mailbox_details = $sth->fetch();
-		$name = $mailbox_details['name'];
-	} catch(PDOException $e) {
-		$message = $LANG['Edit_mailbox_login_error'];
+	if ($domain_exist) {
+		try {
+			$dbh = connect_db();
+			$sth = $dbh->prepare("SELECT * FROM mailbox WHERE username=? AND domain=?");
+			$sth->bindParam(1, $username, PDO::PARAM_STR);
+			$sth->bindParam(2, $domain, PDO::PARAM_STR);
+			$sth->execute();
+			$mailbox_details = $sth->fetch();
+			$name = $mailbox_details['name'];
+		} catch(PDOException $e) {
+			$message = $LANG['Edit_mailbox_login_error'];
+		}
 	}
 }
 
@@ -51,6 +55,8 @@ if ($_SERVER['REQUEST_METHOD'] == "POST") {
 	$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'];
@@ -71,7 +77,7 @@ if ($_SERVER['REQUEST_METHOD'] == "POST") {
 		}	
 	}
 
-	if (empty($message) && isset($domain_key)) {
+	if ($domain_exist && empty($message)) {
 		try {
 			$dbh = connect_db();
 			$sth = $dbh->prepare("UPDATE mailbox SET name=?,modified=NOW() WHERE username=? AND domain=?");
blob - 40d9de400f98399bacb2cc84258ca448571766a1
blob + 574bd084c23499fefe0d58a7cdd8f351e4b1667d
--- admin/viewlog.php
+++ admin/viewlog.php
@@ -25,11 +25,15 @@ $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'));
-	$dbh = connect_db();
-	$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(); 
+	$domain_exist = in_array($domain, array_column($list_domains, 'domain'));
+
+	if ($domain_exist) {
+		$dbh = connect_db();
+		$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';
blob - 0b3bd426c576459c8b7481eae4e11eb9415a1d4d
blob + 7d753a9dbcb72afcf1ad471d4c9b4023b1c31ded
--- delete.php
+++ delete.php
@@ -28,12 +28,13 @@ $list_domains = list_domains($SESSID_USERNAME);
 $admin = $SESSID_USERNAME ?? ADMIN_EMAIL;
 
 if ($_SERVER['REQUEST_METHOD'] == "GET") {
-        $table = strtolower(filter_input(INPUT_GET, 'table', FILTER_DEFAULT));
+        $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 (($table == 'alias' || $table == 'mailbox') && in_array($domain, array_column($list_domains, 'domain'))) {
+	if ($domain_exist && ($table == 'alias' || $table == 'mailbox')) {
 		try {
 			$dbh = connect_db();
 			$sth = $dbh->prepare("DELETE FROM alias WHERE address=? AND domain=?");
@@ -46,7 +47,6 @@ if ($_SERVER['REQUEST_METHOD'] == "GET") {
 			logging($admin, $domain, "delete alias", $delete);
 
 			header("Location: list-virtual.php?domain=$domain");
-			exit;
 		} catch (RuntimeException $e) {
 			$message = $LANG['Delete_delete_error'] . "<b>$delete</b> (" . $e->getMessage() . ")!</span>";
 		} catch (PDOException $e) {
@@ -58,6 +58,11 @@ if ($_SERVER['REQUEST_METHOD'] == "GET") {
 			$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 = $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');
@@ -70,7 +75,6 @@ if ($_SERVER['REQUEST_METHOD'] == "GET") {
 			$sth->execute();
 
 			header("Location: list-virtual.php?domain=$domain");
-			exit;
 		} catch (RuntimeException $e) {
 			$message = $LANG['Delete_delete_error'] . "<b>$delete</b> (" . $e->getMessage() . ")!</span>";
 		} catch (PDOException $e) {
blob - 5a3333a88e1bc08540b2bd23ec499451fa5852ce
blob + 7ae5c6c366610e046129f43a2958879b54fc489d
--- edit-alias.php
+++ edit-alias.php
@@ -31,17 +31,20 @@ 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'));
 
-	try {
-		$dbh = connect_db();
-		$sth = $dbh->prepare("SELECT goto FROM alias WHERE address=? AND domain=?");
-		$sth->bindParam(1, $address, PDO::PARAM_STR);
-		$sth->bindParam(2, $domain, PDO::PARAM_STR);
-		$sth->execute();
-		$goto = $sth->fetch(PDO::FETCH_COLUMN);
-		$goto = explode(',', $goto);
-	} catch(PDOException $e) {
-		$message = $LANG['Edit_alias_address_error'];
+	if ($domain_exist) {
+		try {
+			$dbh = connect_db();
+			$sth = $dbh->prepare("SELECT goto FROM alias WHERE address=? AND domain=?");
+			$sth->bindParam(1, $address, PDO::PARAM_STR);
+			$sth->bindParam(2, $domain, PDO::PARAM_STR);
+			$sth->execute();
+			$goto = $sth->fetch(PDO::FETCH_COLUMN);
+			$goto = explode(',', $goto);
+		} catch(PDOException $e) {
+			$message = $LANG['Edit_alias_address_error'];
+		}
 	}
 }
 
@@ -50,6 +53,7 @@ if ($_SERVER['REQUEST_METHOD'] == "POST") {
 	$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();
@@ -68,7 +72,7 @@ if ($_SERVER['REQUEST_METHOD'] == "POST") {
 		}
 	}
 
-	if (empty($message) && isset($domain_key)) {
+	if ($domain_exist && empty($message)) {
 		try {
 			$dbh = connect_db();
 			$sth = $dbh->prepare("UPDATE alias SET goto=?,modified=NOW() WHERE address=? AND domain=?");
@@ -84,7 +88,7 @@ if ($_SERVER['REQUEST_METHOD'] == "POST") {
 	}
 }
 include './templates/header.tpl';
-include './templates/menu.tpl';
+include './templates/admin_menu.tpl';
 include './templates/edit-alias.tpl';
 include './templates/footer.tpl';
 ?>
blob - 88ade1ff74edfa0c44d3a3dee9a705283679fa32
blob + 6bddeb312dab0dc6519917902a62b1572d82ee6a
--- edit-mailbox.php
+++ edit-mailbox.php
@@ -32,17 +32,21 @@ $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'));
 
-	try {
-		$dbh = connect_db();
-		$sth = $dbh->prepare("SELECT * FROM mailbox WHERE username=? AND domain=?");
-		$sth->bindParam(1, $username, PDO::PARAM_STR);
-		$sth->bindParam(2, $domain, PDO::PARAM_STR);
-		$sth->execute();
-		$mailbox_details = $sth->fetch();
-		$name = $mailbox_details['name'];
-	} catch(PDOException $e) {
-		$message = $LANG['Edit_mailbox_login_error'];
+	if ($domain_exist) {
+		try {
+			$dbh = connect_db();
+			$sth = $dbh->prepare("SELECT * FROM mailbox WHERE username=? AND domain=?");
+			$sth->bindParam(1, $username, PDO::PARAM_STR);
+			$sth->bindParam(2, $domain, PDO::PARAM_STR);
+			$sth->execute();
+			$mailbox_details = $sth->fetch();
+			$name = $mailbox_details['name'];
+		} catch(PDOException $e) {
+			$message = $LANG['Edit_mailbox_login_error'];
+		}
 	}
 }
 
@@ -52,6 +56,8 @@ if ($_SERVER['REQUEST_METHOD'] == "POST") {
 	$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'];
@@ -72,7 +78,7 @@ if ($_SERVER['REQUEST_METHOD'] == "POST") {
 		}	
 	}
 
-	if (empty($message) && isset($domain_key)) {
+	if ($domain_exist && empty($message)) {
 		try {
 			$dbh = connect_db();
 			$sth = $dbh->prepare("UPDATE mailbox SET name=?,modified=NOW() WHERE username=? AND domain=?");
@@ -88,7 +94,7 @@ if ($_SERVER['REQUEST_METHOD'] == "POST") {
 	}
 }
 include './templates/header.tpl';
-include './templates/menu.tpl';
+include './templates/admin_menu.tpl';
 include './templates/edit-mailbox.tpl';
 include './templates/footer.tpl';
 ?>
blob - /dev/null
blob + 8ac84c406fc2599205dd1ff7f4c695168af63bfb (mode 644)
--- /dev/null
+++ list-domain.php
@@ -0,0 +1,30 @@
+<?php
+// 
+// OpenSMTPD Admin 
+// by Mischa Peters <mischa at high5 dot nl>
+// Copyright (c) 2022 High5!
+// License Info: LICENSE.TXT
+//
+// File: list-domains.php
+//
+// Template File: list-domains.tpl
+//
+// Template variables:
+//
+// list_domains
+//
+// GET / POST variables:
+//
+// -none-
+//
+require_once './functions.inc.php';
+include './languages/' . check_language() . '.lang';
+
+$SESSID_USERNAME = check_session();
+$list_domains = list_domains($SESSID_USERNAME);
+
+include './templates/header.tpl';
+include './templates/menu.tpl';
+include './templates/list-domain.tpl';
+include './templates/footer.tpl';
+?>
blob - /dev/null
blob + 9c79c8f92f1c6f71e1b97a1c72ce8f626405a914 (mode 644)
--- /dev/null
+++ list-virtual.php
@@ -0,0 +1,43 @@
+<?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: list-virtual.tpl
+//
+// Template Variables:
+//
+// list_alias
+// list_mailbox
+//
+// Form POST \ GET Variables:
+//
+// domain
+// offset
+//
+require_once './functions.inc.php';
+include './languages/' . check_language() . '.lang';
+
+$SESSID_USERNAME = check_session();
+$list_domains = list_domains($SESSID_USERNAME);
+
+if ($_SERVER['REQUEST_METHOD'] == "GET") {
+	$offset = filter_input(INPUT_GET, 'offset', FILTER_VALIDATE_INT) ?? '0';
+	$limit = PAGE_SIZE;
+	$domain = filter_input(INPUT_GET, 'domain', FILTER_VALIDATE_DOMAIN);
+	if (in_array($domain, array_column($list_domains, 'domain'))) {
+		$domain_key = array_search($domain, array_column($list_domains, 'domain'));
+		$list_alias = list_aliases($domain, $offset, $limit);
+		$list_mailbox = list_mailboxes($domain, $offset, $limit);
+	}
+}
+
+include './templates/header.tpl';
+include './templates/menu.tpl';
+include './templates/list-virtual.tpl';
+include './templates/footer.tpl';
+?>
blob - 8ee12b0ca66c22f057802eff876c8c0f8a90abd2
blob + 71745f57e1fbaee3114c992257e9e0d33f58598a
--- templates/main.tpl
+++ templates/main.tpl
@@ -1,7 +1,7 @@
 <div id="main_menu">
 <table>
 	<tr>
-		<td nowrap><a target="_top" href="list-domains.php"><?php echo $LANG['Menu_overview']; ?></a></td>
+		<td nowrap><a target="_top" href="list-domain.php"><?php echo $LANG['Menu_overview']; ?></a></td>
 		<td><?php echo $LANG['Main_overview']; ?></td>
 	</tr>
 	<tr>
blob - 7fcbd94c4299f09b725e7b0b79dd81ab66775e32
blob + 0062735f1e8bd2666ac6b21d0d2d8326ba10f1aa
--- templates/search.tpl
+++ templates/search.tpl
@@ -24,7 +24,7 @@ if (count($tAlias) > 0) {
 			echo "		<td>" . preg_replace("/,/", "<br>", $tAlias[$i]['goto']) . "</td>\n";
 			echo "		<td>" . $tAlias[$i]['modified'] . "</td>\n";
 			echo "		<td><a href=\"edit-alias.php?address=" . $tAlias[$i]['address'] . "&domain=" . $tAlias[$i]['domain'] . "\">" . $LANG['edit'] . "</a></td>\n";
-			echo "		<td><a href=\"delete.php?delete=" . $tAlias[$i]['address'] . "&domain=" . $tAlias[$i]['domain'] . "\"onclick=\"return confirm ('" . $LANG['confirm'] . $LANG['Overview_get_aliases'] . ": ". $tAlias[$i]['address'] . "')\">" . $LANG['del'] . "</a></td>\n";
+			echo "		<td><a href=\"delete.php?table=alias&delete=" . $tAlias[$i]['address'] . "&domain=" . $tAlias[$i]['domain'] . "\"onclick=\"return confirm ('" . $LANG['confirm'] . $LANG['Overview_get_aliases'] . ": ". $tAlias[$i]['address'] . "')\">" . $LANG['del'] . "</a></td>\n";
 			echo "	</tr>\n";
 		}
 	}
@@ -40,7 +40,6 @@ if (count($tMailbox) > 0) {
 	echo "	<tr class=\"header\">\n";
 	echo "		<td>" . $LANG['Overview_mailbox_username'] . "</td>\n";
 	echo "		<td>" . $LANG['Overview_mailbox_name'] . "</td>\n";
-	if ($CONF['quota'] == 'YES') echo "		<td>" . $LANG['Overview_mailbox_quota'] . "</td>\n";
 	echo "		<td>" . $LANG['Overview_mailbox_modified'] . "</td>\n";
 	echo "		<td>" . $LANG['Overview_mailbox_active'] . "</td>\n";
 	echo "		<td colspan=\"2\">&nbsp;</td>\n";
@@ -52,7 +51,7 @@ if (count($tMailbox) > 0) {
 			echo "		<td>" . $tMailbox[$i]['username'] . "</td>\n";
 			echo "		<td>" . $tMailbox[$i]['name'] . "</td>\n";
 			echo "		<td><a href=\"edit-mailbox.php?username=" . $tMailbox[$i]['username'] . "&domain=" . $tMailbox[$i]['domain'] . "\">" . $LANG['edit'] . "</a></td>\n";
-			echo "		<td><a href=\"delete.php?delete=" . $tMailbox[$i]['username'] . "&domain=" . $tMailbox[$i]['domain'] . "\"onclick=\"return confirm ('" . $LANG['confirm'] . $LANG['Overview_get_mailboxes'] . ": ". $tMailbox[$i]['username'] . "')\">" . $LANG['del'] . "</a></td>\n";
+			echo "		<td><a href=\"delete.php?table=mailbox&delete=" . $tMailbox[$i]['username'] . "&domain=" . $tMailbox[$i]['domain'] . "\"onclick=\"return confirm ('" . $LANG['confirm'] . $LANG['Overview_get_mailboxes'] . ": ". $tMailbox[$i]['username'] . "')\">" . $LANG['del'] . "</a></td>\n";
 			echo "	</tr>\n";
 		}
 	}
blob - 88aaef42e8d1214661425b757f41857cd579a2ab
blob + 33a8b1ea6dffb9d70aebc966cf047580a3605e59
--- templates/viewlog.tpl
+++ templates/viewlog.tpl
@@ -15,7 +15,7 @@ if (count($list_domains) > 0) {
 </form>
 </div>
 <?php 
-if (count($log) > 0) {
+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";
blob - 2c848b9cf669e07daec9107c1e2ce6b9185ac821
blob + fdae458edd429d8f39778affdbbca728b41c23ca
--- viewlog.php
+++ viewlog.php
@@ -26,11 +26,15 @@ $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'));
-	$dbh = connect_db();
-	$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(); 
+	$domain_exist = in_array($domain, array_column($list_domains, 'domain'));
+
+	if ($domain_exist) {
+		$dbh = connect_db();
+		$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';