load config files from environment specific locations in core classes, helpers and libraries
diff --git a/system/core/Hooks.php b/system/core/Hooks.php
index 75fd811..e4f8cfa 100644
--- a/system/core/Hooks.php
+++ b/system/core/Hooks.php
@@ -65,7 +65,15 @@
// Grab the "hooks" definition file.
// If there are no hooks, we're done.
- @include(APPPATH.'config/hooks'.EXT);
+ if (file_exists(APPPATH.'config/'.ENVIRONMENT.'/hooks'.EXT))
+ {
+ @include(APPPATH.'config/'.ENVIRONMENT.'/hooks'.EXT);
+ }
+ else
+ {
+ @include(APPPATH.'config/hooks'.EXT);
+ }
+
if ( ! isset($hook) OR ! is_array($hook))
{
diff --git a/system/core/Loader.php b/system/core/Loader.php
index 7003318..75c0943 100644
--- a/system/core/Loader.php
+++ b/system/core/Loader.php
@@ -975,7 +975,15 @@
*/
function _ci_autoloader()
{
- include_once(APPPATH.'config/autoload'.EXT);
+ if (file_exists(APPPATH.'config/'.ENVIRONMENT.'/autoload'.EXT))
+ {
+ include_once(APPPATH.'config/'.ENVIRONMENT.'/autoload'.EXT);
+ }
+ else
+ {
+ include_once(APPPATH.'config/autoload'.EXT);
+ }
+
if ( ! isset($autoload))
{
diff --git a/system/core/Output.php b/system/core/Output.php
index 6644b3b..82c8215 100644
--- a/system/core/Output.php
+++ b/system/core/Output.php
@@ -43,7 +43,16 @@
$this->_zlib_oc = @ini_get('zlib.output_compression');
// Get mime types for later
- include APPPATH.'config/mimes'.EXT;
+ if (file_exists(APPPATH.'config/'.ENVIRONMENT.'/mimes'.EXT))
+ {
+ include APPPATH.'config/'.ENVIRONMENT.'/mimes'.EXT;
+ }
+ else
+ {
+ include APPPATH.'config/mimes'.EXT;
+ }
+
+
$this->mime_types = $mimes;
log_message('debug', "Output Class Initialized");
diff --git a/system/core/Router.php b/system/core/Router.php
index 6893e6e..005e817 100644
--- a/system/core/Router.php
+++ b/system/core/Router.php
@@ -87,7 +87,15 @@
}
// Load the routes.php file.
- @include(APPPATH.'config/routes'.EXT);
+
+ if (file_exists(APPPATH.'config/'.ENVIRONMENT.'/routes'.EXT))
+ {
+ @include(APPPATH.'config/'.ENVIRONMENT.'/routes'.EXT);
+ }
+ else
+ {
+ @include(APPPATH.'config/routes'.EXT);
+ }
$this->routes = ( ! isset($route) OR ! is_array($route)) ? array() : $route;
unset($route);
diff --git a/system/helpers/download_helper.php b/system/helpers/download_helper.php
index 6cecd0d..a851e3c 100644
--- a/system/helpers/download_helper.php
+++ b/system/helpers/download_helper.php
@@ -58,7 +58,14 @@
$extension = end($x);
// Load the mime types
- @include(APPPATH.'config/mimes'.EXT);
+ if (file_exists(APPPATH.'config/'.ENVIRONMENT.'/mimes'.EXT))
+ {
+ @include(APPPATH.'config/'.ENVIRONMENT.'/mimes'.EXT);
+ }
+ else
+ {
+ @include(APPPATH.'config/mimes'.EXT);
+ }
// Set a default mime if we can't find it
if ( ! isset($mimes[$extension]))
diff --git a/system/helpers/file_helper.php b/system/helpers/file_helper.php
index 9518e48..fb074e0 100644
--- a/system/helpers/file_helper.php
+++ b/system/helpers/file_helper.php
@@ -352,7 +352,16 @@
if ( ! is_array($mimes))
{
- if ( ! require_once(APPPATH.'config/mimes.php'))
+ if (file_exists(APPPATH.'config/'.ENVIRONMENT.'/mimes'.EXT))
+ {
+ @include(APPPATH.'config/'.ENVIRONMENT.'/mimes'.EXT);
+ }
+ else
+ {
+ @include(APPPATH.'config/mimes'.EXT);
+ }
+
+ if ( ! is_array($mimes))
{
return FALSE;
}
diff --git a/system/helpers/html_helper.php b/system/helpers/html_helper.php
index 68c6f59..c94c880 100644
--- a/system/helpers/html_helper.php
+++ b/system/helpers/html_helper.php
@@ -258,7 +258,16 @@
if ( ! is_array($_doctypes))
{
- if ( ! require_once(APPPATH.'config/doctypes.php'))
+ if (file_exists(APPPATH.'config/'.ENVIRONMENT.'/doctypes'.EXT))
+ {
+ @include(APPPATH.'config/'.ENVIRONMENT.'/doctypes'.EXT);
+ }
+ else
+ {
+ @include(APPPATH.'config/doctypes'.EXT);
+ }
+
+ if ( ! is_array($_doctypes))
{
return FALSE;
}
diff --git a/system/helpers/smiley_helper.php b/system/helpers/smiley_helper.php
index 463881f..6c90151 100644
--- a/system/helpers/smiley_helper.php
+++ b/system/helpers/smiley_helper.php
@@ -229,13 +229,20 @@
{
function _get_smiley_array()
{
- if ( ! file_exists(APPPATH.'config/smileys'.EXT))
+ if ( ! file_exists(APPPATH.'config/smileys'.EXT) AND ! file_exists(APPPATH.'config/'.ENVIRONMENT.'/smileys'.EXT))
{
return FALSE;
}
- include(APPPATH.'config/smileys'.EXT);
-
+ if (file_exists(APPPATH.'config/'.ENVIRONMENT.'/smileys'.EXT))
+ {
+ include(APPPATH.'config/'.ENVIRONMENT.'/smileys'.EXT);
+ }
+ else
+ {
+ include(APPPATH.'config/smileys'.EXT);
+ }
+
if ( ! isset($smileys) OR ! is_array($smileys))
{
return FALSE;
diff --git a/system/helpers/text_helper.php b/system/helpers/text_helper.php
index 96afd4c..197bcb1 100644
--- a/system/helpers/text_helper.php
+++ b/system/helpers/text_helper.php
@@ -366,12 +366,19 @@
{
function convert_accented_characters($str)
{
- if ( ! file_exists(APPPATH.'config/foreign_chars'.EXT))
+ if ( ! file_exists(APPPATH.'config/foreign_chars'.EXT) AND ! file_exists(APPPATH.'config/'.ENVIRONMENT.'/foreign_chars'.EXT))
{
return $str;
}
- include APPPATH.'config/foreign_chars'.EXT;
+ if (file_exists(APPPATH.'config/'.ENVIRONMENT.'/foreign_chars'.EXT))
+ {
+ include APPPATH.'config/'.ENVIRONMENT.'/foreign_chars'.EXT;
+ }
+ else
+ {
+ include APPPATH.'config/foreign_chars'.EXT;
+ }
if ( ! isset($foreign_characters))
{
diff --git a/system/libraries/Upload.php b/system/libraries/Upload.php
index 2012fb3..24189f4 100644
--- a/system/libraries/Upload.php
+++ b/system/libraries/Upload.php
@@ -951,7 +951,16 @@
if (count($this->mimes) == 0)
{
- if (@require(APPPATH.'config/mimes'.EXT))
+ if (file_exists(APPPATH.'config/'.ENVIRONMENT.'/mimes'.EXT))
+ {
+ $_mimes_path = APPPATH.'config/'.ENVIRONMENT.'/mimes'.EXT;
+ }
+ else
+ {
+ $_mimes_path = APPPATH.'config/mimes'.EXT;
+ }
+
+ if (@require($_mimes_path))
{
$this->mimes = $mimes;
unset($mimes);
diff --git a/system/libraries/User_agent.php b/system/libraries/User_agent.php
index 3774fc2..2690e17 100644
--- a/system/libraries/User_agent.php
+++ b/system/libraries/User_agent.php
@@ -84,7 +84,16 @@
*/
private function _load_agent_file()
{
- if ( ! @include(APPPATH.'config/user_agents'.EXT))
+ if (file_exists(APPPATH.'config/'.ENVIRONMENT.'/user_agents'.EXT))
+ {
+ $_ua_path = APPPATH.'config/'.ENVIRONMENT.'/user_agents'.EXT;
+ }
+ else
+ {
+ $_ua_path = APPPATH.'config/user_agents'.EXT;
+ }
+
+ if ( ! @include($_ua_path))
{
return FALSE;
}