Use HTTP_HOST instead of SERVER_NAME

* Fixes https://github.com/pi-hole/pi-hole/issues/1479
This commit is contained in:
WaLLy3K 2017-05-18 18:54:26 +10:00 committed by GitHub
parent f9d41caeb6
commit 69fa9874dd
1 changed files with 4 additions and 4 deletions

View File

@ -15,11 +15,11 @@ function validate_server_name($domain) { // Cr: http://stackoverflow.com/a/46948
&& preg_match("/^[^\.]{1,63}(\.[^\.]{1,63})*$/", $domain)); // Length of each label
}
// Validate SERVER_NAME output
if (validate_server_name($_SERVER["SERVER_NAME"]) === TRUE) {
$serverName = $_SERVER["SERVER_NAME"];
// Validate HTTP_HOST output
if (validate_server_name($_SERVER["HTTP_HOST"]) === TRUE) {
$serverName = $_SERVER["HTTP_HOST"];
} else {
die("[ERROR]: <code>SERVER_NAME</code> header output does not appear to be valid: <code>".$_SERVER["SERVER_NAME"]."</code>");
die("[ERROR]: <code>HTTP_HOST</code> header output does not appear to be valid: <code>".$_SERVER["HTTP_HOST"]."</code>");
}
// Get values from setupVars.conf