From 6a1e7cc539b7d0d1a2ff8387bcc22c3429ee4d34 Mon Sep 17 00:00:00 2001 From: Michael Kaufmann Date: Sun, 26 Nov 2023 15:19:49 +0100 Subject: [PATCH] actually create notice file for 'unconfigured/unmanaged domain' and redirect it for potential dynamic contents (e.g. file extension php) to work properly Signed-off-by: Michael Kaufmann --- lib/Froxlor/FileDir.php | 7 ++++++- lib/init.php | 4 ++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/lib/Froxlor/FileDir.php b/lib/Froxlor/FileDir.php index a43e81b0f5..acb8fb9a58 100644 --- a/lib/Froxlor/FileDir.php +++ b/lib/Froxlor/FileDir.php @@ -263,6 +263,7 @@ public static function safe_exec(string $exec_string, &$return_value = false, $a * @param string $servername * * @return string + * @throws Exception */ public static function getUnknownDomainTemplate(string $servername = "") { @@ -276,7 +277,9 @@ public static function getUnknownDomainTemplate(string $servername = "") 'SERVERNAME' => $servername, ]; $tpl_content = PhpHelper::replaceVariables($template['value'], $replace_arr); + $tpl_ext = $template['file_extension']; } else { + $tpl_ext = 'html'; $unconfiguredPath = FileDir::makeCorrectFile(Froxlor::getInstallDir() . '/templates/misc/unconfigured/index.html'); if (file_exists($unconfiguredPath)) { $tpl_content = file_get_contents($unconfiguredPath); @@ -284,7 +287,9 @@ public static function getUnknownDomainTemplate(string $servername = "") $tpl_content = lng('admin.templates.unconfigured_content_fallback'); } } - return $tpl_content; + $redirect_file = FileDir::makeCorrectFile(Froxlor::getInstallDir().'/notice.'.$tpl_ext); + file_put_contents($redirect_file, $tpl_content); + return basename($redirect_file); } /** diff --git a/lib/init.php b/lib/init.php index ade9b50125..75591c8115 100644 --- a/lib/init.php +++ b/lib/init.php @@ -121,8 +121,8 @@ (!empty(Settings::Get('system.froxloraliases')) && !in_array($_SERVER['SERVER_NAME'], array_map('trim', explode(',', Settings::Get('system.froxloraliases'))))) )) { // not the froxlor system-hostname, show info page for domains not configured in froxlor - $output = FileDir::getUnknownDomainTemplate($_SERVER['SERVER_NAME']); - echo $output; + $redirect_file = FileDir::getUnknownDomainTemplate($_SERVER['SERVER_NAME']); + header('Location: '.$redirect_file); die(); }