diff --git a/advanced/index.php b/advanced/index.php
index 911f3cc8..0111c95f 100644
--- a/advanced/index.php
+++ b/advanced/index.php
@@ -9,32 +9,30 @@
// Sanitise HTTP_HOST output
$serverName = htmlspecialchars($_SERVER["HTTP_HOST"]);
+if (!is_file("/etc/pihole/setupVars.conf"))
+ die("[ERROR] File not found: /etc/pihole/setupVars.conf
");
+
// Get values from setupVars.conf
-if (is_file("/etc/pihole/setupVars.conf")) {
- $setupVars = parse_ini_file("/etc/pihole/setupVars.conf");
- $svFQDN = $setupVars["FQDN"];
- $svPasswd = !empty($setupVars["WEBPASSWORD"]);
- $svEmail = (!empty($setupVars["ADMIN_EMAIL"]) && filter_var($setupVars["ADMIN_EMAIL"], FILTER_VALIDATE_EMAIL)) ? $setupVars["ADMIN_EMAIL"] : "";
- unset($setupVars);
-} else {
- die("[ERROR] File not found: /etc/pihole/setupVars.conf
");
-}
+$setupVars = parse_ini_file("/etc/pihole/setupVars.conf");
+$svPasswd = !empty($setupVars["WEBPASSWORD"]);
+$svEmail = (!empty($setupVars["ADMIN_EMAIL"]) && filter_var($setupVars["ADMIN_EMAIL"], FILTER_VALIDATE_EMAIL)) ? $setupVars["ADMIN_EMAIL"] : "";
+unset($setupVars);
// Set landing page location, found within /var/www/html/
$landPage = "../landing.php";
-// Set empty array for hostnames to be accepted as self address for splash page
+// Define array for hostnames to be accepted as self address for splash page
$authorizedHosts = [];
-
-// Append FQDN to $authorizedHosts
-if (!empty($svFQDN)) array_push($authorizedHosts, $svFQDN);
-
-// Append virtual hostname to $authorizedHosts
-if (!empty($_SERVER["VIRTUAL_HOST"])) {
+if (!empty($_SERVER["FQDN"])) {
+ // If setenv.add-environment = ("fqdn" => "true") is configured in lighttpd,
+ // append $serverName to $authorizedHosts
+ array_push($authorizedHosts, $serverName);
+} else if (!empty($_SERVER["VIRTUAL_HOST"])) {
+ // Append virtual hostname to $authorizedHosts
array_push($authorizedHosts, $_SERVER["VIRTUAL_HOST"]);
}
-// Set which extension types render as Block Page (Including "" for index.wxyz)
+// Set which extension types render as Block Page (Including "" for index.ext)
$validExtTypes = array("asp", "htm", "html", "php", "rss", "xml", "");
// Get extension of current URL
@@ -49,8 +47,9 @@ function setHeader($type = "x") {
if (isset($type) && $type === "js") header("Content-Type: application/javascript");
}
-// Determine block page redirect type
+// Determine block page type
if ($serverName === "pi.hole") {
+ // Redirect to Web Interface
exit(header("Location: /admin"));
} elseif (filter_var($serverName, FILTER_VALIDATE_IP) || in_array($serverName, $authorizedHosts)) {
// Set Splash Page output
@@ -60,22 +59,29 @@ if ($serverName === "pi.hole") {