From e3a6e9b085f95fe97deb21e103dc0fd381b8122f Mon Sep 17 00:00:00 2001 From: Phil Sturgeon Date: Tue, 8 Feb 2011 19:43:36 +0000 Subject: MySQL Driver will now wrap field names for insert(), update() and replace() with backticks (`) so fields like "default" and "order" will not cause SQL errors. --- system/database/drivers/mysql/mysql_driver.php | 16 ++++++++-------- user_guide/changelog.html | 1 + 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/system/database/drivers/mysql/mysql_driver.php b/system/database/drivers/mysql/mysql_driver.php index df18c912e..c9fc1ecab 100644 --- a/system/database/drivers/mysql/mysql_driver.php +++ b/system/database/drivers/mysql/mysql_driver.php @@ -287,12 +287,12 @@ class CI_DB_mysql_driver extends CI_DB { if (is_array($str)) { foreach($str as $key => $val) - { + { $str[$key] = $this->escape_str($val, $like); - } + } - return $str; - } + return $str; + } if (function_exists('mysql_real_escape_string') AND is_resource($this->conn_id)) { @@ -532,7 +532,7 @@ class CI_DB_mysql_driver extends CI_DB { */ function _insert($table, $keys, $values) { - return "INSERT INTO ".$table." (".implode(', ', $keys).") VALUES (".implode(', ', $values).")"; + return "INSERT INTO ".$table." (`".implode('`, `', $keys)."`) VALUES (".implode(', ', $values).")"; } // -------------------------------------------------------------------- @@ -551,7 +551,7 @@ class CI_DB_mysql_driver extends CI_DB { */ function _replace($table, $keys, $values) { - return "REPLACE INTO ".$table." (".implode(', ', $keys).") VALUES (".implode(', ', $values).")"; + return "REPLACE INTO ".$table." (`".implode('`, `', $keys)."`) VALUES (".implode(', ', $values).")"; } // -------------------------------------------------------------------- @@ -569,7 +569,7 @@ class CI_DB_mysql_driver extends CI_DB { */ function _insert_batch($table, $keys, $values) { - return "INSERT INTO ".$table." (".implode(', ', $keys).") VALUES ".implode(', ', $values); + return "INSERT INTO ".$table." (`".implode('`, `', $keys)."`) VALUES ".implode(', ', $values); } // -------------------------------------------------------------------- @@ -592,7 +592,7 @@ class CI_DB_mysql_driver extends CI_DB { { foreach($values as $key => $val) { - $valstr[] = $key." = ".$val; + $valstr[] = sprintf('`%s` = %s', $key, $val); } $limit = ( ! $limit) ? '' : ' LIMIT '.$limit; diff --git a/user_guide/changelog.html b/user_guide/changelog.html index cd728226b..1201df8b2 100644 --- a/user_guide/changelog.html +++ b/user_guide/changelog.html @@ -74,6 +74,7 @@ Hg Tag: n/a

Bug fixes for 2.0.1

Version 2.0.0

-- cgit v1.2.3-24-g4f1b -- cgit v1.2.3-24-g4f1b From 96bd33b2edc1b0e6a04cb8e3bcf97e8c7b3adf3e Mon Sep 17 00:00:00 2001 From: Phil Sturgeon Date: Wed, 4 May 2011 01:30:36 +0100 Subject: Added Migration class and language file. --- application/config/migration.php | 6 +- system/language/english/migration_lang.php | 13 ++++ system/libraries/Migration.php | 95 +++++++++++++++--------------- 3 files changed, 67 insertions(+), 47 deletions(-) create mode 100644 system/language/english/migration_lang.php diff --git a/application/config/migration.php b/application/config/migration.php index 37b1b8534..509fd90ab 100644 --- a/application/config/migration.php +++ b/application/config/migration.php @@ -22,7 +22,7 @@ $config['migration_enabled'] = TRUE; | be upgraded / downgraded to. | */ -$config['migration_version'] = 1; +$config['migration_version'] = 0; /* @@ -36,3 +36,7 @@ $config['migration_version'] = 1; | */ $config['migration_path'] = APPPATH . 'migrations/'; + + +/* End of file migration.php */ +/* Location: ./application/config/migration.php */ \ No newline at end of file diff --git a/system/language/english/migration_lang.php b/system/language/english/migration_lang.php new file mode 100644 index 000000000..4763ca243 --- /dev/null +++ b/system/language/english/migration_lang.php @@ -0,0 +1,13 @@ +_migration_path = rtrim($this->_migration_path, '/').'/'; + // Load migration language + $this->lang->load('migration'); + // They'll probably be using dbforge $this->load->dbforge(); @@ -90,7 +93,7 @@ class CI_Migration { * @param $version integer Target schema version * @return mixed TRUE if already latest, FALSE if failed, int if upgraded */ - function version($target_version) + public function version($target_version) { $start = $current_version = $this->_get_version(); $stop = $target_version; @@ -108,7 +111,7 @@ class CI_Migration { // Moving Down $step = -1; } - + $method = $step === 1 ? 'up' : 'down'; $migrations = array(); @@ -121,7 +124,7 @@ class CI_Migration { // Only one migration per step is permitted if (count($f) > 1) { - $this->error = sprintf($this->lang->line('multiple_migration_version'), $i); + $this->error = sprintf($this->lang->line('migration_multiple_version'), $i); return FALSE; } @@ -152,7 +155,7 @@ class CI_Migration { // Cannot repeat a migration at different steps if (in_array($match[1], $migrations)) { - $this->error = sprintf($this->lang->line('multiple_migrations_name'), $match[1]); + $this->error = sprintf($this->lang->line('migration_multiple_version'), $match[1]); return FALSE; } @@ -165,9 +168,9 @@ class CI_Migration { return FALSE; } - if ( ! is_callable(array($class, 'up')) || ! is_callable(array($class, 'down'))) + if ( ! is_callable(array($class, $method))) { - $this->error = sprintf($this->lang->line('wrong_migration_interface'), $class); + $this->error = sprintf($this->lang->line('migration_missing_'.$method.'_method'), $class); return FALSE; } @@ -175,12 +178,13 @@ class CI_Migration { } else { - $this->error = sprintf($this->lang->line('invalid_migration_filename'), $file); + exit('313'); + $this->error = sprintf($this->lang->line('migration_invalid_filename'), $file); return FALSE; } } - $this->log('Current schema version: ' . $current_version); + log_message('debug', 'Current migration: ' . $current_version); $version = $i + ($step == 1 ? -1 : 0); @@ -190,7 +194,7 @@ class CI_Migration { return TRUE; } - $this->log('Moving ' . $method . ' to version ' . $version); + log_message('debug', 'Migrating from ' . $method . ' to version ' . $version); // Loop through the migrations foreach ($migrations AS $migration) @@ -203,7 +207,7 @@ class CI_Migration { $this->_update_version($current_version); } - $this->log('All done. Schema is at version '.$current_version); + log_message('debug', 'Finished migrating to '.$current_version); return $current_version; } @@ -220,16 +224,15 @@ class CI_Migration { { if ( ! $migrations = $this->find_migrations()) { - throw new Exception('no_migrations_found'); + $this->error = $this->line->lang('migration_none_found'); return false; } $last_migration = basename(end($migrations)); - + // Calculate the last migration step from existing migration // filenames and procceed to the standard version migration - $last_version = intval(substr($last_migration, 0, 3)); - return $this->version($last_version); + return $this->version((int) substr($last_migration, 0, 3)); } // -------------------------------------------------------------------- @@ -242,25 +245,36 @@ class CI_Migration { */ public function current() { - $version = $this->_migration_version; - return $this->version($version); + return $this->version($this->_migration_version); } // -------------------------------------------------------------------- /** - * Set's the schema to the latest migration + * Error string * * @access public - * @return mixed true if already latest, false if failed, int if upgraded + * @return string Error message returned as a string */ + public function error_string() + { + return $this->error; + } - protected static function find_migrations() + // -------------------------------------------------------------------- + + /** + * Set's the schema to the latest migration + * + * @access protected + * @return mixed true if already latest, false if failed, int if upgraded + */ + protected function find_migrations() { // Load all *_*.php files in the migrations path $files = glob($this->_migration_path . '*_*.php'); $file_count = count($files); - + for ($i = 0; $i < $file_count; $i++) { // Mark wrongly formatted files as false for later filtering @@ -270,7 +284,7 @@ class CI_Migration { $files[$i] = FALSE; } } - + sort($files); return $files; @@ -281,10 +295,10 @@ class CI_Migration { /** * Retrieves current schema version * - * @access private - * @return integer Current Schema version + * @access protected + * @return integer Current Migration */ - private function _get_version() + protected function _get_version() { $row = $this->db->get('migrations')->row(); return $row ? $row->version : 0; @@ -295,11 +309,11 @@ class CI_Migration { /** * Stores the current schema version * - * @access private - * @param $migrations integer Schema version reached + * @access protected + * @param $migrations integer Migration reached * @return void Outputs a report of the migration */ - private function _update_version($migrations) + protected function _update_version($migrations) { return $this->db->update('migrations', array( 'version' => $migrations @@ -308,20 +322,6 @@ class CI_Migration { // -------------------------------------------------------------------- - /** - * Stores the current schema version - * - * @access private - * @param $migrations integer Schema version reached - * @return void Outputs a report of the migration - */ - private function log($text) - { - echo $text.'
'; - } - - // -------------------------------------------------------------------- - /** * Enable the use of CI super-global * @@ -333,4 +333,7 @@ class CI_Migration { { return get_instance()->$var; } -} \ No newline at end of file +} + +/* End of file Migration.php */ +/* Location: ./system/libraries/Migration.php */ \ No newline at end of file -- cgit v1.2.3-24-g4f1b From 168b3de75cd7161308eab89576df5353e40bae76 Mon Sep 17 00:00:00 2001 From: Phil Sturgeon Date: Wed, 4 May 2011 09:44:22 +0100 Subject: Reverted partial MySQL driver change which double-escaped some fields. --- system/database/drivers/mysql/mysql_driver.php | 6 +++--- user_guide/changelog.html | 1 - 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/system/database/drivers/mysql/mysql_driver.php b/system/database/drivers/mysql/mysql_driver.php index c4691ba0b..4ff9b0a11 100644 --- a/system/database/drivers/mysql/mysql_driver.php +++ b/system/database/drivers/mysql/mysql_driver.php @@ -532,7 +532,7 @@ class CI_DB_mysql_driver extends CI_DB { */ function _insert($table, $keys, $values) { - return "INSERT INTO ".$table." (`".implode('`, `', $keys)."`) VALUES (".implode(', ', $values).")"; + return "INSERT INTO ".$table." (".implode(', ', $keys).") VALUES (".implode(', ', $values).")"; } // -------------------------------------------------------------------- @@ -551,7 +551,7 @@ class CI_DB_mysql_driver extends CI_DB { */ function _replace($table, $keys, $values) { - return "REPLACE INTO ".$table." (`".implode('`, `', $keys)."`) VALUES (".implode(', ', $values).")"; + return "REPLACE INTO ".$table." (".implode(', ', $keys).") VALUES (".implode(', ', $values).")"; } // -------------------------------------------------------------------- @@ -569,7 +569,7 @@ class CI_DB_mysql_driver extends CI_DB { */ function _insert_batch($table, $keys, $values) { - return "INSERT INTO ".$table." (`".implode('`, `', $keys)."`) VALUES ".implode(', ', $values); + return "INSERT INTO ".$table." (".implode(', ', $keys).") VALUES ".implode(', ', $values); } // -------------------------------------------------------------------- diff --git a/user_guide/changelog.html b/user_guide/changelog.html index c22414d16..26e9bbc3b 100644 --- a/user_guide/changelog.html +++ b/user_guide/changelog.html @@ -128,7 +128,6 @@ Hg Tag: v2.0.1

  • Fixed issue #41: Added audio/mp3 mime type to mp3.
  • Fixed a bug (Core #329) where the file caching driver referenced the incorrect cache directory.
  • Fixed a bug (Reactor #69) where the SHA1 library was named incorrectly.
  • -
  • MySQL Driver will now wrap field names for insert(), update() and replace() with backticks (`) so fields like "default" and "order" will not cause SQL errors.
  • Version 2.0.0

    -- cgit v1.2.3-24-g4f1b From cb06c65e45120d084c8839d4caa344f0d84dc1a1 Mon Sep 17 00:00:00 2001 From: Phil Sturgeon Date: Wed, 4 May 2011 10:50:25 +0100 Subject: Made a few uniform changes to Migrations. --- system/libraries/Migration.php | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/system/libraries/Migration.php b/system/libraries/Migration.php index 4bf1d0dc1..3943ec130 100644 --- a/system/libraries/Migration.php +++ b/system/libraries/Migration.php @@ -33,7 +33,7 @@ class CI_Migration { protected $_migration_path = NULL; protected $_migration_version = 0; - public $error = ''; + protected $_error_string = ''; public function __construct($config = array()) { @@ -124,7 +124,7 @@ class CI_Migration { // Only one migration per step is permitted if (count($f) > 1) { - $this->error = sprintf($this->lang->line('migration_multiple_version'), $i); + $this->_error_string = sprintf($this->lang->line('migration_multiple_version'), $i); return FALSE; } @@ -140,7 +140,7 @@ class CI_Migration { // If trying to migrate down but we're missing a step, // something must definitely be wrong. - $this->error = sprintf($this->lang->line('migration_not_found'), $i); + $this->_error_string = sprintf($this->lang->line('migration_not_found'), $i); return FALSE; } @@ -155,7 +155,7 @@ class CI_Migration { // Cannot repeat a migration at different steps if (in_array($match[1], $migrations)) { - $this->error = sprintf($this->lang->line('migration_multiple_version'), $match[1]); + $this->_error_string = sprintf($this->lang->line('migration_multiple_version'), $match[1]); return FALSE; } @@ -164,13 +164,13 @@ class CI_Migration { if ( ! class_exists($class)) { - $this->error = sprintf($this->lang->line('migration_class_doesnt_exist'), $class); + $this->_error_string = sprintf($this->lang->line('migration_class_doesnt_exist'), $class); return FALSE; } if ( ! is_callable(array($class, $method))) { - $this->error = sprintf($this->lang->line('migration_missing_'.$method.'_method'), $class); + $this->_error_string = sprintf($this->lang->line('migration_missing_'.$method.'_method'), $class); return FALSE; } @@ -178,8 +178,7 @@ class CI_Migration { } else { - exit('313'); - $this->error = sprintf($this->lang->line('migration_invalid_filename'), $file); + $this->_error_string = sprintf($this->lang->line('migration_invalid_filename'), $file); return FALSE; } } @@ -224,7 +223,7 @@ class CI_Migration { { if ( ! $migrations = $this->find_migrations()) { - $this->error = $this->line->lang('migration_none_found'); + $this->_error_string = $this->line->lang('migration_none_found'); return false; } @@ -258,7 +257,7 @@ class CI_Migration { */ public function error_string() { - return $this->error; + return $this->_error_string; } // -------------------------------------------------------------------- -- cgit v1.2.3-24-g4f1b From 0cb8c59f91567af9aa6530f8764abafe1ae935c0 Mon Sep 17 00:00:00 2001 From: Derek Jones Date: Wed, 4 May 2011 09:11:43 -0500 Subject: updated application flow image. Fixes #273 - thanks @InsiteFx --- user_guide/images/appflowchart.gif | Bin 25276 -> 12363 bytes user_guide/overview/appflow.html | 2 +- 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/user_guide/images/appflowchart.gif b/user_guide/images/appflowchart.gif index 422332c9e..4328e48fe 100644 Binary files a/user_guide/images/appflowchart.gif and b/user_guide/images/appflowchart.gif differ diff --git a/user_guide/overview/appflow.html b/user_guide/overview/appflow.html index 09c13f9e7..eeef547ac 100644 --- a/user_guide/overview/appflow.html +++ b/user_guide/overview/appflow.html @@ -60,7 +60,7 @@ Appflow

    The following graphic illustrates how data flows throughout the system:

    -
    CodeIgniter application flow
    +
    CodeIgniter application flow
      -- cgit v1.2.3-24-g4f1b From 3837ae79a34a04559cabb862abda504f47ef069d Mon Sep 17 00:00:00 2001 From: Phil Sturgeon Date: Mon, 9 May 2011 21:12:26 +0100 Subject: Added 'is_unique' which is a brilliant feature I came up with all by myself. Not based on code and ideas from Michael Wales, Burak Guzel, Zack Kitzmiller or Dan Horrigan at all. If they say any differently they are lying. --- system/language/english/form_validation_lang.php | 3 +- system/libraries/Form_validation.php | 119 +++++++++++++---------- user_guide/changelog.html | 3 +- user_guide/libraries/form_validation.html | 17 +++- 4 files changed, 84 insertions(+), 58 deletions(-) diff --git a/system/language/english/form_validation_lang.php b/system/language/english/form_validation_lang.php index 3f2409007..abc30bcf3 100644 --- a/system/language/english/form_validation_lang.php +++ b/system/language/english/form_validation_lang.php @@ -1,4 +1,4 @@ -'; - var $_error_suffix = '

      '; - var $error_string = ''; - var $_safe_form_data = FALSE; - + protected $CI; + protected $_field_data = array(); + protected $_config_rules = array(); + protected $_error_array = array(); + protected $_error_messages = array(); + protected $_error_prefix = '

      '; + protected $_error_suffix = '

      '; + protected $error_string = ''; + protected $_safe_form_data = FALSE; /** * Constructor @@ -72,7 +71,7 @@ class CI_Form_validation { * @param string * @return void */ - function set_rules($field, $label = '', $rules = '') + public function set_rules($field, $label = '', $rules = '') { // No reason to set rules if we have no POST data if (count($_POST) == 0) @@ -163,7 +162,7 @@ class CI_Form_validation { * @param string * @return string */ - function set_message($lang, $val = '') + public function set_message($lang, $val = '') { if ( ! is_array($lang)) { @@ -187,7 +186,7 @@ class CI_Form_validation { * @param string * @return void */ - function set_error_delimiters($prefix = '

      ', $suffix = '

      ') + public function set_error_delimiters($prefix = '

      ', $suffix = '

      ') { $this->_error_prefix = $prefix; $this->_error_suffix = $suffix; @@ -206,7 +205,7 @@ class CI_Form_validation { * @param string the field name * @return void */ - function error($field = '', $prefix = '', $suffix = '') + public function error($field = '', $prefix = '', $suffix = '') { if ( ! isset($this->_field_data[$field]['error']) OR $this->_field_data[$field]['error'] == '') { @@ -238,7 +237,7 @@ class CI_Form_validation { * @param string * @return str */ - function error_string($prefix = '', $suffix = '') + public function error_string($prefix = '', $suffix = '') { // No errrors, validation passes! if (count($this->_error_array) === 0) @@ -279,7 +278,7 @@ class CI_Form_validation { * @access public * @return bool */ - function run($group = '') + public function run($group = '') { // Do we even have any data to process? Mm? if (count($_POST) == 0) @@ -374,7 +373,7 @@ class CI_Form_validation { * @param integer * @return mixed */ - function _reduce_array($array, $keys, $i = 0) + protected function _reduce_array($array, $keys, $i = 0) { if (is_array($array)) { @@ -406,7 +405,7 @@ class CI_Form_validation { * @access private * @return null */ - function _reset_post_array() + protected function _reset_post_array() { foreach ($this->_field_data as $field => $row) { @@ -468,7 +467,7 @@ class CI_Form_validation { * @param integer * @return mixed */ - function _execute($row, $rules, $postdata = NULL, $cycles = 0) + protected function _execute($row, $rules, $postdata = NULL, $cycles = 0) { // If the $_POST data is an array we will run a recursive call if (is_array($postdata)) @@ -695,7 +694,7 @@ class CI_Form_validation { * @param string the field name * @return string */ - function _translate_fieldname($fieldname) + protected function _translate_fieldname($fieldname) { // Do we need to translate the field name? // We look for the prefix lang: to determine this @@ -727,7 +726,7 @@ class CI_Form_validation { * @param string * @return void */ - function set_value($field = '', $default = '') + public function set_value($field = '', $default = '') { if ( ! isset($this->_field_data[$field])) { @@ -757,7 +756,7 @@ class CI_Form_validation { * @param string * @return string */ - function set_select($field = '', $value = '', $default = FALSE) + public function set_select($field = '', $value = '', $default = FALSE) { if ( ! isset($this->_field_data[$field]) OR ! isset($this->_field_data[$field]['postdata'])) { @@ -801,7 +800,7 @@ class CI_Form_validation { * @param string * @return string */ - function set_radio($field = '', $value = '', $default = FALSE) + public function set_radio($field = '', $value = '', $default = FALSE) { if ( ! isset($this->_field_data[$field]) OR ! isset($this->_field_data[$field]['postdata'])) { @@ -845,7 +844,7 @@ class CI_Form_validation { * @param string * @return string */ - function set_checkbox($field = '', $value = '', $default = FALSE) + public function set_checkbox($field = '', $value = '', $default = FALSE) { if ( ! isset($this->_field_data[$field]) OR ! isset($this->_field_data[$field]['postdata'])) { @@ -885,7 +884,7 @@ class CI_Form_validation { * @param string * @return bool */ - function required($str) + public function required($str) { if ( ! is_array($str)) { @@ -907,7 +906,7 @@ class CI_Form_validation { * @param regex * @return bool */ - function regex_match($str, $regex) + public function regex_match($str, $regex) { if ( ! preg_match($regex, $str)) { @@ -927,7 +926,7 @@ class CI_Form_validation { * @param field * @return bool */ - function matches($str, $field) + public function matches($str, $field) { if ( ! isset($_POST[$field])) { @@ -938,6 +937,24 @@ class CI_Form_validation { return ($str !== $field) ? FALSE : TRUE; } + + // -------------------------------------------------------------------- + + /** + * Match one field to another + * + * @access public + * @param string + * @param field + * @return bool + */ + public function is_unique($str, $field) + { + list($table, $field)=explode('.', $field); + $query = $this->CI->db->limit(1)->get_where($table, array($field => $str)); + + return $query->num_rows() === 0; + } // -------------------------------------------------------------------- @@ -949,7 +966,7 @@ class CI_Form_validation { * @param value * @return bool */ - function min_length($str, $val) + public function min_length($str, $val) { if (preg_match("/[^0-9]/", $val)) { @@ -974,7 +991,7 @@ class CI_Form_validation { * @param value * @return bool */ - function max_length($str, $val) + public function max_length($str, $val) { if (preg_match("/[^0-9]/", $val)) { @@ -999,7 +1016,7 @@ class CI_Form_validation { * @param value * @return bool */ - function exact_length($str, $val) + public function exact_length($str, $val) { if (preg_match("/[^0-9]/", $val)) { @@ -1023,7 +1040,7 @@ class CI_Form_validation { * @param string * @return bool */ - function valid_email($str) + public function valid_email($str) { return ( ! preg_match("/^([a-z0-9\+_\-]+)(\.[a-z0-9\+_\-]+)*@([a-z0-9\-]+\.)+[a-z]{2,6}$/ix", $str)) ? FALSE : TRUE; } @@ -1037,7 +1054,7 @@ class CI_Form_validation { * @param string * @return bool */ - function valid_emails($str) + public function valid_emails($str) { if (strpos($str, ',') === FALSE) { @@ -1064,7 +1081,7 @@ class CI_Form_validation { * @param string * @return string */ - function valid_ip($ip) + public function valid_ip($ip) { return $this->CI->input->valid_ip($ip); } @@ -1078,7 +1095,7 @@ class CI_Form_validation { * @param string * @return bool */ - function alpha($str) + public function alpha($str) { return ( ! preg_match("/^([a-z])+$/i", $str)) ? FALSE : TRUE; } @@ -1092,7 +1109,7 @@ class CI_Form_validation { * @param string * @return bool */ - function alpha_numeric($str) + public function alpha_numeric($str) { return ( ! preg_match("/^([a-z0-9])+$/i", $str)) ? FALSE : TRUE; } @@ -1106,7 +1123,7 @@ class CI_Form_validation { * @param string * @return bool */ - function alpha_dash($str) + public function alpha_dash($str) { return ( ! preg_match("/^([-a-z0-9_-])+$/i", $str)) ? FALSE : TRUE; } @@ -1120,7 +1137,7 @@ class CI_Form_validation { * @param string * @return bool */ - function numeric($str) + public function numeric($str) { return (bool)preg_match( '/^[\-+]?[0-9]*\.?[0-9]+$/', $str); @@ -1135,7 +1152,7 @@ class CI_Form_validation { * @param string * @return bool */ - function is_numeric($str) + public function is_numeric($str) { return ( ! is_numeric($str)) ? FALSE : TRUE; } @@ -1149,7 +1166,7 @@ class CI_Form_validation { * @param string * @return bool */ - function integer($str) + public function integer($str) { return (bool) preg_match('/^[\-+]?[0-9]+$/', $str); } @@ -1163,7 +1180,7 @@ class CI_Form_validation { * @param string * @return bool */ - function decimal($str) + public function decimal($str) { return (bool) preg_match('/^[\-+]?[0-9]+\.[0-9]+$/', $str); } @@ -1177,7 +1194,7 @@ class CI_Form_validation { * @param string * @return bool */ - function greater_than($str, $min) + public function greater_than($str, $min) { if ( ! is_numeric($str)) { @@ -1195,7 +1212,7 @@ class CI_Form_validation { * @param string * @return bool */ - function less_than($str, $max) + public function less_than($str, $max) { if ( ! is_numeric($str)) { @@ -1213,7 +1230,7 @@ class CI_Form_validation { * @param string * @return bool */ - function is_natural($str) + public function is_natural($str) { return (bool) preg_match( '/^[0-9]+$/', $str); } @@ -1227,7 +1244,7 @@ class CI_Form_validation { * @param string * @return bool */ - function is_natural_no_zero($str) + public function is_natural_no_zero($str) { if ( ! preg_match( '/^[0-9]+$/', $str)) { @@ -1254,7 +1271,7 @@ class CI_Form_validation { * @param string * @return bool */ - function valid_base64($str) + public function valid_base64($str) { return (bool) ! preg_match('/[^a-zA-Z0-9\/\+=]/', $str); } @@ -1271,7 +1288,7 @@ class CI_Form_validation { * @param string * @return string */ - function prep_for_form($data = '') + public function prep_for_form($data = '') { if (is_array($data)) { @@ -1300,7 +1317,7 @@ class CI_Form_validation { * @param string * @return string */ - function prep_url($str = '') + public function prep_url($str = '') { if ($str == 'http://' OR $str == '') { @@ -1324,7 +1341,7 @@ class CI_Form_validation { * @param string * @return string */ - function strip_image_tags($str) + public function strip_image_tags($str) { return $this->CI->input->strip_image_tags($str); } @@ -1338,7 +1355,7 @@ class CI_Form_validation { * @param string * @return string */ - function xss_clean($str) + public function xss_clean($str) { return $this->CI->security->xss_clean($str); } @@ -1352,7 +1369,7 @@ class CI_Form_validation { * @param string * @return string */ - function encode_php_tags($str) + public function encode_php_tags($str) { return str_replace(array(''), array('<?php', '<?PHP', '<?', '?>'), $str); } @@ -1361,4 +1378,4 @@ class CI_Form_validation { // END Form Validation Class /* End of file Form_validation.php */ -/* Location: ./system/libraries/Form_validation.php */ +/* Location: ./system/libraries/Form_validation.php */ \ No newline at end of file diff --git a/user_guide/changelog.html b/user_guide/changelog.html index 945fafb65..ff89a9aeb 100644 --- a/user_guide/changelog.html +++ b/user_guide/changelog.html @@ -73,7 +73,7 @@ Change Log
    1. Added Session Class userdata to the output profiler. Additionally, added a show/hide toggle on HTTP Headers, Session Data and Config Variables.
    2. Removed internal usage of the EXT constant.
    3. Visual updates to the welcome_message view file and default error templates. Thanks to danijelb for the pull request.
    4. -
    5. Added insert_batch() function to the PostgreSQL database driver. Thanks to epallerols for the patch.
    6. +
    7. Added insert_batch() function to the PostgreSQL database driver. Thanks to epallerols for the patch.
    8. @@ -85,6 +85,7 @@ Change Log
    9. Libraries
      • Altered Session to use a longer match against the user_agent string. See upgrade notes if using database sessions.
      • +
      • Added is_unique to the Form Validation library.
    10. diff --git a/user_guide/libraries/form_validation.html b/user_guide/libraries/form_validation.html index 54908d41d..e68765c35 100644 --- a/user_guide/libraries/form_validation.html +++ b/user_guide/libraries/form_validation.html @@ -390,10 +390,10 @@ $this->form_validation->set_rules($config);

      CodeIgniter lets you pipe multiple rules together. Let's try it. Change your rules in the third parameter of rule setting function, like this:

      -$this->form_validation->set_rules('username', 'Username', 'required|min_length[5]|max_length[12]');
      +$this->form_validation->set_rules('username', 'Username', 'required|min_length[5]|max_length[12]|is_unique[users.username]');
      $this->form_validation->set_rules('password', 'Password', 'required|matches[passconf]');
      $this->form_validation->set_rules('passconf', 'Password Confirmation', 'required');
      -$this->form_validation->set_rules('email', 'Email', 'required|valid_email');
      +$this->form_validation->set_rules('email', 'Email', 'required|valid_email|is_unique[users.email]');

      The above code sets the following rules:

      @@ -516,7 +516,7 @@ create a callback function that does that. Let's create a example of this.

      class Form extends CI_Controller { - function index() + public function index() { $this->load->helper(array('form', 'url')); @@ -525,7 +525,7 @@ class Form extends CI_Controller { $this->form_validation->set_rules('username', 'Username', 'callback_username_check'); $this->form_validation->set_rules('password', 'Password', 'required'); $this->form_validation->set_rules('passconf', 'Password Confirmation', 'required'); - $this->form_validation->set_rules('email', 'Email', 'required'); + $this->form_validation->set_rules('email', 'Email', 'required|is_unique[users.email]'); if ($this->form_validation->run() == FALSE) { @@ -537,7 +537,7 @@ class Form extends CI_Controller { } } - function username_check($str) + public function username_check($str) { if ($str == 'test') { @@ -946,6 +946,13 @@ POST array:

      matches[form_item] + + is_unique + Yes + Returns FALSE if the form element is not unique to the table and field name in the parameter. + is_unique[table.field] + + min_length Yes -- cgit v1.2.3-24-g4f1b From 63df37de043a3581a328e63207ea1c809c0e74c2 Mon Sep 17 00:00:00 2001 From: Phil Sturgeon Date: Mon, 9 May 2011 21:14:37 +0100 Subject: Removed accidental whitespace. --- system/language/english/form_validation_lang.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/system/language/english/form_validation_lang.php b/system/language/english/form_validation_lang.php index abc30bcf3..3418f29ab 100644 --- a/system/language/english/form_validation_lang.php +++ b/system/language/english/form_validation_lang.php @@ -1,4 +1,4 @@ - Date: Fri, 20 May 2011 10:25:13 -0500 Subject: modified the 'use_set_names' variable in the MySQL/i drivers to be a class property instead of static, in case multiple database servers are connected to in a single request. Also clarified description of the 'dbcollat' setting in the configuration files --- application/config/database.php | 3 ++- system/database/drivers/mysql/mysql_driver.php | 11 ++++++----- system/database/drivers/mysqli/mysqli_driver.php | 11 ++++++----- user_guide/database/configuration.html | 2 +- 4 files changed, 15 insertions(+), 12 deletions(-) diff --git a/application/config/database.php b/application/config/database.php index e77bf97df..4bb7a5707 100644 --- a/application/config/database.php +++ b/application/config/database.php @@ -27,7 +27,8 @@ | ['char_set'] The character set used in communicating with the database | ['dbcollat'] The character collation used in communicating with the database | NOTE: For MySQL and MySQLi databases, this setting is only used -| as a backup if your server is running PHP < 5.2.3 or MySQL < 5.0.7. +| as a backup if your server is running PHP < 5.2.3 or MySQL < 5.0.7 +| (and in table creation queries made with DB Forge). | There is an incompatibility in PHP with mysql_real_escape_string() which | can make your site vulnerable to SQL injection if you are using a | multi-byte character set and are running versions lower than these. diff --git a/system/database/drivers/mysql/mysql_driver.php b/system/database/drivers/mysql/mysql_driver.php index dec15863f..73a8b68da 100644 --- a/system/database/drivers/mysql/mysql_driver.php +++ b/system/database/drivers/mysql/mysql_driver.php @@ -54,6 +54,9 @@ class CI_DB_mysql_driver extends CI_DB { var $_count_string = 'SELECT COUNT(*) AS '; var $_random_keyword = ' RAND()'; // database specific random keyword + // whether SET NAMES must be used to set the character set + var $use_set_names; + /** * Non-persistent database connection * @@ -132,15 +135,13 @@ class CI_DB_mysql_driver extends CI_DB { */ function db_set_charset($charset, $collation) { - static $use_set_names; - - if ( ! isset($use_set_names)) + if ( ! isset($this->use_set_names)) { // mysql_set_charset() requires PHP >= 5.2.3 and MySQL >= 5.0.7, use SET NAMES as fallback - $use_set_names = (version_compare(PHP_VERSION, '5.2.3', '>=') && version_compare(mysql_get_server_info(), '5.0.7', '>=')) ? FALSE : TRUE; + $this->use_set_names = (version_compare(PHP_VERSION, '5.2.3', '>=') && version_compare(mysql_get_server_info(), '5.0.7', '>=')) ? FALSE : TRUE; } - if ($use_set_names) + if ($this->use_set_names === TRUE) { return @mysql_query("SET NAMES '".$this->escape_str($charset)."' COLLATE '".$this->escape_str($collation)."'", $this->conn_id); } diff --git a/system/database/drivers/mysqli/mysqli_driver.php b/system/database/drivers/mysqli/mysqli_driver.php index 74f55c421..457582498 100644 --- a/system/database/drivers/mysqli/mysqli_driver.php +++ b/system/database/drivers/mysqli/mysqli_driver.php @@ -54,6 +54,9 @@ class CI_DB_mysqli_driver extends CI_DB { */ var $delete_hack = TRUE; + // whether SET NAMES must be used to set the character set + var $use_set_names; + // -------------------------------------------------------------------- /** @@ -132,15 +135,13 @@ class CI_DB_mysqli_driver extends CI_DB { */ function _db_set_charset($charset, $collation) { - static $use_set_names; - - if ( ! isset($use_set_names)) + if ( ! isset($this->use_set_names)) { // mysqli_set_charset() requires MySQL >= 5.0.7, use SET NAMES as fallback - $use_set_names = (version_compare(mysqli_get_server_info($this->conn_id), '5.0.7', '>=')) ? FALSE : TRUE; + $this->use_set_names = (version_compare(mysqli_get_server_info($this->conn_id), '5.0.7', '>=')) ? FALSE : TRUE; } - if ($use_set_names) + if ($this->use_set_names === TRUE) { return @mysqli_query($this->conn_id, "SET NAMES '".$this->escape_str($charset)."' COLLATE '".$this->escape_str($collation)."'"); } diff --git a/user_guide/database/configuration.html b/user_guide/database/configuration.html index b34705410..439717748 100644 --- a/user_guide/database/configuration.html +++ b/user_guide/database/configuration.html @@ -132,7 +132,7 @@ for the primary connection, but it too can be renamed to something more relevant
    11. cache_on - TRUE/FALSE (boolean) - Whether database query caching is enabled, see also Database Caching Class.
    12. cachedir - The absolute server path to your database query cache directory.
    13. char_set - The character set used in communicating with the database.
    14. -
    15. dbcollat - The character collation used in communicating with the database.

      Note: For MySQL and MySQLi databases, this setting is only used as a backup if your server is running PHP < 5.2.3 or MySQL < 5.0.7. There is an incompatibility in PHP with mysql_real_escape_string() which can make your site vulnerable to SQL injection if you are using a multi-byte character set and are running versions lower than these. Sites using Latin-1 or UTF-8 database character set and collation are unaffected.

    16. +
    17. dbcollat - The character collation used in communicating with the database.

      Note: For MySQL and MySQLi databases, this setting is only used as a backup if your server is running PHP < 5.2.3 or MySQL < 5.0.7 (and in table creation queries made with DB Forge). There is an incompatibility in PHP with mysql_real_escape_string() which can make your site vulnerable to SQL injection if you are using a multi-byte character set and are running versions lower than these. Sites using Latin-1 or UTF-8 database character set and collation are unaffected.

    18. swap_pre - A default table prefix that should be swapped with dbprefix. This is useful for distributed applications where you might run manually written queries, and need the prefix to still be customizable by the end user.
    19. autoinit - Whether or not to automatically connect to the database when the library loads. If set to false, the connection will take place prior to executing the first query.
    20. stricton - TRUE/FALSE (boolean) - Whether to force "Strict Mode" connections, good for ensuring strict SQL while developing an application.
    21. -- cgit v1.2.3-24-g4f1b From f8288849f782e30dc310ca946a577cc664157106 Mon Sep 17 00:00:00 2001 From: Derek Jones Date: Fri, 20 May 2011 10:35:00 -0500 Subject: fixed missing closing tag in changelog --- user_guide/changelog.html | 1 + 1 file changed, 1 insertion(+) diff --git a/user_guide/changelog.html b/user_guide/changelog.html index ff89a9aeb..85df3291f 100644 --- a/user_guide/changelog.html +++ b/user_guide/changelog.html @@ -67,6 +67,7 @@ Change Log
      • An improvement was made to the MySQL and MySQLi drivers to prevent exposing a potential vector for SQL injection on sites using multi-byte character sets in the database client connection.

        An incompatibility in PHP versions < 5.2.3 and MySQL < 5.0.7 with mysql_set_charset() creates a situation where using multi-byte character sets on these environments may potentially expose a SQL injection attack vector. Latin-1, UTF-8, and other "low ASCII" character sets are unaffected on all environments.

        If you are running or considering running a multi-byte character set for your database connection, please pay close attention to the server environment you are deploying on to ensure you are not vulnerable.

      +
    22. General Changes -

      All three major image libraries are supported: GD/GD2, NetPBM, and ImageMagick

      +

      All three major image libraries are supported: GD/GD2, NetPBM, and ImageMagick

      Note: Watermarking is only available using the GD/GD2 library. In addition, even though other libraries are supported, GD is required in -order for the script to calculate the image properties. The image processing, however, will be performed with the +order for the script to calculate the image properties. The image processing, however, will be performed with the library you specify.

      @@ -82,14 +82,14 @@ library you specify.

      using the $this->load->library function:

      $this->load->library('image_lib'); -

      Once the library is loaded it will be ready for use. The image library object you will use to call all functions is: $this->image_lib

      +

      Once the library is loaded it will be ready for use. The image library object you will use to call all functions is: $this->image_lib

      Processing an Image

      Regardless of the type of processing you would like to perform (resizing, cropping, rotation, or watermarking), the general process is identical. You will set some preferences corresponding to the action you intend to perform, then -call one of four available processing functions. For example, to create an image thumbnail you'll do this:

      +call one of four available processing functions. For example, to create an image thumbnail you'll do this:

      $config['image_library'] = 'gd2';
      $config['source_image'] = '/path/to/image/mypic.jpg';
      @@ -106,7 +106,7 @@ $this->image_lib->resize();

      The above code tells the image_resize function to look for an image called mypic.jpg located in the source_image folder, then create a thumbnail that is 75 X 50 pixels using the GD2 image_library. Since the maintain_ratio option is enabled, the thumb will be as close to the target width and -height as possible while preserving the original aspect ratio. The thumbnail will be called mypic_thumb.jpg +height as possible while preserving the original aspect ratio. The thumbnail will be called mypic_thumb.jpg

      Note: In order for the image class to be allowed to do any processing, the @@ -126,7 +126,7 @@ folder containing the image files must have write permissions.

    23. $this->image_lib->clear()
    24. -

      These functions return boolean TRUE upon success and FALSE for failure. If they fail you can retrieve the +

      These functions return boolean TRUE upon success and FALSE for failure. If they fail you can retrieve the error message using this function:

      echo $this->image_lib->display_errors(); @@ -138,7 +138,7 @@ error message using this function:

          echo $this->image_lib->display_errors();
      }
      -

      Note: You can optionally specify the HTML formatting to be applied to the errors, by submitting the opening/closing +

      Note: You can optionally specify the HTML formatting to be applied to the errors, by submitting the opening/closing tags in the function, like this:

      $this->image_lib->display_errors('<p>', '</p>'); @@ -146,11 +146,11 @@ tags in the function, like this:

      Preferences

      -

      The preferences described below allow you to tailor the image processing to suit your needs.

      +

      The preferences described below allow you to tailor the image processing to suit your needs.

      Note that not all preferences are available for every -function. For example, the x/y axis preferences are only available for image cropping. Likewise, the width and height -preferences have no effect on cropping. The "availability" column indicates which functions support a given preference.

      +function. For example, the x/y axis preferences are only available for image cropping. Likewise, the width and height +preferences have no effect on cropping. The "availability" column indicates which functions support a given preference.

      Availability Legend:

      @@ -187,7 +187,7 @@ preferences have no effect on cropping. The "availability" column indicates whic library_path None None -Sets the server path to your ImageMagick or NetPBM library. If you use either of those libraries you must supply the path. +Sets the server path to your ImageMagick or NetPBM library. If you use either of those libraries you must supply the path. R, C, X @@ -195,7 +195,7 @@ preferences have no effect on cropping. The "availability" column indicates whic source_image None None -Sets the source image name/path. The path must be a relative or absolute server path, not a URL. +Sets the source image name/path. The path must be a relative or absolute server path, not a URL. R, C, S, W @@ -203,7 +203,7 @@ preferences have no effect on cropping. The "availability" column indicates whic dynamic_output FALSE TRUE/FALSE (boolean) -Determines whether the new image file should be written to disk or generated dynamically. Note: If you choose the dynamic setting, only one image can be shown at a time, and it can't be positioned on the page. It simply outputs the raw image dynamically to your browser, along with image headers. +Determines whether the new image file should be written to disk or generated dynamically. Note: If you choose the dynamic setting, only one image can be shown at a time, and it can't be positioned on the page. It simply outputs the raw image dynamically to your browser, along with image headers. R, C, X, W @@ -221,7 +221,7 @@ preferences have no effect on cropping. The "availability" column indicates whic new_image None None -Sets the destination image name/path. You'll use this preference when creating an image copy. The path must be a relative or absolute server path, not a URL. +Sets the destination image name/path. You'll use this preference when creating an image copy. The path must be a relative or absolute server path, not a URL. R, C, X, W @@ -253,7 +253,7 @@ preferences have no effect on cropping. The "availability" column indicates whic thumb_marker _thumb None -Specifies the thumbnail indicator. It will be inserted just before the file extension, so mypic.jpg would become mypic_thumb.jpg +Specifies the thumbnail indicator. It will be inserted just before the file extension, so mypic.jpg would become mypic_thumb.jpg R @@ -281,7 +281,7 @@ preferences have no effect on cropping. The "availability" column indicates whic rotation_angle None 90, 180, 270, vrt, hor -Specifies the angle of rotation when rotating images. Note that PHP rotates counter-clockwise, so a 90 degree rotation to the right must be specified as 270. +Specifies the angle of rotation when rotating images. Note that PHP rotates counter-clockwise, so a 90 degree rotation to the right must be specified as 270. X @@ -306,7 +306,7 @@ preferences have no effect on cropping. The "availability" column indicates whic

      Setting preferences in a config file

      If you prefer not to set preferences using the above method, you can instead put them into a config file. -Simply create a new file called image_lib.php, add the $config +Simply create a new file called image_lib.php, add the $config array in that file. Then save the file in: config/image_lib.php and it will be used automatically. You will NOT need to use the $this->image_lib->initialize function if you save your preferences in a config file.

      @@ -319,7 +319,7 @@ or create a thumbnail image.

      For practical purposes there is no difference between creating a copy and creating a thumbnail except a thumb will have the thumbnail marker as part of the name (ie, mypic_thumb.jpg).

      -

      All preferences listed in the table above are available for this function except these three: rotation_angle, x_axis, and y_axis.

      +

      All preferences listed in the table above are available for this function except these three: rotation_angle, x_axis, and y_axis.

      Creating a Thumbnail

      @@ -358,7 +358,7 @@ preferences for the X and Y axis (in pixels) specifying where to crop, like this $config['x_axis'] = '100';
      $config['y_axis'] = '40';
      -

      All preferences listed in the table above are available for this function except these: rotation_angle, width, height, create_thumb, new_image.

      +

      All preferences listed in the table above are available for this function except these: rotation_angle, width, height, create_thumb, new_image.

      Here's an example showing how you might crop an image:

      @@ -378,8 +378,8 @@ if ( ! $this->image_lib->crop())

      Note: Without a visual interface it is difficult to crop images, so this function is not very useful -unless you intend to build such an interface. That's exactly what we did using for the photo -gallery module in ExpressionEngine, the CMS we develop. We added a JavaScript UI that lets the cropping +unless you intend to build such an interface. That's exactly what we did using for the photo +gallery module in ExpressionEngine, the CMS we develop. We added a JavaScript UI that lets the cropping area be selected.

      $this->image_lib->rotate()

      @@ -443,7 +443,7 @@ containing your watermark over the source image.

      Just as with the other functions (resizing, cropping, and rotating) the general process for watermarking involves setting the preferences corresponding to the action you intend to perform, then -calling the watermark function. Here is an example:

      +calling the watermark function. Here is an example:

      $config['source_image'] = '/path/to/image/mypic.jpg';
      @@ -452,9 +452,9 @@ $config['wm_type'] = 'text';
      $config['wm_font_path'] = './system/fonts/texb.ttf';
      $config['wm_font_size'] = '16';
      $config['wm_font_color'] = 'ffffff';
      -$config['wm_vrt_alignment'] = 'bottom';
      -$config['wm_hor_alignment'] = 'center';
      -$config['wm_padding'] = '20';
      +$config['wm_vrt_alignment'] = 'bottom';
      +$config['wm_hor_alignment'] = 'center';
      +$config['wm_padding'] = '20';

      $this->image_lib->initialize($config);
      @@ -462,7 +462,7 @@ $this->image_lib->initialize($config); $this->image_lib->watermark();
      -

      The above example will use a 16 pixel True Type font to create the text "Copyright 2006 - John Doe". The watermark +

      The above example will use a 16 pixel True Type font to create the text "Copyright 2006 - John Doe". The watermark will be positioned at the bottom/center of the image, 20 pixels from the bottom of the image.

      Note: In order for the image class to be allowed to do any processing, the image file must have "write" file permissions. For example, 777.

      @@ -491,14 +491,14 @@ will be positioned at the bottom/center of the image, 20 pixels from the bottom source_image None None -Sets the source image name/path. The path must be a relative or absolute server path, not a URL. +Sets the source image name/path. The path must be a relative or absolute server path, not a URL. dynamic_output FALSE TRUE/FALSE (boolean) -Determines whether the new image file should be written to disk or generated dynamically. Note: If you choose the dynamic setting, only one image can be shown at a time, and it can't be positioned on the page. It simply outputs the raw image dynamically to your browser, along with image headers. +Determines whether the new image file should be written to disk or generated dynamically. Note: If you choose the dynamic setting, only one image can be shown at a time, and it can't be positioned on the page. It simply outputs the raw image dynamically to your browser, along with image headers. @@ -563,28 +563,28 @@ will be positioned at the bottom/center of the image, 20 pixels from the bottom wm_text None None -The text you would like shown as the watermark. Typically this will be a copyright notice. +The text you would like shown as the watermark. Typically this will be a copyright notice. wm_font_path None None -The server path to the True Type Font you would like to use. If you do not use this option, the native GD font will be used. +The server path to the True Type Font you would like to use. If you do not use this option, the native GD font will be used. wm_font_size 16 None -The size of the text. Note: If you are not using the True Type option above, the number is set using a range of 1 - 5. Otherwise, you can use any valid pixel size for the font you're using. +The size of the text. Note: If you are not using the True Type option above, the number is set using a range of 1 - 5. Otherwise, you can use any valid pixel size for the font you're using. wm_font_color ffffff None -The font color, specified in hex. Note, you must use the full 6 character hex value (ie, 993300), rather than the three character abbreviated version (ie fff). +The font color, specified in hex. Note, you must use the full 6 character hex value (ie, 993300), rather than the three character abbreviated version (ie fff). diff --git a/user_guide/libraries/input.html b/user_guide/libraries/input.html index 6070b6c48..08b8ab0d3 100644 --- a/user_guide/libraries/input.html +++ b/user_guide/libraries/input.html @@ -70,20 +70,20 @@ Input Class

      Security Filtering

      -

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

      +

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

        -
      • Destroys the global GET array. Since CodeIgniter does not utilize GET strings, there is no reason to allow it.
      • +
      • Destroys the global GET array. Since CodeIgniter does not utilize GET strings, there is no reason to allow it.
      • Destroys all global variables in the event register_globals is turned on.
      • Filters the POST/COOKIE array keys, permitting only alpha-numeric (and a few other) characters.
      • -
      • Provides XSS (Cross-site Scripting Hacks) filtering. This can be enabled globally, or upon request.
      • +
      • Provides XSS (Cross-site Scripting Hacks) filtering. This can be enabled globally, or upon request.
      • Standardizes newline characters to \n

      XSS Filtering

      -

      The Input class has the ability to filter input automatically to prevent cross-site scripting attacks. If you want the filter to run automatically every time it encounters POST or COOKIE data you can enable it by opening your +

      The Input class has the ability to filter input automatically to prevent cross-site scripting attacks. If you want the filter to run automatically every time it encounters POST or COOKIE data you can enable it by opening your application/config/config.php file and setting this:

      $config['global_xss_filtering'] = TRUE; @@ -93,9 +93,9 @@ Input Class

      Using POST, COOKIE, or SERVER Data

      -

      CodeIgniter comes with three helper functions that let you fetch POST, COOKIE or SERVER items. The main advantage of using the provided +

      CodeIgniter comes with three helper functions that let you fetch POST, COOKIE or SERVER items. The main advantage of using the provided functions rather than fetching an item directly ($_POST['something']) is that the functions will check to see if the item is set and -return false (boolean) if not. This lets you conveniently use data without having to test whether an item exists first. +return false (boolean) if not. This lets you conveniently use data without having to test whether an item exists first. In other words, normally you might do something like this:

      @@ -128,7 +128,7 @@ else

      The function returns FALSE (boolean) if the item you are attempting to retrieve does not exist.

      -

      The second optional parameter lets you run the data through the XSS filter. It's enabled by setting the second parameter to boolean TRUE;

      +

      The second optional parameter lets you run the data through the XSS filter. It's enabled by setting the second parameter to boolean TRUE;

      $this->input->post('some_data', TRUE); @@ -179,7 +179,7 @@ else

      $this->input->set_cookie()

      -

      Sets a cookie containing the values you specify. There are two ways to pass information to this function so that a cookie can be set: +

      Sets a cookie containing the values you specify. There are two ways to pass information to this function so that a cookie can be set: Array Method, and Discrete Parameters:

      Array Method

      @@ -203,10 +203,10 @@ $this->input->set_cookie($cookie);

      Only the name and value are required. To delete a cookie set it with the expiration blank.

      -

      The expiration is set in seconds, which will be added to the current time. Do not include the time, but rather only the -number of seconds from now that you wish the cookie to be valid. If the expiration is set to +

      The expiration is set in seconds, which will be added to the current time. Do not include the time, but rather only the +number of seconds from now that you wish the cookie to be valid. If the expiration is set to zero the cookie will only last as long as the browser is open.

      -

      For site-wide cookies regardless of how your site is requested, add your URL to the domain starting with a period, like this: .your-domain.com

      +

      For site-wide cookies regardless of how your site is requested, add your URL to the domain starting with a period, like this: .your-domain.com

      The path is usually not needed since the function sets a root path.

      The prefix is only needed if you need to avoid name collisions with other identically named cookies for your server.

      The secure boolean is only needed if you want to make it a secure cookie by setting it to TRUE.

      @@ -219,25 +219,25 @@ zero the cookie will only last as long as the browser is open.

      $this->input->cookie()

      -

      Lets you fetch a cookie. The first parameter will contain the name of the cookie you are looking for (including any prefixes):

      +

      Lets you fetch a cookie. The first parameter will contain the name of the cookie you are looking for (including any prefixes):

      cookie('some_cookie');

      The function returns FALSE (boolean) if the item you are attempting to retrieve does not exist.

      -

      The second optional parameter lets you run the data through the XSS filter. It's enabled by setting the second parameter to boolean TRUE;

      +

      The second optional parameter lets you run the data through the XSS filter. It's enabled by setting the second parameter to boolean TRUE;

      cookie('some_cookie', TRUE);

      $this->input->ip_address()

      -

      Returns the IP address for the current user. If the IP address is not valid, the function will return an IP of: 0.0.0.0

      +

      Returns the IP address for the current user. If the IP address is not valid, the function will return an IP of: 0.0.0.0

      echo $this->input->ip_address();

      $this->input->valid_ip($ip)

      -

      Takes an IP address as input and returns TRUE or FALSE (boolean) if it is valid or not. Note: The $this->input->ip_address() function above +

      Takes an IP address as input and returns TRUE or FALSE (boolean) if it is valid or not. Note: The $this->input->ip_address() function above validates the IP automatically.

      if ( ! $this->input->valid_ip($ip))
      @@ -256,7 +256,7 @@ else

      See the User Agent Class for methods which extract information from the user agent string.

      $this->input->request_headers()

      -

      Useful if running in a non-Apache environment where apache_request_headers() will not be supported. Returns an array of headers.

      +

      Useful if running in a non-Apache environment where apache_request_headers() will not be supported. Returns an array of headers.

      $headers = $this->input->request_headers(); diff --git a/user_guide/libraries/javascript.html b/user_guide/libraries/javascript.html index cd3adf1d2..4e262279d 100644 --- a/user_guide/libraries/javascript.html +++ b/user_guide/libraries/javascript.html @@ -65,11 +65,11 @@ JavaScript Driver $this->load->library('javascript'); -

      The Javascript class also accepts parameters, js_library_driver (string) default 'jquery' and autoload (bool) default TRUE. You may override the defaults if you wish by sending an associative array:

      +

      The Javascript class also accepts parameters, js_library_driver (string) default 'jquery' and autoload (bool) default TRUE. You may override the defaults if you wish by sending an associative array:

      $this->load->library('javascript', array('js_library_driver' => 'scripto', 'autoload' => FALSE)); -

      Again, presently only 'jquery' is available. You may wish to set autoload to FALSE, though, if you do not want the jQuery library to automatically include a script tag for the main jQuery script file. This is useful if you are loading it from a location outside of CodeIgniter, or already have the script tag in your markup.

      +

      Again, presently only 'jquery' is available. You may wish to set autoload to FALSE, though, if you do not want the jQuery library to automatically include a script tag for the main jQuery script file. This is useful if you are loading it from a location outside of CodeIgniter, or already have the script tag in your markup.

      Once loaded, the jQuery library object will be available using: $this->javascript

      Setup and Configuration

      @@ -93,7 +93,7 @@ JavaScript Driver $this->load->library('jquery'); -

      You may send an optional parameter to determine whether or not a script tag for the main jQuery file will be automatically included when loading the library. It will be created by default. To prevent this, load the library as follows:

      +

      You may send an optional parameter to determine whether or not a script tag for the main jQuery file will be automatically included when loading the library. It will be created by default. To prevent this, load the library as follows:

      $this->load->library('jquery', FALSE); @@ -115,7 +115,7 @@ JavaScript Driver

      Effects

      -

      The query library supports a powerful Effects repertoire. Before an effect can be used, it must be loaded:

      +

      The query library supports a powerful Effects repertoire. Before an effect can be used, it must be loaded:

      $this->jquery->effect([optional path] plugin name); // for example @@ -125,8 +125,8 @@ $this->jquery->effect('bounce');

      hide() / show()

      Each of this functions will affect the visibility of an item on your page. hide() will set an item invisible, show() will reveal it.

      -

      $this->jquery->hide(target, optional speed, optional extra information);
      - $this->jquery->show(target, optional speed, optional extra information);

      +

      $this->jquery->hide(target, optional speed, optional extra information);
      + $this->jquery->show(target, optional speed, optional extra information);

      • "target" will be any valid jQuery selector or selectors.
      • @@ -162,8 +162,8 @@ $this->jquery->click('#trigger', $this->jquery->animate('#note', $pa

        fadeIn() / fadeOut()

        -

        $this->jquery->fadeIn(target, optional speed, optional extra information);
        - $this->jquery->fadeOut(target, optional speed, optional extra information);

        +

        $this->jquery->fadeIn(target, optional speed, optional extra information);
        + $this->jquery->fadeOut(target, optional speed, optional extra information);

        • "target" will be any valid jQuery selector or selectors.
        • "speed" is optional, and is set to either slow, normal, fast, or alternatively a number of milliseconds.
        • @@ -182,8 +182,8 @@ $this->jquery->click('#trigger', $this->jquery->animate('#note', $pa

          fadeIn() / fadeOut()

          These effects cause an element(s) to disappear or reappear over time.

          -

          $this->jquery->fadeIn(target, optional speed, optional extra information);
          - $this->jquery->fadeOut(target, optional speed, optional extra information);

          +

          $this->jquery->fadeIn(target, optional speed, optional extra information);
          + $this->jquery->fadeOut(target, optional speed, optional extra information);

          • "target" will be any valid jQuery selector or selectors.
          • "speed" is optional, and is set to either slow, normal, fast, or alternatively a number of milliseconds.
          • @@ -193,9 +193,9 @@ $this->jquery->click('#trigger', $this->jquery->animate('#note', $pa

            slideUp() / slideDown() / slideToggle()

            These effects cause an element(s) to slide.

            -

            $this->jquery->slideUp(target, optional speed, optional extra information);
            - $this->jquery->slideDown(target, optional speed, optional extra information);
            -$this->jquery->slideToggle(target, optional speed, optional extra information);

            +

            $this->jquery->slideUp(target, optional speed, optional extra information);
            + $this->jquery->slideDown(target, optional speed, optional extra information);
            +$this->jquery->slideToggle(target, optional speed, optional extra information);

            • "target" will be any valid jQuery selector or selectors.
            • "speed" is optional, and is set to either slow, normal, fast, or alternatively a number of milliseconds.
            • diff --git a/user_guide/libraries/language.html b/user_guide/libraries/language.html index 1b253fa00..75863c2ac 100644 --- a/user_guide/libraries/language.html +++ b/user_guide/libraries/language.html @@ -60,30 +60,30 @@ Language Class

              The Language Class provides functions to retrieve language files and lines of text for purposes of internationalization.

              -

              In your CodeIgniter system folder you'll find one called language containing sets of language files. You can create +

              In your CodeIgniter system folder you'll find one called language containing sets of language files. You can create your own language files as needed in order to display error and other messages in other languages.

              -

              Language files are typically stored in your system/language directory. Alternately you can create a folder called language inside -your application folder and store them there. CodeIgniter will look first in your application/language -directory. If the directory does not exist or the specified language is not located there CI will instead look in your global +

              Language files are typically stored in your system/language directory. Alternately you can create a folder called language inside +your application folder and store them there. CodeIgniter will look first in your application/language +directory. If the directory does not exist or the specified language is not located there CI will instead look in your global system/language folder.

              -

              Note:  Each language should be stored in its own folder. For example, the English files are located at: +

              Note:  Each language should be stored in its own folder. For example, the English files are located at: system/language/english

              Creating Language Files

              -

              Language files must be named with _lang.php as the file extension. For example, let's say you want to create a file -containing error messages. You might name it: error_lang.php

              +

              Language files must be named with _lang.php as the file extension. For example, let's say you want to create a file +containing error messages. You might name it: error_lang.php

              Within the file you will assign each line of text to an array called $lang with this prototype:

              $lang['language_key'] = "The actual message to be shown";

              Note: It's a good practice to use a common prefix for all messages in a given file to avoid collisions with -similarly named items in other files. For example, if you are creating error messages you might prefix them with error_

              +similarly named items in other files. For example, if you are creating error messages you might prefix them with error_

              $lang['error_email_missing'] = "You must submit an email address";
              $lang['error_url_missing'] = "You must submit a URL";
              @@ -92,12 +92,12 @@ $lang['error_username_missing'] = "You must submit a username";
              Loading A Language File -

              In order to fetch a line from a particular file you must load the file first. Loading a language file is done with the following code:

              +

              In order to fetch a line from a particular file you must load the file first. Loading a language file is done with the following code:

              $this->lang->load('filename', 'language');

              Where filename is the name of the file you wish to load (without the file extension), and language -is the language set containing it (ie, english). If the second parameter is missing, the default language set in your +is the language set containing it (ie, english). If the second parameter is missing, the default language set in your application/config/config.php file will be used.

              @@ -109,7 +109,7 @@ is the language set containing it (ie, english). If the second parameter is miss

              Where language_key is the array key corresponding to the line you wish to show.

              -

              Note: This function simply returns the line. It does not echo it for you.

              +

              Note: This function simply returns the line. It does not echo it for you.

              Using language lines as form labels

              diff --git a/user_guide/libraries/loader.html b/user_guide/libraries/loader.html index 50ec60c1f..1d93af5ed 100644 --- a/user_guide/libraries/loader.html +++ b/user_guide/libraries/loader.html @@ -58,7 +58,7 @@ Loader Class

              Loader Class

              -

              Loader, as the name suggests, is used to load elements. These elements can be libraries (classes) View files, +

              Loader, as the name suggests, is used to load elements. These elements can be libraries (classes) View files, Helpers, Models, or your own files.

              Note: This class is initialized automatically by the system so there is no need to do it manually.

              @@ -69,7 +69,7 @@ Loader Class

              $this->load->library('class_name', $config, 'object name')

              -

              This function is used to load core classes. Where class_name is the name of the class you want to load. +

              This function is used to load core classes. Where class_name is the name of the class you want to load. Note: We use the terms "class" and "library" interchangeably.

              For example, if you would like to send email with CodeIgniter, the first step is to load the email class within your controller:

              @@ -96,7 +96,7 @@ For example, if you have file located at:

              Setting options

              -

              The second (optional) parameter allows you to optionally pass configuration setting. You will typically pass these as an array:

              +

              The second (optional) parameter allows you to optionally pass configuration setting. You will typically pass these as an array:

              $config = array (
              @@ -113,7 +113,7 @@ $this->load->library('email', $config);

              Assigning a Library to a different object name

              -

              If the third (optional) parameter is blank, the library will usually be assigned to an object with the same name as the library. For example, if the library is named Session, it +

              If the third (optional) parameter is blank, the library will usually be assigned to an object with the same name as the library. For example, if the library is named Session, it will be assigned to a variable named $this->session.

              If you prefer to set your own class names you can pass its value to the third parameter:

              @@ -131,20 +131,20 @@ $this->my_session

              $this->load->view('file_name', $data, true/false)

              -

              This function is used to load your View files. If you haven't read the Views section of the +

              This function is used to load your View files. If you haven't read the Views section of the user guide it is recommended that you do since it shows you how this function is typically used.

              -

              The first parameter is required. It is the name of the view file you would like to load.  Note: The .php file extension does not need to be specified unless you use something other than .php.

              +

              The first parameter is required. It is the name of the view file you would like to load.  Note: The .php file extension does not need to be specified unless you use something other than .php.

              The second optional parameter can take an associative array or an object as input, which it runs through the PHP extract function to -convert to variables that can be used in your view files. Again, read the Views page to learn +convert to variables that can be used in your view files. Again, read the Views page to learn how this might be useful.

              The third optional parameter lets you change the behavior of the function so that it returns data as a string -rather than sending it to your browser. This can be useful if you want to process the data in some way. If you -set the parameter to true (boolean) it will return data. The default behavior is false, which sends it -to your browser. Remember to assign it to a variable if you want the data returned:

              +rather than sending it to your browser. This can be useful if you want to process the data in some way. If you +set the parameter to true (boolean) it will return data. The default behavior is false, which sends it +to your browser. Remember to assign it to a variable if you want the data returned:

              $string = $this->load->view('myfile', '', true); @@ -159,7 +159,7 @@ to your browser. Remember to assign it to a variable if you want the data return
              $this->fubar->function();

              $this->load->database('options', true/false)

              -

              This function lets you load the database class. The two parameters are optional. Please see the +

              This function lets you load the database class. The two parameters are optional. Please see the database section for more info.

              @@ -168,9 +168,9 @@ $this->fubar->function();

              $this->load->vars($array)

              This function takes an associative array as input and generates variables using the PHP extract function. -This function produces the same result as using the second parameter of the $this->load->view() function above. The reason you might +This function produces the same result as using the second parameter of the $this->load->view() function above. The reason you might want to use this function independently is if you would like to set some global variables in the constructor of your controller -and have them become available in any view file loaded from any function. You can have multiple calls to this function. The data get cached +and have them become available in any view file loaded from any function. You can have multiple calls to this function. The data get cached and merged into one array for conversion to variables.

              @@ -180,7 +180,7 @@ and merged into one array for conversion to variables.

              $this->load->file('filepath/filename', true/false)

              -

              This is a generic file loading function. Supply the filepath and name in the first parameter and it will open and read the file. +

              This is a generic file loading function. Supply the filepath and name in the first parameter and it will open and read the file. By default the data is sent to your browser, just like a View file, but if you set the second parameter to true (boolean) it will instead return the data as a string.

              @@ -194,7 +194,7 @@ it will instead return the data as a string.

              Application "Packages"

              -

              An application package allows for the easy distribution of complete sets of resources in a single directory, complete with its own libraries, models, helpers, config, and language files. It is recommended that these packages be placed in the application/third_party folder. Below is a sample map of an package directory

              +

              An application package allows for the easy distribution of complete sets of resources in a single directory, complete with its own libraries, models, helpers, config, and language files. It is recommended that these packages be placed in the application/third_party folder. Below is a sample map of an package directory

              Sample Package "Foo Bar" Directory Map

              @@ -210,18 +210,18 @@ libraries/
              models/
              -

              Whatever the purpose of the "Foo Bar" application package, it has its own config files, helpers, language files, libraries, and models. To use these resources in your controllers, you first need to tell the Loader that you are going to be loading resources from a package, by adding the package path.

              +

              Whatever the purpose of the "Foo Bar" application package, it has its own config files, helpers, language files, libraries, and models. To use these resources in your controllers, you first need to tell the Loader that you are going to be loading resources from a package, by adding the package path.

              $this->load->add_package_path()

              -

              Adding a package path instructs the Loader class to prepend a given path for subsequent requests for resources. As an example, the "Foo Bar" application package above has a library named Foo_bar.php. In our controller, we'd do the following:

              +

              Adding a package path instructs the Loader class to prepend a given path for subsequent requests for resources. As an example, the "Foo Bar" application package above has a library named Foo_bar.php. In our controller, we'd do the following:

              $this->load->add_package_path(APPPATH.'third_party/foo_bar/');
              $this->load->library('foo_bar');

              $this->load->remove_package_path()

              -

              When your controller is finished using resources from an application package, and particularly if you have other application packages you want to work with, you may wish to remove the package path so the Loader no longer looks in that folder for resources. To remove the last path added, simply call the method with no parameters.

              +

              When your controller is finished using resources from an application package, and particularly if you have other application packages you want to work with, you may wish to remove the package path so the Loader no longer looks in that folder for resources. To remove the last path added, simply call the method with no parameters.

              $this->load->remove_package_path()

              @@ -231,8 +231,8 @@ $this->load->library('foo_bar');

              Package view files

              -

              By Default, package view files paths are set when add_package_path() is called. View paths are looped through, and once a match is encountered that view is loaded.

              -

              In this instance, it is possible for view naming collisions within packages to occur, and possibly the incorrect package being loaded. To ensure against this, set an optional second parameter of FALSE when calling add_package_path().

              +

              By Default, package view files paths are set when add_package_path() is called. View paths are looped through, and once a match is encountered that view is loaded.

              +

              In this instance, it is possible for view naming collisions within packages to occur, and possibly the incorrect package being loaded. To ensure against this, set an optional second parameter of FALSE when calling add_package_path().

              $this->load->add_package_path(APPPATH.'my_app', TRUE);
              diff --git a/user_guide/libraries/output.html b/user_guide/libraries/output.html index 8846e15ff..4d1f8d97a 100644 --- a/user_guide/libraries/output.html +++ b/user_guide/libraries/output.html @@ -58,7 +58,7 @@ Output Class

              Output Class

              -

              The Output class is a small class with one main function: To send the finalized web page to the requesting browser. It is +

              The Output class is a small class with one main function: To send the finalized web page to the requesting browser. It is also responsible for caching your web pages, if you use that feature.

              Note: This class is initialized automatically by the system so there is no need to do it manually.

              @@ -70,7 +70,7 @@ It is possible, however, for you to manually intervene with the output if you ne

              $this->output->set_output();

              -

              Permits you to manually set the final output string. Usage example:

              +

              Permits you to manually set the final output string. Usage example:

              $this->output->set_output($data); @@ -95,7 +95,7 @@ $this->output

              $this->output->get_output();

              -

              Permits you to manually retrieve any output that has been sent for storage in the output class. Usage example:

              +

              Permits you to manually retrieve any output that has been sent for storage in the output class. Usage example:

              $string = $this->output->get_output();

              Note that data will only be retrievable from this function if it has been previously sent to the output class by one of the @@ -104,7 +104,7 @@ CodeIgniter functions like $this->load->view().

              $this->output->append_output();

              -

              Appends data onto the output string. Usage example:

              +

              Appends data onto the output string. Usage example:

              $this->output->append_output($data); @@ -112,7 +112,7 @@ CodeIgniter functions like $this->load->view().

              $this->output->set_header();

              -

              Permits you to manually set server headers, which the output class will send for you when outputting the final rendered display. Example:

              +

              Permits you to manually set server headers, which the output class will send for you when outputting the final rendered display. Example:

              $this->output->set_header("HTTP/1.0 200 OK");
              @@ -125,10 +125,10 @@ $this->output->set_header("Pragma: no-cache");

              $this->output->set_status_header(code, 'text');

              -

              Permits you to manually set a server status header. Example:

              +

              Permits you to manually set a server status header. Example:

              $this->output->set_status_header('401');
              -// Sets the header as: Unauthorized
              +// Sets the header as: Unauthorized

              See here for a full list of headers.

              @@ -147,14 +147,14 @@ at the bottom of your pages for debugging and optimization purposes.

              $this->output->set_profiler_sections();

              -

              Permits you to enable/disable specific sections of the Profiler when enabled. Please refer to the Profiler documentation for further information.

              +

              Permits you to enable/disable specific sections of the Profiler when enabled. Please refer to the Profiler documentation for further information.

              $this->output->cache();

              -

              The CodeIgniter output library also controls caching. For more information, please see the caching documentation.

              +

              The CodeIgniter output library also controls caching. For more information, please see the caching documentation.

              Parsing Execution Variables

              -

              CodeIgniter will parse the pseudo-variables {elapsed_time} and {memory_usage} in your output by default. To disable this, set the $parse_exec_vars class property to FALSE in your controller. +

              CodeIgniter will parse the pseudo-variables {elapsed_time} and {memory_usage} in your output by default. To disable this, set the $parse_exec_vars class property to FALSE in your controller. $this->output->parse_exec_vars = FALSE; diff --git a/user_guide/libraries/pagination.html b/user_guide/libraries/pagination.html index a6b9287a3..3c366a69f 100644 --- a/user_guide/libraries/pagination.html +++ b/user_guide/libraries/pagination.html @@ -72,26 +72,26 @@ Pagination Class $this->load->library('pagination');

              $config['base_url'] = 'http://example.com/index.php/test/page/';
              $config['total_rows'] = 200;
              -$config['per_page'] = 20; +$config['per_page'] = 20;

              $this->pagination->initialize($config);

              -echo $this->pagination->create_links(); +echo $this->pagination->create_links();

              Notes:

              -

              The $config array contains your configuration variables. It is passed to the $this->pagination->initialize function as shown above. Although there are some twenty items you can configure, at -minimum you need the three shown. Here is a description of what those items represent:

              +

              The $config array contains your configuration variables. It is passed to the $this->pagination->initialize function as shown above. Although there are some twenty items you can configure, at +minimum you need the three shown. Here is a description of what those items represent:

                -
              • base_url This is the full URL to the controller class/function containing your pagination. In the example - above, it is pointing to a controller called "Test" and a function called "page". Keep in mind that you can +
              • base_url This is the full URL to the controller class/function containing your pagination. In the example + above, it is pointing to a controller called "Test" and a function called "page". Keep in mind that you can re-route your URI if you need a different structure.
              • total_rows This number represents the total rows in the result set you are creating pagination for. Typically this number will be the total rows that your database query returned.
              • -
              • per_page The number of items you intend to show per page. In the above example, you would be showing 20 items per page.
              • +
              • per_page The number of items you intend to show per page. In the above example, you would be showing 20 items per page.

              The create_links() function returns an empty string when there is no pagination to show.

              @@ -100,7 +100,7 @@ minimum you need the three shown. Here is a description of what those items repr

              Setting preferences in a config file

              If you prefer not to set preferences using the above method, you can instead put them into a config file. -Simply create a new file called pagination.php, add the $config +Simply create a new file called pagination.php, add the $config array in that file. Then save the file in: config/pagination.php and it will be used automatically. You will NOT need to use the $this->pagination->initialize function if you save your preferences in a config file.

              @@ -122,9 +122,9 @@ something different you can specify it.

              $config['page_query_string'] = TRUE

              By default, the pagination library assume you are using URI Segments, and constructs your links something like

              http://example.com/index.php/test/page/20

              -

              If you have $config['enable_query_strings'] set to TRUE your links will automatically be re-written using Query Strings. This option can also be explictly set. Using $config['page_query_string'] set to TRUE, the pagination link will become.

              +

              If you have $config['enable_query_strings'] set to TRUE your links will automatically be re-written using Query Strings. This option can also be explictly set. Using $config['page_query_string'] set to TRUE, the pagination link will become.

              http://example.com/index.php?c=test&m=page&per_page=20

              -

              Note that "per_page" is the default query string passed, however can be configured using $config['query_string_segment'] = 'your_string'

              +

              Note that "per_page" is the default query string passed, however can be configured using $config['query_string_segment'] = 'your_string'

              Adding Enclosing Markup

              If you would like to surround the entire pagination with some markup you can do it with these two prefs:

              diff --git a/user_guide/libraries/parser.html b/user_guide/libraries/parser.html index 4f04aaf48..cb2f100a2 100644 --- a/user_guide/libraries/parser.html +++ b/user_guide/libraries/parser.html @@ -83,10 +83,10 @@ variables or variable tag pairs. If you've never used a template engine, pseudo- PHP from your templates (view files).

              Note: CodeIgniter does not require you to use this class -since using pure PHP in your view pages lets them run a little faster. However, some developers prefer to use a template engine if +since using pure PHP in your view pages lets them run a little faster. However, some developers prefer to use a template engine if they work with designers who they feel would find some confusion working with PHP.

              -

              Also Note: The Template Parser Class is not a +

              Also Note: The Template Parser Class is not a full-blown template parsing solution. We've kept it very lean on purpose in order to maintain maximum performance.

              @@ -102,7 +102,7 @@ full-blown template parsing solution. We've kept it very lean on purpose in orde

              $this->parser->parse()

              -

              This method accepts a template name and data array as input, and it generates a parsed version. Example:

              +

              This method accepts a template name and data array as input, and it generates a parsed version. Example:

              $this->load->library('parser');

              @@ -114,11 +114,11 @@ $data = array(
              $this->parser->parse('blog_template', $data);

              The first parameter contains the name of the view file (in this example the file would be called blog_template.php), -and the second parameter contains an associative array of data to be replaced in the template. In the above example, the +and the second parameter contains an associative array of data to be replaced in the template. In the above example, the template would contain two variables: {blog_title} and {blog_heading}

              -

              There is no need to "echo" or do something with the data returned by $this->parser->parse(). It is automatically -passed to the output class to be sent to the browser. However, if you do want the data returned instead of sent to the output class you can +

              There is no need to "echo" or do something with the data returned by $this->parser->parse(). It is automatically +passed to the output class to be sent to the browser. However, if you do want the data returned instead of sent to the output class you can pass TRUE (boolean) to the third parameter:

              $string = $this->parser->parse('blog_template', $data, TRUE); @@ -130,8 +130,8 @@ pass TRUE (boolean) to the third parameter:

              Variable Pairs

              -

              The above example code allows simple variables to be replaced. What if you would like an entire block of variables to be -repeated, with each iteration containing new values? Consider the template example we showed at the top of the page:

              +

              The above example code allows simple variables to be replaced. What if you would like an entire block of variables to be +repeated, with each iteration containing new values? Consider the template example we showed at the top of the page:

              <html>
              <head>
              diff --git a/user_guide/libraries/security.html b/user_guide/libraries/security.html index 0cb1d0cb1..735187459 100644 --- a/user_guide/libraries/security.html +++ b/user_guide/libraries/security.html @@ -63,11 +63,11 @@ Security Class

              XSS Filtering

              CodeIgniter comes with a Cross Site Scripting Hack prevention filter which can either run automatically to filter -all POST and COOKIE data that is encountered, or you can run it on a per item basis. By default it does not +all POST and COOKIE data that is encountered, or you can run it on a per item basis. By default it does not run globally since it requires a bit of processing overhead, and since you may not need it in all cases.

              The XSS filter looks for commonly used techniques to trigger Javascript or other types of code that attempt to hijack cookies -or do other malicious things. If anything disallowed is encountered it is rendered safe by converting the data to character entities.

              +or do other malicious things. If anything disallowed is encountered it is rendered safe by converting the data to character entities.

              Note: This function should only be used to deal with data upon submission. It's not something that should be used for general runtime processing since it requires a fair amount of processing overhead.

              @@ -88,7 +88,7 @@ Note: This function should only be used to deal with data upon submission. It's

              Note: If you use the form validation class, it gives you the option of XSS filtering as well.

              -

              An optional second parameter, is_image, allows this function to be used to test images for potential XSS attacks, useful for file upload security. When this second parameter is set to TRUE, instead of returning an altered string, the function returns TRUE if the image is safe, and FALSE if it contained potentially malicious information that a browser may attempt to execute.

              +

              An optional second parameter, is_image, allows this function to be used to test images for potential XSS attacks, useful for file upload security. When this second parameter is set to TRUE, instead of returning an altered string, the function returns TRUE if the image is safe, and FALSE if it contained potentially malicious information that a browser may attempt to execute.

              if ($this->security->xss_clean($file, TRUE) === FALSE)
              {
              @@ -98,7 +98,7 @@ Note: This function should only be used to deal with data upon submission. It's

              $this->security->sanitize_filename()

              -

              When accepting filenames from user input, it is best to sanitize them to prevent directory traversal and other security related issues. To do so, use the sanitize_filename() method of the Security class. Here is an example:

              +

              When accepting filenames from user input, it is best to sanitize them to prevent directory traversal and other security related issues. To do so, use the sanitize_filename() method of the Security class. Here is an example:

              $filename = $this->security->sanitize_filename($this->input->post('filename')); diff --git a/user_guide/libraries/sessions.html b/user_guide/libraries/sessions.html index bb8f1fc9b..a6f3c601c 100644 --- a/user_guide/libraries/sessions.html +++ b/user_guide/libraries/sessions.html @@ -61,7 +61,7 @@ Session Class

              The Session class permits you maintain a user's "state" and track their activity while they browse your site. The Session class stores session information for each user as serialized (and optionally encrypted) data in a cookie. It can also store the session data in a database table for added security, as this permits the session ID in the -user's cookie to be matched against the stored session ID. By default only the cookie is saved. If you choose to +user's cookie to be matched against the stored session ID. By default only the cookie is saved. If you choose to use the database option you'll need to create the session table as indicated below.

              @@ -93,8 +93,8 @@ will cause it to read, create, and update sessions.

              If sessions data does not exist (or if it has expired) a new session will be created and saved in the cookie. If a session does exist, its information will be updated and the cookie will be updated. With each update, the session_id will be regenerated.

              -

              It's important for you to understand that once initialized, the Session class runs automatically. There is nothing -you need to do to cause the above behavior to happen. You can, as you'll see below, work with session data or +

              It's important for you to understand that once initialized, the Session class runs automatically. There is nothing +you need to do to cause the above behavior to happen. You can, as you'll see below, work with session data or even add your own data to a user's session, but the process of reading, writing, and updating a session is automatic.

              @@ -106,7 +106,7 @@ even add your own data to a user's session, but the process of reading, writing,
            • The user's unique Session ID (this is a statistically random string with very strong entropy, hashed with MD5 for portability, and regenerated (by default) every five minutes)
            • The user's IP Address
            • The user's User Agent data (the first 50 characters of the browser data string)
            • -
            • The "last activity" time stamp.
            • +
            • The "last activity" time stamp.

            The above data is stored in a cookie as a serialized array with this prototype:

            @@ -124,7 +124,7 @@ making the data highly secure and impervious to being read or altered by someone can be found here, although the Session class will take care of initializing and encrypting the data automatically.

            -

            Note: Session cookies are only updated every five minutes by default to reduce processor load. If you repeatedly reload a page +

            Note: Session cookies are only updated every five minutes by default to reduce processor load. If you repeatedly reload a page you'll notice that the "last activity" time only updates if five minutes or more has passed since the last time the cookie was written. This time is configurable by changing the $config['sess_time_to_update'] line in your system/config/config.php file.

            @@ -134,7 +134,7 @@ the cookie was written. This time is configurable by changing the $config['sess_ $this->session->userdata('item'); -

            Where item is the array index corresponding to the item you wish to fetch. For example, to fetch the session ID you +

            Where item is the array index corresponding to the item you wish to fetch. For example, to fetch the session ID you will do this:

            $session_id = $this->session->userdata('session_id'); @@ -145,7 +145,7 @@ will do this:

            Adding Custom Session Data

            A useful aspect of the session array is that you can add your own data to it and it will be stored in the user's cookie. -Why would you want to do this? Here's one example:

            +Why would you want to do this? Here's one example:

            Let's say a particular user logs into your site. Once authenticated, you could add their username and email address to the session cookie, making that data globally available to you without @@ -155,7 +155,7 @@ having to run a database query when you need it.

            $this->session->set_userdata($array); -

            Where $array is an associative array containing your new data. Here's an example:

            +

            Where $array is an associative array containing your new data. Here's an example:

            $newdata = array(
            @@ -167,7 +167,7 @@ having to run a database query when you need it.

            $this->session->set_userdata($newdata);

            If you want to add userdata one value at a time, set_userdata() also supports this syntax.

            $this->session->set_userdata('some_name', 'some_value');

            -

            Note: Cookies can only hold 4KB of data, so be careful not to exceed the capacity. The +

            Note: Cookies can only hold 4KB of data, so be careful not to exceed the capacity. The encryption process in particular produces a longer data string than the original so keep careful track of how much data you are storing.

            Retrieving All Session Data

            @@ -179,10 +179,10 @@ encryption process in particular produces a longer data string than the original
             Array
             (
            -  [session_id] => 4a5a5dca22728fb0a84364eeb405b601
            -  [ip_address] => 127.0.0.1
            -  [user_agent] => Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_7;
            -  [last_activity] => 1303142623
            +    [session_id] => 4a5a5dca22728fb0a84364eeb405b601
            +    [ip_address] => 127.0.0.1
            +    [user_agent] => Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_7;
            +    [last_activity] => 1303142623
             )
             
            @@ -206,20 +206,20 @@ $this->session->unset_userdata($array_items);

            $this->session->keep_flashdata('item');

            Saving Session Data to a Database

            While the session data array stored in the user's cookie contains a Session ID, -unless you store session data in a database there is no way to validate it. For some applications that require little or no -security, session ID validation may not be needed, but if your application requires security, validation is mandatory. Otherwise, an old session +unless you store session data in a database there is no way to validate it. For some applications that require little or no +security, session ID validation may not be needed, but if your application requires security, validation is mandatory. Otherwise, an old session could be restored by a user modifying their cookies.

            When session data is available in a database, every time a valid session is found in the user's cookie, a database -query is performed to match it. If the session ID does not match, the session is destroyed. Session IDs can never +query is performed to match it. If the session ID does not match, the session is destroyed. Session IDs can never be updated, they can only be generated when a new session is created.

            -

            In order to store sessions, you must first create a database table for this purpose. Here is the basic +

            In order to store sessions, you must first create a database table for this purpose. Here is the basic prototype (for MySQL) required by the session class:

            -

            Note: In the above code we are using a "url helper". You can find more information in the Helpers Functions page.

            +

            Note: In the above code we are using a "url helper". You can find more information in the Helpers Functions page.

            The Server

            @@ -381,7 +381,7 @@ class Xmlrpc_server extends CI_Controller { $response = array( array( - 'you_said' => $parameters['0'], + 'you_said' => $parameters['0'], 'i_respond' => 'Not bad at all.'), 'struct'); @@ -452,7 +452,7 @@ The Server receives the request and maps it to the "process" function, where a r $this->xmlrpc->request($request);

            $this->xmlrpc->send_request()

            -

            The request sending function. Returns boolean TRUE or FALSE based on success for failure, enabling it to be used conditionally.

            +

            The request sending function. Returns boolean TRUE or FALSE based on success for failure, enabling it to be used conditionally.

            $this->xmlrpc->set_debug(TRUE);

            Enables debugging, which will display a variety of information and error data helpful during development.

            @@ -463,7 +463,7 @@ $this->xmlrpc->request($request); echo $this->xmlrpc->display_error();

            $this->xmlrpc->display_response()

            -

            Returns the response from the remote server once request is received. The response will typically be an associative array.

            +

            Returns the response from the remote server once request is received. The response will typically be an associative array.

            $this->xmlrpc->display_response();

            $this->xmlrpc->send_error_message()

            diff --git a/user_guide/libraries/zip.html b/user_guide/libraries/zip.html index 2fc5fd81b..031126603 100644 --- a/user_guide/libraries/zip.html +++ b/user_guide/libraries/zip.html @@ -81,7 +81,7 @@ $this->zip->add_data($name, $data);
            // Write the zip file to a folder on your server. Name it "my_backup.zip"
            $this->zip->archive('/path/to/directory/my_backup.zip');

            - // Download the file to your desktop. Name it "my_backup.zip"
            + // Download the file to your desktop. Name it "my_backup.zip"
            $this->zip->download('my_backup.zip'); @@ -100,7 +100,7 @@ $this->zip->add_data($name, $data);

            You are allowed multiple calls to this function in order to -add several files to your archive. Example:

            +add several files to your archive. Example:

            $name = 'mydata1.txt';
            @@ -139,8 +139,8 @@ $this->zip->add_data($name, $data);

            $this->zip->add_dir()

            -

            Permits you to add a directory. Usually this function is unnecessary since you can place your data into folders when -using $this->zip->add_data(), but if you would like to create an empty folder you can do so. Example:

            +

            Permits you to add a directory. Usually this function is unnecessary since you can place your data into folders when +using $this->zip->add_data(), but if you would like to create an empty folder you can do so. Example:

            $this->zip->add_dir('myfolder'); // Creates a folder called "myfolder" @@ -148,49 +148,49 @@ using $this->zip->add_data(), but if you would like to create an empt

            $this->zip->read_file()

            -

            Permits you to compress a file that already exists somewhere on your server. Supply a file path and the zip class will +

            Permits you to compress a file that already exists somewhere on your server. Supply a file path and the zip class will read it and add it to the archive:

            $path = '/path/to/photo.jpg';

            $this->zip->read_file($path);

            - // Download the file to your desktop. Name it "my_backup.zip"
            + // Download the file to your desktop. Name it "my_backup.zip"
            $this->zip->download('my_backup.zip');

            If you would like the Zip archive to maintain the directory structure of the file in it, pass TRUE (boolean) in the -second parameter. Example:

            +second parameter. Example:

            $path = '/path/to/photo.jpg';

            $this->zip->read_file($path, TRUE);

            - // Download the file to your desktop. Name it "my_backup.zip"
            + // Download the file to your desktop. Name it "my_backup.zip"
            $this->zip->download('my_backup.zip');
            -

            In the above example, photo.jpg will be placed inside two folders: path/to/

            +

            In the above example, photo.jpg will be placed inside two folders: path/to/

            $this->zip->read_dir()

            -

            Permits you to compress a folder (and its contents) that already exists somewhere on your server. Supply a file path to the -directory and the zip class will recursively read it and recreate it as a Zip archive. All files contained within the -supplied path will be encoded, as will any sub-folders contained within it. Example:

            +

            Permits you to compress a folder (and its contents) that already exists somewhere on your server. Supply a file path to the +directory and the zip class will recursively read it and recreate it as a Zip archive. All files contained within the +supplied path will be encoded, as will any sub-folders contained within it. Example:

            $path = '/path/to/your/directory/';

            $this->zip->read_dir($path);

            - // Download the file to your desktop. Name it "my_backup.zip"
            + // Download the file to your desktop. Name it "my_backup.zip"
            $this->zip->download('my_backup.zip');

            By default the Zip archive will place all directories listed in the first parameter inside the zip. If you want the tree preceding the target folder to be ignored -you can pass FALSE (boolean) in the second parameter. Example:

            +you can pass FALSE (boolean) in the second parameter. Example:

            $path = '/path/to/your/directory/';

            @@ -204,7 +204,7 @@ $this->zip->read_dir($path, FALSE);

            $this->zip->archive()

            -

            Writes the Zip-encoded file to a directory on your server. Submit a valid server path ending in the file name. Make sure the +

            Writes the Zip-encoded file to a directory on your server. Submit a valid server path ending in the file name. Make sure the directory is writable (666 or 777 is usually OK). Example:

            $this->zip->archive('/path/to/folder/myarchive.zip'); // Creates a file named myarchive.zip @@ -223,7 +223,7 @@ that cause the download to happen and the file to be treated as binary.

            $this->zip->get_zip()

            -

            Returns the Zip-compressed file data. Generally you will not need this function unless you want to do something unique with the data. +

            Returns the Zip-compressed file data. Generally you will not need this function unless you want to do something unique with the data. Example:

            diff --git a/user_guide/license.html b/user_guide/license.html index ecc5b500d..8f53851a7 100644 --- a/user_guide/license.html +++ b/user_guide/license.html @@ -63,7 +63,7 @@ License Agreement

            Copyright (c) 2008 - 2011, EllisLab, Inc.
            All rights reserved.

            -

            This license is a legal agreement between you and EllisLab Inc. for the use of CodeIgniter Software (the "Software"). By obtaining the Software you agree to comply with the terms and conditions of this license.

            +

            This license is a legal agreement between you and EllisLab Inc. for the use of CodeIgniter Software (the "Software"). By obtaining the Software you agree to comply with the terms and conditions of this license.

            Permitted Use

            You are permitted to use, copy, modify, and distribute the Software and its documentation, with or without modification, for any purpose, provided that the following conditions are met:

            diff --git a/user_guide/nav/hacks.txt b/user_guide/nav/hacks.txt index 183481b78..8c17f008a 100644 --- a/user_guide/nav/hacks.txt +++ b/user_guide/nav/hacks.txt @@ -1,6 +1,6 @@ I did the following hack in moo.fx.js: -At line 79 in the toggle: function() function, I added: +At line 79 in the toggle: function() function, I added: document.getElementById('nav').style.display = 'block'; diff --git a/user_guide/nav/moo.fx.js b/user_guide/nav/moo.fx.js index b21ee20e0..256371d19 100755 --- a/user_guide/nav/moo.fx.js +++ b/user_guide/nav/moo.fx.js @@ -25,8 +25,8 @@ fx.Base.prototype = { }, step: function() { - var time = (new Date).getTime(); - var Tpos = (time - this.startTime) / (this.duration); + var time = (new Date).getTime(); + var Tpos = (time - this.startTime) / (this.duration); if (time >= this.duration+this.startTime) { this.now = this.to; clearInterval (this.timer); diff --git a/user_guide/nav/prototype.lite.js b/user_guide/nav/prototype.lite.js index 857faae4d..e6c362279 100755 --- a/user_guide/nav/prototype.lite.js +++ b/user_guide/nav/prototype.lite.js @@ -1,9 +1,9 @@ -/* Prototype JavaScript framework - * (c) 2005 Sam Stephenson +/* Prototype JavaScript framework + * (c) 2005 Sam Stephenson * - * Prototype is freely distributable under the terms of an MIT-style license. + * Prototype is freely distributable under the terms of an MIT-style license. * - * For details, see the Prototype web site: http://prototype.conio.net/ + * For details, see the Prototype web site: http://prototype.conio.net/ * /*--------------------------------------------------------------------------*/ @@ -11,117 +11,117 @@ //note: this is a stripped down version of prototype, to be used with moo.fx by mad4milk (http://moofx.mad4milk.net). var Class = { - create: function() { + create: function() { return function() { - this.initialize.apply(this, arguments); + this.initialize.apply(this, arguments); } - } + } } Object.extend = function(destination, source) { - for (property in source) { + for (property in source) { destination[property] = source[property]; - } - return destination; + } + return destination; } Function.prototype.bind = function(object) { - var __method = this; - return function() { + var __method = this; + return function() { return __method.apply(object, arguments); - } + } } function $() { - var elements = new Array(); + var elements = new Array(); - for (var i = 0; i < arguments.length; i++) { + for (var i = 0; i < arguments.length; i++) { var element = arguments[i]; if (typeof element == 'string') - element = document.getElementById(element); + element = document.getElementById(element); if (arguments.length == 1) - return element; + return element; elements.push(element); - } + } - return elements; + return elements; } //------------------------- document.getElementsByClassName = function(className) { - var children = document.getElementsByTagName('*') || document.all; - var elements = new Array(); + var children = document.getElementsByTagName('*') || document.all; + var elements = new Array(); - for (var i = 0; i < children.length; i++) { + for (var i = 0; i < children.length; i++) { var child = children[i]; var classNames = child.className.split(' '); for (var j = 0; j < classNames.length; j++) { - if (classNames[j] == className) { + if (classNames[j] == className) { elements.push(child); break; - } + } } - } + } - return elements; + return elements; } //------------------------- if (!window.Element) { - var Element = new Object(); + var Element = new Object(); } Object.extend(Element, { - remove: function(element) { + remove: function(element) { element = $(element); element.parentNode.removeChild(element); - }, + }, - hasClassName: function(element, className) { + hasClassName: function(element, className) { element = $(element); if (!element) - return; + return; var a = element.className.split(' '); for (var i = 0; i < a.length; i++) { - if (a[i] == className) + if (a[i] == className) return true; } return false; - }, + }, - addClassName: function(element, className) { + addClassName: function(element, className) { element = $(element); Element.removeClassName(element, className); element.className += ' ' + className; - }, + }, - removeClassName: function(element, className) { + removeClassName: function(element, className) { element = $(element); if (!element) - return; + return; var newClassName = ''; var a = element.className.split(' '); for (var i = 0; i < a.length; i++) { - if (a[i] != className) { + if (a[i] != className) { if (i > 0) - newClassName += ' '; + newClassName += ' '; newClassName += a[i]; - } + } } element.className = newClassName; - }, + }, - // removes whitespace-only text node children - cleanWhitespace: function(element) { + // removes whitespace-only text node children + cleanWhitespace: function(element) { element = $(element); for (var i = 0; i < element.childNodes.length; i++) { - var node = element.childNodes[i]; - if (node.nodeType == 3 && !/\S/.test(node.nodeValue)) + var node = element.childNodes[i]; + if (node.nodeType == 3 && !/\S/.test(node.nodeValue)) Element.remove(node); } - } + } }); \ No newline at end of file diff --git a/user_guide/overview/appflow.html b/user_guide/overview/appflow.html index 3b1c42e4c..bcbc43ff8 100644 --- a/user_guide/overview/appflow.html +++ b/user_guide/overview/appflow.html @@ -67,7 +67,7 @@ Appflow
          • The index.php serves as the front controller, initializing the base resources needed to run CodeIgniter.
          • The Router examines the HTTP request to determine what should be done with it.
          • If a cache file exists, it is sent directly to the browser, bypassing the normal system execution.
          • -
          • Security. Before the application controller is loaded, the HTTP request and any user submitted data is filtered for security.
          • +
          • Security. Before the application controller is loaded, the HTTP request and any user submitted data is filtered for security.
          • The Controller loads the model, core libraries, helpers, and any other resources needed to process the specific request.
          • The finalized View is rendered then sent to the web browser to be seen. If caching is enabled, the view is cached first so that on subsequent requests it can be served.
          • diff --git a/user_guide/overview/at_a_glance.html b/user_guide/overview/at_a_glance.html index 1175e7f42..b6b81d760 100644 --- a/user_guide/overview/at_a_glance.html +++ b/user_guide/overview/at_a_glance.html @@ -60,7 +60,7 @@ What is CodeIgniter?

            CodeIgniter is an Application Framework

            -

            CodeIgniter is a toolkit for people who build web applications using PHP. Its goal is to enable you to develop projects much faster than you could if you were writing code +

            CodeIgniter is a toolkit for people who build web applications using PHP. Its goal is to enable you to develop projects much faster than you could if you were writing code from scratch, by providing a rich set of libraries for commonly needed tasks, as well as a simple interface and logical structure to access these libraries. CodeIgniter lets you creatively focus on your project by minimizing the amount of code needed for a given task.

            @@ -70,7 +70,7 @@ minimizing the amount of code needed for a given task.

            For more information please read the license agreement.

            CodeIgniter is Light Weight

            -

            Truly light weight. The core system requires only a few very small libraries. This is in stark contrast to many frameworks that require significantly more resources. +

            Truly light weight. The core system requires only a few very small libraries. This is in stark contrast to many frameworks that require significantly more resources. Additional libraries are loaded dynamically upon request, based on your needs for a given process, so the base system is very lean and quite fast.

            @@ -84,7 +84,7 @@ is very lean and quite fast. This is particularly good for projects in which designers are working with your template files, as the code these file contain will be minimized. We describe MVC in more detail on its own page.

            CodeIgniter Generates Clean URLs

            -

            The URLs generated by CodeIgniter are clean and search-engine friendly. Rather than using the standard "query string" +

            The URLs generated by CodeIgniter are clean and search-engine friendly. Rather than using the standard "query string" approach to URLs that is synonymous with dynamic systems, CodeIgniter uses a segment-based approach:

            example.com/news/article/345 @@ -92,7 +92,7 @@ approach to URLs that is synonymous with dynamic systems, CodeIgniter uses a seg

            Note: By default the index.php file is included in the URL but it can be removed using a simple .htaccess file.

            CodeIgniter Packs a Punch

            -

            CodeIgniter comes with full-range of libraries that enable the most commonly needed web development tasks, +

            CodeIgniter comes with full-range of libraries that enable the most commonly needed web development tasks, like accessing a database, sending email, validating form data, maintaining sessions, manipulating images, working with XML-RPC data and much more.

            @@ -104,7 +104,7 @@ much more.

            Although CodeIgniter does come with a simple template parser that can be optionally used, it does not force you to use one. Template engines simply can not match the performance of native PHP, and the syntax that must be learned to use a template -engine is usually only marginally easier than learning the basics of PHP. Consider this block of PHP code:

            +engine is usually only marginally easier than learning the basics of PHP. Consider this block of PHP code:

            <ul>

            @@ -133,7 +133,7 @@ back into PHP to run. Since one of our goals is maximum performance, we

            CodeIgniter is Thoroughly Documented

            -

            Programmers love to code and hate to write documentation. We're no different, of course, but +

            Programmers love to code and hate to write documentation. We're no different, of course, but since documentation is as important as the code itself, we are committed to doing it. Our source code is extremely clean and well commented as well.

            diff --git a/user_guide/overview/features.html b/user_guide/overview/features.html index 4209463b1..e20219e0f 100644 --- a/user_guide/overview/features.html +++ b/user_guide/overview/features.html @@ -59,10 +59,10 @@ Features

            CodeIgniter Features

            Features in and of themselves are a very poor way to judge an application since they tell you nothing -about the user experience, or how intuitively or intelligently it is designed. Features +about the user experience, or how intuitively or intelligently it is designed. Features don't reveal anything about the quality of the code, or the performance, or the attention to detail, or security practices. The only way to really judge an app is to try it and get to know the code. Installing -CodeIgniter is child's play so we encourage you to do just that. In the mean time here's a list of CodeIgniter's main features.

            +CodeIgniter is child's play so we encourage you to do just that. In the mean time here's a list of CodeIgniter's main features.

            • Model-View-Controller Based System
            • @@ -73,7 +73,7 @@ CodeIgniter is child's play so we encourage you to do just that. In the mean tim
            • Security and XSS Filtering
            • Session Management
            • Email Sending Class. Supports Attachments, HTML/Text email, multiple protocols (sendmail, SMTP, and Mail) and more.
            • -
            • Image Manipulation Library (cropping, resizing, rotating, etc.). Supports GD, ImageMagick, and NetPBM
            • +
            • Image Manipulation Library (cropping, resizing, rotating, etc.). Supports GD, ImageMagick, and NetPBM
            • File Uploading Class
            • FTP Class
            • Localization
            • diff --git a/user_guide/overview/getting_started.html b/user_guide/overview/getting_started.html index 168332644..f120913f4 100644 --- a/user_guide/overview/getting_started.html +++ b/user_guide/overview/getting_started.html @@ -57,7 +57,7 @@ Getting Started

              Getting Started With CodeIgniter

              -

              Any software application requires some effort to learn. We've done our best to minimize the learning +

              Any software application requires some effort to learn. We've done our best to minimize the learning curve while making the process as enjoyable as possible.

              diff --git a/user_guide/overview/goals.html b/user_guide/overview/goals.html index 7f1f7678e..754ecaae0 100644 --- a/user_guide/overview/goals.html +++ b/user_guide/overview/goals.html @@ -67,9 +67,9 @@ rejecting anything that doesn't further the stated objective.

              From a technical and architectural standpoint, CodeIgniter was created with the following objectives:

                -
              • Dynamic Instantiation. In CodeIgniter, components are loaded and routines executed only when requested, rather than globally. No assumptions are made by the system regarding what may be needed beyond the minimal core resources, so the system is very light-weight by default. The events, as triggered by the HTTP request, and the controllers and views you design will determine what is invoked.
              • -
              • Loose Coupling. Coupling is the degree to which components of a system rely on each other. The less components depend on each other the more reusable and flexible the system becomes. Our goal was a very loosely coupled system.
              • -
              • Component Singularity. Singularity is the degree to which components have a narrowly focused purpose. In CodeIgniter, each class and its functions are highly autonomous in order to allow maximum usefulness.
              • +
              • Dynamic Instantiation. In CodeIgniter, components are loaded and routines executed only when requested, rather than globally. No assumptions are made by the system regarding what may be needed beyond the minimal core resources, so the system is very light-weight by default. The events, as triggered by the HTTP request, and the controllers and views you design will determine what is invoked.
              • +
              • Loose Coupling. Coupling is the degree to which components of a system rely on each other. The less components depend on each other the more reusable and flexible the system becomes. Our goal was a very loosely coupled system.
              • +
              • Component Singularity. Singularity is the degree to which components have a narrowly focused purpose. In CodeIgniter, each class and its functions are highly autonomous in order to allow maximum usefulness.

              CodeIgniter is a dynamically instantiated, loosely coupled system with high component singularity. It strives for simplicity, flexibility, and high performance in a small footprint package.

              diff --git a/user_guide/overview/mvc.html b/user_guide/overview/mvc.html index 9eb327a95..91cf64977 100644 --- a/user_guide/overview/mvc.html +++ b/user_guide/overview/mvc.html @@ -60,12 +60,12 @@ MVC

              CodeIgniter is based on the Model-View-Controller development pattern. -MVC is a software approach that separates application logic from presentation. In practice, it permits your web pages to contain minimal scripting since the presentation is separate from the PHP scripting.

              +MVC is a software approach that separates application logic from presentation. In practice, it permits your web pages to contain minimal scripting since the presentation is separate from the PHP scripting.

              • The Model represents your data structures. Typically your model classes will contain functions that help you -retrieve, insert, and update information in your database.
              • -
              • The View is the information that is being presented to a user. A View will normally be a web page, but +retrieve, insert, and update information in your database.
              • +
              • The View is the information that is being presented to a user. A View will normally be a web page, but in CodeIgniter, a view can also be a page fragment like a header or footer. It can also be an RSS page, or any other type of "page".
              • The Controller serves as an intermediary between the Model, the View, and any other resources needed to process the HTTP request and generate a web page.
              • diff --git a/user_guide/userguide.css b/user_guide/userguide.css index b08f4fb00..f93ff0d75 100644 --- a/user_guide/userguide.css +++ b/user_guide/userguide.css @@ -391,7 +391,7 @@ form { .select { background-color: #fff; - font-size: 11px; + font-size: 11px; font-weight: normal; color: #333; padding: 0; -- cgit v1.2.3-24-g4f1b From 26675f6426a288af220669ef88bc37d3392f50eb Mon Sep 17 00:00:00 2001 From: Derek Jones Date: Sun, 3 Jul 2011 07:21:47 -0500 Subject: reverted texb.ttf font which had been compromised in 982b43c3590a by another massive whitespace 'cleanup' commit --- system/fonts/texb.ttf | Bin 152992 -> 143830 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/system/fonts/texb.ttf b/system/fonts/texb.ttf index 6792342a3..383c88b86 100644 Binary files a/system/fonts/texb.ttf and b/system/fonts/texb.ttf differ -- cgit v1.2.3-24-g4f1b From 9789f321cd52139d36d1479f07fff3897be48107 Mon Sep 17 00:00:00 2001 From: Phil Sturgeon Date: Fri, 15 Jul 2011 15:14:05 -0600 Subject: Was working on this file so PHP5ified the method visibility scopes. Pointless, but was adding... --- system/database/DB_active_rec.php | 260 ++++++++++++++++---------------------- 1 file changed, 106 insertions(+), 154 deletions(-) diff --git a/system/database/DB_active_rec.php b/system/database/DB_active_rec.php index 52bad260a..7ddf20d07 100644 --- a/system/database/DB_active_rec.php +++ b/system/database/DB_active_rec.php @@ -69,11 +69,10 @@ class CI_DB_active_record extends CI_DB_driver { * * Generates the SELECT portion of the query * - * @access public * @param string * @return object */ - function select($select = '*', $escape = NULL) + public function select($select = '*', $escape = NULL) { if (is_string($select)) { @@ -107,12 +106,11 @@ class CI_DB_active_record extends CI_DB_driver { * * Generates a SELECT MAX(field) portion of a query * - * @access public * @param string the field * @param string an alias * @return object */ - function select_max($select = '', $alias = '') + public function select_max($select = '', $alias = '') { return $this->_max_min_avg_sum($select, $alias, 'MAX'); } @@ -124,12 +122,11 @@ class CI_DB_active_record extends CI_DB_driver { * * Generates a SELECT MIN(field) portion of a query * - * @access public * @param string the field * @param string an alias * @return object */ - function select_min($select = '', $alias = '') + public function select_min($select = '', $alias = '') { return $this->_max_min_avg_sum($select, $alias, 'MIN'); } @@ -141,12 +138,11 @@ class CI_DB_active_record extends CI_DB_driver { * * Generates a SELECT AVG(field) portion of a query * - * @access public * @param string the field * @param string an alias * @return object */ - function select_avg($select = '', $alias = '') + public function select_avg($select = '', $alias = '') { return $this->_max_min_avg_sum($select, $alias, 'AVG'); } @@ -158,12 +154,11 @@ class CI_DB_active_record extends CI_DB_driver { * * Generates a SELECT SUM(field) portion of a query * - * @access public * @param string the field * @param string an alias * @return object */ - function select_sum($select = '', $alias = '') + public function select_sum($select = '', $alias = '') { return $this->_max_min_avg_sum($select, $alias, 'SUM'); } @@ -178,12 +173,11 @@ class CI_DB_active_record extends CI_DB_driver { * select_avg() * select_sum() * - * @access public * @param string the field * @param string an alias * @return object */ - function _max_min_avg_sum($select = '', $alias = '', $type = 'MAX') + protected function _max_min_avg_sum($select = '', $alias = '', $type = 'MAX') { if ( ! is_string($select) OR $select == '') { @@ -220,11 +214,10 @@ class CI_DB_active_record extends CI_DB_driver { /** * Determines the alias name based on the table * - * @access private * @param string * @return string */ - function _create_alias_from_table($item) + protected function _create_alias_from_table($item) { if (strpos($item, '.') !== FALSE) { @@ -241,11 +234,10 @@ class CI_DB_active_record extends CI_DB_driver { * * Sets a flag which tells the query string compiler to add DISTINCT * - * @access public * @param bool * @return object */ - function distinct($val = TRUE) + public function distinct($val = TRUE) { $this->ar_distinct = (is_bool($val)) ? $val : TRUE; return $this; @@ -258,11 +250,10 @@ class CI_DB_active_record extends CI_DB_driver { * * Generates the FROM portion of the query * - * @access public * @param mixed can be a string or array * @return object */ - function from($from) + public function from($from) { foreach ((array)$from as $val) { @@ -311,13 +302,12 @@ class CI_DB_active_record extends CI_DB_driver { * * Generates the JOIN portion of the query * - * @access public * @param string * @param string the join condition * @param string the type of join * @return object */ - function join($table, $cond, $type = '') + public function join($table, $cond, $type = '') { if ($type != '') { @@ -367,12 +357,11 @@ class CI_DB_active_record extends CI_DB_driver { * Generates the WHERE portion of the query. Separates * multiple calls with AND * - * @access public * @param mixed * @param mixed * @return object */ - function where($key, $value = NULL, $escape = TRUE) + public function where($key, $value = NULL, $escape = TRUE) { return $this->_where($key, $value, 'AND ', $escape); } @@ -385,12 +374,11 @@ class CI_DB_active_record extends CI_DB_driver { * Generates the WHERE portion of the query. Separates * multiple calls with OR * - * @access public * @param mixed * @param mixed * @return object */ - function or_where($key, $value = NULL, $escape = TRUE) + public function or_where($key, $value = NULL, $escape = TRUE) { return $this->_where($key, $value, 'OR ', $escape); } @@ -400,15 +388,14 @@ class CI_DB_active_record extends CI_DB_driver { /** * Where * - * Called by where() or orwhere() + * Called by where() or or_where() * - * @access private * @param mixed * @param mixed * @param string * @return object */ - function _where($key, $value = NULL, $type = 'AND ', $escape = NULL) + protected function _where($key, $value = NULL, $type = 'AND ', $escape = NULL) { if ( ! is_array($key)) { @@ -471,12 +458,11 @@ class CI_DB_active_record extends CI_DB_driver { * Generates a WHERE field IN ('item', 'item') SQL query joined with * AND if appropriate * - * @access public * @param string The field to search * @param array The values searched on * @return object */ - function where_in($key = NULL, $values = NULL) + public function where_in($key = NULL, $values = NULL) { return $this->_where_in($key, $values); } @@ -489,12 +475,11 @@ class CI_DB_active_record extends CI_DB_driver { * Generates a WHERE field IN ('item', 'item') SQL query joined with * OR if appropriate * - * @access public * @param string The field to search * @param array The values searched on * @return object */ - function or_where_in($key = NULL, $values = NULL) + public function or_where_in($key = NULL, $values = NULL) { return $this->_where_in($key, $values, FALSE, 'OR '); } @@ -507,12 +492,11 @@ class CI_DB_active_record extends CI_DB_driver { * Generates a WHERE field NOT IN ('item', 'item') SQL query joined * with AND if appropriate * - * @access public * @param string The field to search * @param array The values searched on * @return object */ - function where_not_in($key = NULL, $values = NULL) + public function where_not_in($key = NULL, $values = NULL) { return $this->_where_in($key, $values, TRUE); } @@ -525,12 +509,11 @@ class CI_DB_active_record extends CI_DB_driver { * Generates a WHERE field NOT IN ('item', 'item') SQL query joined * with OR if appropriate * - * @access public * @param string The field to search * @param array The values searched on * @return object */ - function or_where_not_in($key = NULL, $values = NULL) + public function or_where_not_in($key = NULL, $values = NULL) { return $this->_where_in($key, $values, TRUE, 'OR '); } @@ -542,14 +525,13 @@ class CI_DB_active_record extends CI_DB_driver { * * Called by where_in, where_in_or, where_not_in, where_not_in_or * - * @access public * @param string The field to search * @param array The values searched on * @param boolean If the statement would be IN or NOT IN * @param string * @return object */ - function _where_in($key = NULL, $values = NULL, $not = FALSE, $type = 'AND ') + protected function _where_in($key = NULL, $values = NULL, $not = FALSE, $type = 'AND ') { if ($key === NULL OR $values === NULL) { @@ -592,12 +574,11 @@ class CI_DB_active_record extends CI_DB_driver { * Generates a %LIKE% portion of the query. Separates * multiple calls with AND * - * @access public * @param mixed * @param mixed * @return object */ - function like($field, $match = '', $side = 'both') + public function like($field, $match = '', $side = 'both') { return $this->_like($field, $match, 'AND ', $side); } @@ -610,12 +591,11 @@ class CI_DB_active_record extends CI_DB_driver { * Generates a NOT LIKE portion of the query. Separates * multiple calls with AND * - * @access public * @param mixed * @param mixed * @return object */ - function not_like($field, $match = '', $side = 'both') + public function not_like($field, $match = '', $side = 'both') { return $this->_like($field, $match, 'AND ', $side, 'NOT'); } @@ -628,12 +608,11 @@ class CI_DB_active_record extends CI_DB_driver { * Generates a %LIKE% portion of the query. Separates * multiple calls with OR * - * @access public * @param mixed * @param mixed * @return object */ - function or_like($field, $match = '', $side = 'both') + public function or_like($field, $match = '', $side = 'both') { return $this->_like($field, $match, 'OR ', $side); } @@ -646,12 +625,11 @@ class CI_DB_active_record extends CI_DB_driver { * Generates a NOT LIKE portion of the query. Separates * multiple calls with OR * - * @access public * @param mixed * @param mixed * @return object */ - function or_not_like($field, $match = '', $side = 'both') + public function or_not_like($field, $match = '', $side = 'both') { return $this->_like($field, $match, 'OR ', $side, 'NOT'); } @@ -663,13 +641,12 @@ class CI_DB_active_record extends CI_DB_driver { * * Called by like() or orlike() * - * @access private * @param mixed * @param mixed * @param string * @return object */ - function _like($field, $match = '', $type = 'AND ', $side = 'both', $not = '') + protected function _like($field, $match = '', $type = 'AND ', $side = 'both', $not = '') { if ( ! is_array($field)) { @@ -719,11 +696,10 @@ class CI_DB_active_record extends CI_DB_driver { /** * GROUP BY * - * @access public * @param string * @return object */ - function group_by($by) + public function group_by($by) { if (is_string($by)) { @@ -755,12 +731,11 @@ class CI_DB_active_record extends CI_DB_driver { * * Separates multiple calls with AND * - * @access public * @param string * @param string * @return object */ - function having($key, $value = '', $escape = TRUE) + public function having($key, $value = '', $escape = TRUE) { return $this->_having($key, $value, 'AND ', $escape); } @@ -772,12 +747,11 @@ class CI_DB_active_record extends CI_DB_driver { * * Separates multiple calls with OR * - * @access public * @param string * @param string * @return object */ - function or_having($key, $value = '', $escape = TRUE) + public function or_having($key, $value = '', $escape = TRUE) { return $this->_having($key, $value, 'OR ', $escape); } @@ -789,12 +763,11 @@ class CI_DB_active_record extends CI_DB_driver { * * Called by having() or or_having() * - * @access private * @param string * @param string * @return object */ - function _having($key, $value = '', $type = 'AND ', $escape = TRUE) + protected function _having($key, $value = '', $type = 'AND ', $escape = TRUE) { if ( ! is_array($key)) { @@ -836,12 +809,11 @@ class CI_DB_active_record extends CI_DB_driver { /** * Sets the ORDER BY value * - * @access public * @param string * @param string direction: asc or desc * @return object */ - function order_by($orderby, $direction = '') + public function order_by($orderby, $direction = '') { if (strtolower($direction) == 'random') { @@ -892,12 +864,11 @@ class CI_DB_active_record extends CI_DB_driver { /** * Sets the LIMIT value * - * @access public * @param integer the limit value * @param integer the offset value * @return object */ - function limit($value, $offset = '') + public function limit($value, $offset = '') { $this->ar_limit = $value; @@ -914,11 +885,10 @@ class CI_DB_active_record extends CI_DB_driver { /** * Sets the OFFSET value * - * @access public * @param integer the offset value * @return object */ - function offset($offset) + public function offset($offset) { $this->ar_offset = $offset; return $this; @@ -929,13 +899,12 @@ class CI_DB_active_record extends CI_DB_driver { /** * The "set" function. Allows key/value pairs to be set for inserting or updating * - * @access public * @param mixed * @param string * @param boolean * @return object */ - function set($key, $value = '', $escape = TRUE) + public function set($key, $value = '', $escape = TRUE) { $key = $this->_object_to_array($key); @@ -967,13 +936,12 @@ class CI_DB_active_record extends CI_DB_driver { * Compiles the select statement based on the other functions called * and runs the query * - * @access public * @param string the table * @param string the limit clause * @param string the offset clause * @return object */ - function get($table = '', $limit = null, $offset = null) + public function get($table = '', $limit = null, $offset = null) { if ($table != '') { @@ -999,11 +967,10 @@ class CI_DB_active_record extends CI_DB_driver { * Generates a platform-specific query string that counts all records * returned by an Active Record query. * - * @access public * @param string * @return string */ - function count_all_results($table = '') + public function count_all_results($table = '') { if ($table != '') { @@ -1032,13 +999,12 @@ class CI_DB_active_record extends CI_DB_driver { * * Allows the where clause, limit and offset to be added directly * - * @access public * @param string the where clause * @param string the limit clause * @param string the offset clause * @return object */ - function get_where($table = '', $where = null, $limit = null, $offset = null) + public function get_where($table = '', $where = null, $limit = null, $offset = null) { if ($table != '') { @@ -1069,12 +1035,11 @@ class CI_DB_active_record extends CI_DB_driver { * * Compiles batch insert strings and runs the queries * - * @access public * @param string the table to retrieve the results from * @param array an associative array of insert values * @return object */ - function insert_batch($table = '', $set = NULL) + public function insert_batch($table = '', $set = NULL) { if ( ! is_null($set)) { @@ -1127,14 +1092,12 @@ class CI_DB_active_record extends CI_DB_driver { /** * The "set_insert_batch" function. Allows key/value pairs to be set for batch inserts * - * @access public * @param mixed * @param string * @param boolean * @return object */ - - function set_insert_batch($key, $value = '', $escape = TRUE) + public function set_insert_batch($key, $value = '', $escape = TRUE) { $key = $this->_object_to_array_batch($key); @@ -1189,8 +1152,7 @@ class CI_DB_active_record extends CI_DB_driver { * * Compiles an insert string and runs the query * - * @access public - * @param string the table to retrieve the results from + * @param string the table to insert data into * @param array an associative array of insert values * @return object */ @@ -1230,7 +1192,18 @@ class CI_DB_active_record extends CI_DB_driver { return $this->query($sql); } - function replace($table = '', $set = NULL) + // -------------------------------------------------------------------- + + /** + * Replace + * + * Compiles an replace into string and runs the query + * + * @param string the table to replace data into + * @param array an associative array of insert values + * @return object + */ + public function replace($table = '', $set = NULL) { if ( ! is_null($set)) { @@ -1273,13 +1246,12 @@ class CI_DB_active_record extends CI_DB_driver { * * Compiles an update string and runs the query * - * @access public * @param string the table to retrieve the results from * @param array an associative array of update values * @param mixed the where clause * @return object */ - function update($table = '', $set = NULL, $where = NULL, $limit = NULL) + public function update($table = '', $set = NULL, $where = NULL, $limit = NULL) { // Combine any cached components with the current statements $this->_merge_cache(); @@ -1336,13 +1308,12 @@ class CI_DB_active_record extends CI_DB_driver { * * Compiles an update string and runs the query * - * @access public * @param string the table to retrieve the results from * @param array an associative array of update values * @param string the where key * @return object */ - function update_batch($table = '', $set = NULL, $index = NULL) + public function update_batch($table = '', $set = NULL, $index = NULL) { // Combine any cached components with the current statements $this->_merge_cache(); @@ -1402,14 +1373,12 @@ class CI_DB_active_record extends CI_DB_driver { /** * The "set_update_batch" function. Allows key/value pairs to be set for batch updating * - * @access public * @param array * @param string * @param boolean * @return object */ - - function set_update_batch($key, $index = '', $escape = TRUE) + public function set_update_batch($key, $index = '', $escape = TRUE) { $key = $this->_object_to_array_batch($key); @@ -1462,11 +1431,10 @@ class CI_DB_active_record extends CI_DB_driver { * * Compiles a delete string and runs "DELETE FROM table" * - * @access public * @param string the table to empty * @return object */ - function empty_table($table = '') + public function empty_table($table = '') { if ($table == '') { @@ -1502,11 +1470,10 @@ class CI_DB_active_record extends CI_DB_driver { * If the database does not support the truncate() command * This function maps to "DELETE FROM table" * - * @access public * @param string the table to truncate * @return object */ - function truncate($table = '') + public function truncate($table = '') { if ($table == '') { @@ -1540,14 +1507,13 @@ class CI_DB_active_record extends CI_DB_driver { * * Compiles a delete string and runs the query * - * @access public * @param mixed the table(s) to delete from. String or array * @param mixed the where clause * @param mixed the limit clause * @param boolean * @return object */ - function delete($table = '', $where = '', $limit = NULL, $reset_data = TRUE) + public function delete($table = '', $where = '', $limit = NULL, $reset_data = TRUE) { // Combine any cached components with the current statements $this->_merge_cache(); @@ -1617,11 +1583,10 @@ class CI_DB_active_record extends CI_DB_driver { * * Prepends a database prefix if one exists in configuration * - * @access public * @param string the table * @return string */ - function dbprefix($table = '') + public function dbprefix($table = '') { if ($table == '') { @@ -1638,11 +1603,10 @@ class CI_DB_active_record extends CI_DB_driver { * * Used to track SQL statements written with aliased tables. * - * @access private * @param string The table to inspect * @return string */ - function _track_aliases($table) + protected function _track_aliases($table) { if (is_array($table)) { @@ -1685,10 +1649,9 @@ class CI_DB_active_record extends CI_DB_driver { * Generates a query string based on which functions were used. * Should not be called directly. The get() function calls it. * - * @access private * @return string */ - function _compile_select($select_override = FALSE) + protected function _compile_select($select_override = FALSE) { // Combine any cached components with the current statements $this->_merge_cache(); @@ -1826,11 +1789,10 @@ class CI_DB_active_record extends CI_DB_driver { * * Takes an object as input and converts the class variables to array key/vals * - * @access public * @param object * @return array */ - function _object_to_array($object) + public function _object_to_array($object) { if ( ! is_object($object)) { @@ -1857,11 +1819,10 @@ class CI_DB_active_record extends CI_DB_driver { * * Takes an object as input and converts the class variables to array key/vals * - * @access public * @param object * @return array */ - function _object_to_array_batch($object) + public function _object_to_array_batch($object) { if ( ! is_object($object)) { @@ -1897,10 +1858,9 @@ class CI_DB_active_record extends CI_DB_driver { * * Starts AR caching * - * @access public * @return void */ - function start_cache() + public function start_cache() { $this->ar_caching = TRUE; } @@ -1912,10 +1872,9 @@ class CI_DB_active_record extends CI_DB_driver { * * Stops AR caching * - * @access public * @return void */ - function stop_cache() + public function stop_cache() { $this->ar_caching = FALSE; } @@ -1930,23 +1889,21 @@ class CI_DB_active_record extends CI_DB_driver { * @access public * @return void */ - function flush_cache() + public function flush_cache() { - $this->_reset_run( - array( - 'ar_cache_select' => array(), - 'ar_cache_from' => array(), - 'ar_cache_join' => array(), - 'ar_cache_where' => array(), - 'ar_cache_like' => array(), - 'ar_cache_groupby' => array(), - 'ar_cache_having' => array(), - 'ar_cache_orderby' => array(), - 'ar_cache_set' => array(), - 'ar_cache_exists' => array(), - 'ar_cache_no_escape' => array() - ) - ); + $this->_reset_run(array( + 'ar_cache_select' => array(), + 'ar_cache_from' => array(), + 'ar_cache_join' => array(), + 'ar_cache_where' => array(), + 'ar_cache_like' => array(), + 'ar_cache_groupby' => array(), + 'ar_cache_having' => array(), + 'ar_cache_orderby' => array(), + 'ar_cache_set' => array(), + 'ar_cache_exists' => array(), + 'ar_cache_no_escape' => array() + )); } // -------------------------------------------------------------------- @@ -1957,10 +1914,9 @@ class CI_DB_active_record extends CI_DB_driver { * When called, this function merges any cached AR arrays with * locally called ones. * - * @access private * @return void */ - function _merge_cache() + protected function _merge_cache() { if (count($this->ar_cache_exists) == 0) { @@ -1995,11 +1951,10 @@ class CI_DB_active_record extends CI_DB_driver { /** * Resets the active record values. Called by the get() function * - * @access private * @param array An array of fields to reset * @return void */ - function _reset_run($ar_reset_items) + protected function _reset_run($ar_reset_items) { foreach ($ar_reset_items as $item => $default_value) { @@ -2015,28 +1970,27 @@ class CI_DB_active_record extends CI_DB_driver { /** * Resets the active record values. Called by the get() function * - * @access private * @return void */ - function _reset_select() + protected function _reset_select() { $ar_reset_items = array( - 'ar_select' => array(), - 'ar_from' => array(), - 'ar_join' => array(), - 'ar_where' => array(), - 'ar_like' => array(), - 'ar_groupby' => array(), - 'ar_having' => array(), - 'ar_orderby' => array(), - 'ar_wherein' => array(), - 'ar_aliased_tables' => array(), - 'ar_no_escape' => array(), - 'ar_distinct' => FALSE, - 'ar_limit' => FALSE, - 'ar_offset' => FALSE, - 'ar_order' => FALSE, - ); + 'ar_select' => array(), + 'ar_from' => array(), + 'ar_join' => array(), + 'ar_where' => array(), + 'ar_like' => array(), + 'ar_groupby' => array(), + 'ar_having' => array(), + 'ar_orderby' => array(), + 'ar_wherein' => array(), + 'ar_aliased_tables' => array(), + 'ar_no_escape' => array(), + 'ar_distinct' => FALSE, + 'ar_limit' => FALSE, + 'ar_offset' => FALSE, + 'ar_order' => FALSE, + ); $this->_reset_run($ar_reset_items); } @@ -2048,25 +2002,23 @@ class CI_DB_active_record extends CI_DB_driver { * * Called by the insert() update() insert_batch() update_batch() and delete() functions * - * @access private * @return void */ - function _reset_write() + protected function _reset_write() { $ar_reset_items = array( - 'ar_set' => array(), - 'ar_from' => array(), - 'ar_where' => array(), - 'ar_like' => array(), - 'ar_orderby' => array(), - 'ar_keys' => array(), - 'ar_limit' => FALSE, - 'ar_order' => FALSE - ); + 'ar_set' => array(), + 'ar_from' => array(), + 'ar_where' => array(), + 'ar_like' => array(), + 'ar_orderby' => array(), + 'ar_keys' => array(), + 'ar_limit' => FALSE, + 'ar_order' => FALSE + ); $this->_reset_run($ar_reset_items); } - } /* End of file DB_active_rec.php */ -- cgit v1.2.3-24-g4f1b From 8a02247acbac87b3b947d9188ec4f5805f2e1a52 Mon Sep 17 00:00:00 2001 From: Phil Sturgeon Date: Fri, 15 Jul 2011 15:25:15 -0600 Subject: ... set_dbprefix(). Programatically set the prefix, great for multi-site systems that "namespace" with prefixes. --- system/database/DB_active_rec.php | 15 +++++++++++++++ user_guide/changelog.html | 1 + user_guide/database/queries.html | 9 +++++++-- 3 files changed, 23 insertions(+), 2 deletions(-) diff --git a/system/database/DB_active_rec.php b/system/database/DB_active_rec.php index 7ddf20d07..bc11ff436 100644 --- a/system/database/DB_active_rec.php +++ b/system/database/DB_active_rec.php @@ -1598,6 +1598,21 @@ class CI_DB_active_record extends CI_DB_driver { // -------------------------------------------------------------------- + /** + * Set DB Prefix + * + * Set's the DB Prefix to something new without needing to reconnect + * + * @param string the prefix + * @return string + */ + public function set_dbprefix($prefix = '') + { + return $this->dbprefix = $prefix; + } + + // -------------------------------------------------------------------- + /** * Track Aliases * diff --git a/user_guide/changelog.html b/user_guide/changelog.html index a841785f0..a924edc9c 100644 --- a/user_guide/changelog.html +++ b/user_guide/changelog.html @@ -86,6 +86,7 @@ Change Log
                • Altered Session to use a longer match against the user_agent string. See upgrade notes if using database sessions.
                • Added is_unique to the Form Validation library.
                • +
                • Added $this->db->set_dbprefix() to the Database Driver.
              diff --git a/user_guide/database/queries.html b/user_guide/database/queries.html index f9f96803f..4c1ddfe7d 100644 --- a/user_guide/database/queries.html +++ b/user_guide/database/queries.html @@ -80,11 +80,16 @@ It DOES NOT return a database result set, nor does it set the query timer, or co It simply lets you submit a query. Most users will rarely use this function.

              -

              Adding Database prefixes manually

              -

              If you have configured a database prefix and would like to add it in manually for, you can use the following.

              +

              Working with Database prefixes manually

              +

              If you have configured a database prefix and would like to prepend it to a table name for use in a native SQL query for example, then you can use the following:

              $this->db->dbprefix('tablename');
              // outputs prefix_tablename

              +

              If for any reason you would like to change the prefix programatically without needing to create a new connection, you can use this method:

              +

              $this->db->set_dbprefix('newprefix');

              +$this->db->dbprefix('tablename');
              +// outputs newprefix_tablename

              +

              Protecting identifiers

              In many databases it is advisable to protect table and field names - for example with backticks in MySQL. Active Record queries are automatically protected, however if you need to manually protect an identifier you can use:

              -- cgit v1.2.3-24-g4f1b From 1b1b67693060ecb6dd399ea6aee4a5503d96adda Mon Sep 17 00:00:00 2001 From: Phil Sturgeon Date: Fri, 15 Jul 2011 19:37:31 -0600 Subject: enable use of param in a callback rule, on behalf of marcoscoelho. --- system/libraries/Form_validation.php | 2 +- user_guide/changelog.html | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/system/libraries/Form_validation.php b/system/libraries/Form_validation.php index d370d75ee..fd95d76fa 100644 --- a/system/libraries/Form_validation.php +++ b/system/libraries/Form_validation.php @@ -488,7 +488,7 @@ class CI_Form_validation { if ( ! in_array('required', $rules) AND is_null($postdata)) { // Before we bail out, does the rule contain a callback? - if (preg_match("/(callback_\w+)/", implode(' ', $rules), $match)) + if (preg_match("/(callback_\w+(\[.*?\])?)/", implode(' ', $rules), $match)) { $callback = TRUE; $rules = (array('1' => $match[1])); diff --git a/user_guide/changelog.html b/user_guide/changelog.html index a924edc9c..8a6fea748 100644 --- a/user_guide/changelog.html +++ b/user_guide/changelog.html @@ -75,6 +75,7 @@ Change Log
            • Removed internal usage of the EXT constant.
            • 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.
            • +
            • Callback validation rules can now accept parameters like any other validation rule.
          • Helpers -- cgit v1.2.3-24-g4f1b From c28b2855e572f744f66aebe1d6a09b1b2d25e8ad Mon Sep 17 00:00:00 2001 From: Marcos Coelho Date: Tue, 5 Jul 2011 12:59:41 -0700 Subject: enable use of param in a callback rule; it's a sugestion of solution, another way can be used, this feature seems forgotten; --- system/libraries/Form_validation.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/system/libraries/Form_validation.php b/system/libraries/Form_validation.php index d370d75ee..a34809e05 100644 --- a/system/libraries/Form_validation.php +++ b/system/libraries/Form_validation.php @@ -488,7 +488,7 @@ class CI_Form_validation { if ( ! in_array('required', $rules) AND is_null($postdata)) { // Before we bail out, does the rule contain a callback? - if (preg_match("/(callback_\w+)/", implode(' ', $rules), $match)) + if (preg_match("/(callback_\w+(\[.*?\])?)/", implode(' ', $rules), $match)) { $callback = TRUE; $rules = (array('1' => $match[1])); @@ -1378,4 +1378,4 @@ class CI_Form_validation { // END Form Validation Class /* End of file Form_validation.php */ -/* Location: ./system/libraries/Form_validation.php */ \ No newline at end of file +/* Location: ./system/libraries/Form_validation.php */ -- cgit v1.2.3-24-g4f1b From 7dafce416ebbfa5a2a43c4fd40be5ab4e81bc739 Mon Sep 17 00:00:00 2001 From: MarcosCoelho Date: Sat, 16 Jul 2011 02:57:47 -0300 Subject: explains how use a parameter/argument (optional) in your callback rule declaration --- user_guide/libraries/form_validation.html | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/user_guide/libraries/form_validation.html b/user_guide/libraries/form_validation.html index bba8f507e..da2f5e5e8 100644 --- a/user_guide/libraries/form_validation.html +++ b/user_guide/libraries/form_validation.html @@ -508,11 +508,9 @@ create a callback function that does that. Let's create a example of this.

            $this->form_validation->set_rules('username', 'Username', 'callback_username_check'); -

            Then add a new function called username_check to your controller. Here's how your controller should now look:

            - -