From 2a97c7db940e94a115dea863708f587e58d26be4 Mon Sep 17 00:00:00 2001 From: John Wright Date: Mon, 16 Jan 2012 15:09:19 -0800 Subject: It appears the Security class has been added to the system/core folder and is loaded automatically as well. Using $this->load->library('security'); in controllers currently returns FALSE, yet you might not notice because the Security class is already loaded. I discovered this because of a custom Loader class I was using returned an error when loading the Security class. --- user_guide_src/source/general/core_classes.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/user_guide_src/source/general/core_classes.rst b/user_guide_src/source/general/core_classes.rst index ac41407f7..4aa6693f7 100644 --- a/user_guide_src/source/general/core_classes.rst +++ b/user_guide_src/source/general/core_classes.rst @@ -31,6 +31,7 @@ time CodeIgniter runs: - Log - Output - Router +- Security - URI - Utf8 -- cgit v1.2.3-24-g4f1b From cbe905eba9721cfdc6fe5725b99921f04d716770 Mon Sep 17 00:00:00 2001 From: Cory Date: Tue, 5 Jun 2012 16:01:24 -0400 Subject: Fixing extra td; Issue #1374 --- system/libraries/Table.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/system/libraries/Table.php b/system/libraries/Table.php index 0f8404d85..06b68db32 100644 --- a/system/libraries/Table.php +++ b/system/libraries/Table.php @@ -247,7 +247,7 @@ class CI_Table { { foreach ($args[0] as $key => $val) { - $args[$key] = (is_array($val) && isset($val['data'])) ? $val : array('data' => $val); + $ret_args[$key] = (is_array($val) && isset($val['data'])) ? $val : array('data' => $val); } } } @@ -257,12 +257,12 @@ class CI_Table { { if ( ! is_array($val)) { - $args[$key] = array('data' => $val); + $ret_args[$key] = array('data' => $val); } } } - return $args; + return $ret_args; } // -------------------------------------------------------------------- -- cgit v1.2.3-24-g4f1b From d4901395c598552a3ef52d34aa3734e7b124dbfa Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Wed, 6 Jun 2012 14:54:15 +0300 Subject: Added Fennec as Firefox Mobile to config/user_agents.php (issue #1063) --- application/config/user_agents.php | 6 +++--- user_guide_src/source/changelog.rst | 3 ++- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/application/config/user_agents.php b/application/config/user_agents.php index 76114616b..416ef5679 100644 --- a/application/config/user_agents.php +++ b/application/config/user_agents.php @@ -29,11 +29,10 @@ | ------------------------------------------------------------------- | USER AGENT TYPES | ------------------------------------------------------------------- -| This file contains four arrays of user agent data. It is used by the +| This file contains four arrays of user agent data. It is used by the | User Agent Class to help identify browser, platform, robot, and -| mobile device data. The array keys are used to identify the device +| mobile device data. The array keys are used to identify the device | and the array values are used to set the actual name of the item. -| */ $platforms = array( @@ -179,6 +178,7 @@ $mobiles = array( 'operamini' => 'Opera Mini', 'opera mini' => 'Opera Mini', 'opera mobi' => 'Opera Mobile', + 'fennec' => 'Firefox Mobile', // Other 'digital paths' => 'Digital Paths', diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst index f4bba25ed..74de512f7 100644 --- a/user_guide_src/source/changelog.rst +++ b/user_guide_src/source/changelog.rst @@ -23,6 +23,7 @@ Release Date: Not Released - Added an optional backtrace to php-error template. - Added Android to the list of user agents. - Added Windows 7, Android, Blackberry and iOS to the list of user platforms. + - Added Fennec (Firefox for mobile) to the list of mobile user agents. - Ability to log certain error types, not all under a threshold. - 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 for pgp and gpg to mimes.php. @@ -79,8 +80,8 @@ Release Date: Not Released - Added _optimize_table() support for the :doc:`Database Utility Class ` (rebuilds table indexes). - Added boolean data type support in escape(). - Added update_batch() support. + - Removed limit() and order_by() support for UPDATE and DELETE queries in as PostgreSQL does not support those features. - Added a constructor to the DB_result class and moved all driver-specific properties and logic out of the base DB_driver class to allow better abstraction. - - Removed limit() and order_by() support for UPDATE and DELETE queries in PostgreSQL driver. Postgres does not support those features. - Removed protect_identifiers() and renamed internal method _protect_identifiers() to it instead - it was just an alias. - MySQL and MySQLi drivers now require at least MySQL version 5.1. - db_set_charset() now only requires one parameter (collation was only needed due to legacy support for MySQL versions prior to 5.1). -- cgit v1.2.3-24-g4f1b From c28b651b91367e86f1bd6ab7f0cd6c45e58811ab Mon Sep 17 00:00:00 2001 From: Joffrey Jaffeux Date: Wed, 6 Jun 2012 14:26:04 +0200 Subject: Add support for ipv6 --- system/core/Input.php | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/system/core/Input.php b/system/core/Input.php index 73f46ba6a..6a5a9d8f0 100755 --- a/system/core/Input.php +++ b/system/core/Input.php @@ -383,7 +383,27 @@ class CI_Input { */ public function valid_ip($ip) { - return (bool) filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4); + if($this->ip_version($ip) === '4') + { + return (bool) filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4); + } + else + { + return (bool) filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6); + } + } + + // -------------------------------------------------------------------- + + /** + * Return ip version + * + * @param string + * @return string + */ + public function ip_version($ip) + { + return strpos($ip, ":") === false ? '4' : '6'; } // -------------------------------------------------------------------- -- cgit v1.2.3-24-g4f1b From 83c62ccf881847c5f4eef83822de0f7b09f98491 Mon Sep 17 00:00:00 2001 From: Joffrey Jaffeux Date: Wed, 6 Jun 2012 14:26:31 +0200 Subject: add tests for ipv6 and new method ip_version() --- tests/codeigniter/core/Input_test.php | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/tests/codeigniter/core/Input_test.php b/tests/codeigniter/core/Input_test.php index cfc80c950..27e152d6a 100644 --- a/tests/codeigniter/core/Input_test.php +++ b/tests/codeigniter/core/Input_test.php @@ -143,4 +143,31 @@ class Input_test extends CI_TestCase { $this->assertEquals("Hello, i try to your site", $harm); $this->assertEquals("Hello, i try to [removed]alert('Hack');[removed] your site", $harmless); } + + // -------------------------------------------------------------------- + + public function test_valid_ip() + { + $ip_v4 = '175.123.74.43'; + $this->assertTrue($this->input->valid_ip($ip_v4)); + + $ip_v6 = array('2001:0db8:0000:85a3:0000:0000:ac1f:8001', '2001:db8:0:85a3:0:0:ac1f:8001', '2001:db8:0:85a3::ac1f:8001'); + foreach($ip_v6 as $ip) { + $this->assertTrue($this->input->valid_ip($ip)); + } + } + + // -------------------------------------------------------------------- + + public function test_ip_version() + { + $ip_v4 = '175.123.74.43'; + $this->assertEquals('4', $this->input->ip_version($ip_v4)); + + $ip_v6 = array('2001:0db8:0000:85a3:0000:0000:ac1f:8001', '2001:db8:0:85a3:0:0:ac1f:8001', '2001:db8:0:85a3::ac1f:8001'); + foreach($ip_v6 as $ip) { + $this->assertEquals('6', $this->input->ip_version($ip)); + } + } + } \ No newline at end of file -- cgit v1.2.3-24-g4f1b From 73ed3ed3e2cf3efeb8332c569e589f16468daf7d Mon Sep 17 00:00:00 2001 From: Joffrey Jaffeux Date: Wed, 6 Jun 2012 14:26:55 +0200 Subject: update changelog for ipv6 support --- user_guide_src/source/changelog.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst index f4bba25ed..c12db1f27 100644 --- a/user_guide_src/source/changelog.rst +++ b/user_guide_src/source/changelog.rst @@ -135,6 +135,7 @@ Release Date: Not Released - Added a Wincache driver to the :doc:`Caching Library `. - Added dsn (delivery status notification) option to the :doc:`Email Library `. - Enabled public access to Email library's set_header() for adding additional headers to e-mails. Original function _set_header() now renamed to set_header(). + - Input library now supports IPv6 and has a ip_version() method. - Core -- cgit v1.2.3-24-g4f1b From 5f33f368ee4a635c93ffc73997969a2eabdf67b9 Mon Sep 17 00:00:00 2001 From: Joffrey Jaffeux Date: Wed, 6 Jun 2012 14:28:16 +0200 Subject: update documentation for ip_version() and tells valid_ip() now supports ipv6 --- user_guide_src/source/libraries/input.rst | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/user_guide_src/source/libraries/input.rst b/user_guide_src/source/libraries/input.rst index 432bac3c7..649fe43d6 100644 --- a/user_guide_src/source/libraries/input.rst +++ b/user_guide_src/source/libraries/input.rst @@ -228,7 +228,7 @@ $this->input->valid_ip($ip) ============================ Takes an IP address as input and returns TRUE or FALSE (boolean) if it -is valid or not. Note: The $this->input->ip_address() function above +is valid or not (works with IPv4 and IPv6). Note: The $this->input->ip_address() function above validates the IP automatically. :: @@ -242,6 +242,15 @@ validates the IP automatically. echo 'Valid'; } +$this->input->ip_version($ip) +============================ + +Takes an IP address as input and returns the version : 4 or 6. +:: + + $ip = '175.123.74.43'; + echo $this->input->ip_version($ip); // 4 + $this->input->user_agent() =========================== -- cgit v1.2.3-24-g4f1b From 6c8515459e4c631b0882532e8c44ee6435fd3809 Mon Sep 17 00:00:00 2001 From: Joffrey Jaffeux Date: Wed, 6 Jun 2012 14:30:11 +0200 Subject: bad spacing --- user_guide_src/source/changelog.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst index c12db1f27..0ab18782e 100644 --- a/user_guide_src/source/changelog.rst +++ b/user_guide_src/source/changelog.rst @@ -135,7 +135,7 @@ Release Date: Not Released - Added a Wincache driver to the :doc:`Caching Library `. - Added dsn (delivery status notification) option to the :doc:`Email Library `. - Enabled public access to Email library's set_header() for adding additional headers to e-mails. Original function _set_header() now renamed to set_header(). - - Input library now supports IPv6 and has a ip_version() method. + - Input library now supports IPv6 and has a ip_version() method. - Core -- cgit v1.2.3-24-g4f1b From 0723617703dda3660597d9cdef59e7cdded1c497 Mon Sep 17 00:00:00 2001 From: Joffrey Jaffeux Date: Wed, 6 Jun 2012 14:39:02 +0200 Subject: follow styling guide --- system/core/Input.php | 2 +- tests/codeigniter/core/Input_test.php | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/system/core/Input.php b/system/core/Input.php index 6a5a9d8f0..ac67aaf4f 100755 --- a/system/core/Input.php +++ b/system/core/Input.php @@ -383,7 +383,7 @@ class CI_Input { */ public function valid_ip($ip) { - if($this->ip_version($ip) === '4') + if ($this->ip_version($ip) === '4') { return (bool) filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4); } diff --git a/tests/codeigniter/core/Input_test.php b/tests/codeigniter/core/Input_test.php index 27e152d6a..2aa3a6246 100644 --- a/tests/codeigniter/core/Input_test.php +++ b/tests/codeigniter/core/Input_test.php @@ -152,7 +152,8 @@ class Input_test extends CI_TestCase { $this->assertTrue($this->input->valid_ip($ip_v4)); $ip_v6 = array('2001:0db8:0000:85a3:0000:0000:ac1f:8001', '2001:db8:0:85a3:0:0:ac1f:8001', '2001:db8:0:85a3::ac1f:8001'); - foreach($ip_v6 as $ip) { + foreach($ip_v6 as $ip) + { $this->assertTrue($this->input->valid_ip($ip)); } } @@ -165,7 +166,8 @@ class Input_test extends CI_TestCase { $this->assertEquals('4', $this->input->ip_version($ip_v4)); $ip_v6 = array('2001:0db8:0000:85a3:0000:0000:ac1f:8001', '2001:db8:0:85a3:0:0:ac1f:8001', '2001:db8:0:85a3::ac1f:8001'); - foreach($ip_v6 as $ip) { + foreach($ip_v6 as $ip) + { $this->assertEquals('6', $this->input->ip_version($ip)); } } -- cgit v1.2.3-24-g4f1b From 5ace440aa4dbd948191c37b67b01871b3a7593e9 Mon Sep 17 00:00:00 2001 From: Joffrey Jaffeux Date: Wed, 6 Jun 2012 14:52:15 +0200 Subject: change ellipsizing to ellipsize --- tests/codeigniter/helpers/text_helper_test.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/codeigniter/helpers/text_helper_test.php b/tests/codeigniter/helpers/text_helper_test.php index 584066b0c..a83c7e74d 100644 --- a/tests/codeigniter/helpers/text_helper_test.php +++ b/tests/codeigniter/helpers/text_helper_test.php @@ -122,7 +122,7 @@ class Text_helper_test extends CI_TestCase { // ------------------------------------------------------------------------ - public function test_ellipsizing() + public function test_ellipsize() { $strs = array( '0' => array( -- cgit v1.2.3-24-g4f1b From 47b673324f06236264ca64f8c3155aab51762609 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Wed, 6 Jun 2012 15:58:05 +0300 Subject: Add a second parameter (charset) to CI_Output::set_content_type() + fix for issue #666 --- system/core/Output.php | 10 ++++++++-- user_guide_src/source/changelog.rst | 4 +++- user_guide_src/source/libraries/output.rst | 4 ++++ 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/system/core/Output.php b/system/core/Output.php index 09656711b..0bf982289 100755 --- a/system/core/Output.php +++ b/system/core/Output.php @@ -200,7 +200,7 @@ class CI_Output { * @param string extension of the file we're outputting * @return void */ - public function set_content_type($mime_type) + public function set_content_type($mime_type, $charset = NULL) { if (strpos($mime_type, '/') === FALSE) { @@ -218,7 +218,13 @@ class CI_Output { } } - $header = 'Content-Type: '.$mime_type; + if (empty($charset)) + { + $charset = config_item('charset'); + } + + $header = 'Content-Type: '.$mime_type + .(empty($charset) ? NULL : '; charset='.strtolower($charset)); $this->headers[] = array($header, TRUE); return $this; diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst index 74de512f7..ce9b06883 100644 --- a/user_guide_src/source/changelog.rst +++ b/user_guide_src/source/changelog.rst @@ -135,7 +135,7 @@ Release Date: Not Released - Allowed for setting table class defaults in a config file. - Added a Wincache driver to the :doc:`Caching Library `. - Added dsn (delivery status notification) option to the :doc:`Email Library `. - - Enabled public access to Email library's set_header() for adding additional headers to e-mails. Original function _set_header() now renamed to set_header(). + - Renamed method _set_header() to set_header() and made it public to enable adding custom headers in the :doc:`Email Library `. - Core @@ -150,6 +150,7 @@ Release Date: Not Released - Renamed method _call_hook() to call_hook() in the :doc:`Hooks Library `. - Added get_content_type() method to the :doc:`Output Library `. - Added get_mimes() function to system/core/Commons.php to return the config/mimes.php array. + - Added a second argument to set_content_type() in the :doc:`Output Library ` that allows setting the document charset as well. Bug fixes for 3.0 ------------------ @@ -230,6 +231,7 @@ Bug fixes for 3.0 - Fixed a bug (#1419) - libraries/Driver.php had a static variable that was causing an error. - Fixed a bug (#1411) - the :doc:`Email library ` used its own short list of MIMEs instead the one from config/mimes.php. - Fixed a bug where the magic_quotes_runtime setting wasn't turned off for PHP 5.3 (where it is indeed deprecated, but not non-existent). +- Fixed a bug (#666) - :doc:`Output library `'s set_content_type() method didn't set the document charset. Version 2.1.1 ============= diff --git a/user_guide_src/source/libraries/output.rst b/user_guide_src/source/libraries/output.rst index baceaae7b..0472d14cf 100644 --- a/user_guide_src/source/libraries/output.rst +++ b/user_guide_src/source/libraries/output.rst @@ -49,6 +49,10 @@ data, JPEG's, XML, etc easily. .. important:: Make sure any non-mime string you pass to this method exists in config/mimes.php or it will have no effect. +You can also set the character set of the document, by passing a second argument:: + + $this->output->set_content_type('css', 'utf-8'); + $this->output->get_content_type(); ========================================== -- cgit v1.2.3-24-g4f1b From 0ef92f6fa4a40d4a689eee3ebd7eb7d632fe29c0 Mon Sep 17 00:00:00 2001 From: Joffrey Jaffeux Date: Wed, 6 Jun 2012 15:12:37 +0200 Subject: test for word_wrap() --- tests/codeigniter/helpers/text_helper_test.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tests/codeigniter/helpers/text_helper_test.php b/tests/codeigniter/helpers/text_helper_test.php index a83c7e74d..974247c4f 100644 --- a/tests/codeigniter/helpers/text_helper_test.php +++ b/tests/codeigniter/helpers/text_helper_test.php @@ -156,4 +156,12 @@ class Text_helper_test extends CI_TestCase { // ------------------------------------------------------------------------ + public function test_word_wrap() + { + $string = "Here is a simple string of text that will help us demonstrate this function."; + $word_wraped = word_wrap($string, 25); + preg_match_all("/\r\n|\n/", $word_wraped, $matches); + $this->assertEquals(count($matches[0]), 4); + } + } \ No newline at end of file -- cgit v1.2.3-24-g4f1b From 4221b980b66bbaebc23a0f9cc5dee7d649948e15 Mon Sep 17 00:00:00 2001 From: Joffrey Jaffeux Date: Wed, 6 Jun 2012 15:38:35 +0200 Subject: add test for word_wrap default charlim --- tests/codeigniter/helpers/text_helper_test.php | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/tests/codeigniter/helpers/text_helper_test.php b/tests/codeigniter/helpers/text_helper_test.php index 974247c4f..d59b2743d 100644 --- a/tests/codeigniter/helpers/text_helper_test.php +++ b/tests/codeigniter/helpers/text_helper_test.php @@ -160,8 +160,17 @@ class Text_helper_test extends CI_TestCase { { $string = "Here is a simple string of text that will help us demonstrate this function."; $word_wraped = word_wrap($string, 25); - preg_match_all("/\r\n|\n/", $word_wraped, $matches); - $this->assertEquals(count($matches[0]), 4); + $this->assertEquals(substr_count($word_wraped, "\n"), 4); + } + + // ------------------------------------------------------------------------ + + public function test_default_word_wrap_charlim() + { + $string = "Here is a simple string of text that will help us demonstrate this function."; + $word_wraped = word_wrap($string); + $matches = preg_split("/\n/", $word_wraped, 1); + $this->assertEquals(strlen($matches[0]) - 1, 76); } } \ No newline at end of file -- cgit v1.2.3-24-g4f1b From bfaf50258b6f33961210ecc3df4ade2e0a4512b4 Mon Sep 17 00:00:00 2001 From: Joffrey Jaffeux Date: Wed, 6 Jun 2012 15:39:45 +0200 Subject: typo word_wraped -> word_wrapped --- tests/codeigniter/helpers/text_helper_test.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/codeigniter/helpers/text_helper_test.php b/tests/codeigniter/helpers/text_helper_test.php index d59b2743d..3bc83f050 100644 --- a/tests/codeigniter/helpers/text_helper_test.php +++ b/tests/codeigniter/helpers/text_helper_test.php @@ -159,8 +159,8 @@ class Text_helper_test extends CI_TestCase { public function test_word_wrap() { $string = "Here is a simple string of text that will help us demonstrate this function."; - $word_wraped = word_wrap($string, 25); - $this->assertEquals(substr_count($word_wraped, "\n"), 4); + $word_wrapped = word_wrap($string, 25); + $this->assertEquals(substr_count($word_wrapped, "\n"), 4); } // ------------------------------------------------------------------------ @@ -168,8 +168,8 @@ class Text_helper_test extends CI_TestCase { public function test_default_word_wrap_charlim() { $string = "Here is a simple string of text that will help us demonstrate this function."; - $word_wraped = word_wrap($string); - $matches = preg_split("/\n/", $word_wraped, 1); + $word_wrapped = word_wrap($string); + $matches = preg_split("/\n/", $word_wrapped, 1); $this->assertEquals(strlen($matches[0]) - 1, 76); } -- cgit v1.2.3-24-g4f1b From 385452c2ca1f9ce00668ca6d77c6fd0ad1ea4771 Mon Sep 17 00:00:00 2001 From: Joffrey Jaffeux Date: Wed, 6 Jun 2012 15:43:18 +0200 Subject: correction of the test and longer test string --- tests/codeigniter/helpers/text_helper_test.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/codeigniter/helpers/text_helper_test.php b/tests/codeigniter/helpers/text_helper_test.php index 3bc83f050..3c590538a 100644 --- a/tests/codeigniter/helpers/text_helper_test.php +++ b/tests/codeigniter/helpers/text_helper_test.php @@ -167,10 +167,10 @@ class Text_helper_test extends CI_TestCase { public function test_default_word_wrap_charlim() { - $string = "Here is a simple string of text that will help us demonstrate this function."; + $string = "Here is a longer string of text that will help us demonstrate the default charlim of this function."; $word_wrapped = word_wrap($string); - $matches = preg_split("/\n/", $word_wrapped, 1); - $this->assertEquals(strlen($matches[0]) - 1, 76); + $matches = preg_split("/\n/", $word_wrapped, 0); + $this->assertEquals(strlen($matches[0]), 73); } } \ No newline at end of file -- cgit v1.2.3-24-g4f1b From 908f36a583384b0314d04c4cfe71992746e35daa Mon Sep 17 00:00:00 2001 From: Joffrey Jaffeux Date: Wed, 6 Jun 2012 15:47:22 +0200 Subject: ip_version() now returns int instead of string --- system/core/Input.php | 6 +++--- tests/codeigniter/core/Input_test.php | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/system/core/Input.php b/system/core/Input.php index ac67aaf4f..36ff96d03 100755 --- a/system/core/Input.php +++ b/system/core/Input.php @@ -383,7 +383,7 @@ class CI_Input { */ public function valid_ip($ip) { - if ($this->ip_version($ip) === '4') + if ($this->ip_version($ip) === 4) { return (bool) filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4); } @@ -399,11 +399,11 @@ class CI_Input { * Return ip version * * @param string - * @return string + * @return int */ public function ip_version($ip) { - return strpos($ip, ":") === false ? '4' : '6'; + return strpos($ip, ":") === false ? 4 : 6; } // -------------------------------------------------------------------- diff --git a/tests/codeigniter/core/Input_test.php b/tests/codeigniter/core/Input_test.php index 2aa3a6246..98d6299f8 100644 --- a/tests/codeigniter/core/Input_test.php +++ b/tests/codeigniter/core/Input_test.php @@ -163,12 +163,12 @@ class Input_test extends CI_TestCase { public function test_ip_version() { $ip_v4 = '175.123.74.43'; - $this->assertEquals('4', $this->input->ip_version($ip_v4)); + $this->assertEquals(4, $this->input->ip_version($ip_v4)); $ip_v6 = array('2001:0db8:0000:85a3:0000:0000:ac1f:8001', '2001:db8:0:85a3:0:0:ac1f:8001', '2001:db8:0:85a3::ac1f:8001'); foreach($ip_v6 as $ip) { - $this->assertEquals('6', $this->input->ip_version($ip)); + $this->assertEquals(6, $this->input->ip_version($ip)); } } -- cgit v1.2.3-24-g4f1b From 4215ddccd369ae8894c1031b97a344ae76eef5f6 Mon Sep 17 00:00:00 2001 From: Joffrey Jaffeux Date: Wed, 6 Jun 2012 15:58:28 +0200 Subject: remove regex in favor of strpos --- tests/codeigniter/helpers/text_helper_test.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tests/codeigniter/helpers/text_helper_test.php b/tests/codeigniter/helpers/text_helper_test.php index 3c590538a..73e2b9429 100644 --- a/tests/codeigniter/helpers/text_helper_test.php +++ b/tests/codeigniter/helpers/text_helper_test.php @@ -169,8 +169,7 @@ class Text_helper_test extends CI_TestCase { { $string = "Here is a longer string of text that will help us demonstrate the default charlim of this function."; $word_wrapped = word_wrap($string); - $matches = preg_split("/\n/", $word_wrapped, 0); - $this->assertEquals(strlen($matches[0]), 73); + $this->assertEquals(strpos($word_wrapped, "\n"), 73); } } \ No newline at end of file -- cgit v1.2.3-24-g4f1b From 3c5623748424aaccd6bad980240833b3b1e87d60 Mon Sep 17 00:00:00 2001 From: Cory Date: Wed, 6 Jun 2012 10:51:55 -0400 Subject: Modifying changelog to reflect the change --- user_guide_src/source/changelog.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst index 587e56ea7..e8e8a8da0 100644 --- a/user_guide_src/source/changelog.rst +++ b/user_guide_src/source/changelog.rst @@ -225,6 +225,7 @@ Bug fixes for 3.0 - Fixed a bug (#356) - PostgreSQL driver didn't have an _update_batch() method, which resulted in fatal error being triggered when update_batch() is used with it. - Fixed a bug (#862) - create_table() failed on SQLSRV/MSSQL when used with 'IF NOT EXISTS'. - Fixed a bug (#1419) - libraries/Driver.php had a static variable that was causing an error. +- Fixed a bug (#1374) - :doc:`Table Library ` was generating an extra td tag at the start of the tr. Version 2.1.1 ============= -- cgit v1.2.3-24-g4f1b From 1eb9b127cfb3aef5d89b86a48e35b2f35cd17f81 Mon Sep 17 00:00:00 2001 From: Joffrey Jaffeux Date: Wed, 6 Jun 2012 17:57:40 +0200 Subject: styling guide false -> FALSE --- 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 36ff96d03..c1f2086c4 100755 --- a/system/core/Input.php +++ b/system/core/Input.php @@ -403,7 +403,7 @@ class CI_Input { */ public function ip_version($ip) { - return strpos($ip, ":") === false ? 4 : 6; + return strpos($ip, ":") === FALSE ? 4 : 6; } // -------------------------------------------------------------------- -- cgit v1.2.3-24-g4f1b From 70b5d3b4eb74ad27da7eac29ef5d349be944ba15 Mon Sep 17 00:00:00 2001 From: Joffrey Jaffeux Date: Wed, 6 Jun 2012 18:22:36 +0200 Subject: use an ip of the range 192.18.0.0/15 --- tests/codeigniter/core/Input_test.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/codeigniter/core/Input_test.php b/tests/codeigniter/core/Input_test.php index 98d6299f8..3682d308d 100644 --- a/tests/codeigniter/core/Input_test.php +++ b/tests/codeigniter/core/Input_test.php @@ -148,7 +148,7 @@ class Input_test extends CI_TestCase { public function test_valid_ip() { - $ip_v4 = '175.123.74.43'; + $ip_v4 = '192.18.0.1'; $this->assertTrue($this->input->valid_ip($ip_v4)); $ip_v6 = array('2001:0db8:0000:85a3:0000:0000:ac1f:8001', '2001:db8:0:85a3:0:0:ac1f:8001', '2001:db8:0:85a3::ac1f:8001'); @@ -162,7 +162,7 @@ class Input_test extends CI_TestCase { public function test_ip_version() { - $ip_v4 = '175.123.74.43'; + $ip_v4 = '192.18.0.1'; $this->assertEquals(4, $this->input->ip_version($ip_v4)); $ip_v6 = array('2001:0db8:0000:85a3:0000:0000:ac1f:8001', '2001:db8:0:85a3:0:0:ac1f:8001', '2001:db8:0:85a3::ac1f:8001'); -- cgit v1.2.3-24-g4f1b From 910ff7ad430f47ebcf3d801314fcee9a3c10f011 Mon Sep 17 00:00:00 2001 From: Michiel Vugteveen Date: Wed, 6 Jun 2012 20:03:14 +0200 Subject: form_checkbox set_value fix --- system/helpers/form_helper.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/system/helpers/form_helper.php b/system/helpers/form_helper.php index 410972187..04d11837e 100644 --- a/system/helpers/form_helper.php +++ b/system/helpers/form_helper.php @@ -378,7 +378,7 @@ if ( ! function_exists('form_checkbox')) { $checked = $data['checked']; - if ($checked === FALSE) + if ($checked == FALSE) { unset($data['checked']); } @@ -388,7 +388,7 @@ if ( ! function_exists('form_checkbox')) } } - if ($checked === TRUE) + if ($checked == TRUE) { $defaults['checked'] = 'checked'; } -- cgit v1.2.3-24-g4f1b From 1ab6f6520ebfc016c49cfbe3a4d9d009be5da268 Mon Sep 17 00:00:00 2001 From: Joffrey Jaffeux Date: Wed, 6 Jun 2012 20:14:13 +0200 Subject: removed ip_version() --- system/core/Input.php | 22 +--------------------- tests/codeigniter/core/Input_test.php | 14 -------------- user_guide_src/source/changelog.rst | 2 +- user_guide_src/source/libraries/input.rst | 9 --------- 4 files changed, 2 insertions(+), 45 deletions(-) diff --git a/system/core/Input.php b/system/core/Input.php index c1f2086c4..b986c4973 100755 --- a/system/core/Input.php +++ b/system/core/Input.php @@ -383,27 +383,7 @@ class CI_Input { */ public function valid_ip($ip) { - if ($this->ip_version($ip) === 4) - { - return (bool) filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4); - } - else - { - return (bool) filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6); - } - } - - // -------------------------------------------------------------------- - - /** - * Return ip version - * - * @param string - * @return int - */ - public function ip_version($ip) - { - return strpos($ip, ":") === FALSE ? 4 : 6; + return (bool) filter_var($ip, FILTER_VALIDATE_IP); } // -------------------------------------------------------------------- diff --git a/tests/codeigniter/core/Input_test.php b/tests/codeigniter/core/Input_test.php index 3682d308d..c9322c027 100644 --- a/tests/codeigniter/core/Input_test.php +++ b/tests/codeigniter/core/Input_test.php @@ -158,18 +158,4 @@ class Input_test extends CI_TestCase { } } - // -------------------------------------------------------------------- - - public function test_ip_version() - { - $ip_v4 = '192.18.0.1'; - $this->assertEquals(4, $this->input->ip_version($ip_v4)); - - $ip_v6 = array('2001:0db8:0000:85a3:0000:0000:ac1f:8001', '2001:db8:0:85a3:0:0:ac1f:8001', '2001:db8:0:85a3::ac1f:8001'); - foreach($ip_v6 as $ip) - { - $this->assertEquals(6, $this->input->ip_version($ip)); - } - } - } \ No newline at end of file diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst index 3118b7dc5..0b987b1be 100644 --- a/user_guide_src/source/changelog.rst +++ b/user_guide_src/source/changelog.rst @@ -135,7 +135,7 @@ Release Date: Not Released - Allowed for setting table class defaults in a config file. - Added a Wincache driver to the :doc:`Caching Library `. - Added dsn (delivery status notification) option to the :doc:`Email Library `. - - Input library now supports IPv6 and has a ip_version() method. + - Input library now supports IPv6. - Renamed method _set_header() to set_header() and made it public to enable adding custom headers in the :doc:`Email Library `. - Core diff --git a/user_guide_src/source/libraries/input.rst b/user_guide_src/source/libraries/input.rst index 649fe43d6..abdf87704 100644 --- a/user_guide_src/source/libraries/input.rst +++ b/user_guide_src/source/libraries/input.rst @@ -242,15 +242,6 @@ validates the IP automatically. echo 'Valid'; } -$this->input->ip_version($ip) -============================ - -Takes an IP address as input and returns the version : 4 or 6. -:: - - $ip = '175.123.74.43'; - echo $this->input->ip_version($ip); // 4 - $this->input->user_agent() =========================== -- cgit v1.2.3-24-g4f1b From 9640a037c51c1efea2e64caa974c577dc1594f5d Mon Sep 17 00:00:00 2001 From: Michiel Vugteveen Date: Wed, 6 Jun 2012 20:20:27 +0200 Subject: fixes --- system/helpers/form_helper.php | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/system/helpers/form_helper.php b/system/helpers/form_helper.php index 04d11837e..40c7d8823 100644 --- a/system/helpers/form_helper.php +++ b/system/helpers/form_helper.php @@ -325,7 +325,10 @@ if ( ! function_exists('form_dropdown')) $selected = array($_POST[$name]); } - if ($extra !== '') $extra = ' '.$extra; + if ($extra != '') + { + $extra = ' '.$extra; + } $multiple = (count($selected) > 1 && strpos($extra, 'multiple') === FALSE) ? ' multiple="multiple"' : ''; @@ -702,7 +705,7 @@ if ( ! function_exists('set_select')) return ''; } } - elseif (($field === '' OR $value === '') OR ($field !== $value)) + elseif (($field == '' OR $value == '') OR ($field != $value)) { return ''; } @@ -753,7 +756,7 @@ if ( ! function_exists('set_checkbox')) return ''; } } - elseif (($field === '' OR $value === '') OR ($field !== $value)) + elseif (($field == '' OR $value == '') OR ($field != $value)) { return ''; } @@ -806,7 +809,7 @@ if ( ! function_exists('set_radio')) } else { - if (($field === '' OR $value === '') OR ($field !== $value)) + if (($field == '' OR $value == '') OR ($field != $value)) { return ''; } -- cgit v1.2.3-24-g4f1b From 3dfa14b3831c6f22acdca3d3ae8f0cb48e66b782 Mon Sep 17 00:00:00 2001 From: Joffrey Jaffeux Date: Wed, 6 Jun 2012 22:21:31 +0200 Subject: remove text about ipv4/ipv6 support in the doc --- user_guide_src/source/libraries/input.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/user_guide_src/source/libraries/input.rst b/user_guide_src/source/libraries/input.rst index abdf87704..432bac3c7 100644 --- a/user_guide_src/source/libraries/input.rst +++ b/user_guide_src/source/libraries/input.rst @@ -228,7 +228,7 @@ $this->input->valid_ip($ip) ============================ Takes an IP address as input and returns TRUE or FALSE (boolean) if it -is valid or not (works with IPv4 and IPv6). Note: The $this->input->ip_address() function above +is valid or not. Note: The $this->input->ip_address() function above validates the IP automatically. :: -- cgit v1.2.3-24-g4f1b From a6f3423388c2c51119e71d7aac2917b34911bf5c Mon Sep 17 00:00:00 2001 From: Michiel Vugteveen Date: Thu, 7 Jun 2012 10:14:29 +0200 Subject: fixes --- system/helpers/form_helper.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/system/helpers/form_helper.php b/system/helpers/form_helper.php index 40c7d8823..984634315 100644 --- a/system/helpers/form_helper.php +++ b/system/helpers/form_helper.php @@ -705,7 +705,7 @@ if ( ! function_exists('set_select')) return ''; } } - elseif (($field == '' OR $value == '') OR ($field != $value)) + elseif (($field == '' OR $value == '') OR $field !== $value) { return ''; } @@ -756,7 +756,7 @@ if ( ! function_exists('set_checkbox')) return ''; } } - elseif (($field == '' OR $value == '') OR ($field != $value)) + elseif (($field == '' OR $value == '') OR $field !== $value) { return ''; } @@ -809,7 +809,7 @@ if ( ! function_exists('set_radio')) } else { - if (($field == '' OR $value == '') OR ($field != $value)) + if (($field == '' OR $value == '') OR $field !== $value) { return ''; } -- cgit v1.2.3-24-g4f1b From c839d28f4230dce0c658338f267b821cc16490a2 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Thu, 7 Jun 2012 14:35:27 +0300 Subject: Remove some unnecessary function_exists() checks and some minor improvements --- system/core/Output.php | 2 +- system/helpers/path_helper.php | 2 +- system/libraries/Profiler.php | 2 +- system/libraries/Unit_test.php | 16 ++++++---------- system/libraries/Upload.php | 20 +++++++------------- 5 files changed, 16 insertions(+), 26 deletions(-) diff --git a/system/core/Output.php b/system/core/Output.php index 0bf982289..5588ffe8e 100755 --- a/system/core/Output.php +++ b/system/core/Output.php @@ -370,7 +370,7 @@ class CI_Output { if ($this->parse_exec_vars === TRUE) { - $memory = function_exists('memory_get_usage') ? round(memory_get_usage()/1024/1024, 2).'MB' : '0'; + $memory = round(memory_get_usage() / 1024 / 1024, 2).'MB'; $output = str_replace(array('{elapsed_time}', '{memory_usage}'), array($elapsed, $memory), $output); } diff --git a/system/helpers/path_helper.php b/system/helpers/path_helper.php index 13410545c..fec4a1a10 100644 --- a/system/helpers/path_helper.php +++ b/system/helpers/path_helper.php @@ -55,7 +55,7 @@ if ( ! function_exists('set_realpath')) } // Resolve the path - if (function_exists('realpath') && @realpath($path) !== FALSE) + if (@realpath($path) !== FALSE) { $path = realpath($path); } diff --git a/system/libraries/Profiler.php b/system/libraries/Profiler.php index aaac0c518..d96088c14 100644 --- a/system/libraries/Profiler.php +++ b/system/libraries/Profiler.php @@ -402,7 +402,7 @@ class CI_Profiler { ."\n" .'  '.$this->CI->lang->line('profiler_memory_usage')."  \n" .'
' - .((function_exists('memory_get_usage') && ($usage = memory_get_usage()) !== '') ? number_format($usage).' bytes' : $this->CI->lang->line('profiler_no_memory')) + .(($usage = memory_get_usage()) != '' ? number_format($usage).' bytes' : $this->CI->lang->line('profiler_no_memory')) .'
'; } diff --git a/system/libraries/Unit_test.php b/system/libraries/Unit_test.php index a87cf7e14..70ad8dc41 100644 --- a/system/libraries/Unit_test.php +++ b/system/libraries/Unit_test.php @@ -124,7 +124,7 @@ class CI_Unit_test { $this->results[] = $report; - return($this->report($this->result($report))); + return $this->report($this->result($report)); } // -------------------------------------------------------------------- @@ -289,15 +289,11 @@ class CI_Unit_test { */ protected function _backtrace() { - if (function_exists('debug_backtrace')) - { - $back = debug_backtrace(); - return array( - 'file' => (isset($back[1]['file']) ? $back[1]['file'] : ''), - 'line' => (isset($back[1]['line']) ? $back[1]['line'] : '') - ); - } - return array('file' => 'Unknown', 'line' => 'Unknown'); + $back = debug_backtrace(); + return array( + 'file' => (isset($back[1]['file']) ? $back[1]['file'] : ''), + 'line' => (isset($back[1]['line']) ? $back[1]['line'] : '') + ); } // -------------------------------------------------------------------- diff --git a/system/libraries/Upload.php b/system/libraries/Upload.php index c1e07de7a..1f6aeeb6b 100644 --- a/system/libraries/Upload.php +++ b/system/libraries/Upload.php @@ -694,7 +694,7 @@ class CI_Upload { return FALSE; } - if (function_exists('realpath') && @realpath($this->upload_path) !== FALSE) + if (@realpath($this->upload_path) !== FALSE) { $this->upload_path = str_replace('\\', '/', realpath($this->upload_path)); } @@ -815,17 +815,17 @@ class CI_Upload { return FALSE; } - if (function_exists('memory_get_usage') && memory_get_usage() && ini_get('memory_limit')) + if (memory_get_usage() && ($memory_limit = ini_get('memory_limit'))) { - $current = ini_get('memory_limit') * 1024 * 1024; + $memory_limit *= 1024 * 1024; // There was a bug/behavioural change in PHP 5.2, where numbers over one million get output // into scientific notation. number_format() ensures this number is an integer // http://bugs.php.net/bug.php?id=43053 - $new_memory = number_format(ceil(filesize($file) + $current), 0, '.', ''); + $memory_limit = number_format(ceil(filesize($file) + $memory_limit), 0, '.', ''); - ini_set('memory_limit', $new_memory); // When an integer is used, the value is measured in bytes. - PHP.net + ini_set('memory_limit', $memory_limit); // When an integer is used, the value is measured in bytes. - PHP.net } // If the file being uploaded is an image, then we should have no problem with XSS attacks (in theory), but @@ -849,14 +849,8 @@ class CI_Upload { // ]/i', $opening_bytes)) - { - return TRUE; // its an image, no "triggers" detected in the first 256 bytes, we're good - } - else - { - return FALSE; - } + // if its an image or no "triggers" detected in the first 256 bytes - we're good + return ! preg_match('/<(a|body|head|html|img|plaintext|pre|script|table|title)[\s>]/i', $opening_bytes); } if (($data = @file_get_contents($file)) === FALSE) -- cgit v1.2.3-24-g4f1b From 0f0b76980cb07f39b20c8591882aeae3854f016c Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Thu, 7 Jun 2012 14:57:04 +0300 Subject: Deprecated do_hash() and read_file() in favor of hash() and file_get_contents() respectively --- system/database/DB_cache.php | 2 +- system/helpers/file_helper.php | 31 +++-------------------- system/helpers/security_helper.php | 3 +++ system/libraries/Cache/drivers/Cache_file.php | 4 +-- user_guide_src/source/changelog.rst | 20 ++++++++------- user_guide_src/source/helpers/file_helper.rst | 3 +++ user_guide_src/source/helpers/security_helper.rst | 6 +++-- user_guide_src/source/helpers/string_helper.rst | 3 +-- 8 files changed, 29 insertions(+), 43 deletions(-) diff --git a/system/database/DB_cache.php b/system/database/DB_cache.php index 14f3c21bc..ba9110382 100644 --- a/system/database/DB_cache.php +++ b/system/database/DB_cache.php @@ -99,7 +99,7 @@ class CI_DB_Cache { $segment_two = ($this->CI->uri->segment(2) == FALSE) ? 'index' : $this->CI->uri->segment(2); $filepath = $this->db->cachedir.$segment_one.'+'.$segment_two.'/'.md5($sql); - if (FALSE === ($cachedata = read_file($filepath))) + if (FALSE === ($cachedata = file_get_contents($filepath))) { return FALSE; } diff --git a/system/helpers/file_helper.php b/system/helpers/file_helper.php index d53d986f9..b717aaa0d 100644 --- a/system/helpers/file_helper.php +++ b/system/helpers/file_helper.php @@ -44,38 +44,15 @@ if ( ! function_exists('read_file')) * * Opens the file specfied in the path and returns it as a string. * + * This function is DEPRECATED and should be removed in + * CodeIgniter 3.1+. Use file_get_contents() instead. + * * @param string path to file * @return string */ function read_file($file) { - if ( ! file_exists($file)) - { - return FALSE; - } - - if (function_exists('file_get_contents')) - { - return file_get_contents($file); - } - - if ( ! $fp = @fopen($file, FOPEN_READ)) - { - return FALSE; - } - - flock($fp, LOCK_SH); - - $data = ''; - if (filesize($file) > 0) - { - $data =& fread($fp, filesize($file)); - } - - flock($fp, LOCK_UN); - fclose($fp); - - return $data; + return file_get_contents($file); } } diff --git a/system/helpers/security_helper.php b/system/helpers/security_helper.php index 6187a4a7a..3e6e91435 100644 --- a/system/helpers/security_helper.php +++ b/system/helpers/security_helper.php @@ -77,6 +77,9 @@ if ( ! function_exists('do_hash')) /** * Hash encode a string * + * This function is DEPRECATED and should be removed in + * CodeIgniter 3.1+. Use hash() instead. + * * @param string * @param string * @return string diff --git a/system/libraries/Cache/drivers/Cache_file.php b/system/libraries/Cache/drivers/Cache_file.php index ce2c2b13a..5170de821 100644 --- a/system/libraries/Cache/drivers/Cache_file.php +++ b/system/libraries/Cache/drivers/Cache_file.php @@ -71,7 +71,7 @@ class CI_Cache_file extends CI_Driver { return FALSE; } - $data = unserialize(read_file($this->_cache_path.$id)); + $data = unserialize(file_get_contents($this->_cache_path.$id)); if (time() > $data['time'] + $data['ttl']) { @@ -165,7 +165,7 @@ class CI_Cache_file extends CI_Driver { return FALSE; } - $data = unserialize(read_file($this->_cache_path.$id)); + $data = unserialize(file_get_contents($this->_cache_path.$id)); if (is_array($data)) { diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst index 211e9acc9..7180c2d07 100644 --- a/user_guide_src/source/changelog.rst +++ b/user_guide_src/source/changelog.rst @@ -44,19 +44,21 @@ Release Date: Not Released - Helpers - - create_captcha() accepts additional colors parameter, allowing for color customization - - url_title() will now trim extra dashes from beginning and end. + - ``create_captcha()`` accepts additional colors parameter, allowing for color customization. + - ``url_title()`` will now trim extra dashes from beginning and end. - Added XHTML Basic 1.1 doctype to :doc:`HTML Helper `. - - Changed humanize() to include a second param for the separator. + - Changed ``humanize()`` to include a second param for the separator. - Refactored ``plural()`` and ``singular()`` to avoid double pluralization and support more words. - Added an optional third parameter to ``force_download()`` that enables/disables sending the actual file MIME type in the Content-Type header (disabled by default). - Added an optional third parameter to ``timespan()`` that constrains the number of time units displayed. - - Added a work-around in force_download() for a bug Android <= 2.1, where the filename extension needs to be in uppercase. - - form_dropdown() will now also take an array for unity with other form helpers. - - set_realpath() can now also handle file paths as opposed to just directories. - - do_hash() now uses PHP's native hash() function, supporting more algorithms. - - Added an optional paramater to ``delete_files()`` to enable it to skip deleting files such as .htaccess and index.html. - - Removed deprecated helper function ``js_insert_smiley()`` from smiley helper. + - Added a work-around in ``force_download()`` for a bug Android <= 2.1, where the filename extension needs to be in uppercase. + - ``form_dropdown()`` will now also take an array for unity with other form helpers. + - ``do_hash()`` now uses PHP's native ``hash()`` function (supporting more algorithms) and is deprecated. + - Removed previously deprecated helper function ``js_insert_smiley()`` from smiley helper. + - :doc:`File Helper ` changes include: + - ``set_realpath()`` can now also handle file paths as opposed to just directories. + - Added an optional paramater to ``delete_files()`` to enable it to skip deleting files such as .htaccess and index.html. + - ``read_file()`` is now a deprecated alias of ``file_get_contents()``. - Database diff --git a/user_guide_src/source/helpers/file_helper.rst b/user_guide_src/source/helpers/file_helper.rst index bfc271eb3..60c5aa98c 100644 --- a/user_guide_src/source/helpers/file_helper.rst +++ b/user_guide_src/source/helpers/file_helper.rst @@ -32,6 +32,9 @@ The path can be a relative or full server path. Returns FALSE (boolean) on failu controller or view files. CodeIgniter uses a front controller so paths are always relative to the main site index. +.. note:: This function is DEPRECATED. Use the native ``file_get_contents()`` + instead. + If your server is running an `open_basedir` restriction this function might not work if you are trying to access a file above the calling script. write_file('path', $data) diff --git a/user_guide_src/source/helpers/security_helper.rst b/user_guide_src/source/helpers/security_helper.rst index b1bcf2b4a..ec0be28b3 100644 --- a/user_guide_src/source/helpers/security_helper.rst +++ b/user_guide_src/source/helpers/security_helper.rst @@ -43,8 +43,10 @@ for a full list of supported algorithms. $str = do_hash($str); // SHA1 $str = do_hash($str, 'md5'); // MD5 -.. note:: This function was formerly named dohash(), which has been - removed in favor of `do_hash()`. +.. note:: This function was formerly named ``dohash()``, which has been + removed in favor of ``do_hash()``. + +.. note:: This function is DEPRECATED. Use the native ``hash()`` instead. strip_image_tags() ================== diff --git a/user_guide_src/source/helpers/string_helper.rst b/user_guide_src/source/helpers/string_helper.rst index 2d23fb00c..19500aa0d 100644 --- a/user_guide_src/source/helpers/string_helper.rst +++ b/user_guide_src/source/helpers/string_helper.rst @@ -36,8 +36,7 @@ alpha, alunum, numeric, nozero, unique, md5, encrypt and sha1 - **unique**: Encrypted with MD5 and uniqid(). Note: The length parameter is not available for this type. Returns a fixed length 32 character string. -- **sha1**: An encrypted random number based on do_hash() from the - :doc:`security helper `. +- **sha1**: An encrypted random number based on ``sha1()``. Usage example -- cgit v1.2.3-24-g4f1b From d09ff35e8c4b7cae6313cc40ec0e6b57b9f52106 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Thu, 7 Jun 2012 15:46:32 +0300 Subject: Revert 296ab9a06e3c648de56861ad67581236a6dae71a - there's no bug to fix --- system/libraries/Table.php | 6 +++--- user_guide_src/source/changelog.rst | 1 - 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/system/libraries/Table.php b/system/libraries/Table.php index 06b68db32..0f8404d85 100644 --- a/system/libraries/Table.php +++ b/system/libraries/Table.php @@ -247,7 +247,7 @@ class CI_Table { { foreach ($args[0] as $key => $val) { - $ret_args[$key] = (is_array($val) && isset($val['data'])) ? $val : array('data' => $val); + $args[$key] = (is_array($val) && isset($val['data'])) ? $val : array('data' => $val); } } } @@ -257,12 +257,12 @@ class CI_Table { { if ( ! is_array($val)) { - $ret_args[$key] = array('data' => $val); + $args[$key] = array('data' => $val); } } } - return $ret_args; + return $args; } // -------------------------------------------------------------------- diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst index 7180c2d07..a7bf6fa6e 100644 --- a/user_guide_src/source/changelog.rst +++ b/user_guide_src/source/changelog.rst @@ -235,7 +235,6 @@ Bug fixes for 3.0 - Fixed a bug (#1411) - the :doc:`Email library ` used its own short list of MIMEs instead the one from config/mimes.php. - Fixed a bug where the magic_quotes_runtime setting wasn't turned off for PHP 5.3 (where it is indeed deprecated, but not non-existent). - Fixed a bug (#666) - :doc:`Output library `'s set_content_type() method didn't set the document charset. -- Fixed a bug (#1374) - :doc:`Table Library ` was generating an extra td tag at the start of the tr. Version 2.1.1 ============= -- cgit v1.2.3-24-g4f1b From 596c51cdca8d623c96243a81bc5212d34f820a97 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Thu, 7 Jun 2012 15:51:58 +0300 Subject: Suppress errors from file_get_contents() in read_file() --- system/helpers/file_helper.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/system/helpers/file_helper.php b/system/helpers/file_helper.php index b717aaa0d..be616f62d 100644 --- a/system/helpers/file_helper.php +++ b/system/helpers/file_helper.php @@ -52,7 +52,7 @@ if ( ! function_exists('read_file')) */ function read_file($file) { - return file_get_contents($file); + return @file_get_contents($file); } } -- cgit v1.2.3-24-g4f1b From 1f26edc61f314a74cd93fcdf688b3780734e0e96 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Thu, 7 Jun 2012 16:13:54 +0300 Subject: Added a work-around for MSSQL/SQLSRV create_table() with INT column types (column lengths are not supported) --- system/database/drivers/mssql/mssql_forge.php | 1 + system/database/drivers/sqlsrv/sqlsrv_forge.php | 1 + user_guide_src/source/changelog.rst | 4 ++-- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/system/database/drivers/mssql/mssql_forge.php b/system/database/drivers/mssql/mssql_forge.php index 3708c2233..5454e37b3 100644 --- a/system/database/drivers/mssql/mssql_forge.php +++ b/system/database/drivers/mssql/mssql_forge.php @@ -67,6 +67,7 @@ class CI_DB_mssql_forge extends CI_DB_forge { else { $attributes = array_change_key_case($attributes, CASE_UPPER); + $attributes['TYPE'] = preg_replace('/(INT)\(\d+\)/i', '$1', $attributes['TYPE']); $sql .= "\n\t".$this->db->escape_identifiers($field).' '.$attributes['TYPE']; diff --git a/system/database/drivers/sqlsrv/sqlsrv_forge.php b/system/database/drivers/sqlsrv/sqlsrv_forge.php index 1529b2a21..bd107476e 100644 --- a/system/database/drivers/sqlsrv/sqlsrv_forge.php +++ b/system/database/drivers/sqlsrv/sqlsrv_forge.php @@ -67,6 +67,7 @@ class CI_DB_sqlsrv_forge extends CI_DB_forge { else { $attributes = array_change_key_case($attributes, CASE_UPPER); + $attributes['TYPE'] = preg_replace('/(INT)\(\d+\)/i', '$1', $attributes['TYPE']); $sql .= "\n\t".$this->db->escape_identifiers($field).' '.$attributes['TYPE']; diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst index a7bf6fa6e..942a52cdf 100644 --- a/user_guide_src/source/changelog.rst +++ b/user_guide_src/source/changelog.rst @@ -172,7 +172,7 @@ Bug fixes for 3.0 - Fixed a bug (#797) - timespan() was using incorrect seconds for year and month. - Fixed a bug in CI_Cart::contents() where if called without a TRUE (or equal) parameter, it would fail due to a typo. - Fixed a bug (#696) - make oci_execute() calls inside num_rows() non-committing, since they are only there to reset which row is next in line for oci_fetch calls and thus don't need to be committed. -- Fixed a bug (#406) - sqlsrv DB driver not returning resource on ``db_pconnect()``. +- Fixed a bug (#406) - SQLSRV DB driver not returning resource on ``db_pconnect()``. - Fixed a bug in CI_Image_lib::gd_loaded() where it was possible for the script execution to end or a PHP E_WARNING message to be emitted. - Fixed a bug in the :doc:`Pagination library ` where when use_page_numbers=TRUE previous link and page 1 link did not have the same url. - Fixed a bug (#561) - Errors in :doc:`XML-RPC Library ` were not properly escaped. @@ -230,7 +230,7 @@ Bug fixes for 3.0 - Fixed a bug (#121) - ``CI_DB_result::row()`` returned an array when there's no actual result to be returned. - Fixed a bug (#319) - SQLSRV's affected_rows() method failed due to a scrollable cursor being created for write-type queries. - Fixed a bug (#356) - PostgreSQL driver didn't have an _update_batch() method, which resulted in fatal error being triggered when update_batch() is used with it. -- Fixed a bug (#862) - create_table() failed on SQLSRV/MSSQL when used with 'IF NOT EXISTS'. +- Fixed a bug (#784, #862) - create_table() failed on SQLSRV/MSSQL when used with 'IF NOT EXISTS'. - Fixed a bug (#1419) - libraries/Driver.php had a static variable that was causing an error. - Fixed a bug (#1411) - the :doc:`Email library ` used its own short list of MIMEs instead the one from config/mimes.php. - Fixed a bug where the magic_quotes_runtime setting wasn't turned off for PHP 5.3 (where it is indeed deprecated, but not non-existent). -- cgit v1.2.3-24-g4f1b From af4d55da04b8d8750b59e04e46463d525237b74b Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Thu, 7 Jun 2012 16:22:35 +0300 Subject: Fix issue #861 (and previous commit, for that matter) --- system/database/drivers/mssql/mssql_forge.php | 3 +-- system/database/drivers/sqlsrv/sqlsrv_forge.php | 3 +-- user_guide_src/source/changelog.rst | 3 ++- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/system/database/drivers/mssql/mssql_forge.php b/system/database/drivers/mssql/mssql_forge.php index 5454e37b3..e6227e189 100644 --- a/system/database/drivers/mssql/mssql_forge.php +++ b/system/database/drivers/mssql/mssql_forge.php @@ -67,11 +67,10 @@ class CI_DB_mssql_forge extends CI_DB_forge { else { $attributes = array_change_key_case($attributes, CASE_UPPER); - $attributes['TYPE'] = preg_replace('/(INT)\(\d+\)/i', '$1', $attributes['TYPE']); $sql .= "\n\t".$this->db->escape_identifiers($field).' '.$attributes['TYPE']; - if (array_key_exists('CONSTRAINT', $attributes)) + if (stripos($attributes['TYPE'], 'INT') === FALSE && ! empty($attributes['CONSTRAINT'])) { $sql .= '('.$attributes['CONSTRAINT'].')'; } diff --git a/system/database/drivers/sqlsrv/sqlsrv_forge.php b/system/database/drivers/sqlsrv/sqlsrv_forge.php index bd107476e..d8b5193fa 100644 --- a/system/database/drivers/sqlsrv/sqlsrv_forge.php +++ b/system/database/drivers/sqlsrv/sqlsrv_forge.php @@ -67,11 +67,10 @@ class CI_DB_sqlsrv_forge extends CI_DB_forge { else { $attributes = array_change_key_case($attributes, CASE_UPPER); - $attributes['TYPE'] = preg_replace('/(INT)\(\d+\)/i', '$1', $attributes['TYPE']); $sql .= "\n\t".$this->db->escape_identifiers($field).' '.$attributes['TYPE']; - if (array_key_exists('CONSTRAINT', $attributes)) + if (stripos($attributes['TYPE'], 'INT') === FALSE && ! empty($attributes['CONSTRAINT'])) { $sql .= '('.$attributes['CONSTRAINT'].')'; } diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst index 942a52cdf..801f0e481 100644 --- a/user_guide_src/source/changelog.rst +++ b/user_guide_src/source/changelog.rst @@ -230,11 +230,12 @@ Bug fixes for 3.0 - Fixed a bug (#121) - ``CI_DB_result::row()`` returned an array when there's no actual result to be returned. - Fixed a bug (#319) - SQLSRV's affected_rows() method failed due to a scrollable cursor being created for write-type queries. - Fixed a bug (#356) - PostgreSQL driver didn't have an _update_batch() method, which resulted in fatal error being triggered when update_batch() is used with it. -- Fixed a bug (#784, #862) - create_table() failed on SQLSRV/MSSQL when used with 'IF NOT EXISTS'. +- Fixed a bug (#784, #862) - :doc:`Database Forge ` method ``create_table()`` failed on SQLSRV/MSSQL when used with 'IF NOT EXISTS'. - Fixed a bug (#1419) - libraries/Driver.php had a static variable that was causing an error. - Fixed a bug (#1411) - the :doc:`Email library ` used its own short list of MIMEs instead the one from config/mimes.php. - Fixed a bug where the magic_quotes_runtime setting wasn't turned off for PHP 5.3 (where it is indeed deprecated, but not non-existent). - Fixed a bug (#666) - :doc:`Output library `'s set_content_type() method didn't set the document charset. +- Fixed a bug (#784, #861) - :doc:`Database Forge ` method ``create_table()`` used to accept constraints for MSSQL/SQLSRV integer-type columns. Version 2.1.1 ============= -- cgit v1.2.3-24-g4f1b From 8c38ae93ab6396e5d9264af90505432ad9e8112f Mon Sep 17 00:00:00 2001 From: Joffrey JAFFEUX Date: Thu, 7 Jun 2012 18:42:17 +0300 Subject: Removed UserVoice link --- readme.rst | 2 -- 1 file changed, 2 deletions(-) diff --git a/readme.rst b/readme.rst index 4707847c7..7b718febb 100644 --- a/readme.rst +++ b/readme.rst @@ -183,8 +183,6 @@ Resources - `User Guide `_ - `Community Forums `_ -- `User - Voice `_ - `Community Wiki `_ - `Community IRC `_ -- cgit v1.2.3-24-g4f1b