summaryrefslogtreecommitdiffstats
path: root/system/core/Config.php
diff options
context:
space:
mode:
authorPhil Sturgeon <email@philsturgeon.co.uk>2010-12-15 15:23:14 +0100
committerPhil Sturgeon <email@philsturgeon.co.uk>2010-12-15 15:23:14 +0100
commit4df8b2276bbcc7f025a41b0d09f2f8cd7927b51a (patch)
tree8c6e9701414a7ec384f0ef287057a77266c7a677 /system/core/Config.php
parentfd6948997faf5f064f76353da65bd1d0ec65ec51 (diff)
<kbd>['base_url']</kbd> is now empty by default and will guess what it should be.
Diffstat (limited to 'system/core/Config.php')
-rw-r--r--system/core/Config.php46
1 files changed, 22 insertions, 24 deletions
diff --git a/system/core/Config.php b/system/core/Config.php
index bdd1b8333..506af0d99 100644
--- a/system/core/Config.php
+++ b/system/core/Config.php
@@ -47,6 +47,25 @@ 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'] == '')
+ {
+ // Base URL (keeps this crazy sh*t out of the config.php
+ if(isset($_SERVER['HTTP_HOST']))
+ {
+ $base_url = isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) == 'on' ? '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 +204,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 +220,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 +249,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;
}
}