From afe6b68c875a0734207a90720f43625bca76def9 Mon Sep 17 00:00:00 2001 From: Dima Kasatkin Date: Mon, 18 Mar 2024 05:17:55 +0300 Subject: [PATCH] Fix iports n setup wizard --- setup/index.php | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/setup/index.php b/setup/index.php index c76e3b81a96..05030317c86 100644 --- a/setup/index.php +++ b/setup/index.php @@ -62,12 +62,11 @@ } if (!$isCommandLine) { $https = isset($_SERVER['HTTPS']) ? $_SERVER['HTTPS'] : false; - $installBaseUrl = (!$https || strtolower($https) != 'on') ? 'http://' : 'https://'; - $installBaseUrl .= $_SERVER['HTTP_HOST']; - if (isset($_SERVER['SERVER_PORT']) && (string)$_SERVER['SERVER_PORT'] !== '' && $_SERVER['SERVER_PORT'] !== 80) { - $installBaseUrl = str_replace(':' . $_SERVER['SERVER_PORT'], '', $installBaseUrl); - } - $installBaseUrl .= in_array($_SERVER['SERVER_PORT'], [80, 443]) ? '' : ':' . $_SERVER['SERVER_PORT']; + $url_scheme = (!$https || strtolower($https) != 'on') ? 'http://' : 'https://'; + $installBaseUrl = $url_scheme; + $installBaseUrl .= parse_url($url_scheme . $_SERVER['HTTP_HOST'], PHP_URL_HOST); + $url_port = parse_url($url_scheme . $_SERVER['HTTP_HOST'], PHP_URL_PORT); + $installBaseUrl .= in_array($url_port, [null , 80, 443]) ? '' : ':' . $url_port; $installBaseUrl .= $_SERVER['SCRIPT_NAME']; $installBaseUrl = htmlspecialchars($installBaseUrl, ENT_QUOTES, 'utf-8'); define('MODX_SETUP_URL', $installBaseUrl);