Skip to content

Commit

Permalink
Fix working with port in setup
Browse files Browse the repository at this point in the history
  • Loading branch information
dimasites committed Feb 23, 2024
1 parent cb7ca0b commit d24ca1a
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions setup/includes/config/modconfigreader.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,10 @@ public function getHttpHost() {
if (php_sapi_name() != 'cli') {
$this->config['https_port'] = isset($_POST['httpsport']) ? $_POST['httpsport'] : 443;
$isSecureRequest = ((isset($_SERVER['HTTPS']) && !empty($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) !== 'off') || $_SERVER['SERVER_PORT'] == $this->config['https_port']);
$this->config['http_host'] = $_SERVER['HTTP_HOST'];
if ($_SERVER['SERVER_PORT'] != 80) {
$this->config['http_host'] = str_replace(':' . $_SERVER['SERVER_PORT'], '', $this->config['http_host']);
}
$this->config['http_host'] .= in_array($_SERVER['SERVER_PORT'], [80, 443]) ? '' : ':' . $_SERVER['SERVER_PORT'];
$url_scheme = $isSecureRequest ? 'https://' : 'http://';
$this->config['http_host'] = parse_url($url_scheme . $_SERVER['HTTP_HOST'], PHP_URL_HOST);
$this->config['http_port'] = parse_url($url_scheme . $_SERVER['PHP_URL_PORT'], PHP_URL_HOST) ?: $_SERVER['SERVER_PORT'];
$this->config['http_host'] .= in_array($this->config['http_port'], [80, 443]) ? '' : ':' . $this->config['http_port'];
} else {
$this->config['http_host'] = 'localhost';
$this->config['https_port'] = 443;
Expand Down

0 comments on commit d24ca1a

Please sign in to comment.