diff --git a/lib/init-tiny.php b/lib/init-tiny.php index 7217e769..31011cfa 100644 --- a/lib/init-tiny.php +++ b/lib/init-tiny.php @@ -47,16 +47,23 @@ Config::set('prefix', $prefix); // Register the autoloader spl_autoload_register(array('Core', 'autoload'), true, true); -/* - Check to see if this is http or https -*/ +// Check to see if this is http or https if ((isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https' ) - || (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') - || Config::get('force_ssl')) { - $http_type = "https://"; + || (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on')) { + $http_type = 'https://'; } else { - $http_type = "http://"; + $http_type = 'http://'; +} + +if (isset($_SERVER['HTTP_X_FORWARDED_PORT'])) { + $http_port = $_SERVER['HTTP_X_FORWARDED_PORT']; +} +else if (isset($_SERVER['SERVER_PORT'])) { + $http_port = $_SERVER['SERVER_PORT']; +} +if (!isset($http_port) || !$http_port) { + $http_port = 80; } // Define that we've loaded the INIT file diff --git a/lib/init.php b/lib/init.php index 9f6a5730..1cfacb8f 100644 --- a/lib/init.php +++ b/lib/init.php @@ -73,25 +73,17 @@ if ($link) { $results['version'] = '3.6-Alpha1-DEV'; $results['int_config_version'] = '11'; -$results['raw_web_path'] = $results['web_path']; -$results['web_path'] = $http_type . $_SERVER['HTTP_HOST'] . $results['web_path']; -if (isset($_SERVER['HTTP_X_FORWARDED_PORT'])) { - $results['http_port'] = $_SERVER['HTTP_X_FORWARDED_PORT']; -} else { - $results['http_port'] = $_SERVER['SERVER_PORT']; -} -if (!$results['http_port']) { - $results['http_port'] = '80'; -} -if (!$results['site_charset']) { - $results['site_charset'] = "UTF-8"; -} -if (!$results['raw_web_path']) { - $results['raw_web_path'] = '/'; -} -if (!$_SERVER['SERVER_NAME']) { - $_SERVER['SERVER_NAME'] = ''; +if ($results['force_ssl']) { + $http_type = 'https://'; } + +$results['raw_web_path'] = $results['web_path']; +$results['web_path'] = $http_type . $_SERVER['HTTP_HOST'] . $results['web_path']; +$results['http_port'] = $results['http_port'] ?: $http_port; +$results['site_charset'] = $results['site_charset'] ?: 'UTF-8'; +$results['raw_web_path'] = $results['raw_web_path'] ?: '/'; +$_SERVER['SERVER_NAME'] = $_SERVER['SERVER_NAME'] ?: ''; + if (isset($results['user_ip_cardinality']) && !$results['user_ip_cardinality']) { $results['user_ip_cardinality'] = 42; }