handle proxy settings and _baseUrl in settings in getBaseUrl()

This commit is contained in:
Uwe Steinmann 2023-01-26 13:18:40 +01:00
parent 1aca53f63a
commit e87d7546a3

View File

@ -795,7 +795,21 @@ function sendFile($filename) { /* {{{ */
* @return string
*/
function getBaseUrl() { /* {{{ */
return "http".((isset($_SERVER['HTTPS']) && (strcmp($_SERVER['HTTPS'],'off')!=0)) ? "s" : "")."://".$_SERVER['HTTP_HOST'];
global $settings;
if(!empty($settings->_baseUrl))
return $settings->_baseUrl;
if(isset($_SERVER['X-Forwarded-Host']))
$host = $_SERVER['X-Forwarded-Host'];
else
$host = $_SERVER['HTTP_HOST'];
if(isset($_SERVER['X-Forwarded-Proto']))
$ssl = $_SERVER['X-Forwarded-Proto'] == 'https';
else
$ssl = (isset($_SERVER['HTTPS']) && (strcmp($_SERVER['HTTPS'],'off')!=0));
return "http".($ssl ? "s" : "")."://".$host;
} /* }}} */
function getToken($length){ /* {{{ */