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 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 75bc58b05cf16a0f8c5e7ed1545033a5d8b8feba Mon Sep 17 00:00:00 2001 From: David Behler Date: Sun, 21 Aug 2011 15:03:47 +0200 Subject: Fixed problem with needless seperator at begin/end of string --- system/helpers/url_helper.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) mode change 100644 => 100755 system/helpers/url_helper.php diff --git a/system/helpers/url_helper.php b/system/helpers/url_helper.php old mode 100644 new mode 100755 index d0516cee6..0431e0b4b --- a/system/helpers/url_helper.php +++ b/system/helpers/url_helper.php @@ -509,7 +509,7 @@ if ( ! function_exists('url_title')) $str = strtolower($str); } - return trim(stripslashes($str)); + return trim(trim(stripslashes($str)), $replace); } } -- 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 52c10b68c275248eb7e12ec1d039876cd5f81f11 Mon Sep 17 00:00:00 2001 From: John Bellone Date: Sun, 21 Aug 2011 11:41:32 -0400 Subject: Making changes to stop remote spoofing --- system/core/Input.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/system/core/Input.php b/system/core/Input.php index cfbef942d..365f779de 100644 --- a/system/core/Input.php +++ b/system/core/Input.php @@ -287,13 +287,13 @@ class CI_Input { $this->ip_address = in_array($_SERVER['REMOTE_ADDR'], $proxies) ? $_SERVER['HTTP_X_FORWARDED_FOR'] : $_SERVER['REMOTE_ADDR']; } - elseif ($this->server('REMOTE_ADDR') AND $this->server('HTTP_CLIENT_IP')) + elseif ($this->server('REMOTE_ADDR') AND ! $this->server('HTTP_CLIENT_IP')) { - $this->ip_address = $_SERVER['HTTP_CLIENT_IP']; + $this->ip_address = $_SERVER['REMOTE_ADDR']; } - elseif ($this->server('REMOTE_ADDR')) + elseif ($this->server('REMOTE_ADDR') AND $this->server('HTTP_CLIENT_IP')) { - $this->ip_address = $_SERVER['REMOTE_ADDR']; + $this->ip_address = $_SERVER['HTTP_CLIENT_IP']; } elseif ($this->server('HTTP_CLIENT_IP')) { -- cgit v1.2.3-24-g4f1b From 16f27b402049dc2ff0cc09faf4885aee944ba639 Mon Sep 17 00:00:00 2001 From: John Bellone Date: Sun, 21 Aug 2011 11:45:11 -0400 Subject: Changed order --- system/core/Input.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/system/core/Input.php b/system/core/Input.php index 365f779de..df9d2a5b7 100644 --- a/system/core/Input.php +++ b/system/core/Input.php @@ -287,7 +287,7 @@ class CI_Input { $this->ip_address = in_array($_SERVER['REMOTE_ADDR'], $proxies) ? $_SERVER['HTTP_X_FORWARDED_FOR'] : $_SERVER['REMOTE_ADDR']; } - elseif ($this->server('REMOTE_ADDR') AND ! $this->server('HTTP_CLIENT_IP')) + elseif (! $this->server('HTTP_CLIENT_IP') AND $this->server('REMOTE_ADDR')) { $this->ip_address = $_SERVER['REMOTE_ADDR']; } -- 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 1e4276da338741e63de4701e5cdba611953fe024 Mon Sep 17 00:00:00 2001 From: Phil Sturgeon Date: Sun, 21 Aug 2011 15:46:24 -0400 Subject: Added changelog to last commit. --- user_guide/changelog.html | 1 + 1 file changed, 1 insertion(+) diff --git a/user_guide/changelog.html b/user_guide/changelog.html index 15872c1ac..e2df11b86 100644 --- a/user_guide/changelog.html +++ b/user_guide/changelog.html @@ -72,6 +72,7 @@ Change Log
    • 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)
    • +
    • url_title() will now trim extra dashes from beginning and end.
  • Database -- 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

    Version 2.0.3

    -- cgit v1.2.3-24-g4f1b From 84d76ea2559ddd72b5d1ddbe6fa38e88d9b20c16 Mon Sep 17 00:00:00 2001 From: Michiel Vugteveen Date: Thu, 25 Aug 2011 21:25:12 +0200 Subject: odbc called incorrect parent in construct --- system/database/drivers/odbc/odbc_driver.php | 2 +- user_guide/changelog.html | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/system/database/drivers/odbc/odbc_driver.php b/system/database/drivers/odbc/odbc_driver.php index 5e764e071..08cd27b6c 100644 --- a/system/database/drivers/odbc/odbc_driver.php +++ b/system/database/drivers/odbc/odbc_driver.php @@ -50,7 +50,7 @@ class CI_DB_odbc_driver extends CI_DB { function CI_DB_odbc_driver($params) { - parent::CI_DB($params); + parent::CI_DB_driver($params); $this->_random_keyword = ' RND('.time().')'; // database specific random keyword } diff --git a/user_guide/changelog.html b/user_guide/changelog.html index 865bdd8ac..62f6b4f33 100644 --- a/user_guide/changelog.html +++ b/user_guide/changelog.html @@ -108,6 +108,7 @@ Change Log
  • 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) - load_class() now looks for core classes in APPPATH first, allowing them to be replaced.
  • +
  • Fixed a bug (#24) - ODBC database driver called incorrect parent in __construct().
  • Version 2.0.3

    -- cgit v1.2.3-24-g4f1b From 6935931e0165aed0ef2d5bc9c0f51bf845969c35 Mon Sep 17 00:00:00 2001 From: Eric Barnes Date: Thu, 25 Aug 2011 18:20:02 -0300 Subject: Fixed spelling mistake. --- 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 d7a6c7e05..865bdd8ac 100644 --- a/user_guide/changelog.html +++ b/user_guide/changelog.html @@ -67,7 +67,7 @@ Change Log
    • Callback validation rules can now accept parameters like any other validation rule.
    • Ability to log certain error types, not all under a threshold.
    • -
    • Added html_escape() to the Common functions to escape HTML output for preventing XSS easliy.
    • +
    • Added html_escape() to Common functions to escape HTML output for preventing XSS.
  • Helpers -- cgit v1.2.3-24-g4f1b From f7345e4f5f6e44886eac337d8da064f541df8b9a Mon Sep 17 00:00:00 2001 From: Paul Date: Sat, 27 Aug 2011 06:51:16 +1200 Subject: changed private functions to protected so MY_URI can override them. --- system/core/URI.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/system/core/URI.php b/system/core/URI.php index a3ae20cc3..8946bc76b 100755 --- a/system/core/URI.php +++ b/system/core/URI.php @@ -175,7 +175,7 @@ class CI_URI { * @access private * @return string */ - private function _detect_uri() + protected function _detect_uri() { if ( ! isset($_SERVER['REQUEST_URI']) OR ! isset($_SERVER['SCRIPT_NAME'])) { @@ -232,7 +232,7 @@ class CI_URI { * @access private * @return string */ - private function _parse_cli_args() + protected function _parse_cli_args() { $args = array_slice($_SERVER['argv'], 1); -- cgit v1.2.3-24-g4f1b From eb630f32810c5d3eaa5e5c4df7183034f181e07c Mon Sep 17 00:00:00 2001 From: Paul Date: Sat, 27 Aug 2011 10:22:41 +1200 Subject: added core heading and note about protected functions in URI --- user_guide/changelog.html | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/user_guide/changelog.html b/user_guide/changelog.html index 865bdd8ac..f82dac9fa 100644 --- a/user_guide/changelog.html +++ b/user_guide/changelog.html @@ -95,6 +95,12 @@ Change Log
  • CI_Loader::_ci_autoloader() is now a protected method.
  • +
  • Core +
      + +
    • Changed private functions in CI_URI to protected so MY_URI can override them.
    • +
    +
  • Bug fixes for 2.1.0

    -- cgit v1.2.3-24-g4f1b From 1c342ebc83b2d303ba68415ce2ec6b5b173a1b66 Mon Sep 17 00:00:00 2001 From: Paul Date: Sat, 27 Aug 2011 10:23:38 +1200 Subject: spacing removed --- user_guide/changelog.html | 1 - 1 file changed, 1 deletion(-) diff --git a/user_guide/changelog.html b/user_guide/changelog.html index f82dac9fa..bb80ab8b8 100644 --- a/user_guide/changelog.html +++ b/user_guide/changelog.html @@ -97,7 +97,6 @@ Change Log
  • Core
      -
    • Changed private functions in CI_URI to protected so MY_URI can override them.
  • -- cgit v1.2.3-24-g4f1b From 901998a9a517d96faff5c24fb40f98961f83c3cd Mon Sep 17 00:00:00 2001 From: Phil Sturgeon Date: Fri, 26 Aug 2011 10:03:33 +0100 Subject: Removed some error suppression, which would hide a Notice if the path cannot be read. I discovered this by foolishly passing the file_path, not the full_path but took forever for me to realise this as the error returned (thanks to this error suppression) was "GD is not installed" instead of "File cannot be read". Seeing that notice would have made much more sense. --- system/libraries/Image_lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/system/libraries/Image_lib.php b/system/libraries/Image_lib.php index 8902f524d..a8a0387d8 100644 --- a/system/libraries/Image_lib.php +++ b/system/libraries/Image_lib.php @@ -1334,7 +1334,7 @@ class CI_Image_lib { return FALSE; } - $vals = @getimagesize($path); + $vals = getimagesize($path); $types = array(1 => 'gif', 2 => 'jpeg', 3 => 'png'); -- cgit v1.2.3-24-g4f1b From ddae533eee59e356ed6f40a4f4976162c592965e Mon Sep 17 00:00:00 2001 From: Phil Sturgeon Date: Fri, 26 Aug 2011 10:12:10 +0100 Subject: Moved the "is_unique" change log to 2.1.0-dev where it should have been first time. Sorry about that one, had to manually separate 2.0.3 changes from 2.1.0 based mainly on memory. --- user_guide/changelog.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/user_guide/changelog.html b/user_guide/changelog.html index ff04787cf..c030ce77c 100644 --- a/user_guide/changelog.html +++ b/user_guide/changelog.html @@ -94,11 +94,12 @@ Change Log
  • 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.
  • +
  • Added is_unique to the Form Validation library.
  • Core
      -
    • Changed private functions in CI_URI to protected so MY_URI can override them.
    • +
    • Changed private functions in CI_URI to protected so MY_URI can override them.
  • @@ -153,7 +154,6 @@ Change Log
  • Libraries
    • Altered Session to use a longer match against the user_agent string. See upgrade notes if using database sessions.
    • -
    • Added is_unique to the Form Validation library.
    • Added $this->db->set_dbprefix() to the Database Driver.
    • Changed $this->cart->insert() in the Cart Library to return the Row ID if a single item was inserted successfully.
    • Added $this->load->get_var() to the Loader library to retrieve global vars set with $this->load->view() and $this->load->vars().
    • -- cgit v1.2.3-24-g4f1b From 44cdece942c310f5520497dbde4febc26e96c27e Mon Sep 17 00:00:00 2001 From: Phil Sturgeon Date: Fri, 26 Aug 2011 12:23:18 +0100 Subject: Bumped URL Helper version number. --- user_guide/helpers/url_helper.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/user_guide/helpers/url_helper.html b/user_guide/helpers/url_helper.html index de28a6f56..e60e96bf0 100644 --- a/user_guide/helpers/url_helper.html +++ b/user_guide/helpers/url_helper.html @@ -27,7 +27,7 @@
      - +

      CodeIgniter User Guide Version 2.0.0

      CodeIgniter User Guide Version 2.0.3

      -- cgit v1.2.3-24-g4f1b From d8f002c6c92ed8395331b69ea77c4e5a83bfd83c Mon Sep 17 00:00:00 2001 From: Iban Eguia Date: Fri, 26 Aug 2011 14:34:38 +0200 Subject: Removed some documentation for PHP 4 users in the active record documentation. --- user_guide/database/active_record.html | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/user_guide/database/active_record.html b/user_guide/database/active_record.html index 92d9614d5..0f09e78c3 100644 --- a/user_guide/database/active_record.html +++ b/user_guide/database/active_record.html @@ -79,9 +79,6 @@ is generated by each database adapter. It also allows for safer queries, since

      The following functions allow you to build SQL SELECT statements.

      -

      Note: If you are using PHP 5 you can use method chaining for more compact syntax. This is described at the end of the page.

      - -

      $this->db->get();

      Runs the selection query and returns the result. Can be used by itself to retrieve all records from a table:

      @@ -532,7 +529,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' ,
      @@ -544,7 +541,7 @@ $data = array(
            'name' => 'Another Name' ,
            'date' => 'Another date'
         )
      -);
      +);

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

      -- cgit v1.2.3-24-g4f1b From b183ece10dcde599c04af412f0f5c1c776ed29d8 Mon Sep 17 00:00:00 2001 From: Eric Barnes Date: Fri, 26 Aug 2011 14:42:52 -0400 Subject: Changed CI_VERSION to represent develop branch --- system/core/CodeIgniter.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/system/core/CodeIgniter.php b/system/core/CodeIgniter.php index 0a1391d18..aca4fb23c 100755 --- a/system/core/CodeIgniter.php +++ b/system/core/CodeIgniter.php @@ -39,7 +39,7 @@ * @var string * */ - define('CI_VERSION', '2.0.2'); + define('CI_VERSION', '2.1.0-dev'); /** * CodeIgniter Branch (Core = TRUE, Reactor = FALSE) -- cgit v1.2.3-24-g4f1b From d720af7ce5539c0c5f1a604358a96bcf54af80fd Mon Sep 17 00:00:00 2001 From: Bruno Bierbaumer Date: Sat, 27 Aug 2011 16:13:14 +0200 Subject: add Android user agent --- application/config/user_agents.php | 1 + 1 file changed, 1 insertion(+) diff --git a/application/config/user_agents.php b/application/config/user_agents.php index e2d3c3af0..4746f2fcd 100644 --- a/application/config/user_agents.php +++ b/application/config/user_agents.php @@ -126,6 +126,7 @@ $mobiles = array( 'sendo' => "Sendo", // Operating Systems + 'android' => "Android", 'symbian' => "Symbian", 'SymbianOS' => "SymbianOS", 'elaine' => "Palm", -- cgit v1.2.3-24-g4f1b From 95b7994a298a7c57118c59e03a1aa43bd804bce4 Mon Sep 17 00:00:00 2001 From: Bruno Bierbaumer Date: Sat, 27 Aug 2011 16:52:24 +0200 Subject: add Android user agent --- user_guide/changelog.html | 1 + 1 file changed, 1 insertion(+) diff --git a/user_guide/changelog.html b/user_guide/changelog.html index 33e0a62c1..978b710be 100644 --- a/user_guide/changelog.html +++ b/user_guide/changelog.html @@ -65,6 +65,7 @@ Change Log
      • General Changes
          +
        • Added Android to the list of user agents.
        • Callback validation rules can now accept parameters like any other validation rule.
        • Ability to log certain error types, not all under a threshold.
        • Added html_escape() to Common functions to escape HTML output for preventing XSS.
        • -- cgit v1.2.3-24-g4f1b From dae42fa65fc65e43d704f1a6c139e985e93486f4 Mon Sep 17 00:00:00 2001 From: bubbafoley Date: Sun, 28 Aug 2011 00:54:24 -0500 Subject: Fix the default migration path. --- system/libraries/Migration.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/system/libraries/Migration.php b/system/libraries/Migration.php index 3943ec130..3734e18f5 100644 --- a/system/libraries/Migration.php +++ b/system/libraries/Migration.php @@ -57,7 +57,7 @@ class CI_Migration { } // If not set, set it - $this->_migration_path == '' OR $this->_migration_path = APPPATH . 'migrations/'; + $this->_migration_path == '' AND $this->_migration_path = APPPATH . 'migrations/'; // Add trailing slash if not set $this->_migration_path = rtrim($this->_migration_path, '/').'/'; -- cgit v1.2.3-24-g4f1b From 4c907236af3b6dc11a7b4989ece1c84a26483c46 Mon Sep 17 00:00:00 2001 From: Phil Sturgeon Date: Sun, 28 Aug 2011 17:11:03 +0100 Subject: Fixed recent change to $this->db->field_data() which errored for field types without constraints. It now uses a less expecting regex and defaults to NULL. --- system/database/drivers/mysql/mysql_result.php | 4 ++-- system/database/drivers/mysqli/mysqli_result.php | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/system/database/drivers/mysql/mysql_result.php b/system/database/drivers/mysql/mysql_result.php index 2d2905c98..6ceaf4b9b 100644 --- a/system/database/drivers/mysql/mysql_result.php +++ b/system/database/drivers/mysql/mysql_result.php @@ -86,10 +86,10 @@ class CI_DB_mysql_result extends CI_DB_result { $retval = array(); while ($field = mysql_fetch_object($this->result_id)) { - preg_match('/([a-zA-Z]+)\((\d+)\)/', $field->Type, $matches); + preg_match('/([a-zA-Z]+)(\((\d+)\))?/i', $field->Type, $matches); $type = $matches[1]; - $length = (int)$matches[2]; + $length = isset($matches[3]) ? (int) $matches[3] : NULL; $F = new stdClass(); $F->name = $field->Field; diff --git a/system/database/drivers/mysqli/mysqli_result.php b/system/database/drivers/mysqli/mysqli_result.php index ac863056a..bbfb8481a 100644 --- a/system/database/drivers/mysqli/mysqli_result.php +++ b/system/database/drivers/mysqli/mysqli_result.php @@ -86,10 +86,10 @@ class CI_DB_mysqli_result extends CI_DB_result { $retval = array(); while ($field = mysqli_fetch_object($this->result_id)) { - preg_match('/([a-zA-Z]+)\((\d+)\)/', $field->Type, $matches); + preg_match('/([a-zA-Z]+)(\((\d+)\))?/i', $field->Type, $matches); $type = $matches[1]; - $length = (int)$matches[2]; + $length = isset($matches[3]) ? (int) $matches[3] : NULL; $F = new stdClass(); $F->name = $field->Field; -- cgit v1.2.3-24-g4f1b