diff --git a/advanced/index.php b/advanced/index.php
index bfc44a1d..aeb607ca 100644
--- a/advanced/index.php
+++ b/advanced/index.php
@@ -1,224 +1,335 @@
SERVER_NAME header output does not appear to be valid: ".$_SERVER["SERVER_NAME"]."
");
}
-// Retrieve server URI extension (EG: jpg, exe, php)
-ini_set('pcre.recursion_limit',100);
-$uriExt = pathinfo($uri, PATHINFO_EXTENSION);
-
-// Define which URL extensions get rendered as "Website Blocked"
-$webExt = array('asp', 'htm', 'html', 'php', 'rss', 'xml');
-
-// Get IPv4 and IPv6 addresses from setupVars.conf (if available)
+// Get values from setupVars.conf
$setupVars = parse_ini_file("/etc/pihole/setupVars.conf");
-$ipv4 = isset($setupVars["IPV4_ADDRESS"]) ? explode("/", $setupVars["IPV4_ADDRESS"])[0] : $_SERVER['SERVER_ADDR'];
-$ipv6 = isset($setupVars["IPV6_ADDRESS"]) ? explode("/", $setupVars["IPV6_ADDRESS"])[0] : $_SERVER['SERVER_ADDR'];
+$svFQDN = (!empty($setupVars["FQDN"]) && validate_server_name($setupVars["FQDN"]) === TRUE) ? $setupVars["FQDN"] : "";
+$svPasswd = !empty($setupVars["WEBPASSWORD"]);
+$svEmail = (!empty($setupVars["ADMIN_EMAIL"]) && filter_var($setupVars["ADMIN_EMAIL"], FILTER_VALIDATE_EMAIL)) ? $setupVars["ADMIN_EMAIL"] : "";
+unset($setupVars);
-$AUTHORIZED_HOSTNAMES = array(
- $ipv4,
- $ipv6,
- str_replace(array("[","]"), array("",""), $_SERVER["SERVER_ADDR"]),
- "pi.hole",
- "localhost");
-// Allow user set virtual hostnames
-$virtual_host = getenv('VIRTUAL_HOST');
-if (!empty($virtual_host))
- array_push($AUTHORIZED_HOSTNAMES, $virtual_host);
+// Set landing page name, found within /var/www/html/
+$landPage = "landing.php";
-// Immediately quit since we didn't block this page (the IP address or pi.hole is explicitly requested)
-if(validIP($serverName) || in_array($serverName,$AUTHORIZED_HOSTNAMES))
-{
- http_response_code(404);
- die();
+// Set empty 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 (validate_server_name($_SERVER["VIRTUAL_HOST"]) === TRUE) {
+ array_push($authorizedHosts, $_SERVER["VIRTUAL_HOST"]);
+ } else {
+ die("[ERROR]: VIRTUAL_HOST
header output does not appear to be valid: ".$_SERVER["VIRTUAL_HOST"]."
");
+ }
}
-if(in_array($uriExt, $webExt) || empty($uriExt))
-{
- // Requested resource has an extension listed in $webExt
- // or no extension (index access to some folder incl. the root dir)
- $showPage = true;
-}
-else
-{
- // Something else
- $showPage = false;
+// Set which extension types get rendered as "Website Blocked" (Including "" for index file extensions)
+$validExtTypes = array("asp", "htm", "html", "php", "rss", "xml", "");
+
+// Get extension of current URL
+$currentUrlExt = pathinfo($_SERVER["REQUEST_URI"], PATHINFO_EXTENSION);
+
+// Set mobile friendly viewport
+$viewPort = '';
+
+// Set response header
+function setHeader($type = "x") {
+ header("X-Pi-hole: A black hole for Internet advertisements.");
+ if (isset($type) && $type === "js") header("Content-Type: application/javascript");
}
-// Handle incoming URI types
-if (!$showPage)
-{
-?>
-
-