summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorvlakoff <vlakoff@gmail.com>2014-03-31 20:41:07 +0200
committervlakoff <vlakoff@gmail.com>2014-03-31 20:41:07 +0200
commitdfd51cb0379936a5cc90b980ddf46b170f3b365b (patch)
tree5b978861c6a53200dc1dcb1ec5b6c7be20ed670f
parenta8b0efb5012618dcfa54a88a417929f7d1f2be15 (diff)
Refactoring in Config->__construct()
Put the $_SERVER['HTTP_HOST'] fallback in a more logical place.
-rw-r--r--system/core/Config.php13
1 files changed, 3 insertions, 10 deletions
diff --git a/system/core/Config.php b/system/core/Config.php
index f630d1709..56259bd06 100644
--- a/system/core/Config.php
+++ b/system/core/Config.php
@@ -76,16 +76,9 @@ class CI_Config {
// Set the base_url automatically if none was provided
if (empty($this->config['base_url']))
{
- if (isset($_SERVER['HTTP_HOST']))
- {
- $base_url = is_https() ? 'https' : 'http';
- $base_url .= '://'.$_SERVER['HTTP_HOST']
- .str_replace(basename($_SERVER['SCRIPT_NAME']), '', $_SERVER['SCRIPT_NAME']);
- }
- else
- {
- $base_url = 'http://localhost/';
- }
+ $base_url = (is_https() ? 'https' : 'http') . '://'
+ . (isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : 'localhost')
+ . str_replace(basename($_SERVER['SCRIPT_NAME']), '', $_SERVER['SCRIPT_NAME']);
$this->set_item('base_url', $base_url);
}