summaryrefslogtreecommitdiffstats
path: root/system/core
diff options
context:
space:
mode:
authorPhil Sturgeon <email@philsturgeon.co.uk>2010-12-27 20:06:28 +0100
committerPhil Sturgeon <email@philsturgeon.co.uk>2010-12-27 20:06:28 +0100
commitc8089154217307a56b60ae8f0cb85087a1531b27 (patch)
tree18ea049c55438a80d9b3465863ff699063a12304 /system/core
parent2280e8ea67f94e67f2c803e804fb1b8125b579b0 (diff)
parent5cbe4dd1f0d94791fe86e08111b77c1d57b83f54 (diff)
Implemented GET string support from Dan Horrigan and modified it slightly. Also tweaked his regex_match changes.
Diffstat (limited to 'system/core')
-rw-r--r--system/core/Config.php45
-rw-r--r--system/core/Input.php19
-rw-r--r--system/core/Lang.php18
-rw-r--r--system/core/Loader.php26
-rw-r--r--system/core/Router.php14
-rw-r--r--system/core/URI.php18
6 files changed, 75 insertions, 65 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;
}
}
diff --git a/system/core/Input.php b/system/core/Input.php
index 4ddc402ee..eb2048e58 100644
--- a/system/core/Input.php
+++ b/system/core/Input.php
@@ -49,9 +49,9 @@ class CI_Input {
{
log_message('debug', "Input Class Initialized");
- $this->_allow_get_array = (config_item('allow_get_array') === TRUE) ? TRUE : FALSE;
- $this->_enable_xss = (config_item('global_xss_filtering') === TRUE) ? TRUE : FALSE;
- $this->_enable_csrf = (config_item('csrf_protection') === TRUE) ? TRUE : FALSE;
+ $this->_allow_get_array = (config_item('allow_get_array') === TRUE);
+ $this->_enable_xss = (config_item('global_xss_filtering') === TRUE);
+ $this->_enable_csrf = (config_item('csrf_protection') === TRUE);
// Do we need to load the security class?
if ($this->_enable_xss == TRUE OR $this->_enable_csrf == TRUE)
@@ -216,14 +216,7 @@ class CI_Input {
}
else
{
- if ($expire > 0)
- {
- $expire = time() + $expire;
- }
- else
- {
- $expire = 0;
- }
+ $expire = ($expire > 0) ? time() + $expire : 0;
}
setcookie($prefix.$name, $value, $expire, $path, $domain, 0);
@@ -492,7 +485,7 @@ class CI_Input {
}
// We strip slashes if magic quotes is on to keep things consistent
- if (get_magic_quotes_gpc())
+ if (function_exists('get_magic_quotes_gpc') AND get_magic_quotes_gpc())
{
$str = stripslashes($str);
}
@@ -514,7 +507,7 @@ class CI_Input {
{
if (strpos($str, "\r") !== FALSE)
{
- $str = str_replace(array("\r\n", "\r"), "\n", $str);
+ $str = str_replace(array("\r\n", "\r"), PHP_EOL, $str);
}
}
diff --git a/system/core/Lang.php b/system/core/Lang.php
index e7867b354..8ec179771 100644
--- a/system/core/Lang.php
+++ b/system/core/Lang.php
@@ -78,17 +78,21 @@ class CI_Lang {
{
include($alt_path.'language/'.$idiom.'/'.$langfile);
}
- elseif (file_exists(APPPATH.'language/'.$idiom.'/'.$langfile))
- {
- include(APPPATH.'language/'.$idiom.'/'.$langfile);
- }
else
{
- if (file_exists(BASEPATH.'language/'.$idiom.'/'.$langfile))
+ $found = FALSE;
+
+ foreach (get_instance()->load->get_package_paths(TRUE) as $package_path)
{
- include(BASEPATH.'language/'.$idiom.'/'.$langfile);
+ if (file_exists($package_path.'language/'.$idiom.'/'.$langfile))
+ {
+ include($package_path.'language/'.$idiom.'/'.$langfile);
+ $found = TRUE;
+ break;
+ }
}
- else
+
+ if ($found !== TRUE)
{
show_error('Unable to load the requested language file: language/'.$idiom.'/'.$langfile);
}
diff --git a/system/core/Loader.php b/system/core/Loader.php
index 4b6b19eea..136cae9bf 100644
--- a/system/core/Loader.php
+++ b/system/core/Loader.php
@@ -81,12 +81,12 @@ class CI_Loader {
{
foreach($library as $read)
{
- $this->library($read);
+ $this->library($read);
}
-
+
return;
}
-
+
if ($library == '' OR isset($this->_base_classes[$library]))
{
return FALSE;
@@ -527,7 +527,7 @@ class CI_Loader {
function add_package_path($path)
{
$path = rtrim($path, '/').'/';
-
+
array_unshift($this->_ci_library_paths, $path);
array_unshift($this->_ci_model_paths, $path);
array_unshift($this->_ci_helper_paths, $path);
@@ -540,6 +540,22 @@ class CI_Loader {
// --------------------------------------------------------------------
/**
+ * Get Package Paths
+ *
+ * Return a list of all package paths, by default it will ignore BASEPATH.
+ *
+ * @access public
+ * @param string
+ * @return void
+ */
+ function get_package_paths($include_base = FALSE)
+ {
+ return $include_base === TRUE ? $this->_ci_library_paths : $this->_ci_model_paths;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
* Remove Package Path
*
* Remove a path from the library, model, and helper path arrays if it exists
@@ -563,7 +579,7 @@ class CI_Loader {
else
{
$path = rtrim($path, '/').'/';
-
+
foreach (array('_ci_library_paths', '_ci_model_paths', '_ci_helper_paths') as $var)
{
if (($key = array_search($path, $this->{$var})) !== FALSE)
diff --git a/system/core/Router.php b/system/core/Router.php
index 9276800c3..79a8b4fcc 100644
--- a/system/core/Router.php
+++ b/system/core/Router.php
@@ -270,19 +270,17 @@ class CI_Router {
// If we've gotten this far it means that the URI does not correlate to a valid
// controller class. We will now see if there is an override
- if (isset($this->routes['404_override']) AND $this->routes['404_override'] != '')
+ if (!empty($this->routes['404_override']))
{
- if (strpos($this->routes['404_override'], '/') !== FALSE)
- {
- $x = explode('/', $this->routes['404_override']);
+ $x = explode('/', $this->routes['404_override']);
- $this->set_class($x[0]);
- $this->set_method($x[1]);
+ $this->set_class($x[0]);
+ $this->set_method(isset($x[1]) ? $x[1] : 'index');
- return $x;
- }
+ return $x;
}
+
// Nothing else to do at this point but show a 404
show_404($segments[0]);
}
diff --git a/system/core/URI.php b/system/core/URI.php
index f6487d3f9..047e3c9bc 100644
--- a/system/core/URI.php
+++ b/system/core/URI.php
@@ -133,23 +133,25 @@ class CI_URI {
if (isset($_SERVER['REQUEST_URI']))
{
$uri = $_SERVER['REQUEST_URI'];
- if (strpos($uri, $_SERVER['HTTP_HOST']) !== FALSE)
+ if (strpos($uri, $_SERVER['SERVER_NAME']) !== FALSE)
{
- $uri = preg_replace('/^\w+:\/\/[^\/]+/','',$uri);
+ $uri = preg_replace('/^\w+:\/\/[^\/]+/', '', $uri);
}
}
+
// Now lets check for IIS
elseif (isset($_SERVER['HTTP_X_REWRITE_URL']))
{
$uri = $_SERVER['HTTP_X_REWRITE_URL'];
}
+
// Last ditch effort (for older CGI servers, like IIS 5)
elseif (isset($_SERVER['ORIG_PATH_INFO']))
{
$uri = $_SERVER['ORIG_PATH_INFO'];
if ( ! empty($_SERVER['QUERY_STRING']))
{
- $uri .= '?'.$_SERVER['QUERY_STRING'];
+ $uri .= '?' . $_SERVER['QUERY_STRING'];
}
}
@@ -173,8 +175,8 @@ class CI_URI {
{
// Some server's require URL's like index.php?/whatever If that is the case,
// then we need to add that to our parsing.
- $fc_path = ltrim(FCPATH.SELF, '/');
- if (strpos($uri, SELF.'?') !== FALSE)
+ $fc_path = ltrim(FCPATH . SELF, '/');
+ if (strpos($uri, SELF . '?') !== FALSE)
{
$fc_path .= '?';
}
@@ -182,7 +184,7 @@ class CI_URI {
$parsed_uri = explode('/', ltrim($uri, '/'));
$i = 0;
- foreach(explode("/", $fc_path) as $segment)
+ foreach (explode("/", $fc_path) as $segment)
{
if (isset($parsed_uri[$i]) && $segment == $parsed_uri[$i])
{
@@ -203,7 +205,7 @@ class CI_URI {
}
// If it is just a / or index.php then just empty it.
- if ($uri == '/' || $uri == SELF)
+ if ($uri == '/' OR $uri == SELF)
{
$uri = '';
}
@@ -266,7 +268,7 @@ class CI_URI {
*/
function _explode_segments()
{
- foreach(explode("/", preg_replace("|/*(.+?)/*$|", "\\1", $this->uri_string)) as $val)
+ foreach (explode("/", preg_replace("|/*(.+?)/*$|", "\\1", $this->uri_string)) as $val)
{
// Filter segments for security
$val = trim($this->_filter_uri($val));