From cb07a322bee5c5b0a551ab959c7475a1a702ad03 Mon Sep 17 00:00:00 2001 From: Michael Dennis Date: Sat, 20 Aug 2011 23:40:59 -0700 Subject: Fix for the Image_lib clear() function so that it resets all variables to their default values. This should fix issues #157 and #174. https://github.com/EllisLab/CodeIgniter/issues/157 https://github.com/EllisLab/CodeIgniter/issues/174 --- system/libraries/Image_lib.php | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) (limited to 'system') diff --git a/system/libraries/Image_lib.php b/system/libraries/Image_lib.php index 8902f524d..6855e4498 100644 --- a/system/libraries/Image_lib.php +++ b/system/libraries/Image_lib.php @@ -104,15 +104,37 @@ class CI_Image_lib { */ function clear() { - $props = array('source_folder', 'dest_folder', 'source_image', 'full_src_path', 'full_dst_path', 'new_image', 'image_type', 'size_str', 'quality', 'orig_width', 'orig_height', 'rotation_angle', 'x_axis', 'y_axis', 'create_fnc', 'copy_fnc', 'wm_overlay_path', 'wm_use_truetype', 'dynamic_output', 'wm_font_size', 'wm_text', 'wm_vrt_alignment', 'wm_hor_alignment', 'wm_padding', 'wm_hor_offset', 'wm_vrt_offset', 'wm_font_color', 'wm_use_drop_shadow', 'wm_shadow_color', 'wm_shadow_distance', 'wm_opacity'); + $props = array('library_path', 'source_image', 'new_image', 'width', 'height', 'rotation_angle', 'x_axis', 'y_axis', 'wm_text', 'wm_overlay_path', 'wm_font_path', 'wm_shadow_color', 'source_folder', 'dest_folder', 'mime_type', 'orig_width', 'orig_height', 'image_type', 'size_str', 'full_src_path', 'full_dst_path'); foreach ($props as $val) { $this->$val = ''; } - // special consideration for master_dim - $this->master_dim = 'auto'; + $this->image_library = 'gd2'; + $this->dynamic_output = FALSE; + $this->quality = '90'; + $this->create_thumb = FALSE; + $this->thumb_marker = '_thumb'; + $this->maintain_ratio = TRUE; + $this->master_dim = 'auto'; + $this->wm_type = 'text'; + $this->wm_x_transp = 4; + $this->wm_y_transp = 4; + $this->wm_font_size = 17; + $this->wm_vrt_alignment = 'B'; + $this->wm_hor_alignment = 'C'; + $this->wm_padding = 0; + $this->wm_hor_offset = 0; + $this->wm_vrt_offset = 0; + $this->wm_font_color = '#ffffff'; + $this->wm_shadow_distance = 2; + $this->wm_opacity = 50; + $this->create_fnc = 'imagecreatetruecolor'; + $this->copy_fnc = 'imagecopyresampled'; + $this->error_msg = array(); + $this->wm_use_drop_shadow = FALSE; + $this->wm_use_truetype = FALSE; } // -------------------------------------------------------------------- -- cgit v1.2.3-24-g4f1b From 37e351f1c1bf76758685158630be723e2951c032 Mon Sep 17 00:00:00 2001 From: Kyle Farris Date: Wed, 7 Sep 2011 11:14:46 -0300 Subject: Fix for issue #406 --- system/database/drivers/sqlsrv/sqlsrv_driver.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system') diff --git a/system/database/drivers/sqlsrv/sqlsrv_driver.php b/system/database/drivers/sqlsrv/sqlsrv_driver.php index 400fd31c6..1021db945 100644 --- a/system/database/drivers/sqlsrv/sqlsrv_driver.php +++ b/system/database/drivers/sqlsrv/sqlsrv_driver.php @@ -86,7 +86,7 @@ class CI_DB_sqlsrv_driver extends CI_DB { */ function db_pconnect() { - $this->db_connect(TRUE); + return $this->db_connect(TRUE); } // -------------------------------------------------------------------- -- cgit v1.2.3-24-g4f1b From b840a6704feb7a2439bbd3a9a23127dafc7b42f7 Mon Sep 17 00:00:00 2001 From: Seb Pollard Date: Sat, 22 Oct 2011 23:28:21 +0100 Subject: Fixed an issue with the Image_lib class not clearing width, height or create_thumb properties when calling the clear() method. --- system/libraries/Image_lib.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'system') diff --git a/system/libraries/Image_lib.php b/system/libraries/Image_lib.php index beb463b32..ceb31d1f0 100644 --- a/system/libraries/Image_lib.php +++ b/system/libraries/Image_lib.php @@ -116,7 +116,7 @@ class CI_Image_lib { */ function clear() { - $props = array('source_folder', 'dest_folder', 'source_image', 'full_src_path', 'full_dst_path', 'new_image', 'image_type', 'size_str', 'quality', 'orig_width', 'orig_height', 'rotation_angle', 'x_axis', 'y_axis', 'create_fnc', 'copy_fnc', 'wm_overlay_path', 'wm_use_truetype', 'dynamic_output', 'wm_font_size', 'wm_text', 'wm_vrt_alignment', 'wm_hor_alignment', 'wm_padding', 'wm_hor_offset', 'wm_vrt_offset', 'wm_font_color', 'wm_use_drop_shadow', 'wm_shadow_color', 'wm_shadow_distance', 'wm_opacity'); + $props = array('source_folder', 'dest_folder', 'source_image', 'full_src_path', 'full_dst_path', 'new_image', 'image_type', 'size_str', 'quality', 'orig_width', 'orig_height', 'rotation_angle', 'x_axis', 'y_axis', 'create_fnc', 'copy_fnc', 'wm_overlay_path', 'wm_use_truetype', 'dynamic_output', 'wm_font_size', 'wm_text', 'wm_vrt_alignment', 'wm_hor_alignment', 'wm_padding', 'wm_hor_offset', 'wm_vrt_offset', 'wm_font_color', 'wm_use_drop_shadow', 'wm_shadow_color', 'wm_shadow_distance', 'wm_opacity', 'width', 'height'); foreach ($props as $val) { @@ -125,6 +125,9 @@ class CI_Image_lib { // special consideration for master_dim $this->master_dim = 'auto'; + + // special consideration for create_thumb + $this->create_thumb = FALSE; } // -------------------------------------------------------------------- -- cgit v1.2.3-24-g4f1b From 29130086c3b8df146c8c599f5ba47038efa10faf Mon Sep 17 00:00:00 2001 From: Thomas Traub Date: Fri, 4 Nov 2011 14:16:43 +0100 Subject: Add file exists check to prevent stat failed error warnings in the log These occur when creating .zips by passing data and creating an artificial fs structure inside the .zip --- system/libraries/Zip.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system') diff --git a/system/libraries/Zip.php b/system/libraries/Zip.php index 9101eecb4..8e4357051 100644 --- a/system/libraries/Zip.php +++ b/system/libraries/Zip.php @@ -100,7 +100,7 @@ class CI_Zip { function _get_mod_time($dir) { // filemtime() will return false, but it does raise an error. - $date = (@filemtime($dir)) ? filemtime($dir) : getdate($this->now); + $date = (file_exists($dir) && @filemtime($dir)) ? filemtime($dir) : getdate($this->now); $time['file_mtime'] = ($date['hours'] << 11) + ($date['minutes'] << 5) + $date['seconds'] / 2; $time['file_mdate'] = (($date['year'] - 1980) << 9) + ($date['mon'] << 5) + $date['mday']; -- cgit v1.2.3-24-g4f1b From 0372f1ade3029c8363f1ed13545590c45d45d82f Mon Sep 17 00:00:00 2001 From: a-krebs Date: Wed, 23 Nov 2011 00:04:34 -0700 Subject: fix to issue #696 - make oci_execute calls inside num_rows non-committing, since they are only there to reset which row is next in line for oci_fetch calls and thus don't need to be committed. --- system/database/drivers/oci8/oci8_result.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'system') diff --git a/system/database/drivers/oci8/oci8_result.php b/system/database/drivers/oci8/oci8_result.php index 3ec71a9d6..f32559289 100644 --- a/system/database/drivers/oci8/oci8_result.php +++ b/system/database/drivers/oci8/oci8_result.php @@ -57,11 +57,11 @@ class CI_DB_oci8_result extends CI_DB_result { if ($this->num_rows === 0 && count($this->result_array()) > 0) { $this->num_rows = count($this->result_array()); - @oci_execute($this->stmt_id); + @oci_execute($this->stmt_id, OCI_DEFAULT); if ($this->curs_id) { - @oci_execute($this->curs_id); + @oci_execute($this->curs_id, OCI_DEFAULT); } } -- cgit v1.2.3-24-g4f1b From 65134ce0b594c378679c92c40fb835cf9ab5cdd0 Mon Sep 17 00:00:00 2001 From: Timothy Warren Date: Mon, 28 Nov 2011 08:45:03 -0500 Subject: Fixed sytax error in pdo driver --- system/database/drivers/pdo/pdo_driver.php | 4 ---- 1 file changed, 4 deletions(-) (limited to 'system') diff --git a/system/database/drivers/pdo/pdo_driver.php b/system/database/drivers/pdo/pdo_driver.php index 5f63a3771..18a508b15 100644 --- a/system/database/drivers/pdo/pdo_driver.php +++ b/system/database/drivers/pdo/pdo_driver.php @@ -255,11 +255,7 @@ class CI_DB_pdo_driver extends CI_DB { // Reset the transaction failure flag. // If the $test_mode flag is set to TRUE transactions will be rolled back // even if the queries produce a successful result. -<<<<<<< HEAD - $this->_trans_failure = ($test_mode === TRUE) ? TRUE : FALSE; -======= $this->_trans_failure = (bool) ($test_mode === TRUE); ->>>>>>> master return $this->conn_id->beginTransaction(); } -- cgit v1.2.3-24-g4f1b From 5d581b6d664c6ef662bcb9572ca147ac17af52cb Mon Sep 17 00:00:00 2001 From: Felix Balfoort Date: Tue, 29 Nov 2011 15:53:01 +0100 Subject: The DB_driver can now use failover databases if specified The DB_driver can now use failover databases if specified. If the main connection shouldn't connect for some reason the DB_driver will now try to connect to specified connections in the failover config. Example config: $db['default']['hostname'] = 'localhost'; $db['default']['username'] = ''; $db['default']['password'] = ''; $db['default']['database'] = ''; $db['default']['dbdriver'] = 'mysql'; $db['default']['dbprefix'] = ''; $db['default']['pconnect'] = TRUE; $db['default']['db_debug'] = TRUE; $db['default']['cache_on'] = FALSE; $db['default']['cachedir'] = ''; $db['default']['char_set'] = 'utf8'; $db['default']['dbcollat'] = 'utf8_general_ci'; $db['default']['swap_pre'] = ''; $db['default']['autoinit'] = TRUE; $db['default']['stricton'] = FALSE; $db['default']['failover'] = array(); $db['default']['failover'][0]['hostname'] = 'localhost1'; $db['default']['failover'][0]['username'] = ''; $db['default']['failover'][0]['password'] = ''; $db['default']['failover'][0]['database'] = ''; $db['default']['failover'][0]['dbdriver'] = 'mysql'; $db['default']['failover'][0]['dbprefix'] = ''; $db['default']['failover'][0]['pconnect'] = TRUE; $db['default']['failover'][0]['db_debug'] = TRUE; $db['default']['failover'][0]['cache_on'] = FALSE; $db['default']['failover'][0]['cachedir'] = ''; $db['default']['failover'][0]['char_set'] = 'utf8'; $db['default']['failover'][0]['dbcollat'] = 'utf8_general_ci'; $db['default']['failover'][0]['swap_pre'] = ''; $db['default']['failover'][0]['autoinit'] = TRUE; $db['default']['failover'][0]['stricton'] = FALSE; $db['default']['failover'][0]['failover'] = array(); $db['default']['failover'][1]['hostname'] = 'localhost2'; $db['default']['failover'][1]['username'] = ''; $db['default']['failover'][1]['password'] = ''; $db['default']['failover'][1]['database'] = ''; $db['default']['failover'][1]['dbdriver'] = 'mysql'; $db['default']['failover'][1]['dbprefix'] = ''; $db['default']['failover'][1]['pconnect'] = TRUE; $db['default']['failover'][1]['db_debug'] = TRUE; $db['default']['failover'][1]['cache_on'] = FALSE; $db['default']['failover'][1]['cachedir'] = ''; $db['default']['failover'][1]['char_set'] = 'utf8'; $db['default']['failover'][1]['dbcollat'] = 'utf8_general_ci'; $db['default']['failover'][1]['swap_pre'] = ''; $db['default']['failover'][1]['autoinit'] = TRUE; $db['default']['failover'][1]['stricton'] = FALSE; $db['default']['failover'][1]['failover'] = array(); Signed-off-by: Felix Balfoort --- system/database/DB_driver.php | 37 ++++++++++++++++++++++++++++++++----- 1 file changed, 32 insertions(+), 5 deletions(-) (limited to 'system') diff --git a/system/database/DB_driver.php b/system/database/DB_driver.php index cc40ba48a..c2d57a833 100644 --- a/system/database/DB_driver.php +++ b/system/database/DB_driver.php @@ -126,16 +126,43 @@ class CI_DB_driver { // Connect to the database and set the connection ID $this->conn_id = ($this->pconnect == FALSE) ? $this->db_connect() : $this->db_pconnect(); - // No connection resource? Throw an error + // No connection resource? Check if there is a failover else throw an error if ( ! $this->conn_id) { - log_message('error', 'Unable to connect to the database'); + // Check if there is a failover set + if ( ! empty($this->failover) && is_array($this->failover)) + { + // Go over all the failovers + foreach ($this->failover as $failover) + { + // Replace the current settings with those of the failover + foreach ($failover as $key => $val) + { + $this->$key = $val; + } - if ($this->db_debug) + // Try to connect + $this->conn_id = ($this->pconnect == FALSE) ? $this->db_connect() : $this->db_pconnect(); + + // If a connection is made break the foreach loop + if ($this->conn_id) + { + break; + } + } + } + + // We still don't have a connection? + if ( ! $this->conn_id) { - $this->display_error('db_unable_to_connect'); + log_message('error', 'Unable to connect to the database'); + + if ($this->db_debug) + { + $this->display_error('db_unable_to_connect'); + } + return FALSE; } - return FALSE; } // ---------------------------------------------------------------- -- cgit v1.2.3-24-g4f1b From 71b78096d95fc8f5ab46686168acd702abb90dc9 Mon Sep 17 00:00:00 2001 From: Repox Date: Thu, 1 Dec 2011 09:19:43 +0100 Subject: This fixes issue #725 --- system/database/DB_driver.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'system') diff --git a/system/database/DB_driver.php b/system/database/DB_driver.php index c2d57a833..9d92f2f87 100644 --- a/system/database/DB_driver.php +++ b/system/database/DB_driver.php @@ -1064,7 +1064,14 @@ class CI_DB_driver { { $args = (func_num_args() > 1) ? array_splice(func_get_args(), 1) : null; - return call_user_func_array($function, $args); + if (is_null($args)) + { + return call_user_func($function); + } + else + { + return call_user_func_array($function, $args); + } } } -- cgit v1.2.3-24-g4f1b From 796b2b711f22775ef8e2a578bd71d065f9800442 Mon Sep 17 00:00:00 2001 From: Jack Webb-Heller Date: Thu, 1 Dec 2011 11:56:12 +0000 Subject: CodeIgniter ignores the set config value for Maximum Execution Time, overwriting it with its own value of 300 seconds. Whilst this is sensible in the vast majority of situations (browsers), when running a script from CLI, it is likely that execution times may need to be longer. Therefore, don't override the time limit if being run from the CLI - instead default back to PHP's own configuration. --- system/core/CodeIgniter.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'system') diff --git a/system/core/CodeIgniter.php b/system/core/CodeIgniter.php index 4d76a5587..abdbf91d8 100755 --- a/system/core/CodeIgniter.php +++ b/system/core/CodeIgniter.php @@ -106,9 +106,13 @@ * Set a liberal script execution time limit * ------------------------------------------------------ */ - if (function_exists("set_time_limit") == TRUE AND @ini_get("safe_mode") == 0) + if (function_exists("set_time_limit") AND @ini_get("safe_mode") == 0) { - @set_time_limit(300); + // Do not override the Time Limit value if running from Command Line + if(php_sapi_name() != 'cli' && ! empty($_SERVER['REMOTE_ADDR'])) + { + @set_time_limit(300); + } } /* -- cgit v1.2.3-24-g4f1b From eea0cbebc48d156f74c044f9932602d051eb9401 Mon Sep 17 00:00:00 2001 From: Jack Webb-Heller Date: Thu, 1 Dec 2011 13:37:08 +0000 Subject: Removed `$_SERVER['REMOTE_ADDR']` following feedback --- system/core/CodeIgniter.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system') diff --git a/system/core/CodeIgniter.php b/system/core/CodeIgniter.php index abdbf91d8..97527e5ca 100755 --- a/system/core/CodeIgniter.php +++ b/system/core/CodeIgniter.php @@ -109,7 +109,7 @@ if (function_exists("set_time_limit") AND @ini_get("safe_mode") == 0) { // Do not override the Time Limit value if running from Command Line - if(php_sapi_name() != 'cli' && ! empty($_SERVER['REMOTE_ADDR'])) + if(php_sapi_name() != 'cli') { @set_time_limit(300); } -- cgit v1.2.3-24-g4f1b From 717253f5c77a11b1b997069ff53bd2d2ab2e538c Mon Sep 17 00:00:00 2001 From: Tomasz T Date: Fri, 2 Dec 2011 17:57:30 +0100 Subject: SELECT * FROM isn't that innocuous, changed to SELECT 1 --- system/database/drivers/postgre/postgre_forge.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system') diff --git a/system/database/drivers/postgre/postgre_forge.php b/system/database/drivers/postgre/postgre_forge.php index 166cc4e6a..ddbce6062 100644 --- a/system/database/drivers/postgre/postgre_forge.php +++ b/system/database/drivers/postgre/postgre_forge.php @@ -83,7 +83,7 @@ class CI_DB_postgre_forge extends CI_DB_forge { { if ($this->db->table_exists($table)) { - return "SELECT * FROM $table"; // Needs to return innocous but valid SQL statement + return "SELECT 1"; // Needs to return innocous but valid SQL statement } } -- cgit v1.2.3-24-g4f1b From 9a4902a9708dfe3c99cd5d6d6b765288c23a6977 Mon Sep 17 00:00:00 2001 From: Eric Barnes Date: Sat, 3 Dec 2011 23:46:06 -0500 Subject: Changed visibility of pagination properties and methods. --- system/libraries/Pagination.php | 77 ++++++++++++++++++++--------------------- 1 file changed, 38 insertions(+), 39 deletions(-) (limited to 'system') diff --git a/system/libraries/Pagination.php b/system/libraries/Pagination.php index f470debeb..600aaa663 100644 --- a/system/libraries/Pagination.php +++ b/system/libraries/Pagination.php @@ -5,9 +5,9 @@ * An open source application development framework for PHP 5.1.6 or newer * * NOTICE OF LICENSE - * + * * Licensed under the Open Software License version 3.0 - * + * * This source file is subject to the Open Software License (OSL 3.0) that is * bundled with this package in the files license.txt / license.rst. It is * also available through the world wide web at this URL: @@ -38,39 +38,38 @@ */ class CI_Pagination { - var $base_url = ''; // The page we are linking to - var $prefix = ''; // A custom prefix added to the path. - var $suffix = ''; // A custom suffix added to the path. - - var $total_rows = 0; // Total number of items (database results) - var $per_page = 10; // Max number of items you want shown per page - var $num_links = 2; // Number of "digit" links to show before/after the currently viewed page - var $cur_page = 0; // The current page being viewed - var $use_page_numbers = FALSE; // Use page number for segment instead of offset - var $first_link = '‹ First'; - var $next_link = '>'; - var $prev_link = '<'; - var $last_link = 'Last ›'; - var $uri_segment = 3; - var $full_tag_open = ''; - var $full_tag_close = ''; - var $first_tag_open = ''; - var $first_tag_close = ' '; - var $last_tag_open = ' '; - var $last_tag_close = ''; - var $first_url = ''; // Alternative URL for the First Page. - var $cur_tag_open = ' '; - var $cur_tag_close = ''; - var $next_tag_open = ' '; - var $next_tag_close = ' '; - var $prev_tag_open = ' '; - var $prev_tag_close = ''; - var $num_tag_open = ' '; - var $num_tag_close = ''; - var $page_query_string = FALSE; - var $query_string_segment = 'per_page'; - var $display_pages = TRUE; - var $anchor_class = ''; + protected $base_url = ''; // The page we are linking to + protected $prefix = ''; // A custom prefix added to the path. + protected $suffix = ''; // A custom suffix added to the path. + protected $total_rows = 0; // Total number of items (database results) + protected $per_page = 10; // Max number of items you want shown per page + protected $num_links = 2; // Number of "digit" links to show before/after the currently viewed page + protected $cur_page = 0; // The current page being viewed + protected $use_page_numbers = FALSE; // Use page number for segment instead of offset + protected $first_link = '‹ First'; + protected $next_link = '>'; + protected $prev_link = '<'; + protected $last_link = 'Last ›'; + protected $uri_segment = 3; + protected $full_tag_open = ''; + protected $full_tag_close = ''; + protected $first_tag_open = ''; + protected $first_tag_close = ' '; + protected $last_tag_open = ' '; + protected $last_tag_close = ''; + protected $first_url = ''; // Alternative URL for the First Page. + protected $cur_tag_open = ' '; + protected $cur_tag_close = ''; + protected $next_tag_open = ' '; + protected $next_tag_close = ' '; + protected $prev_tag_open = ' '; + protected $prev_tag_close = ''; + protected $num_tag_open = ' '; + protected $num_tag_close = ''; + protected $page_query_string = FALSE; + protected $query_string_segment = 'per_page'; + protected $display_pages = TRUE; + protected $anchor_class = ''; /** * Constructor @@ -102,7 +101,7 @@ class CI_Pagination { * @param array initialization parameters * @return void */ - function initialize($params = array()) + public function initialize($params = array()) { if (count($params) > 0) { @@ -124,7 +123,7 @@ class CI_Pagination { * @access public * @return string */ - function create_links() + public function create_links() { // If our item count or per-page total is zero there is no need to continue. if ($this->total_rows == 0 OR $this->per_page == 0) @@ -167,7 +166,7 @@ class CI_Pagination { $this->cur_page = (int) $this->cur_page; } } - + // Set current page to 1 if using page numbers instead of offset if ($this->use_page_numbers AND $this->cur_page == 0) { @@ -204,7 +203,7 @@ class CI_Pagination { } $uri_page_number = $this->cur_page; - + if ( ! $this->use_page_numbers) { $this->cur_page = floor(($this->cur_page/$this->per_page) + 1); -- cgit v1.2.3-24-g4f1b From bce4140f05f9e8642554eac7aee232023b9a93d9 Mon Sep 17 00:00:00 2001 From: Eric Barnes Date: Sat, 3 Dec 2011 23:47:41 -0500 Subject: Changed pagination construct to call initialize so it sets the anchor class properly. Fixes #737 --- system/libraries/Pagination.php | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) (limited to 'system') diff --git a/system/libraries/Pagination.php b/system/libraries/Pagination.php index 600aaa663..eea953ae4 100644 --- a/system/libraries/Pagination.php +++ b/system/libraries/Pagination.php @@ -79,16 +79,7 @@ class CI_Pagination { */ public function __construct($params = array()) { - if (count($params) > 0) - { - $this->initialize($params); - } - - if ($this->anchor_class != '') - { - $this->anchor_class = 'class="'.$this->anchor_class.'" '; - } - + $this->initialize($params); log_message('debug', "Pagination Class Initialized"); } @@ -113,6 +104,11 @@ class CI_Pagination { } } } + + if ($this->anchor_class != '') + { + $this->anchor_class = 'class="'.$this->anchor_class.'" '; + } } // -------------------------------------------------------------------- -- cgit v1.2.3-24-g4f1b From cccde9650f061eee602013a1f3695a293f46d13e Mon Sep 17 00:00:00 2001 From: Eric Barnes Date: Sun, 4 Dec 2011 00:01:17 -0500 Subject: Fix for is_unique when you are not connected to a db. Refs: #724 --- system/libraries/Form_validation.php | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) (limited to 'system') diff --git a/system/libraries/Form_validation.php b/system/libraries/Form_validation.php index 5663da981..918f6904c 100644 --- a/system/libraries/Form_validation.php +++ b/system/libraries/Form_validation.php @@ -5,9 +5,9 @@ * An open source application development framework for PHP 5.1.6 or newer * * NOTICE OF LICENSE - * + * * Licensed under the Open Software License version 3.0 - * + * * This source file is subject to the Open Software License (OSL 3.0) that is * bundled with this package in the files license.txt / license.rst. It is * also available through the world wide web at this URL: @@ -949,7 +949,7 @@ class CI_Form_validation { return ($str !== $field) ? FALSE : TRUE; } - + // -------------------------------------------------------------------- /** @@ -962,10 +962,13 @@ class CI_Form_validation { */ public function is_unique($str, $field) { - list($table, $field)=explode('.', $field); - $query = $this->CI->db->limit(1)->get_where($table, array($field => $str)); - - return $query->num_rows() === 0; + list($table, $field) = explode('.', $field); + if (isset($this->CI->db)) + { + $query = $this->CI->db->limit(1)->get_where($table, array($field => $str)); + return $query->num_rows() === 0; + } + return FALSE; } // -------------------------------------------------------------------- -- cgit v1.2.3-24-g4f1b From 2835e08ac46ab5c260978a2013ba8837222318c5 Mon Sep 17 00:00:00 2001 From: Jeroen van der Gulik Date: Sun, 4 Dec 2011 14:19:38 +0100 Subject: - Stop logger from trying to chmod on each event to safe i/o and prevent error messages popping up when the user is different then the webserver --- system/libraries/Log.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'system') diff --git a/system/libraries/Log.php b/system/libraries/Log.php index 6ea905f73..46c5b6ed2 100644 --- a/system/libraries/Log.php +++ b/system/libraries/Log.php @@ -111,6 +111,7 @@ class CI_Log { if ( ! file_exists($filepath)) { + $newfile = TRUE; $message .= "<"."?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); ?".">\n\n"; } @@ -126,7 +127,10 @@ class CI_Log { flock($fp, LOCK_UN); fclose($fp); - @chmod($filepath, FILE_WRITE_MODE); + if (isset($newfile) AND $newfile === TRUE) + { + @chmod($filepath, FILE_WRITE_MODE); + } return TRUE; } @@ -134,4 +138,4 @@ class CI_Log { // END Log Class /* End of file Log.php */ -/* Location: ./system/libraries/Log.php */ \ No newline at end of file +/* Location: ./system/libraries/Log.php */ -- cgit v1.2.3-24-g4f1b From 98f85b177d6ebf6dbc3a2ec8313ef738eca2fbf2 Mon Sep 17 00:00:00 2001 From: Thomas Traub Date: Mon, 5 Dec 2011 14:58:29 +0100 Subject: Took out the now unnecessary error suppression --- system/libraries/Zip.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'system') diff --git a/system/libraries/Zip.php b/system/libraries/Zip.php index 8e4357051..ef6c3e530 100644 --- a/system/libraries/Zip.php +++ b/system/libraries/Zip.php @@ -99,8 +99,8 @@ class CI_Zip { */ function _get_mod_time($dir) { - // filemtime() will return false, but it does raise an error. - $date = (file_exists($dir) && @filemtime($dir)) ? filemtime($dir) : getdate($this->now); + // filemtime() may return false, but raises an error for non-existing files + $date = (file_exists($dir) && filemtime($dir)) ? filemtime($dir) : getdate($this->now); $time['file_mtime'] = ($date['hours'] << 11) + ($date['minutes'] << 5) + $date['seconds'] / 2; $time['file_mdate'] = (($date['year'] - 1980) << 9) + ($date['mon'] << 5) + $date['mday']; -- cgit v1.2.3-24-g4f1b From b9ec402de2ad190df899426f4bbcebbcc759d01f Mon Sep 17 00:00:00 2001 From: Tomasz T Date: Mon, 5 Dec 2011 15:28:33 +0100 Subject: changed create_table method to check whether a value returned from driver's forge is sql or bool (acts exactly as create_database) --- system/database/DB_forge.php | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'system') diff --git a/system/database/DB_forge.php b/system/database/DB_forge.php index 1aa2334ea..78bf77a9f 100644 --- a/system/database/DB_forge.php +++ b/system/database/DB_forge.php @@ -205,6 +205,12 @@ class CI_DB_forge { $sql = $this->_create_table($this->db->dbprefix.$table, $this->fields, $this->primary_keys, $this->keys, $if_not_exists); $this->_reset(); + + if (is_bool($sql)) + { + return $sql; + } + return $this->db->query($sql); } -- cgit v1.2.3-24-g4f1b From c9fc88c09c1a0accdddd3710907fee2f5b42d7ad Mon Sep 17 00:00:00 2001 From: Tomasz T Date: Mon, 5 Dec 2011 15:30:05 +0100 Subject: changed _create_table to return true if table already exists --- system/database/drivers/postgre/postgre_forge.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'system') diff --git a/system/database/drivers/postgre/postgre_forge.php b/system/database/drivers/postgre/postgre_forge.php index ddbce6062..df0338e73 100644 --- a/system/database/drivers/postgre/postgre_forge.php +++ b/system/database/drivers/postgre/postgre_forge.php @@ -81,9 +81,10 @@ class CI_DB_postgre_forge extends CI_DB_forge { if ($if_not_exists === TRUE) { + // PostgreSQL doesn't support IF NOT EXISTS syntax so we check if table exists manually if ($this->db->table_exists($table)) { - return "SELECT 1"; // Needs to return innocous but valid SQL statement + return TRUE; } } -- cgit v1.2.3-24-g4f1b From 7fcfbda4cd72d4198c9b45ac13bcbd47bf067b81 Mon Sep 17 00:00:00 2001 From: Thomas Traub Date: Mon, 5 Dec 2011 17:08:50 +0100 Subject: Update system/libraries/Zip.php --- system/libraries/Zip.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system') diff --git a/system/libraries/Zip.php b/system/libraries/Zip.php index ef6c3e530..2fc30e469 100644 --- a/system/libraries/Zip.php +++ b/system/libraries/Zip.php @@ -100,7 +100,7 @@ class CI_Zip { function _get_mod_time($dir) { // filemtime() may return false, but raises an error for non-existing files - $date = (file_exists($dir) && filemtime($dir)) ? filemtime($dir) : getdate($this->now); + $date = (file_exists($dir) && $filemtime = filemtime($dir)) ? $filemtime : getdate($this->now); $time['file_mtime'] = ($date['hours'] << 11) + ($date['minutes'] << 5) + $date['seconds'] / 2; $time['file_mdate'] = (($date['year'] - 1980) << 9) + ($date['mon'] << 5) + $date['mday']; -- cgit v1.2.3-24-g4f1b From dba657efda6e057dc0c741dc449937c8ba5a029a Mon Sep 17 00:00:00 2001 From: Thomas Traub Date: Tue, 6 Dec 2011 06:30:37 +0100 Subject: Update system/libraries/Zip.php --- system/libraries/Zip.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'system') diff --git a/system/libraries/Zip.php b/system/libraries/Zip.php index 2fc30e469..52f1bc3d0 100644 --- a/system/libraries/Zip.php +++ b/system/libraries/Zip.php @@ -100,8 +100,8 @@ class CI_Zip { function _get_mod_time($dir) { // filemtime() may return false, but raises an error for non-existing files - $date = (file_exists($dir) && $filemtime = filemtime($dir)) ? $filemtime : getdate($this->now); - + $date = (file_exists($dir)) ? filemtime($dir): getdate($this->now); + $time['file_mtime'] = ($date['hours'] << 11) + ($date['minutes'] << 5) + $date['seconds'] / 2; $time['file_mdate'] = (($date['year'] - 1980) << 9) + ($date['mon'] << 5) + $date['mday']; -- cgit v1.2.3-24-g4f1b From 59dbcda901f45c5183e976a0a2da7c7459294d05 Mon Sep 17 00:00:00 2001 From: toopay Date: Thu, 8 Dec 2011 20:42:41 +0700 Subject: Exception for sqlite --- system/database/drivers/pdo/pdo_driver.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'system') diff --git a/system/database/drivers/pdo/pdo_driver.php b/system/database/drivers/pdo/pdo_driver.php index 18a508b15..457cf714a 100644 --- a/system/database/drivers/pdo/pdo_driver.php +++ b/system/database/drivers/pdo/pdo_driver.php @@ -90,7 +90,10 @@ class CI_DB_pdo_driver extends CI_DB { $this->_like_escape_chr = '!'; } - $this->hostname .= ";dbname=".$this->database; + if (strpos($this->hostname, 'sqlite') === FALSE) + { + $this->hostname .= ";dbname=".$this->database; + } $this->trans_enabled = FALSE; -- cgit v1.2.3-24-g4f1b From cde712ce354dcfd69f9c5e2b56ef7d6f1206d11a Mon Sep 17 00:00:00 2001 From: Eric Barnes Date: Fri, 9 Dec 2011 11:27:51 -0500 Subject: Added ability to change the separator value in the humanize function --- system/helpers/inflector_helper.php | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'system') diff --git a/system/helpers/inflector_helper.php b/system/helpers/inflector_helper.php index 513a9c54f..3393bda8f 100644 --- a/system/helpers/inflector_helper.php +++ b/system/helpers/inflector_helper.php @@ -5,9 +5,9 @@ * An open source application development framework for PHP 5.1.6 or newer * * NOTICE OF LICENSE - * + * * Licensed under the Open Software License version 3.0 - * + * * This source file is subject to the Open Software License (OSL 3.0) that is * bundled with this package in the files license.txt / license.rst. It is * also available through the world wide web at this URL: @@ -84,7 +84,7 @@ if ( ! function_exists('singular')) '/(n)ews$/' => '\1\2ews', '/([^u])s$/' => '\1', ); - + foreach ($singular_rules as $rule => $replacement) { if (preg_match($rule, $result)) @@ -115,7 +115,7 @@ if ( ! function_exists('plural')) function plural($str, $force = FALSE) { $result = strval($str); - + $plural_rules = array( '/^(ox)$/' => '\1\2en', // ox '/([m|l])ouse$/' => '\1ice', // mouse, louse @@ -196,20 +196,20 @@ if ( ! function_exists('underscore')) /** * Humanize * - * Takes multiple words separated by underscores and changes them to spaces + * Takes multiple words separated by the separator and changes them to spaces * * @access public - * @param string + * @param string $str + * @param string $separator * @return str */ if ( ! function_exists('humanize')) { - function humanize($str) + function humanize($str, $separator = '_') { - return ucwords(preg_replace('/[_]+/', ' ', strtolower(trim($str)))); + return ucwords(preg_replace('/['.$separator.']+/', ' ', strtolower(trim($str)))); } } - /* End of file inflector_helper.php */ /* Location: ./system/helpers/inflector_helper.php */ \ No newline at end of file -- cgit v1.2.3-24-g4f1b From 2e5bda3bde171e71306c80479f04d886127d88a2 Mon Sep 17 00:00:00 2001 From: Andrew Seymour Date: Tue, 13 Dec 2011 11:40:15 +0000 Subject: Updated Cart.php to handle quantity changes differently (now auto-increments), also updated the changelog to reflect this change for the people that are currently using this library --- system/libraries/Cart.php | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) (limited to 'system') diff --git a/system/libraries/Cart.php b/system/libraries/Cart.php index a0e1bb91e..13485a3ee 100644 --- a/system/libraries/Cart.php +++ b/system/libraries/Cart.php @@ -41,6 +41,7 @@ class CI_Cart { // These are the regular expression rules that we use to validate the product ID and product name var $product_id_rules = '\.a-z0-9_-'; // alpha-numeric, dashes, underscores, or periods var $product_name_rules = '\.\:\-_ a-z0-9'; // alpha-numeric, dashes, underscores, colons or periods + var $product_name_safe = true; // only allow safe product names // Private variables. Do not change! var $CI; @@ -195,10 +196,13 @@ class CI_Cart { // Validate the product name. It can only be alpha-numeric, dashes, underscores, colons or periods. // Note: These can be user-specified by setting the $this->product_name_rules variable. - if ( ! preg_match("/^[".$this->product_name_rules."]+$/i", $items['name'])) + if($this->product_name_safe) { - log_message('error', 'An invalid name was submitted as the product name: '.$items['name'].' The name can only contain alpha-numeric characters, dashes, underscores, colons, and spaces'); - return FALSE; + if ( ! preg_match("/^[".$this->product_name_rules."]+$/i", $items['name'])) + { + log_message('error', 'An invalid name was submitted as the product name: '.$items['name'].' The name can only contain alpha-numeric characters, dashes, underscores, colons, and spaces'); + return FALSE; + } } // -------------------------------------------------------------------- @@ -242,7 +246,18 @@ class CI_Cart { // -------------------------------------------------------------------- // Now that we have our unique "row ID", we'll add our cart items to the master array - + // grab quantity if it's already there and add it on + if(isset($this->_cart_contents[$rowid]['qty'])) + { + // set our old quantity + $old_quantity = (int)$this->_cart_contents[$rowid]['qty']; + } + else + { + // we have no old quantity but - we don't want to throw an error + $old_quantity = 0; + } + // let's unset this first, just to make sure our index contains only the data from this submission unset($this->_cart_contents[$rowid]); @@ -254,7 +269,10 @@ class CI_Cart { { $this->_cart_contents[$rowid][$key] = $val; } - + + // add old quantity back in + $this->_cart_contents[$rowid]['qty'] = ($this->_cart_contents[$rowid]['qty'] + $old_quantity); + // Woot! return $rowid; } -- cgit v1.2.3-24-g4f1b From 3dd66631330841e4d0e29a95fc279a5d5cc921f2 Mon Sep 17 00:00:00 2001 From: Andrew Seymour Date: Tue, 13 Dec 2011 15:50:52 +0000 Subject: Merged the two if's together as suggested by @philsturgeon - updated the Changelog to include something that may be important --- system/libraries/Cart.php | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) (limited to 'system') diff --git a/system/libraries/Cart.php b/system/libraries/Cart.php index 13485a3ee..f9f3bca47 100644 --- a/system/libraries/Cart.php +++ b/system/libraries/Cart.php @@ -196,13 +196,10 @@ class CI_Cart { // Validate the product name. It can only be alpha-numeric, dashes, underscores, colons or periods. // Note: These can be user-specified by setting the $this->product_name_rules variable. - if($this->product_name_safe) + if ( $this->product_name_safe && ! preg_match("/^[".$this->product_name_rules."]+$/i", $items['name'])) { - if ( ! preg_match("/^[".$this->product_name_rules."]+$/i", $items['name'])) - { - log_message('error', 'An invalid name was submitted as the product name: '.$items['name'].' The name can only contain alpha-numeric characters, dashes, underscores, colons, and spaces'); - return FALSE; - } + log_message('error', 'An invalid name was submitted as the product name: '.$items['name'].' The name can only contain alpha-numeric characters, dashes, underscores, colons, and spaces'); + return FALSE; } // -------------------------------------------------------------------- -- cgit v1.2.3-24-g4f1b From fefff9fcdfc26676b8c57653c3d8176b729901b2 Mon Sep 17 00:00:00 2001 From: Andrew Seymour Date: Tue, 13 Dec 2011 15:52:50 +0000 Subject: Spacing added, @philsturgeon is too picky! --- system/libraries/Cart.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system') diff --git a/system/libraries/Cart.php b/system/libraries/Cart.php index f9f3bca47..997b9b8de 100644 --- a/system/libraries/Cart.php +++ b/system/libraries/Cart.php @@ -244,7 +244,7 @@ class CI_Cart { // Now that we have our unique "row ID", we'll add our cart items to the master array // grab quantity if it's already there and add it on - if(isset($this->_cart_contents[$rowid]['qty'])) + if( isset($this->_cart_contents[$rowid]['qty'])) { // set our old quantity $old_quantity = (int)$this->_cart_contents[$rowid]['qty']; -- cgit v1.2.3-24-g4f1b From de2e96a298cc48b8e86a03d530bc328bd43b0c80 Mon Sep 17 00:00:00 2001 From: Andrew Seymour Date: Tue, 13 Dec 2011 16:44:59 +0000 Subject: Added the ability to get the contents in a different order --- system/libraries/Cart.php | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'system') diff --git a/system/libraries/Cart.php b/system/libraries/Cart.php index 997b9b8de..2e580863b 100644 --- a/system/libraries/Cart.php +++ b/system/libraries/Cart.php @@ -476,9 +476,17 @@ class CI_Cart { * @access public * @return array */ - function contents() + function contents($newest_first = false) { - $cart = $this->_cart_contents; + // do we want the newest first? + if($newest_first) + { + // reverse the array + $cart = array_reverse($this->_cart_contents); + } else { + // just added first to last + $cart = $this->_cast_contents; + } // Remove these so they don't create a problem when showing the cart table unset($cart['total_items']); -- cgit v1.2.3-24-g4f1b From 17aebce8e06fae0edf1d54cf6823f1b8f48924c0 Mon Sep 17 00:00:00 2001 From: Andrew Seymour Date: Tue, 13 Dec 2011 16:57:13 +0000 Subject: Changed the syntax slightly, @philsturgeon may be claustrophobic as he doesn't like no spaces --- system/libraries/Cart.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system') diff --git a/system/libraries/Cart.php b/system/libraries/Cart.php index 2e580863b..e78ecd5f6 100644 --- a/system/libraries/Cart.php +++ b/system/libraries/Cart.php @@ -244,7 +244,7 @@ class CI_Cart { // Now that we have our unique "row ID", we'll add our cart items to the master array // grab quantity if it's already there and add it on - if( isset($this->_cart_contents[$rowid]['qty'])) + if (isset($this->_cart_contents[$rowid]['qty'])) { // set our old quantity $old_quantity = (int)$this->_cart_contents[$rowid]['qty']; -- cgit v1.2.3-24-g4f1b From f75ec11d7ed0592f930dd3a090db7c1c6d251eed Mon Sep 17 00:00:00 2001 From: Andrew Seymour Date: Wed, 14 Dec 2011 09:36:39 +0000 Subject: Added in a remove item from cart function to save the "hacky" method of updating a product with 0 quantity, updated the changelog to reflect and to be neater and more readable surrounding the changes of the Cart library --- system/libraries/Cart.php | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) (limited to 'system') diff --git a/system/libraries/Cart.php b/system/libraries/Cart.php index e78ecd5f6..7f6cdf5dd 100644 --- a/system/libraries/Cart.php +++ b/system/libraries/Cart.php @@ -450,7 +450,29 @@ class CI_Cart { { return $this->_cart_contents['cart_total']; } - + + // -------------------------------------------------------------------- + + /** + * Remove Item + * + * Removes an item from the cart + * + * @access public + * @return boolean + */ + public function remove($rowid) + { + // just do an unset + unset($this->_cart_contents[$rowid]); + + // we need to save the cart now we've made our changes + $this->_save_cart(); + + // completed + return true; + } + // -------------------------------------------------------------------- /** -- cgit v1.2.3-24-g4f1b From 3a67ed15d984a341612af9e1dd9ba52f30d02e89 Mon Sep 17 00:00:00 2001 From: Andrew Seymour Date: Wed, 14 Dec 2011 15:35:06 +0000 Subject: Slight syntax change to the Cart class --- system/libraries/Cart.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'system') diff --git a/system/libraries/Cart.php b/system/libraries/Cart.php index 7f6cdf5dd..717ccd9fb 100644 --- a/system/libraries/Cart.php +++ b/system/libraries/Cart.php @@ -505,7 +505,9 @@ class CI_Cart { { // reverse the array $cart = array_reverse($this->_cart_contents); - } else { + } + else + { // just added first to last $cart = $this->_cast_contents; } -- cgit v1.2.3-24-g4f1b From 79c1c46c4c99ca143a1231f7fd6b845f7276e1fd Mon Sep 17 00:00:00 2001 From: Joel Kallman Date: Sun, 18 Dec 2011 19:25:45 -0500 Subject: Makes form open properly when empty array of parameters is passed Signed-off-by: Joel Kallman --- system/helpers/form_helper.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system') diff --git a/system/helpers/form_helper.php b/system/helpers/form_helper.php index 0f02bcf75..347e8be90 100644 --- a/system/helpers/form_helper.php +++ b/system/helpers/form_helper.php @@ -1000,7 +1000,7 @@ if ( ! function_exists('_attributes_to_string')) $attributes = (array)$attributes; } - if (is_array($attributes) AND count($attributes) > 0) + if (is_array($attributes) AND ($formtag === TRUE OR count($attributes) > 0)) { $atts = ''; -- cgit v1.2.3-24-g4f1b From 4eea9895e8ced75a1099c56215c09773de94b92c Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Mon, 19 Dec 2011 12:05:41 +0200 Subject: Add method visibility declarations and optimize display_errors() method in Image_lib, Trackback and Upload libraries --- system/libraries/Image_lib.php | 58 +++++++++++++++++++----------------------- system/libraries/Trackback.php | 42 +++++++++++++----------------- system/libraries/Upload.php | 10 ++------ 3 files changed, 46 insertions(+), 64 deletions(-) (limited to 'system') diff --git a/system/libraries/Image_lib.php b/system/libraries/Image_lib.php index 2ed488c7e..c4797e34a 100644 --- a/system/libraries/Image_lib.php +++ b/system/libraries/Image_lib.php @@ -114,7 +114,7 @@ class CI_Image_lib { * @access public * @return void */ - function clear() + public function clear() { $props = array('library_path', 'source_image', 'new_image', 'width', 'height', 'rotation_angle', 'x_axis', 'y_axis', 'wm_text', 'wm_overlay_path', 'wm_font_path', 'wm_shadow_color', 'source_folder', 'dest_folder', 'mime_type', 'orig_width', 'orig_height', 'image_type', 'size_str', 'full_src_path', 'full_dst_path'); @@ -158,7 +158,7 @@ class CI_Image_lib { * @param array * @return bool */ - function initialize($props = array()) + public function initialize($props = array()) { /* * Convert array elements into class variables @@ -379,7 +379,7 @@ class CI_Image_lib { * @access public * @return bool */ - function resize() + public function resize() { $protocol = 'image_process_'.$this->image_library; @@ -402,7 +402,7 @@ class CI_Image_lib { * @access public * @return bool */ - function crop() + public function crop() { $protocol = 'image_process_'.$this->image_library; @@ -425,7 +425,7 @@ class CI_Image_lib { * @access public * @return bool */ - function rotate() + public function rotate() { // Allowed rotation values $degs = array(90, 180, 270, 'vrt', 'hor'); @@ -478,7 +478,7 @@ class CI_Image_lib { * @param string * @return bool */ - function image_process_gd($action = 'resize') + public function image_process_gd($action = 'resize') { $v2_override = FALSE; @@ -590,7 +590,7 @@ class CI_Image_lib { * @param string * @return bool */ - function image_process_imagemagick($action = 'resize') + public function image_process_imagemagick($action = 'resize') { // Do we have a vaild library path? if ($this->library_path == '') @@ -660,7 +660,7 @@ class CI_Image_lib { * @param string * @return bool */ - function image_process_netpbm($action = 'resize') + public function image_process_netpbm($action = 'resize') { if ($this->library_path == '') { @@ -743,7 +743,7 @@ class CI_Image_lib { * @access public * @return bool */ - function image_rotate_gd() + public function image_rotate_gd() { // Create the image handle if ( ! ($src_img = $this->image_create_gd())) @@ -796,7 +796,7 @@ class CI_Image_lib { * @access public * @return bool */ - function image_mirror_gd() + public function image_mirror_gd() { if ( ! $src_img = $this->image_create_gd()) { @@ -882,7 +882,7 @@ class CI_Image_lib { * @param string * @return bool */ - function watermark() + public function watermark() { if ($this->wm_type == 'overlay') { @@ -902,7 +902,7 @@ class CI_Image_lib { * @access public * @return bool */ - function overlay_watermark() + public function overlay_watermark() { if ( ! function_exists('imagecolortransparent')) { @@ -1015,7 +1015,7 @@ class CI_Image_lib { * @access public * @return bool */ - function text_watermark() + public function text_watermark() { if ( ! ($src_img = $this->image_create_gd())) { @@ -1159,7 +1159,7 @@ class CI_Image_lib { * @param string * @return resource */ - function image_create_gd($path = '', $image_type = '') + public function image_create_gd($path = '', $image_type = '') { if ($path == '') $path = $this->full_src_path; @@ -1216,7 +1216,7 @@ class CI_Image_lib { * @param resource * @return bool */ - function image_save_gd($resource) + public function image_save_gd($resource) { switch ($this->image_type) { @@ -1277,7 +1277,7 @@ class CI_Image_lib { * @param resource * @return void */ - function image_display_gd($resource) + public function image_display_gd($resource) { header("Content-Disposition: filename={$this->source_image};"); header("Content-Type: {$this->mime_type}"); @@ -1312,7 +1312,7 @@ class CI_Image_lib { * @access public * @return void */ - function image_reproportion() + public function image_reproportion() { if ( ! is_numeric($this->width) OR ! is_numeric($this->height) OR $this->width == 0 OR $this->height == 0) return; @@ -1354,7 +1354,7 @@ class CI_Image_lib { * @param string * @return mixed */ - function get_image_properties($path = '', $return = FALSE) + public function get_image_properties($path = '', $return = FALSE) { // For now we require GD but we should // find a way to determine this using IM or NetPBM @@ -1414,7 +1414,7 @@ class CI_Image_lib { * @param array * @return array */ - function size_calculator($vals) + public function size_calculator($vals) { if ( ! is_array($vals)) { @@ -1462,7 +1462,7 @@ class CI_Image_lib { * @param array * @return array */ - function explode_name($source_image) + public function explode_name($source_image) { $ext = strrchr($source_image, '.'); $name = ($ext === FALSE) ? $source_image : substr($source_image, 0, -strlen($ext)); @@ -1478,7 +1478,7 @@ class CI_Image_lib { * @access public * @return bool */ - function gd_loaded() + public function gd_loaded() { if ( ! extension_loaded('gd')) { @@ -1499,7 +1499,7 @@ class CI_Image_lib { * @access public * @return mixed */ - function gd_version() + public function gd_version() { if (function_exists('gd_info')) { @@ -1521,7 +1521,7 @@ class CI_Image_lib { * @param string * @return void */ - function set_error($msg) + public function set_error($msg) { $CI =& get_instance(); $CI->lang->load('imglib'); @@ -1553,19 +1553,13 @@ class CI_Image_lib { * @param string * @return string */ - function display_errors($open = '

