Autocomplete whitelisted domains and handle errors on config file

This commit is contained in:
Romain de Laage 2022-04-28 14:22:39 +02:00
parent 90215a488f
commit 1d4fc255f5
Signed by: rdelaage
GPG Key ID: 534845FADDF0C329
1 changed files with 11 additions and 2 deletions

View File

@ -114,8 +114,19 @@ else {
die("Unknown config type: ".CONFIG_TYPE."\n");
}
if(defined('WHITELIST_DOMAINS_PATH'))
{
$whitelist_domains_file_content = file_get_contents(WHITELIST_DOMAINS_PATH);
if($whitelist_domains_file_content===false)
die("Unable to open file ".WHITELIST_DOMAINS_PATH."\n");
$whitelist_domains = explode("\n", $whitelist_domains_file_content);
}
foreach($conf->capsules as $hostname => $capsule)
{
$whitelist_domains[] = $hostname;
if(empty($conf->capsules->$hostname->redirect))
{
$conf->capsules->$hostname->folder = str_replace("{here}",dirname($conf_filename),$capsule->folder);
@ -131,8 +142,6 @@ if(strpos($_SERVER['HTTP_HOST'],':')!==false)
else
$capsule = strtolower($_SERVER['HTTP_HOST']);
$whitelist_domains = explode("\n", file_get_contents(WHITELIST_DOMAINS_PATH));
$response = false;
$response_code = 0;
$body = false;