To return an array of all POST items call without any parameters.
-
To return all POST items and pass them through the XSS filter leave the first parameter blank while setting the second parameter to boolean;
+
To return all POST items and pass them through the XSS filter set the first parameter NULL while setting the second parameter to boolean;
The function returns FALSE (boolean) if there are no items in the POST.
- $this->input->post(); // returns all POST items with XSS filter
+ $this->input->post(NULL, TRUE); // returns all POST items with XSS filter
- $this->input->post(NULL, FALSE); // returns all POST items without XSS
+ $this->input->post(); // returns all POST items without XSS filter
To return an array of all GET items call without any parameters.
-
To return all GET items and pass them through the XSS filter leave the first parameter blank while setting the second parameter to boolean;
+
To return all GET items and pass them through the XSS filter set the first parameter NULL while setting the second parameter to boolean;
The function returns FALSE (boolean) if there are no items in the GET.
- $this->input->get(); // returns all GET items with XSS filter
+ $this->input->get(NULL, TRUE); // returns all GET items with XSS filter
- $this->input->get(NULL, FALSE); // returns all GET items without XSS filtering
+ $this->input->get(); // returns all GET items without XSS filtering
If a config class was loaded first then a library with the same name is loaded, the config would be ignored.
Fixed a bug (Reactor #19) where 1) the 404_override route was being ignored in some cases, and 2) auto-loaded libraries were not available to the 404_override controller when a controller existed but the requested method did not.
Fixed a bug (Reactor #89) where MySQL export would fail if the table had hyphens or other non alphanumeric/underscore characters.
+
Fixed a bug (#200) where MySQL queries would be malformed after calling count_all() then db->get()
Version 2.0.3
--
cgit v1.2.3-24-g4f1b
From 54a8dcd55f15772acd0b2b39dd8edaa7f3bfcda8 Mon Sep 17 00:00:00 2001
From: Greg Aker
Date: Sat, 20 Aug 2011 14:41:51 -0500
Subject: Fixed a bug (#181) where a mis-spelling was in the form validation
language file.
---
system/language/english/form_validation_lang.php | 2 +-
user_guide/changelog.html | 1 +
2 files changed, 2 insertions(+), 1 deletion(-)
diff --git a/system/language/english/form_validation_lang.php b/system/language/english/form_validation_lang.php
index 3418f29ab..d1cf0399d 100644
--- a/system/language/english/form_validation_lang.php
+++ b/system/language/english/form_validation_lang.php
@@ -7,7 +7,7 @@ $lang['valid_emails'] = "The %s field must contain all valid email addresses.";
$lang['valid_url'] = "The %s field must contain a valid URL.";
$lang['valid_ip'] = "The %s field must contain a valid IP.";
$lang['min_length'] = "The %s field must be at least %s characters in length.";
-$lang['max_length'] = "The %s field can not exceed %s characters in length.";
+$lang['max_length'] = "The %s field cannot exceed %s characters in length.";
$lang['exact_length'] = "The %s field must be exactly %s characters in length.";
$lang['alpha'] = "The %s field may only contain alphabetical characters.";
$lang['alpha_numeric'] = "The %s field may only contain alpha-numeric characters.";
diff --git a/user_guide/changelog.html b/user_guide/changelog.html
index 332c258c7..3e91f47c7 100644
--- a/user_guide/changelog.html
+++ b/user_guide/changelog.html
@@ -96,6 +96,7 @@ Change Log
Fixed a bug (Reactor #19) where 1) the 404_override route was being ignored in some cases, and 2) auto-loaded libraries were not available to the 404_override controller when a controller existed but the requested method did not.
Fixed a bug (Reactor #89) where MySQL export would fail if the table had hyphens or other non alphanumeric/underscore characters.
Fixed a bug (#200) where MySQL queries would be malformed after calling count_all() then db->get()
+
Fixed a bug (#181) where a mis-spelling was in the form validation language file.
If a config class was loaded first then a library with the same name is loaded, the config would be ignored.
Fixed a bug (Reactor #19) where 1) the 404_override route was being ignored in some cases, and 2) auto-loaded libraries were not available to the 404_override controller when a controller existed but the requested method did not.
Fixed a bug (Reactor #89) where MySQL export would fail if the table had hyphens or other non alphanumeric/underscore characters.
+
Resolved issue 65 - made action on form_open_multipart helper function call optional
If a config class was loaded first then a library with the same name is loaded, the config would be ignored.
Fixed a bug (Reactor #19) where 1) the 404_override route was being ignored in some cases, and 2) auto-loaded libraries were not available to the 404_override controller when a controller existed but the requested method did not.
Fixed a bug (Reactor #89) where MySQL export would fail if the table had hyphens or other non alphanumeric/underscore characters.
+
Resolved issue 160. Removed unneeded array copy.
Version 2.0.3
--
cgit v1.2.3-24-g4f1b
From 9bcc40451f76737f787a3f7afc0fdab4842c9305 Mon Sep 17 00:00:00 2001
From: Greg Aker
Date: Sat, 20 Aug 2011 22:11:00 -0500
Subject: Small tweak to the changlog item from the previous commit
---
user_guide/changelog.html | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/user_guide/changelog.html b/user_guide/changelog.html
index 3e66deaf8..2e4727d4a 100644
--- a/user_guide/changelog.html
+++ b/user_guide/changelog.html
@@ -97,7 +97,7 @@ Change Log
Fixed a bug (Reactor #89) where MySQL export would fail if the table had hyphens or other non alphanumeric/underscore characters.
Fixed a bug (#200) where MySQL queries would be malformed after calling count_all() then db->get()
Fixed a bug (#181) where a mis-spelling was in the form validation language file.
-
Resolved issue 160. Removed unneeded array copy.
+
Fixed a bug (#160). Removed unneeded array copy in the file cache driver.
Version 2.0.3
--
cgit v1.2.3-24-g4f1b
From ea4ad9b4e7ab7824da4274e30075fd36a6bf9952 Mon Sep 17 00:00:00 2001
From: Nithin
Date: Sun, 21 Aug 2011 01:23:47 -0300
Subject: Added ability to _like paramater side to use 'none', in case one
wants to query like instead of where without case being sensitive
---
system/database/DB_active_rec.php | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/system/database/DB_active_rec.php b/system/database/DB_active_rec.php
index 7bab729f5..841ede28e 100644
--- a/system/database/DB_active_rec.php
+++ b/system/database/DB_active_rec.php
@@ -660,8 +660,12 @@ class CI_DB_active_record extends CI_DB_driver {
$prefix = (count($this->ar_like) == 0) ? '' : $type;
$v = $this->escape_like_str($v);
-
- if ($side == 'before')
+
+ if ($side == 'none')
+ {
+ $like_statement = $prefix." $k $not LIKE '{$v}'";
+ }
+ elseif ($side == 'before')
{
$like_statement = $prefix." $k $not LIKE '%{$v}'";
}
--
cgit v1.2.3-24-g4f1b
From cb07a322bee5c5b0a551ab959c7475a1a702ad03 Mon Sep 17 00:00:00 2001
From: Michael Dennis
Date: Sat, 20 Aug 2011 23:40:59 -0700
Subject: Fix for the Image_lib clear() function so that it resets all
variables to their default values.
This should fix issues #157 and #174.
https://github.com/EllisLab/CodeIgniter/issues/157
https://github.com/EllisLab/CodeIgniter/issues/174
---
system/libraries/Image_lib.php | 28 +++++++++++++++++++++++++---
1 file changed, 25 insertions(+), 3 deletions(-)
diff --git a/system/libraries/Image_lib.php b/system/libraries/Image_lib.php
index 8902f524d..6855e4498 100644
--- a/system/libraries/Image_lib.php
+++ b/system/libraries/Image_lib.php
@@ -104,15 +104,37 @@ class CI_Image_lib {
*/
function clear()
{
- $props = array('source_folder', 'dest_folder', 'source_image', 'full_src_path', 'full_dst_path', 'new_image', 'image_type', 'size_str', 'quality', 'orig_width', 'orig_height', 'rotation_angle', 'x_axis', 'y_axis', 'create_fnc', 'copy_fnc', 'wm_overlay_path', 'wm_use_truetype', 'dynamic_output', 'wm_font_size', 'wm_text', 'wm_vrt_alignment', 'wm_hor_alignment', 'wm_padding', 'wm_hor_offset', 'wm_vrt_offset', 'wm_font_color', 'wm_use_drop_shadow', 'wm_shadow_color', 'wm_shadow_distance', 'wm_opacity');
+ $props = array('library_path', 'source_image', 'new_image', 'width', 'height', 'rotation_angle', 'x_axis', 'y_axis', 'wm_text', 'wm_overlay_path', 'wm_font_path', 'wm_shadow_color', 'source_folder', 'dest_folder', 'mime_type', 'orig_width', 'orig_height', 'image_type', 'size_str', 'full_src_path', 'full_dst_path');
foreach ($props as $val)
{
$this->$val = '';
}
- // special consideration for master_dim
- $this->master_dim = 'auto';
+ $this->image_library = 'gd2';
+ $this->dynamic_output = FALSE;
+ $this->quality = '90';
+ $this->create_thumb = FALSE;
+ $this->thumb_marker = '_thumb';
+ $this->maintain_ratio = TRUE;
+ $this->master_dim = 'auto';
+ $this->wm_type = 'text';
+ $this->wm_x_transp = 4;
+ $this->wm_y_transp = 4;
+ $this->wm_font_size = 17;
+ $this->wm_vrt_alignment = 'B';
+ $this->wm_hor_alignment = 'C';
+ $this->wm_padding = 0;
+ $this->wm_hor_offset = 0;
+ $this->wm_vrt_offset = 0;
+ $this->wm_font_color = '#ffffff';
+ $this->wm_shadow_distance = 2;
+ $this->wm_opacity = 50;
+ $this->create_fnc = 'imagecreatetruecolor';
+ $this->copy_fnc = 'imagecopyresampled';
+ $this->error_msg = array();
+ $this->wm_use_drop_shadow = FALSE;
+ $this->wm_use_truetype = FALSE;
}
// --------------------------------------------------------------------
--
cgit v1.2.3-24-g4f1b
From 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'
+
+
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:
--
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'.
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 2e0f825c942e7e77a9aba451f3252762db0c86f5 Mon Sep 17 00:00:00 2001
From: Greg Aker
Date: Sun, 21 Aug 2011 16:19:16 -0500
Subject: Fixing errors in date helper tests.
---
tests/codeigniter/helpers/date_helper_test.php | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/tests/codeigniter/helpers/date_helper_test.php b/tests/codeigniter/helpers/date_helper_test.php
index 63cf30bbe..c7a2c9b6e 100644
--- a/tests/codeigniter/helpers/date_helper_test.php
+++ b/tests/codeigniter/helpers/date_helper_test.php
@@ -158,7 +158,9 @@ class Date_helper_test extends CI_TestCase
public function test_mysql_to_unix()
{
- $this->assertEquals(1344708680, mysql_to_unix(date("YYYY-MM-DD HH:MM:SS")));
+ $time = time();
+ $this->assertEquals($time,
+ mysql_to_unix(date("Y-m-d H:i:s", $time)));
}
// ------------------------------------------------------------------------
@@ -166,9 +168,9 @@ class Date_helper_test extends CI_TestCase
public function test_unix_to_human()
{
$time = time();
- $this->assertEquals(date("Y-m-d h:i A"), unix_to_human($time));
- $this->assertEquals(date("Y-m-d h:i:s A"), unix_to_human($time, TRUE, 'us'));
- $this->assertEquals(date("Y-m-d H:i:s"), unix_to_human($time, TRUE, 'eu'));
+ $this->assertEquals(date("Y-m-d h:i A", $time), unix_to_human($time));
+ $this->assertEquals(date("Y-m-d h:i:s A", $time), unix_to_human($time, TRUE, 'us'));
+ $this->assertEquals(date("Y-m-d H:i:s", $time), unix_to_human($time, TRUE, 'eu'));
}
// ------------------------------------------------------------------------
--
cgit v1.2.3-24-g4f1b
From d031ef79248bef6e188b6726682aac12b2fb8ff6 Mon Sep 17 00:00:00 2001
From: Greg Aker
Date: Sun, 21 Aug 2011 16:19:56 -0500
Subject: ignoring a test in the inflector test.
---
tests/codeigniter/helpers/inflector_helper_test.php | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/tests/codeigniter/helpers/inflector_helper_test.php b/tests/codeigniter/helpers/inflector_helper_test.php
index 34bc34ebb..ef1f54afc 100644
--- a/tests/codeigniter/helpers/inflector_helper_test.php
+++ b/tests/codeigniter/helpers/inflector_helper_test.php
@@ -24,6 +24,10 @@ class Inflector_helper_test extends CI_TestCase {
public function test_plural()
{
+ $this->markTestSkipped(
+ 'abjectness is breaking. SKipping for the time being.'
+ );
+
$strs = array(
'telly' => 'tellies',
'smelly' => 'smellies',
--
cgit v1.2.3-24-g4f1b
From 2c4b36620828173f3caf83fc7f6146bccb3688f4 Mon Sep 17 00:00:00 2001
From: Greg Aker
Date: Sun, 21 Aug 2011 16:28:06 -0500
Subject: Adding url_helper unit test file. GO!
---
tests/codeigniter/helpers/url_helper_test.php | 22 ++++++++++++++++++++++
1 file changed, 22 insertions(+)
create mode 100644 tests/codeigniter/helpers/url_helper_test.php
diff --git a/tests/codeigniter/helpers/url_helper_test.php b/tests/codeigniter/helpers/url_helper_test.php
new file mode 100644
index 000000000..ea3fb0e4f
--- /dev/null
+++ b/tests/codeigniter/helpers/url_helper_test.php
@@ -0,0 +1,22 @@
+ 'foo-bar',
+ '\ testing 12' => 'testing-12'
+ );
+
+ foreach ($words as $in => $out)
+ {
+ $this->assertEquals($out, url_title($in, 'dash', TRUE));
+ }
+ }
+
+ // --------------------------------------------------------------------
+
+}
\ No newline at end of file
--
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:
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 a2457b022778a1000f753f799e3527fadc93d207 Mon Sep 17 00:00:00 2001
From: Joël Cox
Date: Mon, 22 Aug 2011 22:29:06 +0200
Subject: Cleanly applied patch of the user guide tutorial by Kenny and me.
---
user_guide/nav/nav.js | 11 +-
user_guide/toc.html | 8 +
user_guide/tutorial/conclusion.html | 91 +++++++++++
user_guide/tutorial/create_news_items.html | 181 +++++++++++++++++++++
user_guide/tutorial/hard_coded_pages.html | 159 +++++++++++++++++++
user_guide/tutorial/introduction.html | 92 +++++++++++
user_guide/tutorial/news_section.html | 242 +++++++++++++++++++++++++++++
user_guide/tutorial/static_pages.html | 206 ++++++++++++++++++++++++
8 files changed, 989 insertions(+), 1 deletion(-)
create mode 100644 user_guide/tutorial/conclusion.html
create mode 100644 user_guide/tutorial/create_news_items.html
create mode 100644 user_guide/tutorial/hard_coded_pages.html
create mode 100644 user_guide/tutorial/introduction.html
create mode 100644 user_guide/tutorial/news_section.html
create mode 100644 user_guide/tutorial/static_pages.html
diff --git a/user_guide/nav/nav.js b/user_guide/nav/nav.js
index b44994d4d..b57851a6c 100644
--- a/user_guide/nav/nav.js
+++ b/user_guide/nav/nav.js
@@ -37,7 +37,16 @@ function create_menu(basepath)
'
This tutorial did not cover all of the things you might expect of a full-fledged content management system, but it introduced you to the more important topics of routing, writing controllers, and models. We hope this tutorial gave you an insight into some of CodeIgniter's basic design patterns, which you can expand upon.
+
+
Now that you've completed this tutorial, we recommend you check out the rest of the documentation. CodeIgniter is often praised because of its comprehensive documentation. Use this to your advantage and read the "Introduction" and "General Topics" sections thoroughly. You should read the class and helper references when needed.
+
+
Every intermediate PHP programmer should be able to get the hang of CodeIgniter within a few days.
+
+
If you still have questions about the framework or your own CodeIgniter code, you can:
You now know how you can read data from a database using CodeIgnite, but you haven't written any information to the database yet. In this section you'll expand your news controller and model created earlier to include this functionality.
+
+
Create a form
+
+
To input data into the database you need to create a form where you can input the information to be stored. This means you'll be needing a form with two fields, one for the title and one for the text. You'll derive the slug from our title in the model. Create the new view at application/views/news/create.php.
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/user_guide/tutorial/hard_coded_pages.html b/user_guide/tutorial/hard_coded_pages.html
new file mode 100644
index 000000000..6201ed081
--- /dev/null
+++ b/user_guide/tutorial/hard_coded_pages.html
@@ -0,0 +1,159 @@
+
+
+
+
+
+CodeIgniter Features : CodeIgniter User Guide
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
The first thing we're going to do is setting up a controller to handle our hard coded pages. A controller is a class with a collection of methods that represent the different actions you can perform on a certain object. In our case, we want to be able to view a page.
+
+
Note: This tutorial assumes you've downloaded CodeIgniter and installed the framework in your development environment.
+
+
Create a file at application/controllers/pages.php with the following code.
If you're familiar with PHP classes you see that we create a Pages class with a view method that accepts one parameter, $page. Another interesting observation is that the Pages class is extending the CI_Controller class. This means that the new Pages class can access the methods and variables defined in the CI_Controller class. When you look at this class in system/core/controller.php you can see this class is doing something really important; assigning an instance from the CodeIgniter super object to the $this object. In most of your code, $this is the object you will use to interact with the framework.
+
+
Now we've created our first method, it is time to do some basic templating. For this tutorial, we will be creating two views to acts as our footer and header. Let's create our header at application/views/templates/header.php and ad the following code.
+
+
+
+
+ - CodeIgniter 2 Tutorial
+
+
+
CodeIgniter 2 Tutorial
+
+
+
+
Our header doesn't do anything exciting. It contains the basic HTML code that we will want to display before loading the main view. You can also see that we echo the $title variable, which we didn't define. We will set this variable in the Pages controller a bit later. Let's go ahead and create a footer at application/views/templates/footer.php that includes the following code.
Now we've set up the basics so we can finally do some real programming. Earlier we set up our controller with a view method. Because we don't want to write a separate method for every page, we made the view method accept one parameter, the name of the page. These hard coded pages will be located in application/views/pages/. Create two files in this directory named home.php and about.php and put in some HTML content.
+
+
In order to load these pages we'll have to check whether these page actually exists. When the page does exist, we load the view for that pages, including the header and footer and display it to the user. If it doesn't, we show a "404 Page not found" error.
The first thing we do is checking whether the page we're looking for does actually exist. We use PHP's native file_exists() to do this check and pass the path where the file is supposed to be. Next is the function show_404(), a CodeIgniter function that renders the default error page and sets the appropriate HTTP headers.
+
+
In the header template you saw we were using the $title variable to customize our page title. This is where we define the title, but instead of assigning the value to a variable, we assign it to the title element in the $data array. The last thing we need to do is loading the views in the order we want them to be displayed. We also pass the $data array to the header view to make its elements available in the header view file.
+
+
Routing
+
+
Actually, our controller is already functioning. Point your browser to index.php/pages/view to see your homepage. When you visit index.php/pages/view/about you will see the about page, again including your header and footer. Now we're going to get rid of the pages/view part in our URI. As you may have seen, CodeIgniter does its routing by the class, method and parameter, separated by slashes.
+
+
Open the routing file located at application/config/routes.php and add the following two lines. Remove all other code that sets any element in the $route array.
CodeIgniter reads its routing rules from top to bottom and routes the request to the first matching rule. These routes are stored in the $route array where the keys represent the incoming request and the value the path to the method, as described above.
+
+
The first rule in our $routes array matches every request - using the wildcard operator (:any) - and passes the value to the view method of the pages class we created earlier. The default controller route makes sure every request to the root goes to the view method as well, which has the first parameter set to 'home' by default.
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/user_guide/tutorial/introduction.html b/user_guide/tutorial/introduction.html
new file mode 100644
index 000000000..cb91f4856
--- /dev/null
+++ b/user_guide/tutorial/introduction.html
@@ -0,0 +1,92 @@
+
+
+
+
+
+CodeIgniter Features : CodeIgniter User Guide
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
This tutorial is intended to introduce you to the CodeIgniter framework and the basic principles of MVC architecture.
+ It will show you how a basic CodeIgniter application is constructed in step-by-step fashion.
+
+
+
In this tutorial, you will be creating a basic news application. You will begin by writing the code that can load static pages. Next, you will create a news section that reads news items from a database. Finally, you'll add a form to create news items in the database.
+
+
This tutorial will primarily focus on:
+
+
Model-View-Controller basics
+
Routing basics
+
Form validation
+
Performing basic database queries using "Active Record"
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/user_guide/tutorial/news_section.html b/user_guide/tutorial/news_section.html
new file mode 100644
index 000000000..d0f64e0c9
--- /dev/null
+++ b/user_guide/tutorial/news_section.html
@@ -0,0 +1,242 @@
+
+
+
+
+
+CodeIgniter Features : CodeIgniter User Guide
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
In the last section, we went over some basic concepts of the framework by writing a class that includes static pages. We cleaned up the URI by adding custom routing rules. Now it's time to introduce dynamic content and start using a database.
+
+
Setting up your model
+
+
Instead of writing database operations right in the controller, queries should be placed in a model, so they can easily be reused later. Models are the place where you retrieve, insert, and update information in your database or other data stores. They represent your data.
+
+
Open up the application/models directory and create a new file called news_model.php and add the following code. Make sure you've configured your database properly as described here.
This code looks similar to the controller code that was used earlier. It creates a new model by extending CI_Model and loads the database library. This will make the database class available through the $this->db object.
+
+
Before querying the database, a database schema has to be created. Connect to your database and run the SQL command below. Also add some seed records.
+
+
+CREATE TABLE news (
+ id int(11) NOT NULL AUTO_INCREMENT,
+ title varchar(128) NOT NULL,
+ slug varchar(128) NOT NULL,
+ text text NOT NULL,
+ PRIMARY KEY (id),
+ KEY slug (slug)
+);
+
+
+
Now that the database and a model have been set up, you'll need a method to get all of our posts from our database. To do this, the database abstraction layer that is included with CodeIgniter — ActiveRecord — is used. This makes it possible to write your 'queries' once and make them work on all supported database systems. Add the following code to your model.
With this code you can perform two different queries. You can get all news records, or get a news item by its slug. You might have noticed that the $slug variable wasn't sanitized before running the query; Active Record does this for you.
+
+
Display the news
+
+
Now that the queries are written, the model should be tied to the views that are going to display the news items to the user. This could be done in our pages controller created earlier, but for the sake of clarity, a new "news" controller is defined. Create the new controller at application/controllers/news.php.
Looking at the code, you may see some similarity with the files we created earlier. First, the "__construct" method: it calls the constructor of its parent class (CI_Controller) and loads the model, so it can be used in all other methods in this controller.
+
+
Next, there are two methods to view all news items and one for a specific news item. You can see that the $slug variable is passed to the model's method in the second method. The model is using this slug to identify the news item to be returned.
+
+
Now the data is retrieved by the controller through our model, but nothing is displayed yet. The next thing to do is passing this data to the views.
The code above gets all news records from the model and assigns it to a variable. The value for the title is also assigned to the $data['title'] element and all data is passed to the views. You now need to create a view to render the news items. Create application/views/news/index.php and add the next piece of code.
Here, each news item is looped and displayed to the user. You can see we wrote our template in PHP mixed with HTML. If you prefer to use a template language, you can use CodeIgniter's Template Parser class or a third party parser.
+
+
The news overview page is now done, but a page to display individual news items is still absent. The model created earlier is made in such way that it can easily be used for this functionality. You only need to add some code to the controller and create a new view. Go back to the news controller and add the following lines to the file.
Instead of calling the get_news() method without a parameter, the $slug variable is passed, so it will return the specific news item. The only things left to do is create the corresponding view at application/views/news/view.php. Put the following code in this file.
Because of the wildcard routing rule created earlier, you need need an extra route to view the controller that you just made. Modify your routing file (application/config/routes.php) so it looks as follows. This makes sure the requests reaches the news controller instead of going directly to the pages controller. The first line routes URI's with a slug to the view method in the news controller.
Note: This tutorial assumes you've downloaded CodeIgniter and installed the framework in your development environment.
+
+
The first thing you're going to do is set up a controller to handle static pages.
+A controller is simply a class that helps delegate work. It is the glue of your
+web application.
+
+
For example, when a call is made to: http://example.com/news/latest/10 We might imagine
+that there is a controller named "news". The method being called on news
+would be "latest". The news method's job could be to grab 10
+news items, and render them on the page. Very often in MVC, you'll see URL
+patterns that match: http://example.com/[controller-class]/[controller-method]/[arguments]
+As URL schemes become more complex, this may change. But for now, this is all we will need to know.
+
+
Create a file at application/controllers/pages.php with the following code.
You have created a class named "pages", with a view method that accepts one argument named $page.
+The pages class is extending the CI_Controller class.
+This means that the new pages class can access the methods and variables defined in the CI_Controller class
+(system/core/Controller.php).
+
+
The controller is what will become the center of every request to your web application.
+In very technical CodeIgniter discussions, it may be referred to as the super object.
+Like any php class, you refer to it within your controllers as $this.
+Referring to $this is how you will load libraries, views, and generally
+command the framework.
+
+
Now you've created your first method, it's time to make some basic page templates.
+We will be creating two "views" (page templates) that act as our page footer and header.
+
+
Create the header at application/views/templates/header.php and add the following code.
+
+
+
+
+ - CodeIgniter 2 Tutorial
+
+
+
CodeIgniter 2 Tutorial
+
+
+
+
The header contains the basic HTML code that you'll want to display before loading the main view, together with a heading.
+It will also output the $title variable, which we'll define later in the controller.
+Now create a footer at application/views/templates/footer.php that includes the following code:
Earlier you set up a controller with a view() method. The method accepts one parameter, which is the name of the page to be loaded.
+The static page templates will be located in the application/views/pages/ directory.
+
+
In that directory, create two files named home.php and about.php.
+Within those files, type some text − anything you'd like − and save them.
+If you like to be particularly un-original, try "Hello World!".
+
+
In order to load those pages, you'll have to check whether the requested page actually exists:
+
+
+function view($page = 'home')
+{
+
+ if ( ! file_exists('application/views/pages/' . $page . EXT))
+ {
+ // Whoops, we don't have a page for that!
+ show_404();
+ }
+
+ $data['title'] = ucfirst($page); // Capitalize the first letter
+
+ $this->load->view('templates/header', $data);
+ $this->load->view('pages/' . $page, $data);
+ $this->load->view('templates/footer', $data);
+
+}
+
+
+
Now, when the page does exist, it is loaded, including the header and footer, and displayed to the user. If the page doesn't exist, a "404 Page not found" error is shown.
+
+
The first line in this method checks whether the page actually exists. PHP's native file_exists() function is used to check whether the file is where it's expected to be. show_404() is a built-in CodeIgniter function that renders the default error page.
+
+
In the header template, the $title variable was used to customize the page title. The value of title is defined in this method, but instead of assigning the value to a variable, it is assigned to the title element in the $data array.
+
+
The last thing that has to be done is loading the views in the order they should be displayed.
+The second parameter in the view() method is used to pass values to the view. Each value in the $data array is assigned to a variable with the name of its key. So the value of $data['title'] in the controller is equivalent to $title in the view.
+
+
Routing
+
+
The controller is now functioning! Point your browser to [your-site-url]index.php/pages/view to see your page. When you visit index.php/pages/view/about you'll see the about page, again including the header and footer.
+
+
Using custom routing rules, you have the power to map any URI to any controller and method, and break free from the normal convention:
+http://example.com/[controller-class]/[controller-method]/[arguments]
+
+
Let's do that. Open the routing file located at application/config/routes.php and add the following two lines. Remove all other code that sets any element in the $route array.
CodeIgniter reads its routing rules from top to bottom and routes the request to the first matching rule. Each rule is a regular expression
+(left-side) mapped to a controller and method name separated by slashes (right-side).
+When a request comes in, CodeIgniter looks for the first match, and calls the appropriate controller and method, possibly with arguments.
+
+
More information about routing can be found in the URI Routing documentation.
+
+
Here, the second rule in the $routes array matches any request using the wildcard string (:any).
+and passes the parameter to the view() method of the pages class.
+
+
Now visit index.php/about. Did it get routed correctly to the view() method
+in the pages controller? Awesome!
+
+
+
+
+
+
+
+
+
\ No newline at end of file
--
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.
There are only two things here that probably look unfamiliar to you: the form_open() function and the validation_errors() function.
-
The first function is provided by the form helper and renders the form element and adds extra functionality, like adding a hidden CSFR prevention field. The latter is used to report errors related to from validation.
+
The first function is provided by the form helper and renders the form element and adds extra functionality, like adding a hidden CSFR prevention field. The latter is used to report errors related to form validation.
Go back to your news controller. You're going to do two things here, check whether the form was submitted and whether the submitted data passed the validation rules. You'll use the form validation library to do this.
@@ -150,7 +150,7 @@ function set_news()
Routing
-
Before you can start adding news items into your CodeIgniter application you have to add an extra rule to config/routes.php file. Make sure your file contains the following. This makes sure CodeIgniter sees 'update' as a method instead of a news item's slug.
+
Before you can start adding news items into your CodeIgniter application you have to add an extra rule to config/routes.php file. Make sure your file contains the following. This makes sure CodeIgniter sees 'create' as a method instead of a news item's slug.
This tutorial is intended to introduce you to the CodeIgniter framework and the basic principles of MVC architecture.
- It will show you how a basic CodeIgniter application is constructed in step-by-step fashion.
-
+
This tutorial is intended to introduce you to the CodeIgniter framework and the basic principles of MVC architecture. It will show you how a basic CodeIgniter application is constructed in step-by-step fashion.
In this tutorial, you will be creating a basic news application. You will begin by writing the code that can load static pages. Next, you will create a news section that reads news items from a database. Finally, you'll add a form to create news items in the database.
@@ -73,6 +71,17 @@ Introduction
Performing basic database queries using "Active Record"
+
The entire tutorial is split up over several pages, each explaining a small part of the functionality of the CodeIgniter framework. You'll go through the following pages:
+
+
Introduction, this page, which gives you an overview of what to expect.
+
Static pages, which will teach you the basics of controllers, views and routing.
+
News section, where you'll start using models and will be doing some basic database operations.
+
Create news items, which will introduce more advanced database operations and form validation.
+
Conclusion, which will give you some pointers on further reading and other resources.
+
+
+
Enjoy your exploration of the CodeIgniter framework.
Now that the database and a model have been set up, you'll need a method to get all of our posts from our database. To do this, the database abstraction layer that is included with CodeIgniter — ActiveRecord — is used. This makes it possible to write your 'queries' once and make them work on all supported database systems. Add the following code to your model.
+
Now that the database and a model have been set up, you'll need a method to get all of our posts from our database. To do this, the database abstraction layer that is included with CodeIgniter — Active Record — is used. This makes it possible to write your 'queries' once and make them work on all supported database systems. Add the following code to your model.
function get_news($slug = FALSE)
diff --git a/user_guide/tutorial/static_pages.html b/user_guide/tutorial/static_pages.html
index 69e5b7446..d5eec43da 100644
--- a/user_guide/tutorial/static_pages.html
+++ b/user_guide/tutorial/static_pages.html
@@ -28,7 +28,7 @@
This function prevents inserting null characters between ascii characters, like Java\0script.
+
html_escape($mixed)
+
This function provides short cut for htmlspecialchars() function. It accepts string and array. To prevent Cross Site Scripting (XSS), it is very useful.
--
cgit v1.2.3-24-g4f1b
From 7addbc4c528199b533aa69afdf2187990d69484a Mon Sep 17 00:00:00 2001
From: Eric Barnes
Date: Wed, 24 Aug 2011 23:46:20 -0400
Subject: Added user voice link to readme
---
readme.md | 1 +
1 file changed, 1 insertion(+)
diff --git a/readme.md b/readme.md
index dfcf856f2..be807dbea 100644
--- a/readme.md
+++ b/readme.md
@@ -6,5 +6,6 @@ CodeIgniter is an Application Development Framework - a toolkit - for people who
* [User Guide](http://codeigniter.com/user_guide/)
* [Community Forums](http://codeigniter.com/forums/)
+ * [User Voice](http://codeigniter.uservoice.com/forums/40508-codeigniter-reactor)
* [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 373043fef2723d7cbdd768d1930363ac6fecba68 Mon Sep 17 00:00:00 2001
From: Frank Michel
Date: Thu, 25 Aug 2011 00:11:00 -0400
Subject: fix for issue #292 with multiple language files
---
system/core/Lang.php | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/system/core/Lang.php b/system/core/Lang.php
index 5ac671838..e140a6a60 100755
--- a/system/core/Lang.php
+++ b/system/core/Lang.php
@@ -112,7 +112,7 @@ class CI_Lang {
}
- if ( ! isset($lang))
+ if ( ! isset($lang) || ! is_array($lang))
{
log_message('error', 'Language file contains no data: language/'.$idiom.'/'.$langfile);
return;
@@ -124,7 +124,7 @@ class CI_Lang {
}
$this->is_loaded[] = $langfile;
- $this->language = array_merge($this->language, $lang);
+ $this->language = $this->language + $lang;
unset($lang);
log_message('debug', 'Language file loaded: language/'.$idiom.'/'.$langfile);
--
cgit v1.2.3-24-g4f1b
From cb272b60e55882246677db929bc2e0a58f31397d Mon Sep 17 00:00:00 2001
From: Frank Michel
Date: Thu, 25 Aug 2011 10:59:55 -0400
Subject: fixed logical operator OR in core/lang
---
system/core/Lang.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/system/core/Lang.php b/system/core/Lang.php
index e140a6a60..d61d1029a 100755
--- a/system/core/Lang.php
+++ b/system/core/Lang.php
@@ -112,7 +112,7 @@ class CI_Lang {
}
- if ( ! isset($lang) || ! is_array($lang))
+ if ( ! isset($lang) OR ! is_array($lang))
{
log_message('error', 'Language file contains no data: language/'.$idiom.'/'.$langfile);
return;
--
cgit v1.2.3-24-g4f1b
From e716f585d5ffb5ef65279734672a39c1ecddac1e Mon Sep 17 00:00:00 2001
From: purandi
Date: Thu, 25 Aug 2011 22:32:01 +0700
Subject: Fix hiperlink Added html_escape() 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 e1a134def..d7a6c7e05 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.
Changed private functions in CI_URI to protected so MY_URI can override them.
--
cgit v1.2.3-24-g4f1b
From 0c147b365a8bb2e584d4f957d4d0761f02bebe56 Mon Sep 17 00:00:00 2001
From: Kyle Farris
Date: Fri, 26 Aug 2011 02:29:31 -0400
Subject: Added get_compiled_select(), get_compiled_insert(),
get_compiled_update(), get_compiled_delete(), and reset_query() methods. to
the Active Record class.
---
system/database/DB_active_rec.php | 257 +++++++++++++++++++++++++++++++++-----
1 file changed, 223 insertions(+), 34 deletions(-)
diff --git a/system/database/DB_active_rec.php b/system/database/DB_active_rec.php
index 37d162bc1..8c801cd62 100644
--- a/system/database/DB_active_rec.php
+++ b/system/database/DB_active_rec.php
@@ -28,6 +28,9 @@
*/
class CI_DB_active_record extends CI_DB_driver {
+ private $return_delete_sql = FALSE;
+ private $reset_delete_data = FALSE;
+
var $ar_select = array();
var $ar_distinct = FALSE;
var $ar_from = array();
@@ -196,7 +199,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 '.$this->_protect_identifiers(trim($alias));
+ $sql = $type.'('.$this->_protect_identifiers(trim($select)).') AS '.$alias;
$this->ar_select[] = $sql;
@@ -660,12 +663,8 @@ class CI_DB_active_record extends CI_DB_driver {
$prefix = (count($this->ar_like) == 0) ? '' : $type;
$v = $this->escape_like_str($v);
-
- if ($side == 'none')
- {
- $like_statement = $prefix." $k $not LIKE '{$v}'";
- }
- elseif ($side == 'before')
+
+ if ($side == 'before')
{
$like_statement = $prefix." $k $not LIKE '%{$v}'";
}
@@ -874,11 +873,11 @@ class CI_DB_active_record extends CI_DB_driver {
*/
public function limit($value, $offset = '')
{
- $this->ar_limit = (int) $value;
+ $this->ar_limit = $value;
if ($offset != '')
{
- $this->ar_offset = (int) $offset;
+ $this->ar_offset = $offset;
}
return $this;
@@ -931,6 +930,38 @@ class CI_DB_active_record extends CI_DB_driver {
return $this;
}
+
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Get SELECT query string
+ *
+ * Compiles a SELECT query string and returns the sql.
+ *
+ * @access public
+ * @param string the table name to select from (optional)
+ * @param boolean TRUE: resets AR values; FALSE: leave AR vaules alone
+ * @return string
+ */
+ public function get_compiled_select($table = '', $reset = TRUE)
+ {
+ if ($table != '')
+ {
+ $this->_track_aliases($table);
+ $this->from($table);
+ }
+
+ $select = $this->_compile_select();
+
+ if ($reset === TRUE)
+ {
+ $this->_reset_select();
+ }
+
+ return $select;
+ }
+
// --------------------------------------------------------------------
@@ -1148,6 +1179,36 @@ class CI_DB_active_record extends CI_DB_driver {
return $this;
}
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Get INSERT query string
+ *
+ * Compiles an insert query and returns the sql
+ *
+ * @access public
+ * @param string the table to insert into
+ * @param boolean TRUE: reset AR values; FALSE: leave AR values alone
+ * @return string
+ */
+ public function get_compiled_insert($table = '', $reset = TRUE)
+ {
+ if ($this->_validate_insert($table) === FALSE)
+ {
+ return FALSE;
+ }
+
+ $sql = $this->_insert($this->_protect_identifiers($this->ar_from[0], TRUE, NULL, FALSE), array_keys($this->ar_set), array_values($this->ar_set));
+
+ if ($reset === TRUE)
+ {
+ $this->_reset_write();
+ }
+
+ return $sql;
+ }
+
// --------------------------------------------------------------------
@@ -1156,17 +1217,45 @@ class CI_DB_active_record extends CI_DB_driver {
*
* Compiles an insert string and runs the query
*
+ * @access public
* @param string the table to insert data into
* @param array an associative array of insert values
* @return object
*/
- function insert($table = '', $set = NULL)
+ public function insert($table = '', $set = NULL)
{
if ( ! is_null($set))
{
$this->set($set);
}
+
+ if ($this->_validate_insert($table) === FALSE)
+ {
+ return FALSE;
+ }
+
+ $sql = $this->_insert($this->_protect_identifiers($this->ar_from[0], TRUE, NULL, FALSE), array_keys($this->ar_set), array_values($this->ar_set));
+ $this->_reset_write();
+ return $this->query($sql);
+ }
+
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Validate Insert
+ *
+ * This method is used by both insert() and get_compiled_insert() to
+ * validate that the there data is actually being set and that table
+ * has been chosen to be inserted into.
+ *
+ * @access public
+ * @param string the table to insert data into
+ * @return string
+ */
+ protected function _validate_insert($table = '')
+ {
if (count($this->ar_set) == 0)
{
if ($this->db_debug)
@@ -1186,14 +1275,13 @@ class CI_DB_active_record extends CI_DB_driver {
}
return FALSE;
}
-
- $table = $this->ar_from[0];
}
-
- $sql = $this->_insert($this->_protect_identifiers($table, TRUE, NULL, FALSE), array_keys($this->ar_set), array_values($this->ar_set));
-
- $this->_reset_write();
- return $this->query($sql);
+ else
+ {
+ $this->ar_from[0] = $table;
+ }
+
+ return TRUE;
}
// --------------------------------------------------------------------
@@ -1242,7 +1330,41 @@ class CI_DB_active_record extends CI_DB_driver {
$this->_reset_write();
return $this->query($sql);
}
+
+
+ // --------------------------------------------------------------------
+ /**
+ * Get UPDATE query string
+ *
+ * Compiles an update query and returns the sql
+ *
+ * @access public
+ * @param string the table to update
+ * @param boolean TRUE: reset AR values; FALSE: leave AR values alone
+ * @return string
+ */
+ public function get_compiled_update($table = '', $reset = TRUE)
+ {
+ // Combine any cached components with the current statements
+ $this->_merge_cache();
+
+ if ($this->_validate_update($table) === FALSE)
+ {
+ return FALSE;
+ }
+
+ $sql = $this->_update($this->_protect_identifiers($this->ar_from[0], TRUE, NULL, FALSE), $this->ar_set, $this->ar_where, $this->ar_orderby, $this->ar_limit);
+
+ if ($reset === TRUE)
+ {
+ $this->_reset_write();
+ }
+
+ return $sql;
+ }
+
+
// --------------------------------------------------------------------
/**
@@ -1265,6 +1387,43 @@ class CI_DB_active_record extends CI_DB_driver {
$this->set($set);
}
+ if ($this->_validate_update($table) === FALSE)
+ {
+ return FALSE;
+ }
+
+ if ($where != NULL)
+ {
+ $this->where($where);
+ }
+
+ if ($limit != NULL)
+ {
+ $this->limit($limit);
+ }
+
+ $sql = $this->_update($this->_protect_identifiers($this->ar_from[0], TRUE, NULL, FALSE), $this->ar_set, $this->ar_where, $this->ar_orderby, $this->ar_limit);
+
+ $this->_reset_write();
+ return $this->query($sql);
+ }
+
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Validate Update
+ *
+ * This method is used by both update() and get_compiled_update() to
+ * validate that data is actually being set and that a table has been
+ * chosen to be update.
+ *
+ * @access public
+ * @param string the table to update data on
+ * @return string
+ */
+ protected function _validate_update($table = '')
+ {
if (count($this->ar_set) == 0)
{
if ($this->db_debug)
@@ -1284,24 +1443,11 @@ class CI_DB_active_record extends CI_DB_driver {
}
return FALSE;
}
-
- $table = $this->ar_from[0];
}
-
- if ($where != NULL)
- {
- $this->where($where);
- }
-
- if ($limit != NULL)
+ else
{
- $this->limit($limit);
+ $this->ar_from[0] = $table;
}
-
- $sql = $this->_update($this->_protect_identifiers($table, TRUE, NULL, FALSE), $this->ar_set, $this->ar_where, $this->ar_orderby, $this->ar_limit);
-
- $this->_reset_write();
- return $this->query($sql);
}
@@ -1326,7 +1472,7 @@ class CI_DB_active_record extends CI_DB_driver {
{
if ($this->db_debug)
{
- return $this->display_error('db_must_use_index');
+ return $this->display_error('db_myst_use_index');
}
return FALSE;
@@ -1503,7 +1649,27 @@ class CI_DB_active_record extends CI_DB_driver {
return $this->query($sql);
}
+
+ // --------------------------------------------------------------------
+ /**
+ * Get DELETE query string
+ *
+ * Compiles a delete query string and returns the sql
+ *
+ * @access public
+ * @param string the table to delete from
+ * @param boolean TRUE: reset AR values; FALSE: leave AR values alone
+ * @return string
+ */
+ public function get_compiled_delete($table = '', $reset = TRUE)
+ {
+ $this->return_delete_sql = TRUE;
+ $sql = $this->delete($table, '', NULL, $reset);
+ $this->return_delete_sql = FALSE;
+ return $sql;
+ }
+
// --------------------------------------------------------------------
/**
@@ -1576,9 +1742,15 @@ class CI_DB_active_record extends CI_DB_driver {
{
$this->_reset_write();
}
+
+ if ($this->return_delete_sql === true)
+ {
+ return $sql;
+ }
return $this->query($sql);
}
+
// --------------------------------------------------------------------
@@ -1659,6 +1831,7 @@ class CI_DB_active_record extends CI_DB_driver {
}
}
}
+
// --------------------------------------------------------------------
@@ -1965,6 +2138,22 @@ class CI_DB_active_record extends CI_DB_driver {
$this->ar_no_escape = $this->ar_cache_no_escape;
}
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Reset Active Record values.
+ *
+ * Publicly-visible method to reset the AR values.
+ *
+ * @access public
+ * @return void
+ */
+ public function reset_query()
+ {
+ $this->_reset_select();
+ $this->_reset_write();
+ }
// --------------------------------------------------------------------
@@ -2042,4 +2231,4 @@ class CI_DB_active_record extends CI_DB_driver {
}
/* End of file DB_active_rec.php */
-/* Location: ./system/database/DB_active_rec.php */
\ No newline at end of file
+/* Location: ./system/database/DB_active_rec.php */
--
cgit v1.2.3-24-g4f1b
From 0a3176b56ad069643c400302b1baf9a2c90267ad Mon Sep 17 00:00:00 2001
From: kylefarris
Date: Fri, 26 Aug 2011 02:37:52 -0400
Subject: Small formatting fix.
---
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 8c801cd62..c36e20348 100644
--- a/system/database/DB_active_rec.php
+++ b/system/database/DB_active_rec.php
@@ -947,7 +947,7 @@ class CI_DB_active_record extends CI_DB_driver {
public function get_compiled_select($table = '', $reset = TRUE)
{
if ($table != '')
- {
+ {
$this->_track_aliases($table);
$this->from($table);
}
--
cgit v1.2.3-24-g4f1b
From c1ee04b4532124cbfaff69f50c996af64f63ac51 Mon Sep 17 00:00:00 2001
From: kylefarris
Date: Fri, 26 Aug 2011 02:39:54 -0400
Subject: Updated the changelog to reflect new Active Record methods:
get_compiled_select(), get_compiled_delete(), get_compiled_insert(),
get_compiled_update(), and reset_query().
---
user_guide/changelog.html | 27 ++-------------------------
1 file changed, 2 insertions(+), 25 deletions(-)
diff --git a/user_guide/changelog.html b/user_guide/changelog.html
index bb80ab8b8..5fff21f7b 100644
--- a/user_guide/changelog.html
+++ b/user_guide/changelog.html
@@ -66,23 +66,18 @@ 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.
-
Added html_escape() to Common functions to escape HTML output for preventing XSS.
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.
+
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.
-
+
Added new Active Record methods that return the SQL string of queries without executing them: get_compiled_select(), get_compiled_insert(), get_compiled_update(), get_compiled_delete().
Libraries
@@ -91,13 +86,6 @@ 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.
-
CI_Loader::_ci_autoloader() is now a protected method.
-
-
-
Core
-
-
Changed private functions in CI_URI to protected so MY_URI can override them.
@@ -108,11 +96,6 @@ Change Log
If a config class was loaded first then a library with the same name is loaded, the config would be ignored.
Fixed a bug (Reactor #19) where 1) the 404_override route was being ignored in some cases, and 2) auto-loaded libraries were not available to the 404_override controller when a controller existed but the requested method did not.
Fixed a bug (Reactor #89) where MySQL export would fail if the table had hyphens or other non alphanumeric/underscore characters.
-
Fixed a bug (#200) where MySQL queries would be malformed after calling count_all() then db->get()
-
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) - load_class() now looks for core classes in APPPATH first, allowing them to be replaced.
Version 2.0.3
@@ -132,13 +115,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.
-
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 0f35b6e8fd4640915b1793f2e531867b859f1e3d Mon Sep 17 00:00:00 2001
From: kylefarris
Date: Fri, 26 Aug 2011 02:40:56 -0400
Subject: Updated the Active Record documentation to reflect new publicly
visible Active Record methods: get_compiled_select(), get_compiled_delete(),
get_compiled_insert(), get_compiled_update(), and reset_query().
---
user_guide/database/active_record.html | 113 +++++++++++++++++++++++++++++----
1 file changed, 100 insertions(+), 13 deletions(-)
diff --git a/user_guide/database/active_record.html b/user_guide/database/active_record.html
index 92d9614d5..d53630402 100644
--- a/user_guide/database/active_record.html
+++ b/user_guide/database/active_record.html
@@ -73,6 +73,7 @@ is generated by each database adapter. It also allows for safer queries, since
The second parameter enables you to set whether or not the active record query will be reset (by default it will be—just like $this->db->get()):
+
+echo $this->db->limit(10,20)->get_compiled_select('mytable', FALSE);
+
+// Produces string: SELECT * FROM mytable LIMIT 20, 10 (in MySQL. Other databases have slightly different syntax)
+
+echo $this->db->select('title, content, date')->get_compiled_select();
+
+// Produces string: SELECT title, content, date FROM mytable
+
+
The key thing to notice in the above example is that the second query did not utlize $this->db->from() and did not pass a table name into the first parameter. The reason for this outcome is because the query has not been executed using $this->db->get() which resets values or reset directly using $this-db->reset_query().
+
$this->db->get_where();
@@ -334,13 +356,6 @@ $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'
-
-
The key thing to notice in the above example is that the second query did not utlize $this->db->from() nor did it pass a table name into the first parameter. The reason this worked is because the query has not been executed using $this->db->insert() which resets values or reset directly using $this-db->reset_query().
+
+
$this->db->insert_batch();
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:
Note: If the TRUNCATE command isn't available, truncate() will execute as "DELETE FROM table".
-
Method Chaining
+
+
+
Method Chaining
Method chaining allows you to simplify your syntax by connecting multiple functions. Consider this example:
@@ -727,9 +793,9 @@ $query = $this->db->get();
Note: Method chaining only works with PHP 5.
-
+
-
Active Record Caching
+
Active Record Caching
While not "true" caching, Active Record enables you to save (or "cache") certain parts of your queries for reuse at a later point in your script's execution. Normally, when an Active Record call is completed, all stored information is reset for the next call. With caching, you can prevent this reset, and reuse information easily.
@@ -769,7 +835,28 @@ $this->db->get('tablename');
//Generates: SELECT `field2` FROM (`tablename`)
Note: The following statements can be cached: select, from, join, where, like, group_by, having, order_by, set
-
+
+
+
+
Reset Active Record
+
+
Resetting Active Record allows you to start fresh with your query without executing it first using a method like $this->db->get() or $this->db->insert(). Just like the methods that execute a query, this will not reset items you've cached using Active Record Caching.
+
This is useful in situations where you are using Active Record to generate SQL (ex. $this->db->get_compiled_select()) but then choose to, for instance, run the query:
+
+
+// Note that the second parameter of the get_compiled_select method is FALSE
+$sql = $this->db->select(array('field1','field2'))->where('field3',5)->get_compiled_select('mytable', FALSE);
+
+// ...
+// Do something crazy with the SQL code... like add it to a cron script for later execution or something...
+// ...
+
+$data = $this->db->get()->result_array();
+
+// Would execute and return an array of results of the following query:
+// SELECT field1, field1 from mytable where field3 = 5;
+
+
--
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.
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
--
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:
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:
Go back to your news controller. You're going to do two things here, check whether the form was submitted and whether the submitted data passed the validation rules. You'll use the form validation library to do this.
-function create()
+public function create()
{
$this->load->helper('form');
$this->load->library('form_validation');
@@ -112,7 +112,6 @@ function create()
$this->news_model->set_news();
$this->load->view('news/success');
}
-
}
@@ -127,7 +126,7 @@ function create()
The only thing that remains is writing a method that writes the data to the database. You'll use the Active Record class to insert the information and use the input library to get the posted data. Open up the model created earlier and add the following:
-function set_news()
+public function set_news()
{
$this->load->helper('url');
@@ -140,7 +139,6 @@ function set_news()
);
return $this->db->insert('news', $data);
-
}
diff --git a/user_guide/tutorial/hard_coded_pages.html b/user_guide/tutorial/hard_coded_pages.html
index e83f1ec80..408634a78 100644
--- a/user_guide/tutorial/hard_coded_pages.html
+++ b/user_guide/tutorial/hard_coded_pages.html
@@ -68,7 +68,7 @@ Features
<?php
class Pages extends CI_Controller {
- function view($page = 'home')
+ public function view($page = 'home')
{
}
@@ -104,7 +104,7 @@ class Pages extends CI_Controller {
In order to load these pages we'll have to check whether these page actually exists. When the page does exist, we load the view for that pages, including the header and footer and display it to the user. If it doesn't, we show a "404 Page not found" error.
This tutorial is intended to introduce you to the CodeIgniter framework and the basic principles of MVC architecture. It will show you how a basic CodeIgniter application is constructed in step-by-step fashion.
+
+
In this tutorial, you will be creating a basic news application. You will begin by writing the code that can load static pages. Next, you will create a news section that reads news items from a database. Finally, you'll add a form to create news items in the database.
+
+
This tutorial will primarily focus on:
+
+
Model-View-Controller basics
+
Routing basics
+
Form validation
+
Performing basic database queries using "Active Record"
+
+
+
The entire tutorial is split up over several pages, each explaining a small part of the functionality of the CodeIgniter framework. You'll go through the following pages:
+
+
Introduction, this page, which gives you an overview of what to expect.
+
Static pages, which will teach you the basics of controllers, views and routing.
+
News section, where you'll start using models and will be doing some basic database operations.
+
Create news items, which will introduce more advanced database operations and form validation.
+
Conclusion, which will give you some pointers on further reading and other resources.
+
+
+
Enjoy your exploration of the CodeIgniter framework.
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/user_guide/tutorial/introduction.html b/user_guide/tutorial/introduction.html
deleted file mode 100644
index 78fd00b61..000000000
--- a/user_guide/tutorial/introduction.html
+++ /dev/null
@@ -1,101 +0,0 @@
-
-
-
-
-
-CodeIgniter Features : CodeIgniter User Guide
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
This tutorial is intended to introduce you to the CodeIgniter framework and the basic principles of MVC architecture. It will show you how a basic CodeIgniter application is constructed in step-by-step fashion.
-
-
In this tutorial, you will be creating a basic news application. You will begin by writing the code that can load static pages. Next, you will create a news section that reads news items from a database. Finally, you'll add a form to create news items in the database.
-
-
This tutorial will primarily focus on:
-
-
Model-View-Controller basics
-
Routing basics
-
Form validation
-
Performing basic database queries using "Active Record"
-
-
-
The entire tutorial is split up over several pages, each explaining a small part of the functionality of the CodeIgniter framework. You'll go through the following pages:
-
-
Introduction, this page, which gives you an overview of what to expect.
-
Static pages, which will teach you the basics of controllers, views and routing.
-
News section, where you'll start using models and will be doing some basic database operations.
-
Create news items, which will introduce more advanced database operations and form validation.
-
Conclusion, which will give you some pointers on further reading and other resources.
-
-
-
Enjoy your exploration of the CodeIgniter framework.
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/user_guide/tutorial/news_section.html b/user_guide/tutorial/news_section.html
index 191f0e1eb..b2d883184 100644
--- a/user_guide/tutorial/news_section.html
+++ b/user_guide/tutorial/news_section.html
@@ -42,7 +42,7 @@
@@ -71,10 +71,9 @@ News section
<?php
class News_model extends CI_Model {
- function __construct()
+ public function __construct()
{
$this->load->database();
-
}
}
@@ -97,18 +96,16 @@ CREATE TABLE news (
Now that the database and a model have been set up, you'll need a method to get all of our posts from our database. To do this, the database abstraction layer that is included with CodeIgniter — Active Record — is used. This makes it possible to write your 'queries' once and make them work on all supported database systems. Add the following code to your model.
The news overview page is now done, but a page to display individual news items is still absent. The model created earlier is made in such way that it can easily be used for this functionality. You only need to add some code to the controller and create a new view. Go back to the news controller and add the following lines to the file.
@@ -79,7 +79,7 @@ As URL schemes become more complex, this may change. But for now, this is all we
class Pages extends CI_Controller {
- function view($page = 'home')
+ public function view($page = 'home')
{
}
@@ -134,10 +134,10 @@ If you like to be particularly un-original, try "Hello World!".
In order to load those pages, you'll have to check whether the requested page actually exists:
-function view($page = 'home')
+public function view($page = 'home')
{
- if ( ! file_exists('application/views/pages/' . $page . '.php'))
+ if ( ! file_exists('application/views/pages/'.$page.'.php'))
{
// Whoops, we don't have a page for that!
show_404();
@@ -146,10 +146,10 @@ function view($page = 'home')
$data['title'] = ucfirst($page); // Capitalize the first letter
$this->load->view('templates/header', $data);
- $this->load->view('pages/' . $page, $data);
+ $this->load->view('pages/'.$page, $data);
$this->load->view('templates/footer', $data);
-
-}
+
+}
Now, when the page does exist, it is loaded, including the header and footer, and displayed to the user. If the page doesn't exist, a "404 Page not found" error is shown.
@@ -193,7 +193,7 @@ in the pages controller? Awesome!