summaryrefslogtreecommitdiffstats
path: root/system
diff options
context:
space:
mode:
Diffstat (limited to 'system')
-rw-r--r--system/core/CodeIgniter.php8
-rw-r--r--system/core/Common.php16
-rw-r--r--system/core/Config.php6
-rw-r--r--system/core/Hooks.php7
-rw-r--r--system/core/Input.php4
-rw-r--r--system/core/Loader.php158
-rw-r--r--system/core/Log.php25
-rw-r--r--system/core/Output.php2
-rw-r--r--system/core/Router.php9
-rw-r--r--system/core/Security.php10
-rw-r--r--system/core/URI.php2
-rw-r--r--system/database/DB.php6
-rw-r--r--system/database/DB_driver.php4
-rw-r--r--system/database/DB_query_builder.php3
-rw-r--r--system/database/drivers/mssql/mssql_result.php1
-rw-r--r--system/database/drivers/mysql/mysql_result.php1
-rw-r--r--system/database/drivers/mysqli/mysqli_result.php1
-rw-r--r--system/database/drivers/pdo/pdo_driver.php7
-rw-r--r--system/helpers/captcha_helper.php6
-rw-r--r--system/helpers/download_helper.php2
-rw-r--r--system/helpers/form_helper.php9
-rw-r--r--system/helpers/html_helper.php20
-rw-r--r--system/helpers/smiley_helper.php28
-rw-r--r--system/helpers/text_helper.php22
-rw-r--r--system/helpers/url_helper.php19
-rw-r--r--system/language/english/form_validation_lang.php1
-rw-r--r--system/language/english/profiler_lang.php1
-rw-r--r--system/libraries/Cache/drivers/Cache_memcached.php4
-rw-r--r--system/libraries/Cart.php4
-rw-r--r--system/libraries/Driver.php19
-rw-r--r--system/libraries/Email.php55
-rw-r--r--system/libraries/Form_validation.php21
-rw-r--r--system/libraries/Image_lib.php2
-rw-r--r--system/libraries/Javascript.php2
-rw-r--r--system/libraries/Javascript/Jquery.php (renamed from system/libraries/javascript/Jquery.php)0
-rw-r--r--system/libraries/Javascript/index.html (renamed from system/libraries/javascript/index.html)0
-rw-r--r--system/libraries/Migration.php6
-rw-r--r--system/libraries/Pagination.php198
-rw-r--r--system/libraries/Profiler.php3
-rw-r--r--system/libraries/Session/drivers/Session_cookie.php5
-rw-r--r--system/libraries/Upload.php51
-rw-r--r--system/libraries/User_agent.php13
-rw-r--r--system/libraries/Xmlrpcs.php2
43 files changed, 422 insertions, 341 deletions
diff --git a/system/core/CodeIgniter.php b/system/core/CodeIgniter.php
index 13826c328..5a872ef21 100644
--- a/system/core/CodeIgniter.php
+++ b/system/core/CodeIgniter.php
@@ -58,7 +58,7 @@ defined('BASEPATH') OR exit('No direct script access allowed');
* Load the framework constants
* ------------------------------------------------------
*/
- if (defined('ENVIRONMENT') && file_exists(APPPATH.'config/'.ENVIRONMENT.'/constants.php'))
+ if (file_exists(APPPATH.'config/'.ENVIRONMENT.'/constants.php'))
{
require(APPPATH.'config/'.ENVIRONMENT.'/constants.php');
}
@@ -263,7 +263,7 @@ defined('BASEPATH') OR exit('No direct script access allowed');
$class = $RTR->fetch_class();
$method = $RTR->fetch_method();
- if ( ! class_exists($class) OR $method[0] === '_' OR method_exists('CI_Controller', $method))
+ if ( ! class_exists($class, FALSE) OR $method[0] === '_' OR method_exists('CI_Controller', $method))
{
if ( ! empty($RTR->routes['404_override']))
{
@@ -272,7 +272,7 @@ defined('BASEPATH') OR exit('No direct script access allowed');
$method = 'index';
}
- if ( ! class_exists($class))
+ if ( ! class_exists($class, FALSE))
{
if ( ! file_exists(APPPATH.'controllers/'.$class.'.php'))
{
@@ -310,7 +310,7 @@ defined('BASEPATH') OR exit('No direct script access allowed');
$method = 'index';
}
- if ( ! class_exists($class))
+ if ( ! class_exists($class, FALSE))
{
if ( ! file_exists(APPPATH.'controllers/'.$class.'.php'))
{
diff --git a/system/core/Common.php b/system/core/Common.php
index d6387209b..3cd97dc2e 100644
--- a/system/core/Common.php
+++ b/system/core/Common.php
@@ -150,7 +150,7 @@ if ( ! function_exists('load_class'))
{
$name = $prefix.$class;
- if (class_exists($name) === FALSE)
+ if (class_exists($name, FALSE) === FALSE)
{
require_once($path.$directory.'/'.$class.'.php');
}
@@ -164,7 +164,7 @@ if ( ! function_exists('load_class'))
{
$name = config_item('subclass_prefix').$class;
- if (class_exists($name) === FALSE)
+ if (class_exists($name, FALSE) === FALSE)
{
require_once(APPPATH.$directory.'/'.config_item('subclass_prefix').$class.'.php');
}
@@ -243,7 +243,7 @@ if ( ! function_exists('get_config'))
}
// Is the config file in the environment folder?
- if (defined('ENVIRONMENT') && file_exists($file_path = APPPATH.'config/'.ENVIRONMENT.'/config.php'))
+ if (file_exists($file_path = APPPATH.'config/'.ENVIRONMENT.'/config.php'))
{
require($file_path);
}
@@ -320,11 +320,11 @@ if ( ! function_exists('get_mimes'))
{
static $_mimes = array();
- if (defined('ENVIRONMENT') && is_file(APPPATH.'config/'.ENVIRONMENT.'/mimes.php'))
+ if (file_exists(APPPATH.'config/'.ENVIRONMENT.'/mimes.php'))
{
$_mimes = include(APPPATH.'config/'.ENVIRONMENT.'/mimes.php');
}
- elseif (is_file(APPPATH.'config/mimes.php'))
+ elseif (file_exists(APPPATH.'config/mimes.php'))
{
$_mimes = include(APPPATH.'config/mimes.php');
}
@@ -347,7 +347,7 @@ if ( ! function_exists('is_https'))
*/
function is_https()
{
- return ( ! empty($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) !== 'off');
+ return (isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) === 'on');
}
}
@@ -429,7 +429,7 @@ if ( ! function_exists('log_message'))
function log_message($level = 'error', $message, $php_error = FALSE)
{
static $_log, $_log_threshold;
-
+
if ($_log_threshold === NULL)
{
$_log_threshold = config_item('log_threshold');
@@ -444,7 +444,7 @@ if ( ! function_exists('log_message'))
{
$_log =& load_class('Log', 'core');
}
-
+
$_log->write_log($level, $message, $php_error);
}
}
diff --git a/system/core/Config.php b/system/core/Config.php
index 0160d1a15..7e64444bc 100644
--- a/system/core/Config.php
+++ b/system/core/Config.php
@@ -106,13 +106,9 @@ class CI_Config {
$file = ($file === '') ? 'config' : str_replace('.php', '', $file);
$found = $loaded = FALSE;
- $check_locations = defined('ENVIRONMENT')
- ? array(ENVIRONMENT.'/'.$file, $file)
- : array($file);
-
foreach ($this->_config_paths as $path)
{
- foreach ($check_locations as $location)
+ foreach (array(ENVIRONMENT.'/'.$file, $file) as $location)
{
$file_path = $path.'config/'.$location.'.php';
diff --git a/system/core/Hooks.php b/system/core/Hooks.php
index 2cb416c0c..b3b111991 100644
--- a/system/core/Hooks.php
+++ b/system/core/Hooks.php
@@ -81,11 +81,12 @@ class CI_Hooks {
}
// Grab the "hooks" definition file.
- if (defined('ENVIRONMENT') && is_file(APPPATH.'config/'.ENVIRONMENT.'/hooks.php'))
+ if (file_exists(APPPATH.'config/'.ENVIRONMENT.'/hooks.php'))
{
include(APPPATH.'config/'.ENVIRONMENT.'/hooks.php');
}
- elseif (is_file(APPPATH.'config/hooks.php'))
+
+ if (file_exists(APPPATH.'config/hooks.php'))
{
include(APPPATH.'config/hooks.php');
}
@@ -194,7 +195,7 @@ class CI_Hooks {
// Call the requested class and/or function
if ($class !== FALSE)
{
- if ( ! class_exists($class))
+ if ( ! class_exists($class, FALSE))
{
require($filepath);
}
diff --git a/system/core/Input.php b/system/core/Input.php
index 8f37e4464..904f4d6e9 100644
--- a/system/core/Input.php
+++ b/system/core/Input.php
@@ -720,9 +720,9 @@ class CI_Input {
}
// Standardize newlines if needed
- if ($this->_standardize_newlines === TRUE && strpos($str, "\r") !== FALSE)
+ if ($this->_standardize_newlines === TRUE)
{
- return str_replace(array("\r\n", "\r", "\r\n\n"), PHP_EOL, $str);
+ return preg_replace('/(?:\r\n|[\r\n])/', PHP_EOL, $str);
}
return $str;
diff --git a/system/core/Loader.php b/system/core/Loader.php
index 1ad07f1fa..6e5b58ba7 100644
--- a/system/core/Loader.php
+++ b/system/core/Loader.php
@@ -97,13 +97,6 @@ class CI_Loader {
protected $_ci_classes = array();
/**
- * List of loaded files
- *
- * @var array
- */
- protected $_ci_loaded_files = array();
-
- /**
* List of loaded models
*
* @var array
@@ -277,7 +270,7 @@ class CI_Loader {
continue;
}
- if ($db_conn !== FALSE && ! class_exists('CI_DB'))
+ if ($db_conn !== FALSE && ! class_exists('CI_DB', FALSE))
{
if ($db_conn === TRUE)
{
@@ -287,7 +280,7 @@ class CI_Loader {
$CI->load->database($db_conn, FALSE, TRUE);
}
- if ( ! class_exists('CI_Model'))
+ if ( ! class_exists('CI_Model', FALSE))
{
load_class('Model', 'core');
}
@@ -943,7 +936,6 @@ class CI_Loader {
// Was the path included with the class name?
// We look for a slash to determine this
- $subdir = '';
if (($last_slash = strrpos($class, '/')) !== FALSE)
{
// Extract the path
@@ -952,108 +944,92 @@ class CI_Loader {
// Get the filename from the path
$class = substr($class, $last_slash);
}
+ else
+ {
+ $subdir = '';
+ }
+
+ $class = ucfirst($class);
+ $subclass = APPPATH.'libraries/'.$subdir.config_item('subclass_prefix').$class.'.php';
- // We'll test for both lowercase and capitalized versions of the file name
- foreach (array(ucfirst($class), strtolower($class)) as $class)
+ // Is this a class extension request?
+ if (file_exists($subclass))
{
- $subclass = APPPATH.'libraries/'.$subdir.config_item('subclass_prefix').$class.'.php';
+ $baseclass = BASEPATH.'libraries/'.$class.'.php';
- // Is this a class extension request?
- if (file_exists($subclass))
+ if ( ! file_exists($baseclass))
{
- $baseclass = BASEPATH.'libraries/'.ucfirst($class).'.php';
-
- if ( ! file_exists($baseclass))
- {
- log_message('error', 'Unable to load the requested class: '.$class);
- show_error('Unable to load the requested class: '.$class);
- }
+ log_message('error', 'Unable to load the requested class: '.$class);
+ show_error('Unable to load the requested class: '.$class);
+ }
- // Safety: Was the class already loaded by a previous call?
- if (in_array($subclass, $this->_ci_loaded_files))
+ // Safety: Was the class already loaded by a previous call?
+ if (class_exists(config_item('subclass_prefix').$class, FALSE))
+ {
+ // Before we deem this to be a duplicate request, let's see
+ // if a custom object name is being supplied. If so, we'll
+ // return a new instance of the object
+ if ($object_name !== NULL)
{
- // Before we deem this to be a duplicate request, let's see
- // if a custom object name is being supplied. If so, we'll
- // return a new instance of the object
- if ($object_name !== NULL)
+ $CI =& get_instance();
+ if ( ! isset($CI->$object_name))
{
- $CI =& get_instance();
- if ( ! isset($CI->$object_name))
- {
- return $this->_ci_init_class($class, config_item('subclass_prefix'), $params, $object_name);
- }
+ return $this->_ci_init_class($class, config_item('subclass_prefix'), $params, $object_name);
}
-
- $is_duplicate = TRUE;
- log_message('debug', $class.' class already loaded. Second attempt ignored.');
- return;
}
- include_once($baseclass);
- include_once($subclass);
- $this->_ci_loaded_files[] = $subclass;
-
- return $this->_ci_init_class($class, config_item('subclass_prefix'), $params, $object_name);
+ log_message('debug', $class.' class already loaded. Second attempt ignored.');
+ return;
}
- // Lets search for the requested library file and load it.
- $is_duplicate = FALSE;
- foreach ($this->_ci_library_paths as $path)
- {
- $filepath = $path.'libraries/'.$subdir.$class.'.php';
+ include_once($baseclass);
+ include_once($subclass);
- // Does the file exist? No? Bummer...
- if ( ! file_exists($filepath))
- {
- continue;
- }
+ return $this->_ci_init_class($class, config_item('subclass_prefix'), $params, $object_name);
+ }
+
+ // Let's search for the requested library file and load it.
+ foreach ($this->_ci_library_paths as $path)
+ {
+ $filepath = $path.'libraries/'.$subdir.$class.'.php';
- // Safety: Was the class already loaded by a previous call?
- if (in_array($filepath, $this->_ci_loaded_files))
+ // Safety: Was the class already loaded by a previous call?
+ if (class_exists($class, FALSE))
+ {
+ // Before we deem this to be a duplicate request, let's see
+ // if a custom object name is being supplied. If so, we'll
+ // return a new instance of the object
+ if ($object_name !== NULL)
{
- // Before we deem this to be a duplicate request, let's see
- // if a custom object name is being supplied. If so, we'll
- // return a new instance of the object
- if ($object_name !== NULL)
+ $CI =& get_instance();
+ if ( ! isset($CI->$object_name))
{
- $CI =& get_instance();
- if ( ! isset($CI->$object_name))
- {
- return $this->_ci_init_class($class, '', $params, $object_name);
- }
+ return $this->_ci_init_class($class, '', $params, $object_name);
}
-
- $is_duplicate = TRUE;
- log_message('debug', $class.' class already loaded. Second attempt ignored.');
- return;
}
- include_once($filepath);
- $this->_ci_loaded_files[] = $filepath;
- return $this->_ci_init_class($class, '', $params, $object_name);
+ log_message('debug', $class.' class already loaded. Second attempt ignored.');
+ return;
+ }
+ // Does the file exist? No? Bummer...
+ elseif ( ! file_exists($filepath))
+ {
+ continue;
}
- } // END FOREACH
+
+ include_once($filepath);
+ return $this->_ci_init_class($class, '', $params, $object_name);
+ }
// One last attempt. Maybe the library is in a subdirectory, but it wasn't specified?
if ($subdir === '')
{
- $path = strtolower($class).'/'.$class;
- return $this->_ci_load_class($path, $params, $object_name);
- }
- elseif (ucfirst($subdir) != $subdir)
- {
- // Lowercase subdir failed - retry capitalized
- $path = ucfirst($subdir).$class;
- return $this->_ci_load_class($path, $params, $object_name);
+ return $this->_ci_load_class($class.'/'.$class, $params, $object_name);
}
// If we got this far we were unable to find the requested class.
- // We do not issue errors if the load call failed due to a duplicate request
- if ($is_duplicate === FALSE)
- {
- log_message('error', 'Unable to load the requested class: '.$class);
- show_error('Unable to load the requested class: '.$class);
- }
+ log_message('error', 'Unable to load the requested class: '.$class);
+ show_error('Unable to load the requested class: '.$class);
}
// --------------------------------------------------------------------
@@ -1089,12 +1065,12 @@ class CI_Loader {
// We test for both uppercase and lowercase, for servers that
// are case-sensitive with regard to file names. Check for environment
// first, global next
- if (defined('ENVIRONMENT') && file_exists($path.'config/'.ENVIRONMENT.'/'.strtolower($class).'.php'))
+ if (file_exists($path.'config/'.ENVIRONMENT.'/'.strtolower($class).'.php'))
{
include($path.'config/'.ENVIRONMENT.'/'.strtolower($class).'.php');
break;
}
- elseif (defined('ENVIRONMENT') && file_exists($path.'config/'.ENVIRONMENT.'/'.ucfirst(strtolower($class)).'.php'))
+ elseif (file_exists($path.'config/'.ENVIRONMENT.'/'.ucfirst(strtolower($class)).'.php'))
{
include($path.'config/'.ENVIRONMENT.'/'.ucfirst(strtolower($class)).'.php');
break;
@@ -1115,11 +1091,11 @@ class CI_Loader {
if ($prefix === '')
{
- if (class_exists('CI_'.$class))
+ if (class_exists('CI_'.$class, FALSE))
{
$name = 'CI_'.$class;
}
- elseif (class_exists(config_item('subclass_prefix').$class))
+ elseif (class_exists(config_item('subclass_prefix').$class, FALSE))
{
$name = config_item('subclass_prefix').$class;
}
@@ -1134,7 +1110,7 @@ class CI_Loader {
}
// Is the class name valid?
- if ( ! class_exists($name))
+ if ( ! class_exists($name, FALSE))
{
log_message('error', 'Non-existent class: '.$name);
show_error('Non-existent class: '.$name);
@@ -1180,7 +1156,7 @@ class CI_Loader {
*/
protected function _ci_autoloader()
{
- if (defined('ENVIRONMENT') && file_exists(APPPATH.'config/'.ENVIRONMENT.'/autoload.php'))
+ if (file_exists(APPPATH.'config/'.ENVIRONMENT.'/autoload.php'))
{
include(APPPATH.'config/'.ENVIRONMENT.'/autoload.php');
}
diff --git a/system/core/Log.php b/system/core/Log.php
index cd3c17e1e..a84d3dc22 100644
--- a/system/core/Log.php
+++ b/system/core/Log.php
@@ -73,6 +73,13 @@ class CI_Log {
protected $_date_fmt = 'Y-m-d H:i:s';
/**
+ * Filename extension
+ *
+ * @var string
+ */
+ protected $_file_ext;
+
+ /**
* Whether or not the logger can write to the log files
*
* @var bool
@@ -86,8 +93,10 @@ class CI_Log {
*/
protected $_levels = array('ERROR' => 1, 'DEBUG' => 2, 'INFO' => 3, 'ALL' => 4);
+ // --------------------------------------------------------------------
+
/**
- * Initialize Logging class
+ * Class constructor
*
* @return void
*/
@@ -96,6 +105,8 @@ class CI_Log {
$config =& get_config();
$this->_log_path = ($config['log_path'] !== '') ? $config['log_path'] : APPPATH.'logs/';
+ $this->_file_ext = (isset($config['log_file_extension']) && $config['log_file_extension'] !== '')
+ ? ltrim($config['log_file_extension'], '.') : 'php';
file_exists($this->_log_path) OR mkdir($this->_log_path, DIR_WRITE_MODE, TRUE);
@@ -147,13 +158,17 @@ class CI_Log {
return FALSE;
}
- $filepath = $this->_log_path.'log-'.date('Y-m-d').'.php';
- $message = '';
+ $filepath = $this->_log_path.'log-'.date('Y-m-d').'.'.$this->_file_ext;
+ $message = '';
if ( ! file_exists($filepath))
{
$newfile = TRUE;
- $message .= '<'."?php defined('BASEPATH') OR exit('No direct script access allowed'); ?".">\n\n";
+ // Only add protection to php files
+ if ($this->_file_ext === 'php')
+ {
+ $message .= "<?php defined('BASEPATH') OR exit('No direct script access allowed'); ?>\n\n";
+ }
}
if ( ! $fp = @fopen($filepath, FOPEN_WRITE_CREATE))
@@ -179,4 +194,4 @@ class CI_Log {
}
/* End of file Log.php */
-/* Location: ./system/libraries/Log.php */ \ No newline at end of file
+/* Location: ./system/core/Log.php */ \ No newline at end of file
diff --git a/system/core/Output.php b/system/core/Output.php
index 7898d1972..d4abe871d 100644
--- a/system/core/Output.php
+++ b/system/core/Output.php
@@ -395,7 +395,7 @@ class CI_Output {
global $BM, $CFG;
// Grab the super object if we can.
- if (class_exists('CI_Controller'))
+ if (class_exists('CI_Controller', FALSE))
{
$CI =& get_instance();
}
diff --git a/system/core/Router.php b/system/core/Router.php
index f284e29cc..bb0ce16bd 100644
--- a/system/core/Router.php
+++ b/system/core/Router.php
@@ -133,13 +133,14 @@ class CI_Router {
}
// Load the routes.php file.
- if (defined('ENVIRONMENT') && is_file(APPPATH.'config/'.ENVIRONMENT.'/routes.php'))
+ if (file_exists(APPPATH.'config/routes.php'))
{
- include(APPPATH.'config/'.ENVIRONMENT.'/routes.php');
+ include(APPPATH.'config/routes.php');
}
- elseif (is_file(APPPATH.'config/routes.php'))
+
+ if (file_exists(APPPATH.'config/'.ENVIRONMENT.'/routes.php'))
{
- include(APPPATH.'config/routes.php');
+ include(APPPATH.'config/'.ENVIRONMENT.'/routes.php');
}
$this->routes = (empty($route) OR ! is_array($route)) ? array() : $route;
diff --git a/system/core/Security.php b/system/core/Security.php
index a6cd14a5f..7aae54efc 100644
--- a/system/core/Security.php
+++ b/system/core/Security.php
@@ -576,7 +576,15 @@ class CI_Security {
}
$str = remove_invisible_characters($str, FALSE);
- return stripslashes(str_replace($bad, '', $str));
+
+ do
+ {
+ $old = $str;
+ $str = str_replace($bad, '', $str);
+ }
+ while ($old !== $str);
+
+ return stripslashes($str);
}
// ----------------------------------------------------------------
diff --git a/system/core/URI.php b/system/core/URI.php
index 9b31a646b..b2286f032 100644
--- a/system/core/URI.php
+++ b/system/core/URI.php
@@ -126,7 +126,7 @@ class CI_URI {
return;
}
- // As a last ditch effort lets try using the $_GET array
+ // As a last ditch effort let's try using the $_GET array
if (is_array($_GET) && count($_GET) === 1 && trim(key($_GET), '/') !== '')
{
$this->_set_uri_string(key($_GET));
diff --git a/system/database/DB.php b/system/database/DB.php
index f94685c51..83d973304 100644
--- a/system/database/DB.php
+++ b/system/database/DB.php
@@ -43,7 +43,7 @@ function &DB($params = '', $query_builder_override = NULL)
if (is_string($params) && strpos($params, '://') === FALSE)
{
// Is the config file in the environment folder?
- if (( ! defined('ENVIRONMENT') OR ! file_exists($file_path = APPPATH.'config/'.ENVIRONMENT.'/database.php'))
+ if ( ! file_exists($file_path = APPPATH.'config/'.ENVIRONMENT.'/database.php')
&& ! file_exists($file_path = APPPATH.'config/database.php'))
{
show_error('The configuration file database.php does not exist.');
@@ -149,7 +149,7 @@ function &DB($params = '', $query_builder_override = NULL)
if ( ! isset($query_builder) OR $query_builder === TRUE)
{
require_once(BASEPATH.'database/DB_query_builder.php');
- if ( ! class_exists('CI_DB'))
+ if ( ! class_exists('CI_DB', FALSE))
{
/**
* CI_DB
@@ -162,7 +162,7 @@ function &DB($params = '', $query_builder_override = NULL)
class CI_DB extends CI_DB_query_builder { }
}
}
- elseif ( ! class_exists('CI_DB'))
+ elseif ( ! class_exists('CI_DB', FALSE))
{
/**
* @ignore
diff --git a/system/database/DB_driver.php b/system/database/DB_driver.php
index cb2ef4ac8..6ae1d524d 100644
--- a/system/database/DB_driver.php
+++ b/system/database/DB_driver.php
@@ -625,7 +625,7 @@ abstract class CI_DB_driver {
// if transactions are enabled. If we don't call this here
// the error message will trigger an exit, causing the
// transactions to remain in limbo.
- $this->trans_complete();
+ $this->_trans_depth > 0 && $this->trans_complete();
// Display errors
return $this->display_error(array('Error Number: '.$error['code'], $error['message'], $sql));
@@ -1560,7 +1560,7 @@ abstract class CI_DB_driver {
*/
protected function _cache_init()
{
- if (class_exists('CI_DB_Cache'))
+ if (class_exists('CI_DB_Cache', FALSE))
{
if (is_object($this->CACHE))
{
diff --git a/system/database/DB_query_builder.php b/system/database/DB_query_builder.php
index ac377d996..85a233b50 100644
--- a/system/database/DB_query_builder.php
+++ b/system/database/DB_query_builder.php
@@ -937,7 +937,7 @@ abstract class CI_DB_query_builder extends CI_DB_driver {
$this->qb_where[] = array('condition' => $like_statement, 'escape' => $escape);
if ($this->qb_caching === TRUE)
{
- $this->qb_cache_where[] = $like_statement;
+ $this->qb_cache_where[] = array('condition' => $like_statement, 'escape' => $escape);
$this->qb_cache_exists[] = 'where';
}
}
@@ -2627,6 +2627,7 @@ abstract class CI_DB_query_builder extends CI_DB_driver {
$this->_reset_run(array(
'qb_set' => array(),
'qb_from' => array(),
+ 'qb_join' => array(),
'qb_where' => array(),
'qb_orderby' => array(),
'qb_keys' => array(),
diff --git a/system/database/drivers/mssql/mssql_result.php b/system/database/drivers/mssql/mssql_result.php
index ea3f8e4d1..b6e5f2b17 100644
--- a/system/database/drivers/mssql/mssql_result.php
+++ b/system/database/drivers/mssql/mssql_result.php
@@ -74,6 +74,7 @@ class CI_DB_mssql_result extends CI_DB_result {
public function list_fields()
{
$field_names = array();
+ mssql_field_seek($this->result_id, 0);
while ($field = mssql_fetch_field($this->result_id))
{
$field_names[] = $field->name;
diff --git a/system/database/drivers/mysql/mysql_result.php b/system/database/drivers/mysql/mysql_result.php
index 1ed2759b6..a2affcb58 100644
--- a/system/database/drivers/mysql/mysql_result.php
+++ b/system/database/drivers/mysql/mysql_result.php
@@ -89,6 +89,7 @@ class CI_DB_mysql_result extends CI_DB_result {
public function list_fields()
{
$field_names = array();
+ mysql_field_seek($this->result_id, 0);
while ($field = mysql_fetch_field($this->result_id))
{
$field_names[] = $field->name;
diff --git a/system/database/drivers/mysqli/mysqli_result.php b/system/database/drivers/mysqli/mysqli_result.php
index 4105f99f6..3fe05f9c5 100644
--- a/system/database/drivers/mysqli/mysqli_result.php
+++ b/system/database/drivers/mysqli/mysqli_result.php
@@ -74,6 +74,7 @@ class CI_DB_mysqli_result extends CI_DB_result {
public function list_fields()
{
$field_names = array();
+ $this->result_id->field_seek(0);
while ($field = $this->result_id->fetch_field())
{
$field_names[] = $field->name;
diff --git a/system/database/drivers/pdo/pdo_driver.php b/system/database/drivers/pdo/pdo_driver.php
index 34adf0f86..fa89661b1 100644
--- a/system/database/drivers/pdo/pdo_driver.php
+++ b/system/database/drivers/pdo/pdo_driver.php
@@ -49,13 +49,6 @@ class CI_DB_pdo_driver extends CI_DB {
public $dbdriver = 'pdo';
/**
- * Transaction enabled flag
- *
- * @var bool
- */
- public $trans_enabled = FALSE;
-
- /**
* PDO Options
*
* @var array
diff --git a/system/helpers/captcha_helper.php b/system/helpers/captcha_helper.php
index 83783324b..78e255a15 100644
--- a/system/helpers/captcha_helper.php
+++ b/system/helpers/captcha_helper.php
@@ -93,7 +93,7 @@ if ( ! function_exists('create_captcha'))
// Do we have a "word" yet?
// -----------------------------------
- if ($word === '')
+ if (empty($word))
{
$pool = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
$word = '';
@@ -102,6 +102,10 @@ if ( ! function_exists('create_captcha'))
$word .= $pool[mt_rand(0, $mt_rand_max)];
}
}
+ elseif ( ! is_string($word))
+ {
+ $word = (string) $word;
+ }
// -----------------------------------
// Determine angle and position
diff --git a/system/helpers/download_helper.php b/system/helpers/download_helper.php
index d7691cb61..daf59f51b 100644
--- a/system/helpers/download_helper.php
+++ b/system/helpers/download_helper.php
@@ -58,7 +58,7 @@ if ( ! function_exists('force_download'))
}
elseif ($data === NULL)
{
- if (@is_file($filename) && @file_exists($filename) && ($filesize = @filesize($filename)) !== FALSE)
+ if (@is_file($filename) && ($filesize = @filesize($filename)) !== FALSE)
{
$filepath = $filename;
$filename = explode('/', str_replace(DIRECTORY_SEPARATOR, '/', $filename));
diff --git a/system/helpers/form_helper.php b/system/helpers/form_helper.php
index f343b6c71..692909c79 100644
--- a/system/helpers/form_helper.php
+++ b/system/helpers/form_helper.php
@@ -228,13 +228,10 @@ if ( ! function_exists('form_upload'))
*/
function form_upload($data = '', $value = '', $extra = '')
{
- if ( ! is_array($data))
- {
- $data = array('name' => $data);
- }
-
+ $defaults = array('type' => 'file', 'name' => '');
+ is_array($data) OR $data = array('name' => $data);
$data['type'] = 'file';
- return form_input($data, $value, $extra);
+ return '<input '._parse_form_attributes($data, $defaults).$extra." />\n";
}
}
diff --git a/system/helpers/html_helper.php b/system/helpers/html_helper.php
index 2d474169b..80a27876f 100644
--- a/system/helpers/html_helper.php
+++ b/system/helpers/html_helper.php
@@ -238,26 +238,30 @@ if ( ! function_exists('doctype'))
*/
function doctype($type = 'xhtml1-strict')
{
- global $_doctypes;
+ static $doctypes;
- if ( ! is_array($_doctypes))
+ if ( ! is_array($doctypes))
{
- if (defined('ENVIRONMENT') && is_file(APPPATH.'config/'.ENVIRONMENT.'/doctypes.php'))
+ if (file_exists(APPPATH.'config/doctypes.php'))
{
- include(APPPATH.'config/'.ENVIRONMENT.'/doctypes.php');
+ include(APPPATH.'config/doctypes.php');
}
- elseif (is_file(APPPATH.'config/doctypes.php'))
+
+ if (file_exists(APPPATH.'config/'.ENVIRONMENT.'/doctypes.php'))
{
- include(APPPATH.'config/doctypes.php');
+ include(APPPATH.'config/'.ENVIRONMENT.'/doctypes.php');
}
- if ( ! is_array($_doctypes))
+ if (empty($_doctypes) OR ! is_array($_doctypes))
{
+ $doctypes = array();
return FALSE;
}
+
+ $doctypes = $_doctypes;
}
- return isset($_doctypes[$type]) ? $_doctypes[$type] : FALSE;
+ return isset($doctypes[$type]) ? $doctypes[$type] : FALSE;
}
}
diff --git a/system/helpers/smiley_helper.php b/system/helpers/smiley_helper.php
index 186b24ce9..d9a693493 100644
--- a/system/helpers/smiley_helper.php
+++ b/system/helpers/smiley_helper.php
@@ -213,16 +213,30 @@ if ( ! function_exists('_get_smiley_array'))
*/
function _get_smiley_array()
{
- if (defined('ENVIRONMENT') && file_exists(APPPATH.'config/'.ENVIRONMENT.'/smileys.php'))
- {
- include(APPPATH.'config/'.ENVIRONMENT.'/smileys.php');
- }
- elseif (file_exists(APPPATH.'config/smileys.php'))
+ static $_smileys;
+
+ if ( ! is_array($smileys))
{
- include(APPPATH.'config/smileys.php');
+ if (file_exists(APPPATH.'config/smileys.php'))
+ {
+ include(APPPATH.'config/smileys.php');
+ }
+
+ if (file_exists(APPPATH.'config/'.ENVIRONMENT.'/smileys.php'))
+ {
+ include(APPPATH.'config/'.ENVIRONMENT.'/smileys.php');
+ }
+
+ if (empty($smileys) OR ! is_array($smileys))
+ {
+ $_smileys = array();
+ return FALSE;
+ }
+
+ $_smileys = $smileys;
}
- return (isset($smileys) && is_array($smileys)) ? $smileys : FALSE;
+ return $_smileys;
}
}
diff --git a/system/helpers/text_helper.php b/system/helpers/text_helper.php
index 1c7eeaf5f..54db14f94 100644
--- a/system/helpers/text_helper.php
+++ b/system/helpers/text_helper.php
@@ -358,31 +358,35 @@ if ( ! function_exists('convert_accented_characters'))
/**
* Convert Accented Foreign Characters to ASCII
*
- * @param string the text string
+ * @param string $str Input string
* @return string
*/
function convert_accented_characters($str)
{
- global $foreign_characters;
+ static $_foreign_characters;
- if ( ! isset($foreign_characters) OR ! is_array($foreign_characters))
+ if ( ! is_array($_foreign_characters))
{
- if (defined('ENVIRONMENT') && is_file(APPPATH.'config/'.ENVIRONMENT.'/foreign_chars.php'))
+ if (file_exists(APPPATH.'config/foreign_chars.php'))
{
- include(APPPATH.'config/'.ENVIRONMENT.'/foreign_chars.php');
+ include(APPPATH.'config/foreign_chars.php');
}
- elseif (is_file(APPPATH.'config/foreign_chars.php'))
+
+ if (file_exists(APPPATH.'config/'.ENVIRONMENT.'/foreign_chars.php'))
{
- include(APPPATH.'config/foreign_chars.php');
+ include(APPPATH.'config/'.ENVIRONMENT.'/foreign_chars.php');
}
- if ( ! isset($foreign_characters) OR ! is_array($foreign_characters))
+ if (empty($foreign_characters) OR ! is_array($foreign_characters))
{
+ $_foreign_characters = array();
return $str;
}
+
+ $_foreign_characters = $foreign_characters;
}
- return preg_replace(array_keys($foreign_characters), array_values($foreign_characters), $str);
+ return preg_replace(array_keys($_foreign_characters), array_values($_foreign_characters), $str);
}
}
diff --git a/system/helpers/url_helper.php b/system/helpers/url_helper.php
index 9a0153542..d6bf7e2c9 100644
--- a/system/helpers/url_helper.php
+++ b/system/helpers/url_helper.php
@@ -384,22 +384,23 @@ if ( ! function_exists('auto_link'))
function auto_link($str, $type = 'both', $popup = FALSE)
{
// Find and replace any URLs.
- if ($type !== 'email' && preg_match_all('#\b(([\w-]+://?|www\.)[^\s()<>]+(?:\([\w\d]+\)|([^[:punct:]\s]|/)))#', $str, $matches, PREG_OFFSET_CAPTURE))
+ if ($type !== 'email' && preg_match_all('#(\w*://|www\.)[^\s()<>;]+\w#i', $str, $matches, PREG_OFFSET_CAPTURE | PREG_SET_ORDER))
{
// Set our target HTML if using popup links.
- $target = ($popup) ? 'target="_blank"' : '';
+ $target = ($popup) ? ' target="_blank"' : '';
// We process the links in reverse order (last -> first) so that
// the returned string offsets from preg_match_all() are not
// moved as we add more HTML.
- foreach (array_reverse($matches[0]) as $match)
+ foreach (array_reverse($matches) as $match)
{
- // $match is an array generated by the PREG_OFFSET_CAPTURE flag.
- // $match[0] is the matched string, $match[1] is the string offset.
-
- $anchor = anchor($match[0], '', $target);
-
- $str = substr_replace($str, $anchor, $match[1], strlen($match[0]));
+ // $match[0] is the matched string/link
+ // $match[1] is either a protocol prefix or 'www.'
+ //
+ // With PREG_OFFSET_CAPTURE, both of the above is an array,
+ // where the actual value is held in [0] and its offset at the [1] index.
+ $a = '<a href="'.(strpos($match[1][0], '/') ? '' : 'http://').$match[0][0].'"'.$target.'>'.$match[0][0].'</a>';
+ $str = substr_replace($str, $a, $match[0][1], strlen($match[0][0]));
}
}
diff --git a/system/language/english/form_validation_lang.php b/system/language/english/form_validation_lang.php
index 3fb007dd2..7c0277c25 100644
--- a/system/language/english/form_validation_lang.php
+++ b/system/language/english/form_validation_lang.php
@@ -37,6 +37,7 @@ $lang['form_validation_max_length'] = 'The {field} field cannot exceed {param}
$lang['form_validation_exact_length'] = 'The {field} field must be exactly {param} characters in length.';
$lang['form_validation_alpha'] = 'The {field} field may only contain alphabetical characters.';
$lang['form_validation_alpha_numeric'] = 'The {field} field may only contain alpha-numeric characters.';
+$lang['form_validation_alpha_numeric_spaces'] = 'The {field} field may only contain alpha-numeric characters and spaces.';
$lang['form_validation_alpha_dash'] = 'The {field} field may only contain alpha-numeric characters, underscores, and dashes.';
$lang['form_validation_numeric'] = 'The {field} field must contain only numbers.';
$lang['form_validation_is_numeric'] = 'The {field} field must contain only numeric characters.';
diff --git a/system/language/english/profiler_lang.php b/system/language/english/profiler_lang.php
index dfe034e79..0ed5f4cb0 100644
--- a/system/language/english/profiler_lang.php
+++ b/system/language/english/profiler_lang.php
@@ -46,6 +46,7 @@ $lang['profiler_no_memory'] = 'Memory Usage Unavailable';
$lang['profiler_no_profiles'] = 'No Profile data - all Profiler sections have been disabled.';
$lang['profiler_section_hide'] = 'Hide';
$lang['profiler_section_show'] = 'Show';
+$lang['profiler_seconds'] = 'seconds';
/* End of file profiler_lang.php */
/* Location: ./system/language/english/profiler_lang.php */ \ No newline at end of file
diff --git a/system/libraries/Cache/drivers/Cache_memcached.php b/system/libraries/Cache/drivers/Cache_memcached.php
index 8096b2650..246a7a264 100644
--- a/system/libraries/Cache/drivers/Cache_memcached.php
+++ b/system/libraries/Cache/drivers/Cache_memcached.php
@@ -182,11 +182,11 @@ class CI_Cache_memcached extends CI_Driver {
}
}
- if (class_exists('Memcached'))
+ if (class_exists('Memcached', FALSE))
{
$this->_memcached = new Memcached();
}
- elseif (class_exists('Memcache'))
+ elseif (class_exists('Memcache', FALSE))
{
$this->_memcached = new Memcache();
}
diff --git a/system/libraries/Cart.php b/system/libraries/Cart.php
index 8734d7774..b7b0697fb 100644
--- a/system/libraries/Cart.php
+++ b/system/libraries/Cart.php
@@ -95,7 +95,7 @@ class CI_Cart {
$config = is_array($params) ? $params : array();
// Load the Sessions class
- $this->CI->load->library('session', $config);
+ $this->CI->load->driver('session', $config);
// Grab the shopping cart array from the session table
$this->_cart_contents = $this->CI->session->userdata('cart_contents');
@@ -365,7 +365,7 @@ class CI_Cart {
*/
protected function _save_cart()
{
- // Lets add up the individual prices and set the cart sub-total
+ // Let's add up the individual prices and set the cart sub-total
$this->_cart_contents['total_items'] = $this->_cart_contents['cart_total'] = 0;
foreach ($this->_cart_contents as $key => $val)
{
diff --git a/system/libraries/Driver.php b/system/libraries/Driver.php
index bb7318991..ba15f81df 100644
--- a/system/libraries/Driver.php
+++ b/system/libraries/Driver.php
@@ -80,8 +80,7 @@ class CI_Driver_Library {
public function load_driver($child)
{
// Get CodeIgniter instance and subclass prefix
- $CI = get_instance();
- $prefix = (string) $CI->config->item('subclass_prefix');
+ $prefix = config_item('subclass_prefix');
if ( ! isset($this->lib_name))
{
@@ -102,11 +101,12 @@ class CI_Driver_Library {
}
// Get package paths and filename case variations to search
+ $CI = get_instance();
$paths = $CI->load->get_package_paths(TRUE);
// Is there an extension?
$class_name = $prefix.$child_name;
- $found = class_exists($class_name);
+ $found = class_exists($class_name, FALSE);
if ( ! $found)
{
// Check for subclass file
@@ -126,8 +126,8 @@ class CI_Driver_Library {
}
// Include both sources and mark found
- include($basepath);
- include($file);
+ include_once($basepath);
+ include_once($file);
$found = TRUE;
break;
}
@@ -139,8 +139,7 @@ class CI_Driver_Library {
{
// Use standard class name
$class_name = 'CI_'.$child_name;
- $found = class_exists($class_name);
- if ( ! $found)
+ if ( ! class_exists($class_name, FALSE))
{
// Check package paths
foreach ($paths as $path)
@@ -150,7 +149,7 @@ class CI_Driver_Library {
if (file_exists($file))
{
// Include source
- include($file);
+ include_once($file);
break;
}
}
@@ -158,9 +157,9 @@ class CI_Driver_Library {
}
// Did we finally find the class?
- if ( ! class_exists($class_name))
+ if ( ! class_exists($class_name, FALSE))
{
- if (class_exists($child_name))
+ if (class_exists($child_name, FALSE))
{
$class_name = $child_name;
}
diff --git a/system/libraries/Email.php b/system/libraries/Email.php
index 997757b0a..daa38484b 100644
--- a/system/libraries/Email.php
+++ b/system/libraries/Email.php
@@ -96,6 +96,13 @@ class CI_Email {
public $smtp_timeout = 5;
/**
+ * SMTP persistent connection
+ *
+ * @var bool
+ */
+ public $smtp_keepalive = FALSE;
+
+ /**
* SMTP Encryption
*
* @var string NULL, 'tls' or 'ssl'
@@ -403,6 +410,21 @@ class CI_Email {
// --------------------------------------------------------------------
/**
+ * Destructor - Releases Resources
+ *
+ * @return void
+ */
+ public function __destruct()
+ {
+ if (is_resource($this->_smtp_connect))
+ {
+ $this->_send_command('quit');
+ }
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
* Initialize preferences
*
* @param array
@@ -1183,8 +1205,11 @@ class CI_Email {
{
if ($this->protocol === 'mail')
{
- $this->_subject = $this->_headers['Subject'];
- unset($this->_headers['Subject']);
+ if (isset($this->_headers['Subject']))
+ {
+ $this->_subject = $this->_headers['Subject'];
+ unset($this->_headers['Subject']);
+ }
}
reset($this->_headers);
@@ -1824,7 +1849,15 @@ class CI_Email {
return FALSE;
}
- $this->_send_command('quit');
+ if ($this->smtp_keepalive)
+ {
+ $this->_send_command('reset');
+ }
+ else
+ {
+ $this->_send_command('quit');
+ }
+
return TRUE;
}
@@ -1837,6 +1870,11 @@ class CI_Email {
*/
protected function _smtp_connect()
{
+ if (is_resource($this->_smtp_connect))
+ {
+ return TRUE;
+ }
+
$ssl = ($this->smtp_crypto === 'ssl') ? 'ssl://' : NULL;
$this->_smtp_connect = fsockopen($ssl.$this->smtp_host,
@@ -1851,6 +1889,7 @@ class CI_Email {
return FALSE;
}
+ stream_set_timeout($this->_smtp_connect, $this->smtp_timeout);
$this->_set_error_message($this->_get_smtp_data());
if ($this->smtp_crypto === 'tls')
@@ -1924,6 +1963,11 @@ class CI_Email {
$this->_send_data('DATA');
$resp = 354;
break;
+ case 'reset':
+
+ $this->_send_data('RSET');
+ $resp = 250;
+ break;
case 'quit' :
$this->_send_data('QUIT');
@@ -1973,6 +2017,11 @@ class CI_Email {
$reply = $this->_get_smtp_data();
+ if (strpos($reply, '503') !== 0) // Already authenticated
+ {
+ return TRUE;
+ }
+
if (strpos($reply, '334') !== 0)
{
$this->_set_error_message('lang:email_failed_smtp_login', $reply);
diff --git a/system/libraries/Form_validation.php b/system/libraries/Form_validation.php
index bbd0b523e..172e799f6 100644
--- a/system/libraries/Form_validation.php
+++ b/system/libraries/Form_validation.php
@@ -356,7 +356,7 @@ class CI_Form_validation {
*/
public function error_string($prefix = '', $suffix = '')
{
- // No errrors, validation passes!
+ // No errors, validation passes!
if (count($this->_error_array) === 0)
{
return '';
@@ -517,7 +517,7 @@ class CI_Form_validation {
{
if (isset($_POST[$row['field']]))
{
- $_POST[$row['field']] = $this->prep_for_form($row['postdata']);
+ $_POST[$row['field']] = $row['postdata'];
}
}
else
@@ -543,14 +543,14 @@ class CI_Form_validation {
$array = array();
foreach ($row['postdata'] as $k => $v)
{
- $array[$k] = $this->prep_for_form($v);
+ $array[$k] = $v;
}
$post_ref = $array;
}
else
{
- $post_ref = $this->prep_for_form($row['postdata']);
+ $post_ref = $row['postdata'];
}
}
}
@@ -1232,6 +1232,19 @@ class CI_Form_validation {
// --------------------------------------------------------------------
/**
+ * Alpha-numeric w/ spaces
+ *
+ * @param string
+ * @return bool
+ */
+ public function alpha_numeric_spaces($str)
+ {
+ return (bool) preg_match('/^[A-Z0-9 ]+$/i', $str);
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
* Alpha-numeric with underscores and dashes
*
* @param string
diff --git a/system/libraries/Image_lib.php b/system/libraries/Image_lib.php
index 6d5493696..0cec43fc4 100644
--- a/system/libraries/Image_lib.php
+++ b/system/libraries/Image_lib.php
@@ -810,7 +810,7 @@ class CI_Image_lib {
imagedestroy($dst_img);
imagedestroy($src_img);
- // Set the file to 777
+ // Set the file to 666
@chmod($this->full_dst_path, FILE_WRITE_MODE);
return TRUE;
diff --git a/system/libraries/Javascript.php b/system/libraries/Javascript.php
index 7f1d85511..773a58384 100644
--- a/system/libraries/Javascript.php
+++ b/system/libraries/Javascript.php
@@ -69,7 +69,7 @@ class CI_Javascript {
$this->CI =& get_instance();
// load the requested js library
- $this->CI->load->library('javascript/'.$js_library_driver, array('autoload' => $autoload));
+ $this->CI->load->library('Javascript/'.$js_library_driver, array('autoload' => $autoload));
// make js to refer to current library
$this->js =& $this->CI->$js_library_driver;
diff --git a/system/libraries/javascript/Jquery.php b/system/libraries/Javascript/Jquery.php
index b6e0434b2..b6e0434b2 100644
--- a/system/libraries/javascript/Jquery.php
+++ b/system/libraries/Javascript/Jquery.php
diff --git a/system/libraries/javascript/index.html b/system/libraries/Javascript/index.html
index c942a79ce..c942a79ce 100644
--- a/system/libraries/javascript/index.html
+++ b/system/libraries/Javascript/index.html
diff --git a/system/libraries/Migration.php b/system/libraries/Migration.php
index fd915c382..cc6fe48f0 100644
--- a/system/libraries/Migration.php
+++ b/system/libraries/Migration.php
@@ -104,8 +104,8 @@ class CI_Migration {
*/
public function __construct($config = array())
{
- # Only run this constructor on main library load
- if (get_parent_class($this) !== FALSE)
+ // Only run this constructor on main library load
+ if ( ! in_array(get_class($this), array('CI_Migration', config_item('subclass_prefix').'Migration'), TRUE))
{
return;
}
@@ -228,7 +228,7 @@ class CI_Migration {
$class = 'Migration_'.ucfirst(strtolower($this->_get_migration_name(basename($file, '.php'))));
// Validate the migration file structure
- if ( ! class_exists($class))
+ if ( ! class_exists($class, FALSE))
{
$this->_error_string = sprintf($this->lang->line('migration_class_doesnt_exist'), $class);
return FALSE;
diff --git a/system/libraries/Pagination.php b/system/libraries/Pagination.php
index d139980d8..10fb29dbd 100644
--- a/system/libraries/Pagination.php
+++ b/system/libraries/Pagination.php
@@ -133,7 +133,7 @@ class CI_Pagination {
*
* @var int
*/
- protected $uri_segment = 3;
+ protected $uri_segment = 0;
/**
* Full tag open
@@ -318,11 +318,9 @@ class CI_Pagination {
*/
public function initialize($params = array())
{
- $attributes = array();
-
if (isset($params['attributes']) && is_array($params['attributes']))
{
- $attributes = $params['attributes'];
+ $this->_parse_attributes($params['attributes']);
unset($params['attributes']);
}
@@ -334,8 +332,6 @@ class CI_Pagination {
unset($params['anchor_class']);
}
- $this->_parse_attributes($attributes);
-
if (count($params) > 0)
{
foreach ($params as $key => $val)
@@ -372,45 +368,119 @@ class CI_Pagination {
return '';
}
- // Set the base page index for starting page number
- $base_page = ($this->use_page_numbers) ? 1 : 0;
+ // Check the user defined number of links.
+ $this->num_links = (int) $this->num_links;
+
+ if ($this->num_links < 1)
+ {
+ show_error('Your number of links must be a positive number.');
+ }
- // Determine the current page number.
$CI =& get_instance();
- // See if we are using a prefix or suffix on links
- if ($this->prefix !== '' OR $this->suffix !== '')
+ // Keep any existing query string items.
+ // Note: Has nothing to do with any other query string option.
+ if ($this->reuse_query_string === TRUE)
{
- $this->cur_page = (int) str_replace(array($this->prefix, $this->suffix), '', $CI->uri->rsegment($this->uri_segment));
+ $get = $CI->input->get();
+
+ // Unset the controll, method, old-school routing options
+ unset($get['c'], $get['m'], $get[$this->query_string_segment]);
+ }
+ else
+ {
+ $get = array();
}
+ // Put together our base and first URLs.
+ $this->base_url = trim($this->base_url);
+
+ $query_string = '';
+ $query_string_sep = (strpos($this->base_url, '?') === FALSE) ? '?' : '&amp;';
+
+ // Are we using query strings?
if ($CI->config->item('enable_query_strings') === TRUE OR $this->page_query_string === TRUE)
{
- if ($CI->input->get($this->query_string_segment) != $base_page)
+ // If a custom first_url hasn't been specified, we'll create one from
+ // the base_url, but without the page item.
+ if ($this->first_url === '')
{
- $this->cur_page = (int) $CI->input->get($this->query_string_segment);
+ $this->first_url = $this->base_url;
+
+ // If we saved any GET items earlier, make sure they're appended.
+ if ( ! empty($get))
+ {
+ $this->first_url .= $query_string_sep.http_build_query($get);
+ }
}
+
+ // Add the page segment to the end of the query string, where the
+ // page number will be appended.
+ $this->base_url .= $query_string_sep.http_build_query(array_merge($get, array($this->query_string_segment => '')));
}
- elseif ( ! $this->cur_page && $CI->uri->segment($this->uri_segment) !== $base_page)
+ else
{
- $this->cur_page = (int) $CI->uri->rsegment($this->uri_segment);
+ // Standard segment mode.
+ // Generate our saved query string to append later after the page number.
+ if ( ! empty($get))
+ {
+ $query_string = $query_string_sep.http_build_query($get);
+ $this->suffix .= $query_string;
+ }
+
+ // Does the base_url have the query string in it?
+ // If we're supposed to save it, remove it so we can append it later.
+ if ($this->reuse_query_string === TRUE && ($base_query_pos = strpos($this->base_url, '?')) !== FALSE)
+ {
+ $this->base_url = substr($this->base_url, 0, $base_query_pos);
+ }
+
+ if ($this->first_url === '')
+ {
+ $this->first_url = $this->base_url.$query_string;
+ }
+
+ $this->base_url = rtrim($this->base_url, '/').'/';
}
- // Set current page to 1 if it's not valid or if using page numbers instead of offset
- if ( ! is_numeric($this->cur_page) OR ($this->use_page_numbers && $this->cur_page === 0))
+ // Determine the current page number.
+ $base_page = ($this->use_page_numbers) ? 1 : 0;
+
+ // Are we using query strings?
+ if ($CI->config->item('enable_query_strings') === TRUE OR $this->page_query_string === TRUE)
{
- $this->cur_page = $base_page;
+ $this->cur_page = $CI->input->get($this->query_string_segment);
}
+ else
+ {
+ // Default to the last segment number if one hasn't been defined.
+ if ($this->uri_segment === 0)
+ {
+ $this->uri_segment = count($CI->uri->segment_array());
+ }
- $this->num_links = (int) $this->num_links;
+ $this->cur_page = $CI->uri->segment($this->uri_segment);
- if ($this->num_links < 1)
+ // Remove any specified prefix/suffix from the segment.
+ if ($this->prefix !== '' OR $this->suffix !== '')
+ {
+ $this->cur_page = str_replace(array($this->prefix, $this->suffix), '', $this->cur_page);
+ }
+ }
+
+ // If something isn't quite right, back to the default base page.
+ if ( ! ctype_digit($this->cur_page) OR ($this->use_page_numbers && (int) $this->cur_page === 0))
{
- show_error('Your number of links must be a positive number.');
+ $this->cur_page = $base_page;
+ }
+ else
+ {
+ // Make sure we're using integers for comparisons later.
+ $this->cur_page = (int) $this->cur_page;
}
// Is the page number beyond the result range?
- // If so we show the last page
+ // If so, we show the last page.
if ($this->use_page_numbers)
{
if ($this->cur_page > $num_pages)
@@ -425,80 +495,47 @@ class CI_Pagination {
$uri_page_number = $this->cur_page;
+ // If we're using offset instead of page numbers, convert it
+ // to a page number, so we can generate the surrounding number links.
if ( ! $this->use_page_numbers)
{
$this->cur_page = (int) floor(($this->cur_page/$this->per_page) + 1);
}
// Calculate the start and end numbers. These determine
- // which number to start and end the digit links with
+ // which number to start and end the digit links with.
$start = (($this->cur_page - $this->num_links) > 0) ? $this->cur_page - ($this->num_links - 1) : 1;
$end = (($this->cur_page + $this->num_links) < $num_pages) ? $this->cur_page + $this->num_links : $num_pages;
- // Is pagination being used over GET or POST? If get, add a per_page query
- // string. If post, add a trailing slash to the base URL if needed
- if ($CI->config->item('enable_query_strings') === TRUE OR $this->page_query_string === TRUE)
- {
- $segment = (strpos($this->base_url, '?')) ? '&amp;' : '?';
- $this->base_url = rtrim($this->base_url).$segment.$this->query_string_segment.'=';
- }
- else
- {
- $this->base_url = rtrim($this->base_url, '/') .'/';
- }
-
// And here we go...
$output = '';
- $query_string = '';
-
- // Add anything in the query string back to the links
- // Note: Nothing to do with query_string_segment or any other query string options
- if ($this->reuse_query_string === TRUE)
- {
- $get = $CI->input->get();
-
- // Unset the controll, method, old-school routing options
- unset($get['c'], $get['m'], $get[$this->query_string_segment]);
- if ( ! empty($get))
- {
- // Put everything else onto the end
- $query_string = (strpos($this->base_url, '?') !== FALSE ? '&amp;' : '?')
- .http_build_query($get, '', '&amp;');
-
- // Add this after the suffix to put it into more links easily
- $this->suffix .= $query_string;
- }
- }
-
- // Render the "First" link
+ // Render the "First" link.
if ($this->first_link !== FALSE && $this->cur_page > ($this->num_links + 1))
{
- $first_url = ($this->first_url === '') ? $this->base_url : $this->first_url;
-
- // Take the general parameters, and squeeze this pagination-page attr in there for JS fw's
+ // Take the general parameters, and squeeze this pagination-page attr in for JS frameworks.
$attributes = sprintf('%s %s="%d"', $this->_attributes, $this->data_page_attr, 1);
- $output .= $this->first_tag_open.'<a href="'.$first_url.'"'.$attributes.$this->_attr_rel('start').'>'
+ $output .= $this->first_tag_open.'<a href="'.$this->first_url.'"'.$attributes.$this->_attr_rel('start').'>'
.$this->first_link.'</a>'.$this->first_tag_close;
}
- // Render the "previous" link
+ // Render the "Previous" link.
if ($this->prev_link !== FALSE && $this->cur_page !== 1)
{
$i = ($this->use_page_numbers) ? $uri_page_number - 1 : $uri_page_number - $this->per_page;
- // Take the general parameters, and squeeze this pagination-page attr in there for JS fw's
$attributes = sprintf('%s %s="%d"', $this->_attributes, $this->data_page_attr, (int) $i);
- if ($i === $base_page && $this->first_url !== '')
+ if ($i === $base_page)
{
- $output .= $this->prev_tag_open.'<a href="'.$this->first_url.$query_string.'"'.$attributes.$this->_attr_rel('prev').'>'
+ // First page
+ $output .= $this->prev_tag_open.'<a href="'.$this->first_url.'"'.$attributes.$this->_attr_rel('prev').'>'
.$this->prev_link.'</a>'.$this->prev_tag_close;
}
else
{
- $append = ($i === $base_page) ? $query_string : $this->prefix.$i.$this->suffix;
+ $append = $this->prefix.$i.$this->suffix;
$output .= $this->prev_tag_open.'<a href="'.$this->base_url.$append.'"'.$attributes.$this->_attr_rel('prev').'>'
.$this->prev_link.'</a>'.$this->prev_tag_close;
}
@@ -513,29 +550,26 @@ class CI_Pagination {
{
$i = ($this->use_page_numbers) ? $loop : ($loop * $this->per_page) - $this->per_page;
- // Take the general parameters, and squeeze this pagination-page attr in there for JS fw's
$attributes = sprintf('%s %s="%d"', $this->_attributes, $this->data_page_attr, (int) $i);
if ($i >= $base_page)
{
if ($this->cur_page === $loop)
{
- $output .= $this->cur_tag_open.$loop.$this->cur_tag_close; // Current page
+ // Current page
+ $output .= $this->cur_tag_open.$loop.$this->cur_tag_close;
+ }
+ elseif ($i === $base_page)
+ {
+ // First page
+ $output .= $this->num_tag_open.'<a href="'.$this->first_url.'"'.$attributes.$this->_attr_rel('start').'>'
+ .$loop.'</a>'.$this->num_tag_close;
}
else
{
- $n = ($i === $base_page) ? '' : $i;
- if ($n === '' && ! empty($this->first_url))
- {
- $output .= $this->num_tag_open.'<a href="'.$this->first_url.$query_string.'"'.$attributes.$this->_attr_rel('start').'>'
- .$loop.'</a>'.$this->num_tag_close;
- }
- else
- {
- $append = ($n === '') ? $query_string : $this->prefix.$n.$this->suffix;
- $output .= $this->num_tag_open.'<a href="'.$this->base_url.$append.'"'.$attributes.$this->_attr_rel('start').'>'
- .$loop.'</a>'.$this->num_tag_close;
- }
+ $append = $this->prefix.$i.$this->suffix;
+ $output .= $this->num_tag_open.'<a href="'.$this->base_url.$append.'"'.$attributes.$this->_attr_rel('start').'>'
+ .$loop.'</a>'.$this->num_tag_close;
}
}
}
@@ -546,7 +580,6 @@ class CI_Pagination {
{
$i = ($this->use_page_numbers) ? $this->cur_page + 1 : $this->cur_page * $this->per_page;
- // Take the general parameters, and squeeze this pagination-page attr in there for JS fw's
$attributes = sprintf('%s %s="%d"', $this->_attributes, $this->data_page_attr, (int) $i);
$output .= $this->next_tag_open.'<a href="'.$this->base_url.$this->prefix.$i.$this->suffix.'"'.$attributes
@@ -558,7 +591,6 @@ class CI_Pagination {
{
$i = ($this->use_page_numbers) ? $num_pages : ($num_pages * $this->per_page) - $this->per_page;
- // Take the general parameters, and squeeze this pagination-page attr in there for JS fw's
$attributes = sprintf('%s %s="%d"', $this->_attributes, $this->data_page_attr, (int) $i);
$output .= $this->last_tag_open.'<a href="'.$this->base_url.$this->prefix.$i.$this->suffix.'"'.$attributes.'>'
diff --git a/system/libraries/Profiler.php b/system/libraries/Profiler.php
index e93239901..470688fdc 100644
--- a/system/libraries/Profiler.php
+++ b/system/libraries/Profiler.php
@@ -238,6 +238,7 @@ class CI_Profiler {
foreach ($dbs as $name => $db)
{
$hide_queries = (count($db->queries) > $this->_query_toggle_count) ? ' display:none' : '';
+ $total_time = number_format(array_sum($db->query_times), 4).' '.$this->CI->lang->line('profiler_seconds');
$show_hide_js = '(<span style="cursor: pointer;" onclick="var s=document.getElementById(\'ci_profiler_queries_db_'.$count.'\').style;s.display=s.display==\'none\'?\'\':\'none\';this.innerHTML=this.innerHTML==\''.$this->CI->lang->line('profiler_section_hide').'\'?\''.$this->CI->lang->line('profiler_section_show').'\':\''.$this->CI->lang->line('profiler_section_hide').'\';">'.$this->CI->lang->line('profiler_section_hide').'</span>)';
@@ -250,7 +251,7 @@ class CI_Profiler {
."\n"
.'<legend style="color:#0000FF;">&nbsp;&nbsp;'.$this->CI->lang->line('profiler_database')
.':&nbsp; '.$db->database.' ('.$name.')&nbsp;&nbsp;&nbsp;'.$this->CI->lang->line('profiler_queries')
- .': '.count($db->queries).'&nbsp;&nbsp;'.$show_hide_js."</legend>\n\n\n"
+ .': '.count($db->queries).' ('.$total_time.')&nbsp;&nbsp;'.$show_hide_js."</legend>\n\n\n"
.'<table style="width:100%;'.$hide_queries.'" id="ci_profiler_queries_db_'.$count."\">\n";
if (count($db->queries) === 0)
diff --git a/system/libraries/Session/drivers/Session_cookie.php b/system/libraries/Session/drivers/Session_cookie.php
index 474641642..057e5a1d1 100644
--- a/system/libraries/Session/drivers/Session_cookie.php
+++ b/system/libraries/Session/drivers/Session_cookie.php
@@ -602,6 +602,9 @@ class CI_Session_cookie extends CI_Session_driver {
$set['user_data'] = $this->_serialize($userdata);
}
+ // Reset query builder values.
+ $this->CI->db->reset_query();
+
// Run the update query
// Any time we change the session id, it gets updated immediately,
// so our where clause below is always safe
@@ -805,7 +808,7 @@ class CI_Session_cookie extends CI_Session_driver {
{
if (is_string($val))
{
- $val= str_replace('{{slash}}', '\\', $val);
+ $val = str_replace('{{slash}}', '\\', $val);
}
}
diff --git a/system/libraries/Upload.php b/system/libraries/Upload.php
index 96bb17edc..1c14f99ed 100644
--- a/system/libraries/Upload.php
+++ b/system/libraries/Upload.php
@@ -430,7 +430,7 @@ class CI_Upload {
}
else
{
- // An extension was provided, lets have it!
+ // An extension was provided, let's have it!
$this->file_ext = $this->get_extension($this->_file_name_override);
}
@@ -463,7 +463,8 @@ class CI_Upload {
}
// Sanitize the file name for security
- $this->file_name = $this->clean_file_name($this->file_name);
+ $CI =& get_instance();
+ $this->file_name = $CI->security->sanitize_filename($this->file_name);
// Truncate the file name if it's too long
if ($this->max_filename > 0)
@@ -971,46 +972,6 @@ class CI_Upload {
// --------------------------------------------------------------------
/**
- * Clean the file name for security
- *
- * @param string $filename
- * @return string
- */
- public function clean_file_name($filename)
- {
- $bad = array(
- '<!--', '-->',
- "'", '"',
- '<', '>',
- '&', '$',
- '=',
- ';',
- '?',
- '/',
- '!',
- '#',
- '%20',
- '%22',
- '%3c', // <
- '%253c', // <
- '%3e', // >
- '%0e', // >
- '%28', // (
- '%29', // )
- '%2528', // (
- '%26', // &
- '%24', // $
- '%3f', // ?
- '%3b', // ;
- '%3d' // =
- );
-
- return stripslashes(str_replace($bad, '', $filename));
- }
-
- // --------------------------------------------------------------------
-
- /**
* Limit the File Name Length
*
* @param string $filename
@@ -1089,7 +1050,7 @@ class CI_Upload {
// <a, <body, <head, <html, <img, <plaintext, <pre, <script, <table, <title
// title is basically just in SVG, but we filter it anyhow
- // if its an image or no "triggers" detected in the first 256 bytes - we're good
+ // if it's an image or no "triggers" detected in the first 256 bytes - we're good
return ! preg_match('/<(a|body|head|html|img|plaintext|pre|script|table|title)[\s>]/i', $opening_bytes);
}
@@ -1251,7 +1212,7 @@ class CI_Upload {
* Notes:
* - the DIRECTORY_SEPARATOR comparison ensures that we're not on a Windows system
* - many system admins would disable the exec(), shell_exec(), popen() and similar functions
- * due to security concerns, hence the function_exists() checks
+ * due to security concerns, hence the function_usable() checks
*/
if (DIRECTORY_SEPARATOR !== '\\')
{
@@ -1262,7 +1223,7 @@ class CI_Upload {
if (function_usable('exec'))
{
/* This might look confusing, as $mime is being populated with all of the output when set in the second parameter.
- * However, we only neeed the last line, which is the actual return value of exec(), and as such - it overwrites
+ * However, we only need the last line, which is the actual return value of exec(), and as such - it overwrites
* anything that could already be set for $mime previously. This effectively makes the second parameter a dummy
* value, which is only put to allow us to get the return status code.
*/
diff --git a/system/libraries/User_agent.php b/system/libraries/User_agent.php
index 1f4b2fa52..2f6f81909 100644
--- a/system/libraries/User_agent.php
+++ b/system/libraries/User_agent.php
@@ -175,15 +175,18 @@ class CI_User_agent {
*/
protected function _load_agent_file()
{
- if (defined('ENVIRONMENT') && is_file(APPPATH.'config/'.ENVIRONMENT.'/user_agents.php'))
+ if (($found = file_exists(APPPATH.'config/user_agents.php')))
{
- include(APPPATH.'config/'.ENVIRONMENT.'/user_agents.php');
+ include(APPPATH.'config/user_agents.php');
}
- elseif (is_file(APPPATH.'config/user_agents.php'))
+
+ if (file_exists(APPPATH.'config/'.ENVIRONMENT.'/user_agents.php'))
{
- include(APPPATH.'config/user_agents.php');
+ include(APPPATH.'config/'.ENVIRONMENT.'/user_agents.php');
+ $found = TRUE;
}
- else
+
+ if ($found !== TRUE)
{
return FALSE;
}
diff --git a/system/libraries/Xmlrpcs.php b/system/libraries/Xmlrpcs.php
index 465a1967b..2d2e7f13b 100644
--- a/system/libraries/Xmlrpcs.php
+++ b/system/libraries/Xmlrpcs.php
@@ -31,7 +31,7 @@ if ( ! function_exists('xml_parser_create'))
show_error('Your PHP installation does not support XML');
}
-if ( ! class_exists('CI_Xmlrpc'))
+if ( ! class_exists('CI_Xmlrpc', FALSE))
{
show_error('You must load the Xmlrpc class before loading the Xmlrpcs class in order to create a server.');
}