From 95311be467faa2e744bbd9e932900a7cf96b081f Mon Sep 17 00:00:00 2001 From: Alex Bilbie Date: Sat, 20 Aug 2011 17:35:22 +0100 Subject: Renamed some Session library functions to make them shorter. Includes backwards compatibility. --- system/libraries/Cart.php | 10 ++++---- system/libraries/Session.php | 59 +++++++++++++++++++++++++++++++++----------- 2 files changed, 50 insertions(+), 19 deletions(-) diff --git a/system/libraries/Cart.php b/system/libraries/Cart.php index b2eaa9ad7..1caef49cd 100644 --- a/system/libraries/Cart.php +++ b/system/libraries/Cart.php @@ -59,9 +59,9 @@ class CI_Cart { $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) + if ($this->CI->session->get('cart_contents') !== FALSE) { - $this->_cart_contents = $this->CI->session->userdata('cart_contents'); + $this->_cart_contents = $this->CI->session->get('cart_contents'); } else { @@ -397,7 +397,7 @@ class CI_Cart { // Is our cart empty? If so we delete it from the session if (count($this->_cart_contents) <= 2) { - $this->CI->session->unset_userdata('cart_contents'); + $this->CI->session->rm('cart_contents'); // Nothing more to do... coffee time! return FALSE; @@ -405,7 +405,7 @@ class CI_Cart { // If we made it this far it means that our cart has data. // Let's pass it to the Session class so it can be stored - $this->CI->session->set_userdata(array('cart_contents' => $this->_cart_contents)); + $this->CI->session->set(array('cart_contents' => $this->_cart_contents)); // Woot! return TRUE; @@ -541,7 +541,7 @@ class CI_Cart { $this->_cart_contents['cart_total'] = 0; $this->_cart_contents['total_items'] = 0; - $this->CI->session->unset_userdata('cart_contents'); + $this->CI->session->rm('cart_contents'); } diff --git a/system/libraries/Session.php b/system/libraries/Session.php index 2c8a80163..3203468b2 100644 --- a/system/libraries/Session.php +++ b/system/libraries/Session.php @@ -395,7 +395,7 @@ class CI_Session { * @access public * @return void */ - function sess_destroy() + function destroy() { // Kill the session DB row if ($this->sess_use_database === TRUE AND isset($this->userdata['session_id'])) @@ -424,7 +424,7 @@ class CI_Session { * @param string * @return string */ - function userdata($item) + function get($item) { return ( ! isset($this->userdata[$item])) ? FALSE : $this->userdata[$item]; } @@ -437,7 +437,7 @@ class CI_Session { * @access public * @return array */ - function all_userdata() + function get_all() { return $this->userdata; } @@ -452,7 +452,7 @@ class CI_Session { * @param string * @return void */ - function set_userdata($newdata = array(), $newval = '') + function set($newdata = array(), $newval = '') { if (is_string($newdata)) { @@ -478,7 +478,7 @@ class CI_Session { * @access array * @return void */ - function unset_userdata($newdata = array()) + function rm($newdata = array()) { if (is_string($newdata)) { @@ -519,7 +519,7 @@ class CI_Session { foreach ($newdata as $key => $val) { $flashdata_key = $this->flashdata_key.':new:'.$key; - $this->set_userdata($flashdata_key, $val); + $this->set($flashdata_key, $val); } } } @@ -540,10 +540,10 @@ class CI_Session { // Note the function will return FALSE if the $key // provided cannot be found $old_flashdata_key = $this->flashdata_key.':old:'.$key; - $value = $this->userdata($old_flashdata_key); + $value = $this->get($old_flashdata_key); $new_flashdata_key = $this->flashdata_key.':new:'.$key; - $this->set_userdata($new_flashdata_key, $value); + $this->set($new_flashdata_key, $value); } // ------------------------------------------------------------------------ @@ -558,7 +558,7 @@ class CI_Session { function flashdata($key) { $flashdata_key = $this->flashdata_key.':old:'.$key; - return $this->userdata($flashdata_key); + return $this->get($flashdata_key); } // ------------------------------------------------------------------------ @@ -572,15 +572,15 @@ class CI_Session { */ function _flashdata_mark() { - $userdata = $this->all_userdata(); + $userdata = $this->get_all(); foreach ($userdata as $name => $value) { $parts = explode(':new:', $name); if (is_array($parts) && count($parts) === 2) { $new_name = $this->flashdata_key.':old:'.$parts[1]; - $this->set_userdata($new_name, $value); - $this->unset_userdata($name); + $this->set($new_name, $value); + $this->unset($name); } } } @@ -596,12 +596,12 @@ class CI_Session { function _flashdata_sweep() { - $userdata = $this->all_userdata(); + $userdata = $this->get_all(); foreach ($userdata as $key => $value) { if (strpos($key, ':old:')) { - $this->unset_userdata($key); + $this->unset($key); } } @@ -767,6 +767,37 @@ class CI_Session { log_message('debug', 'Session garbage collection performed.'); } } + + // -------------------------------------------------------------------- + + /** + * Backwards compatible functions + */ + + function userdata($item) + { + return $this->get($item); + } + + function all_userdata() + { + return $this->get_all(); + } + + function set_userdata($newdata) + { + $this->set($newdata); + } + + function unset_userdata($newdata) + { + $this->rm($newdata); + } + + function sess_destroy() + { + $this->destroy(); + } } -- cgit v1.2.3-24-g4f1b From f092fdffe24a65ae03b88a9596fe9e596e0ec788 Mon Sep 17 00:00:00 2001 From: Greg Aker Date: Sat, 20 Aug 2011 16:53:52 -0500 Subject: Removing duplicate instructions in the 2.0.3 update instructions. --- user_guide/installation/upgrade_203.html | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/user_guide/installation/upgrade_203.html b/user_guide/installation/upgrade_203.html index 7dbc907ea..1d37a055d 100644 --- a/user_guide/installation/upgrade_203.html +++ b/user_guide/installation/upgrade_203.html @@ -65,25 +65,21 @@ Upgrading from 2.0.2 to 2.0.3

Replace all files and directories in your "system" folder and replace your index.php file. If any modifications were made to your index.php they will need to be made fresh in this new one.

Note: If you have any custom developed files in these folders please make copies of them first.

- -

Step 2: Update CodeIgniter files

- -

Replace the files and directories in your "system" folder with the new versions:

-

Step 3: Update your main index.php file

+

Step 2: Update your main index.php file

If you are running a stock index.php file simply replace your version with the new one.

If your index.php file has internal modifications, please add your modifications to the new file and use it.

-

Step 4: Replace config/user_agents.php

+

Step 3: Replace config/user_agents.php

This config file has been updated to contain more user agent types, please copy it to application/config/user_agents.php.

-

Step 5: Change references of the EXT constant to ".php"

+

Step 4: Change references of the EXT constant to ".php"

Note: The EXT Constant has been marked as deprecated, but has not been removed from the application. You are encouraged to make the changes sooner rather than later.

-

Step 6: Remove APPPATH.'third_party' from autoload.php

+

Step 5: Remove APPPATH.'third_party' from autoload.php

Open application/autoload.php, and look for the following:

-- cgit v1.2.3-24-g4f1b From 212fb07be2a00c43483865d7b000d3549f5080b6 Mon Sep 17 00:00:00 2001 From: Ben Edmunds Date: Sat, 20 Aug 2011 14:02:33 -0500 Subject: Resolved issue 167 - Input Class Userguide Update --- user_guide/libraries/input.html | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/user_guide/libraries/input.html b/user_guide/libraries/input.html index 311f76ee9..77e28488a 100644 --- a/user_guide/libraries/input.html +++ b/user_guide/libraries/input.html @@ -73,11 +73,11 @@ Input Class

The security filtering function is called automatically when a new controller is invoked. It does the following:

    -
  • Destroys the global GET array. Since CodeIgniter does not utilize GET strings, there is no reason to allow it.
  • +
  • If $config['allow_get_array'] is FALSE(default is TRUE), destroys the global GET array.
  • Destroys all global variables in the event register_globals is turned on.
  • -
  • Filters the POST/COOKIE array keys, permitting only alpha-numeric (and a few other) characters.
  • +
  • Filters the GET/POST/COOKIE array keys, permitting only alpha-numeric (and a few other) characters.
  • Provides XSS (Cross-site Scripting Hacks) filtering. This can be enabled globally, or upon request.
  • -
  • Standardizes newline characters to \n
  • +
  • Standardizes newline characters to \n(In Windows \r\n)
@@ -133,13 +133,13 @@ else
$this->input->post('some_data', TRUE);

To return an array of all POST items call without any parameters.

-

To return all POST items and pass them through the XSS filter leave the first parameter blank while setting the second parameter to boolean;

+

To return all POST items and pass them through the XSS filter set the first parameter NULL while setting the second parameter to boolean;

The function returns FALSE (boolean) if there are no items in the POST.

- $this->input->post(); // returns all POST items with XSS filter + $this->input->post(NULL, TRUE); // returns all POST items with XSS filter
- $this->input->post(NULL, FALSE); // returns all POST items without XSS + $this->input->post(); // returns all POST items without XSS filter

$this->input->get()

@@ -149,13 +149,13 @@ else
$this->input->get('some_data', TRUE);

To return an array of all GET items call without any parameters.

-

To return all GET items and pass them through the XSS filter leave the first parameter blank while setting the second parameter to boolean;

+

To return all GET items and pass them through the XSS filter set the first parameter NULL while setting the second parameter to boolean;

The function returns FALSE (boolean) if there are no items in the GET.

- $this->input->get(); // returns all GET items with XSS filter + $this->input->get(NULL, TRUE); // returns all GET items with XSS filter
- $this->input->get(NULL, FALSE); // returns all GET items without XSS filtering + $this->input->get(); // returns all GET items without XSS filtering

$this->input->get_post()

-- cgit v1.2.3-24-g4f1b From 80f4c34d1c5a51d82ae3dd898a12466e01790f10 Mon Sep 17 00:00:00 2001 From: Ben Edmunds Date: Sat, 20 Aug 2011 14:11:21 -0500 Subject: Resolved issue 160. Removed unneeded array copy. --- system/libraries/Cache/drivers/Cache_file.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/system/libraries/Cache/drivers/Cache_file.php b/system/libraries/Cache/drivers/Cache_file.php index 13e2d1af6..edb48acb6 100644 --- a/system/libraries/Cache/drivers/Cache_file.php +++ b/system/libraries/Cache/drivers/Cache_file.php @@ -157,16 +157,15 @@ class CI_Cache_file extends CI_Driver { if (is_array($data)) { - $data = $data['data']; $mtime = filemtime($this->_cache_path.$id); - if ( ! isset($data['ttl'])) + if ( ! isset($data['data']['ttl'])) { return FALSE; } return array( - 'expire' => $mtime + $data['ttl'], + 'expire' => $mtime + $data['data']['ttl'], 'mtime' => $mtime ); } -- cgit v1.2.3-24-g4f1b From 3db2849dcf104127aee23ee69ba67011ebdfa91c Mon Sep 17 00:00:00 2001 From: Ben Edmunds Date: Sat, 20 Aug 2011 14:12:12 -0500 Subject: Resolved issue 48. Removed unneeded array copy. --- system/libraries/Cache/drivers/Cache_file.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/system/libraries/Cache/drivers/Cache_file.php b/system/libraries/Cache/drivers/Cache_file.php index edb48acb6..6c37e7005 100644 --- a/system/libraries/Cache/drivers/Cache_file.php +++ b/system/libraries/Cache/drivers/Cache_file.php @@ -165,8 +165,8 @@ class CI_Cache_file extends CI_Driver { } return array( - 'expire' => $mtime + $data['data']['ttl'], - 'mtime' => $mtime + 'expire' => $mtime + $data['data']['ttl'], + 'mtime' => $mtime ); } -- cgit v1.2.3-24-g4f1b From 98963b343cc3f21dcc16825c1a0d2673534ad516 Mon Sep 17 00:00:00 2001 From: Ben Edmunds Date: Sat, 20 Aug 2011 14:17:16 -0500 Subject: Resolved issue 65 - made action on form_open_multipart helper function call optional --- system/helpers/form_helper.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/system/helpers/form_helper.php b/system/helpers/form_helper.php index 47f93e748..d9305c00b 100644 --- a/system/helpers/form_helper.php +++ b/system/helpers/form_helper.php @@ -94,7 +94,7 @@ if ( ! function_exists('form_open')) */ if ( ! function_exists('form_open_multipart')) { - function form_open_multipart($action, $attributes = array(), $hidden = array()) + function form_open_multipart($action = '', $attributes = array(), $hidden = array()) { if (is_string($attributes)) { -- cgit v1.2.3-24-g4f1b From 90248ab1f66666f9eccc11c05dcbde25aeba3794 Mon Sep 17 00:00:00 2001 From: Greg Aker Date: Sat, 20 Aug 2011 14:23:14 -0500 Subject: Fixed a bug (#200) where MySQL queries would be malformed after calling db->count_all() then db->get() --- system/database/drivers/cubrid/cubrid_driver.php | 1 + system/database/drivers/mssql/mssql_driver.php | 1 + system/database/drivers/mysql/mysql_driver.php | 1 + system/database/drivers/mysqli/mysqli_driver.php | 1 + system/database/drivers/oci8/oci8_driver.php | 1 + system/database/drivers/odbc/odbc_driver.php | 1 + system/database/drivers/postgre/postgre_driver.php | 1 + system/database/drivers/sqlite/sqlite_driver.php | 1 + system/database/drivers/sqlsrv/sqlsrv_driver.php | 1 + user_guide/changelog.html | 1 + 10 files changed, 10 insertions(+) diff --git a/system/database/drivers/cubrid/cubrid_driver.php b/system/database/drivers/cubrid/cubrid_driver.php index 3f0109249..d01140412 100644 --- a/system/database/drivers/cubrid/cubrid_driver.php +++ b/system/database/drivers/cubrid/cubrid_driver.php @@ -398,6 +398,7 @@ class CI_DB_cubrid_driver extends CI_DB { } $row = $query->row(); + $this->_reset_select(); return (int) $row->numrows; } diff --git a/system/database/drivers/mssql/mssql_driver.php b/system/database/drivers/mssql/mssql_driver.php index 65397ed8f..b39bd9360 100644 --- a/system/database/drivers/mssql/mssql_driver.php +++ b/system/database/drivers/mssql/mssql_driver.php @@ -367,6 +367,7 @@ class CI_DB_mssql_driver extends CI_DB { } $row = $query->row(); + $this->_reset_select(); return (int) $row->numrows; } diff --git a/system/database/drivers/mysql/mysql_driver.php b/system/database/drivers/mysql/mysql_driver.php index 28c75a5e3..872504564 100644 --- a/system/database/drivers/mysql/mysql_driver.php +++ b/system/database/drivers/mysql/mysql_driver.php @@ -385,6 +385,7 @@ class CI_DB_mysql_driver extends CI_DB { } $row = $query->row(); + $this->_reset_select(); return (int) $row->numrows; } diff --git a/system/database/drivers/mysqli/mysqli_driver.php b/system/database/drivers/mysqli/mysqli_driver.php index b1796c9df..ddcaff323 100644 --- a/system/database/drivers/mysqli/mysqli_driver.php +++ b/system/database/drivers/mysqli/mysqli_driver.php @@ -386,6 +386,7 @@ class CI_DB_mysqli_driver extends CI_DB { } $row = $query->row(); + $this->_reset_select(); return (int) $row->numrows; } diff --git a/system/database/drivers/oci8/oci8_driver.php b/system/database/drivers/oci8/oci8_driver.php index 14df104ff..42cfaaefb 100644 --- a/system/database/drivers/oci8/oci8_driver.php +++ b/system/database/drivers/oci8/oci8_driver.php @@ -470,6 +470,7 @@ class CI_DB_oci8_driver extends CI_DB { } $row = $query->row(); + $this->_reset_select(); return (int) $row->numrows; } diff --git a/system/database/drivers/odbc/odbc_driver.php b/system/database/drivers/odbc/odbc_driver.php index 81e0d7cf2..5e764e071 100644 --- a/system/database/drivers/odbc/odbc_driver.php +++ b/system/database/drivers/odbc/odbc_driver.php @@ -339,6 +339,7 @@ class CI_DB_odbc_driver extends CI_DB { } $row = $query->row(); + $this->_reset_select(); return (int) $row->numrows; } diff --git a/system/database/drivers/postgre/postgre_driver.php b/system/database/drivers/postgre/postgre_driver.php index 140396885..5367f9759 100644 --- a/system/database/drivers/postgre/postgre_driver.php +++ b/system/database/drivers/postgre/postgre_driver.php @@ -385,6 +385,7 @@ class CI_DB_postgre_driver extends CI_DB { } $row = $query->row(); + $this->_reset_select(); return (int) $row->numrows; } diff --git a/system/database/drivers/sqlite/sqlite_driver.php b/system/database/drivers/sqlite/sqlite_driver.php index eb4e585b3..0cc898b38 100644 --- a/system/database/drivers/sqlite/sqlite_driver.php +++ b/system/database/drivers/sqlite/sqlite_driver.php @@ -354,6 +354,7 @@ class CI_DB_sqlite_driver extends CI_DB { } $row = $query->row(); + $this->_reset_select(); return (int) $row->numrows; } diff --git a/system/database/drivers/sqlsrv/sqlsrv_driver.php b/system/database/drivers/sqlsrv/sqlsrv_driver.php index 1d32792ce..400fd31c6 100644 --- a/system/database/drivers/sqlsrv/sqlsrv_driver.php +++ b/system/database/drivers/sqlsrv/sqlsrv_driver.php @@ -344,6 +344,7 @@ class CI_DB_sqlsrv_driver extends CI_DB { return '0'; $row = $query->row(); + $this->_reset_select(); return $row->numrows; } diff --git a/user_guide/changelog.html b/user_guide/changelog.html index 88b4363ea..332c258c7 100644 --- a/user_guide/changelog.html +++ b/user_guide/changelog.html @@ -95,6 +95,7 @@ Change Log
  • If a config class was loaded first then a library with the same name is loaded, the config would be ignored.
  • Fixed a bug (Reactor #19) where 1) the 404_override route was being ignored in some cases, and 2) auto-loaded libraries were not available to the 404_override controller when a controller existed but the requested method did not.
  • Fixed a bug (Reactor #89) where MySQL export would fail if the table had hyphens or other non alphanumeric/underscore characters.
  • +
  • Fixed a bug (#200) where MySQL queries would be malformed after calling count_all() then db->get()
  • Version 2.0.3

    -- cgit v1.2.3-24-g4f1b From 54a8dcd55f15772acd0b2b39dd8edaa7f3bfcda8 Mon Sep 17 00:00:00 2001 From: Greg Aker Date: Sat, 20 Aug 2011 14:41:51 -0500 Subject: Fixed a bug (#181) where a mis-spelling was in the form validation language file. --- system/language/english/form_validation_lang.php | 2 +- user_guide/changelog.html | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/system/language/english/form_validation_lang.php b/system/language/english/form_validation_lang.php index 3418f29ab..d1cf0399d 100644 --- a/system/language/english/form_validation_lang.php +++ b/system/language/english/form_validation_lang.php @@ -7,7 +7,7 @@ $lang['valid_emails'] = "The %s field must contain all valid email addresses."; $lang['valid_url'] = "The %s field must contain a valid URL."; $lang['valid_ip'] = "The %s field must contain a valid IP."; $lang['min_length'] = "The %s field must be at least %s characters in length."; -$lang['max_length'] = "The %s field can not exceed %s characters in length."; +$lang['max_length'] = "The %s field cannot exceed %s characters in length."; $lang['exact_length'] = "The %s field must be exactly %s characters in length."; $lang['alpha'] = "The %s field may only contain alphabetical characters."; $lang['alpha_numeric'] = "The %s field may only contain alpha-numeric characters."; diff --git a/user_guide/changelog.html b/user_guide/changelog.html index 332c258c7..3e91f47c7 100644 --- a/user_guide/changelog.html +++ b/user_guide/changelog.html @@ -96,6 +96,7 @@ Change Log
  • Fixed a bug (Reactor #19) where 1) the 404_override route was being ignored in some cases, and 2) auto-loaded libraries were not available to the 404_override controller when a controller existed but the requested method did not.
  • Fixed a bug (Reactor #89) where MySQL export would fail if the table had hyphens or other non alphanumeric/underscore characters.
  • Fixed a bug (#200) where MySQL queries would be malformed after calling count_all() then db->get()
  • +
  • Fixed a bug (#181) where a mis-spelling was in the form validation language file.
  • Version 2.0.3

    -- cgit v1.2.3-24-g4f1b From 30c9289d501e840828093fd6c2e595fd25296326 Mon Sep 17 00:00:00 2001 From: Ben Edmunds Date: Sat, 20 Aug 2011 17:40:43 -0500 Subject: Added changes to changelog --- user_guide/changelog.html | 1 + 1 file changed, 1 insertion(+) diff --git a/user_guide/changelog.html b/user_guide/changelog.html index 88b4363ea..fcc4b9140 100644 --- a/user_guide/changelog.html +++ b/user_guide/changelog.html @@ -95,6 +95,7 @@ Change Log
  • If a config class was loaded first then a library with the same name is loaded, the config would be ignored.
  • Fixed a bug (Reactor #19) where 1) the 404_override route was being ignored in some cases, and 2) auto-loaded libraries were not available to the 404_override controller when a controller existed but the requested method did not.
  • Fixed a bug (Reactor #89) where MySQL export would fail if the table had hyphens or other non alphanumeric/underscore characters.
  • +
  • Resolved issue 65 - made action on form_open_multipart helper function call optional
  • Version 2.0.3

    -- cgit v1.2.3-24-g4f1b From 5483872727be793366c4bed9f3a837cd9e63a045 Mon Sep 17 00:00:00 2001 From: Ben Edmunds Date: Sat, 20 Aug 2011 17:48:31 -0500 Subject: Added notes to changelog --- user_guide/changelog.html | 1 + 1 file changed, 1 insertion(+) diff --git a/user_guide/changelog.html b/user_guide/changelog.html index 88b4363ea..d3e6eefbb 100644 --- a/user_guide/changelog.html +++ b/user_guide/changelog.html @@ -95,6 +95,7 @@ Change Log
  • If a config class was loaded first then a library with the same name is loaded, the config would be ignored.
  • Fixed a bug (Reactor #19) where 1) the 404_override route was being ignored in some cases, and 2) auto-loaded libraries were not available to the 404_override controller when a controller existed but the requested method did not.
  • Fixed a bug (Reactor #89) where MySQL export would fail if the table had hyphens or other non alphanumeric/underscore characters.
  • +
  • Resolved issue 160. Removed unneeded array copy.
  • Version 2.0.3

    -- cgit v1.2.3-24-g4f1b From 9bcc40451f76737f787a3f7afc0fdab4842c9305 Mon Sep 17 00:00:00 2001 From: Greg Aker Date: Sat, 20 Aug 2011 22:11:00 -0500 Subject: Small tweak to the changlog item from the previous commit --- user_guide/changelog.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/user_guide/changelog.html b/user_guide/changelog.html index 3e66deaf8..2e4727d4a 100644 --- a/user_guide/changelog.html +++ b/user_guide/changelog.html @@ -97,7 +97,7 @@ Change Log
  • Fixed a bug (Reactor #89) where MySQL export would fail if the table had hyphens or other non alphanumeric/underscore characters.
  • Fixed a bug (#200) where MySQL queries would be malformed after calling count_all() then db->get()
  • Fixed a bug (#181) where a mis-spelling was in the form validation language file.
  • -
  • Resolved issue 160. Removed unneeded array copy.
  • +
  • Fixed a bug (#160). Removed unneeded array copy in the file cache driver.
  • Version 2.0.3

    -- cgit v1.2.3-24-g4f1b From ea4ad9b4e7ab7824da4274e30075fd36a6bf9952 Mon Sep 17 00:00:00 2001 From: Nithin Date: Sun, 21 Aug 2011 01:23:47 -0300 Subject: Added ability to _like paramater side to use 'none', in case one wants to query like instead of where without case being sensitive --- system/database/DB_active_rec.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/system/database/DB_active_rec.php b/system/database/DB_active_rec.php index 7bab729f5..841ede28e 100644 --- a/system/database/DB_active_rec.php +++ b/system/database/DB_active_rec.php @@ -660,8 +660,12 @@ class CI_DB_active_record extends CI_DB_driver { $prefix = (count($this->ar_like) == 0) ? '' : $type; $v = $this->escape_like_str($v); - - if ($side == 'before') + + if ($side == 'none') + { + $like_statement = $prefix." $k $not LIKE '{$v}'"; + } + elseif ($side == 'before') { $like_statement = $prefix." $k $not LIKE '%{$v}'"; } -- cgit v1.2.3-24-g4f1b From 9e8dc0e1b2175fc79b112d469626c76cc13610e3 Mon Sep 17 00:00:00 2001 From: John Bellone Date: Sun, 21 Aug 2011 08:54:56 -0400 Subject: Making changes to support other Memcached extension --- system/libraries/Cache/drivers/Cache_memcached.php | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/system/libraries/Cache/drivers/Cache_memcached.php b/system/libraries/Cache/drivers/Cache_memcached.php index ec2fd216a..405602372 100644 --- a/system/libraries/Cache/drivers/Cache_memcached.php +++ b/system/libraries/Cache/drivers/Cache_memcached.php @@ -153,7 +153,17 @@ class CI_Cache_memcached extends CI_Driver { } } - $this->_memcached = new Memcached(); + if (class_exists('Memcached')) { + $this->_memcached = new Memcached(); + } + else if (class_exists('Memcache')) { + $this->_memcached = new Memcache(); + } + else { + log_message('error', 'Failed to create object for Memcached Cache; extension not loaded?'); + + return FALSE; + } foreach ($this->_memcache_conf as $name => $cache_server) { @@ -189,7 +199,7 @@ class CI_Cache_memcached extends CI_Driver { */ public function is_supported() { - if ( ! extension_loaded('memcached')) + if ( ! extension_loaded('memcached') && ! extension_loaded('memcache')) { log_message('error', 'The Memcached Extension must be loaded to use Memcached Cache.'); -- cgit v1.2.3-24-g4f1b From d0ddeafedc2d9dfa3c1543b5e7aefd1ff29f6deb Mon Sep 17 00:00:00 2001 From: Dan Horrigan Date: Sun, 21 Aug 2011 09:07:27 -0400 Subject: Changed set_alt_message() to cast the message a string to prevent possible issues when sending NULL or FALSE. --- system/libraries/Email.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/system/libraries/Email.php b/system/libraries/Email.php index e28c23a04..f1d65a3eb 100644 --- a/system/libraries/Email.php +++ b/system/libraries/Email.php @@ -452,7 +452,7 @@ class CI_Email { */ public function set_alt_message($str = '') { - $this->alt_message = $str; + $this->alt_message = (string) $str; return $this; } -- cgit v1.2.3-24-g4f1b From 628e6607c4bbd8ea612df80bb9925b7d3ec34765 Mon Sep 17 00:00:00 2001 From: Dan Horrigan Date: Sun, 21 Aug 2011 09:08:31 -0400 Subject: Changed set_wordwrap() to cast the parameter as a boolean instead of using a ternary. Also fixed the doc block. --- system/libraries/Email.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/system/libraries/Email.php b/system/libraries/Email.php index f1d65a3eb..28a3d17b4 100644 --- a/system/libraries/Email.php +++ b/system/libraries/Email.php @@ -477,12 +477,12 @@ class CI_Email { * Set Wordwrap * * @access public - * @param string + * @param bool * @return void */ public function set_wordwrap($wordwrap = TRUE) { - $this->wordwrap = ($wordwrap === FALSE) ? FALSE : TRUE; + $this->wordwrap = (bool) $wordwrap; return $this; } -- cgit v1.2.3-24-g4f1b From cbb81c6a0e0830fa975a5cb4638e39a59504703c Mon Sep 17 00:00:00 2001 From: John Bellone Date: Sun, 21 Aug 2011 09:12:33 -0400 Subject: Formatting, damn tabs --- system/libraries/Cache/drivers/Cache_memcached.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/system/libraries/Cache/drivers/Cache_memcached.php b/system/libraries/Cache/drivers/Cache_memcached.php index 405602372..d16578fc3 100644 --- a/system/libraries/Cache/drivers/Cache_memcached.php +++ b/system/libraries/Cache/drivers/Cache_memcached.php @@ -152,7 +152,7 @@ class CI_Cache_memcached extends CI_Driver { } } } - + if (class_exists('Memcached')) { $this->_memcached = new Memcached(); } @@ -160,9 +160,9 @@ class CI_Cache_memcached extends CI_Driver { $this->_memcached = new Memcache(); } else { - log_message('error', 'Failed to create object for Memcached Cache; extension not loaded?'); + log_message('error', 'Failed to create object for Memcached Cache; extension not loaded?'); - return FALSE; + return FALSE; } foreach ($this->_memcache_conf as $name => $cache_server) -- cgit v1.2.3-24-g4f1b From 15be8fc4f1289e464fc716a7ed4a50f647f70211 Mon Sep 17 00:00:00 2001 From: Dan Horrigan Date: Sun, 21 Aug 2011 09:22:49 -0400 Subject: Changed the 'development' environment default error reporting to included E_STRICT errors. E_ALL does not include these errors. --- index.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.php b/index.php index f4ac11a72..7555158a5 100644 --- a/index.php +++ b/index.php @@ -33,7 +33,7 @@ if (defined('ENVIRONMENT')) switch (ENVIRONMENT) { case 'development': - error_reporting(E_ALL); + error_reporting(E_ALL | E_STRICT); break; case 'testing': -- cgit v1.2.3-24-g4f1b From 0ad834c03b0300ec9bf111a69bc3af0ed724c6cd Mon Sep 17 00:00:00 2001 From: John Bellone Date: Sun, 21 Aug 2011 09:29:39 -0400 Subject: Fixing configuration --- system/libraries/Cache/drivers/Cache_memcached.php | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/system/libraries/Cache/drivers/Cache_memcached.php b/system/libraries/Cache/drivers/Cache_memcached.php index d16578fc3..8047e5853 100644 --- a/system/libraries/Cache/drivers/Cache_memcached.php +++ b/system/libraries/Cache/drivers/Cache_memcached.php @@ -182,9 +182,22 @@ class CI_Cache_memcached extends CI_Driver { $cache_server['weight'] = $this->_default_options['default_weight']; } - $this->_memcached->addServer( - $cache_server['hostname'], $cache_server['port'], $cache_server['weight'] - ); + if (get_class($this->_memcached) == 'Memcache') { + // Third parameter is persistance and defaults to TRUE. + $this->_memcached->addServer( + $cache_server['hostname'], + $cache_server['port'], + TRUE, + $cache_server['weight'] + ); + } + else { + $this->_memcached->addServer( + $cache_server['hostname'], + $cache_server['port'], + $cache_server['weight'] + ); + } } } -- cgit v1.2.3-24-g4f1b From 02d736992f45d7b3c72b900ae2b69af9ca319e6e Mon Sep 17 00:00:00 2001 From: John Bellone Date: Sun, 21 Aug 2011 09:32:35 -0400 Subject: Returning value from _setup_memcached() now --- system/libraries/Cache/drivers/Cache_memcached.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/system/libraries/Cache/drivers/Cache_memcached.php b/system/libraries/Cache/drivers/Cache_memcached.php index 8047e5853..51f317507 100644 --- a/system/libraries/Cache/drivers/Cache_memcached.php +++ b/system/libraries/Cache/drivers/Cache_memcached.php @@ -218,9 +218,8 @@ class CI_Cache_memcached extends CI_Driver { return FALSE; } - - $this->_setup_memcached(); - return TRUE; + + return $this->_setup_memcached(); } // ------------------------------------------------------------------------ -- cgit v1.2.3-24-g4f1b From 0e95b8b04f40739a26f9c945e61cedc61f4fe6c1 Mon Sep 17 00:00:00 2001 From: Dan Horrigan Date: Sun, 21 Aug 2011 09:34:02 -0400 Subject: Changed error reporting level to -1, which will show ALL PHP errors. This will future-proof the solution. Thanks @ericbarnes for pointing that out. --- index.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.php b/index.php index 7555158a5..899f4ce9b 100644 --- a/index.php +++ b/index.php @@ -33,7 +33,7 @@ if (defined('ENVIRONMENT')) switch (ENVIRONMENT) { case 'development': - error_reporting(E_ALL | E_STRICT); + error_reporting(-1); break; case 'testing': -- cgit v1.2.3-24-g4f1b From 51758fc3e9c01f850aea5ec065f1bed51d8894df Mon Sep 17 00:00:00 2001 From: John Bellone Date: Sun, 21 Aug 2011 09:38:44 -0400 Subject: Nah, who needs this? --- system/libraries/Cache/drivers/Cache_memcached.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/system/libraries/Cache/drivers/Cache_memcached.php b/system/libraries/Cache/drivers/Cache_memcached.php index 51f317507..adc6f65bc 100644 --- a/system/libraries/Cache/drivers/Cache_memcached.php +++ b/system/libraries/Cache/drivers/Cache_memcached.php @@ -199,6 +199,8 @@ class CI_Cache_memcached extends CI_Driver { ); } } + + return TRUE; } // ------------------------------------------------------------------------ @@ -219,6 +221,7 @@ class CI_Cache_memcached extends CI_Driver { return FALSE; } + return $this->_setup_memcached(); } -- cgit v1.2.3-24-g4f1b From 8eef9c77512d4fad5357d3cbda83b89f844d7d16 Mon Sep 17 00:00:00 2001 From: Joe Cianflone Date: Sun, 21 Aug 2011 10:39:06 -0400 Subject: Ability to move the view folder out of the Application directory * index.php -- added the $view_folder var and VIEWPATH constant * Loader.php -- changed the private _ci_view_paths var so that it's not hardcoded to the view dir, but looks for the VIEWPATH constant instead --- index.php | 33 +++++++++++++++++++++++++++++++++ system/core/Loader.php | 2 +- 2 files changed, 34 insertions(+), 1 deletion(-) diff --git a/index.php b/index.php index 899f4ce9b..c50cfed43 100644 --- a/index.php +++ b/index.php @@ -73,6 +73,23 @@ if (defined('ENVIRONMENT')) * */ $application_folder = 'application'; + +/* + *--------------------------------------------------------------- + * VIEW FOLDER NAME + *--------------------------------------------------------------- + * + * If you want to move the view folder out of the application + * folder set the path to the folder here. The folder can be renamed + * and relocated anywhere on your server. If blank, it will default + * to the standard location inside your application folder. If you + * do move this, use the full server path to this folder + * + * NO TRAILING SLASH! + * + */ + $view_folder = ''; + /* * -------------------------------------------------------------------- @@ -190,6 +207,22 @@ if (defined('ENVIRONMENT')) define('APPPATH', BASEPATH.$application_folder.'/'); } + + // The path to the "views" folder + if (is_dir($view_folder)) + { + define ('VIEWPATH', $view_folder .'/'); + } + else + { + if ( ! is_dir(APPPATH.'views/')) + { + exit("Your view folder path does not appear to be set correctly. Please open the following file and correct this: ".SELF); + } + + define ('VIEWPATH', APPPATH.'views/' ); + } + /* * -------------------------------------------------------------------- diff --git a/system/core/Loader.php b/system/core/Loader.php index e7fa3d3f6..452dc0b4c 100755 --- a/system/core/Loader.php +++ b/system/core/Loader.php @@ -127,7 +127,7 @@ class CI_Loader { $this->_ci_library_paths = array(APPPATH, BASEPATH); $this->_ci_helper_paths = array(APPPATH, BASEPATH); $this->_ci_model_paths = array(APPPATH); - $this->_ci_view_paths = array(APPPATH.'views/' => TRUE); + $this->_ci_view_paths = array(VIEWPATH => TRUE); log_message('debug', "Loader Class Initialized"); } -- cgit v1.2.3-24-g4f1b From c456b4ad895d4b2f6f290038bc78ae53390d5f70 Mon Sep 17 00:00:00 2001 From: John Bellone Date: Sun, 21 Aug 2011 10:41:21 -0400 Subject: Changing to set as add will not save over existing value --- system/libraries/Cache/drivers/Cache_memcached.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/system/libraries/Cache/drivers/Cache_memcached.php b/system/libraries/Cache/drivers/Cache_memcached.php index ec2fd216a..a9baf22c5 100644 --- a/system/libraries/Cache/drivers/Cache_memcached.php +++ b/system/libraries/Cache/drivers/Cache_memcached.php @@ -64,7 +64,7 @@ class CI_Cache_memcached extends CI_Driver { */ public function save($id, $data, $ttl = 60) { - return $this->_memcached->add($id, array($data, time(), $ttl), $ttl); + return $this->_memcached->set($id, array($data, time(), $ttl), $ttl); } // ------------------------------------------------------------------------ -- cgit v1.2.3-24-g4f1b From a1a8ef711ec179a183a32f6cf4502ddc48782a84 Mon Sep 17 00:00:00 2001 From: Alex Bilbie Date: Sun, 21 Aug 2011 15:44:10 +0100 Subject: Revert 43194ea1af658914a89ca49aed4dca4617b9c4ff^..HEAD --- system/libraries/Cart.php | 10 ++++---- system/libraries/Session.php | 59 +++++++++++--------------------------------- 2 files changed, 19 insertions(+), 50 deletions(-) diff --git a/system/libraries/Cart.php b/system/libraries/Cart.php index 1caef49cd..b2eaa9ad7 100644 --- a/system/libraries/Cart.php +++ b/system/libraries/Cart.php @@ -59,9 +59,9 @@ class CI_Cart { $this->CI->load->library('session', $config); // Grab the shopping cart array from the session table, if it exists - if ($this->CI->session->get('cart_contents') !== FALSE) + if ($this->CI->session->userdata('cart_contents') !== FALSE) { - $this->_cart_contents = $this->CI->session->get('cart_contents'); + $this->_cart_contents = $this->CI->session->userdata('cart_contents'); } else { @@ -397,7 +397,7 @@ class CI_Cart { // Is our cart empty? If so we delete it from the session if (count($this->_cart_contents) <= 2) { - $this->CI->session->rm('cart_contents'); + $this->CI->session->unset_userdata('cart_contents'); // Nothing more to do... coffee time! return FALSE; @@ -405,7 +405,7 @@ class CI_Cart { // If we made it this far it means that our cart has data. // Let's pass it to the Session class so it can be stored - $this->CI->session->set(array('cart_contents' => $this->_cart_contents)); + $this->CI->session->set_userdata(array('cart_contents' => $this->_cart_contents)); // Woot! return TRUE; @@ -541,7 +541,7 @@ class CI_Cart { $this->_cart_contents['cart_total'] = 0; $this->_cart_contents['total_items'] = 0; - $this->CI->session->rm('cart_contents'); + $this->CI->session->unset_userdata('cart_contents'); } diff --git a/system/libraries/Session.php b/system/libraries/Session.php index 3203468b2..2c8a80163 100644 --- a/system/libraries/Session.php +++ b/system/libraries/Session.php @@ -395,7 +395,7 @@ class CI_Session { * @access public * @return void */ - function destroy() + function sess_destroy() { // Kill the session DB row if ($this->sess_use_database === TRUE AND isset($this->userdata['session_id'])) @@ -424,7 +424,7 @@ class CI_Session { * @param string * @return string */ - function get($item) + function userdata($item) { return ( ! isset($this->userdata[$item])) ? FALSE : $this->userdata[$item]; } @@ -437,7 +437,7 @@ class CI_Session { * @access public * @return array */ - function get_all() + function all_userdata() { return $this->userdata; } @@ -452,7 +452,7 @@ class CI_Session { * @param string * @return void */ - function set($newdata = array(), $newval = '') + function set_userdata($newdata = array(), $newval = '') { if (is_string($newdata)) { @@ -478,7 +478,7 @@ class CI_Session { * @access array * @return void */ - function rm($newdata = array()) + function unset_userdata($newdata = array()) { if (is_string($newdata)) { @@ -519,7 +519,7 @@ class CI_Session { foreach ($newdata as $key => $val) { $flashdata_key = $this->flashdata_key.':new:'.$key; - $this->set($flashdata_key, $val); + $this->set_userdata($flashdata_key, $val); } } } @@ -540,10 +540,10 @@ class CI_Session { // Note the function will return FALSE if the $key // provided cannot be found $old_flashdata_key = $this->flashdata_key.':old:'.$key; - $value = $this->get($old_flashdata_key); + $value = $this->userdata($old_flashdata_key); $new_flashdata_key = $this->flashdata_key.':new:'.$key; - $this->set($new_flashdata_key, $value); + $this->set_userdata($new_flashdata_key, $value); } // ------------------------------------------------------------------------ @@ -558,7 +558,7 @@ class CI_Session { function flashdata($key) { $flashdata_key = $this->flashdata_key.':old:'.$key; - return $this->get($flashdata_key); + return $this->userdata($flashdata_key); } // ------------------------------------------------------------------------ @@ -572,15 +572,15 @@ class CI_Session { */ function _flashdata_mark() { - $userdata = $this->get_all(); + $userdata = $this->all_userdata(); foreach ($userdata as $name => $value) { $parts = explode(':new:', $name); if (is_array($parts) && count($parts) === 2) { $new_name = $this->flashdata_key.':old:'.$parts[1]; - $this->set($new_name, $value); - $this->unset($name); + $this->set_userdata($new_name, $value); + $this->unset_userdata($name); } } } @@ -596,12 +596,12 @@ class CI_Session { function _flashdata_sweep() { - $userdata = $this->get_all(); + $userdata = $this->all_userdata(); foreach ($userdata as $key => $value) { if (strpos($key, ':old:')) { - $this->unset($key); + $this->unset_userdata($key); } } @@ -767,37 +767,6 @@ class CI_Session { log_message('debug', 'Session garbage collection performed.'); } } - - // -------------------------------------------------------------------- - - /** - * Backwards compatible functions - */ - - function userdata($item) - { - return $this->get($item); - } - - function all_userdata() - { - return $this->get_all(); - } - - function set_userdata($newdata) - { - $this->set($newdata); - } - - function unset_userdata($newdata) - { - $this->rm($newdata); - } - - function sess_destroy() - { - $this->destroy(); - } } -- cgit v1.2.3-24-g4f1b From aeb2c3e532e78be9ac78ba6fd4a305b7be31d2ab Mon Sep 17 00:00:00 2001 From: Alex Bilbie Date: Sun, 21 Aug 2011 16:14:54 +0100 Subject: Added new config parameter "csrf_exclude_uris" which allows for URIs to be whitelisted from CSRF verification. Fixes #149 --- application/config/config.php | 2 ++ system/core/Security.php | 12 +++++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/application/config/config.php b/application/config/config.php index 1ec65435e..b64b11669 100644 --- a/application/config/config.php +++ b/application/config/config.php @@ -292,11 +292,13 @@ $config['global_xss_filtering'] = FALSE; | 'csrf_token_name' = The token name | 'csrf_cookie_name' = The cookie name | 'csrf_expire' = The number in seconds the token should expire. +| 'csrf_exclude_uris' = Array of URIs which ignore CSRF checks */ $config['csrf_protection'] = FALSE; $config['csrf_token_name'] = 'csrf_test_name'; $config['csrf_cookie_name'] = 'csrf_cookie_name'; $config['csrf_expire'] = 7200; +$config['csrf_exclude_uris'] = array(); /* |-------------------------------------------------------------------------- diff --git a/system/core/Security.php b/system/core/Security.php index 3617cadcc..efd30eb14 100644 --- a/system/core/Security.php +++ b/system/core/Security.php @@ -93,6 +93,16 @@ class CI_Security { { return $this->csrf_set_cookie(); } + + // Check if URI has been whitelisted from CSRF checks + if ($exclude_uris = config_item('csrf_exclude_uris')) + { + $uri = load_class('URI', 'core'); + if (in_array($uri->uri_string(), $exclude_uris)) + { + return $this; + } + } // Do the tokens exist in both the _POST and _COOKIE arrays? if ( ! isset($_POST[$this->_csrf_token_name]) OR @@ -116,7 +126,7 @@ class CI_Security { $this->_csrf_set_hash(); $this->csrf_set_cookie(); - log_message('debug', "CSRF token verified "); + log_message('debug', "CSRF token verified"); return $this; } -- cgit v1.2.3-24-g4f1b From 87c74c885991075cf42e9e78d7843290e2b0c3a7 Mon Sep 17 00:00:00 2001 From: Alex Bilbie Date: Sun, 21 Aug 2011 16:28:43 +0100 Subject: Updated Security library documentation with details on how to whitelist URIs from CSRF protection --- user_guide/libraries/security.html | 3 +++ 1 file changed, 3 insertions(+) diff --git a/user_guide/libraries/security.html b/user_guide/libraries/security.html index dd62a4386..cbe12d852 100644 --- a/user_guide/libraries/security.html +++ b/user_guide/libraries/security.html @@ -116,6 +116,9 @@ Note: This function should only be used to deal with data upon submission. It's

    If you use the form helper the form_open() function will automatically insert a hidden csrf field in your forms.

    +

    Select URIs can be whitelisted from csrf protection (for example API endpoints expecting externally POSTed content). You can add these URIs by editing the 'csrf_exclude_uris' config parameter:

    +$config['csrf_exclude_uris'] = array('api/person/add'); + -- cgit v1.2.3-24-g4f1b From 68d1f4c3e216d8490bd1b1d397c31bd51a05ecc4 Mon Sep 17 00:00:00 2001 From: Nithin Meppurathu Date: Sun, 21 Aug 2011 12:05:17 -0400 Subject: updated changelog and documentation for active record new 3rd argument option #none# to like clause --- user_guide/changelog.html | 5 +++++ user_guide/database/active_record.html | 7 +++++++ 2 files changed, 12 insertions(+) diff --git a/user_guide/changelog.html b/user_guide/changelog.html index 3e91f47c7..bb05f99e1 100644 --- a/user_guide/changelog.html +++ b/user_guide/changelog.html @@ -71,12 +71,16 @@ Change Log
  • Helpers
    • Added increment_string() to String Helper to turn "foo" into "foo-1" or "foo-1" into "foo-2".
    • +
    • Altered form helper - made action on form_open_multipart helper function call optional. Fixes (#65)
  • Database
    • Added a CUBRID driver to the Database Driver. Thanks to the CUBRID team for supplying this patch.
    • Typecast limit and offset in the Database Driver to integers to avoid possible injection.
    • +
    • + Added additional option 'none' for the optional third argument for $this->db->like() in the Database Driver. +
  • Libraries @@ -97,6 +101,7 @@ Change Log
  • Fixed a bug (Reactor #89) where MySQL export would fail if the table had hyphens or other non alphanumeric/underscore characters.
  • Fixed a bug (#200) where MySQL queries would be malformed after calling count_all() then db->get()
  • Fixed a bug (#181) where a mis-spelling was in the form validation language file.
  • +
  • Fixed a bug (#160) - Removed unneeded array copy in the file cache driver.
  • Version 2.0.3

    diff --git a/user_guide/database/active_record.html b/user_guide/database/active_record.html index 3f44fcd5b..3808cb6c3 100644 --- a/user_guide/database/active_record.html +++ b/user_guide/database/active_record.html @@ -334,6 +334,13 @@ $this->db->or_where('id >', $id); $this->db->like('title', 'match', 'both');
    // Produces: WHERE title LIKE '%match%' +If you do not want to use the wildcard (%) you can pass to the optional third argument the option 'none'. + + + $this->db->like('title', 'match', 'none');
    +// Produces: WHERE title LIKE 'match' +
    +
  • Associative array method: -- cgit v1.2.3-24-g4f1b From 24e921a12fa25d38568ff384d0980f198f360434 Mon Sep 17 00:00:00 2001 From: Phil Sturgeon Date: Sun, 21 Aug 2011 12:25:47 -0400 Subject: Fixed some stuff. --- user_guide/database/active_record.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/user_guide/database/active_record.html b/user_guide/database/active_record.html index 3f44fcd5b..a8f6159ef 100644 --- a/user_guide/database/active_record.html +++ b/user_guide/database/active_record.html @@ -525,7 +525,7 @@ $this->db->insert('mytable', $object);

    Generates an insert string based on the data you supply, and runs the query. You can either pass an array or an object to the function. Here is an example using an array:

    - + $data = array(
       array(
          'title' => 'My title' ,
    -- cgit v1.2.3-24-g4f1b From 27a883c946ee524bb7930edfcfc6e8c153119929 Mon Sep 17 00:00:00 2001 From: Phil Sturgeon Date: Sun, 21 Aug 2011 12:28:08 -0400 Subject: Fixed more awesome stuff. --- user_guide/database/active_record.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/user_guide/database/active_record.html b/user_guide/database/active_record.html index a8f6159ef..6609d287e 100644 --- a/user_guide/database/active_record.html +++ b/user_guide/database/active_record.html @@ -537,7 +537,7 @@ $data = array(
          'name' => 'Another Name' ,
          'date' => 'Another date'
       )
    -);
    +);

    $this->db->update_batch('mytable', $data);

    -- cgit v1.2.3-24-g4f1b From 090bdf6f716001ed0b388ab5860a8db5e93a2603 Mon Sep 17 00:00:00 2001 From: John Bellone Date: Sun, 21 Aug 2011 12:42:03 -0400 Subject: Fixing stylish things --- system/libraries/Cache/drivers/Cache_memcached.php | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/system/libraries/Cache/drivers/Cache_memcached.php b/system/libraries/Cache/drivers/Cache_memcached.php index adc6f65bc..7dc22406a 100644 --- a/system/libraries/Cache/drivers/Cache_memcached.php +++ b/system/libraries/Cache/drivers/Cache_memcached.php @@ -153,13 +153,16 @@ class CI_Cache_memcached extends CI_Driver { } } - if (class_exists('Memcached')) { + if (class_exists('Memcached')) + { $this->_memcached = new Memcached(); } - else if (class_exists('Memcache')) { + else if (class_exists('Memcache')) + { $this->_memcached = new Memcache(); } - else { + else + { log_message('error', 'Failed to create object for Memcached Cache; extension not loaded?'); return FALSE; @@ -182,7 +185,8 @@ class CI_Cache_memcached extends CI_Driver { $cache_server['weight'] = $this->_default_options['default_weight']; } - if (get_class($this->_memcached) == 'Memcache') { + if (get_class($this->_memcached) == 'Memcache') + { // Third parameter is persistance and defaults to TRUE. $this->_memcached->addServer( $cache_server['hostname'], @@ -191,7 +195,8 @@ class CI_Cache_memcached extends CI_Driver { $cache_server['weight'] ); } - else { + else + { $this->_memcached->addServer( $cache_server['hostname'], $cache_server['port'], -- cgit v1.2.3-24-g4f1b From 51e4bcab4d123c1ba65031dd5362c98d8c510493 Mon Sep 17 00:00:00 2001 From: John Bellone Date: Sun, 21 Aug 2011 12:43:21 -0400 Subject: I hate tabs --- system/libraries/Cache/drivers/Cache_memcached.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/system/libraries/Cache/drivers/Cache_memcached.php b/system/libraries/Cache/drivers/Cache_memcached.php index 7dc22406a..b9593b734 100644 --- a/system/libraries/Cache/drivers/Cache_memcached.php +++ b/system/libraries/Cache/drivers/Cache_memcached.php @@ -189,7 +189,7 @@ class CI_Cache_memcached extends CI_Driver { { // Third parameter is persistance and defaults to TRUE. $this->_memcached->addServer( - $cache_server['hostname'], + $cache_server['hostname'], $cache_server['port'], TRUE, $cache_server['weight'] @@ -198,7 +198,7 @@ class CI_Cache_memcached extends CI_Driver { else { $this->_memcached->addServer( - $cache_server['hostname'], + $cache_server['hostname'], $cache_server['port'], $cache_server['weight'] ); -- cgit v1.2.3-24-g4f1b From 151b7a9abed49e76232ad195cc2c010bfc82f22a Mon Sep 17 00:00:00 2001 From: Greg Aker Date: Sun, 21 Aug 2011 12:29:43 -0500 Subject: Cleaning up some tabs/spaces issues. Also stripped trailing white space from the file. --- system/libraries/Cache/drivers/Cache_memcached.php | 103 ++++++++++----------- 1 file changed, 51 insertions(+), 52 deletions(-) diff --git a/system/libraries/Cache/drivers/Cache_memcached.php b/system/libraries/Cache/drivers/Cache_memcached.php index b9593b734..ae9d6cd96 100644 --- a/system/libraries/Cache/drivers/Cache_memcached.php +++ b/system/libraries/Cache/drivers/Cache_memcached.php @@ -10,19 +10,19 @@ * @license http://codeigniter.com/user_guide/license.html * @link http://codeigniter.com * @since Version 2.0 - * @filesource + * @filesource */ // ------------------------------------------------------------------------ /** - * CodeIgniter Memcached Caching Class + * CodeIgniter Memcached Caching Class * * @package CodeIgniter * @subpackage Libraries * @category Core * @author ExpressionEngine Dev Team - * @link + * @link */ class CI_Cache_memcached extends CI_Driver { @@ -37,18 +37,18 @@ class CI_Cache_memcached extends CI_Driver { ) ); - // ------------------------------------------------------------------------ + // ------------------------------------------------------------------------ /** * Fetch from cache * * @param mixed unique key id * @return mixed data on success/false on failure - */ + */ public function get($id) - { + { $data = $this->_memcached->get($id); - + return (is_array($data)) ? $data[0] : FALSE; } @@ -68,7 +68,7 @@ class CI_Cache_memcached extends CI_Driver { } // ------------------------------------------------------------------------ - + /** * Delete from Cache * @@ -81,7 +81,7 @@ class CI_Cache_memcached extends CI_Driver { } // ------------------------------------------------------------------------ - + /** * Clean the Cache * @@ -106,7 +106,7 @@ class CI_Cache_memcached extends CI_Driver { } // ------------------------------------------------------------------------ - + /** * Get Cache Metadata * @@ -140,6 +140,7 @@ class CI_Cache_memcached extends CI_Driver { { // Try to load memcached server info from the config file. $CI =& get_instance(); + if ($CI->config->load('memcached', TRUE, TRUE)) { if (is_array($CI->config->config['memcached'])) @@ -149,24 +150,24 @@ class CI_Cache_memcached extends CI_Driver { foreach ($CI->config->config['memcached'] as $name => $conf) { $this->_memcache_conf[$name] = $conf; - } - } + } + } + } + + if (class_exists('Memcached')) + { + $this->_memcached = new Memcached(); + } + else if (class_exists('Memcache')) + { + $this->_memcached = new Memcache(); } + else + { + log_message('error', 'Failed to create object for Memcached Cache; extension not loaded?'); - if (class_exists('Memcached')) - { - $this->_memcached = new Memcached(); - } - else if (class_exists('Memcache')) - { - $this->_memcached = new Memcache(); - } - else - { - log_message('error', 'Failed to create object for Memcached Cache; extension not loaded?'); - - return FALSE; - } + return FALSE; + } foreach ($this->_memcache_conf as $name => $cache_server) { @@ -174,43 +175,42 @@ class CI_Cache_memcached extends CI_Driver { { $cache_server['hostname'] = $this->_default_options['default_host']; } - + if ( ! array_key_exists('port', $cache_server)) { $cache_server['port'] = $this->_default_options['default_port']; } - + if ( ! array_key_exists('weight', $cache_server)) { $cache_server['weight'] = $this->_default_options['default_weight']; } - - if (get_class($this->_memcached) == 'Memcache') - { - // Third parameter is persistance and defaults to TRUE. - $this->_memcached->addServer( - $cache_server['hostname'], - $cache_server['port'], - TRUE, - $cache_server['weight'] - ); - } - else - { - $this->_memcached->addServer( - $cache_server['hostname'], - $cache_server['port'], - $cache_server['weight'] - ); - } + + if (get_class($this->_memcached) == 'Memcache') + { + // Third parameter is persistance and defaults to TRUE. + $this->_memcached->addServer( + $cache_server['hostname'], + $cache_server['port'], + TRUE, + $cache_server['weight'] + ); + } + else + { + $this->_memcached->addServer( + $cache_server['hostname'], + $cache_server['port'], + $cache_server['weight'] + ); + } } - return TRUE; + return TRUE; } // ------------------------------------------------------------------------ - /** * Is supported * @@ -219,14 +219,13 @@ class CI_Cache_memcached extends CI_Driver { */ public function is_supported() { - if ( ! extension_loaded('memcached') && ! extension_loaded('memcache')) + if ( ! extension_loaded('memcached') && ! extension_loaded('memcache')) { log_message('error', 'The Memcached Extension must be loaded to use Memcached Cache.'); - + return FALSE; } - return $this->_setup_memcached(); } -- cgit v1.2.3-24-g4f1b From 7e7338e1e12fd2deb769f3d486b3bcb253e7e275 Mon Sep 17 00:00:00 2001 From: Dan Montgomery Date: Sun, 21 Aug 2011 17:50:23 -0300 Subject: Fix for issue #106 --- system/database/DB_active_rec.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/system/database/DB_active_rec.php b/system/database/DB_active_rec.php index 841ede28e..37d162bc1 100644 --- a/system/database/DB_active_rec.php +++ b/system/database/DB_active_rec.php @@ -196,7 +196,7 @@ class CI_DB_active_record extends CI_DB_driver { $alias = $this->_create_alias_from_table(trim($select)); } - $sql = $type.'('.$this->_protect_identifiers(trim($select)).') AS '.$alias; + $sql = $type.'('.$this->_protect_identifiers(trim($select)).') AS '.$this->_protect_identifiers(trim($alias)); $this->ar_select[] = $sql; -- cgit v1.2.3-24-g4f1b From 393377fd247f38d57a7324515b57fed5d84b28ff Mon Sep 17 00:00:00 2001 From: Joe Cianflone Date: Sun, 21 Aug 2011 14:57:58 -0400 Subject: Added documentation to the user guide --- user_guide/installation/index.html | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/user_guide/installation/index.html b/user_guide/installation/index.html index 5e8ab3883..84338e2e6 100644 --- a/user_guide/installation/index.html +++ b/user_guide/installation/index.html @@ -72,7 +72,9 @@ variables at the top of the file with the new name you've chosen.

    For the best security, both the system and any application folders should be placed above web root so that they are not directly accessible via a browser. By default, .htaccess files are included in each folder to help prevent direct access, but it is best to remove them from public access entirely in case the web server configuration changes or doesn't abide by the .htaccess.

    -

    After moving them, open your main index.php file and set the $system_folder and $application_folder variables, preferably with a full path, e.g. '/www/MyUser/system'.

    +

    If you would like to keep your views public it is also possible to move the views folder out of your application folder.

    + +

    After moving them, open your main index.php file and set the $system_folder, $application_folder and $view_folder variables, preferably with a full path, e.g. '/www/MyUser/system'.

    One additional measure to take in production environments is to disable -- cgit v1.2.3-24-g4f1b From fc7564545fb166553a7080b8dbd2b9941925734d Mon Sep 17 00:00:00 2001 From: danmontgomery Date: Sun, 21 Aug 2011 15:31:22 -0400 Subject: Fixed issue #150 (for mysql and mysqli), now returns the actual column length. --- system/database/drivers/mysql/mysql_driver.php | 2 +- system/database/drivers/mysql/mysql_result.php | 17 +++++++++++------ system/database/drivers/mysqli/mysqli_driver.php | 2 +- system/database/drivers/mysqli/mysqli_result.php | 19 ++++++++++++------- user_guide/changelog.html | 1 + 5 files changed, 26 insertions(+), 15 deletions(-) diff --git a/system/database/drivers/mysql/mysql_driver.php b/system/database/drivers/mysql/mysql_driver.php index 872504564..f87cfea4b 100644 --- a/system/database/drivers/mysql/mysql_driver.php +++ b/system/database/drivers/mysql/mysql_driver.php @@ -441,7 +441,7 @@ class CI_DB_mysql_driver extends CI_DB { */ function _field_data($table) { - return "SELECT * FROM ".$table." LIMIT 1"; + return "DESCRIBE ".$table; } // -------------------------------------------------------------------- diff --git a/system/database/drivers/mysql/mysql_result.php b/system/database/drivers/mysql/mysql_result.php index 507389603..2d2905c98 100644 --- a/system/database/drivers/mysql/mysql_result.php +++ b/system/database/drivers/mysql/mysql_result.php @@ -84,14 +84,19 @@ class CI_DB_mysql_result extends CI_DB_result { function field_data() { $retval = array(); - while ($field = mysql_fetch_field($this->result_id)) + while ($field = mysql_fetch_object($this->result_id)) { + preg_match('/([a-zA-Z]+)\((\d+)\)/', $field->Type, $matches); + + $type = $matches[1]; + $length = (int)$matches[2]; + $F = new stdClass(); - $F->name = $field->name; - $F->type = $field->type; - $F->default = $field->def; - $F->max_length = $field->max_length; - $F->primary_key = $field->primary_key; + $F->name = $field->Field; + $F->type = $type; + $F->default = $field->Default; + $F->max_length = $length; + $F->primary_key = ( $field->Key == 'PRI' ? 1 : 0 ); $retval[] = $F; } diff --git a/system/database/drivers/mysqli/mysqli_driver.php b/system/database/drivers/mysqli/mysqli_driver.php index ddcaff323..ccd110f79 100644 --- a/system/database/drivers/mysqli/mysqli_driver.php +++ b/system/database/drivers/mysqli/mysqli_driver.php @@ -442,7 +442,7 @@ class CI_DB_mysqli_driver extends CI_DB { */ function _field_data($table) { - return "SELECT * FROM ".$table." LIMIT 1"; + return "DESCRIBE ".$table; } // -------------------------------------------------------------------- diff --git a/system/database/drivers/mysqli/mysqli_result.php b/system/database/drivers/mysqli/mysqli_result.php index c4d8f5d58..ac863056a 100644 --- a/system/database/drivers/mysqli/mysqli_result.php +++ b/system/database/drivers/mysqli/mysqli_result.php @@ -84,21 +84,26 @@ class CI_DB_mysqli_result extends CI_DB_result { function field_data() { $retval = array(); - while ($field = mysqli_fetch_field($this->result_id)) + while ($field = mysqli_fetch_object($this->result_id)) { + preg_match('/([a-zA-Z]+)\((\d+)\)/', $field->Type, $matches); + + $type = $matches[1]; + $length = (int)$matches[2]; + $F = new stdClass(); - $F->name = $field->name; - $F->type = $field->type; - $F->default = $field->def; - $F->max_length = $field->max_length; - $F->primary_key = ($field->flags & MYSQLI_PRI_KEY_FLAG) ? 1 : 0; + $F->name = $field->Field; + $F->type = $type; + $F->default = $field->Default; + $F->max_length = $length; + $F->primary_key = ( $field->Key == 'PRI' ? 1 : 0 ); $retval[] = $F; } return $retval; } - + // -------------------------------------------------------------------- /** diff --git a/user_guide/changelog.html b/user_guide/changelog.html index 15872c1ac..5782ac0fb 100644 --- a/user_guide/changelog.html +++ b/user_guide/changelog.html @@ -99,6 +99,7 @@ Change Log

  • Fixed a bug (#200) where MySQL queries would be malformed after calling count_all() then db->get()
  • Fixed a bug (#181) where a mis-spelling was in the form validation language file.
  • Fixed a bug (#160) - Removed unneeded array copy in the file cache driver.
  • +
  • Fixed a bug (#150) - field_data() now correctly returns column length.
  • Version 2.0.3

    -- cgit v1.2.3-24-g4f1b From ccbbea1eaa8a0dd26aa05a0d860fda550f7dd7a8 Mon Sep 17 00:00:00 2001 From: Adam Jackett Date: Sun, 21 Aug 2011 16:19:11 -0400 Subject: Fixed issue #26. Added max_filename_increment as a config setting. --- system/libraries/Upload.php | 54 +++++++++++++++++--------------- user_guide/libraries/file_uploading.html | 7 +++++ 2 files changed, 35 insertions(+), 26 deletions(-) diff --git a/system/libraries/Upload.php b/system/libraries/Upload.php index 3177424c4..8f324de79 100644 --- a/system/libraries/Upload.php +++ b/system/libraries/Upload.php @@ -30,6 +30,7 @@ class CI_Upload { public $max_width = 0; public $max_height = 0; public $max_filename = 0; + public $max_filename_increment = 100; public $allowed_types = ""; public $file_temp = ""; public $file_name = ""; @@ -80,31 +81,32 @@ class CI_Upload { public function initialize($config = array()) { $defaults = array( - 'max_size' => 0, - 'max_width' => 0, - 'max_height' => 0, - 'max_filename' => 0, - 'allowed_types' => "", - 'file_temp' => "", - 'file_name' => "", - 'orig_name' => "", - 'file_type' => "", - 'file_size' => "", - 'file_ext' => "", - 'upload_path' => "", - 'overwrite' => FALSE, - 'encrypt_name' => FALSE, - 'is_image' => FALSE, - 'image_width' => '', - 'image_height' => '', - 'image_type' => '', - 'image_size_str' => '', - 'error_msg' => array(), - 'mimes' => array(), - 'remove_spaces' => TRUE, - 'xss_clean' => FALSE, - 'temp_prefix' => "temp_file_", - 'client_name' => '' + 'max_size' => 0, + 'max_width' => 0, + 'max_height' => 0, + 'max_filename' => 0, + 'max_filename_increment' => 100, + 'allowed_types' => "", + 'file_temp' => "", + 'file_name' => "", + 'orig_name' => "", + 'file_type' => "", + 'file_size' => "", + 'file_ext' => "", + 'upload_path' => "", + 'overwrite' => FALSE, + 'encrypt_name' => FALSE, + 'is_image' => FALSE, + 'image_width' => '', + 'image_height' => '', + 'image_type' => '', + 'image_size_str' => '', + 'error_msg' => array(), + 'mimes' => array(), + 'remove_spaces' => TRUE, + 'xss_clean' => FALSE, + 'temp_prefix' => "temp_file_", + 'client_name' => '' ); @@ -402,7 +404,7 @@ class CI_Upload { $filename = str_replace($this->file_ext, '', $filename); $new_filename = ''; - for ($i = 1; $i < 100; $i++) + for ($i = 1; $i < $this->max_filename_increment; $i++) { if ( ! file_exists($path.$filename.$i.$this->file_ext)) { diff --git a/user_guide/libraries/file_uploading.html b/user_guide/libraries/file_uploading.html index a88c67220..94b219355 100644 --- a/user_guide/libraries/file_uploading.html +++ b/user_guide/libraries/file_uploading.html @@ -304,6 +304,13 @@ $this->upload->initialize($config);
    The maximum length that a file name can be. Set to zero for no limit. + +max_filename_increment +100 +None +When overwrite is set to FALSE, use this to set the maximum filename increment for CodeIgniter to append to the filename. + + encrypt_name FALSE -- cgit v1.2.3-24-g4f1b From 2239277052a79434b5e8f4e9ca3ce7cd7dfc5375 Mon Sep 17 00:00:00 2001 From: Adam Jackett Date: Sun, 21 Aug 2011 16:32:35 -0400 Subject: Updated changelog for max_filename_increment setting. --- user_guide/changelog.html | 1 + 1 file changed, 1 insertion(+) diff --git a/user_guide/changelog.html b/user_guide/changelog.html index bb05f99e1..7af8f7b29 100644 --- a/user_guide/changelog.html +++ b/user_guide/changelog.html @@ -89,6 +89,7 @@ Change Log
  • Added support to set an optional parameter in your callback rules of validation using the Form Validation Library.
  • Added a Migration Library to assist with applying incremental updates to your database schema.
  • Driver children can be located in any package path.
  • +
  • Added max_filename_increment config setting for Upload library.
  • -- cgit v1.2.3-24-g4f1b From 333f9f98edeb11915c168ea4a05b9b76d64d9576 Mon Sep 17 00:00:00 2001 From: Nithin Date: Sun, 21 Aug 2011 16:52:06 -0400 Subject: added ability to log certain error types, not all under a threshold --- application/config/config.php | 4 ++++ system/libraries/Log.php | 21 ++++++++++++++++----- user_guide/changelog.html | 1 + 3 files changed, 21 insertions(+), 5 deletions(-) diff --git a/application/config/config.php b/application/config/config.php index 1ec65435e..7554f994a 100644 --- a/application/config/config.php +++ b/application/config/config.php @@ -176,6 +176,10 @@ $config['directory_trigger'] = 'd'; // experimental not currently in use | 3 = Informational Messages | 4 = All Messages | +| You can also pass in a array with threshold levels to show individual error types +| +| array(2) = Debug Messages, without Error Messages +| | For a live site you'll usually only enable Errors (1) to be logged otherwise | your log files will fill up very fast. | diff --git a/system/libraries/Log.php b/system/libraries/Log.php index 9f1db76ba..bf10d4727 100644 --- a/system/libraries/Log.php +++ b/system/libraries/Log.php @@ -27,10 +27,12 @@ class CI_Log { protected $_log_path; - protected $_threshold = 1; - protected $_date_fmt = 'Y-m-d H:i:s'; - protected $_enabled = TRUE; - protected $_levels = array('ERROR' => '1', 'DEBUG' => '2', 'INFO' => '3', 'ALL' => '4'); + protected $_threshold = 1; + protected $_threshold_max = 0; + protected $_threshold_array = array(); + protected $_date_fmt = 'Y-m-d H:i:s'; + protected $_enabled = TRUE; + protected $_levels = array('ERROR' => '1', 'DEBUG' => '2', 'INFO' => '3', 'ALL' => '4'); /** * Constructor @@ -50,6 +52,11 @@ class CI_Log { { $this->_threshold = $config['log_threshold']; } + elseif (is_array($config['log_threshold'])) + { + $this->_threshold = $this->_threshold_max; + $this->_threshold_array = array_flip($config['log_threshold']); + } if ($config['log_date_format'] != '') { @@ -80,9 +87,13 @@ class CI_Log { if ( ! isset($this->_levels[$level]) OR ($this->_levels[$level] > $this->_threshold)) { - return FALSE; + if (empty($this->_threshold_array) OR ! isset($this->_threshold_array[$this->_levels[$level]])) + { + return FALSE; + } } + $filepath = $this->_log_path.'log-'.date('Y-m-d').'.php'; $message = ''; diff --git a/user_guide/changelog.html b/user_guide/changelog.html index bb05f99e1..6b73485e1 100644 --- a/user_guide/changelog.html +++ b/user_guide/changelog.html @@ -66,6 +66,7 @@ Change Log
  • General Changes
    • Callback validation rules can now accept parameters like any other validation rule.
    • +
    • Ability to log certain error types, not all under a threshold.
  • Helpers -- cgit v1.2.3-24-g4f1b From 896d95aec8f5ddb5f638304f9978e0f2f1a32053 Mon Sep 17 00:00:00 2001 From: Kyle Farris Date: Sun, 21 Aug 2011 23:03:54 -0300 Subject: Added a function that's able to take some really bad date formats from systems that idiots wrote and convert them to something useful. --- system/helpers/date_helper.php | 66 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) diff --git a/system/helpers/date_helper.php b/system/helpers/date_helper.php index 553e8d7ee..6c559bb25 100644 --- a/system/helpers/date_helper.php +++ b/system/helpers/date_helper.php @@ -490,6 +490,72 @@ 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) + * @return string + */ +if ( ! function_exists('nice_date')) +{ + function nice_date($bad_date='', $format=false) + { + if (empty($bad_date)) + { + return 'Unknown'; + } + // Date like: YYYYMM + if (preg_match('/^\d{6}$/',$bad_date)) + { + //echo $bad_date." "; + if (in_array(substr($bad_date, 0, 2),array('19', '20'))) + { + $year = substr($bad_date, 0, 4); + $month = substr($bad_date, 4, 2); + } + 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)) + { + $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)); + } +} + +// ------------------------------------------------------------------------ + /** * Timezone Menu * -- cgit v1.2.3-24-g4f1b From d9c3a6f20e858b22ababbb2a3f3209eca1e93c13 Mon Sep 17 00:00:00 2001 From: Kyle Farris Date: Sun, 21 Aug 2011 23:08:17 -0300 Subject: Added documentation for some other rule someone added but didn't document. --- user_guide/libraries/form_validation.html | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/user_guide/libraries/form_validation.html b/user_guide/libraries/form_validation.html index 7c544b69f..4400bac83 100644 --- a/user_guide/libraries/form_validation.html +++ b/user_guide/libraries/form_validation.html @@ -1037,6 +1037,13 @@ POST array:

      + + is_unique + Yes + Returns FALSE if the form element is not unique in a database table. + is_unique[table.field] + + valid_email No -- cgit v1.2.3-24-g4f1b From 37e5ff65b2bd1601daadac40fdfce80fd8956fd7 Mon Sep 17 00:00:00 2001 From: Kyle Farris Date: Sun, 21 Aug 2011 23:21:25 -0300 Subject: Added documentation for the nice_date function in the date_helper. --- user_guide/helpers/date_helper.html | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/user_guide/helpers/date_helper.html b/user_guide/helpers/date_helper.html index f930ea3ae..29e242696 100644 --- a/user_guide/helpers/date_helper.html +++ b/user_guide/helpers/date_helper.html @@ -234,6 +234,20 @@ $unix = human_to_unix($human);
    +

    nice_date()

    + +

    This function can take a number poorly-formed date formats and convert them into something useful. It also accepts well-formed dates.

    +

    The fuction will return a Unix timestamp by default. You can, optionally, pass a format string (the same type as the PHP date function accepts) as the second parameter. Example:

    + +$bad_time = 199605
    +
    +// Should Produce: 1996-05-01
    +$better_time = nice_date($bad_time,'Y-m-d');
    +
    +$bad_time = 9-11-2001
    +// Should Produce: 2001-09-11
    +$better_time = nice_date($human,'Y-m-d');
    +

    timespan()

    -- cgit v1.2.3-24-g4f1b From ee7363bb48e613d17566e82c6025ad71d39aa104 Mon Sep 17 00:00:00 2001 From: Greg Aker Date: Sun, 21 Aug 2011 16:35:19 -0500 Subject: Fixing a spelling error. --- user_guide/helpers/date_helper.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/user_guide/helpers/date_helper.html b/user_guide/helpers/date_helper.html index 29e242696..5b00e25e0 100644 --- a/user_guide/helpers/date_helper.html +++ b/user_guide/helpers/date_helper.html @@ -237,7 +237,7 @@ $unix = human_to_unix($human);

    nice_date()

    This function can take a number poorly-formed date formats and convert them into something useful. It also accepts well-formed dates.

    -

    The fuction will return a Unix timestamp by default. You can, optionally, pass a format string (the same type as the PHP date function accepts) as the second parameter. Example:

    +

    The function will return a Unix timestamp by default. You can, optionally, pass a format string (the same type as the PHP date function accepts) as the second parameter. Example:

    $bad_time = 199605

    -- cgit v1.2.3-24-g4f1b From 8310c9a33647804be22a92f1a0458d30d5cacd8a Mon Sep 17 00:00:00 2001 From: yterajima Date: Mon, 22 Aug 2011 07:26:54 +0900 Subject: Fixed #56 _compile_session_data() is 'protected' to be able to extend MY_Profiler. --- system/libraries/Profiler.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/system/libraries/Profiler.php b/system/libraries/Profiler.php index 082a5ee1d..330acce73 100644 --- a/system/libraries/Profiler.php +++ b/system/libraries/Profiler.php @@ -493,7 +493,7 @@ class CI_Profiler { * * @return string */ - private function _compile_session_data() + protected function _compile_session_data() { if ( ! isset($this->CI->session)) { @@ -555,4 +555,4 @@ class CI_Profiler { // END CI_Profiler class /* End of file Profiler.php */ -/* Location: ./system/libraries/Profiler.php */ \ No newline at end of file +/* Location: ./system/libraries/Profiler.php */ -- cgit v1.2.3-24-g4f1b From ab57a3520eafacaf2f130b3f4778a57a632fac1c Mon Sep 17 00:00:00 2001 From: Shane Pearson Date: Mon, 22 Aug 2011 16:11:20 -0500 Subject: Fix #8 - Load core classes from the application folder first. --- system/core/Common.php | 6 +++--- user_guide/changelog.html | 1 + 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/system/core/Common.php b/system/core/Common.php index db9fbeb9f..3c62403ac 100644 --- a/system/core/Common.php +++ b/system/core/Common.php @@ -132,9 +132,9 @@ if ( ! function_exists('load_class')) $name = FALSE; - // Look for the class first in the native system/libraries folder - // thenin the local application/libraries folder - foreach (array(BASEPATH, APPPATH) as $path) + // Look for the class first in the local application/libraries folder + // then in the native system/libraries folder + foreach (array(APPPATH, BASEPATH) as $path) { if (file_exists($path.$directory.'/'.$class.'.php')) { diff --git a/user_guide/changelog.html b/user_guide/changelog.html index 9d8fd2b54..e5501abbc 100644 --- a/user_guide/changelog.html +++ b/user_guide/changelog.html @@ -105,6 +105,7 @@ Change Log
  • Fixed a bug (#181) where a mis-spelling was in the form validation language file.
  • Fixed a bug (#160) - Removed unneeded array copy in the file cache driver.
  • Fixed a bug (#150) - field_data() now correctly returns column length.
  • +
  • Fixed a bug (#8) - Look for core classes in APPPATH first.
  • Version 2.0.3

    -- cgit v1.2.3-24-g4f1b From 48705c3345cf115910dbaa798f60288ea7b9ca36 Mon Sep 17 00:00:00 2001 From: Shane Pearson Date: Mon, 22 Aug 2011 16:17:32 -0500 Subject: updated changelog message --- user_guide/changelog.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/user_guide/changelog.html b/user_guide/changelog.html index e5501abbc..4c207d6bc 100644 --- a/user_guide/changelog.html +++ b/user_guide/changelog.html @@ -105,7 +105,7 @@ Change Log
  • Fixed a bug (#181) where a mis-spelling was in the form validation language file.
  • Fixed a bug (#160) - Removed unneeded array copy in the file cache driver.
  • Fixed a bug (#150) - field_data() now correctly returns column length.
  • -
  • Fixed a bug (#8) - Look for core classes in APPPATH first.
  • +
  • Fixed a bug (#8) - load_class() now looks for core classes in APPPATH first, allowing them to be replaced.
  • Version 2.0.3

    -- cgit v1.2.3-24-g4f1b From 665baec264c04fb3284e313d59e102b2bf041e37 Mon Sep 17 00:00:00 2001 From: Shane Pearson Date: Mon, 22 Aug 2011 18:52:19 -0500 Subject: make _ci_autoloader() protected so it can be properly extended. --- system/core/Loader.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/system/core/Loader.php b/system/core/Loader.php index 452dc0b4c..de0fc06d2 100755 --- a/system/core/Loader.php +++ b/system/core/Loader.php @@ -1106,7 +1106,7 @@ class CI_Loader { * @param array * @return void */ - private function _ci_autoloader() + protected function _ci_autoloader() { if (defined('ENVIRONMENT') AND file_exists(APPPATH.'config/'.ENVIRONMENT.'/autoload.php')) { -- cgit v1.2.3-24-g4f1b From e77c6117e473900ca35ec7993f4159179d5b5f9c Mon Sep 17 00:00:00 2001 From: Shane Pearson Date: Mon, 22 Aug 2011 19:01:28 -0500 Subject: add a note to the changelog about _ci_autloader() --- user_guide/changelog.html | 1 + 1 file changed, 1 insertion(+) diff --git a/user_guide/changelog.html b/user_guide/changelog.html index 9d8fd2b54..ac936a68c 100644 --- a/user_guide/changelog.html +++ b/user_guide/changelog.html @@ -91,6 +91,7 @@ Change Log
  • Added a Migration Library to assist with applying incremental updates to your database schema.
  • Driver children can be located in any package path.
  • Added max_filename_increment config setting for Upload library.
  • +
  • CI_Loader::_ci_autoloader() is now a protected method.
  • -- cgit v1.2.3-24-g4f1b From c51a435968eda164dc5d055ff9ec15918a6f56ab Mon Sep 17 00:00:00 2001 From: Bo-Yi Wu Date: Tue, 23 Aug 2011 10:40:39 +0800 Subject: Update: User Guide error on upgrade_203.html file --- user_guide/installation/upgrade_203.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/user_guide/installation/upgrade_203.html b/user_guide/installation/upgrade_203.html index 1d37a055d..04899832d 100644 --- a/user_guide/installation/upgrade_203.html +++ b/user_guide/installation/upgrade_203.html @@ -81,7 +81,7 @@ Upgrading from 2.0.2 to 2.0.3

    Step 5: Remove APPPATH.'third_party' from autoload.php

    -

    Open application/autoload.php, and look for the following:

    +

    Open application/config/autoload.php, and look for the following:

    $autoload['packages'] = array(APPPATH.'third_party'); -- cgit v1.2.3-24-g4f1b From f31895096e821c694670b62180b7a5c309b62a9b Mon Sep 17 00:00:00 2001 From: Eric Barnes Date: Tue, 23 Aug 2011 21:40:59 -0400 Subject: Changed doc block options. Fixes #100 --- system/helpers/url_helper.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/system/helpers/url_helper.php b/system/helpers/url_helper.php index 9f4b85248..09d975621 100644 --- a/system/helpers/url_helper.php +++ b/system/helpers/url_helper.php @@ -527,7 +527,7 @@ if ( ! function_exists('url_title')) * * @access public * @param string the URL - * @param string the method: location or redirect + * @param string the method: location or refresh * @return string */ if ( ! function_exists('redirect')) -- cgit v1.2.3-24-g4f1b From 45c887bb99b537a2b191a1fe476752dc5a8527d7 Mon Sep 17 00:00:00 2001 From: Eric Barnes Date: Tue, 23 Aug 2011 21:53:35 -0400 Subject: Added readme for github project page --- readme.md | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 readme.md diff --git a/readme.md b/readme.md new file mode 100644 index 000000000..599fdb3cf --- /dev/null +++ b/readme.md @@ -0,0 +1,10 @@ +# What is CodeIgniter + +CodeIgniter is an Application Development Framework - a toolkit - for people who build web sites using PHP. Its goal is to enable you to develop projects much faster than you could if you were writing code from scratch, by providing a rich set of libraries for commonly needed tasks, as well as a simple interface and logical structure to access these libraries. CodeIgniter lets you creatively focus on your project by minimizing the amount of code needed for a given task. + +# Resources + + * [User Guide](http://codeigniter.com/user_guide/) + * [Community Forums](http://codeigniter.com/forums/) + * [Community Wiki](http://codeigniter.com/wiki/) + * [Community IRC](http://webchat.freenode.net/?channels=codeigniter&uio=d4)] \ No newline at end of file -- cgit v1.2.3-24-g4f1b From 17e7b44e4b67e8d36ef6a0f8f08c2751fce3b55b Mon Sep 17 00:00:00 2001 From: Kevin Hoogheem Date: Tue, 23 Aug 2011 22:48:48 -0500 Subject: MIME Type Adds/Changes Updated MIME Types with certs and new audio/video files as well as added extra types for some existing files. --- application/config/mimes.php | 50 +++++++++++++++++++++++++++++++++++++------- user_guide/changelog.html | 5 +++++ 2 files changed, 47 insertions(+), 8 deletions(-) diff --git a/application/config/mimes.php b/application/config/mimes.php index 82767d7c8..be9a67842 100644 --- a/application/config/mimes.php +++ b/application/config/mimes.php @@ -8,10 +8,10 @@ | */ -$mimes = array( 'hqx' => 'application/mac-binhex40', +$mimes = array( 'hqx' => array('application/mac-binhex40', 'application/mac-binhex', 'application/x-binhex40', 'application/x-mac-binhex40'), 'cpt' => 'application/mac-compactpro', 'csv' => array('text/x-comma-separated-values', 'text/comma-separated-values', 'application/octet-stream', 'application/vnd.ms-excel', 'application/x-csv', 'text/x-csv', 'text/csv', 'application/csv', 'application/excel', 'application/vnd.msexcel'), - 'bin' => 'application/macbinary', + 'bin' => array('application/macbinary', 'application/mac-binary', 'application/octet-stream', 'application/x-binary', 'application/x-macbinary'), 'dms' => 'application/octet-stream', 'lha' => 'application/octet-stream', 'lzh' => 'application/octet-stream', @@ -39,6 +39,7 @@ $mimes = array( 'hqx' => 'application/mac-binhex40', 'dvi' => 'application/x-dvi', 'gtar' => 'application/x-gtar', 'gz' => 'application/x-gzip', + 'gzip' => 'application/x-gzip', 'php' => 'application/x-httpd-php', 'php4' => 'application/x-httpd-php', 'php3' => 'application/x-httpd-php', @@ -51,14 +52,14 @@ $mimes = array( 'hqx' => 'application/mac-binhex40', 'tgz' => array('application/x-tar', 'application/x-gzip-compressed'), 'xhtml' => 'application/xhtml+xml', 'xht' => 'application/xhtml+xml', - 'zip' => array('application/x-zip', 'application/zip', 'application/x-zip-compressed'), + 'zip' => array('application/x-zip', 'application/zip', 'application/x-zip-compressed'), 'mid' => 'audio/midi', 'midi' => 'audio/midi', 'mpga' => 'audio/mpeg', 'mp2' => 'audio/mpeg', 'mp3' => array('audio/mpeg', 'audio/mpg', 'audio/mpeg3', 'audio/mp3'), - 'aif' => 'audio/x-aiff', - 'aiff' => 'audio/x-aiff', + 'aif' => array('audio/x-aiff', 'audio/aiff'), + 'aiff' => array('audio/x-aiff', 'audio/aiff'), 'aifc' => 'audio/x-aiff', 'ram' => 'audio/x-pn-realaudio', 'rm' => 'audio/x-pn-realaudio', @@ -66,7 +67,7 @@ $mimes = array( 'hqx' => 'application/mac-binhex40', 'ra' => 'audio/x-realaudio', 'rv' => 'video/vnd.rn-realvideo', 'wav' => 'audio/x-wav', - 'bmp' => 'image/bmp', + 'bmp' => array('image/bmp', 'image/x-windows-bmp'), 'gif' => 'image/gif', 'jpeg' => array('image/jpeg', 'image/pjpeg'), 'jpg' => array('image/jpeg', 'image/pjpeg'), @@ -90,7 +91,7 @@ $mimes = array( 'hqx' => 'application/mac-binhex40', 'mpe' => 'video/mpeg', 'qt' => 'video/quicktime', 'mov' => 'video/quicktime', - 'avi' => 'video/x-msvideo', + 'avi' => array('video/x-msvideo', 'video/msvideo', 'video/avi', 'application/x-troff-msvideo'), 'movie' => 'video/x-sgi-movie', 'doc' => 'application/msword', 'docx' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', @@ -98,7 +99,40 @@ $mimes = array( 'hqx' => 'application/mac-binhex40', 'word' => array('application/msword', 'application/octet-stream'), 'xl' => 'application/excel', 'eml' => 'message/rfc822', - 'json' => array('application/json', 'text/json') + 'json' => array('application/json', 'text/json'), + 'pem' => array('application/x-x509-user-cert', 'application/x-pem-file', 'application/octet-stream'), + 'p10' => array('application/x-pkcs10', 'application/pkcs10'), + 'p12' => 'application/x-pkcs12', + 'p7a' => 'application/x-pkcs7-signature', + 'p7c' => array('application/pkcs7-mime', 'application/x-pkcs7-mime'), + 'p7m' => array('application/pkcs7-mime', 'application/x-pkcs7-mime'), + 'p7r' => 'application/x-pkcs7-certreqresp', + 'p7s' => 'application/pkcs7-signature', + 'crt' => array('application/x-x509-ca-cert', 'application/x-x509-user-cert', 'application/pkix-cert'), + 'crl' => array('application/pkix-crl', 'application/pkcs-crl'), + 'der' => 'application/x-x509-ca-cert', + 'kdb' => 'application/octet-stream', + 'pgp' => 'application/pgp', + 'gpg' => 'application/gpg-keys', + 'sst' => 'application/octet-stream', + 'csr' => 'application/octet-stream', + 'rsa' => 'application/x-pkcs7', + 'cer' => array('application/pkix-cert', 'application/x-x509-ca-cert'), + '3g2' => 'video/3gpp2', + '3gp' => 'video/3gp', + 'mp4' => 'video/mp4', + 'm4a' => 'audio/x-m4a', + 'f4v' => 'video/mp4', + 'aac' => 'audio/x-acc', + 'm4u' => 'application/vnd.mpegurl', + 'm3u' => 'text/plain', + 'xspf' => 'application/xspf+xml', + 'vlc' => 'application/videolan', + 'wmv' => 'video/x-ms-wmv', + 'au' => 'audio/x-au', + 'ac3' => 'audio/ac3', + 'flac' => 'audio/x-flac', + 'ogg' => 'audio/ogg', ); diff --git a/user_guide/changelog.html b/user_guide/changelog.html index 9d8fd2b54..2c6cb5ab5 100644 --- a/user_guide/changelog.html +++ b/user_guide/changelog.html @@ -125,6 +125,11 @@ Change Log
  • Added insert_batch() function to the PostgreSQL database driver. Thanks to epallerols for the patch.
  • Added "application/x-csv" to mimes.php.
  • Fixed a bug where Email library attachments with a "." in the name would using invalid MIME-types.
  • +
  • Added support for pem,p10,p12,p7a,p7c,p7m,p7r,p7s,crt,crl,der,kdb,rsa,cer,sst,csr Certs to mimes.php.
  • +
  • Added support pgp,gpg to mimes.php.
  • +
  • Added support 3gp, 3g2, mp4, wmv, f4v, vlc Video files to mimes.php.
  • +
  • Added support m4a, aac, m4u, xspf, au, ac3, flac, ogg Audio files to mimes.php.
  • +
  • Helpers -- cgit v1.2.3-24-g4f1b From aadf15d2b5337b7c66dc974d0b7a872030ed02c1 Mon Sep 17 00:00:00 2001 From: Eric Barnes Date: Wed, 24 Aug 2011 03:55:41 -0300 Subject: Removed bracket from last link. --- readme.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/readme.md b/readme.md index 599fdb3cf..dfcf856f2 100644 --- a/readme.md +++ b/readme.md @@ -7,4 +7,4 @@ CodeIgniter is an Application Development Framework - a toolkit - for people who * [User Guide](http://codeigniter.com/user_guide/) * [Community Forums](http://codeigniter.com/forums/) * [Community Wiki](http://codeigniter.com/wiki/) - * [Community IRC](http://webchat.freenode.net/?channels=codeigniter&uio=d4)] \ No newline at end of file + * [Community IRC](http://webchat.freenode.net/?channels=codeigniter&uio=d4) \ No newline at end of file -- cgit v1.2.3-24-g4f1b From 6a93995f2a24c0ac8d636ecac5f3eb0d0243e23d Mon Sep 17 00:00:00 2001 From: Alex Bilbie Date: Wed, 24 Aug 2011 09:20:36 +0100 Subject: Added note in changelog --- user_guide/changelog.html | 1 + 1 file changed, 1 insertion(+) diff --git a/user_guide/changelog.html b/user_guide/changelog.html index c52a33e5a..5e412ca44 100644 --- a/user_guide/changelog.html +++ b/user_guide/changelog.html @@ -75,6 +75,7 @@ Change Log
  • Visual updates to the welcome_message view file and default error templates. Thanks to danijelb for the pull request.
  • Added insert_batch() function to the PostgreSQL database driver. Thanks to epallerols for the patch.
  • Added "application/x-csv" to mimes.php.
  • +
  • Added CSRF protection URI whitelisting.
  • Fixed a bug where Email library attachments with a "." in the name would using invalid MIME-types.
  • -- cgit v1.2.3-24-g4f1b From 2653e05752d865b921fd4f92d2b9b3eafeae2ac0 Mon Sep 17 00:00:00 2001 From: purandi Date: Wed, 24 Aug 2011 18:31:39 +0700 Subject: Fix link database driver on changelog --- user_guide/changelog.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/user_guide/changelog.html b/user_guide/changelog.html index 4c207d6bc..d095c2f5f 100644 --- a/user_guide/changelog.html +++ b/user_guide/changelog.html @@ -77,7 +77,7 @@ Change Log
  • Database