From d15c65f137457903a523f74d0d8e298077c65be6 Mon Sep 17 00:00:00 2001 From: Uwe Steinmann Date: Tue, 28 Oct 2025 15:41:59 +0100 Subject: [PATCH] new methods getBaseUrl() and getBaseUrlWithRoot() --- inc/inc.ClassSettings.php | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/inc/inc.ClassSettings.php b/inc/inc.ClassSettings.php index a01c29d3c..fd09569f9 100644 --- a/inc/inc.ClassSettings.php +++ b/inc/inc.ClassSettings.php @@ -1839,5 +1839,37 @@ class Settings { /* {{{ */ return min($mus); } /* }}} */ + /** + * Get base url + * + * @return string + */ + public function getBaseUrl() { /* {{{ */ + global $_SERVER; + + if(!empty($this->_baseUrl)) + return $this->_baseUrl; + + if(isset($_SERVER['HTTP_X_FORWARDED_HOST'])) + $host = $_SERVER['HTTP_X_FORWARDED_HOST']; + else + $host = $_SERVER['HTTP_HOST']; + if(isset($_SERVER['HTTP_X_FORWARDED_PROTO'])) + $ssl = $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https'; + else + $ssl = (isset($_SERVER['HTTPS']) && (strcmp($_SERVER['HTTPS'],'off')!=0)); + + return "http".($ssl ? "s" : "")."://".$host; + } /* }}} */ + + /** + * Get base url with http root folder + * + * @return string + */ + public function getBaseUrlWithRoot() { /* {{{ */ + return $this->getBaseUrl().$this->_httpRoot; + } /* }}} */ + } /* }}} */