Commit Diff


commit - 299eeaee3ffbac49b88577bef60c6267da27c4a9
commit + e0b946dd8b114ac17fb1ceb84acc1dd8236cadf7
blob - 8d1c032bca3178cc8dd458ee69671254e4caceac
blob + ac2bcfffbb87b0fb863a84f7c4c6cbb4ccda9d09
--- admin/add-alias.php
+++ admin/add-alias.php
@@ -27,12 +27,18 @@ include '../languages/' . check_language() . '.lang';
 
 $list_domains = list_domains();
 
+if ($_SERVER['REQUEST_METHOD'] == "GET") {
+	$domain = filter_input(INPUT_GET, 'domain', FILTER_VALIDATE_DOMAIN);
+	$domain_key = array_search($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'));
+	print "$domain_key";
 
 	$from = filter_var($address . '@' . $domain, FILTER_VALIDATE_EMAIL);
 	if (!str_contains($goto, '@')) {
blob - 76e84c072cbd0f992e7e8077d5750c402b44912b
blob + d6f2fe79c4154dc312e8d23ede8a84d6292f3838
--- admin/add-mailbox.php
+++ admin/add-mailbox.php
@@ -29,8 +29,12 @@ include '../languages/' . check_language() . '.lang';
 
 $list_domains = list_domains();
 
-if ($_SERVER['REQUEST_METHOD'] == "POST") {
+if ($_SERVER['REQUEST_METHOD'] == "GET") {
+        $domain = filter_input(INPUT_GET, 'domain', FILTER_VALIDATE_DOMAIN);
+        $domain_key = array_search($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);
blob - c9e46062bd0305b15094b7503456b6f111e71934
blob + 76e1928704369e4c51739f3df2fef920432f5a61
--- admin/list-virtual.php
+++ admin/list-virtual.php
@@ -29,7 +29,7 @@ if ($_SERVER['REQUEST_METHOD'] == "GET") {
 	$limit = PAGE_SIZE;
 	if (count($list_domains) > 0) {
 		$domain = filter_input(INPUT_GET, 'domain', FILTER_VALIDATE_DOMAIN) ?? $list_domains[0]['domain'];
-		$selected_domain = array_search($domain, array_column($list_domains, 'domain'));
+		$domain_key = array_search($domain, array_column($list_domains, 'domain'));
 		$list_alias = list_aliases($domain, $offset, $limit);
 		$list_mailbox = list_mailboxes($domain, $offset, $limit);
 	}
blob - 43fdcadb3f53805bd0dcf8aa5d43b4d400f2a5e3
blob + 40d9de400f98399bacb2cc84258ca448571766a1
--- admin/viewlog.php
+++ admin/viewlog.php
@@ -24,6 +24,7 @@ $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);
blob - /dev/null
blob + d3f7356c5473993e6c2ee78eb59056b5ee3b4263 (mode 644)
--- /dev/null
+++ add-alias.php
@@ -0,0 +1,112 @@
+<?php
+// 
+// OpenSMTPD Admin 
+// by Mischa Peters <mischa at high5 dot nl>
+// Copyright (c) 2022 High5!
+// License Info: LICENSE.TXT
+//
+// File: create-alias.php
+//
+// Template File: create-alias.tpl
+//
+// Template Variables:
+//
+// tMessage
+// tAddress
+// tGoto
+// tDomain
+//
+// Form POST \ GET Variables:
+//
+// fAddress
+// fGoto
+// fDomain
+//
+require("./functions.inc.php");
+include("./languages/" . check_language() . ".lang");
+
+$SESSID_USERNAME = check_session();
+$list_domains = list_domains($SESSID_USERNAME);
+
+if ($_SERVER['REQUEST_METHOD'] == "GET") {
+	$pCreate_alias_goto_text = $LANG['Create_alias_goto_text'];
+
+	if (isset($_GET['domain'])) $tDomain = escape_string($_GET['domain']);
+}
+
+if ($_SERVER['REQUEST_METHOD'] == "POST") {
+	$pCreate_alias_goto_text = $LANG['Create_alias_goto_text'];
+
+	$fAddress = escape_string($_POST['fAddress']) . "@" . escape_string($_POST['fDomain']);
+	$fAddress = strtolower($fAddress);
+	$fGoto = escape_string($_POST['fGoto']);
+	$fGoto = strtolower($fGoto);
+	$fDomain = escape_string($_POST['fDomain']);
+
+	if (!preg_match('/@/',$fGoto)) {
+		$fGoto = $fGoto . "@" . escape_string($_POST['fDomain']);
+	}
+
+	if (!check_owner($SESSID_USERNAME, $fDomain)) {
+		$error = 1;
+		$tAddress = escape_string($_POST['fAddress']);
+		$tGoto = $fGoto;
+		$tDomain = $fDomain;		
+		$pCreate_alias_address_text = $LANG['Create_alias_address_text_error1'];
+	}
+
+	if (!check_alias($fDomain)) {
+		$error = 1;
+		$tAddress = escape_string($_POST['fAddress']);
+		$tGoto = $fGoto;
+		$tDomain = $fDomain;
+		$pCreate_alias_address_text = $LANG['Create_alias_address_text_error3'];
+	}
+	
+	if (empty($fAddress) or !check_email($fAddress)) {
+		$error = 1;
+		$tAddress = escape_string($_POST['fAddress']);
+		$tGoto = $fGoto;
+		$tDomain = $fDomain;
+		$pCreate_alias_address_text = $LANG['Create_alias_address_text_error1'];
+	}
+
+	if (empty($fGoto) or !check_email($fGoto)) {
+		$error = 1;
+		$tAddress = escape_string($_POST['fAddress']);
+		$tGoto = $fGoto;
+		$tDomain = $fDomain;
+		$pCreate_alias_goto_text = $LANG['Create_alias_goto_text_error'];
+	}
+
+	if (escape_string($_POST['fAddress']) == "*") $fAddress = "@" . escape_string($_POST['fDomain']);
+
+	$result = db_query("SELECT * FROM alias WHERE address='$fAddress'");
+	if ($result['rows'] == 1) {
+		$error = 1;
+		$tAddress = escape_string($_POST['fAddress']);
+		$tGoto = $fGoto;
+		$tDomain = $fDomain;
+		$pCreate_alias_address_text = $LANG['Create_alias_address_text_error2'];
+	}
+
+	if ($error != 1) {
+		if (preg_match('/^\*@(.*)$/', $fGoto, $match)) $fGoto = "@" . $match[1];
+
+		$result = db_query("INSERT INTO alias (address,goto,domain,created,modified) VALUES ('$fAddress','$fGoto','$fDomain',NOW(),NOW())");
+		if ($result['rows'] != 1) {
+			$tDomain = $fDomain;
+			$tMessage = $LANG['Create_alias_result_error'] . "<br />($fAddress -> $fGoto)<br />\n";
+		} else {
+			db_log($SESSID_USERNAME, $fDomain, "create alias", "$fAddress -> $fGoto");
+
+			$tDomain = $fDomain;
+			$tMessage = $LANG['Create_alias_result_succes'] . "<br />($fAddress -> $fGoto)<br />\n";
+		}
+	}
+}
+include("./templates/header.tpl");
+include("./templates/menu.tpl");
+include("./templates/add-alias.tpl");
+include("./templates/footer.tpl");
+?>
blob - /dev/null
blob + 23698790470ccda7a42802a038efdb6a87b52708 (mode 644)
--- /dev/null
+++ add-mailbox.php
@@ -0,0 +1,191 @@
+<?php
+// 
+// OpenSMTPD Admin 
+// by Mischa Peters <mischa at high5 dot nl>
+// Copyright (c) 2022 High5!
+// License Info: LICENSE.TXT
+//
+// File: create-mailbox.php
+//
+// Template File: create-mailbox.tpl
+//
+// Template Variables:
+//
+// tMessage
+// tUsername
+// tName
+// tQuota
+// tDomain
+//
+// Form POST \ GET Variables:
+//
+// fUsername
+// fPassword
+// fPassword2
+// fName
+// fQuota
+// fDomain
+// fActive
+// fMail
+//
+require("./functions.inc.php");
+include("./languages/" . check_language() . ".lang");
+
+$SESSID_USERNAME = check_session();
+$list_domains = list_domains($SESSID_USERNAME);
+
+if ($_SERVER['REQUEST_METHOD'] == "GET") {
+	$tQuota = $CONF['maxquota'];
+
+	$pCreate_mailbox_password_text = $LANG['Create_mailbox_password_text'];
+	$pCreate_mailbox_name_text = $LANG['Create_mailbox_name_text'];
+	$pCreate_mailbox_quota_text = $LANG['Create_mailbox_quota_text'];
+
+	if (isset($_GET['domain'])) $tDomain = escape_string($_GET['domain']);
+}
+
+if ($_SERVER['REQUEST_METHOD'] == "POST") {
+	$pCreate_mailbox_password_text = $LANG['Create_mailbox_password_text'];
+	$pCreate_mailbox_name_text = $LANG['Create_mailbox_name_text'];
+	$pCreate_mailbox_quota_text = $LANG['Create_mailbox_quota_text'];
+  
+	$fUsername = escape_string($_POST['fUsername']) . "@" . escape_string($_POST['fDomain']);
+	$fUsername = strtolower($fUsername);
+	$fPassword = escape_string($_POST['fPassword']);
+	$fPassword2 = escape_string($_POST['fPassword2']);
+	$fName = escape_string($_POST['fName']);
+	$fDomain = escape_string($_POST['fDomain']);
+	if (isset($_POST['fQuota'])) $fQuota = escape_string($_POST['fQuota']);
+	if (isset($_POST['fActive'])) $fActive = escape_string($_POST['fActive']);
+	if (isset($_POST['fMail'])) $fMail = escape_string($_POST['fMail']);
+
+	if (!check_owner($SESSID_USERNAME, $fDomain)) {
+		$error = 1;
+		$tUsername = escape_string($_POST['fUsername']);
+		$tName = $fName;
+		$tQuota = $fQuota;
+		$tDomain = $fDomain;
+		$pCreate_mailbox_username_text = $LANG['Create_mailbox_username_text_error1'];
+	}
+
+	if (!check_mailbox($fDomain)) {
+		$error = 1;
+		$tUsername = escape_string($_POST['fUsername']);
+		$tName = $fName;
+		$tQuota = $fQuota;
+		$tDomain = $fDomain;
+		$pCreate_mailbox_username_text = $LANG['Create_mailbox_username_text_error3'];
+	}
+	 
+	if (empty($fUsername) or !check_email($fUsername)) {
+		$error = 1;
+		$tUsername = escape_string($_POST['fUsername']);
+		$tName = $fName;
+		$tQuota = $fQuota;
+		$tDomain = $fDomain;
+		$pCreate_mailbox_username_text = $LANG['Create_mailbox_username_text_error1'];
+	}
+
+	if (empty($fPassword) or ($fPassword != $fPassword2)) {
+		if ($CONF['generate_password'] == "YES") {
+			$fPassword = generate_password();
+		} else {
+			$error = 1;
+			$tUsername = escape_string($_POST['fUsername']);
+			$tName = $fName;
+			$tQuota = $fQuota;
+			$tDomain = $fDomain;
+			$pCreate_mailbox_password_text = $LANG['Create_mailbox_password_text_error'];
+		}
+	}
+
+	if ($CONF['quota'] == "YES") {
+		if (!check_quota($fQuota, $fDomain)) {
+			$error = 1;
+			$tUsername = escape_string($_POST['fUsername']);
+			$tName = $fName;
+			$tQuota = $fQuota;
+			$tDomain = $fDomain;
+			$pCreate_mailbox_quota_text = $LANG['Create_mailbox_quota_text_error'];
+		}
+	}
+	
+	$result = db_query("SELECT * FROM alias WHERE address='$fUsername'");
+	if ($result['rows'] == 1) {
+		$error = 1;
+		$tUsername = escape_string($_POST['fUsername']);
+		$tName = $fName;
+		$tQuota = $fQuota;
+		$tDomain = $fDomain;
+		$pCreate_mailbox_username_text = $LANG['Create_mailbox_username_text_error2'];
+	}
+
+	if ($error != 1) {
+		$password = pacrypt($fPassword);
+		
+		if ($CONF['domain_path'] == "YES") {
+			if ($CONF['domain_in_mailbox'] == "YES") {
+				$maildir = $fDomain . "/" . $fUsername . "/";
+			} else {
+				$maildir = $fDomain . "/" . escape_string($_POST['fUsername']) . "/";
+			}
+		} else {
+			$maildir = $fUsername . "/";
+		}
+		
+		if (!empty($fQuota)) {
+			$quota = $fQuota * $CONF['quota_multiplier'];
+		} else {
+			$quota = 0;
+		}
+	
+		if ($fActive == "on") {
+			$fActive = 1;
+		} else {
+			$fActive = 0;
+		}
+
+		$result = db_query("INSERT INTO alias (address,goto,domain,created,modified,active) VALUES ('$fUsername','vmail','$fDomain',NOW(),NOW(),'$fActive')");
+		if ($result['rows'] != 1) {
+			$tDomain = $fDomain;
+			$tMessage = $LANG['Alias_result_error'] . "<br />($fUsername -> $fUsername)</br />";
+		}
+
+		$result = db_query("INSERT INTO mailbox (username,password,name,maildir,quota,domain,created,modified,active) VALUES ('$fUsername','$password','$fName','$maildir','$quota','$fDomain',NOW(),NOW(),'$fActive')");
+		if ($result['rows'] != 1) {
+			$tDomain = $fDomain;
+			$tMessage .= $LANG['Create_mailbox_result_error'] . "<br />($fUsername)<br />";
+		} else {
+			db_log($SESSID_USERNAME, $fDomain, "create mailbox", "$fUsername");
+
+			$tDomain = $fDomain;
+			$tMessage = $LANG['Create_mailbox_result_succes'] . "<br />($fUsername";
+			if ($CONF['generate_password'] == "YES") {
+				$tMessage .= " / $fPassword)</br />";
+			} else {
+				$tMessage .= ")</br />";
+			}
+	
+			$tQuota = $CONF['maxquota'];
+
+			if ($fMail == "on") {
+				$fTo = $fUsername;
+				$fSubject = $LANG['Sendmail_subject_text'];
+				$fHeaders = "From: " . $SESSID_USERNAME . "\r\n";
+				$fHeaders .= "Content-Type: text/plain; charset=utf-8\r\n";
+				$fBody = $CONF['welcome_text'];
+
+				if (!mail($fTo, $fSubject, $fBody, $fHeaders)) {
+					$tMessage .= "<br />" . $LANG['Sendmail_result_error'] . "<br />";
+				} else {
+					$tMessage .= "<br />" . $LANG['Sendmail_result_succes'] . "<br />";
+				}
+			}
+		}
+	}
+}
+include("./templates/header.tpl");
+include("./templates/menu.tpl");
+include("./templates/add-mailbox.tpl");
+include("./templates/footer.tpl");
+?>
blob - 7a1895d5dcbd6ecde053d5aa0320bd810a00211b (mode 644)
blob + /dev/null
--- create-alias.php
+++ /dev/null
@@ -1,114 +0,0 @@
-<?php
-// 
-// OpenSMTPD Admin 
-// by Mischa Peters <mischa at high5 dot nl>
-// Copyright (c) 2022 High5!
-// License Info: LICENSE.TXT
-//
-// File: create-alias.php
-//
-// Template File: create-alias.tpl
-//
-// Template Variables:
-//
-// tMessage
-// tAddress
-// tGoto
-// tDomain
-//
-// Form POST \ GET Variables:
-//
-// fAddress
-// fGoto
-// fDomain
-//
-require("./variables.inc.php");
-require("./config.inc.php");
-require("./functions.inc.php");
-include("./languages/" . check_language() . ".lang");
-
-$SESSID_USERNAME = check_session();
-$list_domains = list_domains_for_admin($SESSID_USERNAME);
-
-if ($_SERVER['REQUEST_METHOD'] == "GET") {
-	$pCreate_alias_goto_text = $LANG['Create_alias_goto_text'];
-
-	if (isset($_GET['domain'])) $tDomain = escape_string($_GET['domain']);
-}
-
-if ($_SERVER['REQUEST_METHOD'] == "POST") {
-	$pCreate_alias_goto_text = $LANG['Create_alias_goto_text'];
-
-	$fAddress = escape_string($_POST['fAddress']) . "@" . escape_string($_POST['fDomain']);
-	$fAddress = strtolower($fAddress);
-	$fGoto = escape_string($_POST['fGoto']);
-	$fGoto = strtolower($fGoto);
-	$fDomain = escape_string($_POST['fDomain']);
-
-	if (!preg_match('/@/',$fGoto)) {
-		$fGoto = $fGoto . "@" . escape_string($_POST['fDomain']);
-	}
-
-	if (!check_owner($SESSID_USERNAME, $fDomain)) {
-		$error = 1;
-		$tAddress = escape_string($_POST['fAddress']);
-		$tGoto = $fGoto;
-		$tDomain = $fDomain;		
-		$pCreate_alias_address_text = $LANG['Create_alias_address_text_error1'];
-	}
-
-	if (!check_alias($fDomain)) {
-		$error = 1;
-		$tAddress = escape_string($_POST['fAddress']);
-		$tGoto = $fGoto;
-		$tDomain = $fDomain;
-		$pCreate_alias_address_text = $LANG['Create_alias_address_text_error3'];
-	}
-	
-	if (empty($fAddress) or !check_email($fAddress)) {
-		$error = 1;
-		$tAddress = escape_string($_POST['fAddress']);
-		$tGoto = $fGoto;
-		$tDomain = $fDomain;
-		$pCreate_alias_address_text = $LANG['Create_alias_address_text_error1'];
-	}
-
-	if (empty($fGoto) or !check_email($fGoto)) {
-		$error = 1;
-		$tAddress = escape_string($_POST['fAddress']);
-		$tGoto = $fGoto;
-		$tDomain = $fDomain;
-		$pCreate_alias_goto_text = $LANG['Create_alias_goto_text_error'];
-	}
-
-	if (escape_string($_POST['fAddress']) == "*") $fAddress = "@" . escape_string($_POST['fDomain']);
-
-	$result = db_query("SELECT * FROM alias WHERE address='$fAddress'");
-	if ($result['rows'] == 1) {
-		$error = 1;
-		$tAddress = escape_string($_POST['fAddress']);
-		$tGoto = $fGoto;
-		$tDomain = $fDomain;
-		$pCreate_alias_address_text = $LANG['Create_alias_address_text_error2'];
-	}
-
-	if ($error != 1) {
-		if (preg_match('/^\*@(.*)$/', $fGoto, $match)) $fGoto = "@" . $match[1];
-
-		$result = db_query("INSERT INTO alias (address,goto,domain,created,modified) VALUES ('$fAddress','$fGoto','$fDomain',NOW(),NOW())");
-		if ($result['rows'] != 1) {
-			$tDomain = $fDomain;
-			$tMessage = $LANG['Create_alias_result_error'] . "<br />($fAddress -> $fGoto)<br />\n";
-		} else {
-			db_log($SESSID_USERNAME, $fDomain, "create alias", "$fAddress -> $fGoto");
-
-			$tDomain = $fDomain;
-			$tMessage = $LANG['Create_alias_result_succes'] . "<br />($fAddress -> $fGoto)<br />\n";
-		}
-	}
-}
-include("./templates/header.tpl");
-include("./templates/menu.tpl");
-include("./templates/create-alias.tpl");
-include("./templates/footer.tpl");
-?>
blob - 3c3b82917b9dc0488dd52cf0af1f9a8a2ee62010 (mode 644)
blob + /dev/null
--- create-mailbox.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: create-mailbox.php
-//
-// Template File: create-mailbox.tpl
-//
-// Template Variables:
-//
-// tMessage
-// tUsername
-// tName
-// tQuota
-// tDomain
-//
-// Form POST \ GET Variables:
-//
-// fUsername
-// fPassword
-// fPassword2
-// fName
-// fQuota
-// fDomain
-// fActive
-// fMail
-//
-require("./variables.inc.php");
-require("./config.inc.php");
-require("./functions.inc.php");
-include("./languages/" . check_language() . ".lang");
-
-$SESSID_USERNAME = check_session();
-$list_domains = list_domains_for_admin($SESSID_USERNAME);
-
-if ($_SERVER['REQUEST_METHOD'] == "GET") {
-	$tQuota = $CONF['maxquota'];
-
-	$pCreate_mailbox_password_text = $LANG['Create_mailbox_password_text'];
-	$pCreate_mailbox_name_text = $LANG['Create_mailbox_name_text'];
-	$pCreate_mailbox_quota_text = $LANG['Create_mailbox_quota_text'];
-
-	if (isset($_GET['domain'])) $tDomain = escape_string($_GET['domain']);
-}
-
-if ($_SERVER['REQUEST_METHOD'] == "POST") {
-	$pCreate_mailbox_password_text = $LANG['Create_mailbox_password_text'];
-	$pCreate_mailbox_name_text = $LANG['Create_mailbox_name_text'];
-	$pCreate_mailbox_quota_text = $LANG['Create_mailbox_quota_text'];
-  
-	$fUsername = escape_string($_POST['fUsername']) . "@" . escape_string($_POST['fDomain']);
-	$fUsername = strtolower($fUsername);
-	$fPassword = escape_string($_POST['fPassword']);
-	$fPassword2 = escape_string($_POST['fPassword2']);
-	$fName = escape_string($_POST['fName']);
-	$fDomain = escape_string($_POST['fDomain']);
-	if (isset($_POST['fQuota'])) $fQuota = escape_string($_POST['fQuota']);
-	if (isset($_POST['fActive'])) $fActive = escape_string($_POST['fActive']);
-	if (isset($_POST['fMail'])) $fMail = escape_string($_POST['fMail']);
-
-	if (!check_owner($SESSID_USERNAME, $fDomain)) {
-		$error = 1;
-		$tUsername = escape_string($_POST['fUsername']);
-		$tName = $fName;
-		$tQuota = $fQuota;
-		$tDomain = $fDomain;
-		$pCreate_mailbox_username_text = $LANG['Create_mailbox_username_text_error1'];
-	}
-
-	if (!check_mailbox($fDomain)) {
-		$error = 1;
-		$tUsername = escape_string($_POST['fUsername']);
-		$tName = $fName;
-		$tQuota = $fQuota;
-		$tDomain = $fDomain;
-		$pCreate_mailbox_username_text = $LANG['Create_mailbox_username_text_error3'];
-	}
-	 
-	if (empty($fUsername) or !check_email($fUsername)) {
-		$error = 1;
-		$tUsername = escape_string($_POST['fUsername']);
-		$tName = $fName;
-		$tQuota = $fQuota;
-		$tDomain = $fDomain;
-		$pCreate_mailbox_username_text = $LANG['Create_mailbox_username_text_error1'];
-	}
-
-	if (empty($fPassword) or ($fPassword != $fPassword2)) {
-		if ($CONF['generate_password'] == "YES") {
-			$fPassword = generate_password();
-		} else {
-			$error = 1;
-			$tUsername = escape_string($_POST['fUsername']);
-			$tName = $fName;
-			$tQuota = $fQuota;
-			$tDomain = $fDomain;
-			$pCreate_mailbox_password_text = $LANG['Create_mailbox_password_text_error'];
-		}
-	}
-
-	if ($CONF['quota'] == "YES") {
-		if (!check_quota($fQuota, $fDomain)) {
-			$error = 1;
-			$tUsername = escape_string($_POST['fUsername']);
-			$tName = $fName;
-			$tQuota = $fQuota;
-			$tDomain = $fDomain;
-			$pCreate_mailbox_quota_text = $LANG['Create_mailbox_quota_text_error'];
-		}
-	}
-	
-	$result = db_query("SELECT * FROM alias WHERE address='$fUsername'");
-	if ($result['rows'] == 1) {
-		$error = 1;
-		$tUsername = escape_string($_POST['fUsername']);
-		$tName = $fName;
-		$tQuota = $fQuota;
-		$tDomain = $fDomain;
-		$pCreate_mailbox_username_text = $LANG['Create_mailbox_username_text_error2'];
-	}
-
-	if ($error != 1) {
-		$password = pacrypt($fPassword);
-		
-		if ($CONF['domain_path'] == "YES") {
-			if ($CONF['domain_in_mailbox'] == "YES") {
-				$maildir = $fDomain . "/" . $fUsername . "/";
-			} else {
-				$maildir = $fDomain . "/" . escape_string($_POST['fUsername']) . "/";
-			}
-		} else {
-			$maildir = $fUsername . "/";
-		}
-		
-		if (!empty($fQuota)) {
-			$quota = $fQuota * $CONF['quota_multiplier'];
-		} else {
-			$quota = 0;
-		}
-	
-		if ($fActive == "on") {
-			$fActive = 1;
-		} else {
-			$fActive = 0;
-		}
-
-		$result = db_query("INSERT INTO alias (address,goto,domain,created,modified,active) VALUES ('$fUsername','vmail','$fDomain',NOW(),NOW(),'$fActive')");
-		if ($result['rows'] != 1) {
-			$tDomain = $fDomain;
-			$tMessage = $LANG['Alias_result_error'] . "<br />($fUsername -> $fUsername)</br />";
-		}
-
-		$result = db_query("INSERT INTO mailbox (username,password,name,maildir,quota,domain,created,modified,active) VALUES ('$fUsername','$password','$fName','$maildir','$quota','$fDomain',NOW(),NOW(),'$fActive')");
-		if ($result['rows'] != 1) {
-			$tDomain = $fDomain;
-			$tMessage .= $LANG['Create_mailbox_result_error'] . "<br />($fUsername)<br />";
-		} else {
-			db_log($SESSID_USERNAME, $fDomain, "create mailbox", "$fUsername");
-
-			$tDomain = $fDomain;
-			$tMessage = $LANG['Create_mailbox_result_succes'] . "<br />($fUsername";
-			if ($CONF['generate_password'] == "YES") {
-				$tMessage .= " / $fPassword)</br />";
-			} else {
-				$tMessage .= ")</br />";
-			}
-	
-			$tQuota = $CONF['maxquota'];
-
-			if ($fMail == "on") {
-				$fTo = $fUsername;
-				$fSubject = $LANG['Sendmail_subject_text'];
-				$fHeaders = "From: " . $SESSID_USERNAME . "\r\n";
-				$fHeaders .= "Content-Type: text/plain; charset=utf-8\r\n";
-				$fBody = $CONF['welcome_text'];
-
-				if (!mail($fTo, $fSubject, $fBody, $fHeaders)) {
-					$tMessage .= "<br />" . $LANG['Sendmail_result_error'] . "<br />";
-				} else {
-					$tMessage .= "<br />" . $LANG['Sendmail_result_succes'] . "<br />";
-				}
-			}
-		}
-	}
-}
-include("./templates/header.tpl");
-include("./templates/menu.tpl");
-include("./templates/create-mailbox.tpl");
-include("./templates/footer.tpl");
-?>
blob - b10de07cab0b29113833827477611ba24c3fe7f0
blob + 6683e3ca78804bccc6557681ea8ec13fedfb82b9
--- list-virtuals.php
+++ list-virtuals.php
@@ -14,14 +14,13 @@
 // list_alias
 // list_mailbox
 //
-// Form GET Variables:
+// Form POST \ GET Variables:
 //
 // domain
 // offset
 //
 require_once './functions.inc.php';
 include './languages/' . check_language() . '.lang';
-include './templates/header.tpl';
 
 $SESSID_USERNAME = check_session();
 $list_domains = list_domains($SESSID_USERNAME);
@@ -34,10 +33,11 @@ if ($_SERVER['REQUEST_METHOD'] == "GET") {
 		$domain_key = array_search($domain, array_column($list_domains, 'domain'));
 		$list_alias = list_aliases($domain, $offset, $limit);
 		$list_mailbox = list_mailboxes($domain, $offset, $limit);
-		$template = "list-virtual.tpl";
-		include './templates/menu.tpl';
-		include './templates/list-virtuals.tpl';
 	}
 }
+
+include './templates/header.tpl';
+include './templates/menu.tpl';
+include './templates/list-virtuals.tpl';
 include './templates/footer.tpl';
 ?>
blob - 4284426cc11f5177ebb5797c8cdfd438ed582639
blob + d03a0e01955cfc3ca8563002e735a3675076c5fe
--- password.php
+++ password.php
@@ -19,8 +19,6 @@
 // fPassword
 // fPassword2
 //
-require("./variables.inc.php");
-require("./config.inc.php");
 require("./functions.inc.php");
 include("./languages/" . check_language() . ".lang");
 
blob - f89cf7665c93e49a6907b67be3b47e15ecc077df
blob + b6834445cf0ca7e83c3a68df1e35391aaf45c5a3
--- sendmail.php
+++ sendmail.php
@@ -22,8 +22,6 @@
 // fSubject
 // fBody
 //
-require("./variables.inc.php");
-require("./config.inc.php");
 require("./functions.inc.php");
 include("./languages/" . check_language() . ".lang");
 
blob - 28b655da4b9457821bf5f59531f6f1d07a602846
blob + bca4f981557c09f14cfe121fb4b23dbf11e739e9
--- templates/add-alias.tpl
+++ templates/add-alias.tpl
@@ -12,7 +12,7 @@
 		<?php
                 foreach ($list_domains as $row) {
                         echo '<option value="' . $row['domain'] . '"';
-			if (isset($domain) && $domain == $row['domain']) echo ' selected';
+			if ($list_domains[$domain_key]['domain'] == $row['domain']) echo ' selected';
                         echo ">" . $row['domain'] . "</option>\n";
                 }
 		?>
blob - 35306c5ce015513547253270e76600c2b10982c2
blob + 96286bf393c82b0e7e6040d28495156a6323e34a
--- templates/add-mailbox.tpl
+++ templates/add-mailbox.tpl
@@ -12,7 +12,7 @@
 		<?php
                 foreach ($list_domains as $row) {
                         echo '<option value="' . $row['domain'] . '"';
-			if (isset($domain) && $domain == $row['domain']) echo ' selected';
+			if ($list_domains[$domain_key]['domain'] == $row['domain']) echo ' selected';
                         echo ">" . $row['domain'] . "</option>\n";
                 }
 		?>
blob - 2338630383156dbebde1231b158b330dbfa9f646
blob + 366f82fc4edbb5b5fe12d15467486f830996758b
--- templates/admin_list-domain.tpl
+++ templates/admin_list-domain.tpl
@@ -5,7 +5,7 @@
 if (count($list_admins) > 0) {
 	foreach ($list_admins as $row) {
 		echo '<option value="' . $row['username'] . '"';
-		if (isset($_GET['username']) && $_GET['username'] == $row['username']) echo ' selected';
+		if (isset($username) && $username  == $row['username']) echo ' selected';
 		echo ">" . $row['username'] . "</option>\n";
 	}
 }
blob - 0bce6853846f5121e996f898f8ab1bf7db943a28
blob + 6688e7d0a016517a1eb2c616fc1eded79967bc47
--- templates/admin_list-virtual.tpl
+++ templates/admin_list-virtual.tpl
@@ -5,7 +5,7 @@
 if (count($list_domains) > 0) {
 	foreach ($list_domains as $row) {
 		echo '<option value="' . $row['domain'] . '"';
-		if ($list_domains[$selected_domain]['domain'] == $row['domain']) echo ' selected';
+		if ($list_domains[$domain_key]['domain'] == $row['domain']) echo ' selected';
 		echo ">" . $row['domain'] . "</option>\n";
 	}
 }
@@ -16,8 +16,8 @@ if (count($list_domains) > 0) {
 </form>
 
 <h4><?php echo $LANG['AdminList_virtual_welcome'] . $domain; ?></h4>
-<p><?php echo $LANG['AdminList_virtual_alias_alias_count'] . ": " . $list_domains[$selected_domain]['alias_count'] . " / " . $list_domains[$selected_domain]['aliases']; ?></p>
-<p><?php echo $LANG['AdminList_virtual_alias_mailbox_count'] . ": " . $list_domains[$selected_domain]['mailbox_count'] . " / " . $list_domains[$selected_domain]['mailboxes']; ?></p>
+<p><?php echo $LANG['AdminList_virtual_alias_alias_count'] . ": " . $list_domains[$domain_key]['alias_count'] . " / " . $list_domains[$domain_key]['aliases']; ?></p>
+<p><?php echo $LANG['AdminList_virtual_alias_mailbox_count'] . ": " . $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">
@@ -25,18 +25,18 @@ if (count($list_domains) > 0) {
 </div>
 
 <?php 
-if ($list_domains[$selected_domain]['alias_count'] > $limit || $list_domains[$selected_domain]['mailbox_count'] > $limit) {
+if ($list_domains[$domain_key]['alias_count'] > $limit || $list_domains[$domain_key]['mailbox_count'] > $limit) {
 	echo "<div id=\"nav_bar\">\n";
 	if ($offset >= $limit) {
 
-		echo "<a href=\"list-virtual.php?domain=" . $list_domains[$selected_domain]['domain'] . "&offset=" . ($offset - $limit) . "\"><img border=\"0\" src=\"../images/arrow-l.png\" title=\"" . $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>\n";
 	}
-	if (($list_domains[$selected_domain]['alias_count'] > $limit) || ($list_domains[$selected_domain]['mailbox_count'] > $limit)) {
+	if (($list_domains[$domain_key]['alias_count'] > $limit) || ($list_domains[$domain_key]['mailbox_count'] > $limit)) {
 
-		echo "<a href=\"list-virtual.php?domain=" . $list_domains[$selected_domain]['domain'] . "&offset=0\"><img border=\"0\" src=\"../images/arrow-u.png\" title=\"" . $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>\n";
 	}		
-	if ((($offset + $limit) < $list_domains[$selected_domain]['alias_count']) || (($offset + $limit) < $list_domains[$selected_domain]['mailbox_count'])) {
-		echo "<a href=\"list-virtual.php?domain=" . $list_domains[$selected_domain]['domain'] . "&offset=" . ($offset + $limit) . "\"><img border=\"0\" src=\"../images/arrow-r.png\" title=\"" . $LANG['Overview_right_arrow'] . "\"></a>\n";
+	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 "</div>\n";
 }
@@ -57,8 +57,8 @@ if (count($list_alias) > 0) {
 			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[$selected_domain]['domain'] . "\">" . $LANG['edit'] . "</a></td>\n";
-			echo "		<td><a href=\"delete.php?table=alias" . "&delete=" . $row['address'] . "&domain=" . $list_domains[$selected_domain]['domain'] . "\"onclick=\"return confirm ('" . $LANG['confirm'] . $LANG['Overview_get_aliases'] . ": ". $row['address'] . "')\">" . $LANG['del'] . "</a></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 "</table>\n";
@@ -81,8 +81,8 @@ if (count($list_mailbox) > 0) {
 			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[$selected_domain]['domain'] . "\">" . $LANG['edit'] . "</a></td>\n";
-			echo "		<td><a href=\"delete.php?table=mailbox" . "&delete=" . $row['username'] . "&domain=" . $list_domains[$selected_domain]['domain'] . "\"onclick=\"return confirm ('" . $LANG['confirm'] . $LANG['Overview_get_mailboxes'] . ": ". $row['username'] . "')\">" . $LANG['del'] . "</a></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 "</table>\n";
blob - bf573c0b6198fde45f6b4d768ef48a19af98e03b (mode 644)
blob + /dev/null
--- templates/create-alias.tpl
+++ /dev/null
@@ -1,35 +0,0 @@
-<div id="edit_form">
-<form name="create_alias" method="post">
-<table>
-	<tr>
-		<td colspan="3"><h3><?php echo $LANG['Create_alias_welcome']; ?></h3></td>
-	</tr>
-	<tr>
-		<td><?php echo $LANG['Create_alias_address']; ?></td>
-		<td><input class="flat" type="text" name="address" value="<?php echo $address ?? ''; ?>" /></td>
-		<td>
-		<select class="flat" name="domain">
-		<?php
-
-                foreach ($list_domains as $row) {
-                        echo '<option value="' . $row['domain'] . '"';
-			if (isset($domain) && $domain == $row['domain']) echo ' selected';
-                        echo ">" . $row['domain'] . "</option>\n";
-                }
-		?>
-		</select>
-		</td>
-	</tr>
-	<tr>
-		<td><?php echo $LANG['Create_alias_goto'] . ":"; ?></td>
-		<td><input class="flat" type="text" name="goto" value="<?php echo $goto ?? ''; ?>" /></td>
-		<td><?php echo $LANG['Create_alias_goto_text']; ?></td>
-	</tr>
-	<tr>
-		<td colspan="3" class="hlp_center"><input class="button" type="submit" name="submit" value="<?php echo $LANG['Create_alias_button']; ?>" /></td>
-	</tr>
-	<tr>
-		<td colspan="3" class="standout"><?php echo $message ?? '&nbsp;'; ?></td>
-	</tr>
-</table>
-</div>
blob - 2c69af0699947f1f32fbea1b8264b86faad77fb5 (mode 644)
blob + /dev/null
--- templates/create-mailbox.tpl
+++ /dev/null
@@ -1,65 +0,0 @@
-<div id="edit_form">
-<form name="create_mailbox" method="post">
-<table>
-	<tr>
-		<td colspan="3"><h3><?php echo $LANG['Create_mailbox_welcome']; ?></h3></td>
-	</tr>
-	<tr>
-		<td><?php echo $LANG['Create_mailbox_username'] . ":"; ?></td>
-		<td><input class="flat" type="text" name="fUsername" value="<?php echo $tUsername; ?>" /></td>
-		<td>
-		<select name="fDomain">
-		<?php
-		for ($i = 0; $i < count($list_domains); $i++) {
-			if ($tDomain == $list_domains[$i]) {
-				echo "<option value=\"$list_domains[$i]\" selected>$list_domains[$i]</option>\n";
-			} else {
-				echo "<option value=\"$list_domains[$i]\">$list_domains[$i]</option>\n";
-			}
-		}
-		?>
-		</select>
-		<?php echo $pCreate_mailbox_username_text; ?>
-		</td>
-	</tr>
-	<tr>
-		<td><?php echo $LANG['Create_mailbox_password'] . ":"; ?></td>
-		<td><input class="flat" type="password" name="fPassword" /></td>
-		<td><?php echo $pCreate_mailbox_password_text; ?></td>
-	</tr>
-	<tr>
-		<td><?php echo $LANG['Create_mailbox_password2'] . ":"; ?></td>
-		<td><input class="flat" type="password" name="fPassword2" /></td>
-		<td>&nbsp;</td>
-	</tr>
-	<tr>
-		<td><?php echo $LANG['Create_mailbox_name'] . ":"; ?></td>
-		<td><input class="flat" type="text" name="fName" value="<?php echo $tName; ?>" /></td>
-		<td><?php echo $pCreate_mailbox_name_text; ?></td>
-	</tr>
-	<?php if ($CONF['quota'] == 'YES') { ?>
-	<tr>
-		<td><?php echo $LANG['Create_mailbox_quota'] . ":"; ?></td>
-		<td><input type="text" name="fQuota" value="<?php echo $tQuota; ?>" /></td>
-		<td><?php echo $pCreate_mailbox_quota_text; ?></td>
-	<tr>
-	<?php } ?>
-	<tr>
-		<td><?php echo $LANG['Create_mailbox_active'] . ":"; ?></td>
-		<td><input class="flat" type="checkbox" name="fActive" checked /></td>
-		<td>&nbsp;</td>
-	</tr>
-	<tr>
-		<td><?php echo $LANG['Create_mailbox_mail'] . ":"; ?></td>
-		<td><input class="flat" type="checkbox" name="fMail" checked /></td>
-		<td>&nbsp;</td>
-	</tr>
-	<tr>
-		<td colspan="3" class="hlp_center"><input class="button" type="submit" name="submit" value="<?php echo $LANG['Create_mailbox_button']; ?>" /></td>
-	</tr>
-	<tr>
-		<td colspan="3" class="standout"><?php echo $tMessage; ?></td>
-	</tr>
-</table>
-</form>
-</div>
blob - 4c3327ec82ff5a548939c12a8ae157c449e1167c
blob + 839685cf778a722874b7bbf123ce392b6d39a08a
--- templates/list-virtuals.tpl
+++ templates/list-virtuals.tpl
@@ -5,7 +5,7 @@
 if (count($list_domains) > 0) {
 	foreach ($list_domains as $row) {
 		echo '<option value="' . $row['domain'] . '"';
-		if (isset($domain) && $domain == $row['domain']) echo ' selected';
+		if ($list_domains[$domain_key]['domain'] == $row['domain']) echo ' selected';
 		echo ">" . $row['domain'] . "</option>\n";
 	}
 }
@@ -63,22 +63,10 @@ if (count($list_alias) > 0) {
 			echo "		<td>" . $row['address'] . "</td>\n";
 			echo "		<td>" . preg_replace("/,/", "<br>", $row['goto']) . "</td>\n";
 			echo "		<td>" . $row['modified'] . "</td>\n";
-
-			if ($CONF['special_alias_control'] == 'YES') {
-				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?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";
-			} else {
-				if (!in_array($row['goto'], $CONF['default_aliases'])) {
-					echo "		<td><a href=\"edit-alias.php?address=" . $row['address'] . "&domain=" . $row['domain'] . "\">" . $LANG['edit'] . "</a></td>\n";
-					echo "		<td><a href=\"delete.php?delete=" . $row['address'] . "&domain=" . $row['domain'] . "\"onclick=\"return confirm ('" . $LANG['confirm'] . $LANG['Overview_get_aliases'] . ": ". $row['address'] . "')\">" . $LANG['del'] . "</a></td>\n";
-				} else {
-					echo "		<td>&nbsp;</td>\n";
-					echo "		<td>&nbsp;</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?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 "</table>\n";
 }
 
@@ -91,7 +79,6 @@ if (count($list_mailbox) > 0) {
 	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>" . $LANG['Overview_mailbox_active'] . "</td>\n";
 	echo "		<td colspan=\"2\">&nbsp;</td>\n";
 	echo "	</tr>\n";
 
@@ -100,8 +87,8 @@ if (count($list_mailbox) > 0) {
 			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=$fDomain" . "\">" . $LANG['edit'] . "</a></td>\n";
-			echo "		<td><a href=\"delete.php?delete=" . $row['username'] . "&domain=$fDomain" . "\"onclick=\"return confirm ('" . $LANG['confirm'] . $LANG['Overview_get_mailboxes'] . ": ". $row['username'] . "')\">" . $LANG['del'] . "</a></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?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 "</table>\n";
blob - cc43a3aed2ba0a7a4178eea6dd0640ecc95cad3d
blob + 8e65d72f3de8328882c59a88cd2b4bec610cfae0
--- templates/menu.tpl
+++ templates/menu.tpl
@@ -1,8 +1,8 @@
 <div id="menu">
 <ul>
 	<li><a target="_top" href="list-domains.php"><?php echo $LANG['Menu_overview']; ?></a></li>
-	<li><a target="_top" href="create-alias.php<?php if (isset($domain)) echo '?domain=' . $domain; ?>"><?php echo $LANG['Menu_create_alias']; ?></a></li>
-	<li><a target="_top" href="create-mailbox.php<?php if (isset($domain)) echo '?domain=' . $domain; ?>"><?php echo $LANG['Menu_create_mailbox']; ?></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="sendmail.php"><?php echo $LANG['Menu_sendmail']; ?></a></li>
 	<li><a target="_top" href="password.php"><?php echo $LANG['Menu_password']; ?></a></li>
 	<li><a target="_top" href="viewlog.php"><?php echo $LANG['Menu_viewlog']; ?></a></li>
blob - 0350ea99d4c9d0ebc6d6040068b991c085a169b9
blob + 88aaef42e8d1214661425b757f41857cd579a2ab
--- templates/viewlog.tpl
+++ templates/viewlog.tpl
@@ -5,7 +5,7 @@
 if (count($list_domains) > 0) {
 	foreach ($list_domains as $row) {
 		echo '<option value="' . $row['domain'] . '"';
-		if (isset($domain) && $domain == $row['domain']) echo ' selected';
+		if ($list_domains[$domain_key]['domain'] == $row['domain']) echo ' selected';
 		echo ">" . $row['domain'] . "</option>\n";
 	}
 }
blob - ba06d29b9701b5f8d2286786a5b2ce5b38d539b7
blob + 2c848b9cf669e07daec9107c1e2ce6b9185ac821
--- viewlog.php
+++ viewlog.php
@@ -11,58 +11,30 @@
 //
 // Template Variables:
 //
-// tMessage
-// tLog
+// log
 //
 // Form POST \ GET Variables:
 //
-// fDomain
+// domain
 //
-require("./variables.inc.php");
-require("./config.inc.php");
-require("./functions.inc.php");
-include("./languages/" . check_language() . ".lang");
+require_once './functions.inc.php';
+include './languages/' . check_language() . '.lang';
 
 $SESSID_USERNAME = check_session();
-$list_domains = list_domains_for_admin($SESSID_USERNAME);
+$list_domains = list_domains($SESSID_USERNAME);
 
 if ($_SERVER['REQUEST_METHOD'] == "GET") {
-	if ((is_array($list_domains) and count($list_domains) > 0)) $fDomain = $list_domains[0];
-	
-	if (!check_owner($SESSID_USERNAME, $fDomain)) {
-		$error = 1;
-		$tMessage = $LANG['Viewlog_result_error'];
-	}
-
-	if ($error != 1) {
-		$result = db_query("SELECT * FROM log WHERE domain='$fDomain' ORDER BY timestamp DESC LIMIT 10");
-		if ($result['rows'] > 0) {
-			while ($row = db_array($result['result'])) {
-				$tLog[] = $row;
-			}
-		}
-	}
+	$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(); 
 }
 
-if ($_SERVER['REQUEST_METHOD'] == "POST") {
-	$fDomain = escape_string($_POST['fDomain']);
-	
-	if (!check_owner($SESSID_USERNAME, $fDomain)) {
-		$error = 1;
-		$tMessage = $LANG['Viewlog_error'];
-	}
-
-	if ($error != 1) {
-		$result = db_query("SELECT * FROM log WHERE domain='$fDomain' ORDER BY timestamp DESC LIMIT 10");
-		if ($result['rows'] > 0) {
-			while ($row = db_array($result['result'])) {
-				$tLog[] = $row;
-			}
-		}
-	}
-}
-include("./templates/header.tpl");
-include("./templates/menu.tpl");
-include("./templates/viewlog.tpl");
-include("./templates/footer.tpl");
+include './templates/header.tpl';
+include './templates/menu.tpl';
+include './templates/viewlog.tpl';
+include './templates/footer.tpl';
 ?>