summaryrefslogtreecommitdiffstats
path: root/system/core/Config.php
diff options
context:
space:
mode:
authorPhil Sturgeon <email@philsturgeon.co.uk>2010-12-27 18:41:33 +0100
committerPhil Sturgeon <email@philsturgeon.co.uk>2010-12-27 18:41:33 +0100
commit5cbe4dd1f0d94791fe86e08111b77c1d57b83f54 (patch)
tree54cfcbe82e0632bf9d438c288f00ccf817d8f3d3 /system/core/Config.php
parentbde25d971bfbf4a54f1d40eedfd3290ebb5f91e5 (diff)
parentde3dbc36dab42d86c66d76efd6fdb1d1dce71ce8 (diff)
Automated merge with http://hg.ellislab.com/CodeIgniter-Reactor
Diffstat (limited to 'system/core/Config.php')
-rw-r--r--system/core/Config.php45
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;
}
}