new methods getBaseUrl() and getBaseUrlWithRoot()

This commit is contained in:
Uwe Steinmann 2025-10-28 15:41:59 +01:00
parent c32fe1be80
commit d15c65f137

View File

@ -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;
} /* }}} */
} /* }}} */