diff options
author | Phil Sturgeon <email@philsturgeon.co.uk> | 2010-12-27 20:06:28 +0100 |
---|---|---|
committer | Phil Sturgeon <email@philsturgeon.co.uk> | 2010-12-27 20:06:28 +0100 |
commit | c8089154217307a56b60ae8f0cb85087a1531b27 (patch) | |
tree | 18ea049c55438a80d9b3465863ff699063a12304 /system/core/Config.php | |
parent | 2280e8ea67f94e67f2c803e804fb1b8125b579b0 (diff) | |
parent | 5cbe4dd1f0d94791fe86e08111b77c1d57b83f54 (diff) |
Implemented GET string support from Dan Horrigan and modified it slightly. Also tweaked his regex_match changes.
Diffstat (limited to 'system/core/Config.php')
-rw-r--r-- | system/core/Config.php | 45 |
1 files changed, 21 insertions, 24 deletions
diff --git a/system/core/Config.php b/system/core/Config.php index bdd1b8333..8ecfba73a 100644 --- a/system/core/Config.php +++ b/system/core/Config.php @@ -47,6 +47,24 @@ class CI_Config { { $this->config =& get_config(); log_message('debug', "Config Class Initialized"); + + // Set the base_url automatically if none was provided + if ($this->config['base_url'] == '') + { + if(isset($_SERVER['HTTP_HOST'])) + { + $base_url = isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) !== 'off' ? 'https' : 'http'; + $base_url .= '://'. $_SERVER['HTTP_HOST']; + $base_url .= str_replace(basename($_SERVER['SCRIPT_NAME']), '', $_SERVER['SCRIPT_NAME']); + } + + else + { + $base_url = 'http://localhost/'; + } + + $this->set_item('base_url', $base_url); + } } // -------------------------------------------------------------------- @@ -185,14 +203,7 @@ class CI_Config { return FALSE; } - $pref = $this->config[$item]; - - if ($pref != '' && substr($pref, -1) != '/') - { - $pref .= '/'; - } - - return $pref; + return rtrim($this->config[$item], '/').'/'; } // -------------------------------------------------------------------- @@ -208,14 +219,7 @@ class CI_Config { { if ($uri == '') { - if ($this->item('base_url') == '') - { - return $this->item('index_page'); - } - else - { - return $this->slash_item('base_url').$this->item('index_page'); - } + return $this->slash_item('base_url').$this->item('index_page'); } if ($this->item('enable_query_strings') == FALSE) @@ -244,14 +248,7 @@ class CI_Config { $uri = $str; } - if ($this->item('base_url') == '') - { - return $this->item('index_page').'?'.$uri; - } - else - { - return $this->slash_item('base_url').$this->item('index_page').'?'.$uri; - } + return $this->slash_item('base_url').$this->item('index_page').'?'.$uri; } } |