Index: startup.php =================================================================== --- startup.php (revision 14184) +++ startup.php (working copy) @@ -52,26 +52,32 @@ safeDefine('BASE_PATH', $ps); // in case in-portal has defined it before # New path detection method: end - if ( array_key_exists('HTTP_HOST', $_SERVER) ) { + $https_mark = getArrayValue($_SERVER, 'HTTPS'); + safeDefine('PROTOCOL', ($https_mark == 'on') || ($https_mark == '1') ? 'https://' : 'http://'); + + if ( isset($_SERVER['HTTP_HOST']) ) { // accessed from browser - define('SERVER_NAME', $_SERVER['HTTP_HOST']); + $http_host = $_SERVER['HTTP_HOST']; } else { // accessed from command line - define('SERVER_NAME', $vars['Domain']); + $http_host = $vars['Domain']; $_SERVER['HTTP_HOST'] = $vars['Domain']; } - $https_mark = getArrayValue($_SERVER, 'HTTPS'); - safeDefine('PROTOCOL', ($https_mark == 'on') || ($https_mark == '1') ? 'https://' : 'http://'); + $port = isset($_SERVER['SERVER_PORT']) ? $_SERVER['SERVER_PORT'] : false; - $port = array_key_exists('HTTP_PORT', $_SERVER) ? $_SERVER['HTTP_PORT'] : false; + if ($port) { + if ( (PROTOCOL == 'http://' && $port != '80') || (PROTOCOL == 'https://' && $port != '443') ) { + // if non-standard port is used, then define it + define('PORT', $port); + } - if ($port && ((PROTOCOL == 'http://' && $port != '80') || (PROTOCOL == 'https://' && $port != '443'))) { - // if non-standard port is used, then define it - define('PORT', $_SERVER['HTTP_PORT']); + $http_host = preg_replace('/:' . $port . '$/', '', $http_host); } + define('SERVER_NAME', $http_host); + safeDefine('APPLICATION_CLASS', isset($vars['ApplicationClass']) ? $vars['ApplicationClass'] : 'kApplication'); safeDefine('APPLICATION_PATH', isset($vars['ApplicationPath']) ? $vars['ApplicationPath'] : '/core/kernel/application.php');