Skip to content

Commit

Permalink
Fix ports in default config template
Browse files Browse the repository at this point in the history
  • Loading branch information
dimasites committed Mar 18, 2024
1 parent fe27614 commit c358fb5
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions core/docs/config.inc.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -49,22 +49,20 @@ if (!defined('MODX_BASE_PATH')) {
if(defined('PHP_SAPI') && (PHP_SAPI == "cli" || PHP_SAPI == "embed")) {
$isSecureRequest = false;
} else {
$isSecureRequest = ((isset($_SERVER['HTTPS']) && !empty($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) !== 'off') || $_SERVER['SERVER_PORT'] == $https_port);
$isSecureRequest = ((isset($_SERVER['HTTPS']) && !empty($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) !== 'off') || parse_url('http://' . $_SERVER['HTTP_HOST'], PHP_URL_PORT) == $https_port);
}
if (!defined('MODX_URL_SCHEME')) {
$url_scheme= $isSecureRequest ? 'https://' : 'http://';
$url_scheme = $isSecureRequest ? 'https://' : 'http://';
define('MODX_URL_SCHEME', $url_scheme);
}
if (!defined('MODX_HTTP_HOST')) {
if(defined('PHP_SAPI') && (PHP_SAPI == "cli" || PHP_SAPI == "embed")) {
$http_host = '{http_host}';
define('MODX_HTTP_HOST', $http_host);
} else {
$http_host= array_key_exists('HTTP_HOST', $_SERVER) ? htmlspecialchars($_SERVER['HTTP_HOST'], ENT_QUOTES) : '{http_host}';
if ($_SERVER['SERVER_PORT'] !== 80) {
$http_host = str_replace(':' . $_SERVER['SERVER_PORT'], '', $http_host);
}
$http_host .= in_array($_SERVER['SERVER_PORT'], [80, 443]) ? '' : ':' . $_SERVER['SERVER_PORT'];
$http_host = array_key_exists('HTTP_HOST', $_SERVER) ? parse_url($url_scheme . $_SERVER['HTTP_HOST'], PHP_URL_HOST) : '{http_host}';
$http_port = parse_url($url_scheme . $_SERVER['HTTP_HOST'], PHP_URL_PORT);
$http_host .= in_array($http_port, [null, 80, 443]) ? '' : ':' . $http_port;
define('MODX_HTTP_HOST', $http_host);
}
}
Expand Down

0 comments on commit c358fb5

Please sign in to comment.