', $close = '

') + public function display_errors($open = '

', $close = '

') { - $str = ''; - foreach ($this->error_msg as $val) - { - $str .= $open.$val.$close; - } - - return $str; + return (count($this->error_msg) > 0) ? $open . implode($close . $open, $this->error_msg) . $close : ''; } } // END Image_lib Class /* End of file Image_lib.php */ -/* Location: ./system/libraries/Image_lib.php */ \ No newline at end of file +/* Location: ./system/libraries/Image_lib.php */ diff --git a/system/libraries/Trackback.php b/system/libraries/Trackback.php index e903ea7d0..3fa55ca20 100644 --- a/system/libraries/Trackback.php +++ b/system/libraries/Trackback.php @@ -5,9 +5,9 @@ * An open source application development framework for PHP 5.1.6 or newer * * NOTICE OF LICENSE - * + * * Licensed under the Open Software License version 3.0 - * + * * This source file is subject to the Open Software License (OSL 3.0) that is * bundled with this package in the files license.txt / license.rst. It is * also available through the world wide web at this URL: @@ -66,7 +66,7 @@ class CI_Trackback { * @param array * @return bool */ - function send($tb_data) + public function send($tb_data) { if ( ! is_array($tb_data)) { @@ -147,7 +147,7 @@ class CI_Trackback { * @access public * @return bool */ - function receive() + public function receive() { foreach (array('url', 'title', 'blog_name', 'excerpt') as $val) { @@ -190,7 +190,7 @@ class CI_Trackback { * @param string * @return void */ - function send_error($message = 'Incomplete Information') + public function send_error($message = 'Incomplete Information') { echo "\n\n1\n".$message."\n"; exit; @@ -207,7 +207,7 @@ class CI_Trackback { * @access public * @return void */ - function send_success() + public function send_success() { echo "\n\n0\n"; exit; @@ -222,7 +222,7 @@ class CI_Trackback { * @param string * @return string */ - function data($item) + public function data($item) { return ( ! isset($this->data[$item])) ? '' : $this->data[$item]; } @@ -240,7 +240,7 @@ class CI_Trackback { * @param string * @return bool */ - function process($url, $data) + public function process($url, $data) { $target = parse_url($url); @@ -309,7 +309,7 @@ class CI_Trackback { * @param string * @return string */ - function extract_urls($urls) + public function extract_urls($urls) { // Remove the pesky white space and replace with a comma. $urls = preg_replace("/\s*(\S+)\s*/", "\\1,", $urls); @@ -345,7 +345,7 @@ class CI_Trackback { * @param string * @return string */ - function validate_url($url) + public function validate_url($url) { $url = trim($url); @@ -364,7 +364,7 @@ class CI_Trackback { * @param string * @return string */ - function get_id($url) + public function get_id($url) { $tb_id = ""; @@ -413,7 +413,7 @@ class CI_Trackback { * @param string * @return string */ - function convert_xml($str) + public function convert_xml($str) { $temp = '__TEMP_AMPERSANDS__'; @@ -443,7 +443,7 @@ class CI_Trackback { * @param string * @return string */ - function limit_characters($str, $n = 500, $end_char = '…') + public function limit_characters($str, $n = 500, $end_char = '…') { if (strlen($str) < $n) { @@ -480,7 +480,7 @@ class CI_Trackback { * @param string * @return string */ - function convert_ascii($str) + public function convert_ascii($str) { $count = 1; $out = ''; @@ -526,7 +526,7 @@ class CI_Trackback { * @param string * @return void */ - function set_error($msg) + public function set_error($msg) { log_message('error', $msg); $this->error_msg[] = $msg; @@ -542,19 +542,13 @@ class CI_Trackback { * @param string * @return string */ - function display_errors($open = '

