summaryrefslogtreecommitdiffstats
path: root/system
diff options
context:
space:
mode:
authorTim Nolte <noltet@sekisui-spi.com>2015-06-08 18:25:34 +0200
committerTim Nolte <noltet@sekisui-spi.com>2015-06-08 18:25:34 +0200
commit89ed9fafd75e3b65a7691f1b13440bdedadf5eda (patch)
tree5dfa69c55ff48502527fcb6f4f532fb5ad6651ca /system
parent2ac4177b4b6afc63d594523416c3991d23dddf20 (diff)
parentb76394834a3e36e8c376913cd9666a8d7a4cea45 (diff)
Merge branch 'develop' into feature/mysqli-ssl
Diffstat (limited to 'system')
-rw-r--r--system/core/Common.php2
-rw-r--r--system/core/Input.php18
-rw-r--r--system/core/Output.php2
-rw-r--r--system/database/DB_driver.php2
-rw-r--r--system/database/DB_utility.php4
-rw-r--r--system/database/drivers/oci8/oci8_driver.php2
-rw-r--r--system/database/drivers/pdo/subdrivers/pdo_sqlite_driver.php30
-rw-r--r--system/database/drivers/sqlite3/sqlite3_driver.php30
-rw-r--r--system/libraries/Cache/Cache.php22
-rw-r--r--system/libraries/Cache/drivers/Cache_redis.php4
-rw-r--r--system/libraries/Form_validation.php2
-rw-r--r--system/libraries/Ftp.php2
-rw-r--r--system/libraries/Image_lib.php40
-rw-r--r--system/libraries/Migration.php6
-rw-r--r--system/libraries/Session/drivers/Session_memcached_driver.php2
-rw-r--r--system/libraries/Session/drivers/Session_redis_driver.php2
16 files changed, 96 insertions, 74 deletions
diff --git a/system/core/Common.php b/system/core/Common.php
index a81e45500..b850fd39a 100644
--- a/system/core/Common.php
+++ b/system/core/Common.php
@@ -749,7 +749,7 @@ if ( ! function_exists('html_escape'))
{
return $var;
}
-
+
if (is_array($var))
{
return array_map('html_escape', $var, array_fill(0, count($var), $double_encode));
diff --git a/system/core/Input.php b/system/core/Input.php
index 12332cf51..b0bbb7b8d 100644
--- a/system/core/Input.php
+++ b/system/core/Input.php
@@ -799,19 +799,27 @@ class CI_Input {
*/
public function get_request_header($index, $xss_clean = FALSE)
{
- if (empty($this->headers))
+ static $headers;
+
+ if ( ! isset($headers))
{
- $this->request_headers();
+ empty($this->headers) OR $this->request_headers();
+ foreach ($this->headers as $key => $value)
+ {
+ $headers[strtolower($key)] = $value;
+ }
}
- if ( ! isset($this->headers[$index]))
+ $index = strtolower($index);
+
+ if ( ! isset($headers[$index]))
{
return NULL;
}
return ($xss_clean === TRUE)
- ? $this->security->xss_clean($this->headers[$index])
- : $this->headers[$index];
+ ? $this->security->xss_clean($headers[$index])
+ : $headers[$index];
}
// --------------------------------------------------------------------
diff --git a/system/core/Output.php b/system/core/Output.php
index 02f66936c..e7d559a1d 100644
--- a/system/core/Output.php
+++ b/system/core/Output.php
@@ -674,7 +674,7 @@ class CI_Output {
$cache_info = unserialize($match[1]);
$expire = $cache_info['expire'];
- $last_modified = filemtime($cache_path);
+ $last_modified = filemtime($filepath);
// Has the file expired?
if ($_SERVER['REQUEST_TIME'] >= $expire && is_really_writable($cache_path))
diff --git a/system/database/DB_driver.php b/system/database/DB_driver.php
index 3d35c2d70..64ee880c8 100644
--- a/system/database/DB_driver.php
+++ b/system/database/DB_driver.php
@@ -1218,7 +1218,7 @@ abstract class CI_DB_driver {
/**
* Fetch Field Names
*
- * @param string the table name
+ * @param string $table Table name
* @return array
*/
public function list_fields($table)
diff --git a/system/database/DB_utility.php b/system/database/DB_utility.php
index 57356ac53..78398ea83 100644
--- a/system/database/DB_utility.php
+++ b/system/database/DB_utility.php
@@ -249,7 +249,7 @@ abstract class CI_DB_utility {
$out .= $enclosure.str_replace($enclosure, $enclosure.$enclosure, $name).$enclosure.$delim;
}
- $out = substr(rtrim($out), 0, -strlen($delim)).$newline;
+ $out = substr($out, 0, -strlen($delim)).$newline;
// Next blast through the result array and build out the rows
while ($row = $query->unbuffered_row('array'))
@@ -258,7 +258,7 @@ abstract class CI_DB_utility {
{
$out .= $enclosure.str_replace($enclosure, $enclosure.$enclosure, $item).$enclosure.$delim;
}
- $out = substr(rtrim($out), 0, -strlen($delim)).$newline;
+ $out = substr($out, 0, -strlen($delim)).$newline;
}
return $out;
diff --git a/system/database/drivers/oci8/oci8_driver.php b/system/database/drivers/oci8/oci8_driver.php
index 4010995a1..b5cf26536 100644
--- a/system/database/drivers/oci8/oci8_driver.php
+++ b/system/database/drivers/oci8/oci8_driver.php
@@ -573,7 +573,7 @@ class CI_DB_oci8_driver extends CI_DB {
{
$default = '';
}
- $retval[$i]->default = $query[$i]->COLUMN_DEFAULT;
+ $retval[$i]->default = $default;
}
return $retval;
diff --git a/system/database/drivers/pdo/subdrivers/pdo_sqlite_driver.php b/system/database/drivers/pdo/subdrivers/pdo_sqlite_driver.php
index f07f49f84..d5ca741fd 100644
--- a/system/database/drivers/pdo/subdrivers/pdo_sqlite_driver.php
+++ b/system/database/drivers/pdo/subdrivers/pdo_sqlite_driver.php
@@ -121,17 +121,31 @@ class CI_DB_pdo_sqlite_driver extends CI_DB_pdo_driver {
// --------------------------------------------------------------------
/**
- * Show column query
+ * Fetch Field Names
*
- * Generates a platform-specific query string so that the column names can be fetched
- *
- * @param string $table
- * @return string
+ * @param string $table Table name
+ * @return array
*/
- protected function _list_columns($table = '')
+ public function list_fields($table)
{
- // Not supported
- return FALSE;
+ // Is there a cached result?
+ if (isset($this->data_cache['field_names'][$table]))
+ {
+ return $this->data_cache['field_names'][$table];
+ }
+
+ if (($result = $this->query('PRAGMA TABLE_INFO('.$this->protect_identifiers($table, TRUE, NULL, FALSE).')')) === FALSE)
+ {
+ return FALSE;
+ }
+
+ $this->data_cache['field_names'][$table] = array();
+ foreach ($result as $row)
+ {
+ $this->data_cache['field_names'][$table][] = $row['name'];
+ }
+
+ return $this->data_cache['field_names'][$table];
}
// --------------------------------------------------------------------
diff --git a/system/database/drivers/sqlite3/sqlite3_driver.php b/system/database/drivers/sqlite3/sqlite3_driver.php
index fdbe94939..a7c6420bb 100644
--- a/system/database/drivers/sqlite3/sqlite3_driver.php
+++ b/system/database/drivers/sqlite3/sqlite3_driver.php
@@ -247,17 +247,31 @@ class CI_DB_sqlite3_driver extends CI_DB {
// --------------------------------------------------------------------
/**
- * Show column query
+ * Fetch Field Names
*
- * Generates a platform-specific query string so that the column names can be fetched
- *
- * @param string $table
- * @return string
+ * @param string $table Table name
+ * @return array
*/
- protected function _list_columns($table = '')
+ public function list_fields($table)
{
- // Not supported
- return FALSE;
+ // Is there a cached result?
+ if (isset($this->data_cache['field_names'][$table]))
+ {
+ return $this->data_cache['field_names'][$table];
+ }
+
+ if (($result = $this->query('PRAGMA TABLE_INFO('.$this->protect_identifiers($table, TRUE, NULL, FALSE).')')) === FALSE)
+ {
+ return FALSE;
+ }
+
+ $this->data_cache['field_names'][$table] = array();
+ foreach ($result as $row)
+ {
+ $this->data_cache['field_names'][$table][] = $row['name'];
+ }
+
+ return $this->data_cache['field_names'][$table];
}
// --------------------------------------------------------------------
diff --git a/system/libraries/Cache/Cache.php b/system/libraries/Cache/Cache.php
index 40ac70103..215a7c528 100644
--- a/system/libraries/Cache/Cache.php
+++ b/system/libraries/Cache/Cache.php
@@ -100,28 +100,10 @@ class CI_Cache extends CI_Driver_Library {
*/
public function __construct($config = array())
{
- $default_config = array(
- 'adapter',
- 'memcached'
- );
-
- foreach ($default_config as $key)
- {
- if (isset($config[$key]))
- {
- $param = '_'.$key;
-
- $this->{$param} = $config[$key];
- }
- }
-
+ isset($config['adapter']) && $this->_adapter = $config['adapter'];
+ isset($config['backup']) && $this->_backup_driver = $config['backup'];
isset($config['key_prefix']) && $this->key_prefix = $config['key_prefix'];
- if (isset($config['backup']) && in_array($config['backup'], $this->valid_drivers))
- {
- $this->_backup_driver = $config['backup'];
- }
-
// If the specified adapter isn't available, check the backup.
if ( ! $this->is_supported($this->_adapter))
{
diff --git a/system/libraries/Cache/drivers/Cache_redis.php b/system/libraries/Cache/drivers/Cache_redis.php
index b940b76cb..66966ba16 100644
--- a/system/libraries/Cache/drivers/Cache_redis.php
+++ b/system/libraries/Cache/drivers/Cache_redis.php
@@ -125,9 +125,7 @@ class CI_Cache_redis extends CI_Driver
$this->_redis->sRemove('_ci_redis_serialized', $id);
}
- return ($ttl)
- ? $this->_redis->setex($id, $ttl, $data)
- : $this->_redis->set($id, $data);
+ return $this->_redis->set($id, $data, $ttl);
}
// ------------------------------------------------------------------------
diff --git a/system/libraries/Form_validation.php b/system/libraries/Form_validation.php
index bb872c7cc..7599602c0 100644
--- a/system/libraries/Form_validation.php
+++ b/system/libraries/Form_validation.php
@@ -461,7 +461,7 @@ class CI_Form_validation {
{
$this->_field_data[$field]['postdata'] = $this->_reduce_array($validation_array, $row['keys']);
}
- elseif (isset($validation_array[$field]) && $validation_array[$field] !== '')
+ elseif (isset($validation_array[$field]))
{
$this->_field_data[$field]['postdata'] = $validation_array[$field];
}
diff --git a/system/libraries/Ftp.php b/system/libraries/Ftp.php
index af45bb55f..b53207577 100644
--- a/system/libraries/Ftp.php
+++ b/system/libraries/Ftp.php
@@ -490,7 +490,7 @@ class CI_FTP {
// so we'll recursively call delete_dir()
if ( ! preg_match('#/\.\.?$#', $list[$i]) && ! @ftp_delete($this->conn_id, $list[$i]))
{
- $this->delete_dir($list[$i]);
+ $this->delete_dir($filepath.$list[$i]);
}
}
}
diff --git a/system/libraries/Image_lib.php b/system/libraries/Image_lib.php
index e056654bb..c69283a7c 100644
--- a/system/libraries/Image_lib.php
+++ b/system/libraries/Image_lib.php
@@ -845,7 +845,7 @@ class CI_Image_lib {
*/
public function image_process_imagemagick($action = 'resize')
{
- // Do we have a vaild library path?
+ // Do we have a vaild library path?
if ($this->library_path === '')
{
$this->set_error('imglib_libpath_invalid');
@@ -1010,7 +1010,7 @@ class CI_Image_lib {
// going to have to figure out how to determine the color
// of the alpha channel in a future release.
- $white = imagecolorallocate($src_img, 255, 255, 255);
+ $white = imagecolorallocate($src_img, 255, 255, 255);
// Rotate it!
$dst_img = imagerotate($src_img, $this->rotation_angle, $white);
@@ -1055,8 +1055,11 @@ class CI_Image_lib {
if ($this->rotation_angle === 'hor')
{
- for ($i = 0; $i < $height; $i++, $left = 0, $right = $width-1)
+ for ($i = 0; $i < $height; $i++)
{
+ $left = 0;
+ $right = $width - 1;
+
while ($left < $right)
{
$cl = imagecolorat($src_img, $left, $i);
@@ -1072,18 +1075,21 @@ class CI_Image_lib {
}
else
{
- for ($i = 0; $i < $width; $i++, $top = 0, $bot = $height-1)
+ for ($i = 0; $i < $width; $i++)
{
- while ($top < $bot)
+ $top = 0;
+ $bottom = $height - 1;
+
+ while ($top < $bottom)
{
$ct = imagecolorat($src_img, $i, $top);
- $cb = imagecolorat($src_img, $i, $bot);
+ $cb = imagecolorat($src_img, $i, $bottom);
imagesetpixel($src_img, $i, $top, $cb);
- imagesetpixel($src_img, $i, $bot, $ct);
+ imagesetpixel($src_img, $i, $bottom, $ct);
$top++;
- $bot--;
+ $bottom--;
}
}
}
@@ -1327,7 +1333,7 @@ class CI_Image_lib {
{
$y_axis += $this->orig_height - $fontheight - $this->wm_shadow_distance - ($fontheight / 2);
}
-
+
// Set horizontal alignment
if ($this->wm_hor_alignment === 'R')
{
@@ -1337,13 +1343,13 @@ class CI_Image_lib {
{
$x_axis += floor(($this->orig_width - ($fontwidth * strlen($this->wm_text))) / 2);
}
-
+
if ($this->wm_use_drop_shadow)
{
// Offset from text
$x_shad = $x_axis + $this->wm_shadow_distance;
$y_shad = $y_axis + $this->wm_shadow_distance;
-
+
/* Set RGB values for shadow
*
* First character is #, so we don't really need it.
@@ -1352,7 +1358,7 @@ class CI_Image_lib {
*/
$drp_color = str_split(substr($this->wm_shadow_color, 1, 6), 2);
$drp_color = imagecolorclosest($src_img, hexdec($drp_color[0]), hexdec($drp_color[1]), hexdec($drp_color[2]));
-
+
// Add the shadow to the source image
if ($this->wm_use_truetype)
{
@@ -1363,7 +1369,7 @@ class CI_Image_lib {
imagestring($src_img, $this->wm_font_size, $x_shad, $y_shad, $this->wm_text, $drp_color);
}
}
-
+
/* Set RGB values for text
*
* First character is #, so we don't really need it.
@@ -1382,7 +1388,7 @@ class CI_Image_lib {
{
imagestring($src_img, $this->wm_font_size, $x_axis, $y_axis, $this->wm_text, $txt_color);
}
-
+
// We can preserve transparency for PNG images
if ($this->image_type === 3)
{
@@ -1431,7 +1437,7 @@ class CI_Image_lib {
switch ($image_type)
{
- case 1 :
+ case 1:
if ( ! function_exists('imagecreatefromgif'))
{
$this->set_error(array('imglib_unsupported_imagecreate', 'imglib_gif_not_supported'));
@@ -1439,7 +1445,7 @@ class CI_Image_lib {
}
return imagecreatefromgif($path);
- case 2 :
+ case 2:
if ( ! function_exists('imagecreatefromjpeg'))
{
$this->set_error(array('imglib_unsupported_imagecreate', 'imglib_jpg_not_supported'));
@@ -1447,7 +1453,7 @@ class CI_Image_lib {
}
return imagecreatefromjpeg($path);
- case 3 :
+ case 3:
if ( ! function_exists('imagecreatefrompng'))
{
$this->set_error(array('imglib_unsupported_imagecreate', 'imglib_png_not_supported'));
diff --git a/system/libraries/Migration.php b/system/libraries/Migration.php
index ae36a3b45..45a3cbbce 100644
--- a/system/libraries/Migration.php
+++ b/system/libraries/Migration.php
@@ -191,7 +191,7 @@ class CI_Migration {
* choice
*
* @param string $target_version Target schema version
- * @return mixed TRUE if already latest, FALSE if failed, string if upgraded
+ * @return mixed TRUE if no migrations are found, current version string on success, FALSE on failure
*/
public function version($target_version)
{
@@ -294,7 +294,7 @@ class CI_Migration {
/**
* Sets the schema to the latest migration
*
- * @return mixed TRUE if already latest, FALSE if failed, string if upgraded
+ * @return mixed Current version string on success, FALSE on failure
*/
public function latest()
{
@@ -318,7 +318,7 @@ class CI_Migration {
/**
* Sets the schema to the migration version set in config
*
- * @return mixed TRUE if already current, FALSE if failed, string if upgraded
+ * @return mixed TRUE if no migrations are found, current version string on success, FALSE on failure
*/
public function current()
{
diff --git a/system/libraries/Session/drivers/Session_memcached_driver.php b/system/libraries/Session/drivers/Session_memcached_driver.php
index c7185ee44..97b860588 100644
--- a/system/libraries/Session/drivers/Session_memcached_driver.php
+++ b/system/libraries/Session/drivers/Session_memcached_driver.php
@@ -322,7 +322,7 @@ class CI_Session_memcached_driver extends CI_Session_driver implements SessionHa
$this->_lock_key = $lock_key;
break;
}
- while ($attempt++ < 30);
+ while (++$attempt < 30);
if ($attempt === 30)
{
diff --git a/system/libraries/Session/drivers/Session_redis_driver.php b/system/libraries/Session/drivers/Session_redis_driver.php
index 1ce101daf..b098cc441 100644
--- a/system/libraries/Session/drivers/Session_redis_driver.php
+++ b/system/libraries/Session/drivers/Session_redis_driver.php
@@ -336,7 +336,7 @@ class CI_Session_redis_driver extends CI_Session_driver implements SessionHandle
$this->_lock_key = $lock_key;
break;
}
- while ($attempt++ < 30);
+ while (++$attempt < 30);
if ($attempt === 30)
{