summaryrefslogtreecommitdiffstats
path: root/system
diff options
context:
space:
mode:
Diffstat (limited to 'system')
-rw-r--r--system/core/Lang.php33
-rw-r--r--system/core/Loader.php13
-rw-r--r--system/core/Output.php74
-rw-r--r--system/database/DB_forge.php17
-rw-r--r--system/database/DB_query_builder.php5
-rw-r--r--system/database/DB_utility.php2
-rw-r--r--system/database/drivers/cubrid/cubrid_forge.php15
-rw-r--r--system/database/drivers/mysql/mysql_forge.php15
-rw-r--r--system/database/drivers/mysqli/mysqli_forge.php15
-rw-r--r--system/database/drivers/pdo/subdrivers/pdo_cubrid_forge.php15
-rw-r--r--system/database/drivers/pdo/subdrivers/pdo_mysql_forge.php15
-rw-r--r--system/helpers/language_helper.php11
-rw-r--r--system/libraries/Cache/Cache.php12
-rw-r--r--system/libraries/Driver.php118
-rw-r--r--system/libraries/Email.php25
-rw-r--r--system/libraries/Form_validation.php44
-rw-r--r--system/libraries/Migration.php14
-rw-r--r--system/libraries/Session/Session.php20
-rw-r--r--system/libraries/Session/drivers/Session_cookie.php2
19 files changed, 363 insertions, 102 deletions
diff --git a/system/core/Lang.php b/system/core/Lang.php
index 5d824cee6..9e6f43716 100644
--- a/system/core/Lang.php
+++ b/system/core/Lang.php
@@ -96,29 +96,40 @@ class CI_Lang {
return;
}
- // Determine where the language file is and load it
- if ($alt_path !== '' && file_exists($alt_path.'language/'.$idiom.'/'.$langfile))
+ // Load the base file, so any others found can override it
+ $basepath = BASEPATH.'language/'.$idiom.'/'.$langfile;
+ if (($found = file_exists($basepath)) === TRUE)
{
- include($alt_path.'language/'.$idiom.'/'.$langfile);
+ include($basepath);
+ }
+
+ // Do we have an alternative path to look in?
+ if ($alt_path !== '')
+ {
+ $alt_path .= 'language/'.$idiom.'/'.$langfile;
+ if (file_exists($alt_path))
+ {
+ include($alt_path);
+ $found = TRUE;
+ }
}
else
{
- $found = FALSE;
-
foreach (get_instance()->load->get_package_paths(TRUE) as $package_path)
{
- if (file_exists($package_path.'language/'.$idiom.'/'.$langfile))
+ $package_path .= 'language/'.$idiom.'/'.$langfile;
+ if ($basepath !== $package_path && file_exists($package_path))
{
- include($package_path.'language/'.$idiom.'/'.$langfile);
+ include($package_path);
$found = TRUE;
break;
}
}
+ }
- if ($found !== TRUE)
- {
- show_error('Unable to load the requested language file: language/'.$idiom.'/'.$langfile);
- }
+ if ($found !== TRUE)
+ {
+ show_error('Unable to load the requested language file: language/'.$idiom.'/'.$langfile);
}
if ( ! isset($lang) OR ! is_array($lang))
diff --git a/system/core/Loader.php b/system/core/Loader.php
index 1e6eafe8a..651507470 100644
--- a/system/core/Loader.php
+++ b/system/core/Loader.php
@@ -669,6 +669,12 @@ class CI_Loader {
return FALSE;
}
+ if ( ! class_exists('CI_Driver_Library'))
+ {
+ // We aren't instantiating an object here, just making the base class available
+ require BASEPATH.'libraries/Driver.php';
+ }
+
// We can save the loader some time since Drivers will *always* be in a subfolder,
// and typically identically named to the library
if ( ! strpos($library, '/'))
@@ -949,13 +955,6 @@ class CI_Loader {
// Get the filename from the path
$class = substr($class, $last_slash);
-
- // Check for match and driver base class
- if (strtolower(trim($subdir, '/')) == strtolower($class) && ! class_exists('CI_Driver_Library'))
- {
- // We aren't instantiating an object here, just making the base class available
- require BASEPATH.'libraries/Driver.php';
- }
}
// We'll test for both lowercase and capitalized versions of the file name
diff --git a/system/core/Output.php b/system/core/Output.php
index 6312ccd86..98deff55c 100644
--- a/system/core/Output.php
+++ b/system/core/Output.php
@@ -256,7 +256,7 @@ class CI_Output {
{
for ($i = 0, $c = count($this->headers); $i < $c; $i++)
{
- if (sscanf($this->headers[$i][0], 'Content-Type: %s', $content_type) === 1)
+ if (sscanf($this->headers[$i][0], 'Content-Type: %[^;]', $content_type) === 1)
{
return $content_type;
}
@@ -268,6 +268,39 @@ class CI_Output {
// --------------------------------------------------------------------
/**
+ * Get Header
+ *
+ * @param string $header_name
+ * @return string
+ */
+ public function get_header($header)
+ {
+ // Combine headers already sent with our batched headers
+ $headers = array_merge(
+ // We only need [x][0] from our multi-dimensional array
+ array_map('array_shift', $this->headers),
+ headers_list()
+ );
+
+ if (empty($headers) OR empty($header))
+ {
+ return NULL;
+ }
+
+ for ($i = 0, $c = count($headers); $i < $c; $i++)
+ {
+ if (strncasecmp($header, $headers[$i], $l = strlen($header)) === 0)
+ {
+ return trim(substr($headers[$i], $l+1));
+ }
+ }
+
+ return NULL;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
* Set HTTP Status Header
*
* As of version 1.7.2, this is an alias for common function
@@ -594,6 +627,45 @@ class CI_Output {
// --------------------------------------------------------------------
/**
+ * Delete cache
+ *
+ * @param string $uri URI string
+ * @return bool
+ */
+ public function delete_cache($uri = '')
+ {
+ $CI =& get_instance();
+ $cache_path = $CI->config->item('cache_path');
+ if ($cache_path === '')
+ {
+ $cache_path = APPPATH.'cache/';
+ }
+
+ if ( ! is_dir($cache_path))
+ {
+ log_message('error', 'Unable to find cache path: '.$cache_path);
+ return FALSE;
+ }
+
+ if (empty($uri))
+ {
+ $uri = $CI->uri->uri_string();
+ }
+
+ $cache_path .= md5($CI->config->item('base_url').$CI->config->item('index_page').$uri);
+
+ if ( ! @unlink($cache_path))
+ {
+ log_message('error', 'Unable to delete cache file for '.$uri);
+ return FALSE;
+ }
+
+ return TRUE;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
* Set Cache Header
*
* Set the HTTP headers to match the server-side file cache settings
diff --git a/system/database/DB_forge.php b/system/database/DB_forge.php
index bb1ee4809..59c3baf8b 100644
--- a/system/database/DB_forge.php
+++ b/system/database/DB_forge.php
@@ -402,7 +402,7 @@ abstract class CI_DB_forge {
// Are indexes created from within the CREATE TABLE statement? (e.g. in MySQL)
if ($this->_create_table_keys === TRUE)
{
- $columns .= $this->_process_indexes();
+ $columns .= $this->_process_indexes($table);
}
// _create_table will usually have the following format: "%s %s (%s\n)"
@@ -962,14 +962,25 @@ abstract class CI_DB_forge {
* @param string $table
* @return string
*/
- protected function _process_indexes($table = NULL)
+ protected function _process_indexes($table)
{
$table = $this->db->escape_identifiers($table);
$sqls = array();
for ($i = 0, $c = count($this->keys); $i < $c; $i++)
{
- if ( ! isset($this->fields[$this->keys[$i]]))
+ if (is_array($this->keys[$i]))
+ {
+ for ($i2 = 0, $c2 = count($this->keys[$i]); $i2 < $c2; $i2++)
+ {
+ if ( ! isset($this->fields[$this->keys[$i][$i2]]))
+ {
+ unset($this->keys[$i][$i2]);
+ continue;
+ }
+ }
+ }
+ elseif ( ! isset($this->fields[$this->keys[$i]]))
{
unset($this->keys[$i]);
continue;
diff --git a/system/database/DB_query_builder.php b/system/database/DB_query_builder.php
index 9bd535b0e..e77fba63d 100644
--- a/system/database/DB_query_builder.php
+++ b/system/database/DB_query_builder.php
@@ -903,11 +903,12 @@ abstract class CI_DB_query_builder extends CI_DB_driver {
}
is_bool($escape) OR $escape = $this->_protect_identifiers;
- $prefix = (count($this->qb_where) === 0 && count($this->qb_cache_where) === 0)
- ? $this->_group_get_type('') : $this->_group_get_type($type);
foreach ($field as $k => $v)
{
+ $prefix = (count($this->qb_where) === 0 && count($this->qb_cache_where) === 0)
+ ? $this->_group_get_type('') : $this->_group_get_type($type);
+
$v = $this->escape_like_str($v);
if ($side === 'none')
diff --git a/system/database/DB_utility.php b/system/database/DB_utility.php
index a32fd4455..c4140aef3 100644
--- a/system/database/DB_utility.php
+++ b/system/database/DB_utility.php
@@ -146,7 +146,7 @@ abstract class CI_DB_utility {
if ($query !== FALSE)
{
$query = $query->result_array();
- return current($res);
+ return current($query);
}
return FALSE;
diff --git a/system/database/drivers/cubrid/cubrid_forge.php b/system/database/drivers/cubrid/cubrid_forge.php
index 9a7cdb805..2a737c5ed 100644
--- a/system/database/drivers/cubrid/cubrid_forge.php
+++ b/system/database/drivers/cubrid/cubrid_forge.php
@@ -179,13 +179,24 @@ class CI_DB_cubrid_forge extends CI_DB_forge {
* @param string $table (ignored)
* @return string
*/
- protected function _process_indexes($table = NULL)
+ protected function _process_indexes($table)
{
$sql = '';
for ($i = 0, $c = count($this->keys); $i < $c; $i++)
{
- if ( ! isset($this->fields[$this->keys[$i]]))
+ if (is_array($this->keys[$i]))
+ {
+ for ($i2 = 0, $c2 = count($this->keys[$i]); $i2 < $c2; $i2++)
+ {
+ if ( ! isset($this->fields[$this->keys[$i][$i2]]))
+ {
+ unset($this->keys[$i][$i2]);
+ continue;
+ }
+ }
+ }
+ elseif ( ! isset($this->fields[$this->keys[$i]]))
{
unset($this->keys[$i]);
continue;
diff --git a/system/database/drivers/mysql/mysql_forge.php b/system/database/drivers/mysql/mysql_forge.php
index 1e9145e4f..f4394c685 100644
--- a/system/database/drivers/mysql/mysql_forge.php
+++ b/system/database/drivers/mysql/mysql_forge.php
@@ -175,13 +175,24 @@ class CI_DB_mysql_forge extends CI_DB_forge {
* @param string $table (ignored)
* @return string
*/
- protected function _process_indexes($table = NULL)
+ protected function _process_indexes($table)
{
$sql = '';
for ($i = 0, $c = count($this->keys); $i < $c; $i++)
{
- if ( ! isset($this->fields[$this->keys[$i]]))
+ if (is_array($this->keys[$i]))
+ {
+ for ($i2 = 0, $c2 = count($this->keys[$i]); $i2 < $c2; $i2++)
+ {
+ if ( ! isset($this->fields[$this->keys[$i][$i2]]))
+ {
+ unset($this->keys[$i][$i2]);
+ continue;
+ }
+ }
+ }
+ elseif ( ! isset($this->fields[$this->keys[$i]]))
{
unset($this->keys[$i]);
continue;
diff --git a/system/database/drivers/mysqli/mysqli_forge.php b/system/database/drivers/mysqli/mysqli_forge.php
index 1a6e284ee..f29ea5ade 100644
--- a/system/database/drivers/mysqli/mysqli_forge.php
+++ b/system/database/drivers/mysqli/mysqli_forge.php
@@ -175,13 +175,24 @@ class CI_DB_mysqli_forge extends CI_DB_forge {
* @param string $table (ignored)
* @return string
*/
- protected function _process_indexes($table = NULL)
+ protected function _process_indexes($table)
{
$sql = '';
for ($i = 0, $c = count($this->keys); $i < $c; $i++)
{
- if ( ! isset($this->fields[$this->keys[$i]]))
+ if (is_array($this->keys[$i]))
+ {
+ for ($i2 = 0, $c2 = count($this->keys[$i]); $i2 < $c2; $i2++)
+ {
+ if ( ! isset($this->fields[$this->keys[$i][$i2]]))
+ {
+ unset($this->keys[$i][$i2]);
+ continue;
+ }
+ }
+ }
+ elseif ( ! isset($this->fields[$this->keys[$i]]))
{
unset($this->keys[$i]);
continue;
diff --git a/system/database/drivers/pdo/subdrivers/pdo_cubrid_forge.php b/system/database/drivers/pdo/subdrivers/pdo_cubrid_forge.php
index cb7d9e697..ebf4b15d6 100644
--- a/system/database/drivers/pdo/subdrivers/pdo_cubrid_forge.php
+++ b/system/database/drivers/pdo/subdrivers/pdo_cubrid_forge.php
@@ -179,13 +179,24 @@ class CI_DB_pdo_cubrid_forge extends CI_DB_pdo_forge {
* @param string $table (ignored)
* @return string
*/
- protected function _process_indexes($table = NULL)
+ protected function _process_indexes($table)
{
$sql = '';
for ($i = 0, $c = count($this->keys); $i < $c; $i++)
{
- if ( ! isset($this->fields[$this->keys[$i]]))
+ if (is_array($this->keys[$i]))
+ {
+ for ($i2 = 0, $c2 = count($this->keys[$i]); $i2 < $c2; $i2++)
+ {
+ if ( ! isset($this->fields[$this->keys[$i][$i2]]))
+ {
+ unset($this->keys[$i][$i2]);
+ continue;
+ }
+ }
+ }
+ elseif ( ! isset($this->fields[$this->keys[$i]]))
{
unset($this->keys[$i]);
continue;
diff --git a/system/database/drivers/pdo/subdrivers/pdo_mysql_forge.php b/system/database/drivers/pdo/subdrivers/pdo_mysql_forge.php
index 85d9445d3..5a6de6b2d 100644
--- a/system/database/drivers/pdo/subdrivers/pdo_mysql_forge.php
+++ b/system/database/drivers/pdo/subdrivers/pdo_mysql_forge.php
@@ -189,13 +189,24 @@ class CI_DB_pdo_mysql_forge extends CI_DB_pdo_forge {
* @param string $table (ignored)
* @return string
*/
- protected function _process_indexes($table = NULL)
+ protected function _process_indexes($table)
{
$sql = '';
for ($i = 0, $c = count($this->keys); $i < $c; $i++)
{
- if ( ! isset($this->fields[$this->keys[$i]]))
+ if (is_array($this->keys[$i]))
+ {
+ for ($i2 = 0, $c2 = count($this->keys[$i]); $i2 < $c2; $i2++)
+ {
+ if ( ! isset($this->fields[$this->keys[$i][$i2]]))
+ {
+ unset($this->keys[$i][$i2]);
+ continue;
+ }
+ }
+ }
+ elseif ( ! isset($this->fields[$this->keys[$i]]))
{
unset($this->keys[$i]);
continue;
diff --git a/system/helpers/language_helper.php b/system/helpers/language_helper.php
index 658be6de7..6d24a9ca6 100644
--- a/system/helpers/language_helper.php
+++ b/system/helpers/language_helper.php
@@ -45,18 +45,19 @@ if ( ! function_exists('lang'))
*
* Fetches a language variable and optionally outputs a form label
*
- * @param string the language line
- * @param string the id of the form element
+ * @param string $line The language line
+ * @param string $for The "for" value (id of the form element)
+ * @param array $attributes Any additional HTML attributes
* @return string
*/
- function lang($line, $id = '')
+ function lang($line, $for = '', $attributes = array())
{
$CI =& get_instance();
$line = $CI->lang->line($line);
- if ($id !== '')
+ if ($for !== '')
{
- $line = '<label for="'.$id.'">'.$line.'</label>';
+ $line = '<label for="'.$for.'"'._stringify_attributes($attributes).'>'.$line.'</label>';
}
return $line;
diff --git a/system/libraries/Cache/Cache.php b/system/libraries/Cache/Cache.php
index e76fdc557..48bd9581a 100644
--- a/system/libraries/Cache/Cache.php
+++ b/system/libraries/Cache/Cache.php
@@ -43,12 +43,12 @@ class CI_Cache extends CI_Driver_Library {
* @var array
*/
protected $valid_drivers = array(
- 'cache_apc',
- 'cache_dummy',
- 'cache_file',
- 'cache_memcached',
- 'cache_redis',
- 'cache_wincache'
+ 'apc',
+ 'dummy',
+ 'file',
+ 'memcached',
+ 'redis',
+ 'wincache'
);
/**
diff --git a/system/libraries/Driver.php b/system/libraries/Driver.php
index 621d22631..8323e8f01 100644
--- a/system/libraries/Driver.php
+++ b/system/libraries/Driver.php
@@ -60,8 +60,8 @@ class CI_Driver_Library {
* The first time a child is used it won't exist, so we instantiate it
* subsequents calls will go straight to the proper child.
*
- * @param string Child class name
- * @return object Child class
+ * @param string Child class name
+ * @return object Child class
*/
public function __get($child)
{
@@ -74,61 +74,109 @@ class CI_Driver_Library {
*
* Separate load_driver call to support explicit driver load by library or user
*
- * @param string Child class name
- * @return object Child class
+ * @param string Driver name (w/o parent prefix)
+ * @return object Child class
*/
public function load_driver($child)
{
+ // Get CodeIgniter instance and subclass prefix
+ $CI = get_instance();
+ $prefix = (string) $CI->config->item('subclass_prefix');
+
if ( ! isset($this->lib_name))
{
- $this->lib_name = get_class($this);
+ // Get library name without any prefix
+ $this->lib_name = str_replace(array('CI_', $prefix), '', get_class($this));
}
- // The class will be prefixed with the parent lib
- $child_class = $this->lib_name.'_'.$child;
+ // The child will be prefixed with the parent lib
+ $child_name = $this->lib_name.'_'.$child;
- // Remove the CI_ prefix and lowercase
- $lib_name = ucfirst(strtolower(str_replace('CI_', '', $this->lib_name)));
- $driver_name = strtolower(str_replace('CI_', '', $child_class));
+ // See if requested child is a valid driver
+ if ( ! in_array($child, $this->valid_drivers))
+ {
+ // The requested driver isn't valid!
+ $msg = 'Invalid driver requested: '.$child_name;
+ log_message('error', $msg);
+ show_error($msg);
+ }
- if (in_array($driver_name, array_map('strtolower', $this->valid_drivers)))
+ // Get package paths and filename case variations to search
+ $paths = $CI->load->get_package_paths(TRUE);
+
+ // Is there an extension?
+ $class_name = $prefix.$child_name;
+ $found = class_exists($class_name);
+ if ( ! $found)
{
- // check and see if the driver is in a separate file
- if ( ! class_exists($child_class))
+ // Check for subclass file
+ foreach ($paths as $path)
{
- // check application path first
- foreach (get_instance()->load->get_package_paths(TRUE) as $path)
+ // Does the file exist?
+ $file = $path.'libraries/'.$this->lib_name.'/drivers/'.$prefix.$child_name.'.php';
+ if (file_exists($file))
{
- // loves me some nesting!
- foreach (array(ucfirst($driver_name), $driver_name) as $class)
+ // Yes - require base class from BASEPATH
+ $basepath = BASEPATH.'libraries/'.$this->lib_name.'/drivers/'.$child_name.'.php';
+ if ( ! file_exists($basepath))
{
- $filepath = $path.'libraries/'.$lib_name.'/drivers/'.$class.'.php';
-
- if (file_exists($filepath))
- {
- include_once $filepath;
- break 2;
- }
+ $msg = 'Unable to load the requested class: CI_'.$child_name;
+ log_message('error', $msg);
+ show_error($msg);
}
+
+ // Include both sources and mark found
+ include($basepath);
+ include($file);
+ $found = TRUE;
+ break;
}
+ }
+ }
- // it's a valid driver, but the file simply can't be found
- if ( ! class_exists($child_class))
+ // Do we need to search for the class?
+ if ( ! $found)
+ {
+ // Use standard class name
+ $class_name = 'CI_'.$child_name;
+ $found = class_exists($class_name);
+ if ( ! $found)
+ {
+ // Check package paths
+ foreach ($paths as $path)
{
- log_message('error', 'Unable to load the requested driver: '.$child_class);
- show_error('Unable to load the requested driver: '.$child_class);
+ // Does the file exist?
+ $file = $path.'libraries/'.$this->lib_name.'/drivers/'.$child_name.'.php';
+ if (file_exists($file))
+ {
+ // Include source
+ include($file);
+ break;
+ }
}
}
+ }
- $obj = new $child_class;
- $obj->decorate($this);
- $this->$child = $obj;
- return $this->$child;
+ // Did we finally find the class?
+ if ( ! class_exists($class_name))
+ {
+ if (class_exists($child_name))
+ {
+ $class_name = $child_name;
+ }
+ else
+ {
+ $msg = 'Unable to load the requested driver: '.$class_name;
+ log_message('error', $msg);
+ show_error($msg);
+ }
}
- // The requested driver isn't valid!
- log_message('error', 'Invalid driver requested: '.$child_class);
- show_error('Invalid driver requested: '.$child_class);
+ // Instantiate, decorate and add child
+ $obj = new $class_name();
+ $obj->decorate($this);
+ $this->$child = $obj;
+ return $this->$child;
}
}
diff --git a/system/libraries/Email.php b/system/libraries/Email.php
index 92ccde60c..5d8fc8aea 100644
--- a/system/libraries/Email.php
+++ b/system/libraries/Email.php
@@ -2062,9 +2062,11 @@ class CI_Email {
/**
* Get Debug Message
*
+ * @param array $include List of raw data chunks to include in the output
+ * Valid options are: 'headers', 'subject', 'body'
* @return string
*/
- public function print_debugger()
+ public function print_debugger($include = array('headers', 'subject', 'body'))
{
$msg = '';
@@ -2076,7 +2078,26 @@ class CI_Email {
}
}
- return $msg.'<pre>'.$this->_header_str."\n".htmlspecialchars($this->_subject)."\n".htmlspecialchars($this->_finalbody).'</pre>';
+ // Determine which parts of our raw data needs to be printed
+ $raw_data = '';
+ is_array($include) OR $include = array($include);
+
+ if (in_array('headers', $include, TRUE))
+ {
+ $raw_data = $this->_header_str."\n";
+ }
+
+ if (in_array('subject', $include, TRUE))
+ {
+ $raw_data .= htmlspecialchars($this->_subject)."\n";
+ }
+
+ if (in_array('body', $include, TRUE))
+ {
+ $raw_data .= htmlspecialchars($this->_finalbody);
+ }
+
+ return $msg.($raw_data === '' ? '' : '<pre>'.$raw_data.'</pre>');
}
// --------------------------------------------------------------------
diff --git a/system/libraries/Form_validation.php b/system/libraries/Form_validation.php
index d3d22c595..b7bd280ee 100644
--- a/system/libraries/Form_validation.php
+++ b/system/libraries/Form_validation.php
@@ -105,7 +105,7 @@ class CI_Form_validation {
*
* @var array
*/
- protected $validation_data = array();
+ public $validation_data = array();
/**
* Initialize Form_Validation class
@@ -1084,6 +1084,48 @@ class CI_Form_validation {
// --------------------------------------------------------------------
/**
+ * Valid URL
+ *
+ * @param string $str
+ * @return bool
+ */
+ public function valid_url($str)
+ {
+ if (empty($str))
+ {
+ return FALSE;
+ }
+ elseif (preg_match('/^(?:([^:]*)\:)?\/\/(.+)$/', $str, $matches))
+ {
+ if (empty($matches[2]))
+ {
+ return FALSE;
+ }
+ elseif ( ! in_array($matches[1], array('http', 'https'), TRUE))
+ {
+ return FALSE;
+ }
+
+ $str = $matches[2];
+ }
+
+ $str = 'http://'.$str;
+
+ // There's a bug affecting PHP 5.2.13, 5.3.2 that considers the
+ // underscore to be a valid hostname character instead of a dash.
+ // Reference: https://bugs.php.net/bug.php?id=51192
+ if (version_compare(PHP_VERSION, '5.2.13', '==') === 0 OR version_compare(PHP_VERSION, '5.3.2', '==') === 0)
+ {
+ sscanf($str, 'http://%[^/]', $host);
+ $str = substr_replace($str, strtr($host, array('_' => '-', '-' => '_')), 7, strlen($host));
+ }
+
+ return (filter_var($str, FILTER_VALIDATE_URL) !== FALSE);
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
* Valid Email
*
* @param string
diff --git a/system/libraries/Migration.php b/system/libraries/Migration.php
index e96791cef..bf2d18e07 100644
--- a/system/libraries/Migration.php
+++ b/system/libraries/Migration.php
@@ -233,11 +233,6 @@ class CI_Migration {
$this->_error_string = sprintf($this->lang->line('migration_class_doesnt_exist'), $class);
return FALSE;
}
- elseif ( ! is_callable(array($class, $method)))
- {
- $this->_error_string = sprintf($this->lang->line('migration_missing_'.$method.'_method'), $class);
- return FALSE;
- }
$previous = $number;
@@ -247,8 +242,15 @@ class CI_Migration {
($method === 'down' && $number <= $current_version && $number > $target_version)
)
{
+ $instance = new $class();
+ if ( ! is_callable(array($instance, $method)))
+ {
+ $this->_error_string = sprintf($this->lang->line('migration_missing_'.$method.'_method'), $class);
+ return FALSE;
+ }
+
log_message('debug', 'Migrating '.$method.' from version '.$current_version.' to version '.$number);
- call_user_func(array(new $class, $method));
+ call_user_func(array($instance, $method));
$current_version = $number;
$this->_update_version($current_version);
}
diff --git a/system/libraries/Session/Session.php b/system/libraries/Session/Session.php
index 9b011dea3..85a483592 100644
--- a/system/libraries/Session/Session.php
+++ b/system/libraries/Session/Session.php
@@ -107,17 +107,15 @@ class CI_Session extends CI_Driver_Library {
// Get valid drivers list
$this->valid_drivers = array(
- 'Session_native',
- 'Session_cookie'
+ 'native',
+ 'cookie'
);
$key = 'sess_valid_drivers';
$drivers = isset($params[$key]) ? $params[$key] : $CI->config->item($key);
if ($drivers)
{
- is_array($drivers) OR $drivers = array($drivers);
-
// Add driver names to valid list
- foreach ($drivers as $driver)
+ foreach ((array) $drivers as $driver)
{
if ( ! in_array(strtolower($driver), array_map('strtolower', $this->valid_drivers)))
{
@@ -134,9 +132,9 @@ class CI_Session extends CI_Driver_Library {
$driver = 'cookie';
}
- if ( ! in_array('session_'.strtolower($driver), array_map('strtolower', $this->valid_drivers)))
+ if ( ! in_array(strtolower($driver), array_map('strtolower', $this->valid_drivers)))
{
- $this->valid_drivers[] = 'Session_'.$driver;
+ $this->valid_drivers[] = $driver;
}
// Save a copy of parameters in case drivers need access
@@ -178,17 +176,17 @@ class CI_Session extends CI_Driver_Library {
/**
* Select default session storage driver
*
- * @param string Driver classname
+ * @param string Driver name
* @return void
*/
public function select_driver($driver)
{
// Validate driver name
- $lowername = strtolower(str_replace('CI_', '', $driver));
- if (in_array($lowername, array_map('strtolower', $this->valid_drivers)))
+ $prefix = (string) get_instance()->config->item('subclass_prefix');
+ $child = strtolower(str_replace(array('CI_', $prefix, $this->lib_name.'_'), '', $driver));
+ if (in_array($child, array_map('strtolower', $this->valid_drivers)))
{
// See if driver is loaded
- $child = str_replace($this->lib_name.'_', '', $driver);
if (isset($this->$child))
{
// See if driver is already current
diff --git a/system/libraries/Session/drivers/Session_cookie.php b/system/libraries/Session/drivers/Session_cookie.php
index 3c4848265..6d926ae3d 100644
--- a/system/libraries/Session/drivers/Session_cookie.php
+++ b/system/libraries/Session/drivers/Session_cookie.php
@@ -219,7 +219,7 @@ class CI_Session_cookie extends CI_Session_driver {
: $this->CI->config->item($key);
}
- if ($this->encryption_key === '')
+ if (empty($this->encryption_key))
{
show_error('In order to use the Cookie Session driver you are required to set an encryption key in your config file.');
}