summaryrefslogtreecommitdiffstats
path: root/system/core
diff options
context:
space:
mode:
Diffstat (limited to 'system/core')
-rwxr-xr-xsystem/core/CodeIgniter.php9
-rw-r--r--system/core/Common.php200
-rwxr-xr-xsystem/core/Config.php2
-rwxr-xr-xsystem/core/Hooks.php11
-rw-r--r--system/core/Loader.php9
-rwxr-xr-xsystem/core/Output.php10
-rwxr-xr-xsystem/core/Router.php9
-rwxr-xr-xsystem/core/Security.php2
-rw-r--r--system/core/Utf8.php25
9 files changed, 133 insertions, 144 deletions
diff --git a/system/core/CodeIgniter.php b/system/core/CodeIgniter.php
index 97527e5ca..04f346c7c 100755
--- a/system/core/CodeIgniter.php
+++ b/system/core/CodeIgniter.php
@@ -59,14 +59,7 @@
* Load the framework constants
* ------------------------------------------------------
*/
- if (defined('ENVIRONMENT') AND file_exists(APPPATH.'config/'.ENVIRONMENT.'/constants.php'))
- {
- require(APPPATH.'config/'.ENVIRONMENT.'/constants.php');
- }
- else
- {
- require(APPPATH.'config/constants.php');
- }
+ load_environ_config('constants', TRUE);
/*
* ------------------------------------------------------
diff --git a/system/core/Common.php b/system/core/Common.php
index b0921fe0c..9e05f3db4 100644
--- a/system/core/Common.php
+++ b/system/core/Common.php
@@ -47,7 +47,6 @@
* Since there are a few places where we conditionally test for PHP > 5
* we'll set a static variable.
*
-* @access public
* @param string
* @return bool TRUE if the current version is $version or higher
*/
@@ -76,7 +75,6 @@ if ( ! function_exists('is_php'))
* the file, based on the read-only attribute. is_writable() is also unreliable
* on Unix servers if safe_mode is on.
*
- * @access private
* @return void
*/
if ( ! function_exists('is_really_writable'))
@@ -118,18 +116,17 @@ if ( ! function_exists('is_really_writable'))
// ------------------------------------------------------------------------
/**
-* Class registry
-*
-* This function acts as a singleton. If the requested class does not
-* exist it is instantiated and set to a static variable. If it has
-* previously been instantiated the variable is returned.
-*
-* @access public
-* @param string the class name being requested
-* @param string the directory where the class should be found
-* @param string the class name prefix
-* @return object
-*/
+ * Class registry
+ *
+ * This function acts as a singleton. If the requested class does not
+ * exist it is instantiated and set to a static variable. If it has
+ * previously been instantiated the variable is returned.
+ *
+ * @param string the class name being requested
+ * @param string the directory where the class should be found
+ * @param string the class name prefix
+ * @return object
+ */
if ( ! function_exists('load_class'))
{
function &load_class($class, $directory = 'libraries', $prefix = 'CI_')
@@ -191,12 +188,11 @@ if ( ! function_exists('load_class'))
// --------------------------------------------------------------------
/**
-* Keeps track of which libraries have been loaded. This function is
-* called by the load_class() function above
-*
-* @access public
-* @return array
-*/
+ * Keeps track of which libraries have been loaded. This function is
+ * called by the load_class() function above
+ *
+ * @return array
+ */
if ( ! function_exists('is_loaded'))
{
function is_loaded($class = '')
@@ -215,14 +211,13 @@ if ( ! function_exists('is_loaded'))
// ------------------------------------------------------------------------
/**
-* Loads the main config.php file
-*
-* This function lets us grab the config file even if the Config class
-* hasn't been instantiated yet
-*
-* @access private
-* @return array
-*/
+ * Loads the main config.php file
+ *
+ * This function lets us grab the config file even if the Config class
+ * hasn't been instantiated yet
+ *
+ * @return array
+ */
if ( ! function_exists('get_config'))
{
function &get_config($replace = array())
@@ -273,11 +268,10 @@ if ( ! function_exists('get_config'))
// ------------------------------------------------------------------------
/**
-* Returns the specified config item
-*
-* @access public
-* @return mixed
-*/
+ * Returns the specified config item
+ *
+ * @return mixed
+ */
if ( ! function_exists('config_item'))
{
function config_item($item)
@@ -302,17 +296,16 @@ if ( ! function_exists('config_item'))
// ------------------------------------------------------------------------
/**
-* Error Handler
-*
-* This function lets us invoke the exception class and
-* display errors using the standard error template located
-* in application/errors/errors.php
-* This function will send the error page directly to the
-* browser and exit.
-*
-* @access public
-* @return void
-*/
+ * Error Handler
+ *
+ * This function lets us invoke the exception class and
+ * display errors using the standard error template located
+ * in application/errors/errors.php
+ * This function will send the error page directly to the
+ * browser and exit.
+ *
+ * @return void
+ */
if ( ! function_exists('show_error'))
{
function show_error($message, $status_code = 500, $heading = 'An Error Was Encountered')
@@ -326,15 +319,14 @@ if ( ! function_exists('show_error'))
// ------------------------------------------------------------------------
/**
-* 404 Page Handler
-*
-* This function is similar to the show_error() function above
-* However, instead of the standard error template it displays
-* 404 errors.
-*
-* @access public
-* @return void
-*/
+ * 404 Page Handler
+ *
+ * This function is similar to the show_error() function above
+ * However, instead of the standard error template it displays
+ * 404 errors.
+ *
+ * @return void
+ */
if ( ! function_exists('show_404'))
{
function show_404($page = '', $log_error = TRUE)
@@ -348,14 +340,13 @@ if ( ! function_exists('show_404'))
// ------------------------------------------------------------------------
/**
-* Error Logging Interface
-*
-* We use this as a simple mechanism to access the logging
-* class and send messages to be logged.
-*
-* @access public
-* @return void
-*/
+ * Error Logging Interface
+ *
+ * We use this as a simple mechanism to access the logging
+ * class and send messages to be logged.
+ *
+ * @return void
+ */
if ( ! function_exists('log_message'))
{
function log_message($level = 'error', $message, $php_error = FALSE)
@@ -377,7 +368,6 @@ if ( ! function_exists('log_message'))
/**
* Set HTTP Status Header
*
- * @access public
* @param int the status code
* @param string
* @return void
@@ -464,19 +454,18 @@ if ( ! function_exists('set_status_header'))
// --------------------------------------------------------------------
/**
-* Exception Handler
-*
-* This is the custom exception handler that is declaired at the top
-* of Codeigniter.php. The main reason we use this is to permit
-* PHP errors to be logged in our own log files since the user may
-* not have access to server logs. Since this function
-* effectively intercepts PHP errors, however, we also need
-* to display errors based on the current error_reporting level.
-* We do that with the use of a PHP error template.
-*
-* @access private
-* @return void
-*/
+ * Exception Handler
+ *
+ * This is the custom exception handler that is declaired at the top
+ * of Codeigniter.php. The main reason we use this is to permit
+ * PHP errors to be logged in our own log files since the user may
+ * not have access to server logs. Since this function
+ * effectively intercepts PHP errors, however, we also need
+ * to display errors based on the current error_reporting level.
+ * We do that with the use of a PHP error template.
+ *
+ * @return void
+ */
if ( ! function_exists('_exception_handler'))
{
function _exception_handler($severity, $message, $filepath, $line)
@@ -518,7 +507,6 @@ if ( ! function_exists('_exception_handler'))
* This prevents sandwiching null characters
* between ascii characters, like Java\0script.
*
- * @access public
* @param string
* @return string
*/
@@ -552,12 +540,11 @@ if ( ! function_exists('remove_invisible_characters'))
// ------------------------------------------------------------------------
/**
-* Returns HTML escaped variable
-*
-* @access public
-* @param mixed
-* @return mixed
-*/
+ * Returns HTML escaped variable
+ *
+ * @param mixed
+ * @return mixed
+ */
if ( ! function_exists('html_escape'))
{
function html_escape($var)
@@ -566,12 +553,57 @@ if ( ! function_exists('html_escape'))
{
return array_map('html_escape', $var);
}
+
+ return htmlspecialchars($var, ENT_QUOTES, config_item('charset'));
+ }
+}
+
+// ------------------------------------------------------------------------
+
+/**
+ * Load Environmental config directory files.
+ *
+ * In several places we check to see if the environment is loaded up and if the file
+ * that is being requested lives in said environment. Otherwise load up the file from
+ * the main CI config dir.
+ *
+ * @todo Optimize a bit to lessen the file system hits if the file has been loaded.
+ * @param string filename without extension. eg: 'config' or 'hooks'
+ * @param boolean whether or not to do a `require_once()` or a simple `include()`
+ * @return void
+ */
+ if ( ! function_exists('load_environ_config'))
+ {
+ function load_environ_config($file, $require=FALSE)
+ {
+ if (defined('ENVIRONMENT') AND file_exists(APPPATH.'config/'.ENVIRONMENT.'/'.$file.'.php'))
+ {
+ if ($require)
+ {
+ require_once(APPPATH.'config/'.ENVIRONMENT.'/'.$file.'.php');
+ }
+ else
+ {
+ include(APPPATH.'config/'.ENVIRONMENT.'/'.$file.'.php');
+ }
+
+ return;
+ }
+
+ if ($require)
+ {
+ require_once(APPPATH.'config/'.$file.'.php');
+ }
else
{
- return htmlspecialchars($var, ENT_QUOTES, config_item('charset'));
+ include(APPPATH.'config/'.$file.'.php');
}
+
+ return;
}
-}
+ }
+
+// ------------------------------------------------------------------------
/* End of file Common.php */
/* Location: ./system/core/Common.php */ \ No newline at end of file
diff --git a/system/core/Config.php b/system/core/Config.php
index abd2767d5..b0b4c9aa4 100755
--- a/system/core/Config.php
+++ b/system/core/Config.php
@@ -328,7 +328,7 @@ class CI_Config {
$uri = $str;
}
}
- return $uri;
+ return $uri;
}
// --------------------------------------------------------------------
diff --git a/system/core/Hooks.php b/system/core/Hooks.php
index 46bfec02a..6a36ce963 100755
--- a/system/core/Hooks.php
+++ b/system/core/Hooks.php
@@ -91,16 +91,7 @@ class CI_Hooks {
// Grab the "hooks" definition file.
// If there are no hooks, we're done.
-
- if (defined('ENVIRONMENT') AND is_file(APPPATH.'config/'.ENVIRONMENT.'/hooks.php'))
- {
- include(APPPATH.'config/'.ENVIRONMENT.'/hooks.php');
- }
- elseif (is_file(APPPATH.'config/hooks.php'))
- {
- include(APPPATH.'config/hooks.php');
- }
-
+ load_environ_config('hooks');
if ( ! isset($hook) OR ! is_array($hook))
{
diff --git a/system/core/Loader.php b/system/core/Loader.php
index 4e14b54af..12d07bbe0 100644
--- a/system/core/Loader.php
+++ b/system/core/Loader.php
@@ -1125,14 +1125,7 @@ class CI_Loader {
*/
protected function _ci_autoloader()
{
- if (defined('ENVIRONMENT') AND file_exists(APPPATH.'config/'.ENVIRONMENT.'/autoload.php'))
- {
- include(APPPATH.'config/'.ENVIRONMENT.'/autoload.php');
- }
- else
- {
- include(APPPATH.'config/autoload.php');
- }
+ load_environ_config('autoload');
if ( ! isset($autoload))
{
diff --git a/system/core/Output.php b/system/core/Output.php
index 7b53f8e3e..4d1036ceb 100755
--- a/system/core/Output.php
+++ b/system/core/Output.php
@@ -106,15 +106,7 @@ class CI_Output {
$this->_zlib_oc = @ini_get('zlib.output_compression');
// Get mime types for later
- if (defined('ENVIRONMENT') AND file_exists(APPPATH.'config/'.ENVIRONMENT.'/mimes.php'))
- {
- include APPPATH.'config/'.ENVIRONMENT.'/mimes.php';
- }
- else
- {
- include APPPATH.'config/mimes.php';
- }
-
+ load_environ_config('mimes');
$this->mime_types = $mimes;
diff --git a/system/core/Router.php b/system/core/Router.php
index 748678d67..5388a9289 100755
--- a/system/core/Router.php
+++ b/system/core/Router.php
@@ -141,14 +141,7 @@ class CI_Router {
}
// Load the routes.php file.
- if (defined('ENVIRONMENT') AND is_file(APPPATH.'config/'.ENVIRONMENT.'/routes.php'))
- {
- include(APPPATH.'config/'.ENVIRONMENT.'/routes.php');
- }
- elseif (is_file(APPPATH.'config/routes.php'))
- {
- include(APPPATH.'config/routes.php');
- }
+ load_environ_config('routes');
$this->routes = ( ! isset($route) OR ! is_array($route)) ? array() : $route;
unset($route);
diff --git a/system/core/Security.php b/system/core/Security.php
index ce3f7d3cc..60a64f358 100755
--- a/system/core/Security.php
+++ b/system/core/Security.php
@@ -182,7 +182,7 @@ class CI_Security {
// Nothing should last forever
unset($_COOKIE[$this->_csrf_cookie_name]);
- $this->_csrf_hash = '';
+ $this->_csrf_hash = '';
$this->_csrf_set_hash();
$this->csrf_set_cookie();
diff --git a/system/core/Utf8.php b/system/core/Utf8.php
index 7abe4e43b..1bcf526a5 100644
--- a/system/core/Utf8.php
+++ b/system/core/Utf8.php
@@ -44,19 +44,18 @@ class CI_Utf8 {
* Constructor
*
* Determines if UTF-8 support is to be enabled
- *
*/
- function __construct()
+ public function __construct()
{
log_message('debug', "Utf8 Class Initialized");
global $CFG;
if (
- preg_match('/./u', 'é') === 1 // PCRE must support UTF-8
- AND function_exists('iconv') // iconv must be installed
- AND ini_get('mbstring.func_overload') != 1 // Multibyte string function overloading cannot be enabled
- AND $CFG->item('charset') == 'UTF-8' // Application charset must be UTF-8
+ @preg_match('/./u', 'é') === 1 // PCRE must support UTF-8
+ && function_exists('iconv') // iconv must be installed
+ && ini_get('mbstring.func_overload') !== 1 // Multibyte string function overloading cannot be enabled
+ && $CFG->item('charset') == 'UTF-8' // Application charset must be UTF-8
)
{
log_message('debug', "UTF-8 Support Enabled");
@@ -90,11 +89,10 @@ class CI_Utf8 {
*
* Ensures strings are UTF-8
*
- * @access public
* @param string
* @return string
*/
- function clean_string($str)
+ public function clean_string($str)
{
if ($this->_is_ascii($str) === FALSE)
{
@@ -113,11 +111,10 @@ class CI_Utf8 {
* line feeds, and carriage returns, as all others can cause
* problems in XML
*
- * @access public
* @param string
* @return string
*/
- function safe_ascii_for_xml($str)
+ public function safe_ascii_for_xml($str)
{
return remove_invisible_characters($str, FALSE);
}
@@ -129,12 +126,11 @@ class CI_Utf8 {
*
* Attempts to convert a string to UTF-8
*
- * @access public
* @param string
* @param string - input encoding
* @return string
*/
- function convert_to_utf8($str, $encoding)
+ public function convert_to_utf8($str, $encoding)
{
if (function_exists('iconv'))
{
@@ -159,13 +155,12 @@ class CI_Utf8 {
*
* Tests if a string is standard 7-bit ASCII or not
*
- * @access public
* @param string
* @return bool
*/
- function _is_ascii($str)
+ protected function _is_ascii($str)
{
- return (preg_match('/[^\x00-\x7F]/S', $str) == 0);
+ return (preg_match('/[^\x00-\x7F]/S', $str) === 0);
}
// --------------------------------------------------------------------