', $close = '

') + public function display_errors($open = '

', $close = '

') { - $str = ''; - foreach ($this->error_msg as $val) - { - $str .= $open.$val.$close; - } - - return $str; + return (count($this->error_msg) > 0) ? $open . implode($close . $open, $this->error_msg) . $close : ''; } } // END Trackback Class /* End of file Trackback.php */ -/* Location: ./system/libraries/Trackback.php */ \ No newline at end of file +/* Location: ./system/libraries/Trackback.php */ diff --git a/system/libraries/Upload.php b/system/libraries/Upload.php index 66e91c5b6..ab97d1a0f 100644 --- a/system/libraries/Upload.php +++ b/system/libraries/Upload.php @@ -934,13 +934,7 @@ class CI_Upload { */ public function display_errors($open = '

', $close = '

') { - $str = ''; - foreach ($this->error_msg as $val) - { - $str .= $open.$val.$close; - } - - return $str; + return (count($this->error_msg) > 0) ? $open . implode($close . $open, $this->error_msg) . $close : ''; } // -------------------------------------------------------------------- @@ -1086,4 +1080,4 @@ class CI_Upload { // END Upload Class /* End of file Upload.php */ -/* Location: ./system/libraries/Upload.php */ \ No newline at end of file +/* Location: ./system/libraries/Upload.php */ -- cgit v1.2.3-24-g4f1b From dc3e4bedb39afe30d95635e5258aaecec4dfd74c Mon Sep 17 00:00:00 2001 From: Eric Barnes Date: Mon, 19 Dec 2011 13:48:29 -0500 Subject: Fixed year and month seconds for timespan(). --- system/helpers/date_helper.php | 70 +++++++++++++++++++++--------------------- 1 file changed, 35 insertions(+), 35 deletions(-) (limited to 'system') diff --git a/system/helpers/date_helper.php b/system/helpers/date_helper.php index 8c92fdc89..49dbdbeb3 100644 --- a/system/helpers/date_helper.php +++ b/system/helpers/date_helper.php @@ -5,9 +5,9 @@ * An open source application development framework for PHP 5.1.6 or newer * * NOTICE OF LICENSE - * + * * Licensed under the Open Software License version 3.0 - * + * * This source file is subject to the Open Software License (OSL 3.0) that is * bundled with this package in the files license.txt / license.rst. It is * also available through the world wide web at this URL: @@ -96,14 +96,14 @@ if ( ! function_exists('mdate')) { if ($datestr == '') { - return ''; + return ''; } $time = ($time == '') ? now() : $time; $datestr = str_replace( - '%\\', - '', + '%\\', + '', preg_replace("/([a-z]+?){1}/i", "\\\\\\1", $datestr) ); @@ -181,15 +181,15 @@ if ( ! function_exists('timespan')) $seconds = ($time <= $seconds) ? 1 : $time - $seconds; $str = ''; - $years = floor($seconds / 31536000); + $years = floor($seconds / 31557600); if ($years > 0) { $str .= $years.' '.$CI->lang->line((($years > 1) ? 'date_years' : 'date_year')).', '; } - $seconds -= $years * 31536000; - $months = floor($seconds / 2628000); + $seconds -= $years * 31557600; + $months = floor($seconds / 2629743); if ($years > 0 OR $months > 0) { @@ -198,7 +198,7 @@ if ( ! function_exists('timespan')) $str .= $months.' '.$CI->lang->line((($months > 1) ? 'date_months' : 'date_month')).', '; } - $seconds -= $months * 2628000; + $seconds -= $months * 2629743; } $weeks = floor($seconds / 604800); @@ -315,13 +315,13 @@ if ( ! function_exists('local_to_gmt')) { $time = time(); } - + return mktime( - gmdate("H", $time), - gmdate("i", $time), - gmdate("s", $time), - gmdate("m", $time), - gmdate("d", $time), + gmdate("H", $time), + gmdate("i", $time), + gmdate("s", $time), + gmdate("m", $time), + gmdate("d", $time), gmdate("Y", $time) ); } @@ -494,17 +494,17 @@ if ( ! function_exists('human_to_unix')) if (substr($ampm, 0, 1) == 'p' AND $hour < 12) { - $hour = $hour + 12; + $hour = $hour + 12; } if (substr($ampm, 0, 1) == 'a' AND $hour == 12) { $hour = '00'; } - + if (strlen($hour) == 1) { - $hour = '0'.$hour; + $hour = '0'.$hour; } } @@ -517,7 +517,7 @@ if ( ! function_exists('human_to_unix')) /** * Turns many "reasonably-date-like" strings into something * that is actually useful. This only works for dates after unix epoch. - * + * * @access public * @param string The terribly formatted date-like string * @param string Date format to return (same as php date function) @@ -525,7 +525,7 @@ if ( ! function_exists('human_to_unix')) */ if ( ! function_exists('nice_date')) { - function nice_date($bad_date = '', $format = FALSE) + function nice_date($bad_date = '', $format = FALSE) { if (empty($bad_date)) { @@ -533,47 +533,47 @@ if ( ! function_exists('nice_date')) } // Date like: YYYYMM - if (preg_match('/^\d{6}$/', $bad_date)) + if (preg_match('/^\d{6}$/', $bad_date)) { - if (in_array(substr($bad_date, 0, 2),array('19', '20'))) + if (in_array(substr($bad_date, 0, 2),array('19', '20'))) { $year = substr($bad_date, 0, 4); $month = substr($bad_date, 4, 2); - } - else + } + else { $month = substr($bad_date, 0, 2); $year = substr($bad_date, 2, 4); } - + return date($format, strtotime($year . '-' . $month . '-01')); } - + // Date Like: YYYYMMDD - if (preg_match('/^\d{8}$/',$bad_date)) + if (preg_match('/^\d{8}$/',$bad_date)) { $month = substr($bad_date, 0, 2); $day = substr($bad_date, 2, 2); $year = substr($bad_date, 4, 4); - + return date($format, strtotime($month . '/01/' . $year)); } - + // Date Like: MM-DD-YYYY __or__ M-D-YYYY (or anything in between) if (preg_match('/^\d{1,2}-\d{1,2}-\d{4}$/',$bad_date)) - { + { list($m, $d, $y) = explode('-', $bad_date); return date($format, strtotime("{$y}-{$m}-{$d}")); } - + // Any other kind of string, when converted into UNIX time, // produces "0 seconds after epoc..." is probably bad... // return "Invalid Date". if (date('U', strtotime($bad_date)) == '0') - { + { return "Invalid Date"; } - + // It's probably a valid-ish date format already return date($format, strtotime($bad_date)); } @@ -688,9 +688,9 @@ if ( ! function_exists('timezones')) { return $zones; } - + $tz = ($tz == 'GMT') ? 'UTC' : $tz; - + return ( ! isset($zones[$tz])) ? 0 : $zones[$tz]; } } -- cgit v1.2.3-24-g4f1b From c4caf5a181344e48fc6740f1383dd302f5b604d2 Mon Sep 17 00:00:00 2001 From: Mancy Date: Tue, 20 Dec 2011 11:47:51 +0300 Subject: taking care of LIKE when used in UPDATE statement #798 --- system/database/DB_active_rec.php | 2 +- system/database/drivers/mysql/mysql_driver.php | 11 ++++++++++- 2 files changed, 11 insertions(+), 2 deletions(-) (limited to 'system') diff --git a/system/database/DB_active_rec.php b/system/database/DB_active_rec.php index 43920772a..7a608c4f0 100644 --- a/system/database/DB_active_rec.php +++ b/system/database/DB_active_rec.php @@ -1424,7 +1424,7 @@ class CI_DB_active_record extends CI_DB_driver { $this->limit($limit); } - $sql = $this->_update($this->_protect_identifiers($this->ar_from[0], TRUE, NULL, FALSE), $this->ar_set, $this->ar_where, $this->ar_orderby, $this->ar_limit); + $sql = $this->_update($this->_protect_identifiers($this->ar_from[0], TRUE, NULL, FALSE), $this->ar_set, $this->ar_where, $this->ar_orderby, $this->ar_limit, , $this->ar_like); $this->_reset_write(); return $this->query($sql); diff --git a/system/database/drivers/mysql/mysql_driver.php b/system/database/drivers/mysql/mysql_driver.php index 828ef006b..7952312ab 100644 --- a/system/database/drivers/mysql/mysql_driver.php +++ b/system/database/drivers/mysql/mysql_driver.php @@ -606,7 +606,7 @@ class CI_DB_mysql_driver extends CI_DB { * @param array the limit clause * @return string */ - function _update($table, $values, $where, $orderby = array(), $limit = FALSE) + function _update($table, $values, $where, $orderby = array(), $limit = FALSE, $like = array()) { foreach ($values as $key => $val) { @@ -620,6 +620,15 @@ class CI_DB_mysql_driver extends CI_DB { $sql = "UPDATE ".$table." SET ".implode(', ', $valstr); $sql .= ($where != '' AND count($where) >=1) ? " WHERE ".implode(" ", $where) : ''; + + if (count($like) > 0) { + $sql .= ($where == '' AND count($where) <1) ? " WHERE " : ' AND '; + foreach ($like as $st_like) { + + $sql .= " " . $st_like; + + } + } $sql .= $orderby.$limit; -- cgit v1.2.3-24-g4f1b From 205d02936cf76f9b430129d9b704c182933cfee4 Mon Sep 17 00:00:00 2001 From: Mancy Date: Tue, 20 Dec 2011 12:45:58 +0300 Subject: #798: following current codeigniter code standards --- system/database/drivers/mysql/mysql_driver.php | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'system') diff --git a/system/database/drivers/mysql/mysql_driver.php b/system/database/drivers/mysql/mysql_driver.php index 7952312ab..6ded6e531 100644 --- a/system/database/drivers/mysql/mysql_driver.php +++ b/system/database/drivers/mysql/mysql_driver.php @@ -621,12 +621,13 @@ class CI_DB_mysql_driver extends CI_DB { $sql .= ($where != '' AND count($where) >=1) ? " WHERE ".implode(" ", $where) : ''; - if (count($like) > 0) { + if (count($like) > 0) + { $sql .= ($where == '' AND count($where) <1) ? " WHERE " : ' AND '; - foreach ($like as $st_like) { - - $sql .= " " . $st_like; - + + foreach ($like as $st_like) + { + $sql .= " " . $st_like; } } -- cgit v1.2.3-24-g4f1b From 0d91fd2956812e07905d8047ef95a0e556edbb1a Mon Sep 17 00:00:00 2001 From: Mancy Date: Tue, 20 Dec 2011 13:13:14 +0300 Subject: #798: update changelog and typo fix --- system/database/DB_active_rec.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system') diff --git a/system/database/DB_active_rec.php b/system/database/DB_active_rec.php index 7a608c4f0..41950e7d8 100644 --- a/system/database/DB_active_rec.php +++ b/system/database/DB_active_rec.php @@ -1424,7 +1424,7 @@ class CI_DB_active_record extends CI_DB_driver { $this->limit($limit); } - $sql = $this->_update($this->_protect_identifiers($this->ar_from[0], TRUE, NULL, FALSE), $this->ar_set, $this->ar_where, $this->ar_orderby, $this->ar_limit, , $this->ar_like); + $sql = $this->_update($this->_protect_identifiers($this->ar_from[0], TRUE, NULL, FALSE), $this->ar_set, $this->ar_where, $this->ar_orderby, $this->ar_limit, $this->ar_like); $this->_reset_write(); return $this->query($sql); -- cgit v1.2.3-24-g4f1b From 3a45957a30ff908445b2772efac8fdb65b64e6cd Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Wed, 21 Dec 2011 11:23:11 +0200 Subject: Also replace old-style 'var' with 'public' --- system/libraries/Image_lib.php | 90 +++++++++++++++++++++--------------------- system/libraries/Trackback.php | 12 +++--- system/libraries/Upload.php | 4 +- 3 files changed, 53 insertions(+), 53 deletions(-) (limited to 'system') diff --git a/system/libraries/Image_lib.php b/system/libraries/Image_lib.php index c4797e34a..20ca1f055 100644 --- a/system/libraries/Image_lib.php +++ b/system/libraries/Image_lib.php @@ -38,55 +38,55 @@ */ class CI_Image_lib { - var $image_library = 'gd2'; // Can be: imagemagick, netpbm, gd, gd2 - var $library_path = ''; - var $dynamic_output = FALSE; // Whether to send to browser or write to disk - var $source_image = ''; - var $new_image = ''; - var $width = ''; - var $height = ''; - var $quality = '90'; - var $create_thumb = FALSE; - var $thumb_marker = '_thumb'; - var $maintain_ratio = TRUE; // Whether to maintain aspect ratio when resizing or use hard values - var $master_dim = 'auto'; // auto, height, or width. Determines what to use as the master dimension - var $rotation_angle = ''; - var $x_axis = ''; - var $y_axis = ''; + public $image_library = 'gd2'; // Can be: imagemagick, netpbm, gd, gd2 + public $library_path = ''; + public $dynamic_output = FALSE; // Whether to send to browser or write to disk + public $source_image = ''; + public $new_image = ''; + public $width = ''; + public $height = ''; + public $quality = '90'; + public $create_thumb = FALSE; + public $thumb_marker = '_thumb'; + public $maintain_ratio = TRUE; // Whether to maintain aspect ratio when resizing or use hard values + public $master_dim = 'auto'; // auto, height, or width. Determines what to use as the master dimension + public $rotation_angle = ''; + public $x_axis = ''; + public $y_axis = ''; // Watermark Vars - var $wm_text = ''; // Watermark text if graphic is not used - var $wm_type = 'text'; // Type of watermarking. Options: text/overlay - var $wm_x_transp = 4; - var $wm_y_transp = 4; - var $wm_overlay_path = ''; // Watermark image path - var $wm_font_path = ''; // TT font - var $wm_font_size = 17; // Font size (different versions of GD will either use points or pixels) - var $wm_vrt_alignment = 'B'; // Vertical alignment: T M B - var $wm_hor_alignment = 'C'; // Horizontal alignment: L R C - var $wm_padding = 0; // Padding around text - var $wm_hor_offset = 0; // Lets you push text to the right - var $wm_vrt_offset = 0; // Lets you push text down - var $wm_font_color = '#ffffff'; // Text color - var $wm_shadow_color = ''; // Dropshadow color - var $wm_shadow_distance = 2; // Dropshadow distance - var $wm_opacity = 50; // Image opacity: 1 - 100 Only works with image + public $wm_text = ''; // Watermark text if graphic is not used + public $wm_type = 'text'; // Type of watermarking. Options: text/overlay + public $wm_x_transp = 4; + public $wm_y_transp = 4; + public $wm_overlay_path = ''; // Watermark image path + public $wm_font_path = ''; // TT font + public $wm_font_size = 17; // Font size (different versions of GD will either use points or pixels) + public $wm_vrt_alignment = 'B'; // Vertical alignment: T M B + public $wm_hor_alignment = 'C'; // Horizontal alignment: L R C + public $wm_padding = 0; // Padding around text + public $wm_hor_offset = 0; // Lets you push text to the right + public $wm_vrt_offset = 0; // Lets you push text down + public $wm_font_color = '#ffffff'; // Text color + public $wm_shadow_color = ''; // Dropshadow color + public $wm_shadow_distance = 2; // Dropshadow distance + public $wm_opacity = 50; // Image opacity: 1 - 100 Only works with image // Private Vars - var $source_folder = ''; - var $dest_folder = ''; - var $mime_type = ''; - var $orig_width = ''; - var $orig_height = ''; - var $image_type = ''; - var $size_str = ''; - var $full_src_path = ''; - var $full_dst_path = ''; - var $create_fnc = 'imagecreatetruecolor'; - var $copy_fnc = 'imagecopyresampled'; - var $error_msg = array(); - var $wm_use_drop_shadow = FALSE; - var $wm_use_truetype = FALSE; + public $source_folder = ''; + public $dest_folder = ''; + public $mime_type = ''; + public $orig_width = ''; + public $orig_height = ''; + public $image_type = ''; + public $size_str = ''; + public $full_src_path = ''; + public $full_dst_path = ''; + public $create_fnc = 'imagecreatetruecolor'; + public $copy_fnc = 'imagecopyresampled'; + public $error_msg = array(); + public $wm_use_drop_shadow = FALSE; + public $wm_use_truetype = FALSE; /** * Constructor diff --git a/system/libraries/Trackback.php b/system/libraries/Trackback.php index 3fa55ca20..1e5928314 100644 --- a/system/libraries/Trackback.php +++ b/system/libraries/Trackback.php @@ -40,12 +40,12 @@ */ class CI_Trackback { - var $time_format = 'local'; - var $charset = 'UTF-8'; - var $data = array('url' => '', 'title' => '', 'excerpt' => '', 'blog_name' => '', 'charset' => ''); - var $convert_ascii = TRUE; - var $response = ''; - var $error_msg = array(); + public $time_format = 'local'; + public $charset = 'UTF-8'; + public $data = array('url' => '', 'title' => '', 'excerpt' => '', 'blog_name' => '', 'charset' => ''); + public $convert_ascii = TRUE; + public $response = ''; + public $error_msg = array(); /** * Constructor diff --git a/system/libraries/Upload.php b/system/libraries/Upload.php index ab97d1a0f..826bcceb8 100644 --- a/system/libraries/Upload.php +++ b/system/libraries/Upload.php @@ -5,9 +5,9 @@ * An open source application development framework for PHP 5.1.6 or newer * * NOTICE OF LICENSE - * + * * Licensed under the Open Software License version 3.0 - * + * * This source file is subject to the Open Software License (OSL 3.0) that is * bundled with this package in the files license.txt / license.rst. It is * also available through the world wide web at this URL: -- cgit v1.2.3-24-g4f1b From bb2488305194e50881df0971bf4f33f30d974d36 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Wed, 21 Dec 2011 16:42:51 +0200 Subject: Improved the Cart library --- system/libraries/Cart.php | 196 +++++++++++++++------------------------------- 1 file changed, 61 insertions(+), 135 deletions(-) (limited to 'system') diff --git a/system/libraries/Cart.php b/system/libraries/Cart.php index 717ccd9fb..b2cc2081e 100644 --- a/system/libraries/Cart.php +++ b/system/libraries/Cart.php @@ -1,13 +1,13 @@ -CI =& get_instance(); // Are any config settings being passed manually? If so, set them - $config = array(); - if (count($params) > 0) - { - foreach ($params as $key => $val) - { - $config[$key] = $val; - } - } + $config = is_array($params) ? $params : array(); // Load the Sessions class $this->CI->load->library('session', $config); - // Grab the shopping cart array from the session table, if it exists - if ($this->CI->session->userdata('cart_contents') !== FALSE) - { - $this->_cart_contents = $this->CI->session->userdata('cart_contents'); - } - else + // Grab the shopping cart array from the session table + $this->_cart_contents = $this->CI->session->userdata('cart_contents'); + if ($this->_cart_contents === FALSE) { // No cart exists so we'll set some base values - $this->_cart_contents['cart_total'] = 0; - $this->_cart_contents['total_items'] = 0; + $this->_cart_contents = array('cart_total' => 0, 'total_items' => 0); } log_message('debug', "Cart Class Initialized"); @@ -95,10 +84,10 @@ class CI_Cart { * @param array * @return bool */ - function insert($items = array()) + public function insert($items = array()) { // Was any cart data passed? No? Bah... - if ( ! is_array($items) OR count($items) == 0) + if ( ! is_array($items) OR count($items) === 0) { log_message('error', 'The insert method must be passed an array containing data.'); return FALSE; @@ -132,7 +121,7 @@ class CI_Cart { } // Save the cart data if the insert was successful - if ($save_cart == TRUE) + if ($save_cart === TRUE) { $this->_save_cart(); return isset($rowid) ? $rowid : TRUE; @@ -150,10 +139,10 @@ class CI_Cart { * @param array * @return bool */ - function _insert($items = array()) + private function _insert($items = array()) { // Was any cart data passed? No? Bah... - if ( ! is_array($items) OR count($items) == 0) + if ( ! is_array($items) OR count($items) === 0) { log_message('error', 'The insert method must be passed an array containing data.'); return FALSE; @@ -170,10 +159,8 @@ class CI_Cart { // -------------------------------------------------------------------- - // Prep the quantity. It can only be a number. Duh... - $items['qty'] = trim(preg_replace('/([^0-9])/i', '', $items['qty'])); - // Trim any leading zeros - $items['qty'] = trim(preg_replace('/(^[0]+)/i', '', $items['qty'])); + // Prep the quantity. It can only be a number. Duh... also trim any leading zeros + $items['qty'] = ltrim(trim(preg_replace('/([^0-9])/i', '', $items['qty'])), '0'); // If the quantity is zero or blank there's nothing for us to do if ( ! is_numeric($items['qty']) OR $items['qty'] == 0) @@ -186,7 +173,7 @@ class CI_Cart { // Validate the product ID. It can only be alpha-numeric, dashes, underscores or periods // Not totally sure we should impose this rule, but it seems prudent to standardize IDs. // Note: These can be user-specified by setting the $this->product_id_rules variable. - if ( ! preg_match("/^[".$this->product_id_rules."]+$/i", $items['id'])) + if ( ! preg_match('/^['.$this->product_id_rules.']+$/i', $items['id'])) { log_message('error', 'Invalid product ID. The product ID can only contain alpha-numeric characters, dashes, and underscores'); return FALSE; @@ -196,7 +183,7 @@ class CI_Cart { // Validate the product name. It can only be alpha-numeric, dashes, underscores, colons or periods. // Note: These can be user-specified by setting the $this->product_name_rules variable. - if ( $this->product_name_safe && ! preg_match("/^[".$this->product_name_rules."]+$/i", $items['name'])) + if ($this->product_name_safe && ! preg_match('/^['.$this->product_name_rules.']+$/i', $items['name'])) { log_message('error', 'An invalid name was submitted as the product name: '.$items['name'].' The name can only contain alpha-numeric characters, dashes, underscores, colons, and spaces'); return FALSE; @@ -204,10 +191,8 @@ class CI_Cart { // -------------------------------------------------------------------- - // Prep the price. Remove anything that isn't a number or decimal point. - $items['price'] = trim(preg_replace('/([^0-9\.])/i', '', $items['price'])); - // Trim any leading zeros - $items['price'] = trim(preg_replace('/(^[0]+)/i', '', $items['price'])); + // Prep the price. Remove leading zeros and anything that isn't a number or decimal point. + $items['price'] = lrtrim(trim(preg_replace('/([^0-9\.])/i', '', $items['price'])), '0'); // Is the price a valid number? if ( ! is_numeric($items['price'])) @@ -244,33 +229,13 @@ class CI_Cart { // Now that we have our unique "row ID", we'll add our cart items to the master array // grab quantity if it's already there and add it on - if (isset($this->_cart_contents[$rowid]['qty'])) - { - // set our old quantity - $old_quantity = (int)$this->_cart_contents[$rowid]['qty']; - } - else - { - // we have no old quantity but - we don't want to throw an error - $old_quantity = 0; - } - - // let's unset this first, just to make sure our index contains only the data from this submission - unset($this->_cart_contents[$rowid]); + $old_quantity = isset($this->_cart_contents[$rowid]['qty']) ? (int) $this->_cart_contents[$rowid]['qty'] : 0; - // Create a new index with our new row ID - $this->_cart_contents[$rowid]['rowid'] = $rowid; + // Re-create the entry, just to make sure our index contains only the data from this submission + $items['rowid'] = $rowid; + $items['qty'] += $old_quantity; + $this->_cart_contents[$rowid] = $items; - // And add the new items to the cart array - foreach ($items as $key => $val) - { - $this->_cart_contents[$rowid][$key] = $val; - } - - // add old quantity back in - $this->_cart_contents[$rowid]['qty'] = ($this->_cart_contents[$rowid]['qty'] + $old_quantity); - - // Woot! return $rowid; } @@ -289,10 +254,10 @@ class CI_Cart { * @param string * @return bool */ - function update($items = array()) + public function update($items = array()) { // Was any cart data passed? - if ( ! is_array($items) OR count($items) == 0) + if ( ! is_array($items) OR count($items) === 0) { return FALSE; } @@ -302,9 +267,9 @@ class CI_Cart { // determine the array type is by looking for a required array key named "id". // If it's not found we assume it's a multi-dimensional array $save_cart = FALSE; - if (isset($items['rowid']) AND isset($items['qty'])) + if (isset($items['rowid'], $items['qty'])) { - if ($this->_update($items) == TRUE) + if ($this->_update($items) === TRUE) { $save_cart = TRUE; } @@ -313,9 +278,9 @@ class CI_Cart { { foreach ($items as $val) { - if (is_array($val) AND isset($val['rowid']) AND isset($val['qty'])) + if (is_array($val) && isset($val['rowid'], $val['qty'])) { - if ($this->_update($val) == TRUE) + if ($this->_update($val) === TRUE) { $save_cart = TRUE; } @@ -324,7 +289,7 @@ class CI_Cart { } // Save the cart data if the insert was successful - if ($save_cart == TRUE) + if ($save_cart === TRUE) { $this->_save_cart(); return TRUE; @@ -347,7 +312,7 @@ class CI_Cart { * @param array * @return bool */ - function _update($items = array()) + private function _update($items = array()) { // Without these array indexes there is nothing we can do if ( ! isset($items['qty']) OR ! isset($items['rowid']) OR ! isset($this->_cart_contents[$items['rowid']])) @@ -393,15 +358,10 @@ class CI_Cart { * @access private * @return bool */ - function _save_cart() + private function _save_cart() { - // Unset these so our total can be calculated correctly below - unset($this->_cart_contents['total_items']); - unset($this->_cart_contents['cart_total']); - // Lets add up the individual prices and set the cart sub-total - $total = 0; - $items = 0; + $this->_cart_contents['total_items'] = $this->_cart_contents['cart_total'] = 0; foreach ($this->_cart_contents as $key => $val) { // We make sure the array contains the proper indexes @@ -410,17 +370,11 @@ class CI_Cart { continue; } - $total += ($val['price'] * $val['qty']); - $items += $val['qty']; - - // Set the subtotal + $this->_cart_contents['cart_total'] += ($val['price'] * $val['qty']); + $this->_cart_contents['total_items'] += $val['qty']; $this->_cart_contents[$key]['subtotal'] = ($this->_cart_contents[$key]['price'] * $this->_cart_contents[$key]['qty']); } - // Set the cart total and total items. - $this->_cart_contents['total_items'] = $items; - $this->_cart_contents['cart_total'] = $total; - // Is our cart empty? If so we delete it from the session if (count($this->_cart_contents) <= 2) { @@ -434,7 +388,6 @@ class CI_Cart { // Let's pass it to the Session class so it can be stored $this->CI->session->set_userdata(array('cart_contents' => $this->_cart_contents)); - // Woot! return TRUE; } @@ -446,13 +399,13 @@ class CI_Cart { * @access public * @return integer */ - function total() + public function total() { return $this->_cart_contents['cart_total']; } - + // -------------------------------------------------------------------- - + /** * Remove Item * @@ -463,16 +416,12 @@ class CI_Cart { */ public function remove($rowid) { - // just do an unset + // unset & save unset($this->_cart_contents[$rowid]); - - // we need to save the cart now we've made our changes $this->_save_cart(); - - // completed - return true; + return TRUE; } - + // -------------------------------------------------------------------- /** @@ -483,7 +432,7 @@ class CI_Cart { * @access public * @return integer */ - function total_items() + public function total_items() { return $this->_cart_contents['total_items']; } @@ -498,19 +447,10 @@ class CI_Cart { * @access public * @return array */ - function contents($newest_first = false) + public function contents($newest_first = FALSE) { // do we want the newest first? - if($newest_first) - { - // reverse the array - $cart = array_reverse($this->_cart_contents); - } - else - { - // just added first to last - $cart = $this->_cast_contents; - } + $cart = ($newest_first) ? array_reverse($this->_cart_contents) : $this->_cart_contents; // Remove these so they don't create a problem when showing the cart table unset($cart['total_items']); @@ -528,16 +468,11 @@ class CI_Cart { * that has options associated with it. * * @access public - * @return array + * @return bool */ - function has_options($rowid = '') + public function has_options($rowid = '') { - if ( ! isset($this->_cart_contents[$rowid]['options']) OR count($this->_cart_contents[$rowid]['options']) === 0) - { - return FALSE; - } - - return TRUE; + return (isset($this->_cart_contents[$rowid]['options']) && count($this->_cart_contents[$rowid]['options']) !== 0) ? TRUE : FALSE; } // -------------------------------------------------------------------- @@ -550,14 +485,9 @@ class CI_Cart { * @access public * @return array */ - function product_options($rowid = '') + public function product_options($rowid = '') { - if ( ! isset($this->_cart_contents[$rowid]['options'])) - { - return array(); - } - - return $this->_cart_contents[$rowid]['options']; + return isset($this->_cart_contents[$rowid]['options']) ? $this->_cart_contents[$rowid]['options'] : array(); } // -------------------------------------------------------------------- @@ -568,9 +498,9 @@ class CI_Cart { * Returns the supplied number with commas and a decimal point. * * @access public - * @return integer + * @return string */ - function format_number($n = '') + public function format_number($n = '') { if ($n == '') { @@ -591,15 +521,11 @@ class CI_Cart { * Empties the cart and kills the session * * @access public - * @return null + * @return void */ - function destroy() + public function destroy() { - unset($this->_cart_contents); - - $this->_cart_contents['cart_total'] = 0; - $this->_cart_contents['total_items'] = 0; - + $this->_cart_contents = array('cart_total' => 0, 'total_items' => 0); $this->CI->session->unset_userdata('cart_contents'); } @@ -608,4 +534,4 @@ class CI_Cart { // END Cart Class /* End of file Cart.php */ -/* Location: ./system/libraries/Cart.php */ \ No newline at end of file +/* Location: ./system/libraries/Cart.php */ -- cgit v1.2.3-24-g4f1b From 2c685fb03a4d4b5a96789b839147191ce8cffacc Mon Sep 17 00:00:00 2001 From: pporlan Date: Thu, 22 Dec 2011 12:15:25 +0100 Subject: Adding $escape parameter to the order_by function, this enables ordering by custom fields --- system/database/DB_active_rec.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'system') diff --git a/system/database/DB_active_rec.php b/system/database/DB_active_rec.php index 41950e7d8..412febfcc 100644 --- a/system/database/DB_active_rec.php +++ b/system/database/DB_active_rec.php @@ -830,9 +830,10 @@ class CI_DB_active_record extends CI_DB_driver { * * @param string * @param string direction: asc or desc + * @param bool enable field name escaping * @return object */ - public function order_by($orderby, $direction = '') + public function order_by($orderby, $direction = '', $escape = TRUE) { if (strtolower($direction) == 'random') { @@ -845,7 +846,7 @@ class CI_DB_active_record extends CI_DB_driver { } - if (strpos($orderby, ',') !== FALSE) + if ((strpos($orderby, ',') !== FALSE) && ($escape === TRUE)) { $temp = array(); foreach (explode(',', $orderby) as $part) @@ -863,7 +864,10 @@ class CI_DB_active_record extends CI_DB_driver { } else if ($direction != $this->_random_keyword) { - $orderby = $this->_protect_identifiers($orderby); + if ($escape === TRUE) + { + $orderby = $this->_protect_identifiers($orderby); + } } $orderby_statement = $orderby.$direction; -- cgit v1.2.3-24-g4f1b From 17779d6163aa3a2b0544a45f7159717c95a23c2f Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Thu, 22 Dec 2011 13:21:08 +0200 Subject: Cast to float instead of using preg_replace() for sanitizing numbers --- system/libraries/Cart.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'system') diff --git a/system/libraries/Cart.php b/system/libraries/Cart.php index b2cc2081e..01a0cb8ce 100644 --- a/system/libraries/Cart.php +++ b/system/libraries/Cart.php @@ -160,7 +160,7 @@ class CI_Cart { // -------------------------------------------------------------------- // Prep the quantity. It can only be a number. Duh... also trim any leading zeros - $items['qty'] = ltrim(trim(preg_replace('/([^0-9])/i', '', $items['qty'])), '0'); + $items['qty'] = (float) $items['qty']; // If the quantity is zero or blank there's nothing for us to do if ( ! is_numeric($items['qty']) OR $items['qty'] == 0) @@ -192,7 +192,7 @@ class CI_Cart { // -------------------------------------------------------------------- // Prep the price. Remove leading zeros and anything that isn't a number or decimal point. - $items['price'] = lrtrim(trim(preg_replace('/([^0-9\.])/i', '', $items['price'])), '0'); + $items['price'] = (float) $items['price']; // Is the price a valid number? if ( ! is_numeric($items['price'])) @@ -321,7 +321,7 @@ class CI_Cart { } // Prep the quantity - $items['qty'] = preg_replace('/([^0-9])/i', '', $items['qty']); + $items['qty'] = (float) $items['qty']; // Is the quantity a number? if ( ! is_numeric($items['qty'])) @@ -388,6 +388,7 @@ class CI_Cart { // Let's pass it to the Session class so it can be stored $this->CI->session->set_userdata(array('cart_contents' => $this->_cart_contents)); + // Woot! return TRUE; } @@ -508,7 +509,7 @@ class CI_Cart { } // Remove anything that isn't a number or decimal point. - $n = trim(preg_replace('/([^0-9\.])/i', '', $n)); + $n = (float) $n; return number_format($n, 2, '.', ','); } -- cgit v1.2.3-24-g4f1b From 83d15051930c48643dc7f684275eb92b41e26cb6 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Thu, 22 Dec 2011 13:35:42 +0200 Subject: Clean up the Driver library --- system/libraries/Driver.php | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'system') diff --git a/system/libraries/Driver.php b/system/libraries/Driver.php index 8df137e74..183a95985 100644 --- a/system/libraries/Driver.php +++ b/system/libraries/Driver.php @@ -1,13 +1,13 @@ -lib_name)) { @@ -55,11 +55,11 @@ class CI_Driver_Library { // The class will be prefixed with the parent lib $child_class = $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)); - + if (in_array($driver_name, array_map('strtolower', $this->valid_drivers))) { // check and see if the driver is in a separate file @@ -119,6 +119,7 @@ class CI_Driver_Library { * @link */ class CI_Driver { + protected $parent; private $methods = array(); @@ -238,4 +239,4 @@ class CI_Driver { // END CI_Driver CLASS /* End of file Driver.php */ -/* Location: ./system/libraries/Driver.php */ \ No newline at end of file +/* Location: ./system/libraries/Driver.php */ -- cgit v1.2.3-24-g4f1b From 1bd3d887057ce807944188f8f18142c14418b2ea Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Thu, 22 Dec 2011 15:38:20 +0200 Subject: Improve the Email library --- system/libraries/Email.php | 480 ++++++++++++++++----------------------------- 1 file changed, 172 insertions(+), 308 deletions(-) (limited to 'system') diff --git a/system/libraries/Email.php b/system/libraries/Email.php index 631b62e86..5158e859c 100644 --- a/system/libraries/Email.php +++ b/system/libraries/Email.php @@ -1,13 +1,13 @@ -_smtp_auth = ($this->smtp_user == '' AND $this->smtp_pass == '') ? FALSE : TRUE; - $this->_safe_mode = ((boolean)@ini_get("safe_mode") === FALSE) ? FALSE : TRUE; + $this->_safe_mode = (bool) @ini_get("safe_mode"); } log_message('debug', "Email Class Initialized"); @@ -140,7 +140,7 @@ class CI_Email { $this->clear(); $this->_smtp_auth = ($this->smtp_user == '' AND $this->smtp_pass == '') ? FALSE : TRUE; - $this->_safe_mode = ((boolean)@ini_get("safe_mode") === FALSE) ? FALSE : TRUE; + $this->_safe_mode = (bool) @ini_get("safe_mode"); return $this; } @@ -194,7 +194,7 @@ class CI_Email { { if (preg_match( '/\<(.*)\>/', $from, $match)) { - $from = $match['1']; + $from = $match[1]; } if ($this->validate) @@ -237,7 +237,7 @@ class CI_Email { { if (preg_match( '/\<(.*)\>/', $replyto, $match)) { - $replyto = $match['1']; + $replyto = $match[1]; } if ($this->validate) @@ -250,7 +250,7 @@ class CI_Email { $name = $replyto; } - if (strncmp($name, '"', 1) != 0) + if (strncmp($name, '"', 1) !== 0) { $name = '"'.$name.'"'; } @@ -280,7 +280,7 @@ class CI_Email { $this->validate_email($to); } - if ($this->_get_protocol() != 'mail') + if ($this->_get_protocol() !== 'mail') { $this->_set_header('To', implode(", ", $to)); } @@ -320,7 +320,7 @@ class CI_Email { $this->_set_header('Cc', implode(", ", $cc)); - if ($this->_get_protocol() == "smtp") + if ($this->_get_protocol() === 'smtp') { $this->_cc_array = $cc; } @@ -354,7 +354,7 @@ class CI_Email { $this->validate_email($bcc); } - if (($this->_get_protocol() == "smtp") OR ($this->bcc_batch_mode && count($bcc) > $this->bcc_batch_size)) + if ($this->_get_protocol() === 'smtp' OR ($this->bcc_batch_mode && count($bcc) > $this->bcc_batch_size)) { $this->_bcc_array = $bcc; } @@ -538,19 +538,13 @@ class CI_Email { */ public function set_priority($n = 3) { - if ( ! is_numeric($n)) - { - $this->priority = 3; - return; - } - - if ($n < 1 OR $n > 5) + if ( ! is_numeric($n) OR $n < 1 OR $n > 5) { $this->priority = 3; return; } - $this->priority = $n; + $this->priority = (int) $n; return $this; } @@ -565,14 +559,7 @@ class CI_Email { */ public function set_newline($newline = "\n") { - if ($newline != "\n" AND $newline != "\r\n" AND $newline != "\r") - { - $this->newline = "\n"; - return; - } - - $this->newline = $newline; - + $this->newline = ($newline !== "\n" AND $newline !== "\r\n" AND $newline !== "\r") ? "\n" : $newline; return $this; } @@ -587,14 +574,7 @@ class CI_Email { */ public function set_crlf($crlf = "\n") { - if ($crlf != "\n" AND $crlf != "\r\n" AND $crlf != "\r") - { - $this->crlf = "\n"; - return; - } - - $this->crlf = $crlf; - + $this->crlf = ($crlf !== "\n" AND $crlf !== "\r\n" AND $crlf !== "\r") ? "\n" : $crlf; return $this; } @@ -622,9 +602,7 @@ class CI_Email { */ protected function _get_message_id() { - $from = $this->_headers['Return-Path']; - $from = str_replace(">", "", $from); - $from = str_replace("<", "", $from); + $from = str_replace(array('>', '<'), array('', ''), $this->_headers['Return-Path']); return "<".uniqid('').strstr($from, '@').">"; } @@ -664,7 +642,7 @@ class CI_Email { foreach ($this->_base_charsets as $charset) { - if (strncmp($charset, $this->charset, strlen($charset)) == 0) + if (strncmp($charset, $this->charset, strlen($charset)) === 0) { $this->_encoding = '7bit'; } @@ -686,15 +664,15 @@ class CI_Email { */ protected function _get_content_type() { - if ($this->mailtype == 'html' && count($this->_attach_name) == 0) + if ($this->mailtype === 'html' && count($this->_attach_name) === 0) { return 'html'; } - elseif ($this->mailtype == 'html' && count($this->_attach_name) > 0) + elseif ($this->mailtype === 'html' && count($this->_attach_name) > 0) { return 'html-attach'; } - elseif ($this->mailtype == 'text' && count($this->_attach_name) > 0) + elseif ($this->mailtype === 'text' && count($this->_attach_name) > 0) { return 'plain-attach'; } @@ -715,9 +693,9 @@ class CI_Email { protected function _set_date() { $timezone = date("Z"); - $operator = (strncmp($timezone, '-', 1) == 0) ? '-' : '+'; + $operator = (strncmp($timezone, '-', 1) === 0) ? '-' : '+'; $timezone = abs($timezone); - $timezone = floor($timezone/3600) * 100 + ($timezone % 3600 ) / 60; + $timezone = floor($timezone/3600) * 100 + ($timezone % 3600) / 60; return sprintf("%s %s%04d", date("D, j M Y H:i:s"), $operator, $timezone); } @@ -775,7 +753,7 @@ class CI_Email { */ public function valid_email($address) { - return ( ! preg_match("/^([a-z0-9\+_\-]+)(\.[a-z0-9\+_\-]+)*@([a-z0-9\-]+\.)+[a-z]{2,6}$/ix", $address)) ? FALSE : TRUE; + return (bool) preg_match("/^([a-z0-9\+_\-]+)(\.[a-z0-9\+_\-]+)*@([a-z0-9\-]+\.)+[a-z]{2,6}$/ix", $address); } // -------------------------------------------------------------------- @@ -791,28 +769,14 @@ class CI_Email { { if ( ! is_array($email)) { - if (preg_match('/\<(.*)\>/', $email, $match)) - { - return $match['1']; - } - else - { - return $email; - } + return (preg_match('/\<(.*)\>/', $email, $match)) ? $match[1] : $email; } $clean_email = array(); foreach ($email as $addy) { - if (preg_match( '/\<(.*)\>/', $addy, $match)) - { - $clean_email[] = $match['1']; - } - else - { - $clean_email[] = $addy; - } + $clean_email[] = (preg_match( '/\<(.*)\>/', $addy, $match)) ? $match[1] : $addy; } return $clean_email; @@ -838,32 +802,15 @@ class CI_Email { return $this->word_wrap($this->alt_message, '76'); } - if (preg_match('/\(.*)\<\/body\>/si', $this->_body, $match)) - { - $body = $match['1']; - } - else - { - $body = $this->_body; - } - - $body = trim(strip_tags($body)); - $body = preg_replace( '#