diff options
-rw-r--r-- | system/core/Loader.php | 3 | ||||
-rw-r--r-- | system/core/Model.php | 3 | ||||
-rw-r--r-- | system/database/DB_utility.php | 3 | ||||
-rw-r--r-- | system/helpers/cookie_helper.php | 6 | ||||
-rw-r--r-- | system/helpers/html_helper.php | 6 | ||||
-rw-r--r-- | system/helpers/language_helper.php | 3 | ||||
-rw-r--r-- | system/helpers/security_helper.php | 9 | ||||
-rw-r--r-- | system/helpers/url_helper.php | 9 | ||||
-rw-r--r-- | system/libraries/Cache/drivers/Cache_redis.php | 4 | ||||
-rw-r--r-- | system/libraries/Upload.php | 23 | ||||
-rw-r--r-- | system/libraries/Xmlrpcs.php | 14 | ||||
-rw-r--r-- | system/libraries/Zip.php | 3 |
12 files changed, 35 insertions, 51 deletions
diff --git a/system/core/Loader.php b/system/core/Loader.php index daf326f25..78172580d 100644 --- a/system/core/Loader.php +++ b/system/core/Loader.php @@ -642,8 +642,7 @@ class CI_Loader { */ public function config($file, $use_sections = FALSE, $fail_gracefully = FALSE) { - $CI =& get_instance(); - return $CI->config->load($file, $use_sections, $fail_gracefully); + return get_instance()->config->load($file, $use_sections, $fail_gracefully); } // -------------------------------------------------------------------- diff --git a/system/core/Model.php b/system/core/Model.php index 1eb6f909b..11e60759b 100644 --- a/system/core/Model.php +++ b/system/core/Model.php @@ -59,8 +59,7 @@ class CI_Model { */ public function __get($key) { - $CI =& get_instance(); - return $CI->$key; + return get_instance()->$key; } } diff --git a/system/database/DB_utility.php b/system/database/DB_utility.php index 9f953d4ac..665615909 100644 --- a/system/database/DB_utility.php +++ b/system/database/DB_utility.php @@ -282,8 +282,7 @@ abstract class CI_DB_utility { extract($params); // Load the xml helper - $CI =& get_instance(); - $CI->load->helper('xml'); + get_instance()->load->helper('xml'); // Generate the result $xml = '<'.$root.'>'.$newline; diff --git a/system/helpers/cookie_helper.php b/system/helpers/cookie_helper.php index e465412cf..5cdcdd137 100644 --- a/system/helpers/cookie_helper.php +++ b/system/helpers/cookie_helper.php @@ -59,8 +59,7 @@ if ( ! function_exists('set_cookie')) function set_cookie($name, $value = '', $expire = '', $domain = '', $path = '/', $prefix = '', $secure = FALSE, $httponly = FALSE) { // Set the config file options - $CI =& get_instance(); - $CI->input->set_cookie($name, $value, $expire, $domain, $path, $prefix, $secure, $httponly); + get_instance()->input->set_cookie($name, $value, $expire, $domain, $path, $prefix, $secure, $httponly); } } @@ -77,9 +76,8 @@ if ( ! function_exists('get_cookie')) */ function get_cookie($index, $xss_clean = FALSE) { - $CI =& get_instance(); $prefix = isset($_COOKIE[$index]) ? '' : config_item('cookie_prefix'); - return $CI->input->cookie($prefix.$index, $xss_clean); + return get_instance()->input->cookie($prefix.$index, $xss_clean); } } diff --git a/system/helpers/html_helper.php b/system/helpers/html_helper.php index ece39584b..988eee715 100644 --- a/system/helpers/html_helper.php +++ b/system/helpers/html_helper.php @@ -199,15 +199,13 @@ if ( ! function_exists('img')) { if ($k === 'src' && strpos($v, '://') === FALSE) { - $CI =& get_instance(); - if ($index_page === TRUE) { - $img .= ' src="'.$CI->config->site_url($v).'"'; + $img .= ' src="'.get_instance()->config->site_url($v).'"'; } else { - $img .= ' src="'.$CI->config->slash_item('base_url').$v.'"'; + $img .= ' src="'.get_instance()->config->slash_item('base_url').$v.'"'; } } else diff --git a/system/helpers/language_helper.php b/system/helpers/language_helper.php index 4d571a71c..d7aa8e638 100644 --- a/system/helpers/language_helper.php +++ b/system/helpers/language_helper.php @@ -52,8 +52,7 @@ if ( ! function_exists('lang')) */ function lang($line, $for = '', $attributes = array()) { - $CI =& get_instance(); - $line = $CI->lang->line($line); + $line = get_instance()->lang->line($line); if ($for !== '') { diff --git a/system/helpers/security_helper.php b/system/helpers/security_helper.php index 4bb94a201..7a6df5420 100644 --- a/system/helpers/security_helper.php +++ b/system/helpers/security_helper.php @@ -49,8 +49,7 @@ if ( ! function_exists('xss_clean')) */ function xss_clean($str, $is_image = FALSE) { - $CI =& get_instance(); - return $CI->security->xss_clean($str, $is_image); + return get_instance()->security->xss_clean($str, $is_image); } } @@ -66,8 +65,7 @@ if ( ! function_exists('sanitize_filename')) */ function sanitize_filename($filename) { - $CI =& get_instance(); - return $CI->security->sanitize_filename($filename); + return get_instance()->security->sanitize_filename($filename); } } @@ -107,8 +105,7 @@ if ( ! function_exists('strip_image_tags')) */ function strip_image_tags($str) { - $CI =& get_instance(); - return $CI->security->strip_image_tags($str); + return get_instance()->security->strip_image_tags($str); } } diff --git a/system/helpers/url_helper.php b/system/helpers/url_helper.php index b0f436840..2d9289791 100644 --- a/system/helpers/url_helper.php +++ b/system/helpers/url_helper.php @@ -91,8 +91,7 @@ if ( ! function_exists('current_url')) */ function current_url() { - $CI =& get_instance(); - return $CI->config->site_url($CI->uri->uri_string()); + return get_instance()->config->site_url($CI->uri->uri_string()); } } @@ -109,8 +108,7 @@ if ( ! function_exists('uri_string')) */ function uri_string() { - $CI =& get_instance(); - return $CI->uri->uri_string(); + return get_instance()->uri->uri_string(); } } @@ -127,8 +125,7 @@ if ( ! function_exists('index_page')) */ function index_page() { - $CI =& get_instance(); - return $CI->config->item('index_page'); + return get_instance()->config->item('index_page'); } } diff --git a/system/libraries/Cache/drivers/Cache_redis.php b/system/libraries/Cache/drivers/Cache_redis.php index f13e4479f..48c803d7e 100644 --- a/system/libraries/Cache/drivers/Cache_redis.php +++ b/system/libraries/Cache/drivers/Cache_redis.php @@ -208,7 +208,7 @@ class CI_Cache_redis extends CI_Driver { $success = $this->_redis->connect($config['host'], $config['port'], $config['timeout']); } - + if ( ! $success) { log_message('debug', 'Cache: Redis connection refused. Check the config.'); @@ -225,7 +225,7 @@ class CI_Cache_redis extends CI_Driver { $this->_redis->auth($config['password']); } - + return TRUE; } diff --git a/system/libraries/Upload.php b/system/libraries/Upload.php index 67a65501e..525880f62 100644 --- a/system/libraries/Upload.php +++ b/system/libraries/Upload.php @@ -263,6 +263,13 @@ class CI_Upload { */ protected $_file_name_override = ''; + /** + * CI Singleton + * + * @var object + */ + protected $CI; + // -------------------------------------------------------------------- /** @@ -279,6 +286,7 @@ class CI_Upload { } $this->mimes =& get_mimes(); + $this->CI =& get_instance(); log_message('debug', 'Upload Class Initialized'); } @@ -479,8 +487,7 @@ class CI_Upload { } // Sanitize the file name for security - $CI =& get_instance(); - $this->file_name = $CI->security->sanitize_filename($this->file_name); + $this->file_name = $this->CI->security->sanitize_filename($this->file_name); // Truncate the file name if it's too long if ($this->max_filename > 0) @@ -1081,7 +1088,7 @@ class CI_Upload { return FALSE; } - return get_instance()->security->xss_clean($data, TRUE); + return $this->CI->security->xss_clean($data, TRUE); } // -------------------------------------------------------------------- @@ -1094,17 +1101,13 @@ class CI_Upload { */ public function set_error($msg) { - $CI =& get_instance(); - $CI->lang->load('upload'); + $this->CI->lang->load('upload'); - if ( ! is_array($msg)) - { - $msg = array($msg); - } + is_array($msg) OR $msg = array($msg); foreach ($msg as $val) { - $msg = ($CI->lang->line($val) === FALSE) ? $val : $CI->lang->line($val); + $msg = ($this->CI->lang->line($val) === FALSE) ? $val : $this->CI->lang->line($val); $this->error_msg[] = $msg; log_message('error', $msg); } diff --git a/system/libraries/Xmlrpcs.php b/system/libraries/Xmlrpcs.php index d263d789d..50ff423f2 100644 --- a/system/libraries/Xmlrpcs.php +++ b/system/libraries/Xmlrpcs.php @@ -384,17 +384,13 @@ class CI_Xmlrpcs extends CI_Xmlrpc { { return call_user_func(array($this, $method_parts[1]), $m); } + elseif ($this->object === FALSE) + { + return get_instance()->$method_parts[1]($m); + } else { - if ($this->object === FALSE) - { - $CI =& get_instance(); - return $CI->$method_parts[1]($m); - } - else - { - return $this->object->$method_parts[1]($m); - } + return $this->object->$method_parts[1]($m); } } else diff --git a/system/libraries/Zip.php b/system/libraries/Zip.php index 229b1ecbc..250ee02cd 100644 --- a/system/libraries/Zip.php +++ b/system/libraries/Zip.php @@ -425,8 +425,7 @@ class CI_Zip { $filename .= '.zip'; } - $CI =& get_instance(); - $CI->load->helper('download'); + get_instance()->load->helper('download'); $get_zip = $this->get_zip(); $zip_content =& $get_zip; |