diff --git a/.hgflow b/.hgflow new file mode 100644 index 00000000..ad6e56e0 --- /dev/null +++ b/.hgflow @@ -0,0 +1,8 @@ +[Basic] +develop = develop +feature = feature/ +version_tag = +publish = default +release = release/ +hotfix = hotfix/ + diff --git a/.hgignore b/.hgignore index 880040b3..5ee4d823 100644 --- a/.hgignore +++ b/.hgignore @@ -3,4 +3,5 @@ syntax: glob .DS_Store syntax: regexp -system/cache/(?!index\.html|\.htaccess) \ No newline at end of file +application/cache/(?!index\.html|\.htaccess) +application/logs/(?!index\.html|\.htaccess) diff --git a/.hgtags b/.hgtags index 8fb6def3..d14ae5a4 100644 --- a/.hgtags +++ b/.hgtags @@ -6,3 +6,18 @@ be717c80433bd1466202ea00d40e5dae5239f952 v1.6.1 c859ee06332f440d2135b916d3a9c926708de72a v1.6.3 3b6f3beea1262d35735167ee77c1fa8ea8d78d0c v1.7.2 0000000000000000000000000000000000000000 v1.7.2 +ca87887086193cf375ea30e7d4e5139dbf330783 v2.0.0 +1941a814526f8aa7186112e6b9bfd868c5c4afbf v2.0.1 +1941a814526f8aa7186112e6b9bfd868c5c4afbf v2.0.1 +0000000000000000000000000000000000000000 v2.0.1 +0000000000000000000000000000000000000000 v2.0.1 +f97a33039a37fc0c3f12e48407ca08e281b6b375 v2.0.1 +f97a33039a37fc0c3f12e48407ca08e281b6b375 v2.0.1 +0000000000000000000000000000000000000000 v2.0.1 +0000000000000000000000000000000000000000 v2.0.1 +52cd3ed4a9ea5c2b0e2bdd38e9822161ef547f9a v2.0.1 +52cd3ed4a9ea5c2b0e2bdd38e9822161ef547f9a v2.0.1 +0000000000000000000000000000000000000000 v2.0.1 +0000000000000000000000000000000000000000 v2.0.1 +1941a814526f8aa7186112e6b9bfd868c5c4afbf v2.0.1 +52107601203719d6149219b28ec93d1d90c748a7 v2.0.2 diff --git a/system/cache/.htaccess b/application/cache/.htaccess similarity index 100% rename from system/cache/.htaccess rename to application/cache/.htaccess diff --git a/system/cache/index.html b/application/cache/index.html similarity index 100% rename from system/cache/index.html rename to application/cache/index.html diff --git a/application/config/autoload.php b/application/config/autoload.php index 90b1a808..53129c9c 100644 --- a/application/config/autoload.php +++ b/application/config/autoload.php @@ -37,7 +37,7 @@ | */ -$autoload['packages'] = array(APPPATH.'third_party'); +$autoload['packages'] = array(); /* diff --git a/application/config/config.php b/application/config/config.php index 5c6cc0ae..1ec65435 100644 --- a/application/config/config.php +++ b/application/config/config.php @@ -262,11 +262,13 @@ | 'cookie_prefix' = Set a prefix if you need to avoid collisions | 'cookie_domain' = Set to .your-domain.com for site-wide cookies | 'cookie_path' = Typically will be a forward slash +| 'cookie_secure' = Cookies will only be set if a secure HTTPS connection exists. | */ -$config['cookie_prefix'] = ''; -$config['cookie_domain'] = ''; -$config['cookie_path'] = '/'; +$config['cookie_prefix'] = ""; +$config['cookie_domain'] = ""; +$config['cookie_path'] = "/"; +$config['cookie_secure'] = FALSE; /* |-------------------------------------------------------------------------- @@ -286,9 +288,15 @@ | Enables a CSRF cookie token to be set. When set to TRUE, token will be | checked on a submitted form. If you are accepting user data, it is strongly | recommended CSRF protection be enabled. +| +| 'csrf_token_name' = The token name +| 'csrf_cookie_name' = The cookie name +| 'csrf_expire' = The number in seconds the token should expire. */ $config['csrf_protection'] = FALSE; - +$config['csrf_token_name'] = 'csrf_test_name'; +$config['csrf_cookie_name'] = 'csrf_cookie_name'; +$config['csrf_expire'] = 7200; /* |-------------------------------------------------------------------------- @@ -351,4 +359,4 @@ /* End of file config.php */ -/* Location: ./application/config/config.php */ \ No newline at end of file +/* Location: ./application/config/config.php */ diff --git a/application/config/database.php b/application/config/database.php index 24d611ac..b4b34bf6 100644 --- a/application/config/database.php +++ b/application/config/database.php @@ -26,6 +26,13 @@ | ['cachedir'] The path to the folder where cache files should be stored | ['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 +| (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. | ['swap_pre'] A default table prefix that should be swapped with the dbprefix | ['autoinit'] Whether or not to automatically initialize the database. | ['stricton'] TRUE/FALSE - forces 'Strict Mode' connections diff --git a/application/config/migration.php b/application/config/migration.php new file mode 100644 index 00000000..509fd90a --- /dev/null +++ b/application/config/migration.php @@ -0,0 +1,42 @@ +migration->latest() this is the version that schema will +| be upgraded / downgraded to. +| +*/ +$config['migration_version'] = 0; + + +/* +|-------------------------------------------------------------------------- +| Migrations Path +|-------------------------------------------------------------------------- +| +| Path to your migrations folder. +| Typically, it will be within your application path. +| Also, writing permission is required within the migrations path. +| +*/ +$config['migration_path'] = APPPATH . 'migrations/'; + + +/* End of file migration.php */ +/* Location: ./application/config/migration.php */ \ No newline at end of file diff --git a/application/config/mimes.php b/application/config/mimes.php index 3815a5aa..8065794f 100644 --- a/application/config/mimes.php +++ b/application/config/mimes.php @@ -56,7 +56,7 @@ 'midi' => 'audio/midi', 'mpga' => 'audio/mpeg', 'mp2' => 'audio/mpeg', - 'mp3' => array('audio/mpeg', 'audio/mpg'), + 'mp3' => array('audio/mpeg', 'audio/mpg', 'audio/mpeg3', 'audio/mp3'), 'aif' => 'audio/x-aiff', 'aiff' => 'audio/x-aiff', 'aifc' => 'audio/x-aiff', @@ -97,7 +97,8 @@ 'xlsx' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', 'word' => array('application/msword', 'application/octet-stream'), 'xl' => 'application/excel', - 'eml' => 'message/rfc822' + 'eml' => 'message/rfc822', + 'json' => array('application/json', 'text/json') ); diff --git a/application/controllers/test_redis.php b/application/controllers/test_redis.php new file mode 100644 index 00000000..576c77a2 --- /dev/null +++ b/application/controllers/test_redis.php @@ -0,0 +1,43 @@ +load->library('unit_test'); + + $this->load->driver('cache', array('adapter' => 'redis')); + } + + function index() + { + $this->unit->run($this->cache->redis->is_supported(), 'is_true'); + + $this->unit->run($this->cache->redis->save('foo', 'bar'), 'is_true'); + + $this->unit->run($this->cache->redis->get('foo'), 'bar'); + + $this->unit->run($this->cache->redis->delete('foo'), 'is_true'); + + $this->unit->run($this->cache->redis->save('foo', 'bar', 1800), 'is_true'); + + $this->unit->run( + $this->cache->redis->get_metadata('foo'), + array( + 'data' => 'bar', + 'expire' => time() + 1800 + ) + ); + + $this->unit->run($this->cache->redis->clean(), 'is_true'); + + $this->unit->run($this->cache->redis->get('foo'), 'is_false'); + + $this->unit->run($this->cache->redis->cache_info(), 'is_array'); + + echo $this->unit->report(); + } + +} diff --git a/application/controllers/welcome.php b/application/controllers/welcome.php index 79689f01..21bef43d 100644 --- a/application/controllers/welcome.php +++ b/application/controllers/welcome.php @@ -2,12 +2,22 @@ class Welcome extends CI_Controller { - function __construct() - { - parent::__construct(); - } - - function index() + /** + * Index Page for this controller. + * + * Maps to the following URL + * http://example.com/index.php/welcome + * - or - + * http://example.com/index.php/welcome/index + * - or - + * Since this controller is set as the default controller in + * config/routes.php, it's displayed at http://example.com/ + * + * So any other public methods not prefixed with an underscore will + * map to /index.php/welcome/ + * @see http://codeigniter.com/user_guide/general/urls.html + */ + public function index() { $this->load->view('welcome_message'); } diff --git a/application/errors/error_404.php b/application/errors/error_404.php index a304f456..792726a6 100644 --- a/application/errors/error_404.php +++ b/application/errors/error_404.php @@ -1,32 +1,60 @@ - + + 404 Page Not Found -
+

diff --git a/application/errors/error_db.php b/application/errors/error_db.php index 181de960..b396cda9 100644 --- a/application/errors/error_db.php +++ b/application/errors/error_db.php @@ -1,32 +1,60 @@ - + + Database Error -
+

diff --git a/application/errors/error_general.php b/application/errors/error_general.php index 7734d34c..fd63ce2c 100644 --- a/application/errors/error_general.php +++ b/application/errors/error_general.php @@ -1,32 +1,60 @@ - + + Error -
+

diff --git a/system/logs/index.html b/application/logs/index.html similarity index 100% rename from system/logs/index.html rename to application/logs/index.html diff --git a/application/views/welcome_message.php b/application/views/welcome_message.php index ca68fc10..0bf5a8d2 100644 --- a/application/views/welcome_message.php +++ b/application/views/welcome_message.php @@ -4,61 +4,85 @@ Welcome to CodeIgniter - + code { + font-family: Consolas, Monaco, Courier New, Courier, monospace; + font-size: 12px; + background-color: #f9f9f9; + border: 1px solid #D0D0D0; + color: #002166; + display: block; + margin: 14px 0 14px 0; + padding: 12px 10px 12px 10px; + } + + #body{ + margin: 0 15px 0 15px; + } + + p.footer{ + text-align: right; + font-size: 11px; + border-top: 1px solid #D0D0D0; + line-height: 32px; + padding: 0 10px 0 10px; + margin: 20px 0 0 0; + } + + #container{ + margin: 10px; + border: 1px solid #D0D0D0; + -webkit-box-shadow: 0 0 8px #D0D0D0; + } + -

Welcome to CodeIgniter!

- -

The page you are looking at is being generated dynamically by CodeIgniter.

+
+

Welcome to CodeIgniter!

-

If you would like to edit this page you'll find it located at:

-application/views/welcome_message.php +
+

The page you are looking at is being generated dynamically by CodeIgniter.

-

The corresponding controller for this page is found at:

-application/controllers/welcome.php +

If you would like to edit this page you'll find it located at:

+ application/views/welcome_message.php -

If you are exploring CodeIgniter for the very first time, you should start by reading the User Guide.

+

The corresponding controller for this page is found at:

+ application/controllers/welcome.php +

If you are exploring CodeIgniter for the very first time, you should start by reading the User Guide.

+
-


Page rendered in {elapsed_time} seconds

+ +
\ No newline at end of file diff --git a/index.php b/index.php index 5bb53d2f..12618c62 100644 --- a/index.php +++ b/index.php @@ -2,15 +2,54 @@ /* *--------------------------------------------------------------- - * PHP ERROR REPORTING LEVEL + * APPLICATION ENVIRONMENT *--------------------------------------------------------------- * - * By default CI runs with error reporting set to ALL. For security - * reasons you are encouraged to change this to 0 when your site goes live. - * For more info visit: http://www.php.net/error_reporting + * You can load different configurations depending on your + * current environment. Setting the environment also influences + * things like logging and error reporting. + * + * This can be set to anything, but default usage is: + * + * development + * testing + * production + * + * NOTE: If you change these, also change the error_reporting() code below * */ - error_reporting(E_ALL); + define('ENVIRONMENT', 'development'); +/* + *--------------------------------------------------------------- + * ERROR REPORTING + *--------------------------------------------------------------- + * + * Different environments will require different levels of error reporting. + * By default development will show errors but testing and live will hide them. + */ + +if (defined('ENVIRONMENT')) +{ + switch (ENVIRONMENT) + { + case 'development': + $error_level = E_ALL; + break; + + case 'testing': + case 'production': + $error_level = 0; + break; + + default: + exit('The application environment is not set correctly.'); + } + + if (isset($error_level) && function_exists('error_reporting')) + { + error_reporting($error_level); + } +} /* *--------------------------------------------------------------- @@ -22,7 +61,7 @@ * as this file. * */ - $system_path = "system"; + $system_path = 'system'; /* *--------------------------------------------------------------- @@ -38,7 +77,7 @@ * NO TRAILING SLASH! * */ - $application_folder = "application"; + $application_folder = 'application'; /* * -------------------------------------------------------------------- @@ -64,7 +103,7 @@ // if your controller is not in a sub-folder within the "controllers" folder // $routing['directory'] = ''; - // The controller class file name. Example: Mycontroller.php + // The controller class file name. Example: Mycontroller // $routing['controller'] = ''; // The controller function you wish to be called. @@ -94,14 +133,18 @@ // END OF USER CONFIGURABLE SETTINGS. DO NOT EDIT BELOW THIS LINE // -------------------------------------------------------------------- - - - /* * --------------------------------------------------------------- * Resolve the system path for increased reliability * --------------------------------------------------------------- */ + + // Set the current directory correctly for CLI requests + if (defined('STDIN')) + { + chdir(dirname(__FILE__)); + } + if (realpath($system_path) !== FALSE) { $system_path = realpath($system_path).'/'; @@ -125,6 +168,7 @@ define('SELF', pathinfo(__FILE__, PATHINFO_BASENAME)); // The PHP file extension + // this global constant is deprecated. define('EXT', '.php'); // Path to the system folder @@ -160,7 +204,7 @@ * And away we go... * */ -require_once BASEPATH.'core/CodeIgniter'.EXT; +require_once BASEPATH.'core/CodeIgniter.php'; /* End of file index.php */ /* Location: ./index.php */ \ No newline at end of file diff --git a/license.txt b/license.txt index 6ec79425..061cdb9d 100644 --- a/license.txt +++ b/license.txt @@ -1,4 +1,4 @@ -Copyright (c) 2008 - 2010, EllisLab, Inc. +Copyright (c) 2008 - 2011, EllisLab, Inc. All rights reserved. This license is a legal agreement between you and EllisLab Inc. for the use diff --git a/system/core/Benchmark.php b/system/core/Benchmark.php index d0e1fc68..a200727a 100644 --- a/system/core/Benchmark.php +++ b/system/core/Benchmark.php @@ -6,7 +6,7 @@ * * @package CodeIgniter * @author ExpressionEngine Dev Team - * @copyright Copyright (c) 2008 - 2010, EllisLab, Inc. + * @copyright Copyright (c) 2008 - 2011, EllisLab, Inc. * @license http://codeigniter.com/user_guide/license.html * @link http://codeigniter.com * @since Version 1.0 @@ -29,6 +29,11 @@ */ class CI_Benchmark { + /** + * List of all benchmark markers and when they were added + * + * @var array + */ var $marker = array(); // -------------------------------------------------------------------- diff --git a/system/core/CodeIgniter.php b/system/core/CodeIgniter.php index 595e00f2..7b92ddf1 100644 --- a/system/core/CodeIgniter.php +++ b/system/core/CodeIgniter.php @@ -6,7 +6,7 @@ * * @package CodeIgniter * @author ExpressionEngine Dev Team - * @copyright Copyright (c) 2008 - 2010, EllisLab, Inc. + * @copyright Copyright (c) 2008 - 2011, EllisLab, Inc. * @license http://codeigniter.com/user_guide/license.html * @link http://codeigniter.com * @since Version 1.0 @@ -32,21 +32,47 @@ * Define the CodeIgniter Version * ------------------------------------------------------ */ - define('CI_VERSION', '2.0'); + /** + * CodeIgniter Version + * + * @var string + * + */ + define('CI_VERSION', '2.0.2'); + +/* + * ------------------------------------------------------ + * Define the CodeIgniter Branch (Core = TRUE, Reactor = FALSE) + * ------------------------------------------------------ + */ + /** + * CodeIgniter Branch (Core = TRUE, Reactor = FALSE) + * + * @var string + * + */ + define('CI_CORE', FALSE); /* * ------------------------------------------------------ * Load the global functions * ------------------------------------------------------ */ - require(BASEPATH.'core/Common'.EXT); + require(BASEPATH.'core/Common.php'); /* * ------------------------------------------------------ * Load the framework constants * ------------------------------------------------------ */ - require(APPPATH.'config/constants'.EXT); + if (defined('ENVIRONMENT') AND file_exists(APPPATH.'config/'.ENVIRONMENT.'/constants.php')) + { + require(APPPATH.'config/'.ENVIRONMENT.'/constants.php'); + } + else + { + require(APPPATH.'config/constants.php'); + } /* * ------------------------------------------------------ @@ -80,7 +106,7 @@ { get_config(array('subclass_prefix' => $assign_to_config['subclass_prefix'])); } - + /* * ------------------------------------------------------ * Set a liberal script execution time limit @@ -129,17 +155,17 @@ /* * ------------------------------------------------------ - * Instantiate the Unicode class + * Instantiate the UTF-8 class * ------------------------------------------------------ * - * Note: Order here is rather important as the Unicode + * Note: Order here is rather important as the UTF-8 * class needs to be used very early on, but it cannot * properly determine if UTf-8 can be supported until * after the Config class is instantiated. * */ - $UNI =& load_class('Unicode', 'core'); + $UNI =& load_class('Utf8', 'core'); /* * ------------------------------------------------------ @@ -182,6 +208,13 @@ } } +/* + * ----------------------------------------------------- + * Load the security class for xss and csrf support + * ----------------------------------------------------- + */ + $SEC =& load_class('Security', 'core'); + /* * ------------------------------------------------------ * Load the Input class and sanitize globals @@ -203,7 +236,7 @@ * */ // Load the base controller class - require BASEPATH.'core/Controller'.EXT; + require BASEPATH.'core/Controller.php'; function &get_instance() { @@ -211,20 +244,20 @@ function &get_instance() } - if (file_exists(APPPATH.'core/'.$CFG->config['subclass_prefix'].'Controller'.EXT)) + if (file_exists(APPPATH.'core/'.$CFG->config['subclass_prefix'].'Controller.php')) { - require APPPATH.'core/'.$CFG->config['subclass_prefix'].'Controller'.EXT; + require APPPATH.'core/'.$CFG->config['subclass_prefix'].'Controller.php'; } // Load the local application controller // Note: The Router class automatically validates the controller path using the router->_validate_request(). // If this include fails it means that the default controller in the Routes.php file is not resolving to something valid. - if ( ! file_exists(APPPATH.'controllers/'.$RTR->fetch_directory().$RTR->fetch_class().EXT)) + if ( ! file_exists(APPPATH.'controllers/'.$RTR->fetch_directory().$RTR->fetch_class().'.php')) { show_error('Unable to load your default controller. Please make sure the controller specified in your Routes.php file is valid.'); } - include(APPPATH.'controllers/'.$RTR->fetch_directory().$RTR->fetch_class().EXT); + include(APPPATH.'controllers/'.$RTR->fetch_directory().$RTR->fetch_class().'.php'); // Set a mark point for benchmarking $BM->mark('loading_time:_base_classes_end'); @@ -246,7 +279,25 @@ function &get_instance() OR in_array(strtolower($method), array_map('strtolower', get_class_methods('CI_Controller'))) ) { - show_404("{$class}/{$method}"); + if ( ! empty($RTR->routes['404_override'])) + { + $x = explode('/', $RTR->routes['404_override']); + $class = $x[0]; + $method = (isset($x[1]) ? $x[1] : 'index'); + if ( ! class_exists($class)) + { + if ( ! file_exists(APPPATH.'controllers/'.$class.'.php')) + { + show_404("{$class}/{$method}"); + } + + include_once(APPPATH.'controllers/'.$class.'.php'); + } + } + else + { + show_404("{$class}/{$method}"); + } } /* @@ -289,7 +340,28 @@ function &get_instance() // methods, so we'll use this workaround for consistent behavior if ( ! in_array(strtolower($method), array_map('strtolower', get_class_methods($CI)))) { - show_404("{$class}/{$method}"); + // Check and see if we are using a 404 override and use it. + if ( ! empty($RTR->routes['404_override'])) + { + $x = explode('/', $RTR->routes['404_override']); + $class = $x[0]; + $method = (isset($x[1]) ? $x[1] : 'index'); + if ( ! class_exists($class)) + { + if ( ! file_exists(APPPATH.'controllers/'.$class.'.php')) + { + show_404("{$class}/{$method}"); + } + + include_once(APPPATH.'controllers/'.$class.'.php'); + unset($CI); + $CI = new $class(); + } + } + else + { + show_404("{$class}/{$method}"); + } } // Call the requested method. diff --git a/system/core/Common.php b/system/core/Common.php index 6a3d5ac0..98b84300 100644 --- a/system/core/Common.php +++ b/system/core/Common.php @@ -6,7 +6,7 @@ * * @package CodeIgniter * @author ExpressionEngine Dev Team - * @copyright Copyright (c) 2008 - 2010, EllisLab, Inc. + * @copyright Copyright (c) 2008 - 2011, EllisLab, Inc. * @license http://codeigniter.com/user_guide/license.html * @link http://codeigniter.com * @since Version 1.0 @@ -39,6 +39,8 @@ * @param string * @return bool TRUE if the current version is $version or higher */ +if ( ! function_exists('is_php')) +{ function is_php($version = '5.0.0') { static $_is_php; @@ -51,6 +53,7 @@ function is_php($version = '5.0.0') return $_is_php[$version]; } +} // ------------------------------------------------------------------------ @@ -64,6 +67,8 @@ function is_php($version = '5.0.0') * @access private * @return void */ +if ( ! function_exists('is_really_writable')) +{ function is_really_writable($file) { // If we're on a Unix server with safe_mode off we call is_writable @@ -88,7 +93,7 @@ function is_really_writable($file) @unlink($file); return TRUE; } - elseif (($fp = @fopen($file, FOPEN_WRITE_CREATE)) === FALSE) + elseif ( ! is_file($file) OR ($fp = @fopen($file, FOPEN_WRITE_CREATE)) === FALSE) { return FALSE; } @@ -96,6 +101,7 @@ function is_really_writable($file) fclose($fp); return TRUE; } +} // ------------------------------------------------------------------------ @@ -112,6 +118,8 @@ function is_really_writable($file) * @param string the class name prefix * @return object */ +if ( ! function_exists('load_class')) +{ function &load_class($class, $directory = 'libraries', $prefix = 'CI_') { static $_classes = array(); @@ -128,13 +136,13 @@ function &load_class($class, $directory = 'libraries', $prefix = 'CI_') // thenin the local application/libraries folder foreach (array(BASEPATH, APPPATH) as $path) { - if (file_exists($path.$directory.'/'.$class.EXT)) + if (file_exists($path.$directory.'/'.$class.'.php')) { $name = $prefix.$class; if (class_exists($name) === FALSE) { - require($path.$directory.'/'.$class.EXT); + require($path.$directory.'/'.$class.'.php'); } break; @@ -142,13 +150,13 @@ function &load_class($class, $directory = 'libraries', $prefix = 'CI_') } // Is the request a class extension? If so we load it too - if (file_exists(APPPATH.$directory.'/'.config_item('subclass_prefix').$class.EXT)) + if (file_exists(APPPATH.$directory.'/'.config_item('subclass_prefix').$class.'.php')) { $name = config_item('subclass_prefix').$class; if (class_exists($name) === FALSE) { - require(APPPATH.$directory.'/'.config_item('subclass_prefix').$class.EXT); + require(APPPATH.$directory.'/'.config_item('subclass_prefix').$class.'.php'); } } @@ -157,7 +165,7 @@ function &load_class($class, $directory = 'libraries', $prefix = 'CI_') { // Note: We use exit() rather then show_error() in order to avoid a // self-referencing loop with the Excptions class - exit('Unable to locate the specified class: '.$class.EXT); + exit('Unable to locate the specified class: '.$class.'.php'); } // Keep track of what we just loaded @@ -166,6 +174,7 @@ function &load_class($class, $directory = 'libraries', $prefix = 'CI_') $_classes[$class] = new $name(); return $_classes[$class]; } +} // -------------------------------------------------------------------- @@ -176,6 +185,8 @@ function &load_class($class, $directory = 'libraries', $prefix = 'CI_') * @access public * @return array */ +if ( ! function_exists('is_loaded')) +{ function is_loaded($class = '') { static $_is_loaded = array(); @@ -187,6 +198,7 @@ function is_loaded($class = '') return $_is_loaded; } +} // ------------------------------------------------------------------------ @@ -199,6 +211,8 @@ function is_loaded($class = '') * @access private * @return array */ +if ( ! function_exists('get_config')) +{ function &get_config($replace = array()) { static $_config; @@ -208,16 +222,20 @@ function &get_config($replace = array()) return $_config[0]; } - // Fetch the config file - if ( ! file_exists(APPPATH.'config/config'.EXT)) + // Is the config file in the environment folder? + if ( ! defined('ENVIRONMENT') OR ! file_exists($file_path = APPPATH.'config/'.ENVIRONMENT.'/config.php')) { - exit('The configuration file does not exist.'); + $file_path = APPPATH.'config/config.php'; } - else + + // Fetch the config file + if ( ! file_exists($file_path)) { - require(APPPATH.'config/config'.EXT); + exit('The configuration file does not exist.'); } + require($file_path); + // Does the $config array exist in the file? if ( ! isset($config) OR ! is_array($config)) { @@ -238,6 +256,7 @@ function &get_config($replace = array()) return $_config[0] =& $config; } +} // ------------------------------------------------------------------------ @@ -247,6 +266,8 @@ function &get_config($replace = array()) * @access public * @return mixed */ +if ( ! function_exists('config_item')) +{ function config_item($item) { static $_config_item = array(); @@ -264,6 +285,7 @@ function config_item($item) return $_config_item[$item]; } +} // ------------------------------------------------------------------------ @@ -279,12 +301,15 @@ function config_item($item) * @access public * @return void */ +if ( ! function_exists('show_error')) +{ function show_error($message, $status_code = 500, $heading = 'An Error Was Encountered') { $_error =& load_class('Exceptions', 'core'); echo $_error->show_error($heading, $message, 'error_general', $status_code); exit; } +} // ------------------------------------------------------------------------ @@ -298,12 +323,15 @@ function show_error($message, $status_code = 500, $heading = 'An Error Was Encou * @access public * @return void */ +if ( ! function_exists('show_404')) +{ function show_404($page = '', $log_error = TRUE) { $_error =& load_class('Exceptions', 'core'); $_error->show_404($page, $log_error); exit; } +} // ------------------------------------------------------------------------ @@ -316,6 +344,8 @@ function show_404($page = '', $log_error = TRUE) * @access public * @return void */ +if ( ! function_exists('log_message')) +{ function log_message($level = 'error', $message, $php_error = FALSE) { static $_log; @@ -328,6 +358,7 @@ function log_message($level = 'error', $message, $php_error = FALSE) $_log =& load_class('Log'); $_log->write_log($level, $message, $php_error); } +} // ------------------------------------------------------------------------ @@ -339,6 +370,8 @@ function log_message($level = 'error', $message, $php_error = FALSE) * @param string * @return void */ +if ( ! function_exists('set_status_header')) +{ function set_status_header($code = 200, $text = '') { $stati = array( @@ -413,6 +446,7 @@ function set_status_header($code = 200, $text = '') header("HTTP/1.1 {$code} {$text}", TRUE, $code); } } +} // -------------------------------------------------------------------- @@ -430,6 +464,8 @@ function set_status_header($code = 200, $text = '') * @access private * @return void */ +if ( ! function_exists('_exception_handler')) +{ function _exception_handler($severity, $message, $filepath, $line) { // We don't bother with "strict" notices since they tend to fill up @@ -446,7 +482,7 @@ function _exception_handler($severity, $message, $filepath, $line) // Should we display the error? We'll get the current error_reporting // level and add its bits with the severity bits to find out. - if (($severity & error_reporting()) == $severity) + if (($severity & (int)ini_get('error_reporting')) == $severity) { $_error->show_php_error($severity, $message, $filepath, $line); } @@ -459,45 +495,46 @@ function _exception_handler($severity, $message, $filepath, $line) $_error->log_exception($severity, $message, $filepath, $line); } +} - // -------------------------------------------------------------------- - - /** - * Remove Invisible Characters - * - * This prevents sandwiching null characters - * between ascii characters, like Java\0script. - * - * @access public - * @param string - * @return string - */ - function remove_invisible_characters($str) - { - static $non_displayables; +// -------------------------------------------------------------------- - if ( ! isset($non_displayables)) +/** + * Remove Invisible Characters + * + * This prevents sandwiching null characters + * between ascii characters, like Java\0script. + * + * @access public + * @param string + * @return string + */ +if ( ! function_exists('remove_invisible_characters')) +{ + function remove_invisible_characters($str, $url_encoded = TRUE) + { + $non_displayables = array(); + + // every control character except newline (dec 10) + // carriage return (dec 13), and horizontal tab (dec 09) + + if ($url_encoded) { - // every control character except newline (dec 10), carriage return (dec 13), and horizontal tab (dec 09), - $non_displayables = array( - '/%0[0-8bcef]/', // url encoded 00-08, 11, 12, 14, 15 - '/%1[0-9a-f]/', // url encoded 16-31 - '/[\x00-\x08]/', // 00-08 - '/\x0b/', '/\x0c/', // 11, 12 - '/[\x0e-\x1f]/' // 14-31 - ); + $non_displayables[] = '/%0[0-8bcef]/'; // url encoded 00-08, 11, 12, 14, 15 + $non_displayables[] = '/%1[0-9a-f]/'; // url encoded 16-31 } + + $non_displayables[] = '/[\x00-\x08\x0B\x0C\x0E-\x1F\x7F]+/S'; // 00-08, 11, 12, 14-31, 127 do { - $cleaned = $str; - $str = preg_replace($non_displayables, '', $str); + $str = preg_replace($non_displayables, '', $str, -1, $count); } - while ($cleaned != $str); + while ($count); return $str; } - +} /* End of file Common.php */ /* Location: ./system/core/Common.php */ \ No newline at end of file diff --git a/system/core/Config.php b/system/core/Config.php index 8ecfba73..5cacf867 100644 --- a/system/core/Config.php +++ b/system/core/Config.php @@ -6,7 +6,7 @@ * * @package CodeIgniter * @author ExpressionEngine Dev Team - * @copyright Copyright (c) 2008 - 2010, EllisLab, Inc. + * @copyright Copyright (c) 2008 - 2011, EllisLab, Inc. * @license http://codeigniter.com/user_guide/license.html * @link http://codeigniter.com * @since Version 1.0 @@ -28,8 +28,23 @@ */ class CI_Config { + /** + * List of all loaded config values + * + * @var array + */ var $config = array(); + /** + * List of all loaded config files + * + * @var array + */ var $is_loaded = array(); + /** + * List of paths to search when trying to load a config file + * + * @var array + */ var $_config_paths = array(APPPATH); /** @@ -51,7 +66,7 @@ function __construct() // Set the base_url automatically if none was provided if ($this->config['base_url'] == '') { - if(isset($_SERVER['HTTP_HOST'])) + if (isset($_SERVER['HTTP_HOST'])) { $base_url = isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) !== 'off' ? 'https' : 'http'; $base_url .= '://'. $_SERVER['HTTP_HOST']; @@ -74,24 +89,40 @@ function __construct() * * @access public * @param string the config file name + * @param boolean if configuration values should be loaded into their own section + * @param boolean true if errors should just return false, false if an error message should be displayed * @return boolean if the file was loaded correctly */ function load($file = '', $use_sections = FALSE, $fail_gracefully = FALSE) { - $file = ($file == '') ? 'config' : str_replace(EXT, '', $file); + $file = ($file == '') ? 'config' : str_replace('.php', '', $file); + $found = FALSE; $loaded = FALSE; - foreach($this->_config_paths as $path) + foreach ($this->_config_paths as $path) { - $file_path = $path.'config/'.$file.EXT; + $check_locations = defined('ENVIRONMENT') + ? array(ENVIRONMENT.'/'.$file, $file) + : array($file); - if (in_array($file_path, $this->is_loaded, TRUE)) + foreach ($check_locations as $location) { - $loaded = TRUE; - continue; + $file_path = $path.'config/'.$location.'.php'; + + if (in_array($file_path, $this->is_loaded, TRUE)) + { + $loaded = TRUE; + continue 2; + } + + if (file_exists($file_path)) + { + $found = TRUE; + break; + } } - if ( ! file_exists($path.'config/'.$file.EXT)) + if ($found === FALSE) { continue; } @@ -128,6 +159,7 @@ function load($file = '', $use_sections = FALSE, $fail_gracefully = FALSE) $loaded = TRUE; log_message('debug', 'Config file loaded: '.$file_path); + break; } if ($loaded === FALSE) @@ -136,7 +168,7 @@ function load($file = '', $use_sections = FALSE, $fail_gracefully = FALSE) { return FALSE; } - show_error('The configuration file '.$file.EXT.' does not exist.'); + show_error('The configuration file '.$file.'.php'.' does not exist.'); } return TRUE; @@ -229,8 +261,9 @@ function site_url($uri = '') $uri = implode('/', $uri); } + $index = $this->item('index_page') == '' ? '' : $this->slash_item('index_page'); $suffix = ($this->item('url_suffix') == FALSE) ? '' : $this->item('url_suffix'); - return $this->slash_item('base_url').$this->slash_item('index_page').trim($uri, '/').$suffix; + return $this->slash_item('base_url').$index.trim($uri, '/').$suffix; } else { @@ -309,4 +342,4 @@ function _assign_to_config($items = array()) // END CI_Config class /* End of file Config.php */ -/* Location: ./system/core/Config.php */ \ No newline at end of file +/* Location: ./system/core/Config.php */ diff --git a/system/core/Controller.php b/system/core/Controller.php index c78be872..fddb81e1 100644 --- a/system/core/Controller.php +++ b/system/core/Controller.php @@ -6,7 +6,7 @@ * * @package CodeIgniter * @author ExpressionEngine Dev Team - * @copyright Copyright (c) 2008 - 2010, EllisLab, Inc. + * @copyright Copyright (c) 2008 - 2011, EllisLab, Inc. * @license http://codeigniter.com/user_guide/license.html * @link http://codeigniter.com * @since Version 1.0 @@ -48,12 +48,9 @@ public function __construct() $this->load =& load_class('Loader', 'core'); - $this->load->_base_classes =& is_loaded(); - - $this->load->_ci_autoloader(); - + $this->load->initialize(); + log_message('debug', "Controller Class Initialized"); - } public static function &get_instance() diff --git a/system/core/Exceptions.php b/system/core/Exceptions.php index 32cb77ba..869739a5 100644 --- a/system/core/Exceptions.php +++ b/system/core/Exceptions.php @@ -6,7 +6,7 @@ * * @package CodeIgniter * @author ExpressionEngine Dev Team - * @copyright Copyright (c) 2008 - 2010, EllisLab, Inc. + * @copyright Copyright (c) 2008 - 2011, EllisLab, Inc. * @license http://codeigniter.com/user_guide/license.html * @link http://codeigniter.com * @since Version 1.0 @@ -30,8 +30,21 @@ class CI_Exceptions { var $message; var $filename; var $line; + + /** + * Nesting level of the output buffering mechanism + * + * @var int + * @access public + */ var $ob_level; + /** + * List if available error levels + * + * @var array + * @access public + */ var $levels = array( E_ERROR => 'Error', E_WARNING => 'Warning', @@ -84,7 +97,8 @@ function log_exception($severity, $message, $filepath, $line) * 404 Page Not Found Handler * * @access private - * @param string + * @param string the page + * @param bool log error yes/no * @return string */ function show_404($page = '', $log_error = TRUE) @@ -115,6 +129,7 @@ function show_404($page = '', $log_error = TRUE) * @param string the heading * @param string the message * @param string the template name + * @param int the status code * @return string */ function show_error($heading, $message, $template = 'error_general', $status_code = 500) @@ -128,7 +143,7 @@ function show_error($heading, $message, $template = 'error_general', $status_cod ob_end_flush(); } ob_start(); - include(APPPATH.'errors/'.$template.EXT); + include(APPPATH.'errors/'.$template.'.php'); $buffer = ob_get_contents(); ob_end_clean(); return $buffer; @@ -164,7 +179,7 @@ function show_php_error($severity, $message, $filepath, $line) ob_end_flush(); } ob_start(); - include(APPPATH.'errors/error_php'.EXT); + include(APPPATH.'errors/error_php.php'); $buffer = ob_get_contents(); ob_end_clean(); echo $buffer; diff --git a/system/core/Hooks.php b/system/core/Hooks.php index 70dc6870..33f1c034 100644 --- a/system/core/Hooks.php +++ b/system/core/Hooks.php @@ -6,7 +6,7 @@ * * @package CodeIgniter * @author ExpressionEngine Dev Team - * @copyright Copyright (c) 2008 - 2010, EllisLab, Inc. + * @copyright Copyright (c) 2008 - 2011, EllisLab, Inc. * @license http://codeigniter.com/user_guide/license.html * @link http://codeigniter.com * @since Version 1.0 @@ -28,8 +28,23 @@ */ class CI_Hooks { + /** + * Determines wether hooks are enabled + * + * @var bool + */ var $enabled = FALSE; + /** + * List of all hooks set in config/hooks.php + * + * @var array + */ var $hooks = array(); + /** + * Determines wether hook is in progress, used to prevent infinte loops + * + * @var bool + */ var $in_progress = FALSE; /** @@ -65,7 +80,15 @@ function _initialize() // Grab the "hooks" definition file. // If there are no hooks, we're done. - @include(APPPATH.'config/hooks'.EXT); + if (defined('ENVIRONMENT') AND is_file(APPPATH.'config/'.ENVIRONMENT.'/hooks.php')) + { + include(APPPATH.'config/'.ENVIRONMENT.'/hooks.php'); + } + elseif (is_file(APPPATH.'config/hooks.php')) + { + include(APPPATH.'config/hooks.php'); + } + if ( ! isset($hook) OR ! is_array($hook)) { diff --git a/system/core/Input.php b/system/core/Input.php index eb2048e5..bc202b3f 100644 --- a/system/core/Input.php +++ b/system/core/Input.php @@ -6,7 +6,7 @@ * * @package CodeIgniter * @author ExpressionEngine Dev Team - * @copyright Copyright (c) 2008 - 2010, EllisLab, Inc. + * @copyright Copyright (c) 2008 - 2011, EllisLab, Inc. * @license http://codeigniter.com/user_guide/license.html * @link http://codeigniter.com * @since Version 1.0 @@ -28,15 +28,51 @@ */ class CI_Input { + /** + * IP address of the current user + * + * @var string + */ var $ip_address = FALSE; + /** + * user agent (web browser) being used by the current user + * + * @var string + */ var $user_agent = FALSE; + /** + * If FALSE, then $_GET will be set to an empty array + * + * @var bool + */ var $_allow_get_array = TRUE; + /** + * If TRUE, then newlines are standardized + * + * @var bool + */ var $_standardize_newlines = TRUE; - var $_enable_xss = FALSE; // Set automatically based on config setting - var $_enable_csrf = FALSE; // Set automatically based on config setting - + /** + * Determines whether the XSS filter is always active when GET, POST or COOKIE data is encountered + * Set automatically based on config setting + * + * @var bool + */ + var $_enable_xss = FALSE; + /** + * Enables a CSRF cookie token to be set. + * Set automatically based on config setting + * + * @var bool + */ + var $_enable_csrf = FALSE; + /** + * List of all HTTP request headers + * + * @var array + */ protected $headers = array(); - + /** * Constructor @@ -53,13 +89,10 @@ public function __construct() $this->_enable_xss = (config_item('global_xss_filtering') === TRUE); $this->_enable_csrf = (config_item('csrf_protection') === TRUE); - // Do we need to load the security class? - if ($this->_enable_xss == TRUE OR $this->_enable_csrf == TRUE) - { - $this->security =& load_class('Security'); - } + global $SEC; + $this->security =& $SEC; - // Do we need the Unicode class? + // Do we need the UTF-8 class? if (UTF8_ENABLED === TRUE) { global $UNI; @@ -92,8 +125,7 @@ function _fetch_from_array(&$array, $index = '', $xss_clean = FALSE) if ($xss_clean === TRUE) { - $_security =& load_class('Security'); - return $_security->xss_clean($array[$index]); + return $this->security->xss_clean($array[$index]); } return $array[$index]; @@ -109,8 +141,21 @@ function _fetch_from_array(&$array, $index = '', $xss_clean = FALSE) * @param bool * @return string */ - function get($index = '', $xss_clean = FALSE) + function get($index = NULL, $xss_clean = FALSE) { + // Check if a field has been provided + if ($index === NULL AND ! empty($_GET)) + { + $get = array(); + + // loop through the full _GET array + foreach (array_keys($_GET) as $key) + { + $get[$key] = $this->_fetch_from_array($_GET, $key, $xss_clean); + } + return $get; + } + return $this->_fetch_from_array($_GET, $index, $xss_clean); } @@ -124,8 +169,21 @@ function get($index = '', $xss_clean = FALSE) * @param bool * @return string */ - function post($index = '', $xss_clean = FALSE) + function post($index = NULL, $xss_clean = FALSE) { + // Check if a field has been provided + if ($index === NULL AND ! empty($_POST)) + { + $post = array(); + + // Loop through the full _POST array and return it + foreach (array_keys($_POST) as $key) + { + $post[$key] = $this->_fetch_from_array($_POST, $key, $xss_clean); + } + return $post; + } + return $this->_fetch_from_array($_POST, $index, $xss_clean); } @@ -182,13 +240,15 @@ function cookie($index = '', $xss_clean = FALSE) * @param string the cookie domain. Usually: .yourdomain.com * @param string the cookie path * @param string the cookie prefix + * @param bool true makes the cookie secure * @return void */ - function set_cookie($name = '', $value = '', $expire = '', $domain = '', $path = '/', $prefix = '') + function set_cookie($name = '', $value = '', $expire = '', $domain = '', $path = '/', $prefix = '', $secure = FALSE) { if (is_array($name)) { - foreach (array('value', 'expire', 'domain', 'path', 'prefix', 'name') as $item) + // always leave 'name' in last place, as the loop will break otherwise, due to $$item + foreach (array('value', 'expire', 'domain', 'path', 'prefix', 'secure', 'name') as $item) { if (isset($name[$item])) { @@ -209,6 +269,10 @@ function set_cookie($name = '', $value = '', $expire = '', $domain = '', $path = { $path = config_item('cookie_path'); } + if ($secure == FALSE AND config_item('cookie_secure') != FALSE) + { + $secure = config_item('cookie_secure'); + } if ( ! is_numeric($expire)) { @@ -219,7 +283,7 @@ function set_cookie($name = '', $value = '', $expire = '', $domain = '', $path = $expire = ($expire > 0) ? time() + $expire : 0; } - setcookie($prefix.$name, $value, $expire, $path, $domain, 0); + setcookie($prefix.$name, $value, $expire, $path, $domain, $secure); } // -------------------------------------------------------------------- @@ -374,9 +438,9 @@ function user_agent() function _sanitize_globals() { // It would be "wrong" to unset any of these GLOBALS. - $protected = array('_SERVER', '_GET', '_POST', '_FILES', '_REQUEST', + $protected = array('_SERVER', '_GET', '_POST', '_FILES', '_REQUEST', '_SESSION', '_ENV', 'GLOBALS', 'HTTP_RAW_POST_DATA', - 'system_folder', 'application_folder', 'BM', 'EXT', + 'system_folder', 'application_folder', 'BM', 'EXT', 'CFG', 'URI', 'RTR', 'OUT', 'IN'); // Unset globals for securiy. @@ -413,7 +477,7 @@ function _sanitize_globals() { if (is_array($_GET) AND count($_GET) > 0) { - foreach($_GET as $key => $val) + foreach ($_GET as $key => $val) { $_GET[$this->_clean_input_keys($key)] = $this->_clean_input_data($val); } @@ -423,7 +487,7 @@ function _sanitize_globals() // Clean $_POST Data if (is_array($_POST) AND count($_POST) > 0) { - foreach($_POST as $key => $val) + foreach ($_POST as $key => $val) { $_POST[$this->_clean_input_keys($key)] = $this->_clean_input_data($val); } @@ -441,7 +505,7 @@ function _sanitize_globals() unset($_COOKIE['$Path']); unset($_COOKIE['$Domain']); - foreach($_COOKIE as $key => $val) + foreach ($_COOKIE as $key => $val) { $_COOKIE[$this->_clean_input_keys($key)] = $this->_clean_input_data($val); } @@ -496,6 +560,9 @@ function _clean_input_data($str) $str = $this->uni->clean_string($str); } + // Remove control characters + $str = remove_invisible_characters($str); + // Should we filter the input data? if ($this->_enable_xss === TRUE) { @@ -507,7 +574,7 @@ function _clean_input_data($str) { if (strpos($str, "\r") !== FALSE) { - $str = str_replace(array("\r\n", "\r"), PHP_EOL, $str); + $str = str_replace(array("\r\n", "\r", "\r\n\n"), PHP_EOL, $str); } } @@ -548,9 +615,11 @@ function _clean_input_keys($str) /** * Request Headers * - * In Apache, you can simply call apache_request_headers(), however for + * In Apache, you can simply call apache_request_headers(), however for * people running other webservers the function is undefined. * + * @param bool XSS cleaning + * * @return array */ public function request_headers($xss_clean = FALSE) @@ -578,10 +647,10 @@ public function request_headers($xss_clean = FALSE) { $key = str_replace('_', ' ', strtolower($key)); $key = str_replace(' ', '-', ucwords($key)); - + $this->headers[$key] = $val; } - + return $this->headers; } @@ -602,7 +671,7 @@ public function get_request_header($index, $xss_clean = FALSE) { $this->request_headers(); } - + if ( ! isset($this->headers[$index])) { return FALSE; @@ -610,29 +679,42 @@ public function get_request_header($index, $xss_clean = FALSE) if ($xss_clean === TRUE) { - $_security =& load_class('Security'); - return $_security->xss_clean($this->headers[$index]); + return $this->security->xss_clean($this->headers[$index]); } - return $this->headers[$index]; + return $this->headers[$index]; } // -------------------------------------------------------------------- - + /** * Is ajax Request? * * Test to see if a request contains the HTTP_X_REQUESTED_WITH header * - * @return boolean + * @return boolean */ public function is_ajax_request() { return ($this->server('HTTP_X_REQUESTED_WITH') === 'XMLHttpRequest'); } + // -------------------------------------------------------------------- + + /** + * Is cli Request? + * + * Test to see if a request was made from the command line + * + * @return boolean + */ + public function is_cli_request() + { + return (bool) defined('STDIN'); + } + } // END Input class /* End of file Input.php */ -/* Location: ./system/core/Input.php */ \ No newline at end of file +/* Location: ./system/core/Input.php */ diff --git a/system/core/Lang.php b/system/core/Lang.php index 8ec17977..5ac67183 100644 --- a/system/core/Lang.php +++ b/system/core/Lang.php @@ -6,7 +6,7 @@ * * @package CodeIgniter * @author ExpressionEngine Dev Team - * @copyright Copyright (c) 2008 - 2010, EllisLab, Inc. + * @copyright Copyright (c) 2008 - 2011, EllisLab, Inc. * @license http://codeigniter.com/user_guide/license.html * @link http://codeigniter.com * @since Version 1.0 @@ -26,7 +26,17 @@ */ class CI_Lang { + /** + * List of translations + * + * @var array + */ var $language = array(); + /** + * List of loaded language files + * + * @var array + */ var $is_loaded = array(); /** @@ -47,18 +57,21 @@ function __construct() * @access public * @param mixed the name of the language file to be loaded. Can be an array * @param string the language (english, etc.) + * @param bool return loaded array of translations + * @param bool add suffix to $langfile + * @param string alternative path to look for language file * @return mixed */ function load($langfile = '', $idiom = '', $return = FALSE, $add_suffix = TRUE, $alt_path = '') { - $langfile = str_replace(EXT, '', $langfile); + $langfile = str_replace('.php', '', $langfile); if ($add_suffix == TRUE) { $langfile = str_replace('_lang.', '', $langfile).'_lang'; } - $langfile .= EXT; + $langfile .= '.php'; if (in_array($langfile, $this->is_loaded, TRUE)) { @@ -129,12 +142,19 @@ function load($langfile = '', $idiom = '', $return = FALSE, $add_suffix = TRUE, */ function line($line = '') { - $line = ($line == '' OR ! isset($this->language[$line])) ? FALSE : $this->language[$line]; - return $line; + $value = ($line == '' OR ! isset($this->language[$line])) ? FALSE : $this->language[$line]; + + // Because killer robots like unicorns! + if ($value === FALSE) + { + log_message('error', 'Could not find the language line "'.$line.'"'); + } + + return $value; } } // END Language Class /* End of file Lang.php */ -/* Location: ./system/core/Lang.php */ \ No newline at end of file +/* Location: ./system/core/Lang.php */ diff --git a/system/core/Loader.php b/system/core/Loader.php index 225b4391..31c93078 100644 --- a/system/core/Loader.php +++ b/system/core/Loader.php @@ -6,7 +6,7 @@ * * @package CodeIgniter * @author ExpressionEngine Dev Team - * @copyright Copyright (c) 2008 - 2010, EllisLab, Inc. + * @copyright Copyright (c) 2008 - 2011, EllisLab, Inc. * @license http://codeigniter.com/user_guide/license.html * @link http://codeigniter.com * @since Version 1.0 @@ -29,59 +29,175 @@ class CI_Loader { // All these are set automatically. Don't mess with them. - var $_ci_ob_level; - var $_ci_view_path = ''; - var $_ci_library_paths = array(); - var $_ci_model_paths = array(); - var $_ci_helper_paths = array(); - var $_base_classes = array(); // Set by the controller class - var $_ci_cached_vars = array(); - var $_ci_classes = array(); - var $_ci_loaded_files = array(); - var $_ci_models = array(); - var $_ci_helpers = array(); - var $_ci_varmap = array('unit_test' => 'unit', 'user_agent' => 'agent'); - + /** + * Nesting level of the output buffering mechanism + * + * @var int + * @access protected + */ + protected $_ci_ob_level; + /** + * List of paths to load views from + * + * @var array + * @access protected + */ + protected $_ci_view_paths = array(); + /** + * List of paths to load libraries from + * + * @var array + * @access protected + */ + protected $_ci_library_paths = array(); + /** + * List of paths to load models from + * + * @var array + * @access protected + */ + protected $_ci_model_paths = array(); + /** + * List of paths to load helpers from + * + * @var array + * @access protected + */ + protected $_ci_helper_paths = array(); + /** + * List of loaded base classes + * Set by the controller class + * + * @var array + * @access protected + */ + protected $_base_classes = array(); // Set by the controller class + /** + * List of cached variables + * + * @var array + * @access protected + */ + protected $_ci_cached_vars = array(); + /** + * List of loaded classes + * + * @var array + * @access protected + */ + protected $_ci_classes = array(); + /** + * List of loaded files + * + * @var array + * @access protected + */ + protected $_ci_loaded_files = array(); + /** + * List of loaded models + * + * @var array + * @access protected + */ + protected $_ci_models = array(); + /** + * List of loaded helpers + * + * @var array + * @access protected + */ + protected $_ci_helpers = array(); + /** + * List of class name mappings + * + * @var array + * @access protected + */ + protected $_ci_varmap = array('unit_test' => 'unit', + 'user_agent' => 'agent'); /** * Constructor * * Sets the path to the view files and gets the initial output buffering level - * - * @access public */ - function __construct() + public function __construct() { - $this->_ci_view_path = APPPATH.'views/'; $this->_ci_ob_level = ob_get_level(); $this->_ci_library_paths = array(APPPATH, BASEPATH); $this->_ci_helper_paths = array(APPPATH, BASEPATH); $this->_ci_model_paths = array(APPPATH); + $this->_ci_view_paths = array(APPPATH.'views/' => TRUE); log_message('debug', "Loader Class Initialized"); } // -------------------------------------------------------------------- + /** + * Initialize the Loader + * + * This method is called once in CI_Controller. + * + * @param array + * @return object + */ + public function initialize() + { + $this->_ci_classes = array(); + $this->_ci_loaded_files = array(); + $this->_ci_models = array(); + $this->_base_classes =& is_loaded(); + + $this->_ci_autoloader(); + + return $this; + } + + // -------------------------------------------------------------------- + + /** + * Is Loaded + * + * A utility function to test if a class is in the self::$_ci_classes array. + * This function returns the object name if the class tested for is loaded, + * and returns FALSE if it isn't. + * + * It is mainly used in the form_helper -> _get_validation_object() + * + * @param string class being checked for + * @return mixed class object name on the CI SuperObject or FALSE + */ + public function is_loaded($class) + { + if (isset($this->_ci_classes[$class])) + { + return $this->_ci_classes[$class]; + } + + return FALSE; + } + + // -------------------------------------------------------------------- + /** * Class Loader * * This function lets users load and instantiate classes. * It is designed to be called from a user's app controllers. * - * @access public * @param string the name of the class * @param mixed the optional parameters * @param string an optional object name * @return void */ - function library($library = '', $params = NULL, $object_name = NULL) + public function library($library = '', $params = NULL, $object_name = NULL) { if (is_array($library)) { - foreach($library as $read) + foreach ($library as $class) { - $this->library($read); + $this->library($class, $params); } return; @@ -97,17 +213,7 @@ function library($library = '', $params = NULL, $object_name = NULL) $params = NULL; } - if (is_array($library)) - { - foreach ($library as $class) - { - $this->_ci_load_class($class, $params, $object_name); - } - } - else - { - $this->_ci_load_class($library, $params, $object_name); - } + $this->_ci_load_class($library, $params, $object_name); } // -------------------------------------------------------------------- @@ -117,17 +223,16 @@ function library($library = '', $params = NULL, $object_name = NULL) * * This function lets users load and instantiate models. * - * @access public * @param string the name of the class * @param string name for the model * @param bool database connection * @return void */ - function model($model, $name = '', $db_conn = FALSE) + public function model($model, $name = '', $db_conn = FALSE) { if (is_array($model)) { - foreach($model as $babe) + foreach ($model as $babe) { $this->model($babe); } @@ -171,7 +276,7 @@ function model($model, $name = '', $db_conn = FALSE) foreach ($this->_ci_model_paths as $mod_path) { - if ( ! file_exists($mod_path.'models/'.$path.$model.EXT)) + if ( ! file_exists($mod_path.'models/'.$path.$model.'.php')) { continue; } @@ -191,7 +296,7 @@ function model($model, $name = '', $db_conn = FALSE) load_class('Model', 'core'); } - require_once($mod_path.'models/'.$path.$model.EXT); + require_once($mod_path.'models/'.$path.$model.'.php'); $model = ucfirst($model); @@ -210,13 +315,12 @@ function model($model, $name = '', $db_conn = FALSE) /** * Database Loader * - * @access public * @param string the DB credentials * @param bool whether to return the DB object * @param bool whether to enable active record (this allows us to override the config setting) * @return object */ - function database($params = '', $return = FALSE, $active_record = NULL) + public function database($params = '', $return = FALSE, $active_record = NULL) { // Grab the super object $CI =& get_instance(); @@ -227,7 +331,7 @@ function database($params = '', $return = FALSE, $active_record = NULL) return FALSE; } - require_once(BASEPATH.'database/DB'.EXT); + require_once(BASEPATH.'database/DB.php'); if ($return === TRUE) { @@ -247,10 +351,9 @@ function database($params = '', $return = FALSE, $active_record = NULL) /** * Load the Utilities Class * - * @access public * @return string */ - function dbutil() + public function dbutil() { if ( ! class_exists('CI_DB')) { @@ -263,8 +366,8 @@ function dbutil() // this use is deprecated and strongly discouraged $CI->load->dbforge(); - require_once(BASEPATH.'database/DB_utility'.EXT); - require_once(BASEPATH.'database/drivers/'.$CI->db->dbdriver.'/'.$CI->db->dbdriver.'_utility'.EXT); + require_once(BASEPATH.'database/DB_utility.php'); + require_once(BASEPATH.'database/drivers/'.$CI->db->dbdriver.'/'.$CI->db->dbdriver.'_utility.php'); $class = 'CI_DB_'.$CI->db->dbdriver.'_utility'; $CI->dbutil = new $class(); @@ -275,10 +378,9 @@ function dbutil() /** * Load the Database Forge Class * - * @access public * @return string */ - function dbforge() + public function dbforge() { if ( ! class_exists('CI_DB')) { @@ -287,8 +389,8 @@ function dbforge() $CI =& get_instance(); - require_once(BASEPATH.'database/DB_forge'.EXT); - require_once(BASEPATH.'database/drivers/'.$CI->db->dbdriver.'/'.$CI->db->dbdriver.'_forge'.EXT); + require_once(BASEPATH.'database/DB_forge.php'); + require_once(BASEPATH.'database/drivers/'.$CI->db->dbdriver.'/'.$CI->db->dbdriver.'_forge.php'); $class = 'CI_DB_'.$CI->db->dbdriver.'_forge'; $CI->dbforge = new $class(); @@ -307,13 +409,12 @@ function dbforge() * some cases it's advantageous to be able to return data so that * a developer can process it in some way. * - * @access public * @param string * @param array * @param bool * @return void */ - function view($view, $vars = array(), $return = FALSE) + public function view($view, $vars = array(), $return = FALSE) { return $this->_ci_load(array('_ci_view' => $view, '_ci_vars' => $this->_ci_object_to_array($vars), '_ci_return' => $return)); } @@ -325,12 +426,11 @@ function view($view, $vars = array(), $return = FALSE) * * This is a generic file loader * - * @access public * @param string * @param bool * @return string */ - function file($path, $return = FALSE) + public function file($path, $return = FALSE) { return $this->_ci_load(array('_ci_path' => $path, '_ci_return' => $return)); } @@ -343,11 +443,11 @@ function file($path, $return = FALSE) * Once variables are set they become available within * the controller class and its "view" files. * - * @access public * @param array + * @param string * @return void */ - function vars($vars = array(), $val = '') + public function vars($vars = array(), $val = '') { if ($val != '' AND is_string($vars)) { @@ -367,16 +467,30 @@ function vars($vars = array(), $val = '') // -------------------------------------------------------------------- + /** + * Get Variable + * + * Check if a variable is set and retrieve it. + * + * @param array + * @return void + */ + public function get_var($key) + { + return isset($this->_ci_cached_vars[$key]) ? $this->_ci_cached_vars[$key] : NULL; + } + + // -------------------------------------------------------------------- + /** * Load Helper * * This function loads the specified helper file. * - * @access public * @param mixed * @return void */ - function helper($helpers = array()) + public function helper($helpers = array()) { foreach ($this->_ci_prep_filename($helpers, '_helper') as $helper) { @@ -385,16 +499,16 @@ function helper($helpers = array()) continue; } - $ext_helper = APPPATH.'helpers/'.config_item('subclass_prefix').$helper.EXT; + $ext_helper = APPPATH.'helpers/'.config_item('subclass_prefix').$helper.'.php'; // Is this a helper extension request? if (file_exists($ext_helper)) { - $base_helper = BASEPATH.'helpers/'.$helper.EXT; + $base_helper = BASEPATH.'helpers/'.$helper.'.php'; if ( ! file_exists($base_helper)) { - show_error('Unable to load the requested file: helpers/'.$helper.EXT); + show_error('Unable to load the requested file: helpers/'.$helper.'.php'); } include_once($ext_helper); @@ -408,9 +522,9 @@ function helper($helpers = array()) // Try to load the helper foreach ($this->_ci_helper_paths as $path) { - if (file_exists($path.'helpers/'.$helper.EXT)) + if (file_exists($path.'helpers/'.$helper.'.php')) { - include_once($path.'helpers/'.$helper.EXT); + include_once($path.'helpers/'.$helper.'.php'); $this->_ci_helpers[$helper] = TRUE; log_message('debug', 'Helper loaded: '.$helper); @@ -421,7 +535,7 @@ function helper($helpers = array()) // unable to load the helper if ( ! isset($this->_ci_helpers[$helper])) { - show_error('Unable to load the requested file: helpers/'.$helper.EXT); + show_error('Unable to load the requested file: helpers/'.$helper.'.php'); } } } @@ -434,11 +548,10 @@ function helper($helpers = array()) * This is simply an alias to the above function in case the * user has written the plural form of this function. * - * @access public * @param array * @return void */ - function helpers($helpers = array()) + public function helpers($helpers = array()) { $this->helper($helpers); } @@ -448,12 +561,11 @@ function helpers($helpers = array()) /** * Loads a language file * - * @access public * @param array * @param string * @return void */ - function language($file = array(), $lang = '') + public function language($file = array(), $lang = '') { $CI =& get_instance(); @@ -473,11 +585,12 @@ function language($file = array(), $lang = '') /** * Loads a config file * - * @access public * @param string + * @param bool + * @param bool * @return void */ - function config($file = '', $use_sections = FALSE, $fail_gracefully = FALSE) + public function config($file = '', $use_sections = FALSE, $fail_gracefully = FALSE) { $CI =& get_instance(); $CI->config->load($file, $use_sections, $fail_gracefully); @@ -495,12 +608,12 @@ function config($file = '', $use_sections = FALSE, $fail_gracefully = FALSE) * @param string an optional object name * @return void */ - function driver($library = '', $params = NULL, $object_name = NULL) + public function driver($library = '', $params = NULL, $object_name = NULL) { if ( ! class_exists('CI_Driver_Library')) { // we aren't instantiating an object here, that'll be done by the Library itself - require BASEPATH.'libraries/Driver'.EXT; + require BASEPATH.'libraries/Driver.php'; } // We can save the loader some time since Drivers will *always* be in a subfolder, @@ -520,11 +633,11 @@ function driver($library = '', $params = NULL, $object_name = NULL) * * Prepends a parent path to the library, model, helper, and config path arrays * - * @access public * @param string + * @param boolean * @return void */ - function add_package_path($path) + public function add_package_path($path, $view_cascade=TRUE) { $path = rtrim($path, '/').'/'; @@ -532,6 +645,8 @@ function add_package_path($path) array_unshift($this->_ci_model_paths, $path); array_unshift($this->_ci_helper_paths, $path); + $this->_ci_view_paths = array($path.'views/' => $view_cascade) + $this->_ci_view_paths; + // Add config file path $config =& $this->_ci_get_component('config'); array_unshift($config->_config_paths, $path); @@ -544,11 +659,10 @@ function add_package_path($path) * * Return a list of all package paths, by default it will ignore BASEPATH. * - * @access public * @param string * @return void */ - function get_package_paths($include_base = FALSE) + public function get_package_paths($include_base = FALSE) { return $include_base === TRUE ? $this->_ci_library_paths : $this->_ci_model_paths; } @@ -561,11 +675,11 @@ function get_package_paths($include_base = FALSE) * Remove a path from the library, model, and helper path arrays if it exists * If no path is provided, the most recently added path is removed. * - * @access public * @param type + * @param bool * @return type */ - function remove_package_path($path = '', $remove_config_path = TRUE) + public function remove_package_path($path = '', $remove_config_path = TRUE) { $config =& $this->_ci_get_component('config'); @@ -574,12 +688,12 @@ function remove_package_path($path = '', $remove_config_path = TRUE) $void = array_shift($this->_ci_library_paths); $void = array_shift($this->_ci_model_paths); $void = array_shift($this->_ci_helper_paths); + $void = array_shift($this->_ci_view_paths); $void = array_shift($config->_config_paths); } else { $path = rtrim($path, '/').'/'; - foreach (array('_ci_library_paths', '_ci_model_paths', '_ci_helper_paths') as $var) { if (($key = array_search($path, $this->{$var})) !== FALSE) @@ -588,6 +702,11 @@ function remove_package_path($path = '', $remove_config_path = TRUE) } } + if (isset($this->_ci_view_paths[$path.'views/'])) + { + unset($this->_ci_view_paths[$path.'views/']); + } + if (($key = array_search($path, $config->_config_paths)) !== FALSE) { unset($config->_config_paths[$key]); @@ -598,6 +717,7 @@ function remove_package_path($path = '', $remove_config_path = TRUE) $this->_ci_library_paths = array_unique(array_merge($this->_ci_library_paths, array(APPPATH, BASEPATH))); $this->_ci_helper_paths = array_unique(array_merge($this->_ci_helper_paths, array(APPPATH, BASEPATH))); $this->_ci_model_paths = array_unique(array_merge($this->_ci_model_paths, array(APPPATH))); + $this->_ci_view_paths = array_merge($this->_ci_view_paths, array(APPPATH.'views/' => TRUE)); $config->_config_paths = array_unique(array_merge($config->_config_paths, array(APPPATH))); } @@ -610,11 +730,10 @@ function remove_package_path($path = '', $remove_config_path = TRUE) * Variables are prefixed with _ci_ to avoid symbol collision with * variables made available to view files * - * @access private * @param array * @return void */ - function _ci_load($_ci_data) + protected function _ci_load($_ci_data) { // Set the default data variables foreach (array('_ci_view', '_ci_vars', '_ci_path', '_ci_return') as $_ci_val) @@ -622,20 +741,36 @@ function _ci_load($_ci_data) $$_ci_val = ( ! isset($_ci_data[$_ci_val])) ? FALSE : $_ci_data[$_ci_val]; } + $file_exists = FALSE; + // Set the path to the requested file - if ($_ci_path == '') + if ($_ci_path != '') { - $_ci_ext = pathinfo($_ci_view, PATHINFO_EXTENSION); - $_ci_file = ($_ci_ext == '') ? $_ci_view.EXT : $_ci_view; - $_ci_path = $this->_ci_view_path.$_ci_file; + $_ci_x = explode('/', $_ci_path); + $_ci_file = end($_ci_x); } else { - $_ci_x = explode('/', $_ci_path); - $_ci_file = end($_ci_x); + $_ci_ext = pathinfo($_ci_view, PATHINFO_EXTENSION); + $_ci_file = ($_ci_ext == '') ? $_ci_view.'.php' : $_ci_view; + + foreach ($this->_ci_view_paths as $view_file => $cascade) + { + if (file_exists($view_file.$_ci_file)) + { + $_ci_path = $view_file.$_ci_file; + $file_exists = TRUE; + break; + } + + if ( ! $cascade) + { + break; + } + } } - if ( ! file_exists($_ci_path)) + if ( ! $file_exists && ! file_exists($_ci_path)) { show_error('Unable to load the requested file: '.$_ci_file); } @@ -731,18 +866,17 @@ function _ci_load($_ci_data) * * This function loads the requested class. * - * @access private * @param string the item that is being loaded * @param mixed any additional parameters * @param string an optional object name * @return void */ - function _ci_load_class($class, $params = NULL, $object_name = NULL) + protected function _ci_load_class($class, $params = NULL, $object_name = NULL) { // Get the class name, and while we're at it trim any slashes. // The directory path can be included as part of the class name, // but we don't want a leading slash - $class = str_replace(EXT, '', trim($class, '/')); + $class = str_replace('.php', '', trim($class, '/')); // Was the path included with the class name? // We look for a slash to determine this @@ -759,12 +893,12 @@ function _ci_load_class($class, $params = NULL, $object_name = NULL) // We'll test for both lowercase and capitalized versions of the file name foreach (array(ucfirst($class), strtolower($class)) as $class) { - $subclass = APPPATH.'libraries/'.$subdir.config_item('subclass_prefix').$class.EXT; + $subclass = APPPATH.'libraries/'.$subdir.config_item('subclass_prefix').$class.'.php'; // Is this a class extension request? if (file_exists($subclass)) { - $baseclass = BASEPATH.'libraries/'.ucfirst($class).EXT; + $baseclass = BASEPATH.'libraries/'.ucfirst($class).'.php'; if ( ! file_exists($baseclass)) { @@ -803,7 +937,7 @@ function _ci_load_class($class, $params = NULL, $object_name = NULL) $is_duplicate = FALSE; foreach ($this->_ci_library_paths as $path) { - $filepath = $path.'libraries/'.$subdir.$class.EXT; + $filepath = $path.'libraries/'.$subdir.$class.'.php'; // Does the file exist? No? Bummer... if ( ! file_exists($filepath)) @@ -859,13 +993,13 @@ function _ci_load_class($class, $params = NULL, $object_name = NULL) /** * Instantiates a class * - * @access private * @param string * @param string + * @param bool * @param string an optional object name * @return null */ - function _ci_init_class($class, $prefix = '', $config = FALSE, $object_name = NULL) + protected function _ci_init_class($class, $prefix = '', $config = FALSE, $object_name = NULL) { // Is there an associated config file for this class? Note: these should always be lowercase if ($config === NULL) @@ -880,15 +1014,26 @@ function _ci_init_class($class, $prefix = '', $config = FALSE, $object_name = NU foreach ($config_component->_config_paths as $path) { // We test for both uppercase and lowercase, for servers that - // are case-sensitive with regard to file names - if (file_exists($path .'config/'.strtolower($class).EXT)) + // are case-sensitive with regard to file names. Check for environment + // first, global next + if (defined('ENVIRONMENT') AND file_exists($path .'config/'.ENVIRONMENT.'/'.strtolower($class).'.php')) + { + include_once($path .'config/'.ENVIRONMENT.'/'.strtolower($class).'.php'); + break; + } + elseif (defined('ENVIRONMENT') AND file_exists($path .'config/'.ENVIRONMENT.'/'.ucfirst(strtolower($class)).'.php')) { - include_once($path .'config/'.strtolower($class).EXT); + include_once($path .'config/'.ENVIRONMENT.'/'.ucfirst(strtolower($class)).'.php'); break; } - elseif (file_exists($path .'config/'.ucfirst(strtolower($class)).EXT)) + elseif (file_exists($path .'config/'.strtolower($class).'.php')) { - include_once($path .'config/'.ucfirst(strtolower($class)).EXT); + include_once($path .'config/'.strtolower($class).'.php'); + break; + } + elseif (file_exists($path .'config/'.ucfirst(strtolower($class)).'.php')) + { + include_once($path .'config/'.ucfirst(strtolower($class)).'.php'); break; } } @@ -958,19 +1103,34 @@ function _ci_init_class($class, $prefix = '', $config = FALSE, $object_name = NU * The config/autoload.php file contains an array that permits sub-systems, * libraries, and helpers to be loaded automatically. * - * @access private * @param array * @return void */ - function _ci_autoloader() + private function _ci_autoloader() { - include_once(APPPATH.'config/autoload'.EXT); + if (defined('ENVIRONMENT') AND file_exists(APPPATH.'config/'.ENVIRONMENT.'/autoload.php')) + { + include(APPPATH.'config/'.ENVIRONMENT.'/autoload.php'); + } + else + { + include(APPPATH.'config/autoload.php'); + } if ( ! isset($autoload)) { return FALSE; } + // Autoload packages + if (isset($autoload['packages'])) + { + foreach ($autoload['packages'] as $package_path) + { + $this->add_package_path($package_path); + } + } + // Load any custom config file if (count($autoload['config']) > 0) { @@ -1028,11 +1188,10 @@ function _ci_autoloader() * * Takes an object as input and converts the class variables to array key/vals * - * @access private * @param object * @return array */ - function _ci_object_to_array($object) + protected function _ci_object_to_array($object) { return (is_object($object)) ? get_object_vars($object) : $object; } @@ -1042,10 +1201,10 @@ function _ci_object_to_array($object) /** * Get a reference to a specific library or model * - * @access private + * @param string * @return bool */ - function &_ci_get_component($component) + protected function &_ci_get_component($component) { $CI =& get_instance(); return $CI->$component; @@ -1058,29 +1217,27 @@ function &_ci_get_component($component) * * This function preps the name of various items to make loading them more reliable. * - * @access private * @param mixed + * @param string * @return array */ - function _ci_prep_filename($filename, $extension) + protected function _ci_prep_filename($filename, $extension) { if ( ! is_array($filename)) { - return array(strtolower(str_replace(EXT, '', str_replace($extension, '', $filename)).$extension)); + return array(strtolower(str_replace('.php', '', str_replace($extension, '', $filename)).$extension)); } else { foreach ($filename as $key => $val) { - $filename[$key] = strtolower(str_replace(EXT, '', str_replace($extension, '', $val)).$extension); + $filename[$key] = strtolower(str_replace('.php', '', str_replace($extension, '', $val)).$extension); } return $filename; } } - - } /* End of file Loader.php */ -/* Location: ./system/core/Loader.php */ \ No newline at end of file +/* Location: ./system/core/Loader.php */ diff --git a/system/core/Model.php b/system/core/Model.php index 80f4b04a..e15ffbeb 100644 --- a/system/core/Model.php +++ b/system/core/Model.php @@ -6,7 +6,7 @@ * * @package CodeIgniter * @author ExpressionEngine Dev Team - * @copyright Copyright (c) 2008 - 2010, EllisLab, Inc. + * @copyright Copyright (c) 2008 - 2011, EllisLab, Inc. * @license http://codeigniter.com/user_guide/license.html * @link http://codeigniter.com * @since Version 1.0 @@ -42,6 +42,7 @@ function __construct() * Allows models to access CI's loaded classes using the same * syntax as controllers. * + * @param string * @access private */ function __get($key) diff --git a/system/core/Output.php b/system/core/Output.php index 0b708e11..ccecafd2 100644 --- a/system/core/Output.php +++ b/system/core/Output.php @@ -6,7 +6,7 @@ * * @package CodeIgniter * @author ExpressionEngine Dev Team - * @copyright Copyright (c) 2008 - 2010, EllisLab, Inc. + * @copyright Copyright (c) 2008 - 2011, EllisLab, Inc. * @license http://codeigniter.com/user_guide/license.html * @link http://codeigniter.com * @since Version 1.0 @@ -28,19 +28,84 @@ */ class CI_Output { - var $final_output; - var $cache_expiration = 0; - var $headers = array(); - var $enable_profiler = FALSE; - var $parse_exec_vars = TRUE; // whether or not to parse variables like {elapsed_time} and {memory_usage} - - var $_zlib_oc = FALSE; - var $_profiler_sections = array(); + /** + * Current output string + * + * @var string + * @access protected + */ + protected $final_output; + /** + * Cache expiration time + * + * @var int + * @access protected + */ + protected $cache_expiration = 0; + /** + * List of server headers + * + * @var array + * @access protected + */ + protected $headers = array(); + /** + * List of mime types + * + * @var array + * @access protected + */ + protected $mime_types = array(); + /** + * Determines wether profiler is enabled + * + * @var book + * @access protected + */ + protected $enable_profiler = FALSE; + /** + * Determines if output compression is enabled + * + * @var bool + * @access protected + */ + protected $_zlib_oc = FALSE; + /** + * List of profiler sections + * + * @var array + * @access protected + */ + protected $_profiler_sections = array(); + /** + * Whether or not to parse variables like {elapsed_time} and {memory_usage} + * + * @var bool + * @access protected + */ + protected $parse_exec_vars = TRUE; + /** + * Constructor + * + */ function __construct() { $this->_zlib_oc = @ini_get('zlib.output_compression'); + // Get mime types for later + if (defined('ENVIRONMENT') AND file_exists(APPPATH.'config/'.ENVIRONMENT.'/mimes.php')) + { + include APPPATH.'config/'.ENVIRONMENT.'/mimes.php'; + } + else + { + include APPPATH.'config/mimes.php'; + } + + + $this->mime_types = $mimes; + log_message('debug', "Output Class Initialized"); } @@ -73,6 +138,8 @@ function get_output() function set_output($output) { $this->final_output = $output; + + return $this; } // -------------------------------------------------------------------- @@ -96,6 +163,8 @@ function append_output($output) { $this->final_output .= $output; } + + return $this; } // -------------------------------------------------------------------- @@ -110,6 +179,7 @@ function append_output($output) * * @access public * @param string + * @param bool * @return void */ function set_header($header, $replace = TRUE) @@ -125,6 +195,42 @@ function set_header($header, $replace = TRUE) } $this->headers[] = array($header, $replace); + + return $this; + } + + // -------------------------------------------------------------------- + + /** + * Set Content Type Header + * + * @access public + * @param string extension of the file we're outputting + * @return void + */ + function set_content_type($mime_type) + { + if (strpos($mime_type, '/') === FALSE) + { + $extension = ltrim($mime_type, '.'); + + // Is this extension supported? + if (isset($this->mime_types[$extension])) + { + $mime_type =& $this->mime_types[$extension]; + + if (is_array($mime_type)) + { + $mime_type = current($mime_type); + } + } + } + + $header = 'Content-Type: '.$mime_type; + + $this->headers[] = array($header, TRUE); + + return $this; } // -------------------------------------------------------------------- @@ -141,6 +247,8 @@ function set_header($header, $replace = TRUE) function set_status_header($code = 200, $text = '') { set_status_header($code, $text); + + return $this; } // -------------------------------------------------------------------- @@ -155,6 +263,8 @@ function set_status_header($code = 200, $text = '') function enable_profiler($val = TRUE) { $this->enable_profiler = (is_bool($val)) ? $val : TRUE; + + return $this; } // -------------------------------------------------------------------- @@ -174,6 +284,8 @@ function set_profiler_sections($sections) { $this->_profiler_sections[$section] = ($enable !== FALSE) ? TRUE : FALSE; } + + return $this; } // -------------------------------------------------------------------- @@ -188,6 +300,8 @@ function set_profiler_sections($sections) function cache($time) { $this->cache_expiration = ( ! is_numeric($time)) ? 0 : $time; + + return $this; } // -------------------------------------------------------------------- @@ -204,6 +318,7 @@ function cache($time) * benchmark timer so the page rendering speed and memory usage can be shown. * * @access public + * @param string * @return mixed */ function _display($output = '') @@ -340,6 +455,7 @@ function _display($output = '') * Write a Cache File * * @access public + * @param string * @return void */ function _write_cache($output) @@ -347,7 +463,7 @@ function _write_cache($output) $CI =& get_instance(); $path = $CI->config->item('cache_path'); - $cache_path = ($path == '') ? BASEPATH.'cache/' : $path; + $cache_path = ($path == '') ? APPPATH.'cache/' : $path; if ( ! is_dir($cache_path) OR ! is_really_writable($cache_path)) { @@ -391,11 +507,13 @@ function _write_cache($output) * Update/serve a cached file * * @access public + * @param object config class + * @param object uri class * @return void */ function _display_cache(&$CFG, &$URI) { - $cache_path = ($CFG->item('cache_path') == '') ? BASEPATH.'cache/' : $CFG->item('cache_path'); + $cache_path = ($CFG->item('cache_path') == '') ? APPPATH.'cache/' : $CFG->item('cache_path'); // Build the file path. The file name is an MD5 hash of the full URI $uri = $CFG->item('base_url'). diff --git a/system/core/Router.php b/system/core/Router.php index 79a8b4fc..6da66747 100644 --- a/system/core/Router.php +++ b/system/core/Router.php @@ -6,7 +6,7 @@ * * @package CodeIgniter * @author ExpressionEngine Dev Team - * @copyright Copyright (c) 2008 - 2010, EllisLab, Inc. + * @copyright Copyright (c) 2008 - 2011, EllisLab, Inc. * @license http://codeigniter.com/user_guide/license.html * @link http://codeigniter.com * @since Version 1.0 @@ -28,12 +28,54 @@ */ class CI_Router { + /** + * Config class + * + * @var object + * @access public + */ var $config; + /** + * List of routes + * + * @var array + * @access public + */ var $routes = array(); + /** + * List of error routes + * + * @var array + * @access public + */ var $error_routes = array(); + /** + * Current class name + * + * @var string + * @access public + */ var $class = ''; + /** + * Current method name + * + * @var string + * @access public + */ var $method = 'index'; + /** + * Sub-directory that contains the requested controller class + * + * @var string + * @access public + */ var $directory = ''; + /** + * Default controller (and method if specific) + * + * @var string + * @access public + */ var $default_controller; /** @@ -87,7 +129,15 @@ function _set_routing() } // Load the routes.php file. - @include(APPPATH.'config/routes'.EXT); + if (defined('ENVIRONMENT') AND is_file(APPPATH.'config/'.ENVIRONMENT.'/routes.php')) + { + include(APPPATH.'config/'.ENVIRONMENT.'/routes.php'); + } + elseif (is_file(APPPATH.'config/routes.php')) + { + include(APPPATH.'config/routes.php'); + } + $this->routes = ( ! isset($route) OR ! is_array($route)) ? array() : $route; unset($route); @@ -144,7 +194,7 @@ function _set_default_controller() $this->set_class($x[0]); $this->set_method($x[1]); - $this->_set_request(array($x[0], $x[1])); + $this->_set_request($x); } else { @@ -219,7 +269,7 @@ function _validate_request($segments) } // Does the requested controller exist in the root folder? - if (file_exists(APPPATH.'controllers/'.$segments[0].EXT)) + if (file_exists(APPPATH.'controllers/'.$segments[0].'.php')) { return $segments; } @@ -234,9 +284,22 @@ function _validate_request($segments) if (count($segments) > 0) { // Does the requested controller exist in the sub-folder? - if ( ! file_exists(APPPATH.'controllers/'.$this->fetch_directory().$segments[0].EXT)) + if ( ! file_exists(APPPATH.'controllers/'.$this->fetch_directory().$segments[0].'.php')) { - show_404($this->fetch_directory().$segments[0]); + if ( ! empty($this->routes['404_override'])) + { + $x = explode('/', $this->routes['404_override']); + + $this->set_directory(''); + $this->set_class($x[0]); + $this->set_method(isset($x[1]) ? $x[1] : 'index'); + + return $x; + } + else + { + show_404($this->fetch_directory().$segments[0]); + } } } else @@ -256,7 +319,7 @@ function _validate_request($segments) } // Does the default controller exist in the sub-folder? - if ( ! file_exists(APPPATH.'controllers/'.$this->fetch_directory().$this->default_controller.EXT)) + if ( ! file_exists(APPPATH.'controllers/'.$this->fetch_directory().$this->default_controller.'.php')) { $this->directory = ''; return array(); @@ -270,7 +333,7 @@ function _validate_request($segments) // If we've gotten this far it means that the URI does not correlate to a valid // controller class. We will now see if there is an override - if (!empty($this->routes['404_override'])) + if ( ! empty($this->routes['404_override'])) { $x = explode('/', $this->routes['404_override']); diff --git a/system/libraries/Security.php b/system/core/Security.php similarity index 60% rename from system/libraries/Security.php rename to system/core/Security.php index d2638560..dcc680a1 100644 --- a/system/libraries/Security.php +++ b/system/core/Security.php @@ -6,7 +6,7 @@ * * @package CodeIgniter * @author ExpressionEngine Dev Team - * @copyright Copyright (c) 2008 - 2010, EllisLab, Inc. + * @copyright Copyright (c) 2008 - 2011, EllisLab, Inc. * @license http://codeigniter.com/user_guide/license.html * @link http://codeigniter.com * @since Version 1.0 @@ -22,39 +22,97 @@ * @subpackage Libraries * @category Security * @author ExpressionEngine Dev Team - * @link http://codeigniter.com/user_guide/libraries/sessions.html + * @link http://codeigniter.com/user_guide/libraries/security.html */ class CI_Security { - var $xss_hash = ''; - var $csrf_hash = ''; - var $csrf_expire = 7200; // Two hours (in seconds) - var $csrf_token_name = 'ci_csrf_token'; - var $csrf_cookie_name = 'ci_csrf_token'; - - /* never allowed, string replacement */ - var $never_allowed_str = array( - 'document.cookie' => '[removed]', - 'document.write' => '[removed]', - '.parentNode' => '[removed]', - '.innerHTML' => '[removed]', - 'window.location' => '[removed]', - '-moz-binding' => '[removed]', - '' => '-->', - ' '<![CDATA[' - ); + + /** + * Random Hash for protecting URLs + * + * @var string + * @access protected + */ + protected $_xss_hash = ''; + /** + * Random Hash for Cross Site Request Forgery Protection Cookie + * + * @var string + * @access protected + */ + protected $_csrf_hash = ''; + /** + * Expiration time for Cross Site Request Forgery Protection Cookie + * Defaults to two hours (in seconds) + * + * @var int + * @access protected + */ + protected $_csrf_expire = 7200; + /** + * Token name for Cross Site Request Forgery Protection Cookie + * + * @var string + * @access protected + */ + protected $_csrf_token_name = 'ci_csrf_token'; + /** + * Cookie name for Cross Site Request Forgery Protection Cookie + * + * @var string + * @access protected + */ + protected $_csrf_cookie_name = 'ci_csrf_token'; + /** + * List of never allowed strings + * + * @var array + * @access protected + */ + protected $_never_allowed_str = array( + 'document.cookie' => '[removed]', + 'document.write' => '[removed]', + '.parentNode' => '[removed]', + '.innerHTML' => '[removed]', + 'window.location' => '[removed]', + '-moz-binding' => '[removed]', + '' => '-->', + ' '<![CDATA[' + ); + /* never allowed, regex replacement */ - var $never_allowed_regex = array( - "javascript\s*:" => '[removed]', - "expression\s*(\(|&\#40;)" => '[removed]', // CSS and IE - "vbscript\s*:" => '[removed]', // IE, surprise! - "Redirect\s+302" => '[removed]' - ); + /** + * List of never allowed regex replacement + * + * @var array + * @access protected + */ + protected $_never_allowed_regex = array( + "javascript\s*:" => '[removed]', + "expression\s*(\(|&\#40;)" => '[removed]', // CSS and IE + "vbscript\s*:" => '[removed]', // IE, surprise! + "Redirect\s+302" => '[removed]' + ); + /** + * Constructor + */ public function __construct() { - // Append application specific cookie prefix to token name - $this->csrf_cookie_name = (config_item('cookie_prefix')) ? config_item('cookie_prefix').$this->csrf_token_name : $this->csrf_token_name; + // CSRF config + foreach(array('csrf_expire', 'csrf_token_name', 'csrf_cookie_name') as $key) + { + if (FALSE !== ($val = config_item($key))) + { + $this->{'_'.$key} = $val; + } + } + + // Append application specific cookie prefix + if (config_item('cookie_prefix')) + { + $this->_csrf_cookie_name = config_item('cookie_prefix').$this->_csrf_cookie_name; + } // Set the CSRF hash $this->_csrf_set_hash(); @@ -67,10 +125,9 @@ public function __construct() /** * Verify Cross Site Request Forgery Protection * - * @access public - * @return null + * @return object */ - function csrf_verify() + public function csrf_verify() { // If no POST data exists we will set the CSRF cookie if (count($_POST) == 0) @@ -79,26 +136,30 @@ function csrf_verify() } // Do the tokens exist in both the _POST and _COOKIE arrays? - if ( ! isset($_POST[$this->csrf_token_name]) OR ! isset($_COOKIE[$this->csrf_cookie_name])) + if ( ! isset($_POST[$this->_csrf_token_name]) OR + ! isset($_COOKIE[$this->_csrf_cookie_name])) { $this->csrf_show_error(); } // Do the tokens match? - if ($_POST[$this->csrf_token_name] != $_COOKIE[$this->csrf_cookie_name]) + if ($_POST[$this->_csrf_token_name] != $_COOKIE[$this->_csrf_cookie_name]) { $this->csrf_show_error(); } - // We kill this since we're done and we don't want to polute the _POST array - unset($_POST[$this->csrf_token_name]); + // We kill this since we're done and we don't want to + // polute the _POST array + unset($_POST[$this->_csrf_token_name]); // Nothing should last forever - unset($_COOKIE[$this->csrf_cookie_name]); + unset($_COOKIE[$this->_csrf_cookie_name]); $this->_csrf_set_hash(); $this->csrf_set_cookie(); log_message('debug', "CSRF token verified "); + + return $this; } // -------------------------------------------------------------------- @@ -106,56 +167,68 @@ function csrf_verify() /** * Set Cross Site Request Forgery Protection Cookie * - * @access public - * @return null + * @return object */ - function csrf_set_cookie() + public function csrf_set_cookie() { - $expire = time() + $this->csrf_expire; + $expire = time() + $this->_csrf_expire; + $secure_cookie = (config_item('cookie_secure') === TRUE) ? 1 : 0; - setcookie($this->csrf_cookie_name, $this->csrf_hash, $expire, config_item('cookie_path'), config_item('cookie_domain'), 0); + if ($secure_cookie) + { + $req = isset($_SERVER['HTTPS']) ? $_SERVER['HTTPS'] : FALSE; + + if ( ! $req OR $req == 'off') + { + return FALSE; + } + } + + setcookie($this->_csrf_cookie_name, $this->_csrf_hash, $expire, config_item('cookie_path'), config_item('cookie_domain'), $secure_cookie); log_message('debug', "CRSF cookie Set"); + + return $this; } // -------------------------------------------------------------------- /** - * Set Cross Site Request Forgery Protection Cookie + * Show CSRF Error * - * @access public - * @return null + * @return void */ - function _csrf_set_hash() + public function csrf_show_error() { - if ($this->csrf_hash == '') - { - // If the cookie exists we will use it's value. We don't necessarily want to regenerate it with - // each page load since a page could contain embedded sub-pages causing this feature to fail - if (isset($_COOKIE[$this->csrf_cookie_name]) AND $_COOKIE[$this->csrf_cookie_name] != '') - { - $this->csrf_hash = $_COOKIE[$this->csrf_cookie_name]; - } - else - { - $this->csrf_hash = md5(uniqid(rand(), TRUE)); - } - } + show_error('The action you have requested is not allowed.'); + } - return $this->csrf_hash; + // -------------------------------------------------------------------- + + /** + * Get CSRF Hash + * + * Getter Method + * + * @return string self::_csrf_hash + */ + public function get_csrf_hash() + { + return $this->_csrf_hash; } // -------------------------------------------------------------------- /** - * Show CSRF Error + * Get CSRF Token Name + * + * Getter Method * - * @access public - * @return null + * @return string self::csrf_token_name */ - function csrf_show_error() + public function get_csrf_token_name() { - show_error('The action you have requested is not allowed.'); + return $this->_csrf_token_name; } // -------------------------------------------------------------------- @@ -182,11 +255,11 @@ function csrf_show_error() * harvested from examining vulnerabilities in other programs: * http://ha.ckers.org/xss.html * - * @access public * @param mixed string or array + * @param bool * @return string */ - function xss_clean($str, $is_image = FALSE) + public function xss_clean($str, $is_image = FALSE) { /* * Is the string an array? @@ -207,35 +280,8 @@ function xss_clean($str, $is_image = FALSE) */ $str = remove_invisible_characters($str); - /* - * Protect GET variables in URLs - */ - - // 901119URL5918AMP18930PROTECT8198 - - $str = preg_replace('|\&([a-z\_0-9\-]+)\=([a-z\_0-9\-]+)|i', $this->xss_hash()."\\1=\\2", $str); - - /* - * Validate standard character entities - * - * Add a semicolon if missing. We do this to enable - * the conversion of entities to ASCII later. - * - */ - $str = preg_replace('#(&\#?[0-9a-z]{2,})([\x00-\x20])*;?#i', "\\1;\\2", $str); - - /* - * Validate UTF16 two byte encoding (x00) - * - * Just as above, adds a semicolon if missing. - * - */ - $str = preg_replace('#(&\#x?)([0-9A-F]+);?#i',"\\1\\2;",$str); - - /* - * Un-Protect GET variables in URLs - */ - $str = str_replace($this->xss_hash(), '&', $str); + // Validate Entities in URLs + $str = $this->_validate_entities($str); /* * URL Decode @@ -259,7 +305,7 @@ function xss_clean($str, $is_image = FALSE) */ $str = preg_replace_callback("/[a-z]+=([\'\"]).*?\\1/si", array($this, '_convert_attribute'), $str); - + $str = preg_replace_callback("/<\w+.*?(?=>|<|$)/si", array($this, '_decode_entity'), $str); /* @@ -272,9 +318,8 @@ function xss_clean($str, $is_image = FALSE) * * This prevents strings like this: ja vascript * NOTE: we deal with spaces between characters later. - * NOTE: preg_replace was found to be amazingly slow here on large blocks of data, - * so we use str_replace. - * + * NOTE: preg_replace was found to be amazingly slow here on + * large blocks of data, so we use str_replace. */ if (strpos($str, "\t") !== FALSE) @@ -287,34 +332,23 @@ function xss_clean($str, $is_image = FALSE) */ $converted_string = $str; - /* - * Not Allowed Under Any Conditions - */ - - foreach ($this->never_allowed_str as $key => $val) - { - $str = str_replace($key, $val, $str); - } - - foreach ($this->never_allowed_regex as $key => $val) - { - $str = preg_replace("#".$key."#i", $val, $str); - } + // Remove Strings that are never allowed + $str = $this->_do_never_allowed($str); /* * Makes PHP tags safe * - * Note: XML tags are inadvertently replaced too: + * Note: XML tags are inadvertently replaced too: * - * , - * but it's unlikely to be a problem. - * - */ - $event_handlers = array('[^a-z_\-]on\w*','xmlns'); - - if ($is_image === TRUE) - { - /* - * Adobe Photoshop puts XML metadata into JFIF images, including namespacing, - * so we have to allow this for images. -Paul - */ - unset($event_handlers[array_search('xmlns', $event_handlers)]); - } - - $str = preg_replace("#<([^><]+?)(".implode('|', $event_handlers).")(\s*=\s*[^><]*)([><]*)#i", "<\\1\\4", $str); + // Remove evil attributes such as style, onclick and xmlns + $str = $this->_remove_evil_attributes($str, $is_image); /* * Sanitize naughty HTML elements @@ -401,7 +421,6 @@ function xss_clean($str, $is_image = FALSE) * * So this: * Becomes: <blink> - * */ $naughty = 'alert|applet|audio|basefont|base|behavior|bgsound|blink|body|embed|expression|form|frameset|frame|head|html|ilayer|iframe|input|isindex|layer|link|meta|object|plaintext|style|script|textarea|title|video|xml|xss'; $str = preg_replace_callback('#<(/*\s*)('.$naughty.')([^><]*)([><]*)#is', array($this, '_sanitize_naughty_html'), $str); @@ -417,45 +436,28 @@ function xss_clean($str, $is_image = FALSE) * * For example: eval('some code') * Becomes: eval('some code') - * */ $str = preg_replace('#(alert|cmd|passthru|eval|exec|expression|system|fopen|fsockopen|file|file_get_contents|readfile|unlink)(\s*)\((.*?)\)#si', "\\1\\2(\\3)", $str); - /* - * Final clean up - * - * This adds a bit of extra precaution in case - * something got through the above filters - * - */ - foreach ($this->never_allowed_str as $key => $val) - { - $str = str_replace($key, $val, $str); - } - foreach ($this->never_allowed_regex as $key => $val) - { - $str = preg_replace("#".$key."#i", $val, $str); - } + // Final clean up + // This adds a bit of extra precaution in case + // something got through the above filters + $str = $this->_do_never_allowed($str); /* - * Images are Handled in a Special Way - * - Essentially, we want to know that after all of the character conversion is done whether - * any unwanted, likely XSS, code was found. If not, we return TRUE, as the image is clean. - * However, if the string post-conversion does not matched the string post-removal of XSS, - * then it fails, as there was unwanted XSS code found and removed/changed during processing. + * Images are Handled in a Special Way + * - Essentially, we want to know that after all of the character + * conversion is done whether any unwanted, likely XSS, code was found. + * If not, we return TRUE, as the image is clean. + * However, if the string post-conversion does not matched the + * string post-removal of XSS, then it fails, as there was unwanted XSS + * code found and removed/changed during processing. */ if ($is_image === TRUE) { - if ($str == $converted_string) - { - return TRUE; - } - else - { - return FALSE; - } + return ($str == $converted_string) ? TRUE: FALSE; } log_message('debug', "XSS Filtering completed"); @@ -467,59 +469,209 @@ function xss_clean($str, $is_image = FALSE) /** * Random Hash for protecting URLs * - * @access public * @return string */ - function xss_hash() + public function xss_hash() { - if ($this->xss_hash == '') + if ($this->_xss_hash == '') { if (phpversion() >= 4.2) + { mt_srand(); + } else + { mt_srand(hexdec(substr(md5(microtime()), -8)) & 0x7fffffff); + } + + $this->_xss_hash = md5(time() + mt_rand(0, 1999999999)); + } + + return $this->_xss_hash; + } + + // -------------------------------------------------------------------- + + /** + * HTML Entities Decode + * + * This function is a replacement for html_entity_decode() + * + * In some versions of PHP the native function does not work + * when UTF-8 is the specified character set, so this gives us + * a work-around. More info here: + * http://bugs.php.net/bug.php?id=25670 + * + * NOTE: html_entity_decode() has a bug in some PHP versions when UTF-8 is the + * character set, and the PHP developers said they were not back porting the + * fix to versions other than PHP 5.x. + * + * @param string + * @param string + * @return string + */ + public function entity_decode($str, $charset='UTF-8') + { + if (stristr($str, '&') === FALSE) return $str; + + // The reason we are not using html_entity_decode() by itself is because + // while it is not technically correct to leave out the semicolon + // at the end of an entity most browsers will still interpret the entity + // correctly. html_entity_decode() does not convert entities without + // semicolons, so we are left with our own little solution here. Bummer. - $this->xss_hash = md5(time() + mt_rand(0, 1999999999)); + if (function_exists('html_entity_decode') && + (strtolower($charset) != 'utf-8')) + { + $str = html_entity_decode($str, ENT_COMPAT, $charset); + $str = preg_replace('~&#x(0*[0-9a-f]{2,5})~ei', 'chr(hexdec("\\1"))', $str); + return preg_replace('~&#([0-9]{2,4})~e', 'chr(\\1)', $str); + } + + // Numeric Entities + $str = preg_replace('~&#x(0*[0-9a-f]{2,5});{0,1}~ei', 'chr(hexdec("\\1"))', $str); + $str = preg_replace('~&#([0-9]{2,4});{0,1}~e', 'chr(\\1)', $str); + + // Literal Entities - Slightly slow so we do another check + if (stristr($str, '&') === FALSE) + { + $str = strtr($str, array_flip(get_html_translation_table(HTML_ENTITIES))); } - return $this->xss_hash; + return $str; } // -------------------------------------------------------------------- + /** + * Filename Security + * + * @param string + * @param bool + * @return string + */ + public function sanitize_filename($str, $relative_path = FALSE) + { + $bad = array( + "../", + "", + "<", + ">", + "'", + '"', + '&', + '$', + '#', + '{', + '}', + '[', + ']', + '=', + ';', + '?', + "%20", + "%22", + "%3c", // < + "%253c", // < + "%3e", // > + "%0e", // > + "%28", // ( + "%29", // ) + "%2528", // ( + "%26", // & + "%24", // $ + "%3f", // ? + "%3b", // ; + "%3d" // = + ); + + if ( ! $relative_path) + { + $bad[] = './'; + $bad[] = '/'; + } + + $str = remove_invisible_characters($str, FALSE); + return stripslashes(str_replace($bad, '', $str)); + } + + // ---------------------------------------------------------------- + /** * Compact Exploded Words * * Callback function for xss_clean() to remove whitespace from * things like j a v a s c r i p t * - * @access public * @param type * @return type */ - function _compact_exploded_words($matches) + protected function _compact_exploded_words($matches) { return preg_replace('/\s+/s', '', $matches[1]).$matches[2]; } // -------------------------------------------------------------------- + /* + * Remove Evil HTML Attributes (like evenhandlers and style) + * + * It removes the evil attribute and either: + * - Everything up until a space + * For example, everything between the pipes: + * + * - Everything inside the quotes + * For example, everything between the pipes: + * + * + * @param string $str The string to check + * @param boolean $is_image TRUE if this is an image + * @return string The string with the evil attributes removed + */ + protected function _remove_evil_attributes($str, $is_image) + { + // All javascript event handlers (e.g. onload, onclick, onmouseover), style, and xmlns + $evil_attributes = array('on\w*', 'style', 'xmlns'); + + if ($is_image === TRUE) + { + /* + * Adobe Photoshop puts XML metadata into JFIF images, + * including namespacing, so we have to allow this for images. + */ + unset($evil_attributes[array_search('xmlns', $evil_attributes)]); + } + + do { + $str = preg_replace( + "#<(/?[^><]+?)([^A-Za-z\-])(".implode('|', $evil_attributes).")(\s*=\s*)([\"][^>]*?[\"]|[\'][^>]*?[\']|[^>]*?)([\s><])([><]*)#i", + "<$1$6", + $str, -1, $count + ); + } while ($count); + + return $str; + } + + // -------------------------------------------------------------------- + /** * Sanitize Naughty HTML * * Callback function for xss_clean() to remove naughty HTML elements * - * @access private * @param array * @return string */ - function _sanitize_naughty_html($matches) + protected function _sanitize_naughty_html($matches) { // encode opening brace $str = '<'.$matches[1].$matches[2].$matches[3]; // encode captured opening or closing brace to prevent recursive vectors - $str .= str_replace(array('>', '<'), array('>', '<'), $matches[4]); + $str .= str_replace(array('>', '<'), array('>', '<'), + $matches[4]); return $str; } @@ -534,16 +686,18 @@ function _sanitize_naughty_html($matches) * and prevents PREG_BACKTRACK_LIMIT_ERROR from being triggered in * PHP 5.2+ on link-heavy strings * - * @access private * @param array * @return string */ - function _js_link_removal($match) + protected function _js_link_removal($match) { $attributes = $this->_filter_attributes(str_replace(array('<', '>'), '', $match[1])); - return str_replace($match[1], preg_replace("#href=.*?(alert\(|alert&\#40;|javascript\:|charset\=|window\.|document\.|\.cookie|_filter_attributes(str_replace(array('<', '>'), '', $match[1])); - return str_replace($match[1], preg_replace("#src=.*?(alert\(|alert&\#40;|javascript\:|charset\=|window\.|document\.|\.cookie|', '<', '\\'), array('>', '<', '\\\\'), $match[0]); } @@ -585,11 +738,10 @@ function _convert_attribute($match) * * Filters tag attributes for consistency and safety * - * @access public * @param string * @return string */ - function _filter_attributes($str) + protected function _filter_attributes($str) { $out = ''; @@ -611,11 +763,10 @@ function _filter_attributes($str) * * Used as a callback for XSS Clean * - * @access public * @param array * @return string */ - function _decode_entity($match) + protected function _decode_entity($match) { return $this->entity_decode($match[0], strtoupper(config_item('charset'))); } @@ -623,49 +774,68 @@ function _decode_entity($match) // -------------------------------------------------------------------- /** - * HTML Entities Decode - * - * This function is a replacement for html_entity_decode() + * Validate URL entities * - * In some versions of PHP the native function does not work - * when UTF-8 is the specified character set, so this gives us - * a work-around. More info here: - * http://bugs.php.net/bug.php?id=25670 + * Called by xss_clean() * - * NOTE: html_entity_decode() has a bug in some PHP versions when UTF-8 is the - * character set, and the PHP developers said they were not back porting the - * fix to versions other than PHP 5.x. - * - * @access public - * @param string - * @param string - * @return string + * @param string + * @return string */ - function entity_decode($str, $charset='UTF-8') + protected function _validate_entities($str) { - if (stristr($str, '&') === FALSE) return $str; + /* + * Protect GET variables in URLs + */ - // The reason we are not using html_entity_decode() by itself is because - // while it is not technically correct to leave out the semicolon - // at the end of an entity most browsers will still interpret the entity - // correctly. html_entity_decode() does not convert entities without - // semicolons, so we are left with our own little solution here. Bummer. + // 901119URL5918AMP18930PROTECT8198 + + $str = preg_replace('|\&([a-z\_0-9\-]+)\=([a-z\_0-9\-]+)|i', $this->xss_hash()."\\1=\\2", $str); + + /* + * Validate standard character entities + * + * Add a semicolon if missing. We do this to enable + * the conversion of entities to ASCII later. + * + */ + $str = preg_replace('#(&\#?[0-9a-z]{2,})([\x00-\x20])*;?#i', "\\1;\\2", $str); + + /* + * Validate UTF16 two byte encoding (x00) + * + * Just as above, adds a semicolon if missing. + * + */ + $str = preg_replace('#(&\#x?)([0-9A-F]+);?#i',"\\1\\2;",$str); - if (function_exists('html_entity_decode') && (strtolower($charset) != 'utf-8' OR is_php('5.0.0'))) + /* + * Un-Protect GET variables in URLs + */ + $str = str_replace($this->xss_hash(), '&', $str); + + return $str; + } + + // ---------------------------------------------------------------------- + + /** + * Do Never Allowed + * + * A utility function for xss_clean() + * + * @param string + * @return string + */ + protected function _do_never_allowed($str) + { + foreach ($this->_never_allowed_str as $key => $val) { - $str = html_entity_decode($str, ENT_COMPAT, $charset); - $str = preg_replace('~&#x(0*[0-9a-f]{2,5})~ei', 'chr(hexdec("\\1"))', $str); - return preg_replace('~&#([0-9]{2,4})~e', 'chr(\\1)', $str); + $str = str_replace($key, $val, $str); } - // Numeric Entities - $str = preg_replace('~&#x(0*[0-9a-f]{2,5});{0,1}~ei', 'chr(hexdec("\\1"))', $str); - $str = preg_replace('~&#([0-9]{2,4});{0,1}~e', 'chr(\\1)', $str); - - // Literal Entities - Slightly slow so we do another check - if (stristr($str, '&') === FALSE) + foreach ($this->_never_allowed_regex as $key => $val) { - $str = strtr($str, array_flip(get_html_translation_table(HTML_ENTITIES))); + $str = preg_replace("#".$key."#i", $val, $str); } return $str; @@ -674,59 +844,32 @@ function entity_decode($str, $charset='UTF-8') // -------------------------------------------------------------------- /** - * Filename Security + * Set Cross Site Request Forgery Protection Cookie * - * @access public - * @param string * @return string */ - function sanitize_filename($str, $relative_path = FALSE) + protected function _csrf_set_hash() { - $bad = array( - "../", - "", - "<", - ">", - "'", - '"', - '&', - '$', - '#', - '{', - '}', - '[', - ']', - '=', - ';', - '?', - "%20", - "%22", - "%3c", // < - "%253c", // < - "%3e", // > - "%0e", // > - "%28", // ( - "%29", // ) - "%2528", // ( - "%26", // & - "%24", // $ - "%3f", // ? - "%3b", // ; - "%3d" // = - ); - - if ( ! $relative_path) + if ($this->_csrf_hash == '') { - $bad[] = './'; - $bad[] = '/'; + // If the cookie exists we will use it's value. + // We don't necessarily want to regenerate it with + // each page load since a page could contain embedded + // sub-pages causing this feature to fail + if (isset($_COOKIE[$this->_csrf_cookie_name]) && + $_COOKIE[$this->_csrf_cookie_name] != '') + { + return $this->_csrf_hash = $_COOKIE[$this->_csrf_cookie_name]; + } + + return $this->_csrf_hash = md5(uniqid(rand(), TRUE)); } - return stripslashes(str_replace($bad, '', $str)); + return $this->_csrf_hash; } } // END Security Class /* End of file Security.php */ -/* Location: ./system/libraries/Security.php */ \ No newline at end of file +/* Location: ./system/libraries/Security.php */ diff --git a/system/core/URI.php b/system/core/URI.php index 769dacd0..10b0b7fa 100644 --- a/system/core/URI.php +++ b/system/core/URI.php @@ -6,7 +6,7 @@ * * @package CodeIgniter * @author ExpressionEngine Dev Team - * @copyright Copyright (c) 2008 - 2010, EllisLab, Inc. + * @copyright Copyright (c) 2008 - 2011, EllisLab, Inc. * @license http://codeigniter.com/user_guide/license.html * @link http://codeigniter.com * @since Version 1.0 @@ -28,9 +28,34 @@ */ class CI_URI { + /** + * List of cached uri segments + * + * @var array + * @access public + */ var $keyval = array(); + /** + * Current uri string + * + * @var string + * @access public + */ var $uri_string; + /** + * List of uri segments + * + * @var array + * @access public + */ var $segments = array(); + /** + * Re-indexed list of uri segments + * Starts at 1 instead of 0 + * + * @var array + * @access public + */ var $rsegments = array(); /** @@ -61,17 +86,17 @@ function _fetch_uri_string() { if (strtoupper($this->config->item('uri_protocol')) == 'AUTO') { - // Let's try the REQUEST_URI first, this will work in most situations - if ($uri = $this->_get_request_uri()) + // Is the request coming from the command line? + if (defined('STDIN')) { - $this->uri_string = $this->_parse_request_uri($uri); + $this->_set_uri_string($this->_parse_cli_args()); return; } - // Arguments exist, it must be a command line request - if ( ! empty($_SERVER['argv'])) + // Let's try the REQUEST_URI first, this will work in most situations + if ($uri = $this->_detect_uri()) { - $this->uri_string = $this->_parse_cli_args(); + $this->_set_uri_string($uri); return; } @@ -80,7 +105,7 @@ function _fetch_uri_string() $path = (isset($_SERVER['PATH_INFO'])) ? $_SERVER['PATH_INFO'] : @getenv('PATH_INFO'); if (trim($path, '/') != '' && $path != "/".SELF) { - $this->uri_string = $path; + $this->_set_uri_string($path); return; } @@ -88,141 +113,113 @@ function _fetch_uri_string() $path = (isset($_SERVER['QUERY_STRING'])) ? $_SERVER['QUERY_STRING'] : @getenv('QUERY_STRING'); if (trim($path, '/') != '') { - $this->uri_string = $path; + $this->_set_uri_string($path); return; } // As a last ditch effort lets try using the $_GET array if (is_array($_GET) && count($_GET) == 1 && trim(key($_GET), '/') != '') { - $this->uri_string = key($_GET); + $this->_set_uri_string(key($_GET)); return; } // We've exhausted all our options... $this->uri_string = ''; + return; } - else - { - $uri = strtoupper($this->config->item('uri_protocol')); - if ($uri == 'REQUEST_URI') - { - $this->uri_string = $this->_parse_request_uri($this->_get_request_uri()); - return; - } - elseif ($uri == 'CLI') - { - $this->uri_string = $this->_parse_cli_args(); - return; - } + $uri = strtoupper($this->config->item('uri_protocol')); - $this->uri_string = (isset($_SERVER[$uri])) ? $_SERVER[$uri] : @getenv($uri); + if ($uri == 'REQUEST_URI') + { + $this->_set_uri_string($this->_detect_uri()); + return; } - - // If the URI contains only a slash we'll kill it - if ($this->uri_string == '/') + elseif ($uri == 'CLI') { - $this->uri_string = ''; + $this->_set_uri_string($this->_parse_cli_args()); + return; } + + $path = (isset($_SERVER[$uri])) ? $_SERVER[$uri] : @getenv($uri); + $this->_set_uri_string($path); } // -------------------------------------------------------------------- /** - * Get REQUEST_URI + * Set the URI String * - * Retrieves the REQUEST_URI, or equivelent for IIS. - * - * @access private + * @access public + * @param string * @return string */ - function _get_request_uri() + function _set_uri_string($str) { - $uri = FALSE; + // Filter out control characters + $str = remove_invisible_characters($str, FALSE); - // Let's check for standard servers first - if (isset($_SERVER['REQUEST_URI'])) - { - $uri = $_SERVER['REQUEST_URI']; - if (strpos($uri, $_SERVER['SERVER_NAME']) !== FALSE) - { - $uri = preg_replace('/^\w+:\/\/[^\/]+/', '', $uri); - } - } - - // Now lets check for IIS - elseif (isset($_SERVER['HTTP_X_REWRITE_URL'])) - { - $uri = $_SERVER['HTTP_X_REWRITE_URL']; - } - - // Last ditch effort (for older CGI servers, like IIS 5) - elseif (isset($_SERVER['ORIG_PATH_INFO'])) - { - $uri = $_SERVER['ORIG_PATH_INFO']; - if ( ! empty($_SERVER['QUERY_STRING'])) - { - $uri .= '?' . $_SERVER['QUERY_STRING']; - } - } - - return $uri; + // If the URI contains only a slash we'll kill it + $this->uri_string = ($str == '/') ? '' : $str; } // -------------------------------------------------------------------- /** - * Parse REQUEST_URI + * Detects the URI * - * Due to the way REQUEST_URI works it usually contains path info - * that makes it unusable as URI data. We'll trim off the unnecessary - * data, hopefully arriving at a valid URI that we can use. + * This function will detect the URI automatically and fix the query string + * if necessary. * * @access private - * @param string * @return string */ - private function _parse_request_uri($uri) + private function _detect_uri() { - // Some server's require URL's like index.php?/whatever If that is the case, - // then we need to add that to our parsing. - $fc_path = ltrim(FCPATH . SELF, '/'); - if (strpos($uri, SELF . '?') !== FALSE) + if ( ! isset($_SERVER['REQUEST_URI']) OR ! isset($_SERVER['SCRIPT_NAME'])) { - $fc_path .= '?'; + return ''; } - $parsed_uri = explode('/', ltrim($uri, '/')); - - $i = 0; - foreach (explode("/", $fc_path) as $segment) + $uri = $_SERVER['REQUEST_URI']; + if (strpos($uri, $_SERVER['SCRIPT_NAME']) === 0) { - if (isset($parsed_uri[$i]) && $segment == $parsed_uri[$i]) - { - $i++; - } + $uri = substr($uri, strlen($_SERVER['SCRIPT_NAME'])); + } + elseif (strpos($uri, dirname($_SERVER['SCRIPT_NAME'])) === 0) + { + $uri = substr($uri, strlen(dirname($_SERVER['SCRIPT_NAME']))); } - $uri = implode("/", array_slice($parsed_uri, $i)); - - // Let's take off any query string and re-assign $_SERVER['QUERY_STRING'] and $_GET. - // This is only needed on some servers. However, we are forced to use it to accomodate - // them. - if (($qs_pos = strpos($uri, '?')) !== FALSE) + // This section ensures that even on servers that require the URI to be in the query string (Nginx) a correct + // URI is found, and also fixes the QUERY_STRING server var and $_GET array. + if (strncmp($uri, '?/', 2) === 0) { - $_SERVER['QUERY_STRING'] = substr($uri, $qs_pos + 1); + $uri = substr($uri, 2); + } + $parts = preg_split('#\?#i', $uri, 2); + $uri = $parts[0]; + if (isset($parts[1])) + { + $_SERVER['QUERY_STRING'] = $parts[1]; parse_str($_SERVER['QUERY_STRING'], $_GET); - $uri = substr($uri, 0, $qs_pos); + } + else + { + $_SERVER['QUERY_STRING'] = ''; + $_GET = array(); } - // If it is just a / or index.php then just empty it. - if ($uri == '/' OR $uri == SELF) + if ($uri == '/' || empty($uri)) { - $uri = ''; + return '/'; } - return $uri; + $uri = parse_url($uri, PHP_URL_PATH); + + // Do some final cleaning of the URI and return it + return str_replace(array('//', '../'), '/', trim($uri, '/')); } // -------------------------------------------------------------------- @@ -395,6 +392,11 @@ function uri_to_assoc($n = 3, $default = array()) /** * Identical to above only it uses the re-routed segment array * + * @access public + * @param integer the starting segment number + * @param array an array of default values + * @return array + * */ function ruri_to_assoc($n = 3, $default = array()) { diff --git a/system/core/Unicode.php b/system/core/Utf8.php similarity index 84% rename from system/core/Unicode.php rename to system/core/Utf8.php index ce1de302..2a27d1f3 100644 --- a/system/core/Unicode.php +++ b/system/core/Utf8.php @@ -6,7 +6,7 @@ * * @package CodeIgniter * @author ExpressionEngine Dev Team - * @copyright Copyright (c) 2008 - 2010, EllisLab, Inc. + * @copyright Copyright (c) 2008 - 2011, EllisLab, Inc. * @license http://codeigniter.com/user_guide/license.html * @link http://codeigniter.com * @since Version 2.0 @@ -16,17 +16,17 @@ // ------------------------------------------------------------------------ /** - * Unicode Class + * Utf8 Class * - * Provides unicode support for UTF-8 environments + * Provides support for UTF-8 environments * * @package CodeIgniter * @subpackage Libraries - * @category Unicode + * @category UTF-8 * @author ExpressionEngine Dev Team - * @link http://codeigniter.com/user_guide/libraries/unicode.html + * @link http://codeigniter.com/user_guide/libraries/utf8.html */ -class CI_Unicode { +class CI_Utf8 { /** * Constructor @@ -36,7 +36,7 @@ class CI_Unicode { */ function __construct() { - log_message('debug', "Unicode Class Initialized"); + log_message('debug', "Utf8 Class Initialized"); global $CFG; @@ -47,7 +47,7 @@ function __construct() AND $CFG->item('charset') == 'UTF-8' // Application charset must be UTF-8 ) { - log_message('debug', "Unicode Class - UTF-8 Support Enabled"); + log_message('debug', "UTF-8 Support Enabled"); define('UTF8_ENABLED', TRUE); @@ -66,7 +66,7 @@ function __construct() } else { - log_message('debug', "Unicode Class - UTF-8 Support Disabled"); + log_message('debug', "UTF-8 Support Disabled"); define('UTF8_ENABLED', FALSE); } } @@ -107,7 +107,7 @@ function clean_string($str) */ function safe_ascii_for_xml($str) { - return preg_replace('/[\x00-\x08\x0B\x0C\x0E-\x1F\x7F]+/S', '', $str); + return remove_invisible_characters($str, FALSE); } // -------------------------------------------------------------------- @@ -159,7 +159,7 @@ function _is_ascii($str) // -------------------------------------------------------------------- } -// End Unicode Class +// End Utf8 Class -/* End of file Unicode.php */ -/* Location: ./system/core/Unicode.php */ \ No newline at end of file +/* End of file Utf8.php */ +/* Location: ./system/core/Utf8.php */ \ No newline at end of file diff --git a/system/database/DB.php b/system/database/DB.php index 60a67e82..8314d3b9 100644 --- a/system/database/DB.php +++ b/system/database/DB.php @@ -6,7 +6,7 @@ * * @package CodeIgniter * @author ExpressionEngine Dev Team - * @copyright Copyright (c) 2008 - 2010, EllisLab, Inc. + * @copyright Copyright (c) 2008 - 2011, EllisLab, Inc. * @license http://codeigniter.com/user_guide/license.html * @link http://codeigniter.com * @since Version 1.0 @@ -21,13 +21,24 @@ * @category Database * @author ExpressionEngine Dev Team * @link http://codeigniter.com/user_guide/database/ + * @param string + * @param bool Determines if active record should be used or not */ function &DB($params = '', $active_record_override = NULL) { // Load the DB config file if a DSN string wasn't passed if (is_string($params) AND strpos($params, '://') === FALSE) { - include(APPPATH.'config/database'.EXT); + // Is the config file in the environment folder? + if ( ! defined('ENVIRONMENT') OR ! file_exists($file_path = APPPATH.'config/'.ENVIRONMENT.'/database.php')) + { + if ( ! file_exists($file_path = APPPATH.'config/database.php')) + { + show_error('The configuration file database.php does not exist.'); + } + } + + include($file_path); if ( ! isset($db) OR count($db) == 0) { @@ -74,7 +85,7 @@ function &DB($params = '', $active_record_override = NULL) { parse_str($dns['query'], $extra); - foreach($extra as $key => $val) + foreach ($extra as $key => $val) { // booleans please if (strtoupper($val) == "TRUE") @@ -107,11 +118,11 @@ function &DB($params = '', $active_record_override = NULL) $active_record = $active_record_override; } - require_once(BASEPATH.'database/DB_driver'.EXT); + require_once(BASEPATH.'database/DB_driver.php'); if ( ! isset($active_record) OR $active_record == TRUE) { - require_once(BASEPATH.'database/DB_active_rec'.EXT); + require_once(BASEPATH.'database/DB_active_rec.php'); if ( ! class_exists('CI_DB')) { @@ -126,7 +137,7 @@ function &DB($params = '', $active_record_override = NULL) } } - require_once(BASEPATH.'database/drivers/'.$params['dbdriver'].'/'.$params['dbdriver'].'_driver'.EXT); + require_once(BASEPATH.'database/drivers/'.$params['dbdriver'].'/'.$params['dbdriver'].'_driver.php'); // Instantiate the DB adapter $driver = 'CI_DB_'.$params['dbdriver'].'_driver'; diff --git a/system/database/DB_active_rec.php b/system/database/DB_active_rec.php index dd46981b..0a25b3cb 100644 --- a/system/database/DB_active_rec.php +++ b/system/database/DB_active_rec.php @@ -6,7 +6,7 @@ * * @package CodeIgniter * @author ExpressionEngine Dev Team - * @copyright Copyright (c) 2008 - 2010, EllisLab, Inc. + * @copyright Copyright (c) 2008 - 2011, EllisLab, Inc. * @license http://codeigniter.com/user_guide/license.html * @link http://codeigniter.com * @since Version 1.0 @@ -58,7 +58,9 @@ class CI_DB_active_record extends CI_DB_driver { var $ar_cache_having = array(); var $ar_cache_orderby = array(); var $ar_cache_set = array(); - + + var $ar_no_escape = array(); + var $ar_cache_no_escape = array(); // -------------------------------------------------------------------- @@ -67,18 +69,11 @@ 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) { - // Set the global value if this was sepecified - if (is_bool($escape)) - { - $this->_protect_identifiers = $escape; - } - if (is_string($select)) { $select = explode(',', $select); @@ -91,11 +86,13 @@ function select($select = '*', $escape = NULL) if ($val != '') { $this->ar_select[] = $val; + $this->ar_no_escape[] = $escape; if ($this->ar_caching === TRUE) { $this->ar_cache_select[] = $val; $this->ar_cache_exists[] = 'select'; + $this->ar_cache_no_escape[] = $escape; } } } @@ -109,12 +106,11 @@ function select($select = '*', $escape = NULL) * * 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'); } @@ -126,12 +122,11 @@ function select_max($select = '', $alias = '') * * 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'); } @@ -143,12 +138,11 @@ function select_min($select = '', $alias = '') * * 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'); } @@ -160,12 +154,11 @@ function select_avg($select = '', $alias = '') * * 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'); } @@ -180,12 +173,11 @@ function select_sum($select = '', $alias = '') * 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 == '') { @@ -222,11 +214,10 @@ function _max_min_avg_sum($select = '', $alias = '', $type = 'MAX') /** * 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) { @@ -243,11 +234,10 @@ function _create_alias_from_table($item) * * 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; @@ -260,11 +250,10 @@ function distinct($val = TRUE) * * 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) { @@ -313,13 +302,12 @@ function from($from) * * 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 != '') { @@ -369,12 +357,11 @@ function join($table, $cond, $type = '') * 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); } @@ -387,12 +374,11 @@ function where($key, $value = NULL, $escape = TRUE) * 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); } @@ -402,15 +388,14 @@ function or_where($key, $value = NULL, $escape = TRUE) /** * 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)) { @@ -441,10 +426,10 @@ function _where($key, $value = NULL, $type = 'AND ', $escape = NULL) $v = ' '.$this->escape($v); } - + if ( ! $this->_has_operator($k)) { - $k .= ' ='; + $k .= ' = '; } } else @@ -473,12 +458,11 @@ function _where($key, $value = NULL, $type = 'AND ', $escape = NULL) * 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); } @@ -491,12 +475,11 @@ function where_in($key = NULL, $values = NULL) * 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 '); } @@ -509,12 +492,11 @@ function or_where_in($key = NULL, $values = NULL) * 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); } @@ -527,12 +509,11 @@ function where_not_in($key = NULL, $values = NULL) * 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 '); } @@ -544,14 +525,13 @@ function or_where_not_in($key = NULL, $values = NULL) * * 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) { @@ -594,12 +574,11 @@ function _where_in($key = NULL, $values = NULL, $not = FALSE, $type = 'AND ') * 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); } @@ -612,12 +591,11 @@ function like($field, $match = '', $side = 'both') * 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'); } @@ -630,12 +608,11 @@ function not_like($field, $match = '', $side = 'both') * 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); } @@ -648,12 +625,11 @@ function or_like($field, $match = '', $side = 'both') * 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'); } @@ -665,13 +641,12 @@ function or_not_like($field, $match = '', $side = 'both') * * 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)) { @@ -721,11 +696,10 @@ function _like($field, $match = '', $type = 'AND ', $side = 'both', $not = '') /** * GROUP BY * - * @access public * @param string * @return object */ - function group_by($by) + public function group_by($by) { if (is_string($by)) { @@ -757,12 +731,11 @@ function group_by($by) * * 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); } @@ -774,12 +747,11 @@ function having($key, $value = '', $escape = TRUE) * * 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); } @@ -791,12 +763,11 @@ function or_having($key, $value = '', $escape = TRUE) * * 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)) { @@ -819,7 +790,7 @@ function _having($key, $value = '', $type = 'AND ', $escape = TRUE) if ($v != '') { - $v = ' '.$this->escape_str($v); + $v = ' '.$this->escape($v); } $this->ar_having[] = $prefix.$k.$v; @@ -838,12 +809,11 @@ function _having($key, $value = '', $type = 'AND ', $escape = TRUE) /** * 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') { @@ -894,12 +864,11 @@ function order_by($orderby, $direction = '') /** * 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; @@ -916,11 +885,10 @@ function limit($value, $offset = '') /** * 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; @@ -931,13 +899,12 @@ function offset($offset) /** * 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); @@ -954,7 +921,7 @@ function set($key, $value = '', $escape = TRUE) } else { - $this->ar_set[$this->_protect_identifiers($k)] = $this->escape($v); + $this->ar_set[$this->_protect_identifiers($k, FALSE, TRUE)] = $this->escape($v); } } @@ -969,13 +936,12 @@ function set($key, $value = '', $escape = TRUE) * 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 != '') { @@ -1001,11 +967,10 @@ function get($table = '', $limit = null, $offset = null) * 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 != '') { @@ -1020,11 +985,11 @@ function count_all_results($table = '') if ($query->num_rows() == 0) { - return '0'; + return 0; } $row = $query->row(); - return $row->numrows; + return (int) $row->numrows; } // -------------------------------------------------------------------- @@ -1034,13 +999,12 @@ function count_all_results($table = '') * * 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 != '') { @@ -1071,12 +1035,11 @@ function get_where($table = '', $where = null, $limit = null, $offset = null) * * 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)) { @@ -1129,14 +1092,12 @@ function insert_batch($table = '', $set = NULL) /** * 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); @@ -1156,7 +1117,7 @@ function set_insert_batch($key, $value = '', $escape = TRUE) $this->ar_set[] = array(); return; } - + ksort($row); // puts $row in the same order as our keys if ($escape === FALSE) @@ -1167,7 +1128,7 @@ function set_insert_batch($key, $value = '', $escape = TRUE) { $clean = array(); - foreach($row as $value) + foreach ($row as $value) { $clean[] = $this->escape($value); } @@ -1191,8 +1152,7 @@ function set_insert_batch($key, $value = '', $escape = TRUE) * * 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 */ @@ -1232,7 +1192,18 @@ function insert($table = '', $set = NULL) 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)) { @@ -1275,13 +1246,12 @@ function replace($table = '', $set = NULL) * * 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(); @@ -1338,13 +1308,12 @@ function update($table = '', $set = NULL, $where = NULL, $limit = NULL) * * 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(); @@ -1404,14 +1373,12 @@ function update_batch($table = '', $set = NULL, $index = NULL) /** * 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); @@ -1425,7 +1392,7 @@ function set_update_batch($key, $index = '', $escape = TRUE) $index_set = FALSE; $clean = array(); - foreach($v as $k2 => $v2) + foreach ($v as $k2 => $v2) { if ($k2 == $index) { @@ -1464,11 +1431,10 @@ function set_update_batch($key, $index = '', $escape = TRUE) * * 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 == '') { @@ -1504,11 +1470,10 @@ function empty_table($table = '') * 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 == '') { @@ -1542,14 +1507,13 @@ function truncate($table = '') * * 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(); @@ -1569,7 +1533,7 @@ function delete($table = '', $where = '', $limit = NULL, $reset_data = TRUE) } elseif (is_array($table)) { - foreach($table as $single_table) + foreach ($table as $single_table) { $this->delete($single_table, $where, $limit, FALSE); } @@ -1619,11 +1583,10 @@ function delete($table = '', $where = '', $limit = NULL, $reset_data = TRUE) * * 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 == '') { @@ -1635,16 +1598,30 @@ function dbprefix($table = '') // -------------------------------------------------------------------- + /** + * 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 * * 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)) { @@ -1687,10 +1664,9 @@ function _track_aliases($table) * 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(); @@ -1718,7 +1694,7 @@ function _compile_select($select_override = FALSE) // is because until the user calls the from() function we don't know if there are aliases foreach ($this->ar_select as $key => $val) { - $this->ar_select[$key] = $this->_protect_identifiers($val); + $this->ar_select[$key] = $this->_protect_identifiers($val, FALSE, $this->ar_no_escape[$key]); } $sql .= implode(', ', $this->ar_select); @@ -1753,9 +1729,7 @@ function _compile_select($select_override = FALSE) if (count($this->ar_where) > 0 OR count($this->ar_like) > 0) { - $sql .= "\n"; - - $sql .= "WHERE "; + $sql .= "\nWHERE "; } $sql .= implode("\n", $this->ar_where); @@ -1830,11 +1804,10 @@ function _compile_select($select_override = FALSE) * * 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)) { @@ -1861,11 +1834,10 @@ function _object_to_array($object) * * 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)) { @@ -1901,10 +1873,9 @@ function _object_to_array_batch($object) * * Starts AR caching * - * @access public * @return void */ - function start_cache() + public function start_cache() { $this->ar_caching = TRUE; } @@ -1916,10 +1887,9 @@ function start_cache() * * Stops AR caching * - * @access public * @return void */ - function stop_cache() + public function stop_cache() { $this->ar_caching = FALSE; } @@ -1934,22 +1904,21 @@ function stop_cache() * @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() - ) - ); + $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() + )); } // -------------------------------------------------------------------- @@ -1960,10 +1929,9 @@ function flush_cache() * 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) { @@ -1989,6 +1957,8 @@ function _merge_cache() { $this->_track_aliases($this->ar_from); } + + $this->ar_no_escape = $this->ar_cache_no_escape; } // -------------------------------------------------------------------- @@ -1996,11 +1966,10 @@ function _merge_cache() /** * 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) { @@ -2016,27 +1985,27 @@ function _reset_run($ar_reset_items) /** * 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_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 +2017,23 @@ function _reset_select() * * 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 */ diff --git a/system/database/DB_cache.php b/system/database/DB_cache.php index 6042e067..3bf065ca 100644 --- a/system/database/DB_cache.php +++ b/system/database/DB_cache.php @@ -6,7 +6,7 @@ * * @package CodeIgniter * @author ExpressionEngine Dev Team - * @copyright Copyright (c) 2008 - 2010, EllisLab, Inc. + * @copyright Copyright (c) 2008 - 2011, EllisLab, Inc. * @license http://codeigniter.com/user_guide/license.html * @link http://codeigniter.com * @since Version 1.0 diff --git a/system/database/DB_driver.php b/system/database/DB_driver.php index 7fe5695b..f3e824da 100644 --- a/system/database/DB_driver.php +++ b/system/database/DB_driver.php @@ -6,7 +6,7 @@ * * @package CodeIgniter * @author ExpressionEngine Dev Team - * @copyright Copyright (c) 2008 - 2010, EllisLab, Inc. + * @copyright Copyright (c) 2008 - 2011, EllisLab, Inc. * @license http://codeigniter.com/user_guide/license.html * @link http://codeigniter.com * @since Version 1.0 @@ -218,7 +218,7 @@ function version() // Some DBs have functions that return the version, and don't run special // SQL queries per se. In these instances, just return the result. - $driver_version_exceptions = array('oci8', 'sqlite'); + $driver_version_exceptions = array('oci8', 'sqlite', 'cubrid'); if (in_array($this->dbdriver, $driver_version_exceptions)) { @@ -424,8 +424,8 @@ function load_rdriver() if ( ! class_exists($driver)) { - include_once(BASEPATH.'database/DB_result'.EXT); - include_once(BASEPATH.'database/drivers/'.$this->dbdriver.'/'.$this->dbdriver.'_result'.EXT); + include_once(BASEPATH.'database/DB_result.php'); + include_once(BASEPATH.'database/drivers/'.$this->dbdriver.'/'.$this->dbdriver.'_result.php'); } return $driver; @@ -767,7 +767,7 @@ function list_tables($constrain_by_prefix = FALSE) if ($query->num_rows() > 0) { - foreach($query->result_array() as $row) + foreach ($query->result_array() as $row) { if (isset($row['TABLE_NAME'])) { @@ -834,7 +834,7 @@ function list_fields($table = '') $query = $this->query($sql); $retval = array(); - foreach($query->result_array() as $row) + foreach ($query->result_array() as $row) { if (isset($row['COLUMN_NAME'])) { @@ -904,7 +904,7 @@ function insert_string($table, $data) $fields = array(); $values = array(); - foreach($data as $key => $val) + foreach ($data as $key => $val) { $fields[] = $this->_escape_identifiers($key); $values[] = $this->escape($val); @@ -932,7 +932,7 @@ function update_string($table, $data, $where) } $fields = array(); - foreach($data as $key => $val) + foreach ($data as $key => $val) { $fields[$this->_protect_identifiers($key)] = $this->escape($val); } @@ -1115,7 +1115,7 @@ function _cache_init() if ( ! class_exists('CI_DB_Cache')) { - if ( ! @include(BASEPATH.'database/DB_cache'.EXT)) + if ( ! @include(BASEPATH.'database/DB_cache.php')) { return $this->cache_off(); } @@ -1175,7 +1175,7 @@ function display_error($error = '', $swap = '', $native = FALSE) $trace = debug_backtrace(); - foreach($trace as $call) + foreach ($trace as $call) { if (isset($call['file']) && strpos($call['file'], BASEPATH.'database') === FALSE) { @@ -1248,7 +1248,7 @@ function _protect_identifiers($item, $prefix_single = FALSE, $protect_identifier { $escaped_array = array(); - foreach($item as $k => $v) + foreach ($item as $k => $v) { $escaped_array[$this->_protect_identifiers($k)] = $this->_protect_identifiers($v); } diff --git a/system/database/DB_forge.php b/system/database/DB_forge.php index ce505f4e..a71fca78 100644 --- a/system/database/DB_forge.php +++ b/system/database/DB_forge.php @@ -6,7 +6,7 @@ * * @package CodeIgniter * @author ExpressionEngine Dev Team - * @copyright Copyright (c) 2008 - 2010, EllisLab, Inc. + * @copyright Copyright (c) 2008 - 2011, EllisLab, Inc. * @license http://codeigniter.com/user_guide/license.html * @link http://codeigniter.com * @since Version 1.0 @@ -99,7 +99,7 @@ function add_key($key = '', $primary = FALSE) { if (is_array($key)) { - foreach($key as $one) + foreach ($key as $one) { $this->add_key($one, $primary); } diff --git a/system/database/DB_result.php b/system/database/DB_result.php index 05f06af6..0c4e7810 100644 --- a/system/database/DB_result.php +++ b/system/database/DB_result.php @@ -6,7 +6,7 @@ * * @package CodeIgniter * @author ExpressionEngine Dev Team - * @copyright Copyright (c) 2008 - 2010, EllisLab, Inc. + * @copyright Copyright (c) 2008 - 2011, EllisLab, Inc. * @license http://codeigniter.com/user_guide/license.html * @link http://codeigniter.com * @since Version 1.0 @@ -28,13 +28,14 @@ */ class CI_DB_result { - var $conn_id = NULL; - var $result_id = NULL; - var $result_array = array(); - var $result_object = array(); - var $current_row = 0; - var $num_rows = 0; - var $row_data = NULL; + var $conn_id = NULL; + var $result_id = NULL; + var $result_array = array(); + var $result_object = array(); + var $custom_result_object = array(); + var $current_row = 0; + var $num_rows = 0; + var $row_data = NULL; /** @@ -46,7 +47,49 @@ class CI_DB_result { */ function result($type = 'object') { - return ($type == 'object') ? $this->result_object() : $this->result_array(); + if ($type == 'array') return $this->result_array(); + else if ($type == 'object') return $this->result_object(); + else return $this->custom_result_object($type); + } + + // -------------------------------------------------------------------- + + /** + * Custom query result. + * + * @param class_name A string that represents the type of object you want back + * @return array of objects + */ + function custom_result_object($class_name) + { + if (array_key_exists($class_name, $this->custom_result_object)) + { + return $this->custom_result_object[$class_name]; + } + + if ($this->result_id === FALSE OR $this->num_rows() == 0) + { + return array(); + } + + // add the data to the object + $this->_data_seek(0); + $result_object = array(); + + while ($row = $this->_fetch_object()) + { + $object = new $class_name(); + + foreach ($row as $key => $value) + { + $object->$key = $value; + } + + $result_object[] = $object; + } + + // return the array + return $this->custom_result_object[$class_name] = $result_object; } // -------------------------------------------------------------------- @@ -142,7 +185,9 @@ function row($n = 0, $type = 'object') $n = 0; } - return ($type == 'object') ? $this->row_object($n) : $this->row_array($n); + if ($type == 'object') return $this->row_object($n); + else if ($type == 'array') return $this->row_array($n); + else return $this->custom_row_object($n, $type); } // -------------------------------------------------------------------- @@ -179,6 +224,29 @@ function set_row($key, $value = NULL) // -------------------------------------------------------------------- + /** + * Returns a single result row - custom object version + * + * @access public + * @return object + */ + function custom_row_object($n, $type) + { + $result = $this->custom_result_object($type); + + if (count($result) == 0) + { + return $result; + } + + if ($n != $this->current_row AND isset($result[$n])) + { + $this->current_row = $n; + } + + return $result[$this->current_row]; + } + /** * Returns a single result row - object version * @@ -339,4 +407,4 @@ function _fetch_object() { return array(); } // END DB_result class /* End of file DB_result.php */ -/* Location: ./system/database/DB_result.php */ \ No newline at end of file +/* Location: ./system/database/DB_result.php */ diff --git a/system/database/DB_utility.php b/system/database/DB_utility.php index c4d537a3..a5f174f0 100644 --- a/system/database/DB_utility.php +++ b/system/database/DB_utility.php @@ -6,7 +6,7 @@ * * @package CodeIgniter * @author ExpressionEngine Dev Team - * @copyright Copyright (c) 2008 - 2010, EllisLab, Inc. + * @copyright Copyright (c) 2008 - 2011, EllisLab, Inc. * @license http://codeigniter.com/user_guide/license.html * @link http://codeigniter.com * @since Version 1.0 diff --git a/system/database/drivers/cubrid/cubrid_driver.php b/system/database/drivers/cubrid/cubrid_driver.php new file mode 100644 index 00000000..3f010924 --- /dev/null +++ b/system/database/drivers/cubrid/cubrid_driver.php @@ -0,0 +1,791 @@ +port == '') + { + $this->port = self::DEFAULT_PORT; + } + + $conn = cubrid_connect($this->hostname, $this->port, $this->database, $this->username, $this->password); + + if ($conn) + { + // Check if a user wants to run queries in dry, i.e. run the + // queries but not commit them. + if (isset($this->auto_commit) && ! $this->auto_commit) + { + cubrid_set_autocommit($conn, CUBRID_AUTOCOMMIT_FALSE); + } + else + { + cubrid_set_autocommit($conn, CUBRID_AUTOCOMMIT_TRUE); + $this->auto_commit = TRUE; + } + } + + return $conn; + } + + // -------------------------------------------------------------------- + + /** + * Persistent database connection + * In CUBRID persistent DB connection is supported natively in CUBRID + * engine which can be configured in the CUBRID Broker configuration + * file by setting the CCI_PCONNECT parameter to ON. In that case, all + * connections established between the client application and the + * server will become persistent. This is calling the same + * @cubrid_connect function will establish persisten connection + * considering that the CCI_PCONNECT is ON. + * + * @access private called by the base class + * @return resource + */ + function db_pconnect() + { + return $this->db_connect(); + } + + // -------------------------------------------------------------------- + + /** + * Reconnect + * + * Keep / reestablish the db connection if no queries have been + * sent for a length of time exceeding the server's idle timeout + * + * @access public + * @return void + */ + function reconnect() + { + if (cubrid_ping($this->conn_id) === FALSE) + { + $this->conn_id = FALSE; + } + } + + // -------------------------------------------------------------------- + + /** + * Select the database + * + * @access private called by the base class + * @return resource + */ + function db_select() + { + // In CUBRID there is no need to select a database as the database + // is chosen at the connection time. + // So, to determine if the database is "selected", all we have to + // do is ping the server and return that value. + return cubrid_ping($this->conn_id); + } + + // -------------------------------------------------------------------- + + /** + * Set client character set + * + * @access public + * @param string + * @param string + * @return resource + */ + function db_set_charset($charset, $collation) + { + // In CUBRID, there is no need to set charset or collation. + // This is why returning true will allow the application continue + // its normal process. + return TRUE; + } + + // -------------------------------------------------------------------- + + /** + * Version number query string + * + * @access public + * @return string + */ + function _version() + { + // To obtain the CUBRID Server version, no need to run the SQL query. + // CUBRID PHP API provides a function to determin this value. + // This is why we also need to add 'cubrid' value to the list of + // $driver_version_exceptions array in DB_driver class in + // version() function. + return cubrid_get_server_info($this->conn_id); + } + + // -------------------------------------------------------------------- + + /** + * Execute the query + * + * @access private called by the base class + * @param string an SQL query + * @return resource + */ + function _execute($sql) + { + $sql = $this->_prep_query($sql); + return @cubrid_query($sql, $this->conn_id); + } + + // -------------------------------------------------------------------- + + /** + * Prep the query + * + * If needed, each database adapter can prep the query string + * + * @access private called by execute() + * @param string an SQL query + * @return string + */ + function _prep_query($sql) + { + // No need to prepare + return $sql; + } + + // -------------------------------------------------------------------- + + /** + * Begin Transaction + * + * @access public + * @return bool + */ + function trans_begin($test_mode = FALSE) + { + if ( ! $this->trans_enabled) + { + return TRUE; + } + + // When transactions are nested we only begin/commit/rollback the outermost ones + if ($this->_trans_depth > 0) + { + return TRUE; + } + + // Reset the transaction failure flag. + // If the $test_mode flag is set to TRUE transactions will be rolled back + // even if the queries produce a successful result. + $this->_trans_failure = ($test_mode === TRUE) ? TRUE : FALSE; + + if (cubrid_get_autocommit($this->conn_id)) + { + cubrid_set_autocommit($this->conn_id, CUBRID_AUTOCOMMIT_FALSE); + } + + return TRUE; + } + + // -------------------------------------------------------------------- + + /** + * Commit Transaction + * + * @access public + * @return bool + */ + function trans_commit() + { + if ( ! $this->trans_enabled) + { + return TRUE; + } + + // When transactions are nested we only begin/commit/rollback the outermost ones + if ($this->_trans_depth > 0) + { + return TRUE; + } + + cubrid_commit($this->conn_id); + + if ($this->auto_commit && ! cubrid_get_autocommit($this->conn_id)) + { + cubrid_set_autocommit($this->conn_id, CUBRID_AUTOCOMMIT_TRUE); + } + + return TRUE; + } + + // -------------------------------------------------------------------- + + /** + * Rollback Transaction + * + * @access public + * @return bool + */ + function trans_rollback() + { + if ( ! $this->trans_enabled) + { + return TRUE; + } + + // When transactions are nested we only begin/commit/rollback the outermost ones + if ($this->_trans_depth > 0) + { + return TRUE; + } + + cubrid_rollback($this->conn_id); + + if ($this->auto_commit && ! cubrid_get_autocommit($this->conn_id)) + { + cubrid_set_autocommit($this->conn_id, CUBRID_AUTOCOMMIT_TRUE); + } + + return TRUE; + } + + // -------------------------------------------------------------------- + + /** + * Escape String + * + * @access public + * @param string + * @param bool whether or not the string will be used in a LIKE condition + * @return string + */ + function escape_str($str, $like = FALSE) + { + if (is_array($str)) + { + foreach ($str as $key => $val) + { + $str[$key] = $this->escape_str($val, $like); + } + + return $str; + } + + if (function_exists('cubrid_real_escape_string') AND is_resource($this->conn_id)) + { + $str = cubrid_real_escape_string($str, $this->conn_id); + } + else + { + $str = addslashes($str); + } + + // escape LIKE condition wildcards + if ($like === TRUE) + { + $str = str_replace(array('%', '_'), array('\\%', '\\_'), $str); + } + + return $str; + } + + // -------------------------------------------------------------------- + + /** + * Affected Rows + * + * @access public + * @return integer + */ + function affected_rows() + { + return @cubrid_affected_rows($this->conn_id); + } + + // -------------------------------------------------------------------- + + /** + * Insert ID + * + * @access public + * @return integer + */ + function insert_id() + { + return @cubrid_insert_id($this->conn_id); + } + + // -------------------------------------------------------------------- + + /** + * "Count All" query + * + * Generates a platform-specific query string that counts all records in + * the specified table + * + * @access public + * @param string + * @return string + */ + function count_all($table = '') + { + if ($table == '') + { + return 0; + } + + $query = $this->query($this->_count_string . $this->_protect_identifiers('numrows') . " FROM " . $this->_protect_identifiers($table, TRUE, NULL, FALSE)); + + if ($query->num_rows() == 0) + { + return 0; + } + + $row = $query->row(); + return (int) $row->numrows; + } + + // -------------------------------------------------------------------- + + /** + * List table query + * + * Generates a platform-specific query string so that the table names can be fetched + * + * @access private + * @param boolean + * @return string + */ + function _list_tables($prefix_limit = FALSE) + { + $sql = "SHOW TABLES"; + + if ($prefix_limit !== FALSE AND $this->dbprefix != '') + { + $sql .= " LIKE '".$this->escape_like_str($this->dbprefix)."%'"; + } + + return $sql; + } + + // -------------------------------------------------------------------- + + /** + * Show column query + * + * Generates a platform-specific query string so that the column names can be fetched + * + * @access public + * @param string the table name + * @return string + */ + function _list_columns($table = '') + { + return "SHOW COLUMNS FROM ".$this->_protect_identifiers($table, TRUE, NULL, FALSE); + } + + // -------------------------------------------------------------------- + + /** + * Field data query + * + * Generates a platform-specific query so that the column data can be retrieved + * + * @access public + * @param string the table name + * @return object + */ + function _field_data($table) + { + return "SELECT * FROM ".$table." LIMIT 1"; + } + + // -------------------------------------------------------------------- + + /** + * The error message string + * + * @access private + * @return string + */ + function _error_message() + { + return cubrid_error($this->conn_id); + } + + // -------------------------------------------------------------------- + + /** + * The error message number + * + * @access private + * @return integer + */ + function _error_number() + { + return cubrid_errno($this->conn_id); + } + + // -------------------------------------------------------------------- + + /** + * Escape the SQL Identifiers + * + * This function escapes column and table names + * + * @access private + * @param string + * @return string + */ + function _escape_identifiers($item) + { + if ($this->_escape_char == '') + { + return $item; + } + + foreach ($this->_reserved_identifiers as $id) + { + if (strpos($item, '.'.$id) !== FALSE) + { + $str = $this->_escape_char. str_replace('.', $this->_escape_char.'.', $item); + + // remove duplicates if the user already included the escape + return preg_replace('/['.$this->_escape_char.']+/', $this->_escape_char, $str); + } + } + + if (strpos($item, '.') !== FALSE) + { + $str = $this->_escape_char.str_replace('.', $this->_escape_char.'.'.$this->_escape_char, $item).$this->_escape_char; + } + else + { + $str = $this->_escape_char.$item.$this->_escape_char; + } + + // remove duplicates if the user already included the escape + return preg_replace('/['.$this->_escape_char.']+/', $this->_escape_char, $str); + } + + // -------------------------------------------------------------------- + + /** + * From Tables + * + * This function implicitly groups FROM tables so there is no confusion + * about operator precedence in harmony with SQL standards + * + * @access public + * @param type + * @return type + */ + function _from_tables($tables) + { + if ( ! is_array($tables)) + { + $tables = array($tables); + } + + return '('.implode(', ', $tables).')'; + } + + // -------------------------------------------------------------------- + + /** + * Insert statement + * + * Generates a platform-specific insert string from the supplied data + * + * @access public + * @param string the table name + * @param array the insert keys + * @param array the insert values + * @return string + */ + function _insert($table, $keys, $values) + { + return "INSERT INTO ".$table." (\"".implode('", "', $keys)."\") VALUES (".implode(', ', $values).")"; + } + + // -------------------------------------------------------------------- + + + /** + * Replace statement + * + * Generates a platform-specific replace string from the supplied data + * + * @access public + * @param string the table name + * @param array the insert keys + * @param array the insert values + * @return string + */ + function _replace($table, $keys, $values) + { + return "REPLACE INTO ".$table." (\"".implode('", "', $keys)."\") VALUES (".implode(', ', $values).")"; + } + + // -------------------------------------------------------------------- + + /** + * Insert_batch statement + * + * Generates a platform-specific insert string from the supplied data + * + * @access public + * @param string the table name + * @param array the insert keys + * @param array the insert values + * @return string + */ + function _insert_batch($table, $keys, $values) + { + return "INSERT INTO ".$table." (\"".implode('", "', $keys)."\") VALUES ".implode(', ', $values); + } + + // -------------------------------------------------------------------- + + + /** + * Update statement + * + * Generates a platform-specific update string from the supplied data + * + * @access public + * @param string the table name + * @param array the update data + * @param array the where clause + * @param array the orderby clause + * @param array the limit clause + * @return string + */ + function _update($table, $values, $where, $orderby = array(), $limit = FALSE) + { + foreach ($values as $key => $val) + { + $valstr[] = sprintf('"%s" = %s', $key, $val); + } + + $limit = ( ! $limit) ? '' : ' LIMIT '.$limit; + + $orderby = (count($orderby) >= 1)?' ORDER BY '.implode(", ", $orderby):''; + + $sql = "UPDATE ".$table." SET ".implode(', ', $valstr); + + $sql .= ($where != '' AND count($where) >=1) ? " WHERE ".implode(" ", $where) : ''; + + $sql .= $orderby.$limit; + + return $sql; + } + + // -------------------------------------------------------------------- + + + /** + * Update_Batch statement + * + * Generates a platform-specific batch update string from the supplied data + * + * @access public + * @param string the table name + * @param array the update data + * @param array the where clause + * @return string + */ + function _update_batch($table, $values, $index, $where = NULL) + { + $ids = array(); + $where = ($where != '' AND count($where) >=1) ? implode(" ", $where).' AND ' : ''; + + foreach ($values as $key => $val) + { + $ids[] = $val[$index]; + + foreach (array_keys($val) as $field) + { + if ($field != $index) + { + $final[$field][] = 'WHEN '.$index.' = '.$val[$index].' THEN '.$val[$field]; + } + } + } + + $sql = "UPDATE ".$table." SET "; + $cases = ''; + + foreach ($final as $k => $v) + { + $cases .= $k.' = CASE '."\n"; + foreach ($v as $row) + { + $cases .= $row."\n"; + } + + $cases .= 'ELSE '.$k.' END, '; + } + + $sql .= substr($cases, 0, -2); + + $sql .= ' WHERE '.$where.$index.' IN ('.implode(',', $ids).')'; + + return $sql; + } + + // -------------------------------------------------------------------- + + + /** + * Truncate statement + * + * Generates a platform-specific truncate string from the supplied data + * If the database does not support the truncate() command + * This function maps to "DELETE FROM table" + * + * @access public + * @param string the table name + * @return string + */ + function _truncate($table) + { + return "TRUNCATE ".$table; + } + + // -------------------------------------------------------------------- + + /** + * Delete statement + * + * Generates a platform-specific delete string from the supplied data + * + * @access public + * @param string the table name + * @param array the where clause + * @param string the limit clause + * @return string + */ + function _delete($table, $where = array(), $like = array(), $limit = FALSE) + { + $conditions = ''; + + if (count($where) > 0 OR count($like) > 0) + { + $conditions = "\nWHERE "; + $conditions .= implode("\n", $this->ar_where); + + if (count($where) > 0 && count($like) > 0) + { + $conditions .= " AND "; + } + $conditions .= implode("\n", $like); + } + + $limit = ( ! $limit) ? '' : ' LIMIT '.$limit; + + return "DELETE FROM ".$table.$conditions.$limit; + } + + // -------------------------------------------------------------------- + + /** + * Limit string + * + * Generates a platform-specific LIMIT clause + * + * @access public + * @param string the sql query string + * @param integer the number of rows to limit the query to + * @param integer the offset value + * @return string + */ + function _limit($sql, $limit, $offset) + { + if ($offset == 0) + { + $offset = ''; + } + else + { + $offset .= ", "; + } + + return $sql."LIMIT ".$offset.$limit; + } + + // -------------------------------------------------------------------- + + /** + * Close DB Connection + * + * @access public + * @param resource + * @return void + */ + function _close($conn_id) + { + @cubrid_close($conn_id); + } + +} + + +/* End of file cubrid_driver.php */ +/* Location: ./system/database/drivers/cubrid/cubrid_driver.php */ \ No newline at end of file diff --git a/system/database/drivers/cubrid/cubrid_forge.php b/system/database/drivers/cubrid/cubrid_forge.php new file mode 100644 index 00000000..bab03f74 --- /dev/null +++ b/system/database/drivers/cubrid/cubrid_forge.php @@ -0,0 +1,288 @@ +$attributes) + { + // Numeric field names aren't allowed in databases, so if the key is + // numeric, we know it was assigned by PHP and the developer manually + // entered the field information, so we'll simply add it to the list + if (is_numeric($field)) + { + $sql .= "\n\t$attributes"; + } + else + { + $attributes = array_change_key_case($attributes, CASE_UPPER); + + $sql .= "\n\t\"" . $this->db->_protect_identifiers($field) . "\""; + + if (array_key_exists('NAME', $attributes)) + { + $sql .= ' '.$this->db->_protect_identifiers($attributes['NAME']).' '; + } + + if (array_key_exists('TYPE', $attributes)) + { + $sql .= ' '.$attributes['TYPE']; + + if (array_key_exists('CONSTRAINT', $attributes)) + { + switch ($attributes['TYPE']) + { + case 'decimal': + case 'float': + case 'numeric': + $sql .= '('.implode(',', $attributes['CONSTRAINT']).')'; + break; + case 'enum': // As of version 8.4.0 CUBRID does not support + // enum data type. + break; + case 'set': + $sql .= '("'.implode('","', $attributes['CONSTRAINT']).'")'; + break; + default: + $sql .= '('.$attributes['CONSTRAINT'].')'; + } + } + } + + if (array_key_exists('UNSIGNED', $attributes) && $attributes['UNSIGNED'] === TRUE) + { + //$sql .= ' UNSIGNED'; + // As of version 8.4.0 CUBRID does not support UNSIGNED INTEGER data type. + // Will be supported in the next release as a part of MySQL Compatibility. + } + + if (array_key_exists('DEFAULT', $attributes)) + { + $sql .= ' DEFAULT \''.$attributes['DEFAULT'].'\''; + } + + if (array_key_exists('NULL', $attributes) && $attributes['NULL'] === TRUE) + { + $sql .= ' NULL'; + } + else + { + $sql .= ' NOT NULL'; + } + + if (array_key_exists('AUTO_INCREMENT', $attributes) && $attributes['AUTO_INCREMENT'] === TRUE) + { + $sql .= ' AUTO_INCREMENT'; + } + + if (array_key_exists('UNIQUE', $attributes) && $attributes['UNIQUE'] === TRUE) + { + $sql .= ' UNIQUE'; + } + } + + // don't add a comma on the end of the last field + if (++$current_field_count < count($fields)) + { + $sql .= ','; + } + } + + return $sql; + } + + // -------------------------------------------------------------------- + + /** + * Create Table + * + * @access private + * @param string the table name + * @param mixed the fields + * @param mixed primary key(s) + * @param mixed key(s) + * @param boolean should 'IF NOT EXISTS' be added to the SQL + * @return bool + */ + function _create_table($table, $fields, $primary_keys, $keys, $if_not_exists) + { + $sql = 'CREATE TABLE '; + + if ($if_not_exists === TRUE) + { + //$sql .= 'IF NOT EXISTS '; + // As of version 8.4.0 CUBRID does not support this SQL syntax. + } + + $sql .= $this->db->_escape_identifiers($table)." ("; + + $sql .= $this->_process_fields($fields); + + // If there is a PK defined + if (count($primary_keys) > 0) + { + $key_name = "pk_" . $table . "_" . + $this->db->_protect_identifiers(implode('_', $primary_keys)); + + $primary_keys = $this->db->_protect_identifiers($primary_keys); + $sql .= ",\n\tCONSTRAINT " . $key_name . " PRIMARY KEY(" . implode(', ', $primary_keys) . ")"; + } + + if (is_array($keys) && count($keys) > 0) + { + foreach ($keys as $key) + { + if (is_array($key)) + { + $key_name = $this->db->_protect_identifiers(implode('_', $key)); + $key = $this->db->_protect_identifiers($key); + } + else + { + $key_name = $this->db->_protect_identifiers($key); + $key = array($key_name); + } + + $sql .= ",\n\tKEY \"{$key_name}\" (" . implode(', ', $key) . ")"; + } + } + + $sql .= "\n);"; + + return $sql; + } + + // -------------------------------------------------------------------- + + /** + * Drop Table + * + * @access private + * @return string + */ + function _drop_table($table) + { + return "DROP TABLE IF EXISTS ".$this->db->_escape_identifiers($table); + } + + // -------------------------------------------------------------------- + + /** + * Alter table query + * + * Generates a platform-specific query so that a table can be altered + * Called by add_column(), drop_column(), and column_alter(), + * + * @access private + * @param string the ALTER type (ADD, DROP, CHANGE) + * @param string the column name + * @param array fields + * @param string the field after which we should add the new field + * @return object + */ + function _alter_table($alter_type, $table, $fields, $after_field = '') + { + $sql = 'ALTER TABLE '.$this->db->_protect_identifiers($table)." $alter_type "; + + // DROP has everything it needs now. + if ($alter_type == 'DROP') + { + return $sql.$this->db->_protect_identifiers($fields); + } + + $sql .= $this->_process_fields($fields); + + if ($after_field != '') + { + $sql .= ' AFTER ' . $this->db->_protect_identifiers($after_field); + } + + return $sql; + } + + // -------------------------------------------------------------------- + + /** + * Rename a table + * + * Generates a platform-specific query so that a table can be renamed + * + * @access private + * @param string the old table name + * @param string the new table name + * @return string + */ + function _rename_table($table_name, $new_table_name) + { + $sql = 'RENAME TABLE '.$this->db->_protect_identifiers($table_name)." AS ".$this->db->_protect_identifiers($new_table_name); + return $sql; + } + +} + +/* End of file cubrid_forge.php */ +/* Location: ./system/database/drivers/cubrid/cubrid_forge.php */ \ No newline at end of file diff --git a/system/database/drivers/cubrid/cubrid_result.php b/system/database/drivers/cubrid/cubrid_result.php new file mode 100644 index 00000000..6f0c2b5f --- /dev/null +++ b/system/database/drivers/cubrid/cubrid_result.php @@ -0,0 +1,202 @@ +result_id); + } + + // -------------------------------------------------------------------- + + /** + * Number of fields in the result set + * + * @access public + * @return integer + */ + function num_fields() + { + return @cubrid_num_fields($this->result_id); + } + + // -------------------------------------------------------------------- + + /** + * Fetch Field Names + * + * Generates an array of column names + * + * @access public + * @return array + */ + function list_fields() + { + return cubrid_column_names($this->result_id); + } + + // -------------------------------------------------------------------- + + /** + * Field data + * + * Generates an array of objects containing field meta-data + * + * @access public + * @return array + */ + function field_data() + { + $retval = array(); + + $tablePrimaryKeys = array(); + + while ($field = cubrid_fetch_field($this->result_id)) + { + $F = new stdClass(); + $F->name = $field->name; + $F->type = $field->type; + $F->default = $field->def; + $F->max_length = $field->max_length; + + // At this moment primary_key property is not returned when + // cubrid_fetch_field is called. The following code will + // provide a patch for it. primary_key property will be added + // in the next release. + + // TODO: later version of CUBRID will provide primary_key + // property. + // When PK is defined in CUBRID, an index is automatically + // created in the db_index system table in the form of + // pk_tblname_fieldname. So the following will count how many + // columns are there which satisfy this format. + // The query will search for exact single columns, thus + // compound PK is not supported. + $res = cubrid_query($this->conn_id, + "SELECT COUNT(*) FROM db_index WHERE class_name = '" . $field->table . + "' AND is_primary_key = 'YES' AND index_name = 'pk_" . + $field->table . "_" . $field->name . "'" + ); + + if ($res) + { + $row = cubrid_fetch_array($res, CUBRID_NUM); + $F->primary_key = ($row[0] > 0 ? 1 : null); + } + else + { + $F->primary_key = null; + } + + if (is_resource($res)) + { + cubrid_close_request($res); + $this->result_id = FALSE; + } + + $retval[] = $F; + } + + return $retval; + } + + // -------------------------------------------------------------------- + + /** + * Free the result + * + * @return null + */ + function free_result() + { + if(is_resource($this->result_id) || + get_resource_type($this->result_id) == "Unknown" && + preg_match('/Resource id #/', strval($this->result_id))) + { + cubrid_close_request($this->result_id); + $this->result_id = FALSE; + } + } + + // -------------------------------------------------------------------- + + /** + * Data Seek + * + * Moves the internal pointer to the desired offset. We call + * this internally before fetching results to make sure the + * result set starts at zero + * + * @access private + * @return array + */ + function _data_seek($n = 0) + { + return cubrid_data_seek($this->result_id, $n); + } + + // -------------------------------------------------------------------- + + /** + * Result - associative array + * + * Returns the result set as an array + * + * @access private + * @return array + */ + function _fetch_assoc() + { + return cubrid_fetch_assoc($this->result_id); + } + + // -------------------------------------------------------------------- + + /** + * Result - object + * + * Returns the result set as an object + * + * @access private + * @return object + */ + function _fetch_object() + { + return cubrid_fetch_object($this->result_id); + } + +} + + +/* End of file cubrid_result.php */ +/* Location: ./system/database/drivers/cubrid/cubrid_result.php */ \ No newline at end of file diff --git a/system/database/drivers/cubrid/cubrid_utility.php b/system/database/drivers/cubrid/cubrid_utility.php new file mode 100644 index 00000000..cd16d1e1 --- /dev/null +++ b/system/database/drivers/cubrid/cubrid_utility.php @@ -0,0 +1,108 @@ +conn_id) + { + return "SELECT '" . $this->database . "'"; + } + else + { + return FALSE; + } + } + + // -------------------------------------------------------------------- + + /** + * Optimize table query + * + * Generates a platform-specific query so that a table can be optimized + * + * @access private + * @param string the table name + * @return object + * @link http://www.cubrid.org/manual/840/en/Optimize%20Database + */ + function _optimize_table($table) + { + // No SQL based support in CUBRID as of version 8.4.0. Database or + // table optimization can be performed using CUBRID Manager + // database administration tool. See the link above for more info. + return FALSE; + } + + // -------------------------------------------------------------------- + + /** + * Repair table query + * + * Generates a platform-specific query so that a table can be repaired + * + * @access private + * @param string the table name + * @return object + * @link http://www.cubrid.org/manual/840/en/Checking%20Database%20Consistency + */ + function _repair_table($table) + { + // Not supported in CUBRID as of version 8.4.0. Database or + // table consistency can be checked using CUBRID Manager + // database administration tool. See the link above for more info. + return FALSE; + } + + // -------------------------------------------------------------------- + /** + * CUBRID Export + * + * @access private + * @param array Preferences + * @return mixed + */ + function _backup($params = array()) + { + // No SQL based support in CUBRID as of version 8.4.0. Database or + // table backup can be performed using CUBRID Manager + // database administration tool. + return $this->db->display_error('db_unsuported_feature'); + } +} + +/* End of file cubrid_utility.php */ +/* Location: ./system/database/drivers/cubrid/cubrid_utility.php */ \ No newline at end of file diff --git a/system/database/drivers/cubrid/index.html b/system/database/drivers/cubrid/index.html new file mode 100644 index 00000000..c942a79c --- /dev/null +++ b/system/database/drivers/cubrid/index.html @@ -0,0 +1,10 @@ + + + 403 Forbidden + + + +

Directory access is forbidden.

+ + + \ No newline at end of file diff --git a/system/database/drivers/mssql/mssql_driver.php b/system/database/drivers/mssql/mssql_driver.php index eade10ee..65397ed8 100644 --- a/system/database/drivers/mssql/mssql_driver.php +++ b/system/database/drivers/mssql/mssql_driver.php @@ -6,7 +6,7 @@ * * @package CodeIgniter * @author ExpressionEngine Dev Team - * @copyright Copyright (c) 2008 - 2010, EllisLab, Inc. + * @copyright Copyright (c) 2008 - 2011, EllisLab, Inc. * @license http://codeigniter.com/user_guide/license.html * @link http://codeigniter.com * @since Version 1.0 @@ -253,7 +253,7 @@ function escape_str($str, $like = FALSE) { if (is_array($str)) { - foreach($str as $key => $val) + foreach ($str as $key => $val) { $str[$key] = $this->escape_str($val, $like); } @@ -267,9 +267,11 @@ function escape_str($str, $like = FALSE) // escape LIKE condition wildcards if ($like === TRUE) { - $str = str_replace( array('%', '_', $this->_like_escape_chr), - array($this->_like_escape_chr.'%', $this->_like_escape_chr.'_', $this->_like_escape_chr.$this->_like_escape_chr), - $str); + $str = str_replace( + array($this->_like_escape_chr, '%', '_'), + array($this->_like_escape_chr.$this->_like_escape_chr, $this->_like_escape_chr.'%', $this->_like_escape_chr.'_'), + $str + ); } return $str; @@ -551,7 +553,7 @@ function _insert($table, $keys, $values) */ function _update($table, $values, $where, $orderby = array(), $limit = FALSE) { - foreach($values as $key => $val) + foreach ($values as $key => $val) { $valstr[] = $key." = ".$val; } diff --git a/system/database/drivers/mssql/mssql_forge.php b/system/database/drivers/mssql/mssql_forge.php index 6b02e1eb..70b20ecf 100644 --- a/system/database/drivers/mssql/mssql_forge.php +++ b/system/database/drivers/mssql/mssql_forge.php @@ -6,7 +6,7 @@ * * @package CodeIgniter * @author ExpressionEngine Dev Team - * @copyright Copyright (c) 2008 - 2010, EllisLab, Inc. + * @copyright Copyright (c) 2008 - 2011, EllisLab, Inc. * @license http://codeigniter.com/user_guide/license.html * @link http://codeigniter.com * @since Version 1.0 diff --git a/system/database/drivers/mssql/mssql_result.php b/system/database/drivers/mssql/mssql_result.php index c0a20dbd..2897ca5a 100644 --- a/system/database/drivers/mssql/mssql_result.php +++ b/system/database/drivers/mssql/mssql_result.php @@ -6,7 +6,7 @@ * * @package CodeIgniter * @author ExpressionEngine Dev Team - * @copyright Copyright (c) 2008 - 2010, EllisLab, Inc. + * @copyright Copyright (c) 2008 - 2011, EllisLab, Inc. * @license http://codeigniter.com/user_guide/license.html * @link http://codeigniter.com * @since Version 1.0 diff --git a/system/database/drivers/mssql/mssql_utility.php b/system/database/drivers/mssql/mssql_utility.php index b867dd7b..48ecbc72 100644 --- a/system/database/drivers/mssql/mssql_utility.php +++ b/system/database/drivers/mssql/mssql_utility.php @@ -6,7 +6,7 @@ * * @package CodeIgniter * @author ExpressionEngine Dev Team - * @copyright Copyright (c) 2008 - 2010, EllisLab, Inc. + * @copyright Copyright (c) 2008 - 2011, EllisLab, Inc. * @license http://codeigniter.com/user_guide/license.html * @link http://codeigniter.com * @since Version 1.0 diff --git a/system/database/drivers/mysql/mysql_driver.php b/system/database/drivers/mysql/mysql_driver.php index f27a1eef..28c75a5e 100644 --- a/system/database/drivers/mysql/mysql_driver.php +++ b/system/database/drivers/mysql/mysql_driver.php @@ -6,7 +6,7 @@ * * @package CodeIgniter * @author ExpressionEngine Dev Team - * @copyright Copyright (c) 2008 - 2010, EllisLab, Inc. + * @copyright Copyright (c) 2008 - 2011, EllisLab, Inc. * @license http://codeigniter.com/user_guide/license.html * @link http://codeigniter.com * @since Version 1.0 @@ -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,7 +135,20 @@ function db_select() */ function db_set_charset($charset, $collation) { - return @mysql_query("SET NAMES '".$this->escape_str($charset)."' COLLATE '".$this->escape_str($collation)."'", $this->conn_id); + if ( ! isset($this->use_set_names)) + { + // mysql_set_charset() requires PHP >= 5.2.3 and MySQL >= 5.0.7, use SET NAMES as fallback + $this->use_set_names = (version_compare(PHP_VERSION, '5.2.3', '>=') && version_compare(mysql_get_server_info(), '5.0.7', '>=')) ? FALSE : TRUE; + } + + if ($this->use_set_names === TRUE) + { + return @mysql_query("SET NAMES '".$this->escape_str($charset)."' COLLATE '".$this->escape_str($collation)."'", $this->conn_id); + } + else + { + return @mysql_set_charset($charset, $this->conn_id); + } } // -------------------------------------------------------------------- @@ -286,13 +302,13 @@ function escape_str($str, $like = FALSE) { if (is_array($str)) { - foreach($str as $key => $val) - { + 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)) { @@ -590,9 +606,9 @@ function _insert_batch($table, $keys, $values) */ function _update($table, $values, $where, $orderby = array(), $limit = FALSE) { - foreach($values as $key => $val) + foreach ($values as $key => $val) { - $valstr[] = $key." = ".$val; + $valstr[] = $key . ' = ' . $val; } $limit = ( ! $limit) ? '' : ' LIMIT '.$limit; @@ -627,11 +643,11 @@ function _update_batch($table, $values, $index, $where = NULL) $ids = array(); $where = ($where != '' AND count($where) >=1) ? implode(" ", $where).' AND ' : ''; - foreach($values as $key => $val) + foreach ($values as $key => $val) { $ids[] = $val[$index]; - foreach(array_keys($val) as $field) + foreach (array_keys($val) as $field) { if ($field != $index) { @@ -643,7 +659,7 @@ function _update_batch($table, $values, $index, $where = NULL) $sql = "UPDATE ".$table." SET "; $cases = ''; - foreach($final as $k => $v) + foreach ($final as $k => $v) { $cases .= $k.' = CASE '."\n"; foreach ($v as $row) diff --git a/system/database/drivers/mysql/mysql_forge.php b/system/database/drivers/mysql/mysql_forge.php index 35845d6a..c1cae136 100644 --- a/system/database/drivers/mysql/mysql_forge.php +++ b/system/database/drivers/mysql/mysql_forge.php @@ -6,7 +6,7 @@ * * @package CodeIgniter * @author ExpressionEngine Dev Team - * @copyright Copyright (c) 2008 - 2010, EllisLab, Inc. + * @copyright Copyright (c) 2008 - 2011, EllisLab, Inc. * @license http://codeigniter.com/user_guide/license.html * @link http://codeigniter.com * @since Version 1.0 @@ -119,9 +119,13 @@ function _process_fields($fields) $sql .= ' DEFAULT \''.$attributes['DEFAULT'].'\''; } - if (array_key_exists('NULL', $attributes)) + if (array_key_exists('NULL', $attributes) && $attributes['NULL'] === TRUE) { - $sql .= ($attributes['NULL'] === TRUE) ? ' NULL' : ' NOT NULL'; + $sql .= ' NULL'; + } + else + { + $sql .= ' NOT NULL'; } if (array_key_exists('AUTO_INCREMENT', $attributes) && $attributes['AUTO_INCREMENT'] === TRUE) diff --git a/system/database/drivers/mysql/mysql_result.php b/system/database/drivers/mysql/mysql_result.php index c3aa4ccd..50738960 100644 --- a/system/database/drivers/mysql/mysql_result.php +++ b/system/database/drivers/mysql/mysql_result.php @@ -6,7 +6,7 @@ * * @package CodeIgniter * @author ExpressionEngine Dev Team - * @copyright Copyright (c) 2008 - 2010, EllisLab, Inc. + * @copyright Copyright (c) 2008 - 2011, EllisLab, Inc. * @license http://codeigniter.com/user_guide/license.html * @link http://codeigniter.com * @since Version 1.0 diff --git a/system/database/drivers/mysql/mysql_utility.php b/system/database/drivers/mysql/mysql_utility.php index 1259fee6..e9747c54 100644 --- a/system/database/drivers/mysql/mysql_utility.php +++ b/system/database/drivers/mysql/mysql_utility.php @@ -6,7 +6,7 @@ * * @package CodeIgniter * @author ExpressionEngine Dev Team - * @copyright Copyright (c) 2008 - 2010, EllisLab, Inc. + * @copyright Copyright (c) 2008 - 2011, EllisLab, Inc. * @license http://codeigniter.com/user_guide/license.html * @link http://codeigniter.com * @since Version 1.0 diff --git a/system/database/drivers/mysqli/mysqli_driver.php b/system/database/drivers/mysqli/mysqli_driver.php index b50fe5f7..b1796c9d 100644 --- a/system/database/drivers/mysqli/mysqli_driver.php +++ b/system/database/drivers/mysqli/mysqli_driver.php @@ -6,7 +6,7 @@ * * @package CodeIgniter * @author ExpressionEngine Dev Team - * @copyright Copyright (c) 2008 - 2010, EllisLab, Inc. + * @copyright Copyright (c) 2008 - 2011, EllisLab, Inc. * @license http://codeigniter.com/user_guide/license.html * @link http://codeigniter.com * @since Version 1.0 @@ -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,7 +135,20 @@ function db_select() */ function _db_set_charset($charset, $collation) { - return @mysqli_query($this->conn_id, "SET NAMES '".$this->escape_str($charset)."' COLLATE '".$this->escape_str($collation)."'"); + if ( ! isset($this->use_set_names)) + { + // mysqli_set_charset() requires MySQL >= 5.0.7, use SET NAMES as fallback + $this->use_set_names = (version_compare(mysqli_get_server_info($this->conn_id), '5.0.7', '>=')) ? FALSE : TRUE; + } + + if ($this->use_set_names === TRUE) + { + return @mysqli_query($this->conn_id, "SET NAMES '".$this->escape_str($charset)."' COLLATE '".$this->escape_str($collation)."'"); + } + else + { + return @mysqli_set_charset($this->conn_id, $charset); + } } // -------------------------------------------------------------------- @@ -287,7 +303,7 @@ function escape_str($str, $like = FALSE) { if (is_array($str)) { - foreach($str as $key => $val) + foreach ($str as $key => $val) { $str[$key] = $this->escape_str($val, $like); } @@ -538,6 +554,24 @@ function _insert($table, $keys, $values) // -------------------------------------------------------------------- + /** + * Insert_batch statement + * + * Generates a platform-specific insert string from the supplied data + * + * @access public + * @param string the table name + * @param array the insert keys + * @param array the insert values + * @return string + */ + function _insert_batch($table, $keys, $values) + { + return "INSERT INTO ".$table." (".implode(', ', $keys).") VALUES ".implode(', ', $values); + } + + // -------------------------------------------------------------------- + /** * Update statement * @@ -553,7 +587,7 @@ function _insert($table, $keys, $values) */ function _update($table, $values, $where, $orderby = array(), $limit = FALSE) { - foreach($values as $key => $val) + foreach ($values as $key => $val) { $valstr[] = $key." = ".$val; } @@ -571,6 +605,57 @@ function _update($table, $values, $where, $orderby = array(), $limit = FALSE) return $sql; } + // -------------------------------------------------------------------- + + /** + * Update_Batch statement + * + * Generates a platform-specific batch update string from the supplied data + * + * @access public + * @param string the table name + * @param array the update data + * @param array the where clause + * @return string + */ + function _update_batch($table, $values, $index, $where = NULL) + { + $ids = array(); + $where = ($where != '' AND count($where) >=1) ? implode(" ", $where).' AND ' : ''; + + foreach ($values as $key => $val) + { + $ids[] = $val[$index]; + + foreach (array_keys($val) as $field) + { + if ($field != $index) + { + $final[$field][] = 'WHEN '.$index.' = '.$val[$index].' THEN '.$val[$field]; + } + } + } + + $sql = "UPDATE ".$table." SET "; + $cases = ''; + + foreach ($final as $k => $v) + { + $cases .= $k.' = CASE '."\n"; + foreach ($v as $row) + { + $cases .= $row."\n"; + } + + $cases .= 'ELSE '.$k.' END, '; + } + + $sql .= substr($cases, 0, -2); + + $sql .= ' WHERE '.$where.$index.' IN ('.implode(',', $ids).')'; + + return $sql; + } // -------------------------------------------------------------------- diff --git a/system/database/drivers/mysqli/mysqli_forge.php b/system/database/drivers/mysqli/mysqli_forge.php index 5d5b7808..26054945 100644 --- a/system/database/drivers/mysqli/mysqli_forge.php +++ b/system/database/drivers/mysqli/mysqli_forge.php @@ -6,7 +6,7 @@ * * @package CodeIgniter * @author ExpressionEngine Dev Team - * @copyright Copyright (c) 2008 - 2010, EllisLab, Inc. + * @copyright Copyright (c) 2008 - 2011, EllisLab, Inc. * @license http://codeigniter.com/user_guide/license.html * @link http://codeigniter.com * @since Version 1.0 @@ -104,9 +104,13 @@ function _process_fields($fields) $sql .= ' DEFAULT \''.$attributes['DEFAULT'].'\''; } - if (array_key_exists('NULL', $attributes)) + if (array_key_exists('NULL', $attributes) && $attributes['NULL'] === TRUE) { - $sql .= ($attributes['NULL'] === TRUE) ? ' NULL' : ' NOT NULL'; + $sql .= ' NULL'; + } + else + { + $sql .= ' NOT NULL'; } if (array_key_exists('AUTO_INCREMENT', $attributes) && $attributes['AUTO_INCREMENT'] === TRUE) diff --git a/system/database/drivers/mysqli/mysqli_result.php b/system/database/drivers/mysqli/mysqli_result.php index 16f57c07..c4d8f5d5 100644 --- a/system/database/drivers/mysqli/mysqli_result.php +++ b/system/database/drivers/mysqli/mysqli_result.php @@ -6,7 +6,7 @@ * * @package CodeIgniter * @author ExpressionEngine Dev Team - * @copyright Copyright (c) 2008 - 2010, EllisLab, Inc. + * @copyright Copyright (c) 2008 - 2011, EllisLab, Inc. * @license http://codeigniter.com/user_guide/license.html * @link http://codeigniter.com * @since Version 1.0 diff --git a/system/database/drivers/mysqli/mysqli_utility.php b/system/database/drivers/mysqli/mysqli_utility.php index 84ff0daf..e17889b8 100644 --- a/system/database/drivers/mysqli/mysqli_utility.php +++ b/system/database/drivers/mysqli/mysqli_utility.php @@ -6,7 +6,7 @@ * * @package CodeIgniter * @author ExpressionEngine Dev Team - * @copyright Copyright (c) 2008 - 2010, EllisLab, Inc. + * @copyright Copyright (c) 2008 - 2011, EllisLab, Inc. * @license http://codeigniter.com/user_guide/license.html * @link http://codeigniter.com * @since Version 1.0 diff --git a/system/database/drivers/oci8/oci8_driver.php b/system/database/drivers/oci8/oci8_driver.php index 44d5dec7..14df104f 100644 --- a/system/database/drivers/oci8/oci8_driver.php +++ b/system/database/drivers/oci8/oci8_driver.php @@ -6,7 +6,7 @@ * * @package CodeIgniter * @author ExpressionEngine Dev Team - * @copyright Copyright (c) 2008 - 2010, EllisLab, Inc. + * @copyright Copyright (c) 2008 - 2011, EllisLab, Inc. * @license http://codeigniter.com/user_guide/license.html * @link http://codeigniter.com * @since Version 1.0 @@ -253,7 +253,7 @@ function stored_procedure($package, $procedure, $params) $sql = "begin $package.$procedure("; $have_cursor = FALSE; - foreach($params as $param) + foreach ($params as $param) { $sql .= $param['name'] . ","; @@ -395,7 +395,7 @@ function escape_str($str, $like = FALSE) { if (is_array($str)) { - foreach($str as $key => $val) + foreach ($str as $key => $val) { $str[$key] = $this->escape_str($val, $like); } @@ -655,7 +655,7 @@ function _insert($table, $keys, $values) */ function _update($table, $values, $where, $orderby = array(), $limit = FALSE) { - foreach($values as $key => $val) + foreach ($values as $key => $val) { $valstr[] = $key." = ".$val; } diff --git a/system/database/drivers/oci8/oci8_forge.php b/system/database/drivers/oci8/oci8_forge.php index 4bcb081b..3cd17585 100644 --- a/system/database/drivers/oci8/oci8_forge.php +++ b/system/database/drivers/oci8/oci8_forge.php @@ -6,7 +6,7 @@ * * @package CodeIgniter * @author ExpressionEngine Dev Team - * @copyright Copyright (c) 2008 - 2010, EllisLab, Inc. + * @copyright Copyright (c) 2008 - 2011, EllisLab, Inc. * @license http://codeigniter.com/user_guide/license.html * @link http://codeigniter.com * @since Version 1.0 diff --git a/system/database/drivers/oci8/oci8_result.php b/system/database/drivers/oci8/oci8_result.php index 058524f4..88531b43 100644 --- a/system/database/drivers/oci8/oci8_result.php +++ b/system/database/drivers/oci8/oci8_result.php @@ -6,7 +6,7 @@ * * @package CodeIgniter * @author ExpressionEngine Dev Team - * @copyright Copyright (c) 2008 - 2010, EllisLab, Inc. + * @copyright Copyright (c) 2008 - 2011, EllisLab, Inc. * @license http://codeigniter.com/user_guide/license.html * @link http://codeigniter.com * @since Version 1.0 diff --git a/system/database/drivers/oci8/oci8_utility.php b/system/database/drivers/oci8/oci8_utility.php index 48d4acec..854b467e 100644 --- a/system/database/drivers/oci8/oci8_utility.php +++ b/system/database/drivers/oci8/oci8_utility.php @@ -6,7 +6,7 @@ * * @package CodeIgniter * @author ExpressionEngine Dev Team - * @copyright Copyright (c) 2008 - 2010, EllisLab, Inc. + * @copyright Copyright (c) 2008 - 2011, EllisLab, Inc. * @license http://codeigniter.com/user_guide/license.html * @link http://codeigniter.com * @since Version 1.0 diff --git a/system/database/drivers/odbc/odbc_driver.php b/system/database/drivers/odbc/odbc_driver.php index af90f0c7..81e0d7cf 100644 --- a/system/database/drivers/odbc/odbc_driver.php +++ b/system/database/drivers/odbc/odbc_driver.php @@ -6,7 +6,7 @@ * * @package CodeIgniter * @author ExpressionEngine Dev Team - * @copyright Copyright (c) 2008 - 2010, EllisLab, Inc. + * @copyright Copyright (c) 2008 - 2011, EllisLab, Inc. * @license http://codeigniter.com/user_guide/license.html * @link http://codeigniter.com * @since Version 1.0 @@ -264,7 +264,7 @@ function escape_str($str, $like = FALSE) { if (is_array($str)) { - foreach($str as $key => $val) + foreach ($str as $key => $val) { $str[$key] = $this->escape_str($val, $like); } @@ -523,7 +523,7 @@ function _insert($table, $keys, $values) */ function _update($table, $values, $where, $orderby = array(), $limit = FALSE) { - foreach($values as $key => $val) + foreach ($values as $key => $val) { $valstr[] = $key." = ".$val; } diff --git a/system/database/drivers/odbc/odbc_forge.php b/system/database/drivers/odbc/odbc_forge.php index 602016ad..3ec86b4e 100644 --- a/system/database/drivers/odbc/odbc_forge.php +++ b/system/database/drivers/odbc/odbc_forge.php @@ -6,7 +6,7 @@ * * @package CodeIgniter * @author ExpressionEngine Dev Team - * @copyright Copyright (c) 2008 - 2010, EllisLab, Inc. + * @copyright Copyright (c) 2008 - 2011, EllisLab, Inc. * @license http://codeigniter.com/user_guide/license.html * @link http://codeigniter.com * @since Version 1.0 diff --git a/system/database/drivers/odbc/odbc_result.php b/system/database/drivers/odbc/odbc_result.php index b673464b..5d64a464 100644 --- a/system/database/drivers/odbc/odbc_result.php +++ b/system/database/drivers/odbc/odbc_result.php @@ -6,7 +6,7 @@ * * @package CodeIgniter * @author ExpressionEngine Dev Team - * @copyright Copyright (c) 2008 - 2010, EllisLab, Inc. + * @copyright Copyright (c) 2008 - 2011, EllisLab, Inc. * @license http://codeigniter.com/user_guide/license.html * @link http://codeigniter.com * @since Version 1.0 @@ -188,7 +188,7 @@ function _fetch_object() */ function _odbc_fetch_object(& $odbc_result) { $rs = array(); - $rs_obj = false; + $rs_obj = FALSE; if (odbc_fetch_into($odbc_result, $rs)) { foreach ($rs as $k=>$v) { $field_name= odbc_field_name($odbc_result, $k+1); @@ -210,7 +210,7 @@ function _odbc_fetch_object(& $odbc_result) { */ function _odbc_fetch_array(& $odbc_result) { $rs = array(); - $rs_assoc = false; + $rs_assoc = FALSE; if (odbc_fetch_into($odbc_result, $rs)) { $rs_assoc=array(); foreach ($rs as $k=>$v) { diff --git a/system/database/drivers/odbc/odbc_utility.php b/system/database/drivers/odbc/odbc_utility.php index 9f9ef5a3..d335bed9 100644 --- a/system/database/drivers/odbc/odbc_utility.php +++ b/system/database/drivers/odbc/odbc_utility.php @@ -6,7 +6,7 @@ * * @package CodeIgniter * @author ExpressionEngine Dev Team - * @copyright Copyright (c) 2008 - 2010, EllisLab, Inc. + * @copyright Copyright (c) 2008 - 2011, EllisLab, Inc. * @license http://codeigniter.com/user_guide/license.html * @link http://codeigniter.com * @since Version 1.0 diff --git a/system/database/drivers/postgre/postgre_driver.php b/system/database/drivers/postgre/postgre_driver.php index b61a9d75..14039688 100644 --- a/system/database/drivers/postgre/postgre_driver.php +++ b/system/database/drivers/postgre/postgre_driver.php @@ -6,7 +6,7 @@ * * @package CodeIgniter * @author ExpressionEngine Dev Team - * @copyright Copyright (c) 2008 - 2010, EllisLab, Inc. + * @copyright Copyright (c) 2008 - 2011, EllisLab, Inc. * @license http://codeigniter.com/user_guide/license.html * @link http://codeigniter.com * @since Version 1.0 @@ -283,7 +283,7 @@ function escape_str($str, $like = FALSE) { if (is_array($str)) { - foreach($str as $key => $val) + foreach ($str as $key => $val) { $str[$key] = $this->escape_str($val, $like); } @@ -330,21 +330,21 @@ function insert_id() $v = $this->_version(); $v = $v['server']; - $table = func_num_args() > 0 ? func_get_arg(0) : null; - $column = func_num_args() > 1 ? func_get_arg(1) : null; + $table = func_num_args() > 0 ? func_get_arg(0) : NULL; + $column = func_num_args() > 1 ? func_get_arg(1) : NULL; - if ($table == null && $v >= '8.1') + if ($table == NULL && $v >= '8.1') { $sql='SELECT LASTVAL() as ins_id'; } - elseif ($table != null && $column != null && $v >= '8.0') + elseif ($table != NULL && $column != NULL && $v >= '8.0') { $sql = sprintf("SELECT pg_get_serial_sequence('%s','%s') as seq", $table, $column); $query = $this->query($sql); $row = $query->row(); $sql = sprintf("SELECT CURRVAL('%s') as ins_id", $row->seq); } - elseif ($table != null) + elseif ($table != NULL) { // seq_name passed in table parameter $sql = sprintf("SELECT CURRVAL('%s') as ins_id", $table); @@ -553,6 +553,24 @@ function _insert($table, $keys, $values) // -------------------------------------------------------------------- + /** + * Insert_batch statement + * + * Generates a platform-specific insert string from the supplied data + * + * @access public + * @param string the table name + * @param array the insert keys + * @param array the insert values + * @return string + */ + function _insert_batch($table, $keys, $values) + { + return "INSERT INTO ".$table." (".implode(', ', $keys).") VALUES ".implode(', ', $values); + } + + // -------------------------------------------------------------------- + /** * Update statement * @@ -568,7 +586,7 @@ function _insert($table, $keys, $values) */ function _update($table, $values, $where, $orderby = array(), $limit = FALSE) { - foreach($values as $key => $val) + foreach ($values as $key => $val) { $valstr[] = $key." = ".$val; } diff --git a/system/database/drivers/postgre/postgre_forge.php b/system/database/drivers/postgre/postgre_forge.php index 41858f36..91a1c686 100644 --- a/system/database/drivers/postgre/postgre_forge.php +++ b/system/database/drivers/postgre/postgre_forge.php @@ -6,7 +6,7 @@ * * @package CodeIgniter * @author ExpressionEngine Dev Team - * @copyright Copyright (c) 2008 - 2010, EllisLab, Inc. + * @copyright Copyright (c) 2008 - 2011, EllisLab, Inc. * @license http://codeigniter.com/user_guide/license.html * @link http://codeigniter.com * @since Version 1.0 @@ -69,7 +69,10 @@ function _create_table($table, $fields, $primary_keys, $keys, $if_not_exists) if ($if_not_exists === TRUE) { - $sql .= 'IF NOT EXISTS '; + if ($this->db->table_exists($table)) + { + return "SELECT * FROM $table"; // Needs to return innocous but valid SQL statement + } } $sql .= $this->db->_escape_identifiers($table)." ("; @@ -90,16 +93,55 @@ function _create_table($table, $fields, $primary_keys, $keys, $if_not_exists) $sql .= "\n\t".$this->db->_protect_identifiers($field); - $sql .= ' '.$attributes['TYPE']; + $is_unsigned = (array_key_exists('UNSIGNED', $attributes) && $attributes['UNSIGNED'] === TRUE); - if (array_key_exists('CONSTRAINT', $attributes)) + // Convert datatypes to be PostgreSQL-compatible + switch (strtoupper($attributes['TYPE'])) { - $sql .= '('.$attributes['CONSTRAINT'].')'; + case 'TINYINT': + $attributes['TYPE'] = 'SMALLINT'; + break; + case 'SMALLINT': + $attributes['TYPE'] = ($is_unsigned) ? 'INTEGER' : 'SMALLINT'; + break; + case 'MEDIUMINT': + $attributes['TYPE'] = 'INTEGER'; + break; + case 'INT': + $attributes['TYPE'] = ($is_unsigned) ? 'BIGINT' : 'INTEGER'; + break; + case 'BIGINT': + $attributes['TYPE'] = ($is_unsigned) ? 'NUMERIC' : 'BIGINT'; + break; + case 'DOUBLE': + $attributes['TYPE'] = 'DOUBLE PRECISION'; + break; + case 'DATETIME': + $attributes['TYPE'] = 'TIMESTAMP'; + break; + case 'LONGTEXT': + $attributes['TYPE'] = 'TEXT'; + break; + case 'BLOB': + $attributes['TYPE'] = 'BYTEA'; + break; } - if (array_key_exists('UNSIGNED', $attributes) && $attributes['UNSIGNED'] === TRUE) + // If this is an auto-incrementing primary key, use the serial data type instead + if (in_array($field, $primary_keys) && array_key_exists('AUTO_INCREMENT', $attributes) + && $attributes['AUTO_INCREMENT'] === TRUE) + { + $sql .= ' SERIAL'; + } + else { - $sql .= ' UNSIGNED'; + $sql .= ' '.$attributes['TYPE']; + } + + // Modified to prevent constraints with integer data types + if (array_key_exists('CONSTRAINT', $attributes) && strpos($attributes['TYPE'], 'INT') === false) + { + $sql .= '('.$attributes['CONSTRAINT'].')'; } if (array_key_exists('DEFAULT', $attributes)) @@ -116,9 +158,10 @@ function _create_table($table, $fields, $primary_keys, $keys, $if_not_exists) $sql .= ' NOT NULL'; } - if (array_key_exists('AUTO_INCREMENT', $attributes) && $attributes['AUTO_INCREMENT'] === TRUE) + // Added new attribute to create unqite fields. Also works with MySQL + if (array_key_exists('UNIQUE', $attributes) && $attributes['UNIQUE'] === TRUE) { - $sql .= ' AUTO_INCREMENT'; + $sql .= ' UNIQUE'; } } @@ -131,10 +174,17 @@ function _create_table($table, $fields, $primary_keys, $keys, $if_not_exists) if (count($primary_keys) > 0) { - $primary_keys = $this->db->_protect_identifiers($primary_keys); + // Something seems to break when passing an array to _protect_identifiers() + foreach ($primary_keys as $index => $key) + { + $primary_keys[$index] = $this->db->_protect_identifiers($key); + } + $sql .= ",\n\tPRIMARY KEY (" . implode(', ', $primary_keys) . ")"; } + $sql .= "\n);"; + if (is_array($keys) && count($keys) > 0) { foreach ($keys as $key) @@ -148,12 +198,13 @@ function _create_table($table, $fields, $primary_keys, $keys, $if_not_exists) $key = array($this->db->_protect_identifiers($key)); } - $sql .= ",\n\tFOREIGN KEY (" . implode(', ', $key) . ")"; + foreach ($key as $field) + { + $sql .= "CREATE INDEX " . $table . "_" . str_replace(array('"', "'"), '', $field) . "_index ON $table ($field); "; + } } } - $sql .= "\n);"; - return $sql; } @@ -162,12 +213,12 @@ function _create_table($table, $fields, $primary_keys, $keys, $if_not_exists) /** * Drop Table * - * @access private - * @return bool + * @access private + * @return bool */ function _drop_table($table) { - return "DROP TABLE ".$this->db->_escape_identifiers($table)." CASCADE"; + return "DROP TABLE IF EXISTS ".$this->db->_escape_identifiers($table)." CASCADE"; } // -------------------------------------------------------------------- diff --git a/system/database/drivers/postgre/postgre_result.php b/system/database/drivers/postgre/postgre_result.php index 12663120..e9a1d160 100644 --- a/system/database/drivers/postgre/postgre_result.php +++ b/system/database/drivers/postgre/postgre_result.php @@ -6,7 +6,7 @@ * * @package CodeIgniter * @author ExpressionEngine Dev Team - * @copyright Copyright (c) 2008 - 2010, EllisLab, Inc. + * @copyright Copyright (c) 2008 - 2011, EllisLab, Inc. * @license http://codeigniter.com/user_guide/license.html * @link http://codeigniter.com * @since Version 1.0 diff --git a/system/database/drivers/postgre/postgre_utility.php b/system/database/drivers/postgre/postgre_utility.php index f04c7f08..741c52ea 100644 --- a/system/database/drivers/postgre/postgre_utility.php +++ b/system/database/drivers/postgre/postgre_utility.php @@ -6,7 +6,7 @@ * * @package CodeIgniter * @author ExpressionEngine Dev Team - * @copyright Copyright (c) 2008 - 2010, EllisLab, Inc. + * @copyright Copyright (c) 2008 - 2011, EllisLab, Inc. * @license http://codeigniter.com/user_guide/license.html * @link http://codeigniter.com * @since Version 1.0 diff --git a/system/database/drivers/sqlite/sqlite_driver.php b/system/database/drivers/sqlite/sqlite_driver.php index d6c6897c..eb4e585b 100644 --- a/system/database/drivers/sqlite/sqlite_driver.php +++ b/system/database/drivers/sqlite/sqlite_driver.php @@ -6,7 +6,7 @@ * * @package CodeIgniter * @author ExpressionEngine Dev Team - * @copyright Copyright (c) 2008 - 2010, EllisLab, Inc. + * @copyright Copyright (c) 2008 - 2011, EllisLab, Inc. * @license http://codeigniter.com/user_guide/license.html * @link http://codeigniter.com * @since Version 1.0 @@ -280,7 +280,7 @@ function escape_str($str, $like = FALSE) { if (is_array($str)) { - foreach($str as $key => $val) + foreach ($str as $key => $val) { $str[$key] = $this->escape_str($val, $like); } @@ -537,7 +537,7 @@ function _insert($table, $keys, $values) */ function _update($table, $values, $where, $orderby = array(), $limit = FALSE) { - foreach($values as $key => $val) + foreach ($values as $key => $val) { $valstr[] = $key." = ".$val; } diff --git a/system/database/drivers/sqlite/sqlite_forge.php b/system/database/drivers/sqlite/sqlite_forge.php index 0aa5d382..56904082 100644 --- a/system/database/drivers/sqlite/sqlite_forge.php +++ b/system/database/drivers/sqlite/sqlite_forge.php @@ -6,7 +6,7 @@ * * @package CodeIgniter * @author ExpressionEngine Dev Team - * @copyright Copyright (c) 2008 - 2010, EllisLab, Inc. + * @copyright Copyright (c) 2008 - 2011, EllisLab, Inc. * @license http://codeigniter.com/user_guide/license.html * @link http://codeigniter.com * @since Version 1.0 diff --git a/system/database/drivers/sqlite/sqlite_result.php b/system/database/drivers/sqlite/sqlite_result.php index 9a86aa99..7bd30db7 100644 --- a/system/database/drivers/sqlite/sqlite_result.php +++ b/system/database/drivers/sqlite/sqlite_result.php @@ -6,7 +6,7 @@ * * @package CodeIgniter * @author ExpressionEngine Dev Team - * @copyright Copyright (c) 2008 - 2010, EllisLab, Inc. + * @copyright Copyright (c) 2008 - 2011, EllisLab, Inc. * @license http://codeigniter.com/user_guide/license.html * @link http://codeigniter.com * @since Version 1.0 diff --git a/system/database/drivers/sqlite/sqlite_utility.php b/system/database/drivers/sqlite/sqlite_utility.php index b76c1b36..508023e2 100644 --- a/system/database/drivers/sqlite/sqlite_utility.php +++ b/system/database/drivers/sqlite/sqlite_utility.php @@ -6,7 +6,7 @@ * * @package CodeIgniter * @author ExpressionEngine Dev Team - * @copyright Copyright (c) 2008 - 2010, EllisLab, Inc. + * @copyright Copyright (c) 2008 - 2011, EllisLab, Inc. * @license http://codeigniter.com/user_guide/license.html * @link http://codeigniter.com * @since Version 1.0 diff --git a/system/fonts/texb.ttf b/system/fonts/texb.ttf index 6792342a..383c88b8 100644 Binary files a/system/fonts/texb.ttf and b/system/fonts/texb.ttf differ diff --git a/system/helpers/array_helper.php b/system/helpers/array_helper.php index 47c5f103..075a31fd 100644 --- a/system/helpers/array_helper.php +++ b/system/helpers/array_helper.php @@ -6,7 +6,7 @@ * * @package CodeIgniter * @author ExpressionEngine Dev Team - * @copyright Copyright (c) 2008 - 2010, EllisLab, Inc. + * @copyright Copyright (c) 2008 - 2011, EllisLab, Inc. * @license http://codeigniter.com/user_guide/license.html * @link http://codeigniter.com * @since Version 1.0 @@ -69,6 +69,7 @@ function random_element($array) { return $array; } + return $array[array_rand($array)]; } } diff --git a/system/helpers/captcha_helper.php b/system/helpers/captcha_helper.php index 0f4e68c5..19ec0c77 100644 --- a/system/helpers/captcha_helper.php +++ b/system/helpers/captcha_helper.php @@ -6,7 +6,7 @@ * * @package CodeIgniter * @author ExpressionEngine Dev Team - * @copyright Copyright (c) 2008 - 2010, EllisLab, Inc. + * @copyright Copyright (c) 2008 - 2011, EllisLab, Inc. * @license http://codeigniter.com/user_guide/license.html * @link http://codeigniter.com * @since Version 1.0 @@ -87,7 +87,7 @@ function create_captcha($data = '', $img_path = '', $img_url = '', $font_path = $current_dir = @opendir($img_path); - while($filename = @readdir($current_dir)) + while ($filename = @readdir($current_dir)) { if ($filename != "." and $filename != ".." and $filename != "index.html") { diff --git a/system/helpers/cookie_helper.php b/system/helpers/cookie_helper.php index 4283bfd0..7cee0282 100644 --- a/system/helpers/cookie_helper.php +++ b/system/helpers/cookie_helper.php @@ -6,7 +6,7 @@ * * @package CodeIgniter * @author ExpressionEngine Dev Team - * @copyright Copyright (c) 2008 - 2010, EllisLab, Inc. + * @copyright Copyright (c) 2008 - 2011, EllisLab, Inc. * @license http://codeigniter.com/user_guide/license.html * @link http://codeigniter.com * @since Version 1.0 @@ -44,11 +44,11 @@ */ if ( ! function_exists('set_cookie')) { - function set_cookie($name = '', $value = '', $expire = '', $domain = '', $path = '/', $prefix = '') + function set_cookie($name = '', $value = '', $expire = '', $domain = '', $path = '/', $prefix = '', $secure = FALSE) { // Set the config file options $CI =& get_instance(); - $CI->input->set_cookie($name, $value, $expire, $domain, $path, $prefix); + $CI->input->set_cookie($name, $value, $expire, $domain, $path, $prefix, $secure); } } diff --git a/system/helpers/date_helper.php b/system/helpers/date_helper.php index c8680a1d..553e8d7e 100644 --- a/system/helpers/date_helper.php +++ b/system/helpers/date_helper.php @@ -6,7 +6,7 @@ * * @package CodeIgniter * @author ExpressionEngine Dev Team - * @copyright Copyright (c) 2008 - 2010, EllisLab, Inc. + * @copyright Copyright (c) 2008 - 2011, EllisLab, Inc. * @license http://codeigniter.com/user_guide/license.html * @link http://codeigniter.com * @since Version 1.0 @@ -114,7 +114,7 @@ function standard_date($fmt = 'DATE_RFC822', $time = '') $formats = array( 'DATE_ATOM' => '%Y-%m-%dT%H:%i:%s%Q', 'DATE_COOKIE' => '%l, %d-%M-%y %H:%i:%s UTC', - 'DATE_ISO8601' => '%Y-%m-%dT%H:%i:%s%O', + 'DATE_ISO8601' => '%Y-%m-%dT%H:%i:%s%Q', 'DATE_RFC822' => '%D, %d %M %y %H:%i:%s %O', 'DATE_RFC850' => '%l, %d-%M-%y %H:%m:%i UTC', 'DATE_RFC1036' => '%D, %d %M %y %H:%i:%s %O', diff --git a/system/helpers/directory_helper.php b/system/helpers/directory_helper.php index 30aaa617..38347fa6 100644 --- a/system/helpers/directory_helper.php +++ b/system/helpers/directory_helper.php @@ -6,7 +6,7 @@ * * @package CodeIgniter * @author ExpressionEngine Dev Team - * @copyright Copyright (c) 2008 - 2010, EllisLab, Inc. + * @copyright Copyright (c) 2008 - 2011, EllisLab, Inc. * @license http://codeigniter.com/user_guide/license.html * @link http://codeigniter.com * @since Version 1.0 diff --git a/system/helpers/download_helper.php b/system/helpers/download_helper.php index ba9c0a3c..1145688a 100644 --- a/system/helpers/download_helper.php +++ b/system/helpers/download_helper.php @@ -6,7 +6,7 @@ * * @package CodeIgniter * @author ExpressionEngine Dev Team - * @copyright Copyright (c) 2008 - 2010, EllisLab, Inc. + * @copyright Copyright (c) 2008 - 2011, EllisLab, Inc. * @license http://codeigniter.com/user_guide/license.html * @link http://codeigniter.com * @since Version 1.0 @@ -58,7 +58,14 @@ function force_download($filename = '', $data = '') $extension = end($x); // Load the mime types - @include(APPPATH.'config/mimes'.EXT); + if (defined('ENVIRONMENT') AND is_file(APPPATH.'config/'.ENVIRONMENT.'/mimes.php')) + { + include(APPPATH.'config/'.ENVIRONMENT.'/mimes.php'); + } + elseif (is_file(APPPATH.'config/mimes.php')) + { + include(APPPATH.'config/mimes.php'); + } // Set a default mime if we can't find it if ( ! isset($mimes[$extension])) diff --git a/system/helpers/email_helper.php b/system/helpers/email_helper.php index b6f7437e..651aef43 100644 --- a/system/helpers/email_helper.php +++ b/system/helpers/email_helper.php @@ -6,7 +6,7 @@ * * @package CodeIgniter * @author ExpressionEngine Dev Team - * @copyright Copyright (c) 2008 - 2010, EllisLab, Inc. + * @copyright Copyright (c) 2008 - 2011, EllisLab, Inc. * @license http://codeigniter.com/user_guide/license.html * @link http://codeigniter.com * @since Version 1.0 diff --git a/system/helpers/file_helper.php b/system/helpers/file_helper.php index 9b9f9dca..3931667f 100644 --- a/system/helpers/file_helper.php +++ b/system/helpers/file_helper.php @@ -6,7 +6,7 @@ * * @package CodeIgniter * @author ExpressionEngine Dev Team - * @copyright Copyright (c) 2008 - 2010, EllisLab, Inc. + * @copyright Copyright (c) 2008 - 2011, EllisLab, Inc. * @license http://codeigniter.com/user_guide/license.html * @link http://codeigniter.com * @since Version 1.0 @@ -128,7 +128,7 @@ function delete_files($path, $del_dir = FALSE, $level = 0) return FALSE; } - while(FALSE !== ($filename = @readdir($current_dir))) + while (FALSE !== ($filename = @readdir($current_dir))) { if ($filename != "." and $filename != "..") { @@ -352,7 +352,16 @@ function get_mime_by_extension($file) if ( ! is_array($mimes)) { - if ( ! require_once(APPPATH.'config/mimes.php')) + if (defined('ENVIRONMENT') AND is_file(APPPATH.'config/'.ENVIRONMENT.'/mimes.php')) + { + include(APPPATH.'config/'.ENVIRONMENT.'/mimes.php'); + } + elseif (is_file(APPPATH.'config/mimes.php')) + { + include(APPPATH.'config/mimes.php'); + } + + if ( ! is_array($mimes)) { return FALSE; } diff --git a/system/helpers/form_helper.php b/system/helpers/form_helper.php index b9381f7b..5720a06e 100644 --- a/system/helpers/form_helper.php +++ b/system/helpers/form_helper.php @@ -6,7 +6,7 @@ * * @package CodeIgniter * @author ExpressionEngine Dev Team - * @copyright Copyright (c) 2008 - 2010, EllisLab, Inc. + * @copyright Copyright (c) 2008 - 2011, EllisLab, Inc. * @license http://codeigniter.com/user_guide/license.html * @link http://codeigniter.com * @since Version 1.0 @@ -49,7 +49,14 @@ function form_open($action = '', $attributes = '', $hidden = array()) $attributes = 'method="post"'; } - $action = ( strpos($action, '://') === FALSE) ? $CI->config->site_url($action) : $action; + // If an action is not a full URL then turn it into one + if ($action && strpos($action, '://') === FALSE) + { + $action = $CI->config->site_url($action); + } + + // If no action is provided then set to the current url + $action OR $action = $CI->config->site_url($CI->uri->uri_string()); $form = '
config->item('csrf_protection') === TRUE) + // Add CSRF field if enabled, but leave it out for GET requests and requests to external websites + if ($CI->config->item('csrf_protection') === TRUE AND ! (strpos($action, $CI->config->site_url()) === FALSE OR strpos($form, 'method="get"'))) { - $hidden[$CI->security->csrf_token_name] = $CI->security->csrf_hash; + $hidden[$CI->security->get_csrf_token_name()] = $CI->security->get_csrf_hash(); } if (is_array($hidden) AND count($hidden) > 0) { - $form .= sprintf("\n
%s
", form_hidden($hidden)); + $form .= sprintf("
%s
", form_hidden($hidden)); } return $form; @@ -1025,25 +1032,23 @@ function &_get_validation_object() { $CI =& get_instance(); - // We set this as a variable since we're returning by reference + // We set this as a variable since we're returning by reference. $return = FALSE; - - if ( ! isset($CI->load->_ci_classes) OR ! isset($CI->load->_ci_classes['form_validation'])) + + if (FALSE !== ($object = $CI->load->is_loaded('form_validation'))) { - return $return; - } - - $object = $CI->load->_ci_classes['form_validation']; - - if ( ! isset($CI->$object) OR ! is_object($CI->$object)) - { - return $return; + if ( ! isset($CI->$object) OR ! is_object($CI->$object)) + { + return $return; + } + + return $CI->$object; } - - return $CI->$object; + + return $return; } } /* End of file form_helper.php */ -/* Location: ./system/helpers/form_helper.php */ \ No newline at end of file +/* Location: ./system/helpers/form_helper.php */ diff --git a/system/helpers/html_helper.php b/system/helpers/html_helper.php index 0ba4eba2..080f622d 100644 --- a/system/helpers/html_helper.php +++ b/system/helpers/html_helper.php @@ -6,7 +6,7 @@ * * @package CodeIgniter * @author ExpressionEngine Dev Team - * @copyright Copyright (c) 2008 - 2010, EllisLab, Inc. + * @copyright Copyright (c) 2008 - 2011, EllisLab, Inc. * @license http://codeigniter.com/user_guide/license.html * @link http://codeigniter.com * @since Version 1.0 @@ -40,9 +40,10 @@ */ if ( ! function_exists('heading')) { - function heading($data = '', $h = '1') + function heading($data = '', $h = '1', $attributes = '') { - return "".$data.""; + $attributes = ($attributes != '') ? ' '.$attributes : $attributes; + return "".$data.""; } } @@ -258,7 +259,16 @@ function doctype($type = 'xhtml1-strict') if ( ! is_array($_doctypes)) { - if ( ! require_once(APPPATH.'config/doctypes.php')) + if (defined('ENVIRONMENT') AND is_file(APPPATH.'config/'.ENVIRONMENT.'/doctypes.php')) + { + include(APPPATH.'config/'.ENVIRONMENT.'/doctypes.php'); + } + elseif (is_file(APPPATH.'config/doctypes.php')) + { + include(APPPATH.'config/doctypes.php'); + } + + if ( ! is_array($_doctypes)) { return FALSE; } diff --git a/system/helpers/inflector_helper.php b/system/helpers/inflector_helper.php index 88f48d48..c7c113b8 100644 --- a/system/helpers/inflector_helper.php +++ b/system/helpers/inflector_helper.php @@ -6,7 +6,7 @@ * * @package CodeIgniter * @author ExpressionEngine Dev Team - * @copyright Copyright (c) 2008 - 2010, EllisLab, Inc. + * @copyright Copyright (c) 2008 - 2011, EllisLab, Inc. * @license http://codeigniter.com/user_guide/license.html * @link http://codeigniter.com * @since Version 1.0 @@ -41,20 +41,22 @@ { function singular($str) { - $str = strtolower(trim($str)); + $str = trim($str); $end = substr($str, -3); - - if ($end == 'ies') + + $str = preg_replace('/(.*)?([s|c]h)es/i','$1$2',$str); + + if (strtolower($end) == 'ies') { - $str = substr($str, 0, strlen($str)-3).'y'; + $str = substr($str, 0, strlen($str)-3).(preg_match('/[a-z]/',$end) ? 'y' : 'Y'); } - elseif ($end == 'ses') + elseif (strtolower($end) == 'ses') { $str = substr($str, 0, strlen($str)-2); } else { - $end = substr($str, -1); + $end = strtolower(substr($str, -1)); if ($end == 's') { @@ -81,19 +83,19 @@ function singular($str) if ( ! function_exists('plural')) { function plural($str, $force = FALSE) - { - $str = strtolower(trim($str)); + { + $str = trim($str); $end = substr($str, -1); - if ($end == 'y') + if (preg_match('/y/i',$end)) { // Y preceded by vowel => regular plural - $vowels = array('a', 'e', 'i', 'o', 'u'); + $vowels = array('a', 'e', 'i', 'o', 'u', 'A', 'E', 'I', 'O', 'U'); $str = in_array(substr($str, -2, 1), $vowels) ? $str.'s' : substr($str, 0, -1).'ies'; } - elseif ($end == 'h') + elseif (preg_match('/h/i',$end)) { - if (substr($str, -2) == 'ch' OR substr($str, -2) == 'sh') + if(preg_match('/^[c|s]h$/i',substr($str, -2))) { $str .= 'es'; } @@ -102,7 +104,7 @@ function plural($str, $force = FALSE) $str .= 's'; } } - elseif ($end == 's') + elseif (preg_match('/s/i',$end)) { if ($force == TRUE) { diff --git a/system/helpers/language_helper.php b/system/helpers/language_helper.php index 06428a76..ac0d69da 100644 --- a/system/helpers/language_helper.php +++ b/system/helpers/language_helper.php @@ -1,4 +1,4 @@ -generate($str); - } - else - { - return bin2hex(mhash(MHASH_SHA1, $str)); - } - } - else - { - return sha1($str); - } + return sha1($str); } else { diff --git a/system/helpers/smiley_helper.php b/system/helpers/smiley_helper.php index da3fd286..6d888935 100644 --- a/system/helpers/smiley_helper.php +++ b/system/helpers/smiley_helper.php @@ -6,7 +6,7 @@ * * @package CodeIgniter * @author ExpressionEngine Dev Team - * @copyright Copyright (c) 2008 - 2010, EllisLab, Inc. + * @copyright Copyright (c) 2008 - 2011, EllisLab, Inc. * @license http://codeigniter.com/user_guide/license.html * @link http://codeigniter.com * @since Version 1.0 @@ -59,7 +59,7 @@ function smiley_js($alias = '', $field_id = '', $inline = TRUE) if (is_array($alias)) { - foreach($alias as $name => $id) + foreach ($alias as $name => $id) { $m[] = '"'.$name.'" : "'.$id.'"'; } @@ -101,7 +101,7 @@ function insert_smiley(smiley, field_id) { { if (is_array($alias)) { - foreach($alias as $name => $id) + foreach ($alias as $name => $id) { $r .= 'smiley_map["'.$name.'"] = "'.$id.'";'."\n"; } @@ -229,19 +229,21 @@ function parse_smileys($str = '', $image_url = '', $smileys = NULL) { function _get_smiley_array() { - if ( ! file_exists(APPPATH.'config/smileys'.EXT)) + if (defined('ENVIRONMENT') AND file_exists(APPPATH.'config/'.ENVIRONMENT.'/smileys.php')) { - return FALSE; + include(APPPATH.'config/'.ENVIRONMENT.'/smileys.php'); } - - include(APPPATH.'config/smileys'.EXT); - - if ( ! isset($smileys) OR ! is_array($smileys)) + elseif (file_exists(APPPATH.'config/smileys.php')) + { + include(APPPATH.'config/smileys.php'); + } + + if (isset($smileys) AND is_array($smileys)) { - return FALSE; + return $smileys; } - return $smileys; + return FALSE; } } diff --git a/system/helpers/string_helper.php b/system/helpers/string_helper.php index b0f0b8d8..7765bba3 100644 --- a/system/helpers/string_helper.php +++ b/system/helpers/string_helper.php @@ -6,7 +6,7 @@ * * @package CodeIgniter * @author ExpressionEngine Dev Team - * @copyright Copyright (c) 2008 - 2010, EllisLab, Inc. + * @copyright Copyright (c) 2008 - 2011, EllisLab, Inc. * @license http://codeigniter.com/user_guide/license.html * @link http://codeigniter.com * @since Version 1.0 diff --git a/system/helpers/text_helper.php b/system/helpers/text_helper.php index 9194b577..33d7fa2f 100644 --- a/system/helpers/text_helper.php +++ b/system/helpers/text_helper.php @@ -6,7 +6,7 @@ * * @package CodeIgniter * @author ExpressionEngine Dev Team - * @copyright Copyright (c) 2008 - 2010, EllisLab, Inc. + * @copyright Copyright (c) 2008 - 2011, EllisLab, Inc. * @license http://codeigniter.com/user_guide/license.html * @link http://codeigniter.com * @since Version 1.0 @@ -366,12 +366,14 @@ function highlight_phrase($str, $phrase, $tag_open = '', $tag_close = '< { function convert_accented_characters($str) { - if ( ! file_exists(APPPATH.'config/foreign_chars'.EXT)) + if (defined('ENVIRONMENT') AND is_file(APPPATH.'config/'.ENVIRONMENT.'/foreign_chars.php')) { - return $str; + include(APPPATH.'config/'.ENVIRONMENT.'/foreign_chars.php'); + } + elseif (is_file(APPPATH.'config/foreign_chars.php')) + { + include(APPPATH.'config/foreign_chars.php'); } - - include APPPATH.'config/foreign_chars'.EXT; if ( ! isset($foreign_characters)) { @@ -443,7 +445,7 @@ function word_wrap($str, $charlim = '76') } $temp = ''; - while((strlen($line)) > $charlim) + while ((strlen($line)) > $charlim) { // If the over-length word is a URL we won't wrap it if (preg_match("!\[url.+\]|://|wwww.!", $line)) diff --git a/system/helpers/typography_helper.php b/system/helpers/typography_helper.php index 222c8fc1..19b4eec0 100644 --- a/system/helpers/typography_helper.php +++ b/system/helpers/typography_helper.php @@ -6,7 +6,7 @@ * * @package CodeIgniter * @author ExpressionEngine Dev Team - * @copyright Copyright (c) 2008 - 2010, EllisLab, Inc. + * @copyright Copyright (c) 2008 - 2011, EllisLab, Inc. * @license http://codeigniter.com/user_guide/license.html * @link http://codeigniter.com * @since Version 1.0 @@ -84,9 +84,8 @@ function auto_typography($str, $strip_js_event_handlers = TRUE, $reduce_linebrea { function entity_decode($str, $charset='UTF-8') { - $CI =& get_instance(); - $CI->load->library('security'); - return $CI->security->entity_decode($str, $charset); + global $SEC; + return $SEC->entity_decode($str, $charset); } } diff --git a/system/helpers/url_helper.php b/system/helpers/url_helper.php index 53bcad56..d0516cee 100644 --- a/system/helpers/url_helper.php +++ b/system/helpers/url_helper.php @@ -6,7 +6,7 @@ * * @package CodeIgniter * @author ExpressionEngine Dev Team - * @copyright Copyright (c) 2008 - 2010, EllisLab, Inc. + * @copyright Copyright (c) 2008 - 2011, EllisLab, Inc. * @license http://codeigniter.com/user_guide/license.html * @link http://codeigniter.com * @since Version 1.0 diff --git a/system/helpers/xml_helper.php b/system/helpers/xml_helper.php index e00cc9aa..cdd81ad7 100644 --- a/system/helpers/xml_helper.php +++ b/system/helpers/xml_helper.php @@ -6,7 +6,7 @@ * * @package CodeIgniter * @author ExpressionEngine Dev Team - * @copyright Copyright (c) 2008 - 2010, EllisLab, Inc. + * @copyright Copyright (c) 2008 - 2011, EllisLab, Inc. * @license http://codeigniter.com/user_guide/license.html * @link http://codeigniter.com * @since Version 1.0 diff --git a/system/language/english/form_validation_lang.php b/system/language/english/form_validation_lang.php index b0188509..5da09e16 100644 --- a/system/language/english/form_validation_lang.php +++ b/system/language/english/form_validation_lang.php @@ -17,8 +17,13 @@ $lang['integer'] = "The %s field must contain an integer."; $lang['regex_match'] = "The %s field is not in the correct format."; $lang['matches'] = "The %s field does not match the %s field."; +$lang['is_unique'] = "The %s field must contain a unique value."; $lang['is_natural'] = "The %s field must contain only positive numbers."; $lang['is_natural_no_zero'] = "The %s field must contain a number greater than zero."; +$lang['decimal'] = "The %s field must contain a decimal number."; +$lang['less_than'] = "The %s field must contain a number less than %s."; +$lang['greater_than'] = "The %s field must contain a number greater than %s."; +$lang['valid_date'] = "The %s field must contain a valid date, correctly formatted."; /* End of file form_validation_lang.php */ diff --git a/system/language/english/ftp_lang.php b/system/language/english/ftp_lang.php index 392b2b27..1e5168cf 100644 --- a/system/language/english/ftp_lang.php +++ b/system/language/english/ftp_lang.php @@ -1,17 +1,17 @@ $time + $ttl, diff --git a/system/libraries/Cache/drivers/Cache_dummy.php b/system/libraries/Cache/drivers/Cache_dummy.php index 13c1f5cd..77ea539f 100644 --- a/system/libraries/Cache/drivers/Cache_dummy.php +++ b/system/libraries/Cache/drivers/Cache_dummy.php @@ -6,33 +6,33 @@ * * @package CodeIgniter * @author ExpressionEngine Dev Team - * @copyright Copyright (c) 2006 - 2010 EllisLab, Inc. + * @copyright Copyright (c) 2006 - 2011 EllisLab, Inc. * @license http://codeigniter.com/user_guide/license.html * @link http://codeigniter.com * @since Version 2.0 - * @filesource + * @filesource */ // ------------------------------------------------------------------------ /** - * CodeIgniter Dummy Caching Class + * CodeIgniter Dummy Caching Class * * @package CodeIgniter * @subpackage Libraries * @category Core * @author ExpressionEngine Dev Team - * @link + * @link */ -class Cache_dummy extends CI_Driver { +class CI_Cache_dummy extends CI_Driver { /** - * Get + * Get * * Since this is the dummy class, it's always going to return FALSE. * - * @param string + * @param string * @return Boolean FALSE */ public function get($id) @@ -40,8 +40,8 @@ public function get($id) return FALSE; } - // ------------------------------------------------------------------------ - + // ------------------------------------------------------------------------ + /** * Cache Save * @@ -55,7 +55,7 @@ public function save($id, $data, $ttl = 60) { return TRUE; } - + // ------------------------------------------------------------------------ /** @@ -112,7 +112,7 @@ public function get_metadata($id) /** * Is this caching driver supported on the system? * Of course this one is. - * + * * @return TRUE; */ public function is_supported() @@ -121,9 +121,9 @@ public function is_supported() } // ------------------------------------------------------------------------ - + } // End Class -/* End of file Cache_apc.php */ -/* Location: ./system/libraries/Cache/drivers/Cache_apc.php */ \ No newline at end of file +/* End of file Cache_dummy.php */ +/* Location: ./system/libraries/Cache/drivers/Cache_dummy.php */ diff --git a/system/libraries/Cache/drivers/Cache_file.php b/system/libraries/Cache/drivers/Cache_file.php index bedbfaff..13e2d1af 100644 --- a/system/libraries/Cache/drivers/Cache_file.php +++ b/system/libraries/Cache/drivers/Cache_file.php @@ -6,7 +6,7 @@ * * @package CodeIgniter * @author ExpressionEngine Dev Team - * @copyright Copyright (c) 2006 - 2010 EllisLab, Inc. + * @copyright Copyright (c) 2006 - 2011 EllisLab, Inc. * @license http://codeigniter.com/user_guide/license.html * @link http://codeigniter.com * @since Version 2.0 @@ -25,7 +25,7 @@ * @link */ -class Cache_file extends CI_Driver { +class CI_Cache_file extends CI_Driver { protected $_cache_path; @@ -39,7 +39,7 @@ public function __construct() $path = $CI->config->item('cache_path'); - $this->_cache_path = ($path == '') ? BASEPATH.'cache/' : $path; + $this->_cache_path = ($path == '') ? APPPATH.'cache/' : $path; } // ------------------------------------------------------------------------ diff --git a/system/libraries/Cache/drivers/Cache_memcached.php b/system/libraries/Cache/drivers/Cache_memcached.php index adc7fbf4..ec2fd216 100644 --- a/system/libraries/Cache/drivers/Cache_memcached.php +++ b/system/libraries/Cache/drivers/Cache_memcached.php @@ -6,7 +6,7 @@ * * @package CodeIgniter * @author ExpressionEngine Dev Team - * @copyright Copyright (c) 2006 - 2010 EllisLab, Inc. + * @copyright Copyright (c) 2006 - 2011 EllisLab, Inc. * @license http://codeigniter.com/user_guide/license.html * @link http://codeigniter.com * @since Version 2.0 @@ -25,7 +25,7 @@ * @link */ -class Cache_memcached extends CI_Driver { +class CI_Cache_memcached extends CI_Driver { private $_memcached; // Holds the memcached object @@ -122,7 +122,7 @@ public function get_metadata($id) return FALSE; } - list($value, $time, $ttl) = $stored; + list($data, $time, $ttl) = $stored; return array( 'expire' => $time + $ttl, diff --git a/system/libraries/Cache/drivers/Cache_redis.php b/system/libraries/Cache/drivers/Cache_redis.php new file mode 100644 index 00000000..9eb7a8d4 --- /dev/null +++ b/system/libraries/Cache/drivers/Cache_redis.php @@ -0,0 +1,217 @@ + + * @link + */ +class CI_Cache_redis extends CI_Driver +{ + + /** + * Default config + * + * @access private + * @static + * @var array + */ + private static $_default_config = array( + 'host' => '127.0.0.1', + 'port' => 6379, + 'timeout' => 0 + ); + + /** + * Redis connection + * + * @access private + * @var Redis + */ + private $_redis; + + /** + * Class destructor + * + * Closes the connection to Redis if present. + * + * @access public + * @return void + */ + public function __destruct() + { + if ($this->_redis) + { + $this->_redis->close(); + } + } + + /** + * Get cache + * + * @access public + * @param string $key Cache key identifier + * @return mixed + */ + public function get($key) + { + return $this->_redis->get($key); + } + + /** + * Save cache + * + * @access public + * @param string $key Cache key identifier + * @param mixed $value Data to save + * @param integer $ttl Time to live + * @return boolean + */ + public function save($key, $value, $ttl = NULL) + { + return ($ttl) + ? $this->_redis->setex($key, $ttl, $value) + : $this->_redis->set($key, $value); + } + + /** + * Delete from cache + * + * @access public + * @param string $key Cache key + * @return boolean + */ + public function delete($key) + { + return ($this->_redis->delete($key) === 1); + } + + /** + * Clean cache + * + * @access public + * @return boolean + * @see Redis::flushDB() + */ + public function clean() + { + return $this->_redis->flushDB(); + } + + /** + * Get cache driver info + * + * @access public + * @param string $type Not supported in Redis. Only included in order to offer a + * consistent cache API. + * @return array + * @see Redis::info() + */ + public function cache_info($type = NULL) + { + return $this->_redis->info(); + } + + /** + * Get cache metadata + * + * @access public + * @param string $key Cache key + * @return array + */ + public function get_metadata($key) + { + $value = $this->get($key); + + if ($value) + { + return array( + 'expire' => time() + $this->_redis->ttl($key), + 'data' => $value + ); + } + } + + /** + * Check if Redis driver is supported + * + * @access public + * @return boolean + */ + public function is_supported() + { + if (extension_loaded('redis')) + { + $this->_setup_redis(); + + return TRUE; + } + else + { + log_message( + 'error', + 'The Redis extension must be loaded to use Redis cache.' + ); + + return FALSE; + } + + } + + /** + * Setup Redis config and connection + * + * Loads Redis config file if present. Will halt execution if a Redis connection + * can't be established. + * + * @access private + * @return void + * @see Redis::connect() + */ + private function _setup_redis() + { + $config = array(); + $CI =& get_instance(); + + if ($CI->config->load('redis', TRUE, TRUE)) + { + $config += $CI->config->item('redis'); + } + + $config = array_merge(self::$_default_config, $config); + + $this->_redis = new Redis(); + + try + { + $this->_redis->connect($config['host'], $config['port'], $config['timeout']); + } + catch (RedisException $e) + { + show_error('Redis connection refused. ' . $e->getMessage()); + } + } + +} +// End Class + +/* End of file Cache_redis.php */ +/* Location: ./system/libraries/Cache/drivers/Cache_redis.php */ \ No newline at end of file diff --git a/system/libraries/Calendar.php b/system/libraries/Calendar.php index 59025cf5..df0fd6ee 100644 --- a/system/libraries/Calendar.php +++ b/system/libraries/Calendar.php @@ -6,7 +6,7 @@ * * @package CodeIgniter * @author ExpressionEngine Dev Team - * @copyright Copyright (c) 2008 - 2010, EllisLab, Inc. + * @copyright Copyright (c) 2008 - 2011, EllisLab, Inc. * @license http://codeigniter.com/user_guide/license.html * @link http://codeigniter.com * @since Version 1.0 @@ -47,7 +47,7 @@ public function __construct($config = array()) { $this->CI =& get_instance(); - if ( ! in_array('calendar_lang'.EXT, $this->CI->lang->is_loaded, TRUE)) + if ( ! in_array('calendar_lang.php', $this->CI->lang->is_loaded, TRUE)) { $this->CI->lang->load('calendar'); } diff --git a/system/libraries/Cart.php b/system/libraries/Cart.php index 5d3f91d4..ab5a70c9 100644 --- a/system/libraries/Cart.php +++ b/system/libraries/Cart.php @@ -6,7 +6,7 @@ * * @package CodeIgniter * @author ExpressionEngine Dev Team - * @copyright Copyright (c) 2006 - 2010, EllisLab, Inc. + * @copyright Copyright (c) 2006 - 2011, EllisLab, Inc. * @license http://codeigniter.com/user_guide/license.html * @link http://codeigniter.com * @since Version 1.0 @@ -99,7 +99,7 @@ function insert($items = array()) $save_cart = FALSE; if (isset($items['id'])) { - if ($this->_insert($items) == TRUE) + if (($rowid = $this->_insert($items))) { $save_cart = TRUE; } @@ -110,7 +110,7 @@ function insert($items = array()) { if (is_array($val) AND isset($val['id'])) { - if ($this->_insert($val) == TRUE) + if ($this->_insert($val)) { $save_cart = TRUE; } @@ -122,7 +122,7 @@ function insert($items = array()) if ($save_cart == TRUE) { $this->_save_cart(); - return TRUE; + return isset($rowid) ? $rowid : TRUE; } return FALSE; @@ -244,7 +244,7 @@ function _insert($items = array()) } // Woot! - return TRUE; + return $rowid; } // -------------------------------------------------------------------- @@ -374,6 +374,7 @@ function _save_cart() // Lets add up the individual prices and set the cart sub-total $total = 0; + $items = 0; foreach ($this->_cart_contents as $key => $val) { // We make sure the array contains the proper indexes @@ -383,13 +384,14 @@ function _save_cart() } $total += ($val['price'] * $val['qty']); + $items += $val['qty']; // Set the subtotal $this->_cart_contents[$key]['subtotal'] = ($this->_cart_contents[$key]['price'] * $this->_cart_contents[$key]['qty']); } // Set the cart total and total items. - $this->_cart_contents['total_items'] = count($this->_cart_contents); + $this->_cart_contents['total_items'] = $items; $this->_cart_contents['cart_total'] = $total; // Is our cart empty? If so we delete it from the session diff --git a/system/libraries/Driver.php b/system/libraries/Driver.php index 8579a602..c32f2c1e 100644 --- a/system/libraries/Driver.php +++ b/system/libraries/Driver.php @@ -1,4 +1,4 @@ -lib_name)) + if ( ! isset($this->lib_name)) { $this->lib_name = get_class($this); } // The class will be prefixed with the parent lib $child_class = $this->lib_name.'_'.$child; - - if (in_array(strtolower($child_class), array_map('strtolower', $this->valid_drivers))) + + // Remove the CI_ prefix and lowercase + $lib_name = ucfirst(strtolower(str_replace('CI_', '', $this->lib_name))); + $driver_name = strtolower(str_replace('CI_', '', $child_class)); + + if (in_array($driver_name, array_map('strtolower', $this->valid_drivers))) { // check and see if the driver is in a separate file if ( ! class_exists($child_class)) @@ -52,19 +56,15 @@ function __get($child) // check application path first foreach (array(APPPATH, BASEPATH) as $path) { - // and check for case sensitivity of both the parent and child libs - foreach (array(ucfirst($this->lib_name), strtolower($this->lib_name)) as $lib) + // loves me some nesting! + foreach (array(ucfirst($driver_name), $driver_name) as $class) { - // loves me some nesting! - foreach (array(ucfirst($child_class), strtolower($child_class)) as $class) - { - $filepath = $path.'libraries/'.$this->lib_name.'/drivers/'.$child_class.EXT; + $filepath = $path.'libraries/'.$lib_name.'/drivers/'.$class.'.php'; - if (file_exists($filepath)) - { - include_once $filepath; - break; - } + if (file_exists($filepath)) + { + include_once $filepath; + break; } } } @@ -143,7 +143,7 @@ public function decorate($parent) } } - foreach($r->getProperties() as $prop) + foreach ($r->getProperties() as $prop) { if ($prop->isPublic()) { @@ -226,4 +226,4 @@ public function __set($var, $val) // END CI_Driver CLASS /* End of file Driver.php */ -/* Location: ./system/libraries/Driver.php */ \ No newline at end of file +/* Location: ./system/libraries/Driver.php */ diff --git a/system/libraries/Email.php b/system/libraries/Email.php index 132f3db2..9b3bc75e 100644 --- a/system/libraries/Email.php +++ b/system/libraries/Email.php @@ -6,7 +6,7 @@ * * @package CodeIgniter * @author ExpressionEngine Dev Team - * @copyright Copyright (c) 2008 - 2010, EllisLab, Inc. + * @copyright Copyright (c) 2008 - 2011, EllisLab, Inc. * @license http://codeigniter.com/user_guide/license.html * @link http://codeigniter.com * @since Version 1.0 @@ -405,12 +405,12 @@ public function attach($filename, $disposition = 'attachment') /** * Add a Header Item * - * @access private + * @access protected * @param string * @param string * @return void */ - private function _set_header($header, $value) + protected function _set_header($header, $value) { $this->_headers[$header] = $value; } @@ -420,11 +420,11 @@ private function _set_header($header, $value) /** * Convert a String to an Array * - * @access private + * @access protected * @param string * @return array */ - private function _str_to_array($email) + protected function _str_to_array($email) { if ( ! is_array($email)) { @@ -577,10 +577,10 @@ public function set_crlf($crlf = "\n") /** * Set Message Boundary * - * @access private + * @access protected * @return void */ - private function _set_boundaries() + protected function _set_boundaries() { $this->_alt_boundary = "B_ALT_".uniqid(''); // multipart/alternative $this->_atc_boundary = "B_ATC_".uniqid(''); // attachment boundary @@ -591,10 +591,10 @@ private function _set_boundaries() /** * Get the Message ID * - * @access private + * @access protected * @return string */ - private function _get_message_id() + protected function _get_message_id() { $from = $this->_headers['Return-Path']; $from = str_replace(">", "", $from); @@ -608,11 +608,11 @@ private function _get_message_id() /** * Get Mail Protocol * - * @access private + * @access protected * @param bool * @return string */ - private function _get_protocol($return = TRUE) + protected function _get_protocol($return = TRUE) { $this->protocol = strtolower($this->protocol); $this->protocol = ( ! in_array($this->protocol, $this->_protocols, TRUE)) ? 'mail' : $this->protocol; @@ -628,11 +628,11 @@ private function _get_protocol($return = TRUE) /** * Get Mail Encoding * - * @access private + * @access protected * @param bool * @return string */ - private function _get_encoding($return = TRUE) + protected function _get_encoding($return = TRUE) { $this->_encoding = ( ! in_array($this->_encoding, $this->_bit_depths)) ? '8bit' : $this->_encoding; @@ -655,10 +655,10 @@ private function _get_encoding($return = TRUE) /** * Get content type (text/html/attachment) * - * @access private + * @access protected * @return string */ - private function _get_content_type() + protected function _get_content_type() { if ($this->mailtype == 'html' && count($this->_attach_name) == 0) { @@ -683,10 +683,10 @@ private function _get_content_type() /** * Set RFC 822 Date * - * @access private + * @access protected * @return string */ - private function _set_date() + protected function _set_date() { $timezone = date("Z"); $operator = (strncmp($timezone, '-', 1) == 0) ? '-' : '+'; @@ -701,10 +701,10 @@ private function _set_date() /** * Mime message * - * @access private + * @access protected * @return string */ - private function _get_mime_message() + protected function _get_mime_message() { return "This is a multi-part message in MIME format.".$this->newline."Your email application may not support this format."; } @@ -722,7 +722,7 @@ public function validate_email($email) { if ( ! is_array($email)) { - $this->_set_error_message('email_must_be_array'); + $this->_set_error_message('lang:email_must_be_array'); return FALSE; } @@ -730,7 +730,7 @@ public function validate_email($email) { if ( ! $this->valid_email($val)) { - $this->_set_error_message('email_invalid_address', $val); + $this->_set_error_message('lang:email_invalid_address', $val); return FALSE; } } @@ -802,10 +802,10 @@ public function clean_email($email) * If the user hasn't specified his own alternative message * it creates one by stripping the HTML * - * @access private + * @access protected * @return string */ - private function _get_alt_message() + protected function _get_alt_message() { if ($this->alt_message != "") { @@ -897,7 +897,7 @@ public function word_wrap($str, $charlim = '') } $temp = ''; - while((strlen($line)) > $charlim) + while ((strlen($line)) > $charlim) { // If the over-length word is a URL we won't wrap it if (preg_match("!\[url.+\]|://|wwww.!", $line)) @@ -941,11 +941,11 @@ public function word_wrap($str, $charlim = '') /** * Build final headers * - * @access private + * @access protected * @param string * @return string */ - private function _build_headers() + protected function _build_headers() { $this->_set_header('X-Sender', $this->clean_email($this->_headers['From'])); $this->_set_header('X-Mailer', $this->useragent); @@ -959,10 +959,10 @@ private function _build_headers() /** * Write Headers as a string * - * @access private + * @access protected * @return void */ - private function _write_headers() + protected function _write_headers() { if ($this->protocol == 'mail') { @@ -973,7 +973,7 @@ private function _write_headers() reset($this->_headers); $this->_header_str = ""; - foreach($this->_headers as $key => $val) + foreach ($this->_headers as $key => $val) { $val = trim($val); @@ -994,10 +994,10 @@ private function _write_headers() /** * Build Final Body and attachments * - * @access private + * @access protected * @return void */ - private function _build_message() + protected function _build_message() { if ($this->wordwrap === TRUE AND $this->mailtype != 'html') { @@ -1131,7 +1131,7 @@ private function _build_message() if ( ! file_exists($filename)) { - $this->_set_error_message('email_attachment_missing', $filename); + $this->_set_error_message('lang:email_attachment_missing', $filename); return FALSE; } @@ -1146,7 +1146,7 @@ private function _build_message() if ( ! $fp = fopen($filename, FOPEN_READ)) { - $this->_set_error_message('email_attachment_unreadable', $filename); + $this->_set_error_message('lang:email_attachment_unreadable', $filename); return FALSE; } @@ -1177,12 +1177,12 @@ private function _build_message() * Prepares string for Quoted-Printable Content-Transfer-Encoding * Refer to RFC 2045 http://www.ietf.org/rfc/rfc2045.txt * - * @access private + * @access protected * @param string * @param integer * @return string */ - private function _prep_quoted_printable($str, $charlim = '') + protected function _prep_quoted_printable($str, $charlim = '') { // Set the character limit // Don't allow over 76, as that will make servers and MUAs barf @@ -1275,7 +1275,7 @@ private function _prep_quoted_printable($str, $charlim = '') * @param bool // set to TRUE for processing From: headers * @return str */ - private function _prep_q_encoding($str, $from = FALSE) + protected function _prep_q_encoding($str, $from = FALSE) { $str = str_replace(array("\r", "\n"), array('', ''), $str); @@ -1353,7 +1353,7 @@ public function send() ( ! isset($this->_bcc_array) AND ! isset($this->_headers['Bcc'])) AND ( ! isset($this->_headers['Cc']))) { - $this->_set_error_message('email_no_recipients'); + $this->_set_error_message('lang:email_no_recipients'); return FALSE; } @@ -1440,10 +1440,10 @@ public function batch_bcc_send() /** * Unwrap special elements * - * @access private + * @access protected * @return void */ - private function _unwrap_specials() + protected function _unwrap_specials() { $this->_finalbody = preg_replace_callback("/\{unwrap\}(.*?)\{\/unwrap\}/si", array($this, '_remove_nl_callback'), $this->_finalbody); } @@ -1453,10 +1453,10 @@ private function _unwrap_specials() /** * Strip line-breaks via callback * - * @access private + * @access protected * @return string */ - private function _remove_nl_callback($matches) + protected function _remove_nl_callback($matches) { if (strpos($matches[1], "\r") !== FALSE OR strpos($matches[1], "\n") !== FALSE) { @@ -1471,10 +1471,10 @@ private function _remove_nl_callback($matches) /** * Spool mail to the mail server * - * @access private + * @access protected * @return bool */ - private function _spool_email() + protected function _spool_email() { $this->_unwrap_specials(); @@ -1484,7 +1484,7 @@ private function _spool_email() if ( ! $this->_send_with_mail()) { - $this->_set_error_message('email_send_failure_phpmail'); + $this->_set_error_message('lang:email_send_failure_phpmail'); return FALSE; } break; @@ -1492,7 +1492,7 @@ private function _spool_email() if ( ! $this->_send_with_sendmail()) { - $this->_set_error_message('email_send_failure_sendmail'); + $this->_set_error_message('lang:email_send_failure_sendmail'); return FALSE; } break; @@ -1500,14 +1500,14 @@ private function _spool_email() if ( ! $this->_send_with_smtp()) { - $this->_set_error_message('email_send_failure_smtp'); + $this->_set_error_message('lang:email_send_failure_smtp'); return FALSE; } break; } - $this->_set_error_message('email_sent', $this->_get_protocol()); + $this->_set_error_message('lang:email_sent', $this->_get_protocol()); return TRUE; } @@ -1516,10 +1516,10 @@ private function _spool_email() /** * Send using mail() * - * @access private + * @access protected * @return bool */ - private function _send_with_mail() + protected function _send_with_mail() { if ($this->_safe_mode == TRUE) { @@ -1553,10 +1553,10 @@ private function _send_with_mail() /** * Send using Sendmail * - * @access private + * @access protected * @return bool */ - private function _send_with_sendmail() + protected function _send_with_sendmail() { $fp = @popen($this->mailpath . " -oi -f ".$this->clean_email($this->_headers['From'])." -t", 'w'); @@ -1578,8 +1578,8 @@ private function _send_with_sendmail() if ($status != 0) { - $this->_set_error_message('email_exit_status', $status); - $this->_set_error_message('email_no_socket'); + $this->_set_error_message('lang:email_exit_status', $status); + $this->_set_error_message('lang:email_no_socket'); return FALSE; } @@ -1591,14 +1591,14 @@ private function _send_with_sendmail() /** * Send using SMTP * - * @access private + * @access protected * @return bool */ - private function _send_with_smtp() + protected function _send_with_smtp() { if ($this->smtp_host == '') { - $this->_set_error_message('email_no_hostname'); + $this->_set_error_message('lang:email_no_hostname'); return FALSE; } @@ -1607,14 +1607,14 @@ private function _send_with_smtp() $this->_send_command('from', $this->clean_email($this->_headers['From'])); - foreach($this->_recipients as $val) + foreach ($this->_recipients as $val) { $this->_send_command('to', $val); } if (count($this->_cc_array) > 0) { - foreach($this->_cc_array as $val) + foreach ($this->_cc_array as $val) { if ($val != "") { @@ -1625,7 +1625,7 @@ private function _send_with_smtp() if (count($this->_bcc_array) > 0) { - foreach($this->_bcc_array as $val) + foreach ($this->_bcc_array as $val) { if ($val != "") { @@ -1647,7 +1647,7 @@ private function _send_with_smtp() if (strncmp($reply, '250', 3) != 0) { - $this->_set_error_message('email_smtp_error', $reply); + $this->_set_error_message('lang:email_smtp_error', $reply); return FALSE; } @@ -1660,11 +1660,11 @@ private function _send_with_smtp() /** * SMTP Connect * - * @access private + * @access protected * @param string * @return string */ - private function _smtp_connect() + protected function _smtp_connect() { $this->_smtp_connect = fsockopen($this->smtp_host, $this->smtp_port, @@ -1672,9 +1672,9 @@ private function _smtp_connect() $errstr, $this->smtp_timeout); - if( ! is_resource($this->_smtp_connect)) + if ( ! is_resource($this->_smtp_connect)) { - $this->_set_error_message('email_smtp_error', $errno." ".$errstr); + $this->_set_error_message('lang:email_smtp_error', $errno." ".$errstr); return FALSE; } @@ -1687,12 +1687,12 @@ private function _smtp_connect() /** * Send SMTP command * - * @access private + * @access protected * @param string * @param string * @return string */ - private function _send_command($cmd, $data = '') + protected function _send_command($cmd, $data = '') { switch ($cmd) { @@ -1737,7 +1737,7 @@ private function _send_command($cmd, $data = '') if (substr($reply, 0, 3) != $resp) { - $this->_set_error_message('email_smtp_error', $reply); + $this->_set_error_message('lang:email_smtp_error', $reply); return FALSE; } @@ -1754,10 +1754,10 @@ private function _send_command($cmd, $data = '') /** * SMTP Authenticate * - * @access private + * @access protected * @return bool */ - private function _smtp_authenticate() + protected function _smtp_authenticate() { if ( ! $this->_smtp_auth) { @@ -1766,7 +1766,7 @@ private function _smtp_authenticate() if ($this->smtp_user == "" AND $this->smtp_pass == "") { - $this->_set_error_message('email_no_smtp_unpw'); + $this->_set_error_message('lang:email_no_smtp_unpw'); return FALSE; } @@ -1776,7 +1776,7 @@ private function _smtp_authenticate() if (strncmp($reply, '334', 3) != 0) { - $this->_set_error_message('email_failed_smtp_login', $reply); + $this->_set_error_message('lang:email_failed_smtp_login', $reply); return FALSE; } @@ -1786,7 +1786,7 @@ private function _smtp_authenticate() if (strncmp($reply, '334', 3) != 0) { - $this->_set_error_message('email_smtp_auth_un', $reply); + $this->_set_error_message('lang:email_smtp_auth_un', $reply); return FALSE; } @@ -1796,7 +1796,7 @@ private function _smtp_authenticate() if (strncmp($reply, '235', 3) != 0) { - $this->_set_error_message('email_smtp_auth_pw', $reply); + $this->_set_error_message('lang:email_smtp_auth_pw', $reply); return FALSE; } @@ -1808,14 +1808,14 @@ private function _smtp_authenticate() /** * Send SMTP data * - * @access private + * @access protected * @return bool */ - private function _send_data($data) + protected function _send_data($data) { if ( ! fwrite($this->_smtp_connect, $data . $this->newline)) { - $this->_set_error_message('email_smtp_data_failure', $data); + $this->_set_error_message('lang:email_smtp_data_failure', $data); return FALSE; } else @@ -1829,10 +1829,10 @@ private function _send_data($data) /** * Get SMTP data * - * @access private + * @access protected * @return string */ - private function _get_smtp_data() + protected function _get_smtp_data() { $data = ""; @@ -1854,10 +1854,10 @@ private function _get_smtp_data() /** * Get Hostname * - * @access private + * @access protected * @return string */ - private function _get_hostname() + protected function _get_hostname() { return (isset($_SERVER['SERVER_NAME'])) ? $_SERVER['SERVER_NAME'] : 'localhost.localdomain'; } @@ -1867,10 +1867,10 @@ private function _get_hostname() /** * Get IP * - * @access private + * @access protected * @return string */ - private function _get_ip() + protected function _get_ip() { if ($this->_IP !== FALSE) { @@ -1933,16 +1933,16 @@ public function print_debugger() /** * Set Message * - * @access private + * @access protected * @param string * @return string */ - private function _set_error_message($msg, $val = '') + protected function _set_error_message($msg, $val = '') { $CI =& get_instance(); $CI->lang->load('email'); - if (FALSE === ($line = $CI->lang->line($msg))) + if (substr($msg, 0, 5) != 'lang:' || FALSE === ($line = $CI->lang->line(substr($msg, 5)))) { $this->_debug_msg[] = str_replace('%s', $val, $msg)."
"; } @@ -1957,11 +1957,11 @@ private function _set_error_message($msg, $val = '') /** * Mime Types * - * @access private + * @access protected * @param string * @return string */ - private function _mime_types($ext = "") + protected function _mime_types($ext = "") { $mimes = array( 'hqx' => 'application/mac-binhex40', 'cpt' => 'application/mac-compactpro', @@ -2059,4 +2059,4 @@ private function _mime_types($ext = "") // END CI_Email class /* End of file Email.php */ -/* Location: ./system/libraries/Email.php */ \ No newline at end of file +/* Location: ./system/libraries/Email.php */ diff --git a/system/libraries/Encrypt.php b/system/libraries/Encrypt.php index 7682f21e..b30a8cf0 100644 --- a/system/libraries/Encrypt.php +++ b/system/libraries/Encrypt.php @@ -6,7 +6,7 @@ * * @package CodeIgniter * @author ExpressionEngine Dev Team - * @copyright Copyright (c) 2008 - 2010, EllisLab, Inc. + * @copyright Copyright (c) 2008 - 2011, EllisLab, Inc. * @license http://codeigniter.com/user_guide/license.html * @link http://codeigniter.com * @since Version 1.0 @@ -524,7 +524,7 @@ function sha1($str) { if ( ! function_exists('mhash')) { - require_once(BASEPATH.'libraries/Sha1'.EXT); + require_once(BASEPATH.'libraries/Sha1.php'); $SH = new CI_SHA; return $SH->generate($str); } diff --git a/system/libraries/Form_validation.php b/system/libraries/Form_validation.php index f4576002..f6987a1b 100644 --- a/system/libraries/Form_validation.php +++ b/system/libraries/Form_validation.php @@ -6,7 +6,7 @@ * * @package CodeIgniter * @author ExpressionEngine Dev Team - * @copyright Copyright (c) 2008 - 2010, EllisLab, Inc. + * @copyright Copyright (c) 2008 - 2011, EllisLab, Inc. * @license http://codeigniter.com/user_guide/license.html * @link http://codeigniter.com * @since Version 1.0 @@ -26,16 +26,15 @@ */ class CI_Form_validation { - var $CI; - var $_field_data = array(); - var $_config_rules = array(); - var $_error_array = array(); - var $_error_messages = array(); - var $_error_prefix = '

'; - 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 @@ public function __construct($rules = array()) * @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) @@ -138,14 +137,14 @@ function set_rules($field, $label = '', $rules = '') // Build our master array $this->_field_data[$field] = array( - 'field' => $field, - 'label' => $label, - 'rules' => $rules, - 'is_array' => $is_array, - 'keys' => $indexes, - 'postdata' => NULL, - 'error' => '' - ); + 'field' => $field, + 'label' => $label, + 'rules' => $rules, + 'is_array' => $is_array, + 'keys' => $indexes, + 'postdata' => NULL, + 'error' => '' + ); return $this; } @@ -163,15 +162,24 @@ function set_rules($field, $label = '', $rules = '') * @param string * @return string */ - function set_message($lang, $val = '') + public function set_message($lang, $val = '') { if ( ! is_array($lang)) { $lang = array($lang => $val); } + else + { + $new_lang = array(); + foreach($lang as $l) + { + $new_lang[$l['rule']] = $l['message']; + } + $lang = $new_lang; + } $this->_error_messages = array_merge($this->_error_messages, $lang); - + return $this; } @@ -187,11 +195,11 @@ function set_message($lang, $val = '') * @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; - + return $this; } @@ -206,7 +214,7 @@ function set_error_delimiters($prefix = '

', $suffix = '

') * @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 +246,7 @@ function error($field = '', $prefix = '', $suffix = '') * @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 +287,7 @@ function error_string($prefix = '', $suffix = '') * @access public * @return bool */ - function run($group = '') + public function run($group = '') { // Do we even have any data to process? Mm? if (count($_POST) == 0) @@ -339,13 +347,7 @@ function run($group = '') } } - preg_match_all('/([a-zA-Z_-]*(\[.*\])?)\|?/i', $row['rules'], $matches); - - $rules = $matches[1]; - array_pop($rules); - unset($matches); - - $this->_execute($row, $rules, $this->_field_data[$field]['postdata']); + $this->_execute($row, explode('|', $row['rules']), $this->_field_data[$field]['postdata']); } // Did we end up with any errors? @@ -380,7 +382,7 @@ function run($group = '') * @param integer * @return mixed */ - function _reduce_array($array, $keys, $i = 0) + protected function _reduce_array($array, $keys, $i = 0) { if (is_array($array)) { @@ -412,7 +414,7 @@ function _reduce_array($array, $keys, $i = 0) * @access private * @return null */ - function _reset_post_array() + protected function _reset_post_array() { foreach ($this->_field_data as $field => $row) { @@ -474,7 +476,7 @@ function _reset_post_array() * @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)) @@ -495,7 +497,7 @@ function _execute($row, $rules, $postdata = NULL, $cycles = 0) 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])); @@ -634,6 +636,10 @@ function _execute($row, $rules, $postdata = NULL, $cycles = 0) $this->_field_data[$row['field']]['postdata'] = (is_bool($result)) ? $postdata : $result; } } + else + { + log_message('debug', "Unable to find validation rule: ".$rule); + } continue; } @@ -697,7 +703,7 @@ function _execute($row, $rules, $postdata = NULL, $cycles = 0) * @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 @@ -729,7 +735,7 @@ function _translate_fieldname($fieldname) * @param string * @return void */ - function set_value($field = '', $default = '') + public function set_value($field = '', $default = '') { if ( ! isset($this->_field_data[$field])) { @@ -742,7 +748,7 @@ function set_value($field = '', $default = '') { return array_shift($this->_field_data[$field]['postdata']); } - + return $this->_field_data[$field]['postdata']; } @@ -759,7 +765,7 @@ function set_value($field = '', $default = '') * @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'])) { @@ -803,7 +809,7 @@ function set_select($field = '', $value = '', $default = FALSE) * @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'])) { @@ -847,7 +853,7 @@ function set_radio($field = '', $value = '', $default = FALSE) * @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'])) { @@ -887,7 +893,7 @@ function set_checkbox($field = '', $value = '', $default = FALSE) * @param string * @return bool */ - function required($str) + public function required($str) { if ( ! is_array($str)) { @@ -909,7 +915,7 @@ function required($str) * @param regex * @return bool */ - function regex_match($str, $regex) + public function regex_match($str, $regex) { if ( ! preg_match($regex, $str)) { @@ -929,7 +935,7 @@ function regex_match($str, $regex) * @param field * @return bool */ - function matches($str, $field) + public function matches($str, $field) { if ( ! isset($_POST[$field])) { @@ -940,6 +946,24 @@ function matches($str, $field) 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; + } // -------------------------------------------------------------------- @@ -951,7 +975,7 @@ function matches($str, $field) * @param value * @return bool */ - function min_length($str, $val) + public function min_length($str, $val) { if (preg_match("/[^0-9]/", $val)) { @@ -976,7 +1000,7 @@ function min_length($str, $val) * @param value * @return bool */ - function max_length($str, $val) + public function max_length($str, $val) { if (preg_match("/[^0-9]/", $val)) { @@ -1001,7 +1025,7 @@ function max_length($str, $val) * @param value * @return bool */ - function exact_length($str, $val) + public function exact_length($str, $val) { if (preg_match("/[^0-9]/", $val)) { @@ -1025,7 +1049,7 @@ function exact_length($str, $val) * @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; } @@ -1039,14 +1063,14 @@ function valid_email($str) * @param string * @return bool */ - function valid_emails($str) + public function valid_emails($str) { if (strpos($str, ',') === FALSE) { return $this->valid_email(trim($str)); } - foreach(explode(',', $str) as $email) + foreach (explode(',', $str) as $email) { if (trim($email) != '' && $this->valid_email(trim($email)) === FALSE) { @@ -1066,7 +1090,7 @@ function valid_emails($str) * @param string * @return string */ - function valid_ip($ip) + public function valid_ip($ip) { return $this->CI->input->valid_ip($ip); } @@ -1080,7 +1104,7 @@ function valid_ip($ip) * @param string * @return bool */ - function alpha($str) + public function alpha($str) { return ( ! preg_match("/^([a-z])+$/i", $str)) ? FALSE : TRUE; } @@ -1094,7 +1118,7 @@ function alpha($str) * @param string * @return bool */ - function alpha_numeric($str) + public function alpha_numeric($str) { return ( ! preg_match("/^([a-z0-9])+$/i", $str)) ? FALSE : TRUE; } @@ -1108,7 +1132,7 @@ function alpha_numeric($str) * @param string * @return bool */ - function alpha_dash($str) + public function alpha_dash($str) { return ( ! preg_match("/^([-a-z0-9_-])+$/i", $str)) ? FALSE : TRUE; } @@ -1122,7 +1146,7 @@ function alpha_dash($str) * @param string * @return bool */ - function numeric($str) + public function numeric($str) { return (bool)preg_match( '/^[\-+]?[0-9]*\.?[0-9]+$/', $str); @@ -1137,7 +1161,7 @@ function numeric($str) * @param string * @return bool */ - function is_numeric($str) + public function is_numeric($str) { return ( ! is_numeric($str)) ? FALSE : TRUE; } @@ -1151,9 +1175,59 @@ function is_numeric($str) * @param string * @return bool */ - function integer($str) + public function integer($str) + { + return (bool) preg_match('/^[\-+]?[0-9]+$/', $str); + } + + // -------------------------------------------------------------------- + + /** + * Decimal number + * + * @access public + * @param string + * @return bool + */ + public function decimal($str) + { + return (bool) preg_match('/^[\-+]?[0-9]+\.[0-9]+$/', $str); + } + + // -------------------------------------------------------------------- + + /** + * Greather than + * + * @access public + * @param string + * @return bool + */ + public function greater_than($str, $min) { - return (bool)preg_match( '/^[\-+]?[0-9]+$/', $str); + if ( ! is_numeric($str)) + { + return FALSE; + } + return $str > $min; + } + + // -------------------------------------------------------------------- + + /** + * Less than + * + * @access public + * @param string + * @return bool + */ + public function less_than($str, $max) + { + if ( ! is_numeric($str)) + { + return FALSE; + } + return $str < $max; } // -------------------------------------------------------------------- @@ -1165,9 +1239,9 @@ function integer($str) * @param string * @return bool */ - function is_natural($str) + public function is_natural($str) { - return (bool)preg_match( '/^[0-9]+$/', $str); + return (bool) preg_match( '/^[0-9]+$/', $str); } // -------------------------------------------------------------------- @@ -1179,7 +1253,7 @@ function is_natural($str) * @param string * @return bool */ - function is_natural_no_zero($str) + public function is_natural_no_zero($str) { if ( ! preg_match( '/^[0-9]+$/', $str)) { @@ -1206,7 +1280,7 @@ function is_natural_no_zero($str) * @param string * @return bool */ - function valid_base64($str) + public function valid_base64($str) { return (bool) ! preg_match('/[^a-zA-Z0-9\/\+=]/', $str); } @@ -1223,7 +1297,7 @@ function valid_base64($str) * @param string * @return string */ - function prep_for_form($data = '') + public function prep_for_form($data = '') { if (is_array($data)) { @@ -1252,7 +1326,7 @@ function prep_for_form($data = '') * @param string * @return string */ - function prep_url($str = '') + public function prep_url($str = '') { if ($str == 'http://' OR $str == '') { @@ -1276,7 +1350,7 @@ function prep_url($str = '') * @param string * @return string */ - function strip_image_tags($str) + public function strip_image_tags($str) { return $this->CI->input->strip_image_tags($str); } @@ -1290,13 +1364,8 @@ function strip_image_tags($str) * @param string * @return string */ - function xss_clean($str) + public function xss_clean($str) { - if ( ! isset($this->CI->security)) - { - $this->CI->load->library('security'); - } - return $this->CI->security->xss_clean($str); } @@ -1309,10 +1378,60 @@ function xss_clean($str) * @param string * @return string */ - function encode_php_tags($str) + public function encode_php_tags($str) { return str_replace(array(''), array('<?php', '<?PHP', '<?', '?>'), $str); } + + + // -------------------------------------------------------------------- + + /** + * Check date format and validity + * + * @access public + * @param string (date) + * @param string (format) + * @return string + * @author jondavidjohn + */ + function valid_date($str, $format = 'y-m-d') + { + $search = array( + '/[yY]/', + '/[mM]/', + '/[dD]/', + ); + + $replace = array( + '(?P[0-9]{4})', + '(?P[0-9]{1,2})', + '(?P[0-9]{1,2})', + ); + + $pattern = preg_replace($search, $replace, $format); + $pattern = str_replace('/','\/',$pattern); + + if (preg_match('/^' . $pattern . '$/', $str, $match)) + { + $year = $match['year']; + $month = $match['month']; + $day = $match['day']; + + if (checkdate($month,$day,$year)) + { + return TRUE; + } + else + { + return FALSE; + } + } + else + { + return FALSE; + } + } } // END Form Validation Class diff --git a/system/libraries/Ftp.php b/system/libraries/Ftp.php index 6ffbef17..d7a8b3b0 100644 --- a/system/libraries/Ftp.php +++ b/system/libraries/Ftp.php @@ -6,7 +6,7 @@ * * @package CodeIgniter * @author ExpressionEngine Dev Team - * @copyright Copyright (c) 2008 - 2010, EllisLab, Inc. + * @copyright Copyright (c) 2008 - 2011, EllisLab, Inc. * @license http://codeigniter.com/user_guide/license.html * @link http://codeigniter.com * @since Version 1.0 diff --git a/system/libraries/Image_lib.php b/system/libraries/Image_lib.php index 84c41c4e..8902f524 100644 --- a/system/libraries/Image_lib.php +++ b/system/libraries/Image_lib.php @@ -6,7 +6,7 @@ * * @package CodeIgniter * @author ExpressionEngine Dev Team - * @copyright Copyright (c) 2008 - 2010, EllisLab, Inc. + * @copyright Copyright (c) 2008 - 2011, EllisLab, Inc. * @license http://codeigniter.com/user_guide/license.html * @link http://codeigniter.com * @since Version 1.0 @@ -749,7 +749,7 @@ function image_rotate_gd() @chmod($this->full_dst_path, FILE_WRITE_MODE); - return true; + return TRUE; } // -------------------------------------------------------------------- diff --git a/system/libraries/Javascript.php b/system/libraries/Javascript.php index 6fe365f0..34e0d700 100644 --- a/system/libraries/Javascript.php +++ b/system/libraries/Javascript.php @@ -6,7 +6,7 @@ * * @package CodeIgniter * @author ExpressionEngine Dev Team - * @copyright Copyright (c) 2008 - 2010, EllisLab, Inc. + * @copyright Copyright (c) 2008 - 2011, EllisLab, Inc. * @license http://codeigniter.com/user_guide/license.html * @link http://codeigniter.com * @since Version 1.0 @@ -855,7 +855,7 @@ function _prep_args($result, $is_key = FALSE) } elseif (is_string($result) OR $is_key) { - return '"'.str_replace(array('\\', "\t", "\n", "\r", '"'), array('\\\\', '\\t', '\\n', "\\r", '\"'), $result).'"'; + return '"'.str_replace(array('\\', "\t", "\n", "\r", '"', '/'), array('\\\\', '\\t', '\\n', "\\r", '\"', '\/'), $result).'"'; } elseif (is_scalar($result)) { diff --git a/system/libraries/Log.php b/system/libraries/Log.php index 6d44cfa4..9f1db76b 100644 --- a/system/libraries/Log.php +++ b/system/libraries/Log.php @@ -6,7 +6,7 @@ * * @package CodeIgniter * @author ExpressionEngine Dev Team - * @copyright Copyright (c) 2008 - 2010, EllisLab, Inc. + * @copyright Copyright (c) 2008 - 2011, EllisLab, Inc. * @license http://codeigniter.com/user_guide/license.html * @link http://codeigniter.com * @since Version 1.0 @@ -26,11 +26,11 @@ */ class CI_Log { - var $log_path; - var $_threshold = 1; - var $_date_fmt = 'Y-m-d H:i:s'; - var $_enabled = TRUE; - var $_levels = array('ERROR' => '1', 'DEBUG' => '2', 'INFO' => '3', 'ALL' => '4'); + protected $_log_path; + protected $_threshold = 1; + protected $_date_fmt = 'Y-m-d H:i:s'; + protected $_enabled = TRUE; + protected $_levels = array('ERROR' => '1', 'DEBUG' => '2', 'INFO' => '3', 'ALL' => '4'); /** * Constructor @@ -39,9 +39,9 @@ public function __construct() { $config =& get_config(); - $this->log_path = ($config['log_path'] != '') ? $config['log_path'] : BASEPATH.'logs/'; + $this->_log_path = ($config['log_path'] != '') ? $config['log_path'] : APPPATH.'logs/'; - if ( ! is_dir($this->log_path) OR ! is_really_writable($this->log_path)) + if ( ! is_dir($this->_log_path) OR ! is_really_writable($this->_log_path)) { $this->_enabled = FALSE; } @@ -64,13 +64,12 @@ public function __construct() * * Generally this function will be called using the global log_message() function * - * @access public * @param string the error level * @param string the error message * @param bool whether the error is a native PHP error * @return bool */ - function write_log($level = 'error', $msg, $php_error = FALSE) + public function write_log($level = 'error', $msg, $php_error = FALSE) { if ($this->_enabled === FALSE) { @@ -84,7 +83,7 @@ function write_log($level = 'error', $msg, $php_error = FALSE) return FALSE; } - $filepath = $this->log_path.'log-'.date('Y-m-d').EXT; + $filepath = $this->_log_path.'log-'.date('Y-m-d').'.php'; $message = ''; if ( ! file_exists($filepath)) diff --git a/system/libraries/Migration.php b/system/libraries/Migration.php new file mode 100644 index 00000000..3943ec13 --- /dev/null +++ b/system/libraries/Migration.php @@ -0,0 +1,338 @@ + $val) + { + $this->{'_' . $key} = $val; + } + + log_message('debug', 'Migrations class initialized'); + + // Are they trying to use migrations while it is disabled? + if ($this->_migration_enabled !== TRUE) + { + show_error('Migrations has been loaded but is disabled or set up incorrectly.'); + } + + // If not set, set it + $this->_migration_path == '' OR $this->_migration_path = APPPATH . 'migrations/'; + + // Add trailing slash if not set + $this->_migration_path = rtrim($this->_migration_path, '/').'/'; + + // Load migration language + $this->lang->load('migration'); + + // They'll probably be using dbforge + $this->load->dbforge(); + + // If the migrations table is missing, make it + if ( ! $this->db->table_exists('migrations')) + { + $this->dbforge->add_field(array( + 'version' => array('type' => 'INT', 'constraint' => 3), + )); + + $this->dbforge->create_table('migrations', TRUE); + + $this->db->insert('migrations', array('version' => 0)); + } + } + + // -------------------------------------------------------------------- + + /** + * Migrate to a schema version + * + * Calls each migration step required to get to the schema version of + * choice + * + * @access public + * @param $version integer Target schema version + * @return mixed TRUE if already latest, FALSE if failed, int if upgraded + */ + public function version($target_version) + { + $start = $current_version = $this->_get_version(); + $stop = $target_version; + + if ($target_version > $current_version) + { + // Moving Up + ++$start; + ++$stop; + $step = 1; + } + + else + { + // Moving Down + $step = -1; + } + + $method = $step === 1 ? 'up' : 'down'; + $migrations = array(); + + // We now prepare to actually DO the migrations + // But first let's make sure that everything is the way it should be + for ($i = $start; $i != $stop; $i += $step) + { + $f = glob(sprintf($this->_migration_path . '%03d_*.php', $i)); + + // Only one migration per step is permitted + if (count($f) > 1) + { + $this->_error_string = sprintf($this->lang->line('migration_multiple_version'), $i); + return FALSE; + } + + // Migration step not found + if (count($f) == 0) + { + // If trying to migrate up to a version greater than the last + // existing one, migrate to the last one. + if ($step == 1) + { + break; + } + + // If trying to migrate down but we're missing a step, + // something must definitely be wrong. + $this->_error_string = sprintf($this->lang->line('migration_not_found'), $i); + return FALSE; + } + + $file = basename($f[0]); + $name = basename($f[0], '.php'); + + // Filename validations + if (preg_match('/^\d{3}_(\w+)$/', $name, $match)) + { + $match[1] = strtolower($match[1]); + + // Cannot repeat a migration at different steps + if (in_array($match[1], $migrations)) + { + $this->_error_string = sprintf($this->lang->line('migration_multiple_version'), $match[1]); + return FALSE; + } + + include $f[0]; + $class = 'Migration_' . ucfirst($match[1]); + + if ( ! class_exists($class)) + { + $this->_error_string = sprintf($this->lang->line('migration_class_doesnt_exist'), $class); + return FALSE; + } + + if ( ! is_callable(array($class, $method))) + { + $this->_error_string = sprintf($this->lang->line('migration_missing_'.$method.'_method'), $class); + return FALSE; + } + + $migrations[] = $match[1]; + } + else + { + $this->_error_string = sprintf($this->lang->line('migration_invalid_filename'), $file); + return FALSE; + } + } + + log_message('debug', 'Current migration: ' . $current_version); + + $version = $i + ($step == 1 ? -1 : 0); + + // If there is nothing to do so quit + if ($migrations === array()) + { + return TRUE; + } + + log_message('debug', 'Migrating from ' . $method . ' to version ' . $version); + + // Loop through the migrations + foreach ($migrations AS $migration) + { + // Run the migration class + $class = 'Migration_' . ucfirst(strtolower($migration)); + call_user_func(array(new $class, $method)); + + $current_version += $step; + $this->_update_version($current_version); + } + + log_message('debug', 'Finished migrating to '.$current_version); + + return $current_version; + } + + // -------------------------------------------------------------------- + + /** + * Set's the schema to the latest migration + * + * @access public + * @return mixed true if already latest, false if failed, int if upgraded + */ + public function latest() + { + if ( ! $migrations = $this->find_migrations()) + { + $this->_error_string = $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 + return $this->version((int) substr($last_migration, 0, 3)); + } + + // -------------------------------------------------------------------- + + /** + * Set's the schema to the migration version set in config + * + * @access public + * @return mixed true if already current, false if failed, int if upgraded + */ + public function current() + { + return $this->version($this->_migration_version); + } + + // -------------------------------------------------------------------- + + /** + * Error string + * + * @access public + * @return string Error message returned as a string + */ + public function error_string() + { + return $this->_error_string; + } + + // -------------------------------------------------------------------- + + /** + * 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 + $name = basename($files[$i], '.php'); + if ( ! preg_match('/^\d{3}_(\w+)$/', $name)) + { + $files[$i] = FALSE; + } + } + + sort($files); + + return $files; + } + + // -------------------------------------------------------------------- + + /** + * Retrieves current schema version + * + * @access protected + * @return integer Current Migration + */ + protected function _get_version() + { + $row = $this->db->get('migrations')->row(); + return $row ? $row->version : 0; + } + + // -------------------------------------------------------------------- + + /** + * Stores the current schema version + * + * @access protected + * @param $migrations integer Migration reached + * @return void Outputs a report of the migration + */ + protected function _update_version($migrations) + { + return $this->db->update('migrations', array( + 'version' => $migrations + )); + } + + // -------------------------------------------------------------------- + + /** + * Enable the use of CI super-global + * + * @access public + * @param $var + * @return mixed + */ + public function __get($var) + { + return get_instance()->$var; + } +} + +/* End of file Migration.php */ +/* Location: ./system/libraries/Migration.php */ \ No newline at end of file diff --git a/system/libraries/Pagination.php b/system/libraries/Pagination.php index 47b718bd..cc62e660 100644 --- a/system/libraries/Pagination.php +++ b/system/libraries/Pagination.php @@ -6,7 +6,7 @@ * * @package CodeIgniter * @author ExpressionEngine Dev Team - * @copyright Copyright (c) 2008 - 2010, EllisLab, Inc. + * @copyright Copyright (c) 2008 - 2011, EllisLab, Inc. * @license http://codeigniter.com/user_guide/license.html * @link http://codeigniter.com * @since Version 1.0 @@ -30,7 +30,7 @@ class CI_Pagination { var $prefix = ''; // A custom prefix added to the path. var $suffix = ''; // A custom suffix added to the path. - var $total_rows = ''; // Total number of items (database results) + var $total_rows = 0; // Total number of items (database results) var $per_page = 10; // Max number of items you want shown per page var $num_links = 2; // Number of "digit" links to show before/after the currently viewed page var $cur_page = 0; // The current page being viewed diff --git a/system/libraries/Parser.php b/system/libraries/Parser.php index 4cac7394..d223da02 100644 --- a/system/libraries/Parser.php +++ b/system/libraries/Parser.php @@ -6,7 +6,7 @@ * * @package CodeIgniter * @author ExpressionEngine Dev Team - * @copyright Copyright (c) 2008 - 2010, EllisLab, Inc. + * @copyright Copyright (c) 2008 - 2011, EllisLab, Inc. * @license http://codeigniter.com/user_guide/license.html * @link http://codeigniter.com * @since Version 1.0 diff --git a/system/libraries/Profiler.php b/system/libraries/Profiler.php index e7d88b66..082a5ee1 100644 --- a/system/libraries/Profiler.php +++ b/system/libraries/Profiler.php @@ -6,7 +6,7 @@ * * @package CodeIgniter * @author ExpressionEngine Dev Team - * @copyright Copyright (c) 2008 - 2010, EllisLab, Inc. + * @copyright Copyright (c) 2008 - 2011, EllisLab, Inc. * @license http://codeigniter.com/user_guide/license.html * @link http://codeigniter.com * @since Version 1.0 @@ -32,8 +32,6 @@ */ class CI_Profiler { - var $CI; - protected $_available_sections = array( 'benchmarks', 'get', @@ -43,14 +41,27 @@ class CI_Profiler { 'controller_info', 'queries', 'http_headers', + 'session_data', 'config' ); + protected $_query_toggle_count = 25; + + protected $CI; + + // -------------------------------------------------------------------- + public function __construct($config = array()) { $this->CI =& get_instance(); $this->CI->load->language('profiler'); + if (isset($config['query_toggle_count'])) + { + $this->_query_toggle_count = (int) $config['query_toggle_count']; + unset($config['query_toggle_count']); + } + // default all sections to display foreach ($this->_available_sections as $section) { @@ -162,7 +173,7 @@ protected function _compile_queries() $output .= "\n"; $output .= '  '.$this->CI->lang->line('profiler_queries').'  '; $output .= "\n"; - $output .= "\n\n\n"; + $output .= "\n\n
\n"; $output .="\n"; $output .= "
".$this->CI->lang->line('profiler_no_db')."
\n"; $output .= ""; @@ -178,13 +189,26 @@ protected function _compile_queries() $output = "\n\n"; + $count = 0; + foreach ($dbs as $db) { + $count++; + + $hide_queries = (count($db->queries) > $this->_query_toggle_count) ? ' display:none' : ''; + + $show_hide_js = '('.$this->CI->lang->line('profiler_section_hide').')'; + + if ($hide_queries != '') + { + $show_hide_js = '('.$this->CI->lang->line('profiler_section_show').')'; + } + $output .= '
'; $output .= "\n"; - $output .= '  '.$this->CI->lang->line('profiler_database').':  '.$db->database.'   '.$this->CI->lang->line('profiler_queries').': '.count($this->CI->db->queries).'   '; + $output .= '  '.$this->CI->lang->line('profiler_database').':  '.$db->database.'   '.$this->CI->lang->line('profiler_queries').': '.count($db->queries).'  '.$show_hide_js.''; $output .= "\n"; - $output .= "\n\n\n"; + $output .= "\n\n
\n"; if (count($db->queries) == 0) { @@ -388,7 +412,7 @@ protected function _compile_memory_usage() } else { - $output .= "
".$this->CI->lang->line('profiler_no_memory_usage')."
"; + $output .= "
".$this->CI->lang->line('profiler_no_memory')."
"; } $output .= ""; @@ -410,12 +434,12 @@ protected function _compile_http_headers() $output = "\n\n"; $output .= '
'; $output .= "\n"; - $output .= '  '.$this->CI->lang->line('profiler_headers').'  '; + $output .= '  '.$this->CI->lang->line('profiler_headers').'  ('.$this->CI->lang->line('profiler_section_show').')'; $output .= "\n"; - $output .= "\n\n
\n"; + $output .= "\n\n
\n"; - foreach(array('HTTP_ACCEPT', 'HTTP_USER_AGENT', 'HTTP_CONNECTION', 'SERVER_PORT', 'SERVER_NAME', 'REMOTE_ADDR', 'SERVER_SOFTWARE', 'HTTP_ACCEPT_LANGUAGE', 'SCRIPT_NAME', 'REQUEST_METHOD',' HTTP_HOST', 'REMOTE_HOST', 'CONTENT_TYPE', 'SERVER_PROTOCOL', 'QUERY_STRING', 'HTTP_ACCEPT_ENCODING', 'HTTP_X_FORWARDED_FOR') as $header) + foreach (array('HTTP_ACCEPT', 'HTTP_USER_AGENT', 'HTTP_CONNECTION', 'SERVER_PORT', 'SERVER_NAME', 'REMOTE_ADDR', 'SERVER_SOFTWARE', 'HTTP_ACCEPT_LANGUAGE', 'SCRIPT_NAME', 'REQUEST_METHOD',' HTTP_HOST', 'REMOTE_HOST', 'CONTENT_TYPE', 'SERVER_PROTOCOL', 'QUERY_STRING', 'HTTP_ACCEPT_ENCODING', 'HTTP_X_FORWARDED_FOR') as $header) { $val = (isset($_SERVER[$header])) ? $_SERVER[$header] : ''; $output .= "\n"; @@ -441,12 +465,12 @@ protected function _compile_config() $output = "\n\n"; $output .= '
'; $output .= "\n"; - $output .= '  '.$this->CI->lang->line('profiler_config').'  '; + $output .= '  '.$this->CI->lang->line('profiler_config').'  ('.$this->CI->lang->line('profiler_section_show').')'; $output .= "\n"; - $output .= "\n\n
\n"; + $output .= "\n\n
\n"; - foreach($this->CI->config->config as $config=>$val) + foreach ($this->CI->config->config as $config=>$val) { if (is_array($val)) { @@ -464,6 +488,39 @@ protected function _compile_config() // -------------------------------------------------------------------- + /** + * Compile session userdata + * + * @return string + */ + private function _compile_session_data() + { + if ( ! isset($this->CI->session)) + { + return; + } + + $output = '
'; + $output .= '  '.$this->CI->lang->line('profiler_session_data').'  ('.$this->CI->lang->line('profiler_section_show').')'; + $output .= "
"; + + foreach ($this->CI->session->all_userdata() as $key => $val) + { + if (is_array($val)) + { + $val = print_r($val, TRUE); + } + + $output .= "\n"; + } + + $output .= ''; + $output .= "
"; + return $output; + } + + // -------------------------------------------------------------------- + /** * Run the Profiler * @@ -493,7 +550,6 @@ public function run() return $output; } - } // END CI_Profiler class diff --git a/system/libraries/Session.php b/system/libraries/Session.php index 4dccc46c..2c8a8016 100644 --- a/system/libraries/Session.php +++ b/system/libraries/Session.php @@ -6,7 +6,7 @@ * * @package CodeIgniter * @author ExpressionEngine Dev Team - * @copyright Copyright (c) 2008 - 2010, EllisLab, Inc. + * @copyright Copyright (c) 2008 - 2011, EllisLab, Inc. * @license http://codeigniter.com/user_guide/license.html * @link http://codeigniter.com * @since Version 1.0 @@ -37,6 +37,7 @@ class CI_Session { var $cookie_prefix = ''; var $cookie_path = ''; var $cookie_domain = ''; + var $cookie_secure = FALSE; var $sess_time_to_update = 300; var $encryption_key = ''; var $flashdata_key = 'flash'; @@ -61,7 +62,7 @@ public function __construct($params = array()) // Set all the session preferences, which can either be set // manually via the $params array above or via the config file - foreach (array('sess_encrypt_cookie', 'sess_use_database', 'sess_table_name', 'sess_expiration', 'sess_expire_on_close', 'sess_match_ip', 'sess_match_useragent', 'sess_cookie_name', 'cookie_path', 'cookie_domain', 'sess_time_to_update', 'time_reference', 'cookie_prefix', 'encryption_key') as $key) + foreach (array('sess_encrypt_cookie', 'sess_use_database', 'sess_table_name', 'sess_expiration', 'sess_expire_on_close', 'sess_match_ip', 'sess_match_useragent', 'sess_cookie_name', 'cookie_path', 'cookie_domain', 'cookie_secure', 'sess_time_to_update', 'time_reference', 'cookie_prefix', 'encryption_key') as $key) { $this->$key = (isset($params[$key])) ? $params[$key] : $this->CI->config->item($key); } @@ -188,7 +189,7 @@ function sess_read() } // Does the User Agent Match? - if ($this->sess_match_useragent == TRUE AND trim($session['user_agent']) != trim(substr($this->CI->input->user_agent(), 0, 50))) + if ($this->sess_match_useragent == TRUE AND trim($session['user_agent']) != trim(substr($this->CI->input->user_agent(), 0, 120))) { $this->sess_destroy(); return FALSE; @@ -315,7 +316,7 @@ function sess_create() $this->userdata = array( 'session_id' => md5(uniqid($sessid, TRUE)), 'ip_address' => $this->CI->input->ip_address(), - 'user_agent' => substr($this->CI->input->user_agent(), 0, 50), + 'user_agent' => substr($this->CI->input->user_agent(), 0, 120), 'last_activity' => $this->now ); @@ -434,11 +435,11 @@ function userdata($item) * Fetch all session data * * @access public - * @return mixed + * @return array */ function all_userdata() { - return ( ! isset($this->userdata)) ? FALSE : $this->userdata; + return $this->userdata; } // -------------------------------------------------------------------- @@ -666,7 +667,7 @@ function _set_cookie($cookie_data = NULL) $expire, $this->cookie_path, $this->cookie_domain, - 0 + $this->cookie_secure ); } diff --git a/system/libraries/Sha1.php b/system/libraries/Sha1.php index a5addd00..1a657572 100644 --- a/system/libraries/Sha1.php +++ b/system/libraries/Sha1.php @@ -6,7 +6,7 @@ * * @package CodeIgniter * @author ExpressionEngine Dev Team - * @copyright Copyright (c) 2008 - 2010, EllisLab, Inc. + * @copyright Copyright (c) 2008 - 2011, EllisLab, Inc. * @license http://codeigniter.com/user_guide/license.html * @link http://codeigniter.com * @since Version 1.0 @@ -42,7 +42,7 @@ * @author ExpressionEngine Dev Team * @link http://codeigniter.com/user_guide/general/encryption.html */ -class CI_SHA { +class CI_SHA1 { public function __construct() { @@ -88,7 +88,7 @@ function generate($str) $oldd = $d; $olde = $e; - for($j = 0; $j < 80; $j++) + for ($j = 0; $j < 80; $j++) { if ($j < 16) { diff --git a/system/libraries/Table.php b/system/libraries/Table.php index b4c6d366..def69677 100644 --- a/system/libraries/Table.php +++ b/system/libraries/Table.php @@ -6,7 +6,7 @@ * * @package CodeIgniter * @author ExpressionEngine Dev Team - * @copyright Copyright (c) 2008 - 2010, EllisLab, Inc. + * @copyright Copyright (c) 2008 - 2011, EllisLab, Inc. * @license http://codeigniter.com/user_guide/license.html * @link http://codeigniter.com * @since Version 1.3.1 @@ -108,7 +108,7 @@ function make_columns($array = array(), $col_limit = 0) } $new = array(); - while(count($array) > 0) + while (count($array) > 0) { $temp = array_splice($array, 0, $col_limit); @@ -280,7 +280,7 @@ function generate($table_data = NULL) $out .= $this->template['heading_row_start']; $out .= $this->newline; - foreach($this->heading as $heading) + foreach ($this->heading as $heading) { $temp = $this->template['heading_cell_start']; @@ -310,7 +310,7 @@ function generate($table_data = NULL) $out .= $this->newline; $i = 1; - foreach($this->rows as $row) + foreach ($this->rows as $row) { if ( ! is_array($row)) { @@ -323,7 +323,7 @@ function generate($table_data = NULL) $out .= $this->template['row_'.$name.'start']; $out .= $this->newline; - foreach($row as $cell) + foreach ($row as $cell) { $temp = $this->template['cell_'.$name.'start']; @@ -367,6 +367,9 @@ function generate($table_data = NULL) $out .= $this->template['table_close']; + // Clear table class properties before generating the table + $this->clear(); + return $out; } diff --git a/system/libraries/Trackback.php b/system/libraries/Trackback.php index 79f512b2..b0a76782 100644 --- a/system/libraries/Trackback.php +++ b/system/libraries/Trackback.php @@ -6,7 +6,7 @@ * * @package CodeIgniter * @author ExpressionEngine Dev Team - * @copyright Copyright (c) 2008 - 2010, EllisLab, Inc. + * @copyright Copyright (c) 2008 - 2011, EllisLab, Inc. * @license http://codeigniter.com/user_guide/license.html * @link http://codeigniter.com * @since Version 1.0 @@ -94,7 +94,7 @@ function send($tb_data) { $$item = $this->convert_ascii($$item); } - elseif($item == 'blog_name') + elseif ($item == 'blog_name') { $$item = $this->convert_ascii($$item); } @@ -261,7 +261,7 @@ function process($url, $data) // Was it successful? $this->response = ""; - while( ! feof($fp)) + while ( ! feof($fp)) { $this->response .= fgets($fp, 128); } diff --git a/system/libraries/Typography.php b/system/libraries/Typography.php index 2ea25e48..734cec10 100644 --- a/system/libraries/Typography.php +++ b/system/libraries/Typography.php @@ -6,7 +6,7 @@ * * @package CodeIgniter * @author ExpressionEngine Dev Team - * @copyright Copyright (c) 2008 - 2010, EllisLab, Inc. + * @copyright Copyright (c) 2008 - 2011, EllisLab, Inc. * @license http://codeigniter.com/user_guide/license.html * @link http://codeigniter.com * @since Version 1.0 diff --git a/system/libraries/Unit_test.php b/system/libraries/Unit_test.php index a57934cd..5bd7e801 100644 --- a/system/libraries/Unit_test.php +++ b/system/libraries/Unit_test.php @@ -6,7 +6,7 @@ * * @package CodeIgniter * @author ExpressionEngine Dev Team - * @copyright Copyright (c) 2008 - 2010, EllisLab, Inc. + * @copyright Copyright (c) 2008 - 2011, EllisLab, Inc. * @license http://codeigniter.com/user_guide/license.html * @link http://codeigniter.com * @since Version 1.3.1 diff --git a/system/libraries/Upload.php b/system/libraries/Upload.php index b0e1f4c6..3177424c 100644 --- a/system/libraries/Upload.php +++ b/system/libraries/Upload.php @@ -6,7 +6,7 @@ * * @package CodeIgniter * @author ExpressionEngine Dev Team - * @copyright Copyright (c) 2008 - 2010, EllisLab, Inc. + * @copyright Copyright (c) 2008 - 2011, EllisLab, Inc. * @license http://codeigniter.com/user_guide/license.html * @link http://codeigniter.com * @since Version 1.0 @@ -142,7 +142,8 @@ public function initialize($config = array()) */ public function do_upload($field = 'userfile') { - // Is $_FILES[$field] set? If not, no reason to continue. + + // Is $_FILES[$field] set? If not, no reason to continue. if ( ! isset($_FILES[$field])) { $this->set_error('upload_no_file_selected'); @@ -214,7 +215,7 @@ public function do_upload($field = 'userfile') $this->file_name = $this->_prep_filename($this->_file_name_override); // If no extension was provided in the file_name config item, use the uploaded one - if(strpos($this->_file_name_override, '.') === FALSE) + if (strpos($this->_file_name_override, '.') === FALSE) { $this->file_name .= $this->file_ext; } @@ -874,12 +875,6 @@ public function do_xss_clean() } $CI =& get_instance(); - - if ( ! isset($CI->security)) - { - $CI->load->library('security'); - } - return $CI->security->xss_clean($data, TRUE); } @@ -950,11 +945,21 @@ public function mimes_types($mime) if (count($this->mimes) == 0) { - if (@require_once(APPPATH.'config/mimes'.EXT)) + if (defined('ENVIRONMENT') AND is_file(APPPATH.'config/'.ENVIRONMENT.'/mimes.php')) + { + include(APPPATH.'config/'.ENVIRONMENT.'/mimes.php'); + } + elseif (is_file(APPPATH.'config/mimes.php')) + { + include(APPPATH.'config//mimes.php'); + } + else { - $this->mimes = $mimes; - unset($mimes); + return FALSE; } + + $this->mimes = $mimes; + unset($mimes); } return ( ! isset($this->mimes[$mime])) ? FALSE : $this->mimes[$mime]; diff --git a/system/libraries/User_agent.php b/system/libraries/User_agent.php index 53cd7b2f..016102a2 100644 --- a/system/libraries/User_agent.php +++ b/system/libraries/User_agent.php @@ -6,7 +6,7 @@ * * @package CodeIgniter * @author ExpressionEngine Dev Team - * @copyright Copyright (c) 2008 - 2010, EllisLab, Inc. + * @copyright Copyright (c) 2008 - 2011, EllisLab, Inc. * @license http://codeigniter.com/user_guide/license.html * @link http://codeigniter.com * @since Version 1.0 @@ -84,7 +84,15 @@ public function __construct() */ private function _load_agent_file() { - if ( ! @include(APPPATH.'config/user_agents'.EXT)) + if (defined('ENVIRONMENT') AND is_file(APPPATH.'config/'.ENVIRONMENT.'/user_agents.php')) + { + include(APPPATH.'config/'.ENVIRONMENT.'/user_agents.php'); + } + elseif (is_file(APPPATH.'config/user_agents.php')) + { + include(APPPATH.'config/user_agents.php'); + } + else { return FALSE; } @@ -375,7 +383,11 @@ public function is_mobile($key = NULL) */ public function is_referral() { - return ( ! isset($_SERVER['HTTP_REFERER']) OR $_SERVER['HTTP_REFERER'] == ''); + if ( ! isset($_SERVER['HTTP_REFERER']) OR $_SERVER['HTTP_REFERER'] == '') + { + return FALSE; + } + return TRUE; } // -------------------------------------------------------------------- diff --git a/system/libraries/Xmlrpc.php b/system/libraries/Xmlrpc.php index 3ae5bad4..5da6ea6a 100644 --- a/system/libraries/Xmlrpc.php +++ b/system/libraries/Xmlrpc.php @@ -6,7 +6,7 @@ * * @package CodeIgniter * @author ExpressionEngine Dev Team - * @copyright Copyright (c) 2008 - 2010, EllisLab, Inc. + * @copyright Copyright (c) 2008 - 2011, EllisLab, Inc. * @license http://codeigniter.com/user_guide/license.html * @link http://codeigniter.com * @since Version 1.0 @@ -207,7 +207,7 @@ function request($incoming) $this->data = array(); - foreach($incoming as $key => $value) + foreach ($incoming as $key => $value) { $this->data[$key] = $this->values_parsing($value); } @@ -232,7 +232,7 @@ function values_parsing($value, $return = FALSE) { if (is_array($value) && array_key_exists(0, $value)) { - if ( ! isset($value['1']) OR (! isset($this->xmlrpcTypes[$value['1']]))) + if ( ! isset($value['1']) OR ( ! isset($this->xmlrpcTypes[$value['1']]))) { if (is_array($value[0])) { @@ -243,7 +243,7 @@ function values_parsing($value, $return = FALSE) $temp = new XML_RPC_Values($value['0'], 'string'); } } - elseif(is_array($value['0']) && ($value['1'] == 'struct' OR $value['1'] == 'array')) + elseif (is_array($value['0']) && ($value['1'] == 'struct' OR $value['1'] == 'array')) { while (list($k) = each($value['0'])) { @@ -281,7 +281,7 @@ function send_request() $this->error = $this->result->errstr; return FALSE; } - elseif( ! is_object($this->result->val)) + elseif ( ! is_object($this->result->val)) { $this->error = $this->result->errstr; return FALSE; @@ -358,7 +358,7 @@ class XML_RPC_Client extends CI_Xmlrpc var $errno = ''; var $errstring = ''; var $timeout = 5; - var $no_multicall = false; + var $no_multicall = FALSE; public function __construct($path, $server, $port=80) { @@ -392,7 +392,7 @@ function sendPayload($msg) return $r; } - if(empty($msg->payload)) + if (empty($msg->payload)) { // $msg = XML_RPC_Messages $msg->createPayload(); @@ -504,12 +504,7 @@ function prepare_response() function decode($array=FALSE) { $CI =& get_instance(); - - if ($this->xss_clean && ! isset($CI->security)) - { - $CI->load->library('security'); - } - + if ($array !== FALSE && is_array($array)) { while (list($key) = each($array)) @@ -553,11 +548,11 @@ function xmlrpc_decoder($xmlrpc_val) { $kind = $xmlrpc_val->kindOf(); - if($kind == 'scalar') + if ($kind == 'scalar') { return $xmlrpc_val->scalarval(); } - elseif($kind == 'array') + elseif ($kind == 'array') { reset($xmlrpc_val->me); list($a,$b) = each($xmlrpc_val->me); @@ -565,18 +560,18 @@ function xmlrpc_decoder($xmlrpc_val) $arr = array(); - for($i = 0; $i < $size; $i++) + for ($i = 0; $i < $size; $i++) { $arr[] = $this->xmlrpc_decoder($xmlrpc_val->me['array'][$i]); } return $arr; } - elseif($kind == 'struct') + elseif ($kind == 'struct') { reset($xmlrpc_val->me['struct']); $arr = array(); - while(list($key,$value) = each($xmlrpc_val->me['struct'])) + while (list($key,$value) = each($xmlrpc_val->me['struct'])) { $arr[$key] = $this->xmlrpc_decoder($value); } @@ -595,10 +590,8 @@ function iso8601_decode($time, $utc=0) $t = 0; if (preg_match('/([0-9]{4})([0-9]{2})([0-9]{2})T([0-9]{2}):([0-9]{2}):([0-9]{2})/', $time, $regs)) { - if ($utc == 1) - $t = gmmktime($regs[4], $regs[5], $regs[6], $regs[2], $regs[3], $regs[1]); - else - $t = mktime($regs[4], $regs[5], $regs[6], $regs[2], $regs[3], $regs[1]); + $fnc = ($utc == 1) ? 'gmmktime' : 'mktime'; + $t = $fnc($regs[4], $regs[5], $regs[6], $regs[2], $regs[3], $regs[1]); } return $t; } @@ -628,7 +621,7 @@ public function __construct($method, $pars=0) $this->method_name = $method; if (is_array($pars) && count($pars) > 0) { - for($i=0; $iparams[] = $pars[$i]; @@ -646,7 +639,7 @@ function createPayload() $this->payload .= '' . $this->method_name . "\r\n"; $this->payload .= "\r\n"; - for($i=0; $iparams); $i++) + for ($i=0; $iparams); $i++) { // $p = XML_RPC_Values $p = $this->params[$i]; @@ -664,7 +657,7 @@ function parseResponse($fp) { $data = ''; - while($datum = fread($fp, 4096)) + while ($datum = fread($fp, 4096)) { $data .= $datum; } @@ -684,7 +677,7 @@ function parseResponse($fp) // Check for data //------------------------------------- - if($data == "") + if ($data == "") { error_log($this->xmlrpcstr['no_data']); $r = new XML_RPC_Response(0, $this->xmlrpcerr['no_data'], $this->xmlrpcstr['no_data']); @@ -896,7 +889,7 @@ function open_tag($the_parser, $name, $attrs) $this->xh[$the_parser]['isf'] = 1; break; case 'PARAM': - $this->xh[$the_parser]['value'] = null; + $this->xh[$the_parser]['value'] = NULL; break; case 'VALUE': $this->xh[$the_parser]['vt'] = 'value'; @@ -925,7 +918,7 @@ function open_tag($the_parser, $name, $attrs) $this->xh[$the_parser]['valuestack'][0]['name'] = ''; // Set NULL value to check to see if value passed for this param/member - $this->xh[$the_parser]['value'] = null; + $this->xh[$the_parser]['value'] = NULL; break; case 'DATA': case 'METHODCALL': @@ -1108,7 +1101,7 @@ function character_data($the_parser, $data) $this->xh[$the_parser]['lv'] = 2; // Found a value } - if( ! @isset($this->xh[$the_parser]['ac'])) + if ( ! @isset($this->xh[$the_parser]['ac'])) { $this->xh[$the_parser]['ac'] = ''; } @@ -1123,12 +1116,7 @@ function addParam($par) { $this->params[]=$par; } function output_parameters($array=FALSE) { $CI =& get_instance(); - - if ($this->xss_clean && ! isset($CI->security)) - { - $CI->load->library('security'); - } - + if ($array !== FALSE && is_array($array)) { while (list($key) = each($array)) @@ -1174,11 +1162,11 @@ function decode_message($param) { $kind = $param->kindOf(); - if($kind == 'scalar') + if ($kind == 'scalar') { return $param->scalarval(); } - elseif($kind == 'array') + elseif ($kind == 'array') { reset($param->me); list($a,$b) = each($param->me); @@ -1192,13 +1180,13 @@ function decode_message($param) return $arr; } - elseif($kind == 'struct') + elseif ($kind == 'struct') { reset($param->me['struct']); $arr = array(); - while(list($key,$value) = each($param->me['struct'])) + while (list($key,$value) = each($param->me['struct'])) { $arr[$key] = $this->decode_message($value); } @@ -1343,7 +1331,7 @@ function serializedata($typ, $val) // struct $rs .= "\n"; reset($val); - while(list($key2, $val2) = each($val)) + while (list($key2, $val2) = each($val)) { $rs .= "\n{$key2}\n"; $rs .= $this->serializeval($val2); diff --git a/system/libraries/Xmlrpcs.php b/system/libraries/Xmlrpcs.php index 555ec749..9cd33214 100644 --- a/system/libraries/Xmlrpcs.php +++ b/system/libraries/Xmlrpcs.php @@ -6,7 +6,7 @@ * * @package CodeIgniter * @author ExpressionEngine Dev Team - * @copyright Copyright (c) 2008 - 2010, EllisLab, Inc. + * @copyright Copyright (c) 2008 - 2011, EllisLab, Inc. * @license http://codeigniter.com/user_guide/license.html * @link http://codeigniter.com * @since Version 1.0 @@ -59,10 +59,15 @@ public function __construct($config=array()) log_message('debug', "XML-RPC Server Class Initialized"); } - //------------------------------------- - // Initialize Prefs and Serve - //------------------------------------- + // -------------------------------------------------------------------- + /** + * Initialize Prefs and Serve + * + * @access public + * @param mixed + * @return void + */ function initialize($config=array()) { if (isset($config['functions']) && is_array($config['functions'])) @@ -86,11 +91,15 @@ function initialize($config=array()) } } - //------------------------------------- - // Setting of System Methods - //------------------------------------- + // -------------------------------------------------------------------- - function set_system_methods () + /** + * Setting of System Methods + * + * @access public + * @return void + */ + function set_system_methods() { $this->methods = array( 'system.listMethods' => array( @@ -112,11 +121,14 @@ function set_system_methods () ); } + // -------------------------------------------------------------------- - //------------------------------------- - // Main Server Function - //------------------------------------- - + /** + * Main Server Function + * + * @access public + * @return void + */ function serve() { $r = $this->parseRequest(); @@ -129,11 +141,19 @@ function serve() exit($payload); } - //------------------------------------- - // Add Method to Class - //------------------------------------- + // -------------------------------------------------------------------- - function add_to_map($methodname,$function,$sig,$doc) + /** + * Add Method to Class + * + * @access public + * @param string method name + * @param string function + * @param string signature + * @param string docstring + * @return void + */ + function add_to_map($methodname, $function, $sig, $doc) { $this->methods[$methodname] = array( 'function' => $function, @@ -142,11 +162,15 @@ function add_to_map($methodname,$function,$sig,$doc) ); } + // -------------------------------------------------------------------- - //------------------------------------- - // Parse Server Request - //------------------------------------- - + /** + * Parse Server Request + * + * @access public + * @param string data + * @return object xmlrpc response + */ function parseRequest($data='') { global $HTTP_RAW_POST_DATA; @@ -196,7 +220,7 @@ function parseRequest($data='') xml_get_current_line_number($parser))); xml_parser_free($parser); } - elseif($parser_object->xh[$parser]['isf']) + elseif ($parser_object->xh[$parser]['isf']) { return new XML_RPC_Response(0, $this->xmlrpcerr['invalid_return'], $this->xmlrpcstr['invalid_return']); } @@ -207,7 +231,7 @@ function parseRequest($data='') $m = new XML_RPC_Message($parser_object->xh[$parser]['method']); $plist=''; - for($i=0; $i < count($parser_object->xh[$parser]['params']); $i++) + for ($i=0; $i < count($parser_object->xh[$parser]['params']); $i++) { if ($this->debug === TRUE) { @@ -239,10 +263,15 @@ function parseRequest($data='') return $r; } - //------------------------------------- - // Executes the Method - //------------------------------------- + // -------------------------------------------------------------------- + /** + * Executes the Method + * + * @access protected + * @param object + * @return mixed + */ function _execute($m) { $methName = $m->method_name; @@ -297,13 +326,13 @@ function _execute($m) if (isset($this->methods[$methName]['signature'])) { $sig = $this->methods[$methName]['signature']; - for($i=0; $iparams)+1) { - for($n=0; $n < count($m->params); $n++) + for ($n=0; $n < count($m->params); $n++) { $p = $m->params[$n]; $pt = ($p->kindOf() == 'scalar') ? $p->scalarval() : $p->kindOf(); @@ -352,23 +381,27 @@ function _execute($m) return call_user_func($this->methods[$methName]['function'], $m); } } + + // -------------------------------------------------------------------- - - //------------------------------------- - // Server Function: List Methods - //------------------------------------- - + /** + * Server Function: List Methods + * + * @access public + * @param mixed + * @return object + */ function listMethods($m) { $v = new XML_RPC_Values(); $output = array(); - foreach($this->methods as $key => $value) + foreach ($this->methods as $key => $value) { $output[] = new XML_RPC_Values($key, 'string'); } - foreach($this->system_methods as $key => $value) + foreach ($this->system_methods as $key => $value) { $output[]= new XML_RPC_Values($key, 'string'); } @@ -376,11 +409,16 @@ function listMethods($m) $v->addArray($output); return new XML_RPC_Response($v); } + + // -------------------------------------------------------------------- - //------------------------------------- - // Server Function: Return Signature for Method - //------------------------------------- - + /** + * Server Function: Return Signature for Method + * + * @access public + * @param mixed + * @return object + */ function methodSignature($m) { $parameters = $m->output_parameters(); @@ -393,11 +431,11 @@ function methodSignature($m) $sigs = array(); $signature = $this->methods[$method_name]['signature']; - for($i=0; $i < count($signature); $i++) + for ($i=0; $i < count($signature); $i++) { $cursig = array(); $inSig = $signature[$i]; - for($j=0; $joutput_parameters(); @@ -437,11 +480,16 @@ function methodHelp($m) return new XML_RPC_Response(0, $this->xmlrpcerr['introspect_unknown'], $this->xmlrpcstr['introspect_unknown']); } } + + // -------------------------------------------------------------------- - //------------------------------------- - // Server Function: Multi-call - //------------------------------------- - + /** + * Server Function: Multi-call + * + * @access public + * @param mixed + * @return object + */ function multicall($m) { // Disabled @@ -459,7 +507,7 @@ function multicall($m) $m = new XML_RPC_Message($value[0]); $plist=''; - for($i=0; $i < count($value[1]); $i++) + for ($i=0; $i < count($value[1]); $i++) { $m->addParam(new XML_RPC_Values($value[1][$i], 'string')); } @@ -477,11 +525,15 @@ function multicall($m) return new XML_RPC_Response(new XML_RPC_Values($result, 'array')); } + // -------------------------------------------------------------------- - //------------------------------------- - // Multi-call Function: Error Handling - //------------------------------------- - + /** + * Multi-call Function: Error Handling + * + * @access public + * @param mixed + * @return object + */ function multicall_error($err) { $str = is_string($err) ? $this->xmlrpcstr["multicall_${err}"] : $err->faultString(); @@ -493,29 +545,45 @@ function multicall_error($err) return new XML_RPC_Values($struct, 'struct'); } + // -------------------------------------------------------------------- - //------------------------------------- - // Multi-call Function: Processes method - //------------------------------------- - + /** + * Multi-call Function: Processes method + * + * @access public + * @param mixed + * @return object + */ function do_multicall($call) { if ($call->kindOf() != 'struct') + { return $this->multicall_error('notstruct'); + } elseif ( ! $methName = $call->me['struct']['methodName']) + { return $this->multicall_error('nomethod'); + } list($scalar_type,$scalar_value)=each($methName->me); $scalar_type = $scalar_type == $this->xmlrpcI4 ? $this->xmlrpcInt : $scalar_type; if ($methName->kindOf() != 'scalar' OR $scalar_type != 'string') + { return $this->multicall_error('notstring'); + } elseif ($scalar_value == 'system.multicall') + { return $this->multicall_error('recursion'); + } elseif ( ! $params = $call->me['struct']['params']) + { return $this->multicall_error('noparams'); + } elseif ($params->kindOf() != 'array') + { return $this->multicall_error('notarray'); + } list($a,$b)=each($params->me); $numParams = count($b); diff --git a/system/libraries/Zip.php b/system/libraries/Zip.php index 94da4b3b..666327d5 100644 --- a/system/libraries/Zip.php +++ b/system/libraries/Zip.php @@ -6,7 +6,7 @@ * * @package CodeIgniter * @author ExpressionEngine Dev Team - * @copyright Copyright (c) 2008 - 2010, EllisLab, Inc. + * @copyright Copyright (c) 2008 - 2011, EllisLab, Inc. * @license http://codeigniter.com/user_guide/license.html * @link http://codeigniter.com * @since Version 1.0 @@ -289,7 +289,7 @@ function read_dir($path, $preserve_filepath = TRUE, $root_path = NULL) while (FALSE !== ($file = readdir($fp))) { - if(substr($file, 0, 1) == '.') + if (substr($file, 0, 1) == '.') { continue; } diff --git a/system/libraries/javascript/Jquery.php b/system/libraries/javascript/Jquery.php index 91148dca..baab83d2 100644 --- a/system/libraries/javascript/Jquery.php +++ b/system/libraries/javascript/Jquery.php @@ -7,7 +7,7 @@ * * @package CodeIgniter * @author ExpressionEngine Dev Team - * @copyright Copyright (c) 2008 - 2010, EllisLab, Inc. + * @copyright Copyright (c) 2008 - 2011, EllisLab, Inc. * @license http://www.codeigniter.com/user_guide/license.html * @link http://www.codeigniter.com * @since Version 1.0 @@ -21,7 +21,7 @@ * @subpackage Libraries * @author ExpressionEngine Dev Team * @category Loader - * @link http://www.codeigniter.com/user_guide/libraries/jquery.html + * @link http://www.codeigniter.com/user_guide/libraries/javascript.html */ class CI_Jquery extends CI_Javascript { diff --git a/user_guide/changelog.html b/user_guide/changelog.html index a6332d64..e0cefc31 100644 --- a/user_guide/changelog.html +++ b/user_guide/changelog.html @@ -28,7 +28,7 @@
diff --git a/user_guide/database/active_record.html b/user_guide/database/active_record.html index 9ae93a9a..62833813 100644 --- a/user_guide/database/active_record.html +++ b/user_guide/database/active_record.html @@ -27,7 +27,7 @@
- +

CodeIgniter User Guide Version 2.0.0

CodeIgniter User Guide Version 2.0.2

@@ -489,10 +489,10 @@

$this->db->insert();

$data = array(
-               'title' => 'My title' ,
-               'name' => 'My Name' ,
-               'date' => 'My date'
-            );
+   'title' => 'My title' ,
+   'name' => 'My Name' ,
+   'date' => 'My date'
+);

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

@@ -517,10 +517,35 @@

$this->db->insert();



// Produces: INSERT INTO mytable (title, content, date) VALUES ('My Title', 'My Content', 'My Date')
-

The first parameter will contain the table name, the second is an associative array of values.

+

The first parameter will contain the table name, the second is an object.

Note: All values are escaped automatically producing safer queries.

+

$this->db->insert_batch();

+

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

+ + +$data = array(
+   array(
+      'title' => 'My title' ,
+      'name' => 'My Name' ,
+      'date' => 'My date'
+   ),
+   array(
+      'title' => 'Another title' ,
+      'name' => 'Another Name' ,
+      'date' => 'Another date'
+   )
+);
+
+$this->db->update_batch('mytable', $data); +

+// Produces: INSERT INTO mytable (title, name, date) VALUES ('My title', 'My name', 'My date'), ('Another title', 'Another name', 'Another date')
+ +

The first parameter will contain the table name, the second is an associative array of values.

+ +

Note: All values are escaped automatically producing safer queries.

@@ -750,7 +775,7 @@

$this->db->flush_cache()

User Guide Home   ·   Next Topic:  Transactions

-

CodeIgniter  ·  Copyright © 2006-2010  ·  EllisLab, Inc.

+

CodeIgniter  ·  Copyright © 2006 - 2011  ·  EllisLab, Inc.

diff --git a/user_guide/database/caching.html b/user_guide/database/caching.html index d5ed5885..3f4ef2bc 100644 --- a/user_guide/database/caching.html +++ b/user_guide/database/caching.html @@ -28,7 +28,7 @@
- +

CodeIgniter User Guide Version 2.0.0

CodeIgniter User Guide Version 2.0.2

@@ -213,7 +213,7 @@

$this->db->cache_delete_all()

User Guide Home   ·   Next Topic:  Database manipulation with Database Forge

-

CodeIgniter  ·  Copyright © 2006-2010  ·  EllisLab, Inc.

+

CodeIgniter  ·  Copyright © 2006 - 2011  ·  EllisLab, Inc.

diff --git a/user_guide/database/call_function.html b/user_guide/database/call_function.html index 46dfe89d..3e0c78d3 100644 --- a/user_guide/database/call_function.html +++ b/user_guide/database/call_function.html @@ -28,7 +28,7 @@
- +

CodeIgniter User Guide Version 2.0.0

CodeIgniter User Guide Version 2.0.2

@@ -111,7 +111,7 @@

$this->db->call_function();

User Guide Home   ·   Next Topic:  Query Caching

-

CodeIgniter  ·  Copyright © 2006-2010  ·  EllisLab, Inc.

+

CodeIgniter  ·  Copyright © 2006 - 2011  ·  EllisLab, Inc.

diff --git a/user_guide/database/configuration.html b/user_guide/database/configuration.html index 893db622..4ea2e6b3 100644 --- a/user_guide/database/configuration.html +++ b/user_guide/database/configuration.html @@ -28,7 +28,7 @@
- +

CodeIgniter User Guide Version 2.0.0

CodeIgniter User Guide Version 2.0.2

@@ -61,9 +61,7 @@

Database Configuration

CodeIgniter has a config file that lets you store your database connection values (username, password, database name, etc.). -The config file is located at:

- -

application/config/database.php

+The config file is located at application/config/database.php. You can also set database connection values for specific environments by placing database.php it the respective environment config folder.

The config settings are stored in a multi-dimensional array with this prototype:

@@ -134,9 +132,9 @@

Explanation of Values:

  • cache_on - TRUE/FALSE (boolean) - Whether database query caching is enabled, see also Database Caching Class.
  • cachedir - The absolute server path to your database query cache directory.
  • char_set - The character set used in communicating with the database.
  • -
  • dbcollat - The character collation used in communicating with the database.
  • -
  • 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.
  • -
  • autoinit - Whether or not to automatically initialize 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 (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.

  • +
  • 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.
  • +
  • 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.
  • stricton - TRUE/FALSE (boolean) - Whether to force "Strict Mode" connections, good for ensuring strict SQL while developing an application.
  • port - The database port number. To use this value you have to add a line to the database config array.$db['default']['port'] = 5432; @@ -159,7 +157,7 @@

    Explanation of Values:

    User Guide Home   ·   Next Topic:  Connecting to your Database

    -

    CodeIgniter  ·  Copyright © 2006-2010  ·  EllisLab, Inc.

    +

    CodeIgniter  ·  Copyright © 2006 - 2011  ·  EllisLab, Inc.

  • diff --git a/user_guide/database/connecting.html b/user_guide/database/connecting.html index 3ce40562..bb1b401f 100644 --- a/user_guide/database/connecting.html +++ b/user_guide/database/connecting.html @@ -28,7 +28,7 @@
    - +

    CodeIgniter User Guide Version 2.0.0

    CodeIgniter User Guide Version 2.0.2

    @@ -181,7 +181,7 @@

    Manually closing the Connection

    User Guide Home   ·   Next Topic:  Queries

    -

    CodeIgniter  ·  Copyright © 2006-2010  ·  EllisLab, Inc.

    +

    CodeIgniter  ·  Copyright © 2006 - 2011  ·  EllisLab, Inc.

    diff --git a/user_guide/database/examples.html b/user_guide/database/examples.html index 41cfba0e..535fa317 100644 --- a/user_guide/database/examples.html +++ b/user_guide/database/examples.html @@ -28,7 +28,7 @@
    - +

    CodeIgniter User Guide Version 2.0.0

    CodeIgniter User Guide Version 2.0.2

    @@ -210,7 +210,7 @@

    Active Record Insert

    User Guide Home   ·   Next Topic:  Database Configuration

    -

    CodeIgniter  ·  Copyright © 2006-2010  ·  EllisLab, Inc.

    +

    CodeIgniter  ·  Copyright © 2006 - 2011  ·  EllisLab, Inc.

    diff --git a/user_guide/database/fields.html b/user_guide/database/fields.html index e5cc4777..04d8b809 100644 --- a/user_guide/database/fields.html +++ b/user_guide/database/fields.html @@ -28,7 +28,7 @@
    - +

    CodeIgniter User Guide Version 2.0.0

    CodeIgniter User Guide Version 2.0.2

    @@ -156,7 +156,7 @@

    $this->db->field_data()

    User Guide Home   ·   Next Topic:  Custom Function Calls

    -

    CodeIgniter  ·  Copyright © 2006-2010  ·  EllisLab, Inc.

    +

    CodeIgniter  ·  Copyright © 2006 - 2011  ·  EllisLab, Inc.

    diff --git a/user_guide/database/forge.html b/user_guide/database/forge.html index b9e04428..cad2cf26 100644 --- a/user_guide/database/forge.html +++ b/user_guide/database/forge.html @@ -28,7 +28,7 @@
    - +

    CodeIgniter User Guide Version 2.0.0

    CodeIgniter User Guide Version 2.0.2

    @@ -227,7 +227,7 @@

    $this->dbforge->modify_column()

    Top of Page   ·   User Guide Home   ·   Next Topic:  Database Utilities Class

    -

    CodeIgniter  ·  Copyright © 2006-2010  ·  EllisLab, Inc.

    +

    CodeIgniter  ·  Copyright © 2006 - 2011  ·  EllisLab, Inc.

    diff --git a/user_guide/database/helpers.html b/user_guide/database/helpers.html index b7b8a538..107d2ed8 100644 --- a/user_guide/database/helpers.html +++ b/user_guide/database/helpers.html @@ -28,7 +28,7 @@
    - +

    CodeIgniter User Guide Version 2.0.0

    CodeIgniter User Guide Version 2.0.2

    @@ -144,7 +144,7 @@

    $this->db->update_string();

    User Guide Home   ·   Next Topic:  Active Record Pattern

    -

    CodeIgniter  ·  Copyright © 2006-2010  ·  EllisLab, Inc.

    +

    CodeIgniter  ·  Copyright © 2006 - 2011  ·  EllisLab, Inc.

    diff --git a/user_guide/database/index.html b/user_guide/database/index.html index 381592c2..9c67e3b7 100644 --- a/user_guide/database/index.html +++ b/user_guide/database/index.html @@ -28,7 +28,7 @@
    - +

    CodeIgniter User Guide Version 2.0.0

    CodeIgniter User Guide Version 2.0.2

    @@ -86,13 +86,13 @@

    The Database Class

    diff --git a/user_guide/database/queries.html b/user_guide/database/queries.html index c8a30494..4c1ddfe7 100644 --- a/user_guide/database/queries.html +++ b/user_guide/database/queries.html @@ -28,7 +28,7 @@
    - +

    CodeIgniter User Guide Version 2.0.0

    CodeIgniter User Guide Version 2.0.2

    @@ -80,11 +80,16 @@

    $this->db->simple_query();

    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:

    @@ -146,7 +151,7 @@

    Query Bindings

    User Guide Home   ·   Next Topic:  Query Results

    -

    CodeIgniter  ·  Copyright © 2006-2010  ·  EllisLab, Inc.

    +

    CodeIgniter  ·  Copyright © 2006 - 2011  ·  EllisLab, Inc.

    diff --git a/user_guide/database/results.html b/user_guide/database/results.html index 410dac84..8ad6a198 100644 --- a/user_guide/database/results.html +++ b/user_guide/database/results.html @@ -28,7 +28,7 @@
    - +

    CodeIgniter User Guide Version 2.0.0

    CodeIgniter User Guide Version 2.0.2

    @@ -98,6 +98,18 @@

    result()

    } +

    You can also pass a string to result() which represents a class to instantiate for each result object (note: this class must be loaded)

    + + + $query = $this->db->query("SELECT * FROM users;");
    +
    + foreach ($query->result('User') as $user)
    + {
    +    echo $row->name; // call attributes
    +    echo $row->reverse_name(); // or methods defined on the 'User' class
    + } +
    +

    result_array()

    This function returns the query result as a pure array, or an empty array when no result is produced. Typically you'll use this in a foreach loop, like this:

    @@ -133,6 +145,15 @@

    row()

    $row = $query->row(5); +

    You can also add a second String parameter, which is the name of a class to instantiate the row with:

    + + + $query = $this->db->query("SELECT * FROM users LIMIT 1;");
    +
    + $query->row(0, 'User')
    + echo $row->name; // call attributes
    + echo $row->reverse_name(); // or methods defined on the 'User' class
    +

    row_array()

    @@ -231,8 +252,8 @@

    $query->free_result()

    User Guide Home   ·   Next Topic:  Query Helper Functions

    -

    CodeIgniter  ·  Copyright © 2006-2010  ·  EllisLab, Inc.

    +

    CodeIgniter  ·  Copyright © 2006 - 2011  ·  EllisLab, Inc.

    - \ No newline at end of file + diff --git a/user_guide/database/table_data.html b/user_guide/database/table_data.html index 8b86ed58..a2aaa99a 100644 --- a/user_guide/database/table_data.html +++ b/user_guide/database/table_data.html @@ -28,7 +28,7 @@
    - +

    CodeIgniter User Guide Version 2.0.0

    CodeIgniter User Guide Version 2.0.2

    @@ -106,7 +106,7 @@

    $this->db->table_exists();

    User Guide Home   ·   Next Topic:   Field Metadata

    -

    CodeIgniter  ·  Copyright © 2006-2010  ·  EllisLab, Inc.

    +

    CodeIgniter  ·  Copyright © 2006 - 2011  ·  EllisLab, Inc.

    diff --git a/user_guide/database/transactions.html b/user_guide/database/transactions.html index c6ecac6f..74945d43 100644 --- a/user_guide/database/transactions.html +++ b/user_guide/database/transactions.html @@ -28,7 +28,7 @@
    - +

    CodeIgniter User Guide Version 2.0.0

    CodeIgniter User Guide Version 2.0.2

    @@ -193,7 +193,7 @@

    Running Transactions Manually

    User Guide Home   ·   Next Topic:  Table Metadata

    -

    CodeIgniter  ·  Copyright © 2006-2010  ·  EllisLab, Inc.

    +

    CodeIgniter  ·  Copyright © 2006 - 2011  ·  EllisLab, Inc.

    diff --git a/user_guide/database/utilities.html b/user_guide/database/utilities.html index 1ce63d3a..582ea2ce 100644 --- a/user_guide/database/utilities.html +++ b/user_guide/database/utilities.html @@ -28,7 +28,7 @@
    - +

    CodeIgniter User Guide Version 2.0.0

    CodeIgniter User Guide Version 2.0.2

    @@ -96,19 +96,19 @@

    $this->dbutil->list_databases()

    $dbs = $this->dbutil->list_databases();

    -foreach($dbs as $db)
    +foreach ($dbs as $db)
    {
        echo $db;
    }
    -

    $this->db->database_exists();

    +

    $this->dbutil->database_exists();

    Sometimes it's helpful to know whether a particular database exists. Returns a boolean TRUE/FALSE. Usage example:

    -if ($this->db->database_exists('database_name'))
    +if ($this->dbutil->database_exists('database_name'))
    {
       // some code...
    } @@ -306,8 +306,8 @@

    Description of Backup Preferences

       ·   Top of Page   ·   User Guide Home   ·   -Next Topic:   Email Class

    -

    CodeIgniter  ·  Copyright © 2006-2010  ·  EllisLab, Inc.

    +Next Topic:  Javascript Class

    +

    CodeIgniter  ·  Copyright © 2006 - 2011  ·  EllisLab, Inc.

    diff --git a/user_guide/doc_style/index.html b/user_guide/doc_style/index.html index 22637d38..f69846f2 100644 --- a/user_guide/doc_style/index.html +++ b/user_guide/doc_style/index.html @@ -28,7 +28,7 @@
    - +

    CodeIgniter User Guide Version 2.0.0

    CodeIgniter User Guide Version 2.0.2

    @@ -80,7 +80,7 @@

    Files

    User Guide Home   ·   Next Topic:  Benchmarking Class

    -

    CodeIgniter  ·  Copyright © 2006-2010  ·  EllisLab, Inc.

    +

    CodeIgniter  ·  Copyright © 2006 - 2011  ·  EllisLab, Inc.

    diff --git a/user_guide/doc_style/template.html b/user_guide/doc_style/template.html index d5ef5caa..d59d5e4e 100644 --- a/user_guide/doc_style/template.html +++ b/user_guide/doc_style/template.html @@ -121,7 +121,7 @@

    $this->foo->bar()

    User Guide Home   ·   Next Topic:  Next Class

    -

    CodeIgniter  ·  Copyright © 2006-2010  ·  EllisLab, Inc.

    +

    CodeIgniter  ·  Copyright © 2006 - 2011  ·  EllisLab, Inc.

    diff --git a/user_guide/general/alternative_php.html b/user_guide/general/alternative_php.html index 3193c058..abd5845f 100644 --- a/user_guide/general/alternative_php.html +++ b/user_guide/general/alternative_php.html @@ -28,7 +28,7 @@
    - +

    CodeIgniter User Guide Version 2.0.0

    CodeIgniter User Guide Version 2.0.2

    @@ -94,7 +94,7 @@

    Alternative Control Structures

    <ul>

    -<?php foreach($todo as $item): ?>
    +<?php foreach ($todo as $item): ?>

    <li><?=$item?></li>

    @@ -140,7 +140,7 @@

    Alternative Control Structures

    User Guide Home   ·   Next Topic:  Security

    -

    CodeIgniter  ·  Copyright © 2006-2010  ·  EllisLab, Inc.

    +

    CodeIgniter  ·  Copyright © 2006 - 2011  ·  EllisLab, Inc.

    diff --git a/user_guide/general/ancillary_classes.html b/user_guide/general/ancillary_classes.html index 92a8fd95..a7365e70 100644 --- a/user_guide/general/ancillary_classes.html +++ b/user_guide/general/ancillary_classes.html @@ -28,7 +28,7 @@
    - +

    CodeIgniter User Guide Version 2.0.0

    CodeIgniter User Guide Version 2.0.2

    @@ -110,7 +110,7 @@

    get_instance()

    User Guide Home   ·   Next Topic:  Auto-loading Resources

    -

    CodeIgniter  ·  Copyright © 2006-2010  ·  EllisLab, Inc.

    +

    CodeIgniter  ·  Copyright © 2006 - 2011  ·  EllisLab, Inc.

    diff --git a/user_guide/general/autoloader.html b/user_guide/general/autoloader.html index adcd2269..fae0b5fd 100644 --- a/user_guide/general/autoloader.html +++ b/user_guide/general/autoloader.html @@ -28,7 +28,7 @@
    - +

    CodeIgniter User Guide Version 2.0.0

    CodeIgniter User Guide Version 2.0.2

    @@ -93,7 +93,7 @@

    Auto-loading Resources

    Top of Page   ·   User Guide Home   ·   Next Topic:  Common Functions

    -

    CodeIgniter  ·  Copyright © 2006-2010  ·  EllisLab, Inc.

    +

    CodeIgniter  ·  Copyright © 2006 - 2011  ·  EllisLab, Inc.

    diff --git a/user_guide/general/caching.html b/user_guide/general/caching.html index 5c1bcfd0..c77f9a15 100644 --- a/user_guide/general/caching.html +++ b/user_guide/general/caching.html @@ -28,7 +28,7 @@
    - +

    CodeIgniter User Guide Version 2.0.0

    CodeIgniter User Guide Version 2.0.2

    @@ -68,7 +68,7 @@

    Web Page Caching

    How Does Caching Work?

    Caching can be enabled on a per-page basis, and you can set the length of time that a page should remain cached before being refreshed. -When a page is loaded for the first time, the cache file will be written to your system/cache folder. On subsequent page loads the cache file will be retrieved +When a page is loaded for the first time, the cache file will be written to your application/cache folder. On subsequent page loads the cache file will be retrieved and sent to the requesting user's browser. If it has expired, it will be deleted and refreshed before being sent to the browser.

    Note: The Benchmark tag is not cached so you can still view your page load speed when caching is enabled.

    @@ -86,7 +86,7 @@

    Enabling Caching

    Warning: Because of the way CodeIgniter stores content for output, caching will only work if you are generating display for your controller with a view.

    Note: Before the cache files can be written you must set the file permissions on your -system/cache folder such that it is writable.

    +application/cache folder such that it is writable.

    Deleting Caches

    @@ -108,7 +108,7 @@

    Deleting Caches

    User Guide Home   ·   Next Topic:  Profiling Your Application

    -

    CodeIgniter  ·  Copyright © 2006-2010  ·  EllisLab, Inc.

    +

    CodeIgniter  ·  Copyright © 2006 - 2011  ·  EllisLab, Inc.

    diff --git a/user_guide/general/cli.html b/user_guide/general/cli.html new file mode 100644 index 00000000..962954b1 --- /dev/null +++ b/user_guide/general/cli.html @@ -0,0 +1,150 @@ + + + + + +Running via the CLI : CodeIgniter User Guide + + + + + + + + + + + + + + + + + + + + + +
    + + + + + +

    CodeIgniter User Guide Version 2.0.2

    +
    + + + + + + + + + +
    + + +
    + + + +
    + +

    Running via the CLI

    + +

    + As well as calling an applications Controllers via the URL in a browser they can also be loaded via the command-line interface (CLI). +

    + + + + + + +

    What is the CLI?

    + +

    The command-line interface is a text-based method of interacting with computers that looks like what most people remember as DOS.

    + + + +

    Why run via the command-line?

    + +

    + There are many reasons for running CodeIgniter from the command-line, but they are not always obvious.

    + +
      +
    • Run your cron-jobs without needing to use wget or curl
    • +
    • Make your cron-jobs inaccessible from being loaded in the URL by checking for IS_CLI
    • +
    • Make interactive "tasks" that can do things like set permissions, prune cache folders, run backups, etc.
    • +
    • Integrate with other applications in other languages. For example, a random C++ script could call one command and run code in your models!
    • +
    + + +

    Let's try it:  Hello World!

    + +

    Let's create a simple controller so you can see it in action. Using your text editor, create a file called tools.php, and put the following code in it:

    + + + +

    Then save the file to your application/controllers/ folder.

    + +

    Now normally you would visit the your site using a URL similar to this:

    + +example.com/index.php/tools/message/to + +

    Instead, we are going to open Terminal in Mac/Lunix or go to Run > "cmd" in Windows and navigate to our CodeIgniter project.

    + +
    + $ cd /path/to/project;
    + $ php index.php tools message +
    + +

    If you did it right, you should see Hello World!.

    + +
    + $ php index.php tools message "John Smith" +
    + +

    Here we are passing it a argument in the same way that URL parameters work. "John Smith" is passed as a argument and output is: Hello John Smith!.

    + +

    That's it!

    + +

    That, in a nutshell, is all there is to know about controllers on the command line. Remember that this is just a normal controller, so routing and _remap works fine.

    + + + +
    + + + + + + + \ No newline at end of file diff --git a/user_guide/general/common_functions.html b/user_guide/general/common_functions.html index 0e68d111..bfac3268 100644 --- a/user_guide/general/common_functions.html +++ b/user_guide/general/common_functions.html @@ -28,7 +28,7 @@
    - +

    CodeIgniter User Guide Version 2.0.0

    CodeIgniter User Guide Version 2.0.2

    @@ -118,7 +118,7 @@

    remove_invisible_characters($str)

    Top of Page   ·   User Guide Home   ·   Next Topic:  URI Routing

    -

    CodeIgniter  ·  Copyright © 2006-2010  ·  EllisLab, Inc.

    +

    CodeIgniter  ·  Copyright © 2006 - 2011  ·  EllisLab, Inc.

    diff --git a/user_guide/general/controllers.html b/user_guide/general/controllers.html index 1d9cd032..c9091647 100644 --- a/user_guide/general/controllers.html +++ b/user_guide/general/controllers.html @@ -28,7 +28,7 @@
    - +

    CodeIgniter User Guide Version 2.0.0

    CodeIgniter User Guide Version 2.0.2

    @@ -98,7 +98,7 @@

    Let's try it:  Hello World!

    <?php class Blog extends CI_Controller { - function index() + public function index() { echo 'Hello World!'; } @@ -153,12 +153,12 @@

    Functions

    <?php class Blog extends CI_Controller { - function index() + public function index() { echo 'Hello World!'; } - function comments() + public function comments() { echo 'Look at this!'; } @@ -187,7 +187,7 @@

    Passing URI Segments to your Functions

    <?php
    class Products extends CI_Controller {

    -    function shoes($sandals, $id)
    +    public function shoes($sandals, $id)
        {
            echo $sandals;
            echo $id;
    @@ -220,7 +220,7 @@

    Remapping Function Calls

    As noted above, the second segment of the URI typically determines which function in the controller gets called. CodeIgniter permits you to override this behavior through the use of the _remap() function:

    -function _remap()
    +public function _remap()
    {
        // Some code here...
    }
    @@ -231,7 +231,7 @@

    Remapping Function Calls

    The overridden function call (typically the second segment of the URI) will be passed as a parameter to the _remap() function:

    -function _remap($method)
    +public function _remap($method)
    {
        if ($method == 'some_method')
        {
    @@ -243,9 +243,17 @@

    Remapping Function Calls

        }
    }
    -

    An array of leftover segments are passed into _remap() as an optional second parameter.

    - +

    Any extra segments after the method name are passed into _remap() as an optional second parameter. This array can be used in combination with PHP's call_user_func_array to emulate CodeIgniter's default behavior.

    +public function _remap($method, $params = array())
    +{
    +    $method = 'process_'.$method;
    +    if (method_exists($this, $method))
    +    {
    +        return call_user_func_array(array($this, $method), $params);
    +    }
    +    show_404();
    +}
    @@ -262,7 +270,7 @@

    Processing Output

    Here is an example:

    -function _output($output)
    +public function _output($output)
    {
        echo $output;
    }
    @@ -290,7 +298,7 @@

    Private Functions

    underscore as the name prefix and it will not be served via a URL request. For example, if you were to have a function like this:

    -function _utility()
    +private function _utility()
    {
      // some code
    }
    @@ -338,7 +346,7 @@

    Class Constructors

    <?php
    class Blog extends CI_Controller {

    -       function __construct()
    +       public function __construct()
           {
                parent::__construct();
                // Your own constructor code
    @@ -373,7 +381,7 @@

    That's it!

    Top of Page   ·   User Guide Home   ·   Next Topic:  Reserved Names

    -

    CodeIgniter  ·  Copyright © 2006-2010  ·  EllisLab, Inc.

    +

    CodeIgniter  ·  Copyright © 2006 - 2011  ·  EllisLab, Inc.

    diff --git a/user_guide/general/core_classes.html b/user_guide/general/core_classes.html index 35043d9c..51c2c744 100644 --- a/user_guide/general/core_classes.html +++ b/user_guide/general/core_classes.html @@ -28,7 +28,7 @@
    - +

    CodeIgniter User Guide Version 2.0.0

    CodeIgniter User Guide Version 2.0.2

    @@ -84,8 +84,8 @@

    System Class List

  • Log
  • Output
  • Router
  • -
  • Unicode
  • URI
  • +
  • Utf8
  • Replacing Core Classes

    @@ -179,7 +179,7 @@

    Setting Your Own Prefix

    User Guide Home   ·   Next Topic:  Hooks - Extending the Core

    -

    CodeIgniter  ·  Copyright © 2006-2010  ·  EllisLab, Inc.

    +

    CodeIgniter  ·  Copyright © 2006 - 2011  ·  EllisLab, Inc.

    diff --git a/user_guide/general/creating_drivers.html b/user_guide/general/creating_drivers.html index 920cc16c..a7594056 100644 --- a/user_guide/general/creating_drivers.html +++ b/user_guide/general/creating_drivers.html @@ -28,7 +28,7 @@
    - +

    CodeIgniter User Guide Version 2.0.0

    CodeIgniter User Guide Version 2.0.2

    @@ -93,7 +93,7 @@

    Driver Directory and File Structure

    User Guide Home   ·   Next Topic:  Creating Core System Classes

    -

    CodeIgniter  ·  Copyright © 2006-2010  ·  EllisLab, Inc.

    +

    CodeIgniter  ·  Copyright © 2006 - 2011  ·  EllisLab, Inc.

    diff --git a/user_guide/general/creating_libraries.html b/user_guide/general/creating_libraries.html index e700f30f..8198c18f 100644 --- a/user_guide/general/creating_libraries.html +++ b/user_guide/general/creating_libraries.html @@ -28,7 +28,7 @@
    - +

    CodeIgniter User Guide Version 2.0.0

    CodeIgniter User Guide Version 2.0.2

    @@ -101,11 +101,11 @@

    The Class File



    class Someclass {

    -    function some_function()
    +    public function some_function()
        {
        }
    }

    -?>
    +/* End of file Someclass.php */

    Using Your Class

    @@ -140,7 +140,7 @@

    Passing Parameters When Initializing Your Class


    class Someclass {

    -    function __construct($params)
    +    public function __construct($params)
        {
            // Do something with $params
        }
    @@ -243,7 +243,7 @@

    Extending Native Libraries

    class MY_Email extends CI_Email {

    -    function __construct()
    +    public function __construct()
        {
            parent::__construct();
        }
    @@ -286,7 +286,7 @@

    Setting Your Own Prefix

    User Guide Home   ·   Next Topic:  Using CodeIgniter Drivers

    -

    CodeIgniter  ·  Copyright © 2006-2010  ·  EllisLab, Inc.

    +

    CodeIgniter  ·  Copyright © 2006 - 2011  ·  EllisLab, Inc.

    diff --git a/user_guide/general/credits.html b/user_guide/general/credits.html index 5423d583..9e0fbac0 100644 --- a/user_guide/general/credits.html +++ b/user_guide/general/credits.html @@ -28,7 +28,7 @@
    - +

    CodeIgniter User Guide Version 2.0.0

    CodeIgniter User Guide Version 2.0.2

    @@ -62,7 +62,8 @@

    Credits

    world, with many of the class libraries, helpers, and sub-systems borrowed from the code-base of ExpressionEngine.

    -

    It is currently developed and maintained by the ExpressionEngine Development Team.

    +

    It is currently developed and maintained by the ExpressionEngine Development Team.
    +Bleeding edge development is spearheaded by the handpicked contributors of the Reactor Team.

    A hat tip goes to Ruby on Rails for inspiring us to create a PHP framework, and for bringing frameworks into the general consciousness of the web community.

    @@ -79,7 +80,7 @@

    Credits

    User Guide Home   ·   Next Topic:  Downloading CodeIgniter

    -

    CodeIgniter  ·  Copyright © 2006-2010  ·  EllisLab, Inc.

    +

    CodeIgniter  ·  Copyright © 2006 - 2011  ·  EllisLab, Inc.

    diff --git a/user_guide/general/drivers.html b/user_guide/general/drivers.html index 3163c11a..8dbeb93a 100644 --- a/user_guide/general/drivers.html +++ b/user_guide/general/drivers.html @@ -28,7 +28,7 @@
    - +

    CodeIgniter User Guide Version 2.0.0

    CodeIgniter User Guide Version 2.0.2

    @@ -97,7 +97,7 @@

    Creating Your Own Drivers

    User Guide Home   ·   Next Topic:  Creating Drivers

    -

    CodeIgniter  ·  Copyright © 2006-2010  ·  EllisLab, Inc.

    +

    CodeIgniter  ·  Copyright © 2006 - 2011  ·  EllisLab, Inc.

    diff --git a/user_guide/general/environments.html b/user_guide/general/environments.html new file mode 100644 index 00000000..175a1531 --- /dev/null +++ b/user_guide/general/environments.html @@ -0,0 +1,126 @@ + + + + + +Handling Multiple Environments : CodeIgniter User Guide + + + + + + + + + + + + + + + + + + + + + +
    + + + + + +

    CodeIgniter User Guide Version 2.0.2

    +
    + + + + + + + + + +
    + + +
    + + + +
    + +

    Handling Multiple Environments

    + +

    + Developers often desire different system behavior depending on whether + an application is running in a development or production + environment. For example, verbose error output is something that would + be useful while developing an application, but it may also pose a security issue when "live". +

    + +

    The ENVIRONMENT Constant

    + +

    + By default, CodeIgniter comes with the environment constant set to + 'development'. At the top of index.php, you will see: +

    + + +define('ENVIRONMENT', 'development'); + + +

    + In addition to affecting some basic framework behavior (see the next section), + you may use this constant in your own development to differentiate + between which environment you are running in. +

    + +

    Effects On Default Framework Behavior

    + +

    + There are some places in the CodeIgniter system where the ENVIRONMENT + constant is used. This section describes how default framework behavior is + affected. +

    + +

    Error Reporting

    + +

    + Setting the ENVIRONMENT constant to a value of 'development' will + cause all PHP errors to be rendered to the browser when they occur. Conversely, + setting the constant to 'production' will disable all error output. Disabling + error reporting in production is a good security practice. +

    + +

    Configuration Files

    + +

    + Optionally, you can have CodeIgniter load environment-specific + configuration files. This may be useful for managing things like differing API keys + across multiple environments. This is described in more detail in the + environment section of the Config Class documentation. +

    + +
    + + + + + + + \ No newline at end of file diff --git a/user_guide/general/errors.html b/user_guide/general/errors.html index 5bd5011a..58eff659 100644 --- a/user_guide/general/errors.html +++ b/user_guide/general/errors.html @@ -28,7 +28,7 @@
    - +

    CodeIgniter User Guide Version 2.0.0

    CodeIgniter User Guide Version 2.0.2

    @@ -115,7 +115,7 @@

    log_message('level', 'message')

    Note: In order for the log file to actually be written, the - "logs" folder must be writable. In addition, you must set the "threshold" for logging. + "logs" folder must be writable. In addition, you must set the "threshold" for logging in application/config/config.php. You might, for example, only want error messages to be logged, and not the other two types. If you set it to zero logging will be disabled.

    @@ -133,7 +133,7 @@

    log_message('level', 'message')

    User Guide Home   ·   Next Topic:  Page Caching

    -

    CodeIgniter  ·  Copyright © 2006-2010  ·  EllisLab, Inc.

    +

    CodeIgniter  ·  Copyright © 2006 - 2011  ·  EllisLab, Inc.

    diff --git a/user_guide/general/helpers.html b/user_guide/general/helpers.html index 98c0dca8..339a0df0 100644 --- a/user_guide/general/helpers.html +++ b/user_guide/general/helpers.html @@ -28,7 +28,7 @@
    - +

    CodeIgniter User Guide Version 2.0.0

    CodeIgniter User Guide Version 2.0.2

    @@ -178,7 +178,7 @@

    Now What?

    User Guide Home   ·   Next Topic:  Using Libraries

    -

    CodeIgniter  ·  Copyright © 2006-2010  ·  EllisLab, Inc.

    +

    CodeIgniter  ·  Copyright © 2006 - 2011  ·  EllisLab, Inc.

    diff --git a/user_guide/general/hooks.html b/user_guide/general/hooks.html index 0d87f3b2..11de4090 100644 --- a/user_guide/general/hooks.html +++ b/user_guide/general/hooks.html @@ -28,7 +28,7 @@
    - +

    CodeIgniter User Guide Version 2.0.0

    CodeIgniter User Guide Version 2.0.2

    @@ -158,7 +158,7 @@

    Hook Points

    User Guide Home   ·   Next Topic:  Auto-loading Resources

    -

    CodeIgniter  ·  Copyright © 2006-2010  ·  EllisLab, Inc.

    +

    CodeIgniter  ·  Copyright © 2006 - 2011  ·  EllisLab, Inc.

    diff --git a/user_guide/general/libraries.html b/user_guide/general/libraries.html index dc0d9b6c..ce367cde 100644 --- a/user_guide/general/libraries.html +++ b/user_guide/general/libraries.html @@ -28,7 +28,7 @@
    - +

    CodeIgniter User Guide Version 2.0.0

    CodeIgniter User Guide Version 2.0.2

    @@ -91,7 +91,7 @@

    Creating Your Own Libraries

    User Guide Home   ·   Next Topic:  Creating Libraries

    -

    CodeIgniter  ·  Copyright © 2006-2010  ·  EllisLab, Inc.

    +

    CodeIgniter  ·  Copyright © 2006 - 2011  ·  EllisLab, Inc.

    diff --git a/user_guide/general/managing_apps.html b/user_guide/general/managing_apps.html index a1a96cf8..ea886d9c 100644 --- a/user_guide/general/managing_apps.html +++ b/user_guide/general/managing_apps.html @@ -28,7 +28,7 @@
    - +

    CodeIgniter User Guide Version 2.0.0

    CodeIgniter User Guide Version 2.0.2

    @@ -126,7 +126,7 @@

    Running Multiple Applications with one CodeIgniter Installation

    User Guide Home   ·   Next Topic:  Alternative PHP Syntax

    -

    CodeIgniter  ·  Copyright © 2006-2010  ·  EllisLab, Inc.

    +

    CodeIgniter  ·  Copyright © 2006 - 2011  ·  EllisLab, Inc.

    diff --git a/user_guide/general/models.html b/user_guide/general/models.html index eb6962f0..117c810b 100644 --- a/user_guide/general/models.html +++ b/user_guide/general/models.html @@ -27,7 +27,7 @@
    - +

    CodeIgniter User Guide Version 2.0.0

    CodeIgniter User Guide Version 2.0.2

    @@ -244,7 +244,7 @@

    Connecting to your Database

    User Guide Home   ·   Next Topic:  Helpers

    -

    CodeIgniter  ·  Copyright © 2006-2010  ·  EllisLab, Inc.

    +

    CodeIgniter  ·  Copyright © 2006 - 2011  ·  EllisLab, Inc.

    diff --git a/user_guide/general/profiling.html b/user_guide/general/profiling.html index 7cb3f158..78ece7dc 100644 --- a/user_guide/general/profiling.html +++ b/user_guide/general/profiling.html @@ -28,7 +28,7 @@
    - +

    CodeIgniter User Guide Version 2.0.0

    CodeIgniter User Guide Version 2.0.2

    @@ -105,55 +105,60 @@

    Enabling and Disabling Profiler Sections

    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    KeyDescriptionDefault
    benchmarksElapsed time of Benchmark points and total execution timeTRUE
    configCodeIgniter Config variablesTRUE
    controller_infoThe Controller class and method requestedTRUE
    getAny GET data passed in the requestTRUE
    http_headersThe HTTP headers for the current requestTRUE
    memory_usageAmount of memory consumed by the current request, in bytesTRUE
    postAny POST data passed in the requestTRUE
    queriesListing of all database queries executed, including execution timeTRUE
    uri_stringThe URI of the current requestTRUE
    KeyDescriptionDefault
    benchmarksElapsed time of Benchmark points and total execution timeTRUE
    configCodeIgniter Config variablesTRUE
    controller_infoThe Controller class and method requestedTRUE
    getAny GET data passed in the requestTRUE
    http_headersThe HTTP headers for the current requestTRUE
    memory_usageAmount of memory consumed by the current request, in bytesTRUE
    postAny POST data passed in the requestTRUE
    queriesListing of all database queries executed, including execution timeTRUE
    uri_stringThe URI of the current requestTRUE
    query_toggle_countThe number of queries after which the query block will default to hidden.25
    @@ -169,7 +174,7 @@

    Enabling and Disabling Profiler Sections

    User Guide Home   ·   Next Topic:  Managing Applications

    -

    CodeIgniter  ·  Copyright © 2006-2010  ·  EllisLab, Inc.

    +

    CodeIgniter  ·  Copyright © 2006 - 2011  ·  EllisLab, Inc.

    diff --git a/user_guide/general/quick_reference.html b/user_guide/general/quick_reference.html index d90e9620..9273708f 100644 --- a/user_guide/general/quick_reference.html +++ b/user_guide/general/quick_reference.html @@ -28,7 +28,7 @@
    - +

    CodeIgniter User Guide Version 2.0.0

    CodeIgniter User Guide Version 2.0.2

    @@ -70,7 +70,7 @@

    Quick Reference Chart

    Top of Page   ·   User Guide Home

    -

    CodeIgniter  ·  Copyright © 2006-2010  ·  EllisLab, Inc.

    +

    CodeIgniter  ·  Copyright © 2006 - 2011  ·  EllisLab, Inc.

    diff --git a/user_guide/general/requirements.html b/user_guide/general/requirements.html index 6ae3da78..ab0e2885 100644 --- a/user_guide/general/requirements.html +++ b/user_guide/general/requirements.html @@ -28,7 +28,7 @@
    - +

    CodeIgniter User Guide Version 2.0.0

    CodeIgniter User Guide Version 2.0.2

    @@ -75,7 +75,7 @@

    Server Requirements

    User Guide Home   ·   Next Topic:  License Agreement

    -

    CodeIgniter  ·  Copyright © 2006-2010  ·  EllisLab, Inc.

    +

    CodeIgniter  ·  Copyright © 2006 - 2011  ·  EllisLab, Inc.

    diff --git a/user_guide/general/reserved_names.html b/user_guide/general/reserved_names.html index 3115d6a8..00bebff6 100644 --- a/user_guide/general/reserved_names.html +++ b/user_guide/general/reserved_names.html @@ -28,7 +28,7 @@
    - +

    CodeIgniter User Guide Version 2.0.0

    CodeIgniter User Guide Version 2.0.2

    @@ -90,6 +90,7 @@

    Variables

    Constants

    diff --git a/user_guide/general/routing.html b/user_guide/general/routing.html index a423eaa8..d1d8d1a8 100644 --- a/user_guide/general/routing.html +++ b/user_guide/general/routing.html @@ -28,7 +28,7 @@
    - +

    CodeIgniter User Guide Version 2.0.0

    CodeIgniter User Guide Version 2.0.2

    @@ -145,6 +145,11 @@

    Reserved Routes

    when people load your root URL. In the above example, the "welcome" class would be loaded. You are encouraged to always have a default route otherwise a 404 page will appear by default.

    +$route['404_override'] = ''; + +

    This route indicates which controller class should be loaded if the requested controller is not found. It will override the default 404 +error page. It won't affect to the show_404() function, which will continue loading the default error_404.php file at application/errors/error_404.php.

    +

    Important:  The reserved routes must come before any wildcard or regular expression routes.

    @@ -159,7 +164,7 @@

    Reserved Routes

    User Guide Home   ·   Next Topic:  Error Handling

    -

    CodeIgniter  ·  Copyright © 2006-2010  ·  EllisLab, Inc.

    +

    CodeIgniter  ·  Copyright © 2006 - 2011  ·  EllisLab, Inc.

    - +

    CodeIgniter User Guide Version 2.0.0

    CodeIgniter User Guide Version 2.0.2

    @@ -57,9 +57,141 @@

    Change Log

    +

    The Reactor Marker indicates items that were contributed to CodeIgniter via CodeIgniter Reactor.

    + +

    Version 2.0.3

    +

    Release Date: Not Released

    + +
    + +

    Bug fixes for 2.0.3

    +
      +
    • Added ENVIRONMENT to reserved constants. (Reactor #196)
    • +
    • Changed server check to ensure SCRIPT_NAME is defined. (Reactor #57)
    • +
    • Removed APPPATH.'third_party' from the packages autoloader to negate needless file stats if no packages exist or if the developer does not load any other packages by default.
    • +
    • Fixed a bug (Reactor #231) where Sessions Library database table example SQL did not contain an index on last_activity. See Upgrade Notes.
    • +
    • Fixed a bug (Reactor #229) where the Sessions Library example SQL in the documentation contained incorrect SQL.
    • +
    • Fixed a bug (Core #340) where when passing in the second parameter to $this->db->select(), column names in subsequent queries would not be properly escaped.
    • +
    • Fixed a bug where the method $this->cart->total_items() from Cart Library now returns the sum of the quantity of all items in the cart instead of your total count.
    • +
    • Fixed a bug where not setting 'null' when adding fields in db_forge for mysql and mysqli drivers would default to NULL instead of NOT NULL as the docs suggest.
    • +
    • Fixed a bug (Reactor #19) where 1) the 404_override route was being ignored in some cases, and 2) auto-loaded libraries were not available to the 404_override controller when a controller existed but the requested method did not.
    • +
    + +

    Version 2.0.2

    +

    Release Date: April 7, 2011
    +Hg Tag: v2.0.2

    + +
      +
    • General changes +
        +
      • The Security library was moved to the core and is now loaded automatically. Please remove your loading calls.
      • +
      • The CI_SHA class is now deprecated. All supported versions of PHP provide a sha1() function.
      • +
      • constants.php will now be loaded from the environment folder if available.
      • +
      • Added language key error logging
      • +
      • Made Environment Support optional. Comment out or delete the constant to stop environment checks.
      • +
      • Added Environment Support for Hooks.
      • +
      • Added CI_ Prefix to the Cache driver.
      • +
      • Added CLI usage documentation.
      • +
      +
    • +
    • Helpers +
        +
      • Removed the previously deprecated dohash() from the Security helper; use do_hash() instead.
      • +
      • Changed the 'plural' function so that it doesn't ruin the captalization of your string. It also take into consideration acronyms which are all caps.
      • +
      +
    • +
    • Database +
        +
      • $this->db->count_all_results() will now return an integer instead of a string.
      • +
      +
    • +
    + +

    Bug fixes for 2.0.2

    +
      +
    • Fixed a bug (Reactor #145) where the Output Library had parse_exec_vars set to protected.
    • +
    • Fixed a bug (Reactor #80) where is_really_writable would create an empty file when on Windows or with safe_mode enabled.
    • +
    • Fixed various bugs with User Guide.
    • +
    • Added is_cli_request() method to documentation for Input class.
    • +
    • Added form_validation_lang entries for decimal, less_than and greater_than.
    • +
    • Fixed issue #153 Escape Str Bug in MSSQL driver.
    • +
    • Fixed issue #172 Google Chrome 11 posts incorrectly when action is empty.
    • + +
    + +

    Version 2.0.1

    +

    Release Date: March 15, 2011
    +Hg Tag: v2.0.1

    + +
      +
    • General changes +
        +
      • Added $config['cookie_secure'] to the config file to allow requiring a secure (HTTPS) in order to set cookies.
      • +
      • Added the constant CI_CORE to help differentiate between Core: TRUE and Reactor: FALSE.
      • +
      • Added an ENVIRONMENT constant in index.php, which affects PHP error reporting settings, and optionally, + which configuration files are loaded (see below). Read more on the Handling Environments page.
      • +
      • Added support for environment-specific configuration files.
      • +
      +
    • +
    • Libraries +
        +
      • Added decimal, less_than and greater_than rules to the Form validation Class.
      • +
      • Input Class methods post() and get() will now return a full array if the first argument is not provided.
      • +
      • Secure cookies can now be made with the set_cookie() helper and Input Class method.
      • +
      • Added set_content_type() to Output Class to set the output Content-Type HTTP header based on a MIME Type or a config/mimes.php array key.
      • +
      • Output Class will now support method chaining.
      • +
      +
    • +
    • Helpers +
        +
      • Changed the logic for form_open() in Form helper. If no value is passed it will submit to the current URL.
      • +
      +
    • +
    + +

    Bug fixes for 2.0.1

    +
      +
    • CLI requests can now be run from any folder, not just when CD'ed next to index.php.
    • +
    • 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.
    • +
    +

    Version 2.0.0

    -

    Release Date: not yet released
    -Hg Tag:

    +

    Release Date: January 28, 2011
    +Hg Tag: v2.0.0

    • General changes @@ -68,21 +200,25 @@

      Version 2.0.0

    • Scaffolding, having been deprecated for a number of versions, has been removed.
    • Plugins have been removed, in favor of Helpers. The CAPTCHA plugin has been converted to a Helper and documented. The JavaScript calendar plugin was removed due to the ready availability of great JavaScript calendars, particularly with jQuery.
    • Added new special Library type: Drivers.
    • +
    • Added full query-string support. See the config file for details.
    • Moved the application folder outside of the system folder.
    • +
    • Moved system/cache and system/logs directories to the application directory.
    • Added routing overrides to the main index.php file, enabling the normal routing to be overridden on a per "index" file basis.
    • Added the ability to set config values (or override config values) directly from data set in the main index.php file. This allows a single application to be used with multiple front controllers, each having its own config values.
    • Added $config['directory_trigger'] to the config file so that a controller sub-directory can be specified when running _GET strings instead of URI segments.
    • Added ability to set "Package" paths - specific paths where the Loader and Config classes should try to look first for a requested file. This allows distribution of sub-applications with their own libraries, models, config files, etc. in a single "package" directory. See the Loader class documentation for more details.
    • -
    • In-development code is now hosted at BitBucket.
    • +
    • In-development code is now hosted at BitBucket.
    • Removed the deprecated Validation Class.
    • Added CI_ Prefix to all core classes.
    • -
    • Package paths can now be set in application/config/autoload.php.
    • -
    • Upload library file_name can now be set without an extension, the extension will be taken from the uploaded file instead of the given name.
    • -
    • Name can be omitted from $this->dbforge->modify_column()'s 2nd param if you aren't changing the name.
    • -
    • $config['base_url'] is now empty by default and will guess what it should be.
    • +
    • Package paths can now be set in application/config/autoload.php.
    • +
    • Upload library file_name can now be set without an extension, the extension will be taken from the uploaded file instead of the given name.
    • +
    • In Database Forge the name can be omitted from $this->dbforge->modify_column()'s 2nd param if you aren't changing the name.
    • +
    • $config['base_url'] is now empty by default and will guess what it should be.
    • +
    • Enabled full Command Line Interface compatibility with config['uri_protocol'] = 'CLI';.
  • Libraries
      +
    • Added a Cache driver with APC, memcached, and file-based support.
    • Added $prefix, $suffix and $first_url properties to Pagination library.
    • Added the ability to suppress first, previous, next, last, and page links by setting their values to FALSE in the Pagination library.
    • Added Security library, which now contains the xss_clean function, filename_security function and other security related functions.
    • @@ -113,12 +249,13 @@

      Version 2.0.0

    • Altered Form_Validation library to allow for method chaining on set_rules(), set_message() and set_error_delimiters() functions.
    • Altered Email Library to allow for method chaining.
    • Added request_headers(), get_request_header() and is_ajax_request() to the input class.
    • -
    • Altered User agent library so that is_browser(), is_mobile() and is_robot() can optionally check for a specific browser or mobile device.
    • +
    • Altered User agent library so that is_browser(), is_mobile() and is_robot() can optionally check for a specific browser or mobile device.
    • +
    • Altered Input library so that post() and get() will return all POST and GET items (respectively) if there are no parameters passed in.
  • Database
      -
    • Added swap_pre value to database configuration.
    • +
    • database configuration.
    • Added autoinit value to database configuration.
    • Added stricton value to database configuration.
    • Added database_exists() to the Database Utilities Class.
    • @@ -128,6 +265,7 @@

      Version 2.0.0

    • Modified the database errors to show the filename and line number of the problematic query.
    • Removed the following deprecated functions: orwhere, orlike, groupby, orhaving, orderby, getwhere.
    • Removed deprecated _drop_database() and _create_database() functions from the db utility drivers.
    • +
    • Improved dbforge create_table() function for the Postgres driver.
  • Helpers @@ -165,14 +303,16 @@

    Version 2.0.0

  • Documented append_output() in the Output Class.
  • Documented a second argument in the decode() function for the Encryption Class.
  • Documented db->close().
  • +
  • Updated the router to support a default route with any number of segments.
  • Moved _remove_invisible_characters() function from the Security Library to common functions.
  • +
  • Added audio/mpeg3 as a valid mime type for MP3.
  • Bug fixes for 2.0.0

      -
    • Fixed a bug where you could not change the User-Agent when sending email.
    • +
    • Fixed a bug where you could not change the User-Agent when sending email.
    • Fixed a bug where the Output class would send incorrect cached output for controllers implementing their own _output() method.
    • Fixed a bug where a failed query would not have a saved query execution time causing errors in the Profiler
    • Fixed a bug that was writing log entries when multiple identical helpers and plugins were loaded.
    • @@ -200,6 +340,8 @@

      Bug fixes for 2.0.0

    • Added a log message in core/output if the cache directory config value was not found.
    • Fixed a bug where multiple libraries could not be loaded by passing an array to load->library()
    • Fixed a bug in the html helper where too much white space was rendered between the src and alt tags in the img() function.
    • +
    • Fixed a bug in the profilers _compile_queries() function.
    • +
    • Fixed a bug in the date helper where the DATE_ISO8601 variable was returning an incorrectly formatted date string.

    Version 1.7.2

    @@ -1215,7 +1357,7 @@

    Version Beta 1.0

    User Guide Home   ·   Next Topic:  Credits

    -

    CodeIgniter  ·  Copyright © 2006-2010  ·  EllisLab, Inc.

    +

    CodeIgniter  ·  Copyright © 2006 - 2011  ·  EllisLab, Inc.

    diff --git a/user_guide/general/security.html b/user_guide/general/security.html index 1a0ed13f..0609afc4 100644 --- a/user_guide/general/security.html +++ b/user_guide/general/security.html @@ -28,7 +28,7 @@
    - +

    CodeIgniter User Guide Version 2.0.0

    CodeIgniter User Guide Version 2.0.2

    @@ -76,17 +76,28 @@

    URI Security

  • Dash: -
  • -

    GET, POST, and COOKIE Data

    - -

    GET data is simply disallowed by CodeIgniter since the system utilizes URI segments rather than traditional URL query strings (unless -you have the query string option enabled in your config file). The global GET -array is unset by the Input class during system initialization.

    -

    Register_globals

    -

    During system initialization all global variables are unset, except those found in the $_POST and $_COOKIE arrays. The unsetting +

    During system initialization all global variables are unset, except those found in the $_GET, $_POST, and $_COOKIE arrays. The unsetting routine is effectively the same as register_globals = off.

    + +

    error_reporting

    + +

    + In production environments, it is typically desirable to disable PHP's + error reporting by setting the internal error_reporting flag to a value of 0. This disables native PHP + errors from being rendered as output, which may potentially contain + sensitive information. +

    + +

    + Setting CodeIgniter's ENVIRONMENT constant in index.php to a + value of 'production' will turn off these errors. In development + mode, it is recommended that a value of 'development' is used. + More information about differentiating between environments can be found + on the Handling Environments page. +

    magic_quotes_runtime

    @@ -146,7 +157,7 @@

    Best Practices

    User Guide Home   ·   Next Topic:  PHP Style Guide

    -

    CodeIgniter  ·  Copyright © 2006-2010  ·  EllisLab, Inc.

    +

    CodeIgniter  ·  Copyright © 2006 - 2011  ·  EllisLab, Inc.

    diff --git a/user_guide/general/styleguide.html b/user_guide/general/styleguide.html index f30f4552..1f7a8a04 100644 --- a/user_guide/general/styleguide.html +++ b/user_guide/general/styleguide.html @@ -34,7 +34,7 @@
    - +

    CodeIgniter User Guide Version 2.0.0

    CodeIgniter User Guide Version 2.0.2

    @@ -381,7 +381,7 @@

    Whitespace in Files

    Compatibility

    -

    Unless specifically mentioned in your add-on's documentation, all code must be compatible with PHP version 4.3+. Additionally, do not use PHP functions that require non-default libraries to be installed unless your code contains an alternative method when the function is not available, or you implicitly document that your add-on requires said PHP libraries.

    +

    Unless specifically mentioned in your add-on's documentation, all code must be compatible with PHP version 5.1+. Additionally, do not use PHP functions that require non-default libraries to be installed unless your code contains an alternative method when the function is not available, or you implicitly document that your add-on requires said PHP libraries.

    @@ -672,7 +672,7 @@

    Default Function Arguments

    User Guide Home   ·   Next Topic:  Writing Documentation

    -

    CodeIgniter  ·  Copyright © 2006-2010  ·  EllisLab, Inc.

    +

    CodeIgniter  ·  Copyright © 2006 - 2011  ·  EllisLab, Inc.

    diff --git a/user_guide/general/urls.html b/user_guide/general/urls.html index abddea83..421f5130 100644 --- a/user_guide/general/urls.html +++ b/user_guide/general/urls.html @@ -28,7 +28,7 @@
    - +

    CodeIgniter User Guide Version 2.0.0

    CodeIgniter User Guide Version 2.0.2

    @@ -144,7 +144,7 @@

    Enabling Query Strings

    Top of Page   ·   User Guide Home   ·   Next Topic:  Controllers

    -

    CodeIgniter  ·  Copyright © 2006-2010  ·  EllisLab, Inc.

    +

    CodeIgniter  ·  Copyright © 2006 - 2011  ·  EllisLab, Inc.

    diff --git a/user_guide/general/views.html b/user_guide/general/views.html index 228eb64b..ad93f4bc 100644 --- a/user_guide/general/views.html +++ b/user_guide/general/views.html @@ -28,7 +28,7 @@
    - +

    CodeIgniter User Guide Version 2.0.0

    CodeIgniter User Guide Version 2.0.2

    @@ -233,7 +233,7 @@

    Creating Loops

    <h3>My Todo List</h3> <ul> -<?php foreach($todo_list as $item):?> +<?php foreach ($todo_list as $item):?> <li><?php echo $item;?></li> @@ -267,7 +267,7 @@

    Returning views as data

    User Guide Home   ·   Next Topic:  Models

    -

    CodeIgniter  ·  Copyright © 2006-2010  ·  EllisLab, Inc.

    +

    CodeIgniter  ·  Copyright © 2006 - 2011  ·  EllisLab, Inc.

    diff --git a/user_guide/helpers/array_helper.html b/user_guide/helpers/array_helper.html index 6d95c4a5..51c7ab51 100644 --- a/user_guide/helpers/array_helper.html +++ b/user_guide/helpers/array_helper.html @@ -28,7 +28,7 @@
    - +

    CodeIgniter User Guide Version 2.0.0

    CodeIgniter User Guide Version 2.0.2

    @@ -159,11 +159,11 @@

    elements()

    diff --git a/user_guide/helpers/captcha_helper.html b/user_guide/helpers/captcha_helper.html index d6eb0652..95ed672f 100644 --- a/user_guide/helpers/captcha_helper.html +++ b/user_guide/helpers/captcha_helper.html @@ -28,7 +28,7 @@
    - +

    CodeIgniter User Guide Version 2.0.0

    CodeIgniter User Guide Version 2.0.2

    @@ -68,7 +68,7 @@

    Loading this Helper

    The following functions are available:

    -

    captcha_create($data)

    +

    create_captcha($data)

    Takes an array of information to generate the CAPTCHA as input and creates the image to your specifications, returning an array of associative data about the image.

    @@ -167,7 +167,7 @@

    Adding a Database

    $this->db->query("DELETE FROM captcha WHERE captcha_time < ".$expiration);

    // Then see if a captcha exists:
    -$sql = "SELECT COUNT(*) AS count FROM captcha WHERE word = ? AND ip_address = ? AND date > ?";
    +$sql = "SELECT COUNT(*) AS count FROM captcha WHERE word = ? AND ip_address = ? AND captcha_time > ?";
    $binds = array($_POST['captcha'], $this->input->ip_address(), $expiration);
    $query = $this->db->query($sql, $binds);
    $row = $query->row();
    @@ -183,12 +183,12 @@

    Adding a Database

    diff --git a/user_guide/helpers/cookie_helper.html b/user_guide/helpers/cookie_helper.html index d0471d71..45386314 100644 --- a/user_guide/helpers/cookie_helper.html +++ b/user_guide/helpers/cookie_helper.html @@ -28,7 +28,7 @@
    - +

    CodeIgniter User Guide Version 2.0.0

    CodeIgniter User Guide Version 2.0.2

    @@ -95,12 +95,12 @@

    delete_cookie()

    diff --git a/user_guide/helpers/date_helper.html b/user_guide/helpers/date_helper.html index f8775b14..44096ff4 100644 --- a/user_guide/helpers/date_helper.html +++ b/user_guide/helpers/date_helper.html @@ -28,7 +28,7 @@
    - +

    CodeIgniter User Guide Version 2.0.0

    CodeIgniter User Guide Version 2.0.2

    @@ -129,12 +129,12 @@

    standard_date()

    DATE_ISO8601 ISO-8601 - 2005-08-14T16:13:03+0000 + 2005-08-14T16:13:03+00:00 DATE_RFC822 RFC 822 - Sun, 14 Aug 2005 16:13:03 UTC + Sun, 14 Aug 05 16:13:03 UTC DATE_RFC850 @@ -401,7 +401,7 @@

    Timezone Reference

    User Guide Home   ·   Next Topic:  Directory Helper

    -

    CodeIgniter  ·  Copyright © 2006-2010  ·  EllisLab, Inc.

    +

    CodeIgniter  ·  Copyright © 2006 - 2011  ·  EllisLab, Inc.

    diff --git a/user_guide/helpers/directory_helper.html b/user_guide/helpers/directory_helper.html index 6e4faef0..1a2f28d7 100644 --- a/user_guide/helpers/directory_helper.html +++ b/user_guide/helpers/directory_helper.html @@ -28,7 +28,7 @@
    - +

    CodeIgniter User Guide Version 2.0.0

    CodeIgniter User Guide Version 2.0.2

    @@ -136,7 +136,7 @@

    directory_map('source directory')

    User Guide Home   ·   Next Topic:  Download Helper

    -

    CodeIgniter  ·  Copyright © 2006-2010  ·  EllisLab, Inc.

    +

    CodeIgniter  ·  Copyright © 2006 - 2011  ·  EllisLab, Inc.

    diff --git a/user_guide/helpers/download_helper.html b/user_guide/helpers/download_helper.html index 4c0e2017..335e97d3 100644 --- a/user_guide/helpers/download_helper.html +++ b/user_guide/helpers/download_helper.html @@ -28,7 +28,7 @@
    - +

    CodeIgniter User Guide Version 2.0.0

    CodeIgniter User Guide Version 2.0.2

    @@ -105,7 +105,7 @@

    force_download('filename', 'data')

    Top of Page   ·   User Guide Home   ·   Next Topic:  Email Helper

    -

    CodeIgniter  ·  Copyright © 2006-2010  ·  EllisLab, Inc.

    +

    CodeIgniter  ·  Copyright © 2006 - 2011  ·  EllisLab, Inc.

    diff --git a/user_guide/helpers/email_helper.html b/user_guide/helpers/email_helper.html index 0084ada1..8a3868a7 100644 --- a/user_guide/helpers/email_helper.html +++ b/user_guide/helpers/email_helper.html @@ -28,7 +28,7 @@
    - +

    CodeIgniter User Guide Version 2.0.0

    CodeIgniter User Guide Version 2.0.2

    @@ -95,7 +95,7 @@

    send_email('recipient', 'subject', 'message Top of Page   ·   User Guide Home   ·   Next Topic:  File Helper

    -

    CodeIgniter  ·  Copyright © 2006-2010  ·  EllisLab, Inc.

    +

    CodeIgniter  ·  Copyright © 2006 - 2011  ·  EllisLab, Inc.

    diff --git a/user_guide/helpers/file_helper.html b/user_guide/helpers/file_helper.html index dd9df954..c3723542 100644 --- a/user_guide/helpers/file_helper.html +++ b/user_guide/helpers/file_helper.html @@ -27,7 +27,7 @@
    - +

    CodeIgniter User Guide Version 2.0.0

    CodeIgniter User Guide Version 2.0.2

    @@ -172,7 +172,7 @@

    octal_permissions($perms)

    Top of Page   ·   User Guide Home   ·   Next Topic:  Form Helper

    -

    CodeIgniter  ·  Copyright © 2006-2010  ·  EllisLab, Inc.

    +

    CodeIgniter  ·  Copyright © 2006 - 2011  ·  EllisLab, Inc.

    diff --git a/user_guide/helpers/form_helper.html b/user_guide/helpers/form_helper.html index 0aaa8f60..87e3c28b 100644 --- a/user_guide/helpers/form_helper.html +++ b/user_guide/helpers/form_helper.html @@ -28,7 +28,7 @@
    - +

    CodeIgniter User Guide Version 2.0.0

    CodeIgniter User Guide Version 2.0.2

    @@ -281,7 +281,7 @@

    form_fieldset_close()

    which will be added below the tag. For example:

    $string = "</div></div>";

    -echo fieldset_close($string);
    +echo form_fieldset_close($string);

    // Would produce:
    </fieldset>
    @@ -477,7 +477,7 @@

    set_radio()

    User Guide Home   ·   Next Topic:  HTML Helper

    -

    CodeIgniter  ·  Copyright © 2006-2010  ·  EllisLab, Inc.

    +

    CodeIgniter  ·  Copyright © 2006 - 2011  ·  EllisLab, Inc.

    diff --git a/user_guide/helpers/html_helper.html b/user_guide/helpers/html_helper.html index 845ecf10..308013d5 100644 --- a/user_guide/helpers/html_helper.html +++ b/user_guide/helpers/html_helper.html @@ -28,7 +28,7 @@
    - +

    CodeIgniter User Guide Version 2.0.0

    CodeIgniter User Guide Version 2.0.2

    @@ -89,6 +89,11 @@

    heading()

    echo heading('Welcome!', 3);

    The above would produce: <h3>Welcome!</h3>

    +

    Additionally, in order to add attributes to the heading tag such as HTML classes, ids or inline styles, a third parameter is available.

    +echo heading('Welcome!', 3, 'class="pink"') +

    The above code produces: <h3 class="pink">Welcome!<<h3>

    + +

    img()

    Lets you create HTML <img /> tags. The first parameter contains the image source. Example:

    echo img('images/picture.jpg');
    @@ -378,7 +383,7 @@

    doctype()

    Top of Page   ·   User Guide Home   ·   Next Topic:   Path Helper

    -

    CodeIgniter  ·  Copyright © 2006-2010  ·  EllisLab, Inc.

    +

    CodeIgniter  ·  Copyright © 2006 - 2011  ·  EllisLab, Inc.

    diff --git a/user_guide/helpers/inflector_helper.html b/user_guide/helpers/inflector_helper.html index 9dcd1fc7..221c0590 100644 --- a/user_guide/helpers/inflector_helper.html +++ b/user_guide/helpers/inflector_helper.html @@ -28,7 +28,7 @@
    - +

    CodeIgniter User Guide Version 2.0.0

    CodeIgniter User Guide Version 2.0.2

    @@ -144,7 +144,7 @@

    humanize()

    User Guide Home   ·   Next Topic:  Number Helper

    -

    CodeIgniter  ·  Copyright © 2006-2010  ·  EllisLab, Inc.

    +

    CodeIgniter  ·  Copyright © 2006 - 2011  ·  EllisLab, Inc.

    diff --git a/user_guide/helpers/language_helper.html b/user_guide/helpers/language_helper.html index ada6c60e..3b3b87da 100644 --- a/user_guide/helpers/language_helper.html +++ b/user_guide/helpers/language_helper.html @@ -28,7 +28,7 @@
    - +

    CodeIgniter User Guide Version 2.0.0

    CodeIgniter User Guide Version 2.0.2

    @@ -91,7 +91,7 @@

    lang('language line', 'element id')

    User Guide Home   ·   Next Topic:  Download Helper

    -

    CodeIgniter  ·  Copyright © 2006-2010  ·  EllisLab, Inc.

    +

    CodeIgniter  ·  Copyright © 2006 - 2011  ·  EllisLab, Inc.

    diff --git a/user_guide/helpers/number_helper.html b/user_guide/helpers/number_helper.html index 9274e0cf..51a4521a 100644 --- a/user_guide/helpers/number_helper.html +++ b/user_guide/helpers/number_helper.html @@ -28,7 +28,7 @@
    - +

    CodeIgniter User Guide Version 2.0.0

    CodeIgniter User Guide Version 2.0.2

    @@ -106,7 +106,7 @@

    byte_format()

    User Guide Home   ·   Next Topic:  Path Helper

    -

    CodeIgniter  ·  Copyright © 2006-2010  ·  EllisLab, Inc.

    +

    CodeIgniter  ·  Copyright © 2006 - 2011  ·  EllisLab, Inc.

    diff --git a/user_guide/helpers/path_helper.html b/user_guide/helpers/path_helper.html index c1d7b020..584a127f 100644 --- a/user_guide/helpers/path_helper.html +++ b/user_guide/helpers/path_helper.html @@ -27,7 +27,7 @@
    - +

    CodeIgniter User Guide Version 2.0.0

    CodeIgniter User Guide Version 2.0.2

    @@ -99,7 +99,7 @@

     

    User Guide Home   ·   Next Topic:  Security Helper

    -

    CodeIgniter  ·  Copyright © 2006-2010  ·  EllisLab, Inc.

    +

    CodeIgniter  ·  Copyright © 2006 - 2011  ·  EllisLab, Inc.

    diff --git a/user_guide/helpers/security_helper.html b/user_guide/helpers/security_helper.html index f74a7766..e0cace32 100644 --- a/user_guide/helpers/security_helper.html +++ b/user_guide/helpers/security_helper.html @@ -28,7 +28,7 @@
    - +

    CodeIgniter User Guide Version 2.0.0

    CodeIgniter User Guide Version 2.0.2

    @@ -125,7 +125,7 @@

    encode_php_tags()

    Top of Page   ·   User Guide Home   ·   Next Topic:  Smiley Helper

    -

    CodeIgniter  ·  Copyright © 2006-2010  ·  EllisLab, Inc.

    +

    CodeIgniter  ·  Copyright © 2006 - 2011  ·  EllisLab, Inc.

    diff --git a/user_guide/helpers/smiley_helper.html b/user_guide/helpers/smiley_helper.html index 6846b78e..408df17c 100644 --- a/user_guide/helpers/smiley_helper.html +++ b/user_guide/helpers/smiley_helper.html @@ -28,7 +28,7 @@
    - +

    CodeIgniter User Guide Version 2.0.0

    CodeIgniter User Guide Version 2.0.2

    @@ -208,7 +208,7 @@

    parse_smileys()

    User Guide Home   ·   Next Topic:  String Helper

    -

    CodeIgniter  ·  Copyright © 2006-2010  ·  EllisLab, Inc.

    +

    CodeIgniter  ·  Copyright © 2006 - 2011  ·  EllisLab, Inc.

    diff --git a/user_guide/helpers/string_helper.html b/user_guide/helpers/string_helper.html index d3f97fb5..169ee4eb 100644 --- a/user_guide/helpers/string_helper.html +++ b/user_guide/helpers/string_helper.html @@ -28,7 +28,7 @@
    - +

    CodeIgniter User Guide Version 2.0.0

    CodeIgniter User Guide Version 2.0.2

    @@ -171,7 +171,7 @@

    strip_quotes()

    User Guide Home   ·   Next Topic:  Text Helper

    -

    CodeIgniter  ·  Copyright © 2006-2010  ·  EllisLab, Inc.

    +

    CodeIgniter  ·  Copyright © 2006 - 2011  ·  EllisLab, Inc.

    diff --git a/user_guide/helpers/text_helper.html b/user_guide/helpers/text_helper.html index 6a68180b..f71d8784 100644 --- a/user_guide/helpers/text_helper.html +++ b/user_guide/helpers/text_helper.html @@ -28,7 +28,7 @@
    - +

    CodeIgniter User Guide Version 2.0.0

    CodeIgniter User Guide Version 2.0.2

    @@ -204,7 +204,7 @@

    ellipsize()

    User Guide Home   ·   Next Topic:  Typography Helper

    -

    CodeIgniter  ·  Copyright © 2006-2010  ·  EllisLab, Inc.

    +

    CodeIgniter  ·  Copyright © 2006 - 2011  ·  EllisLab, Inc.

    diff --git a/user_guide/helpers/typography_helper.html b/user_guide/helpers/typography_helper.html index 96a68e9f..00686a34 100644 --- a/user_guide/helpers/typography_helper.html +++ b/user_guide/helpers/typography_helper.html @@ -28,7 +28,7 @@
    - +

    CodeIgniter User Guide Version 2.0.0

    CodeIgniter User Guide Version 2.0.2

    @@ -105,7 +105,7 @@

    nl2br_except_pre()

    User Guide Home   ·   Next Topic:  URL Helper

    -

    CodeIgniter  ·  Copyright © 2006-2010  ·  EllisLab, Inc.

    +

    CodeIgniter  ·  Copyright © 2006 - 2011  ·  EllisLab, Inc.

    diff --git a/user_guide/helpers/url_helper.html b/user_guide/helpers/url_helper.html index 5b478024..d20f1b1e 100644 --- a/user_guide/helpers/url_helper.html +++ b/user_guide/helpers/url_helper.html @@ -27,7 +27,7 @@
    - +

    CodeIgniter User Guide Version 2.0.0

    CodeIgniter User Guide Version 2.0.2

    @@ -281,7 +281,7 @@

    redirect()

    User Guide Home   ·   Next Topic:  XML Helper

    -

    CodeIgniter  ·  Copyright © 2006-2010  ·  EllisLab, Inc.

    +

    CodeIgniter  ·  Copyright © 2006 - 2011  ·  EllisLab, Inc.

    diff --git a/user_guide/helpers/xml_helper.html b/user_guide/helpers/xml_helper.html index 50179ce4..ded9aaa3 100644 --- a/user_guide/helpers/xml_helper.html +++ b/user_guide/helpers/xml_helper.html @@ -28,7 +28,7 @@
    - +

    CodeIgniter User Guide Version 2.0.0

    CodeIgniter User Guide Version 2.0.2

    @@ -98,7 +98,7 @@

    xml_convert('string')

    Top of Page   ·   User Guide Home

    -

    CodeIgniter  ·  Copyright © 2006-2010  ·  EllisLab, Inc.

    +

    CodeIgniter  ·  Copyright © 2006 - 2011  ·  EllisLab, Inc.

    diff --git a/user_guide/images/appflowchart.gif b/user_guide/images/appflowchart.gif index 422332c9..4328e48f 100644 Binary files a/user_guide/images/appflowchart.gif and b/user_guide/images/appflowchart.gif differ diff --git a/user_guide/images/reactor-bullet.png b/user_guide/images/reactor-bullet.png new file mode 100755 index 00000000..89c8129a Binary files /dev/null and b/user_guide/images/reactor-bullet.png differ diff --git a/user_guide/index.html b/user_guide/index.html index a1d56d48..2681004e 100644 --- a/user_guide/index.html +++ b/user_guide/index.html @@ -28,7 +28,7 @@
    - +

    CodeIgniter User Guide Version 2.0.0

    CodeIgniter User Guide Version 2.0.2

    @@ -90,7 +90,7 @@

    Who is CodeIgniter For?

    diff --git a/user_guide/installation/downloads.html b/user_guide/installation/downloads.html index f557a788..f452ba47 100644 --- a/user_guide/installation/downloads.html +++ b/user_guide/installation/downloads.html @@ -28,7 +28,7 @@
    - +

    CodeIgniter User Guide Version 2.0.0

    CodeIgniter User Guide Version 2.0.2

    @@ -58,25 +58,29 @@

    Downloading CodeIgniter

    @@ -85,7 +89,7 @@

    Downloading CodeIgniter

    Mercurial Server

    Mercurial is a distributed version control system.

    -

    Public Hg access is available at BitBucket. +

    Public Hg access is available at BitBucket. Please note that while every effort is made to keep this code base functional, we cannot guarantee the functionality of code taken from the tip.

    @@ -102,7 +106,7 @@

    Mercurial Server

    User Guide Home   ·   Next Topic:  Installation Instructions

    -

    CodeIgniter  ·  Copyright © 2006-2010  ·  EllisLab, Inc.

    +

    CodeIgniter  ·  Copyright © 2006 - 2011  ·  EllisLab, Inc.

    diff --git a/user_guide/installation/index.html b/user_guide/installation/index.html index 973d2106..87da5189 100644 --- a/user_guide/installation/index.html +++ b/user_guide/installation/index.html @@ -28,7 +28,7 @@
    - +

    CodeIgniter User Guide Version 2.0.0

    CodeIgniter User Guide Version 2.0.2

    @@ -74,6 +74,12 @@

    Installation Instructions

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

    +

    + One additional measure to take in production environments is to disable + PHP error reporting and any other development-only functionality. In CodeIgniter, + this can be done by setting the ENVIRONMENT constant, which is + more fully described on the security page. +

    That's it!

    @@ -95,7 +101,7 @@

    Installation Instructions

    Next Topic:  Upgrading from a Previous Version

    -

    CodeIgniter  ·  Copyright © 2006-2010  ·  EllisLab, Inc.

    +

    CodeIgniter  ·  Copyright © 2006 - 2011  ·  EllisLab, Inc.

    diff --git a/user_guide/installation/troubleshooting.html b/user_guide/installation/troubleshooting.html index 0c05ed60..2a50b8db 100644 --- a/user_guide/installation/troubleshooting.html +++ b/user_guide/installation/troubleshooting.html @@ -28,7 +28,7 @@
    - +

    CodeIgniter User Guide Version 2.0.0

    CodeIgniter User Guide Version 2.0.2

    @@ -83,7 +83,7 @@

    Troubleshooting

    User Guide Home   ·   Next Topic:  CodeIgniter at a Glance

    -

    CodeIgniter  ·  Copyright © 2006-2010  ·  EllisLab, Inc.

    +

    CodeIgniter  ·  Copyright © 2006 - 2011  ·  EllisLab, Inc.

    diff --git a/user_guide/installation/upgrade_120.html b/user_guide/installation/upgrade_120.html index ec947274..563c98c6 100644 --- a/user_guide/installation/upgrade_120.html +++ b/user_guide/installation/upgrade_120.html @@ -28,7 +28,7 @@
    - +

    CodeIgniter User Guide Version 2.0.0

    CodeIgniter User Guide Version 2.0.2

    @@ -85,7 +85,7 @@

    Upgrading From Beta 1.0 to Final 1.2

    User Guide Home   ·   Next Topic:  Troubleshooting

    -

    CodeIgniter  ·  Copyright © 2006-2010  ·  EllisLab, Inc.

    +

    CodeIgniter  ·  Copyright © 2006 - 2011  ·  EllisLab, Inc.

    diff --git a/user_guide/installation/upgrade_130.html b/user_guide/installation/upgrade_130.html index bd43dd9e..f7ffac74 100644 --- a/user_guide/installation/upgrade_130.html +++ b/user_guide/installation/upgrade_130.html @@ -28,7 +28,7 @@
    - +

    CodeIgniter User Guide Version 2.0.0

    CodeIgniter User Guide Version 2.0.2

    @@ -196,7 +196,7 @@

    Step 6: Update your user guide

    User Guide Home   ·   Next Topic:  Troubleshooting

    -

    CodeIgniter  ·  Copyright © 2006-2010  ·  EllisLab, Inc.

    +

    CodeIgniter  ·  Copyright © 2006 - 2011  ·  EllisLab, Inc.

    diff --git a/user_guide/installation/upgrade_131.html b/user_guide/installation/upgrade_131.html index db02b481..7541a83e 100644 --- a/user_guide/installation/upgrade_131.html +++ b/user_guide/installation/upgrade_131.html @@ -28,7 +28,7 @@
    - +

    CodeIgniter User Guide Version 2.0.0

    CodeIgniter User Guide Version 2.0.2

    @@ -95,7 +95,7 @@

    Step 2: Update your user guide

    User Guide Home   ·   Next Topic:  Troubleshooting

    -

    CodeIgniter  ·  Copyright © 2006-2010  ·  EllisLab, Inc.

    +

    CodeIgniter  ·  Copyright © 2006 - 2011  ·  EllisLab, Inc.

    diff --git a/user_guide/installation/upgrade_132.html b/user_guide/installation/upgrade_132.html index 2caf9771..4fcbb46b 100644 --- a/user_guide/installation/upgrade_132.html +++ b/user_guide/installation/upgrade_132.html @@ -28,7 +28,7 @@
    - +

    CodeIgniter User Guide Version 2.0.0

    CodeIgniter User Guide Version 2.0.2

    @@ -93,7 +93,7 @@

    Step 2: Update your user guide

    User Guide Home   ·   Next Topic:  Troubleshooting

    -

    CodeIgniter  ·  Copyright © 2006-2010  ·  EllisLab, Inc.

    +

    CodeIgniter  ·  Copyright © 2006 - 2011  ·  EllisLab, Inc.

    diff --git a/user_guide/installation/upgrade_133.html b/user_guide/installation/upgrade_133.html index e3d05814..c6346595 100644 --- a/user_guide/installation/upgrade_133.html +++ b/user_guide/installation/upgrade_133.html @@ -28,7 +28,7 @@
    - +

    CodeIgniter User Guide Version 2.0.0

    CodeIgniter User Guide Version 2.0.2

    @@ -105,7 +105,7 @@

    Step 3: Update your user guide

    User Guide Home   ·   Next Topic:  Troubleshooting

    -

    CodeIgniter  ·  Copyright © 2006-2010  ·  EllisLab, Inc.

    +

    CodeIgniter  ·  Copyright © 2006 - 2011  ·  EllisLab, Inc.

    diff --git a/user_guide/installation/upgrade_140.html b/user_guide/installation/upgrade_140.html index 1d6b7ec0..2049628a 100644 --- a/user_guide/installation/upgrade_140.html +++ b/user_guide/installation/upgrade_140.html @@ -28,7 +28,7 @@
    - +

    CodeIgniter User Guide Version 2.0.0

    CodeIgniter User Guide Version 2.0.2

    @@ -138,7 +138,7 @@

    Step 3: Update your user guide

    User Guide Home   ·   Next Topic:  Troubleshooting

    -

    CodeIgniter  ·  Copyright © 2006-2010  ·  EllisLab, Inc.

    +

    CodeIgniter  ·  Copyright © 2006 - 2011  ·  EllisLab, Inc.

    diff --git a/user_guide/installation/upgrade_141.html b/user_guide/installation/upgrade_141.html index 12112803..c19143c6 100644 --- a/user_guide/installation/upgrade_141.html +++ b/user_guide/installation/upgrade_141.html @@ -28,7 +28,7 @@
    - +

    CodeIgniter User Guide Version 2.0.0

    CodeIgniter User Guide Version 2.0.2

    @@ -141,7 +141,7 @@

    Step 4: Update your user guide

    User Guide Home   ·   Next Topic:  Troubleshooting

    -

    CodeIgniter  ·  Copyright © 2006-2010  ·  EllisLab, Inc.

    +

    CodeIgniter  ·  Copyright © 2006 - 2011  ·  EllisLab, Inc.

    diff --git a/user_guide/installation/upgrade_150.html b/user_guide/installation/upgrade_150.html index 7e9bfa8c..342d486d 100644 --- a/user_guide/installation/upgrade_150.html +++ b/user_guide/installation/upgrade_150.html @@ -28,7 +28,7 @@
    - +

    CodeIgniter User Guide Version 2.0.0

    CodeIgniter User Guide Version 2.0.2

    @@ -171,7 +171,7 @@

    Step 5: Update your user guide

    User Guide Home   ·   Next Topic:  Troubleshooting

    -

    CodeIgniter  ·  Copyright © 2006-2010  ·  EllisLab, Inc.

    +

    CodeIgniter  ·  Copyright © 2006 - 2011  ·  EllisLab, Inc.

    diff --git a/user_guide/installation/upgrade_152.html b/user_guide/installation/upgrade_152.html index 0b386a66..f601a252 100644 --- a/user_guide/installation/upgrade_152.html +++ b/user_guide/installation/upgrade_152.html @@ -28,7 +28,7 @@
    - +

    CodeIgniter User Guide Version 2.0.0

    CodeIgniter User Guide Version 2.0.2

    @@ -104,7 +104,7 @@

    Step 2: Update your user guide

    User Guide Home   ·   Next Topic:  Troubleshooting

    -

    CodeIgniter  ·  Copyright © 2006-2010  ·  EllisLab, Inc.

    +

    CodeIgniter  ·  Copyright © 2006 - 2011  ·  EllisLab, Inc.

    diff --git a/user_guide/installation/upgrade_153.html b/user_guide/installation/upgrade_153.html index b32130dc..fe6978aa 100644 --- a/user_guide/installation/upgrade_153.html +++ b/user_guide/installation/upgrade_153.html @@ -28,7 +28,7 @@
    - +

    CodeIgniter User Guide Version 2.0.0

    CodeIgniter User Guide Version 2.0.2

    @@ -93,7 +93,7 @@

    Step 2: Update your user guide

    User Guide Home   ·   Next Topic:  Troubleshooting

    -

    CodeIgniter  ·  Copyright © 2006-2010  ·  EllisLab, Inc.

    +

    CodeIgniter  ·  Copyright © 2006 - 2011  ·  EllisLab, Inc.

    diff --git a/user_guide/installation/upgrade_154.html b/user_guide/installation/upgrade_154.html index 33fbef4b..e5086813 100644 --- a/user_guide/installation/upgrade_154.html +++ b/user_guide/installation/upgrade_154.html @@ -28,7 +28,7 @@
    - +

    CodeIgniter User Guide Version 2.0.0

    CodeIgniter User Guide Version 2.0.2

    @@ -109,7 +109,7 @@

    Step 4: Update your user guide

    User Guide Home   ·   Next Topic:  Troubleshooting

    -

    CodeIgniter  ·  Copyright © 2006-2010  ·  EllisLab, Inc.

    +

    CodeIgniter  ·  Copyright © 2006 - 2011  ·  EllisLab, Inc.

    diff --git a/user_guide/installation/upgrade_160.html b/user_guide/installation/upgrade_160.html index b6a946d7..d06f58ec 100644 --- a/user_guide/installation/upgrade_160.html +++ b/user_guide/installation/upgrade_160.html @@ -28,7 +28,7 @@
    - +

    CodeIgniter User Guide Version 2.0.0

    CodeIgniter User Guide Version 2.0.2

    @@ -118,7 +118,7 @@

    Step 5: Update your user guide

    User Guide Home   ·   Next Topic:  Troubleshooting

    -

    CodeIgniter  ·  Copyright © 2006-2010  ·  EllisLab, Inc.

    +

    CodeIgniter  ·  Copyright © 2006 - 2011  ·  EllisLab, Inc.

    diff --git a/user_guide/installation/upgrade_161.html b/user_guide/installation/upgrade_161.html index 81d592c5..2dc2de59 100644 --- a/user_guide/installation/upgrade_161.html +++ b/user_guide/installation/upgrade_161.html @@ -28,7 +28,7 @@
    - +

    CodeIgniter User Guide Version 2.0.0

    CodeIgniter User Guide Version 2.0.2

    @@ -91,7 +91,7 @@

    Step 2: Update your user guide

    User Guide Home   ·   Next Topic:  Troubleshooting

    -

    CodeIgniter  ·  Copyright © 2006-2010  ·  EllisLab, Inc.

    +

    CodeIgniter  ·  Copyright © 2006 - 2011  ·  EllisLab, Inc.

    diff --git a/user_guide/installation/upgrade_162.html b/user_guide/installation/upgrade_162.html index 630fc3fe..0add80f8 100644 --- a/user_guide/installation/upgrade_162.html +++ b/user_guide/installation/upgrade_162.html @@ -28,7 +28,7 @@
    - +

    CodeIgniter User Guide Version 2.0.0

    CodeIgniter User Guide Version 2.0.2

    @@ -99,7 +99,7 @@

    Step 5: Update your user guide

    User Guide Home   ·   Next Topic:  Troubleshooting

    -

    CodeIgniter  ·  Copyright © 2006-2010  ·  EllisLab, Inc.

    +

    CodeIgniter  ·  Copyright © 2006 - 2011  ·  EllisLab, Inc.

    diff --git a/user_guide/installation/upgrade_163.html b/user_guide/installation/upgrade_163.html index 222b7b4b..73441397 100644 --- a/user_guide/installation/upgrade_163.html +++ b/user_guide/installation/upgrade_163.html @@ -28,7 +28,7 @@
    - +

    CodeIgniter User Guide Version 2.0.0

    CodeIgniter User Guide Version 2.0.2

    @@ -92,7 +92,7 @@

    Step 2: Update your user guide

    User Guide Home   ·   Next Topic:  Troubleshooting

    -

    CodeIgniter  ·  Copyright © 2006-2010  ·  EllisLab, Inc.

    +

    CodeIgniter  ·  Copyright © 2006 - 2011  ·  EllisLab, Inc.

    diff --git a/user_guide/installation/upgrade_170.html b/user_guide/installation/upgrade_170.html index 91238ecb..01597a41 100644 --- a/user_guide/installation/upgrade_170.html +++ b/user_guide/installation/upgrade_170.html @@ -28,7 +28,7 @@
    - +

    CodeIgniter User Guide Version 2.0.0

    CodeIgniter User Guide Version 2.0.2

    @@ -114,7 +114,7 @@

    Step 4: Update your user guide

    User Guide Home   ·   Next Topic:  Troubleshooting

    -

    CodeIgniter  ·  Copyright © 2006-2010  ·  EllisLab, Inc.

    +

    CodeIgniter  ·  Copyright © 2006 - 2011  ·  EllisLab, Inc.

    diff --git a/user_guide/installation/upgrade_171.html b/user_guide/installation/upgrade_171.html index d9cbcc00..baee208a 100644 --- a/user_guide/installation/upgrade_171.html +++ b/user_guide/installation/upgrade_171.html @@ -28,7 +28,7 @@
    - +

    CodeIgniter User Guide Version 2.0.0

    CodeIgniter User Guide Version 2.0.2

    @@ -91,7 +91,7 @@

    Step 2: Update your user guide

    User Guide Home   ·   Next Topic:  Troubleshooting

    -

    CodeIgniter  ·  Copyright © 2006-2010  ·  EllisLab, Inc.

    +

    CodeIgniter  ·  Copyright © 2006 - 2011  ·  EllisLab, Inc.

    diff --git a/user_guide/installation/upgrade_172.html b/user_guide/installation/upgrade_172.html index 0f95a815..dbf0fb01 100644 --- a/user_guide/installation/upgrade_172.html +++ b/user_guide/installation/upgrade_172.html @@ -28,7 +28,7 @@
    - +

    CodeIgniter User Guide Version 2.0.0

    CodeIgniter User Guide Version 2.0.2

    @@ -102,7 +102,7 @@

    Step 4: Update your user guide

    User Guide Home   ·   Next Topic:  Troubleshooting

    -

    CodeIgniter  ·  Copyright © 2006-2010  ·  EllisLab, Inc.

    +

    CodeIgniter  ·  Copyright © 2006 - 2011  ·  EllisLab, Inc.

    diff --git a/user_guide/installation/upgrade_200.html b/user_guide/installation/upgrade_200.html index 16c7d8d3..0b24079e 100644 --- a/user_guide/installation/upgrade_200.html +++ b/user_guide/installation/upgrade_200.html @@ -28,7 +28,7 @@
    - +

    CodeIgniter User Guide Version 2.0.0

    CodeIgniter User Guide Version 2.0.2

    @@ -124,7 +124,7 @@

    Step 8: Update your user guide

    User Guide Home   ·   Next Topic:  Troubleshooting

    -

    CodeIgniter  ·  Copyright © 2006-2010  ·  EllisLab, Inc.

    +

    CodeIgniter  ·  Copyright © 2006 - 2011  ·  EllisLab, Inc.

    diff --git a/user_guide/installation/upgrade_201.html b/user_guide/installation/upgrade_201.html new file mode 100644 index 00000000..fe99cc0c --- /dev/null +++ b/user_guide/installation/upgrade_201.html @@ -0,0 +1,105 @@ + + + + + +Upgrading from 2.0.0 to 2.0.1 : CodeIgniter User Guide + + + + + + + + + + + + + + + + + + + + + +
    + + + + + +

    CodeIgniter User Guide Version 2.0.2

    +
    + + + + + + + + + +
    + + +
    + + + +
    + +

    Upgrading from 2.0.0 to 2.0.1

    + +

    Before performing an update you should take your site offline by replacing the index.php file with a static one.

    + + +

    Step 1: Update your CodeIgniter files

    + +

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

    + +

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

    + + +

    Step 2: Replace config/mimes.php

    + +

    This config file has been updated to contain more mime types, please copy it to application/config/mimes.php.

    + + +

    Step 3: Check for forms posting to default controller

    + +

    + The default behavior for form_open() when called with no parameters used to be to post to the default controller, but it will now just leave an empty action="" meaning the form will submit to the current URL. + If submitting to the default controller was the expected behavior it will need to be changed from: +

    + +echo form_open(); //<form action="" method="post" accept-charset="utf-8"> + +

    to use either a / or base_url():

    + +echo form_open('/'); //<form action="http://example.com/index.php/" method="post" accept-charset="utf-8">
    +echo form_open(base_url()); //<form action="http://example.com/" method="post" accept-charset="utf-8">
    + +
    + + + + + + + \ No newline at end of file diff --git a/user_guide/installation/upgrade_202.html b/user_guide/installation/upgrade_202.html new file mode 100644 index 00000000..d457d8bb --- /dev/null +++ b/user_guide/installation/upgrade_202.html @@ -0,0 +1,97 @@ + + + + + +Upgrading from 2.0.1 to 2.0.2 : CodeIgniter User Guide + + + + + + + + + + + + + + + + + + + + + +
    + + + + + +

    CodeIgniter User Guide Version 2.0.2

    +
    + + + + + + + + + +
    + + +
    + + + +
    + +

    Upgrading from 2.0.1 to 2.0.2

    + +

    Before performing an update you should take your site offline by replacing the index.php file with a static one.

    + + +

    Step 1: Update your CodeIgniter files

    + +

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

    + +

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

    + + +

    Step 2: Remove loading calls for the Security Library

    + +

    Security has been moved to the core and is now always loaded automatically. Make sure you remove any loading calls as they will result in PHP errors.

    + + +

    Step 3: Move MY_Security

    + +

    If you are overriding or extending the Security library, you will need to move it to application/core.

    + +

    csrf_token_name and csrf_hash have changed to protected class properties. Please use security->get_csrf_hash() and security->get_csrf_token_name() to access those values.

    + +
    + + + + + + + \ No newline at end of file diff --git a/user_guide/installation/upgrade_203.html b/user_guide/installation/upgrade_203.html new file mode 100644 index 00000000..7dbc907e --- /dev/null +++ b/user_guide/installation/upgrade_203.html @@ -0,0 +1,125 @@ + + + + + +Upgrading from 2.0.2 to 2.0.3 : CodeIgniter User Guide + + + + + + + + + + + + + + + + + + + + + +
    + + + + + +

    CodeIgniter User Guide Version 2.0.3

    +
    + + + + + + + + + +
    + + +
    + + + +
    + +

    Upgrading from 2.0.2 to 2.0.3

    + +

    Before performing an update you should take your site offline by replacing the index.php file with a static one.

    + + +

    Step 1: Update your CodeIgniter files

    + +

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

    + +

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

    + +

    Step 2: Update CodeIgniter files

    + +

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

    + +

    Step 3: Update your main index.php file

    + +

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

    + +

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

    + +

    Step 4: Replace config/user_agents.php

    + +

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

    + +

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

    +

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

    + +

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

    + +

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

    + +$autoload['packages'] = array(APPPATH.'third_party'); + +

    If you have not chosen to load any additional packages, that line can be changed to:

    +$autoload['packages'] = array(); + +

    Which should provide for nominal performance gains if not autoloading packages.

    + +

    Update Sessions Database Tables

    + +

    If you are using database sessions with the CI Session Library, please update your ci_sessions database table as follows:

    + + + CREATE INDEX last_activity_idx ON ci_sessions(last_activity); + ALTER TABLE ci_sessions MODIFY user_agent VARCHAR(120); + + + + + +
    + + + + + + + \ No newline at end of file diff --git a/user_guide/installation/upgrade_b11.html b/user_guide/installation/upgrade_b11.html index 8604d514..add7228c 100644 --- a/user_guide/installation/upgrade_b11.html +++ b/user_guide/installation/upgrade_b11.html @@ -28,7 +28,7 @@
    - +

    CodeIgniter User Guide Version 2.0.0

    CodeIgniter User Guide Version 2.0.2

    @@ -137,7 +137,7 @@

    Step 5: Edit your config file

    User Guide Home   ·   Next Topic:  Troubleshooting

    -

    CodeIgniter  ·  Copyright © 2006-2010  ·  EllisLab, Inc.

    +

    CodeIgniter  ·  Copyright © 2006 - 2011  ·  EllisLab, Inc.

    diff --git a/user_guide/installation/upgrading.html b/user_guide/installation/upgrading.html index eb1cd9d9..014ffa3f 100644 --- a/user_guide/installation/upgrading.html +++ b/user_guide/installation/upgrading.html @@ -28,7 +28,7 @@
    - +

    CodeIgniter User Guide Version 2.0.0

    CodeIgniter User Guide Version 2.0.2

    @@ -60,26 +60,29 @@

    Upgrading From a Previous Version

    Please read the upgrade notes corresponding to the version you are upgrading from.

    @@ -95,7 +98,7 @@

    Upgrading From a Previous Version

    User Guide Home   ·   Next Topic:  Troubleshooting

    -

    CodeIgniter  ·  Copyright © 2006-2010  ·  EllisLab, Inc.

    +

    CodeIgniter  ·  Copyright © 2006 - 2011  ·  EllisLab, Inc.

    diff --git a/user_guide/libraries/benchmark.html b/user_guide/libraries/benchmark.html index 05f7cc0e..c29acb7b 100644 --- a/user_guide/libraries/benchmark.html +++ b/user_guide/libraries/benchmark.html @@ -28,7 +28,7 @@
    - +

    CodeIgniter User Guide Version 2.0.0

    CodeIgniter User Guide Version 2.0.2

    @@ -191,7 +191,7 @@

    Displaying Memory Consumption

    User Guide Home   ·   Next Topic:  Calendar Class

    -

    CodeIgniter  ·  Copyright © 2006-2010  ·  EllisLab, Inc.

    +

    CodeIgniter  ·  Copyright © 2006 - 2011  ·  EllisLab, Inc.

    diff --git a/user_guide/libraries/caching.html b/user_guide/libraries/caching.html index e4651dc4..f94a3d1a 100644 --- a/user_guide/libraries/caching.html +++ b/user_guide/libraries/caching.html @@ -28,7 +28,7 @@
    - +

    CodeIgniter User Guide Version 2.0.0

    CodeIgniter User Guide Version 2.0.2

    @@ -180,13 +180,13 @@

    Dummy Cache

    diff --git a/user_guide/libraries/calendar.html b/user_guide/libraries/calendar.html index 2c052424..e1af71cc 100644 --- a/user_guide/libraries/calendar.html +++ b/user_guide/libraries/calendar.html @@ -28,7 +28,7 @@
    - +

    CodeIgniter User Guide Version 2.0.0

    CodeIgniter User Guide Version 2.0.2

    @@ -242,7 +242,7 @@

    Creating a Calendar Template

    User Guide Home   ·   Next Topic:  Cart Class

    -

    CodeIgniter  ·  Copyright © 2006-2010  ·  EllisLab, Inc.

    +

    CodeIgniter  ·  Copyright © 2006 - 2011  ·  EllisLab, Inc.

    diff --git a/user_guide/libraries/cart.html b/user_guide/libraries/cart.html index ba95b24c..81b43e36 100644 --- a/user_guide/libraries/cart.html +++ b/user_guide/libraries/cart.html @@ -28,7 +28,7 @@
    - +

    CodeIgniter User Guide Version 2.0.0

    CodeIgniter User Guide Version 2.0.2

    @@ -61,7 +61,7 @@

    Shopping Cart Class

    The Cart Class permits items to be added to a session that stays active while a user is browsing your site. These items can be retrieved and displayed in a standard "shopping cart" format, allowing the user to update the quantity or remove items from the cart.

    -

    Please note that the Cart Class ONLY provides the core "cart" functionality. It does not provide shipping, credit card authorization, or other processing components.

    +

    Please note that the Cart Class ONLY provides the core "cart" functionality. It does not provide shipping, credit card authorization, or other processing components.

    Initializing the Shopping Cart Class

    @@ -106,20 +106,19 @@

    Adding an Item to The Cart

  • qty - The quantity being purchased.
  • price - The price of the item.
  • name - The name of the item. -
  • options - Any additional attributes that are needed to identify the product. These must be passed via an array. +
  • options - Any additional attributes that are needed to identify the product. These must be passed via an array. -

    In addition to the five indexes above, there are two reserved words: rowid and subtotal. These are used internally by the Cart class, so -please do NOT use those words as index names when inserting data into the cart.

    +

    In addition to the five indexes above, there are two reserved words: rowid and subtotal. These are used internally by the Cart class, so please do NOT use those words as index names when inserting data into the cart.

    -

    Your array may contain additional data. Anything you include in your array will be stored in the session. However, it is best to standardize your data among -all your products in order to make displaying the information in a table easier.

    +

    Your array may contain additional data. Anything you include in your array will be stored in the session. However, it is best to standardize your data among all your products in order to make displaying the information in a table easier.

    + +

    The insert() method will return the $rowid if you successfully insert a single item.

    Adding Multiple Items to The Cart

    -

    By using a multi-dimensional array, as shown below, it is possible to add multiple products to the cart in one action. This is useful in cases where you wish to allow -people to select from among several items on the same page.

    +

    By using a multi-dimensional array, as shown below, it is possible to add multiple products to the cart in one action. This is useful in cases where you wish to allow people to select from among several items on the same page.

    @@ -178,7 +177,7 @@

    Displaying the Cart

    <?php $i = 1; ?> -<?php foreach($this->cart->contents() as $items): ?> +<?php foreach ($this->cart->contents() as $items): ?> <?php echo form_hidden($i.'[rowid]', $items['rowid']); ?> @@ -265,11 +264,11 @@

    Updating The Cart

    -

    What is a Row ID?  The row ID is a unique identifier that is generated by the cart code when an item is added to the cart. The reason a +

    What is a Row ID?  The row ID is a unique identifier that is generated by the cart code when an item is added to the cart. The reason a unique ID is created is so that identical products with different options can be managed by the cart.

    -

    For example, let's say someone buys two identical t-shirts (same product ID), but in different sizes. The product ID (and other attributes) will be -identical for both sizes because it's the same shirt. The only difference will be the size. The cart must therefore have a means of identifying this +

    For example, let's say someone buys two identical t-shirts (same product ID), but in different sizes. The product ID (and other attributes) will be +identical for both sizes because it's the same shirt. The only difference will be the size. The cart must therefore have a means of identifying this difference so that the two sizes of shirts can be managed independently. It does so by creating a unique "row ID" based on the product ID and any options associated with it.

    In nearly all cases, updating the cart will be something the user does via the "view cart" page, so as a developer, it is unlikely that you will ever have to concern yourself @@ -311,7 +310,7 @@

    $this->cart->contents();

    $this->cart->has_options(rowid);

    -

    Returns TRUE (boolean) if a particular row in the cart contains options. This function is designed to be used in a loop with $this->cart->contents(), since you must pass the rowid to this function, as shown in the Displaying the Cart example above.

    +

    Returns TRUE (boolean) if a particular row in the cart contains options. This function is designed to be used in a loop with $this->cart->contents(), since you must pass the rowid to this function, as shown in the Displaying the Cart example above.

    $this->cart->product_options(rowid);

    @@ -322,7 +321,7 @@

    $this->cart->product_options(rowid);

    $this->cart->destroy();

    -

    Permits you to destroy the cart. This function will likely be called when you are finished processing the customer's order.

    +

    Permits you to destroy the cart. This function will likely be called when you are finished processing the customer's order.

    @@ -339,7 +338,7 @@

    $this->cart->destroy();

    User Guide Home   ·   Next Topic:  Config Class

    -

    CodeIgniter  ·  Copyright © 2006-2010  ·  EllisLab, Inc.

    +

    CodeIgniter  ·  Copyright © 2006 - 2011  ·  EllisLab, Inc.

  • diff --git a/user_guide/libraries/config.html b/user_guide/libraries/config.html index bfb67945..2433ec4a 100644 --- a/user_guide/libraries/config.html +++ b/user_guide/libraries/config.html @@ -28,7 +28,7 @@
    - +

    CodeIgniter User Guide Version 2.0.0

    CodeIgniter User Guide Version 2.0.2

    @@ -150,6 +150,42 @@

    Setting a Config Item

    Where item_name is the $config array index you want to change, and item_value is its value.

    + +

    Environments

    + +

    + You may load different configuration files depending on the current environment. + The ENVIRONMENT constant is defined in index.php, and is described + in detail in the Handling Environments + section. +

    + +

    + To create an environment-specific configuration file, + create or copy a configuration file in application/config/{ENVIRONMENT}/{FILENAME}.php +

    + +

    For example, to create a production-only config.php, you would:

    + +
      +
    1. Create the directory application/config/production/
    2. +
    3. Copy your existing config.php into the above directory
    4. +
    5. Edit application/config/production/config.php so it contains your production settings
    6. +
    + +

    + When you set the ENVIRONMENT constant to 'production', the settings + for your new production-only config.php will be loaded. +

    + +

    You can place the following configuration files in environment-specific folders:

    + +
      +
    • Default CodeIgniter configuration files
    • +
    • Your own custom configuration files
    • +
    + +

    Note: CodeIgniter always tries to load the configuration files for the current environment first. If the file does not exist, the global config file (i.e., the one in application/config/) is loaded. This means you are not obligated to place all of your configuration files in an environment folder − only the files that change per environment.

    Helper Functions

    @@ -174,8 +210,8 @@

    $this->config->system_url();

    User Guide Home   ·   Next Topic:  Database Class

    -

    CodeIgniter  ·  Copyright © 2006-2010  ·  EllisLab, Inc.

    +

    CodeIgniter  ·  Copyright © 2006 - 2011  ·  EllisLab, Inc.

    - \ No newline at end of file + diff --git a/user_guide/libraries/email.html b/user_guide/libraries/email.html index b863ef4c..5a8814d5 100644 --- a/user_guide/libraries/email.html +++ b/user_guide/libraries/email.html @@ -28,7 +28,7 @@
    - +

    CodeIgniter User Guide Version 2.0.0

    CodeIgniter User Guide Version 2.0.2

    @@ -300,7 +300,7 @@

    Overriding Word Wrapping

    User Guide Home   ·   Next Topic:  Encryption Class

    -

    CodeIgniter  ·  Copyright © 2006-2010  ·  EllisLab, Inc.

    +

    CodeIgniter  ·  Copyright © 2006 - 2011  ·  EllisLab, Inc.

    diff --git a/user_guide/libraries/encryption.html b/user_guide/libraries/encryption.html index fbffd63c..60099312 100644 --- a/user_guide/libraries/encryption.html +++ b/user_guide/libraries/encryption.html @@ -28,7 +28,7 @@
    - +

    CodeIgniter User Guide Version 2.0.0

    CodeIgniter User Guide Version 2.0.2

    @@ -217,7 +217,7 @@

    $this->encrypt->encode_from_legacy($orig_data, $ User Guide Home   ·   Next Topic:  File Uploading Class

    -

    CodeIgniter  ·  Copyright © 2006-2010  ·  EllisLab, Inc.

    +

    CodeIgniter  ·  Copyright © 2006 - 2011  ·  EllisLab, Inc.

    diff --git a/user_guide/libraries/file_uploading.html b/user_guide/libraries/file_uploading.html index 54725d03..e4e842e5 100644 --- a/user_guide/libraries/file_uploading.html +++ b/user_guide/libraries/file_uploading.html @@ -28,7 +28,7 @@
    - +

    CodeIgniter User Guide Version 2.0.0

    CodeIgniter User Guide Version 2.0.2

    @@ -125,7 +125,7 @@

    The Success Page

    <h3>Your file was successfully uploaded!</h3> <ul> -<?php foreach($upload_data as $item => $value):?> +<?php foreach ($upload_data as $item => $value):?> <li><?php echo $item;?>: <?php echo $value;?></li> <?php endforeach; ?> </ul> @@ -444,7 +444,7 @@

    Explanation

    User Guide Home   ·   Next Topic:  Form Validation Class

    -

    CodeIgniter  ·  Copyright © 2006-2010  ·  Ellislab, Inc.

    +

    CodeIgniter  ·  Copyright © 2006 - 2011  ·  Ellislab, Inc.

    diff --git a/user_guide/libraries/form_validation.html b/user_guide/libraries/form_validation.html index eae2036c..8e5ec1e4 100644 --- a/user_guide/libraries/form_validation.html +++ b/user_guide/libraries/form_validation.html @@ -27,7 +27,7 @@
    - +

    CodeIgniter User Guide Version 2.0.0

    CodeIgniter User Guide Version 2.0.2

    @@ -390,10 +390,10 @@

    Cascading Rules

    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 @@

    Callbacks: Your own Validation Functions

    class Form extends CI_Controller { - function index() + public function index() { $this->load->helper(array('form', 'url')); @@ -525,7 +525,7 @@

    Callbacks: Your own Validation Functions

    $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 @@

    Callbacks: Your own Validation Functions

    } } - function username_check($str) + public function username_check($str) { if ($str == 'test') { @@ -586,6 +586,22 @@

    Setting Error Messages

    $this->form_validation->set_message('required', 'Your custom message here'); +

    You can also set custom messages with arrays, in the same way you set rules. Use the following structure:

    + @@ -924,118 +940,160 @@

    Rule Reference

    The following is a list of all the native rules that are available to use:

    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    RuleParameterDescriptionExample
    requiredNoReturns FALSE if the form element is empty. 
    matchesYesReturns FALSE if the form element does not match the one in the parameter.matches[form_item]
    min_lengthYesReturns FALSE if the form element is shorter then the parameter value.min_length[6]
    max_lengthYesReturns FALSE if the form element is longer then the parameter value.max_length[12]
    exact_lengthYesReturns FALSE if the form element is not exactly the parameter value.exact_length[8]
    alphaNoReturns FALSE if the form element contains anything other than alphabetical characters. 
    alpha_numericNoReturns FALSE if the form element contains anything other than alpha-numeric characters. 
    alpha_dashNoReturns FALSE if the form element contains anything other than alpha-numeric characters, underscores or dashes. 
    numericNoReturns FALSE if the form element contains anything other than numeric characters. 
    integerNoReturns FALSE if the form element contains anything other than an integer. 
    is_naturalNoReturns FALSE if the form element contains anything other than a natural number: 0, 1, 2, 3, etc. 
    is_natural_no_zeroNoReturns FALSE if the form element contains anything other than a natural number, but not zero: 1, 2, 3, etc. 
    valid_emailNoReturns FALSE if the form element does not contain a valid email address. 
    valid_emailsNoReturns FALSE if any value provided in a comma separated list is not a valid email. 
    valid_ipNoReturns FALSE if the supplied IP is not valid. 
    valid_base64NoReturns FALSE if the supplied string contains anything other than valid Base64 characters. 
    RuleParameterDescriptionExample
    requiredNoReturns FALSE if the form element is empty. 
    matchesYesReturns FALSE if the form element does not match the one in the parameter.matches[form_item]
    is_uniqueYesReturns FALSE if the form element is not unique to the table and field name in the parameter.is_unique[table.field]
    valid_dateOptional - default format "y-m-d"Returns FALSE if the input format does not match the given format and then also checks that the date entered is also valid. Formatting character's [m|y|d] case has no effect. Date formatting does NOT follow http://php.net/date formatting characters and is a simplified single character syntaxvalid_date valid_date[M.Y.D] valid_date[d/M/y]
    min_lengthYesReturns FALSE if the form element is shorter then the parameter value.min_length[6]
    max_lengthYesReturns FALSE if the form element is longer then the parameter value.max_length[12]
    exact_lengthYesReturns FALSE if the form element is not exactly the parameter value.exact_length[8]
    greater_thanYesReturns FALSE if the form element is less than the parameter value or not numeric.greater_than[8]
    less_thanYesReturns FALSE if the form element is greater than the parameter value or not numeric.less_than[8]
    alphaNoReturns FALSE if the form element contains anything other than alphabetical characters. 
    alpha_numericNoReturns FALSE if the form element contains anything other than alpha-numeric characters. 
    alpha_dashNoReturns FALSE if the form element contains anything other than alpha-numeric characters, underscores or dashes. 
    numericNoReturns FALSE if the form element contains anything other than numeric characters. 
    integerNoReturns FALSE if the form element contains anything other than an integer. 
    decimalYesReturns FALSE if the form element is not exactly the parameter value. 
    is_naturalNoReturns FALSE if the form element contains anything other than a natural number: 0, 1, 2, 3, etc. 
    is_natural_no_zeroNoReturns FALSE if the form element contains anything other than a natural number, but not zero: 1, 2, 3, etc. 
    valid_emailNoReturns FALSE if the form element does not contain a valid email address. 
    valid_emailsNoReturns FALSE if any value provided in a comma separated list is not a valid email. 
    valid_ipNoReturns FALSE if the supplied IP is not valid. 
    valid_base64NoReturns FALSE if the supplied string contains anything other than valid Base64 characters. 
    @@ -1058,36 +1116,36 @@

    Prepping Reference

    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameParameterDescription
    xss_cleanNoRuns the data through the XSS filtering function, described in the Input Class page.
    prep_for_formNoConverts special characters so that HTML data can be shown in a form field without breaking it.
    prep_urlNoAdds "http://" to URLs if missing.
    strip_image_tagsNoStrips the HTML from image tags leaving the raw URL.
    encode_php_tagsNoConverts PHP tags to entities.
    NameParameterDescription
    xss_cleanNoRuns the data through the XSS filtering function, described in the Input Class page.
    prep_for_formNoConverts special characters so that HTML data can be shown in a form field without breaking it.
    prep_urlNoAdds "http://" to URLs if missing.
    strip_image_tagsNoStrips the HTML from image tags leaving the raw URL.
    encode_php_tagsNoConverts PHP tags to entities.
    @@ -1211,7 +1269,7 @@

    set_radio()

    User Guide Home   ·   Next Topic:  FTP Class

    -

    CodeIgniter  ·  Copyright © 2006-2010  ·  EllisLab, Inc.

    +

    CodeIgniter  ·  Copyright © 2006 - 2011  ·  EllisLab, Inc.

    diff --git a/user_guide/libraries/ftp.html b/user_guide/libraries/ftp.html index 49317765..43b949a5 100644 --- a/user_guide/libraries/ftp.html +++ b/user_guide/libraries/ftp.html @@ -28,7 +28,7 @@
    - +

    CodeIgniter User Guide Version 2.0.0

    CodeIgniter User Guide Version 2.0.2

    @@ -309,7 +309,7 @@

    $this->ftp->close();

    User Guide Home   ·   Next Topic:  HTML Table Class

    -

    CodeIgniter  ·  Copyright © 2006-2010  ·  EllisLab, Inc.

    +

    CodeIgniter  ·  Copyright © 2006 - 2011  ·  EllisLab, Inc.

    diff --git a/user_guide/libraries/image_lib.html b/user_guide/libraries/image_lib.html index 98ed4f6d..dbf07768 100644 --- a/user_guide/libraries/image_lib.html +++ b/user_guide/libraries/image_lib.html @@ -28,7 +28,7 @@
    - +

    CodeIgniter User Guide Version 2.0.0

    CodeIgniter User Guide Version 2.0.2

    @@ -660,7 +660,7 @@

    Overlay Preferences

    User Guide Home   ·   Next Topic:  Input Class

    -

    CodeIgniter  ·  Copyright © 2006-2010  ·  EllisLab, Inc.

    +

    CodeIgniter  ·  Copyright © 2006 - 2011  ·  EllisLab, Inc.

    diff --git a/user_guide/libraries/input.html b/user_guide/libraries/input.html index d838cf02..08b8ab0d 100644 --- a/user_guide/libraries/input.html +++ b/user_guide/libraries/input.html @@ -28,7 +28,7 @@
    - +

    CodeIgniter User Guide Version 2.0.0

    CodeIgniter User Guide Version 2.0.2

    @@ -132,12 +132,32 @@

    $this->input->post()

    $this->input->post('some_data', TRUE); +

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

    +

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

    +

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

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

    $this->input->get()

    This function is identical to the post function, only it fetches get data:

    $this->input->get('some_data', TRUE); +

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

    +

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

    +

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

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

    $this->input->get_post()

    This function will search through both the post and get streams for data, looking first in post, and then in get:

    @@ -167,13 +187,14 @@

    Array Method

    Using this method, an associative array is passed to the first parameter:

    $cookie = array(
    -                   'name'   => 'The Cookie Name',
    -                   'value'  => 'The Value',
    -                   'expire' => '86500',
    -                   'domain' => '.some-domain.com',
    -                   'path'   => '/',
    -                   'prefix' => 'myprefix_',
    -               );
    +    'name'   => 'The Cookie Name',
    +    'value'  => 'The Value',
    +    'expire' => '86500',
    +    'domain' => '.some-domain.com',
    +    'path'   => '/',
    +    'prefix' => 'myprefix_',
    +    'secure' => TRUE
    +);

    $this->input->set_cookie($cookie);
    @@ -188,24 +209,25 @@

    Array Method

    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.

    Discrete Parameters

    If you prefer, you can set the cookie by passing data using individual parameters:

    -$this->input->set_cookie($name, $value, $expire, $domain, $path, $prefix); +$this->input->set_cookie($name, $value, $expire, $domain, $path, $prefix, $secure); -

    $this->input->get_cookie()

    +

    $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):

    -get_cookie('some_cookie'); +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;

    -

    get_cookie('some_cookie', TRUE);

    +

    cookie('some_cookie', TRUE);

    $this->input->ip_address()

    @@ -231,7 +253,7 @@

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

    $this->input->user_agent()

    Returns the user agent (web browser) being used by the current user. Returns FALSE if it's not available.

    echo $this->input->user_agent(); - +

    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.

    @@ -247,7 +269,11 @@

    $this->input->get_request_header();

    $this->input->is_ajax_request()

    Checks to see if the HTTP_X_REQUESTED_WITH server header has been set, and returns a boolean response.

    -$this->input->is_ajax_request() + +

    $this->input->is_cli_request()

    +

    Checks to see if the STDIN constant is set, which is a failsafe way to see if PHP is being run on the command line.

    + +$this->input->is_cli_request()
    @@ -262,7 +288,7 @@

    $this->input->is_ajax_request()

    User Guide Home   ·   Next Topic:  Loader Class

    -

    CodeIgniter  ·  Copyright © 2006-2010  ·  EllisLab, Inc.

    +

    CodeIgniter  ·  Copyright © 2006 - 2011  ·  EllisLab, Inc.

    diff --git a/user_guide/libraries/javascript.html b/user_guide/libraries/javascript.html index 0f1d0a09..5b7ef437 100644 --- a/user_guide/libraries/javascript.html +++ b/user_guide/libraries/javascript.html @@ -2,7 +2,7 @@ -CodeIgniter User Guide : Input Class +JavaScript Class : CodeIgniter User Guide @@ -28,7 +28,7 @@
    - +

    CodeIgniter User Guide Version 2.0.0

    CodeIgniter User Guide Version 2.0.2

    @@ -42,7 +42,8 @@ CodeIgniter Home  ›  User Guide Home  ›  -Input Class +Drivers  ›  +JavaScript Driver
    Search User Guide   
    @@ -55,11 +56,12 @@
    +

    Note: This driver is experimental. Its feature set and implementation may change in future releases.


    Javascript Class

    -

    Rewrite this paragraph: jQuery is a fast, concise, JavaScript Library that simplifies how you traverse HTML documents, handle events, perform animations, and add Ajax interactions to your web pages. CodeIgniter provides a library to help you with certain common functions that you may want to use within jQuery. Please note that CodeIgniter does not require the jQuery library to run, and that any scripting library will work equally well. The jQuery library is simply presented as a convenience if you choose to use it.

    +

    CodeIgniter provides a library to help you with certain common functions that you may want to use with Javascript. Please note that CodeIgniter does not require the jQuery library to run, and that any scripting library will work equally well. The jQuery library is simply presented as a convenience if you choose to use it.

    Initializing the Class

    -

    To initialize the jQuery class manually in your controller constructor, use the $this->load->library function. Currently, the only available library is jQuery, which will automatically be loaded like this:

    +

    To initialize the Javascript class manually in your controller constructor, use the $this->load->library function. Currently, the only available library is jQuery, which will automatically be loaded like this:

    $this->load->library('javascript'); @@ -72,33 +74,174 @@

    Initializing the Class

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

    Setup and Configuration

    Set these variables in your view

    -

    As a javascript library, your files must be available to your application. For your convenience, the needed files to run this library are available for download from our site.

    -

    As javascript is a client side language, the library must be able to write content into your final output. This generally means a view. You'll need to include the following variables in the <head> sections of your output.

    +

    As a Javascript library, your files must be available to your application.

    +

    As Javascript is a client side language, the library must be able to write content into your final output. This generally means a view. You'll need to include the following variables in the <head> sections of your output.

    <?php echo $library_src;?>
    <?php echo $script_head;?>

    $library_src, is where the actual library file will be loaded, as well as any subsequent plugin script calls; $script_head is where specific events, functions and other commands will be rendered.

    Set the path to the librarys with config items

    -

    There are some configuration items in javascript library. These can either be set in application/config.php, within its own confg/javascript.php file, or within any controller usings the set_item() function.

    +

    There are some configuration items in Javascript library. These can either be set in application/config.php, within its own config/javascript.php file, or within any controller usings the set_item() function.

    An image to be used as an "ajax loader", or progress indicator. Without one, the simple text message of "loading" will appear when Ajax calls need to be made.

    -

    $config['javascript_location'] = 'http://localhost/codeigniter/themes/js/jquery/');
    +

    $config['javascript_location'] = 'http://localhost/codeigniter/themes/js/jquery/';
    $config['javascript_ajax_img'] = 'images/ajax-loader.gif';

    If you keep your files in the same directories they were downloaded from, then you need not set this configuration items.

    -

    For information on outputting events, effects, etc., refer to the jQuery Class documentation.

    +

    The jQuery Class

    + +

    To initialize the jQuery class manually in your controller constructor, use the $this->load->library function:

    + +$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:

    + +$this->load->library('jquery', FALSE); + +

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

    + +

    jQuery Events

    + +

    Events are set using the following syntax.

    + +

    $this->jquery->event('element_path', code_to_run());

    + +

    In the above example:

    + +
      +
    • "event" is any of blur, change, click, dblclick, error, focus, hover, keydown, keyup, load, mousedown, mouseup, mouseover, mouseup, resize, scroll, or unload.
    • +
    • "element_path" is any valid jQuery selector. Due to jQuery's unique selector syntax, this is usually an element id, or CSS selector. For example "#notice_area" would effect <div id="notice_area">, and "#content a.notice" would effect all anchors with a class of "notice" in the div with id "content".
    • +
    • "code_to_run()" is script your write yourself, or an action such as an effect from the jQuery library below.
    • +
    + +

    Effects

    + +

    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 +$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);

    + +
      +
    • "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.
    • +
    • "extra information" is optional, and could include a callback, or other additional information.
    • +
    + +

    toggle()

    + +

    toggle() will change the visibility of an item to the opposite of its current state, hiding visible elements, and revealing hidden ones.

    +

    $this->jquery->toggle(target);

    +
      +
    • "target" will be any valid jQuery selector or selectors.
    • +
    + +

    animate()

    + +

    $this->jquery->animate(target, parameters, optional speed, optional extra information);

    +
      +
    • "target" will be any valid jQuery selector or selectors.
    • +
    • "parameters" in jQuery would generally include a series of CSS properties that you wish to change.
    • +
    • "speed" is optional, and is set to either slow, normal, fast, or alternatively a number of milliseconds.
    • +
    • "extra information" is optional, and could include a callback, or other additional information.
    • +
    +

    For a full summary, see http://docs.jquery.com/Effects/animate

    +

    Here is an example of an animate() called on a div with an id of "note", and triggered by a click using the jQuery library's click() event.

    +

    $params = array(
    + 'height' => 80,
    + 'width' => '50%',
    + 'marginLeft' => 125
    +);
    +$this->jquery->click('#trigger', $this->jquery->animate('#note', $params, normal));

    + +

    fadeIn() / fadeOut()

    + +

    $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.
    • +
    • "extra information" is optional, and could include a callback, or other additional information.
    • +
    + +

    toggleClass()

    + +

    This function will add or remove a CSS class to its target.

    +

    $this->jquery->toggleClass(target, class)

    +
      +
    • "target" will be any valid jQuery selector or selectors.
    • +
    • "class" is any CSS classname. Note that this class must be defined and available in a CSS that is already loaded.
    • +
    + +

    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);

    +
      +
    • "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.
    • +
    • "extra information" is optional, and could include a callback, or other additional information.
    • +
    + +

    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);

    +
      +
    • "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.
    • +
    • "extra information" is optional, and could include a callback, or other additional information.
    • +
    + +

    Plugins

    + +

    + +

    Some select jQuery plugins are made available using this library.

    + +

    corner()

    +

    Used to add distinct corners to page elements. For full details see http://www.malsup.com/jquery/corner/

    +

    $this->jquery->corner(target, corner_style);

    +
      +
    • "target" will be any valid jQuery selector or selectors.
    • +
    • "corner_style" is optional, and can be set to any valid style such as round, sharp, bevel, bite, dog, etc. Individual corners can be set by following the style with a space and using "tl" (top left), "tr" (top right), "bl" (bottom left), or "br" (bottom right).
    • +
    +

    $this->jquery->corner("#note", "cool tl br");

    + +

    tablesorter()

    + +

    description to come

    + +

    modal()

    + +

    description to come

    + +

    calendar()

    + +

    description to come

    +
    - \ No newline at end of file + diff --git a/user_guide/libraries/jquery.html b/user_guide/libraries/jquery.html deleted file mode 100644 index d8307f34..00000000 --- a/user_guide/libraries/jquery.html +++ /dev/null @@ -1,236 +0,0 @@ - - - - -CodeIgniter User Guide : Input Class - - - - - - - - - - - - - - - - - - - - - - -
    - - - - - -

    CodeIgniter User Guide Version 2.0.0

    -
    - - - - - - - - - -
    - - -
    - - - -
    - - -

    jQuery Class

    - -

    jQuery is a fast, concise, JavaScript Library that simplifies how you traverse HTML documents, handle events, perform animations, and add Ajax interactions to your web pages. CodeIgniter provides a library to help you with certain common functions that you may want to use within jQuery. Please note that CodeIgniter does not require the jQuery library to run, and that any scripting library will work equally well. The jQuery library is simply presented as a convenience if you choose to use it.

    - -

    Initializing the Class

    - -

    To initialize the jQuery class manually in your controller constructor, use the $this->load->library function:

    - -$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:

    - -$this->load->library('jquery', FALSE); - -

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

    - -

    Setup and Configuration

    - -

    As a javascript library, jquery.js must be available to your application. For your convenience, the needed files to run this library are available for download from our site.

    - -

    As javascript is a client side language, the library must be able to write content into your final output. This generally means a view. You'll need to include the following variables in the <head> sections of your output.

    - -

    <?php echo $jquery_script;?>
    -<?php echo $script_head;?>

    - -

    There are 2 configuration items in jQuery library. These can either be set in application/config.php, or within any controller. The first is the path from the root of your site to the jquery library ('js' is the default) and the second is an image to be used as an "ajax loader", or progress indicator. Without one, the simple text message of "loading" will appear when Ajax calls need to be made.

    - -

    $config['javascript_folder'] = 'js';
    - $config['javascript_ajax_img'] = 'images/ajax-loader.gif';

    - -

    If you keep your files in the same directories they were downloaded from, then you needed set this configuration items.

    - -

    Events

    - -

    Events are set using the following syntax.

    - -

    $this->jquery->event('element_path', code_to_run());

    - -

    In the above example:

    - -
      -
    • "event" is any of blur, change, click, dblclick, error, focus, hover, keydown, keyup, load, mousedown, mouseup, mouseover, mouseup, resize, scroll, or unload.
    • -
    • "element_path" is any valid jQuery selector. Due to jQuery's unique selector syntax, this is usually an element id, or CSS selector. For example "#notice_area" would effect <div id="notice_area">, and "#content a.notice" would effect all anchors with a class of "notice" in the div with id "content".
    • -
    • "code_to_run()" is script your write yourself, or an action such as an effect from the jQuery library below.
    • -
    - -

    Effects

    - -

    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 -$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);

    - -
      -
    • "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.
    • -
    • "extra information" is optional, and could include a callback, or other additional information.
    • -
    - -

    toggle()

    - -

    toggle() will change the visibility of an item to the opposite of its current state, hiding visible elements, and revealing hidden ones.

    -

    $this->jquery->toggle(target);

    -
      -
    • "target" will be any valid jQuery selector or selectors.
    • -
    - -

    animate()

    - -

    $this->jquery->animate(target, parameters, optional speed, optional extra information);

    -
      -
    • "target" will be any valid jQuery selector or selectors.
    • -
    • "paramters" in jQuery would generally include a series of CSS properties that you wish to change.
    • -
    • "speed" is optional, and is set to either slow, normal, fast, or alternatively a number of milliseconds.
    • -
    • "extra information" is optional, and could include a callback, or other additional information.
    • -
    -

    For a full summary, see http://docs.jquery.com/Effects/animate

    -

    Here is an example of an animate() called on a div with an id of "note", and triggered by a click using the jQuery library's click() event.

    -

    $params = array(
    - 'height' => 80,
    - 'width' => '50%',
    - 'marginLeft' => 125
    -);
    -$this->jquery->click('#trigger', $this->jquery->animate('#note', $params, normal));

    - -

    fadeIn() / fadeOut()

    - -

    $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.
    • -
    • "extra information" is optional, and could include a callback, or other additional information.
    • -
    - -

    toggleClass()

    - -

    This function will add or remove a CSS class to its target.

    -

    $this->jquery->toggleClass(target, class)

    -
      -
    • "target" will be any valid jQuery selector or selectors.
    • -
    • "class" is any CSS classname. Note that this class must be defined and available in a CSS that is already loaded.
    • -
    - -

    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);

    -
      -
    • "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.
    • -
    • "extra information" is optional, and could include a callback, or other additional information.
    • -
    - -

    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);

    -
      -
    • "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.
    • -
    • "extra information" is optional, and could include a callback, or other additional information.
    • -
    - -

    Plugins

    - -

    - -

    Some select jQuery plugins are made available using this library.

    - -

    corner()

    -

    Used to add distinct corners to page elements. For full details see http://www.malsup.com/jquery/corner/

    -

    $this->jquery->corner(target, corner_style);

    -
      -
    • "target" will be any valid jQuery selector or selectors.
    • -
    • "corner_style" is optional, and can be set to any valid style such as round, sharp, bevel, bite, dog, etc. Individual corners can be set by following the style with a space and using "tl" (top left), "tr" (top right), "bl" (bottom left), or "br" (bottom right).
    • -
    -

    $this->jquery->corner("#note", "cool tl br");

    - -

    tablesorter()

    - -

    description to come

    - -

    modal()

    - -

    description to come

    - -

    calendar()

    - -

    description to come

    - -
    - - - - - - - \ No newline at end of file diff --git a/user_guide/libraries/language.html b/user_guide/libraries/language.html index c37f0092..75863c2a 100644 --- a/user_guide/libraries/language.html +++ b/user_guide/libraries/language.html @@ -28,7 +28,7 @@
    - +

    CodeIgniter User Guide Version 2.0.0

    CodeIgniter User Guide Version 2.0.2

    @@ -130,7 +130,7 @@

    Auto-loading Languages

    User Guide Home   ·   Next Topic:  Output Class

    -

    CodeIgniter  ·  Copyright © 2006-2010  ·  EllisLab, Inc.

    +

    CodeIgniter  ·  Copyright © 2006 - 2011  ·  EllisLab, Inc.

    diff --git a/user_guide/libraries/loader.html b/user_guide/libraries/loader.html index 34e3929a..a472730c 100644 --- a/user_guide/libraries/loader.html +++ b/user_guide/libraries/loader.html @@ -28,7 +28,7 @@
    - +

    CodeIgniter User Guide Version 2.0.0

    CodeIgniter User Guide Version 2.0.2

    @@ -90,6 +90,10 @@

    $this->load->library('class_name', $config, 'ob

    You may nest the file in as many subdirectories as you want.

    +

    Additionally, multiple libraries can be loaded at the same time by passing an array of libraries to the load function.

    + +$this->load->library(array('email', 'table')); +

    Setting options

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

    @@ -105,6 +109,8 @@

    Setting options

    Config options can usually also be set via a config file. Each library is explained in detail in its own page, so please read the information regarding each one you would like to use.

    +

    Please take note, when multiple libraries are supplied in an array for the first parameter, each will receive the same parameter information.

    +

    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 @@ -120,6 +126,7 @@

    Assigning a Library to a different object name

    +

    Please take note, when multiple libraries are supplied in an array for the first parameter, this parameter is discarded.

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

    @@ -168,6 +175,12 @@

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

    +

    $this->load->get_var($key)

    + +

    This function checks the associative array of variables available to your views. This is useful if for any reason a var is set in a library or another controller method using $this->load->vars(). +

    + +

    $this->load->helper('file_name')

    This function loads helper files, where file_name is the name of the file, without the _helper.php extension.

    @@ -224,17 +237,22 @@

    $this->load->remove_package_path()

    Package view files

    -

    @todo - package view file interface is not complete. It can be experimentally used by first saving the Loader's original view path, setting the view path to the package's view path, and when finished, setting back to the original view path.

    - -// ... save the original view path, and set to our Foo Bar package view folder
    -$orig_view_path = $this->load->_ci_view_path;
    -$this->load->_ci_view_path = APPPATH.'third_party/foo_bar/views/';
    -
    -// ... code using the package's view files
    -
    -// ... then return the view path to the application's original view path
    -$this->load->_ci_view_path = $orig_view_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);
    +$this->load->view('my_app_index'); // Loads
    +$this->load->view('welcome_message'); // Will not load the default welcome_message b/c the second param to add_package_path is TRUE
    +
    +// Reset things
    +$this->load->remove_package_path(APPPATH.'my_app');
    +
    +// Again without the second parameter:
    +$this->load->add_package_path(APPPATH.'my_app', TRUE);
    +$this->load->view('my_app_index'); // Loads
    +$this->load->view('welcome_message'); // Loads
    +
    @@ -248,7 +266,7 @@

    Package view files

    User Guide Home   ·   Next Topic:  Language Class

    -

    CodeIgniter  ·  Copyright © 2006-2010  ·  EllisLab, Inc.

    +

    CodeIgniter  ·  Copyright © 2006 - 2011  ·  EllisLab, Inc.

    diff --git a/user_guide/libraries/output.html b/user_guide/libraries/output.html index a1427de7..4d1f8d97 100644 --- a/user_guide/libraries/output.html +++ b/user_guide/libraries/output.html @@ -28,7 +28,7 @@
    - +

    CodeIgniter User Guide Version 2.0.0

    CodeIgniter User Guide Version 2.0.2

    @@ -78,6 +78,21 @@

    $this->output->set_output();

    For example, if you build a page in one of your controller functions, don't set the output until the end.

    +

    $this->output->set_content_type();

    + +

    Permits you to set the mime-type of your page so you can serve JSON data, JPEG's, XML, etc easily.

    + +$this->output
    +    ->set_content_type('application/json')
    +    ->set_output(json_encode(array('foo' => 'bar')));
    +
    +$this->output
    +    ->set_content_type('jpeg') // You could also use ".jpeg" which will have the full stop removed before looking in config/mimes.php
    +    ->set_output(file_get_contents('files/something.jpg'));
    + +

    Important: Make sure any non-mime string you pass to this method exists in config/mimes.php or it will have no effect.

    + +

    $this->output->get_output();

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

    @@ -155,7 +170,7 @@

    Parsing Execution Variables

    User Guide Home   ·   Next Topic:  Pagination Class

    -

    CodeIgniter  ·  Copyright © 2006-2010  ·  EllisLab, Inc.

    +

    CodeIgniter  ·  Copyright © 2006 - 2011  ·  EllisLab, Inc.

    diff --git a/user_guide/libraries/pagination.html b/user_guide/libraries/pagination.html index 42c102c8..3c366a69 100644 --- a/user_guide/libraries/pagination.html +++ b/user_guide/libraries/pagination.html @@ -28,7 +28,7 @@
    - +

    CodeIgniter User Guide Version 2.0.0

    CodeIgniter User Guide Version 2.0.2

    @@ -71,8 +71,8 @@

    Example

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

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

    $this->pagination->initialize($config); @@ -222,7 +222,7 @@

    Adding a class to every anchor

    User Guide Home   ·   Next Topic:  Session Class

    -

    CodeIgniter  ·  Copyright © 2006-2010  ·  EllisLab, Inc.

    +

    CodeIgniter  ·  Copyright © 2006 - 2011  ·  EllisLab, Inc.

    diff --git a/user_guide/libraries/parser.html b/user_guide/libraries/parser.html index ece61c1f..cb2f100a 100644 --- a/user_guide/libraries/parser.html +++ b/user_guide/libraries/parser.html @@ -28,7 +28,7 @@
    - +

    CodeIgniter User Guide Version 2.0.0

    CodeIgniter User Guide Version 2.0.2

    @@ -205,7 +205,7 @@

    Variable Pairs

    User Guide Home   ·   Next Topic:  Typography

    -

    CodeIgniter  ·  Copyright © 2006-2010  ·  EllisLab, Inc.

    +

    CodeIgniter  ·  Copyright © 2006 - 2011  ·  EllisLab, Inc.

    diff --git a/user_guide/libraries/security.html b/user_guide/libraries/security.html index 6d6216d9..73518745 100644 --- a/user_guide/libraries/security.html +++ b/user_guide/libraries/security.html @@ -28,7 +28,7 @@
    - +

    CodeIgniter User Guide Version 2.0.0

    CodeIgniter User Guide Version 2.0.2

    @@ -104,11 +104,18 @@

    $this->security->sanitize_filename()

    If it is acceptable for the user input to include relative paths, e.g. file/in/some/approved/folder.txt, you can set the second optional parameter, $relative_path to TRUE.

    - + $filename = $this->security->sanitize_filename($this->input->post('filename'), TRUE); +

    Cross-site request forgery (CSRF)

    + +

    You can enable csrf protection by opening your application/config/config.php file and setting this:

    +$config['csrf_protection'] = TRUE; + +

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

    +
    @@ -121,7 +128,7 @@

    $this->security->sanitize_filename()

    User Guide Home   ·   Next Topic:  Session Class

    -

    CodeIgniter  ·  Copyright © 2006-2010  ·  EllisLab, Inc.

    +

    CodeIgniter  ·  Copyright © 2006 - 2011  ·  EllisLab, Inc.

    diff --git a/user_guide/libraries/sessions.html b/user_guide/libraries/sessions.html index 2d295d72..75ea0e6d 100644 --- a/user_guide/libraries/sessions.html +++ b/user_guide/libraries/sessions.html @@ -28,7 +28,7 @@
    - +

    CodeIgniter User Guide Version 2.0.0

    CodeIgniter User Guide Version 2.0.2

    @@ -105,8 +105,8 @@

    What is Session Data?

    • 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 user's User Agent data (the first 120 characters of the browser data string)
    • +
    • The "last activity" time stamp.

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

    @@ -170,6 +170,23 @@

    Adding Custom Session Data

    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

    +

    An array of all userdata can be retrieved as follows:

    +$this->session->all_userdata() + +

    And returns an associative array like the following:

    + +
    +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
    +)
    +
    + +

    Removing Session Data

    Just as set_userdata() can be used to add information into a session, unset_userdata() can be used to remove it, by passing the session key. For example, if you wanted to remove 'some_name' from your session information:

    $this->session->unset_userdata('some_name');

    @@ -201,15 +218,17 @@

    Saving Session Data to a Database

    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:

    - + session_id varchar(40) DEFAULT '0' NOT NULL, + ip_address varchar(16) DEFAULT '0' NOT NULL, + user_agent varchar(120) NOT NULL, + last_activity int(10) unsigned DEFAULT 0 NOT NULL, + user_data text NOT NULL, + PRIMARY KEY (session_id), + KEY `last_activity_idx` (`last_activity`) +); +

    Note: By default the table is called ci_sessions, but you can name it anything you want as long as you update the application/config/config.php file so that it contains the name you have chosen. @@ -315,7 +334,7 @@

    Session Preferences

    User Guide Home   ·   Next Topic:  Trackback Class

    -

    CodeIgniter  ·  Copyright © 2006-2010  ·  EllisLab, Inc.

    +

    CodeIgniter  ·  Copyright © 2006 - 2011  ·  EllisLab, Inc.

    diff --git a/user_guide/libraries/table.html b/user_guide/libraries/table.html index 094d7aac..eeb3b421 100644 --- a/user_guide/libraries/table.html +++ b/user_guide/libraries/table.html @@ -27,7 +27,7 @@
    - +

    CodeIgniter User Guide Version 2.0.0

    CodeIgniter User Guide Version 2.0.2

    @@ -308,7 +308,7 @@

    $this->table->function

    User Guide Home   ·   Next Topic:  Image Manipulation Class

    -

    CodeIgniter  ·  Copyright © 2006-2010  ·  EllisLab, Inc.

    +

    CodeIgniter  ·  Copyright © 2006 - 2011  ·  EllisLab, Inc.

    diff --git a/user_guide/libraries/trackback.html b/user_guide/libraries/trackback.html index a07b8d1f..7f89b4f5 100644 --- a/user_guide/libraries/trackback.html +++ b/user_guide/libraries/trackback.html @@ -28,7 +28,7 @@
    - +

    CodeIgniter User Guide Version 2.0.0

    CodeIgniter User Guide Version 2.0.2

    @@ -239,7 +239,7 @@

    Notes:

    User Guide Home   ·   Next Topic:  Template Parser Class

    -

    CodeIgniter  ·  Copyright © 2006-2010  ·  EllisLab, Inc.

    +

    CodeIgniter  ·  Copyright © 2006 - 2011  ·  EllisLab, Inc.

    diff --git a/user_guide/libraries/typography.html b/user_guide/libraries/typography.html index e78af5f9..895e76f7 100644 --- a/user_guide/libraries/typography.html +++ b/user_guide/libraries/typography.html @@ -28,7 +28,7 @@
    - +

    CodeIgniter User Guide Version 2.0.0

    CodeIgniter User Guide Version 2.0.2

    @@ -153,7 +153,7 @@

    protect_braced_quotes

    User Guide Home   ·   Next Topic:  Unit Testing Class

    -

    CodeIgniter  ·  Copyright © 2006-2010  ·  EllisLab, Inc.

    +

    CodeIgniter  ·  Copyright © 2006 - 2011  ·  EllisLab, Inc.

    diff --git a/user_guide/libraries/unit_testing.html b/user_guide/libraries/unit_testing.html index 84db5443..5e0c4c16 100644 --- a/user_guide/libraries/unit_testing.html +++ b/user_guide/libraries/unit_testing.html @@ -28,7 +28,7 @@
    - +

    CodeIgniter User Guide Version 2.0.0

    CodeIgniter User Guide Version 2.0.2

    @@ -219,7 +219,7 @@

    Creating a Template

    User Guide Home   ·   Next Topic:  URI Class

    -

    CodeIgniter  ·  Copyright © 2006-2010  ·  EllisLab, Inc.

    +

    CodeIgniter  ·  Copyright © 2006 - 2011  ·  EllisLab, Inc.

    diff --git a/user_guide/libraries/uri.html b/user_guide/libraries/uri.html index b2f5ac3d..e4e0f9d3 100644 --- a/user_guide/libraries/uri.html +++ b/user_guide/libraries/uri.html @@ -28,7 +28,7 @@
    - +

    CodeIgniter User Guide Version 2.0.0

    CodeIgniter User Guide Version 2.0.2

    @@ -245,7 +245,7 @@

    $this->uri->rsegment_array()

    User Guide Home   ·   Next Topic:  User Agent Class

    -

    CodeIgniter  ·  Copyright © 2006-2010  ·  EllisLab, Inc.

    +

    CodeIgniter  ·  Copyright © 2006 - 2011  ·  EllisLab, Inc.

    diff --git a/user_guide/libraries/user_agent.html b/user_guide/libraries/user_agent.html index d2f79d2e..24e8071f 100644 --- a/user_guide/libraries/user_agent.html +++ b/user_guide/libraries/user_agent.html @@ -28,7 +28,7 @@
    - +

    CodeIgniter User Guide Version 2.0.0

    CodeIgniter User Guide Version 2.0.2

    @@ -219,7 +219,7 @@

    $this->agent->accept_charset()

    User Guide Home   ·   Next Topic:  XML-RPC Class

    -

    CodeIgniter  ·  Copyright © 2006-2010  ·  EllisLab, Inc.

    +

    CodeIgniter  ·  Copyright © 2006 - 2011  ·  EllisLab, Inc.

    diff --git a/user_guide/libraries/xmlrpc.html b/user_guide/libraries/xmlrpc.html index 87ca0948..5ba85134 100644 --- a/user_guide/libraries/xmlrpc.html +++ b/user_guide/libraries/xmlrpc.html @@ -28,7 +28,7 @@
    - +

    CodeIgniter User Guide Version 2.0.0

    CodeIgniter User Guide Version 2.0.2

    @@ -512,7 +512,7 @@

    Data Types

    User Guide Home   ·   Next Topic:  Zip Encoding Class

    -

    CodeIgniter  ·  Copyright © 2006-2010  ·  EllisLab, Inc.

    +

    CodeIgniter  ·  Copyright © 2006 - 2011  ·  EllisLab, Inc.

    diff --git a/user_guide/libraries/zip.html b/user_guide/libraries/zip.html index d57dd48a..087b4adf 100644 --- a/user_guide/libraries/zip.html +++ b/user_guide/libraries/zip.html @@ -28,7 +28,7 @@
    - +

    CodeIgniter User Guide Version 2.0.0

    CodeIgniter User Guide Version 2.0.2

    @@ -279,9 +279,9 @@

    $this->zip->clear_data()

       ·   Top of Page   ·   User Guide Home   ·   -Next Topic:  Array Helper +Next Topic:  Caching Class

    -

    CodeIgniter  ·  Copyright © 2006-2010  ·  EllisLab, Inc.

    +

    CodeIgniter  ·  Copyright © 2006 - 2011  ·  EllisLab, Inc.

    diff --git a/user_guide/license.html b/user_guide/license.html index c76035d1..8f53851a 100644 --- a/user_guide/license.html +++ b/user_guide/license.html @@ -28,7 +28,7 @@
    - +

    CodeIgniter User Guide Version 2.0.0

    CodeIgniter User Guide Version 2.0.2

    @@ -60,7 +60,7 @@

    CodeIgniter License Agreement

    -

    Copyright (c) 2008 - 2010, EllisLab, Inc.
    +

    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.

    @@ -100,7 +100,7 @@

    Limitations of Liability

    User Guide Home   ·   Next Topic:  Change Log

    -

    CodeIgniter  ·  Copyright © 2006-2010  ·  EllisLab, Inc.

    +

    CodeIgniter  ·  Copyright © 2006 - 2011  ·  EllisLab, Inc.

    diff --git a/user_guide/nav/nav.js b/user_guide/nav/nav.js index 4ac10991..b44994d4 100644 --- a/user_guide/nav/nav.js +++ b/user_guide/nav/nav.js @@ -50,6 +50,8 @@ function create_menu(basepath) '
  • Helpers
  • ' + '
  • Using CodeIgniter Libraries
  • ' + '
  • Creating Your Own Libraries
  • ' + + '
  • Using CodeIgniter Drivers
  • ' + + '
  • Creating Your Own Drivers
  • ' + '
  • Creating Core Classes
  • ' + '
  • Hooks - Extending the Core
  • ' + '
  • Auto-loading Resources
  • ' + @@ -58,13 +60,21 @@ function create_menu(basepath) '
  • Error Handling
  • ' + '
  • Caching
  • ' + '
  • Profiling Your Application
  • ' + + '
  • Running via the CLI
  • ' + '
  • Managing Applications
  • ' + + '
  • Handling Multiple Environments
  • ' + '
  • Alternative PHP Syntax
  • ' + '
  • Security
  • ' + '
  • PHP Style Guide
  • ' + '
  • Writing Documentation
  • ' + '' + + '

    Additional Resources

    ' + + '' + + '' + '

    Class Reference

    ' + @@ -73,7 +83,6 @@ function create_menu(basepath) '
  • Calendar Class
  • ' + '
  • Cart Class
  • ' + '
  • Config Class
  • ' + - '
  • Database Class
  • ' + '
  • Email Class
  • ' + '
  • Encryption Class
  • ' + '
  • File Uploading Class
  • ' + @@ -82,6 +91,7 @@ function create_menu(basepath) '
  • HTML Table Class
  • ' + '
  • Image Manipulation Class
  • ' + '
  • Input Class
  • ' + + '
  • Javascript Class
  • ' + '
  • Loader Class
  • ' + '
  • Language Class
  • ' + '
  • Output Class
  • ' + @@ -100,6 +110,13 @@ function create_menu(basepath) '' + + '

    Driver Reference

    ' + + '' + + '

    Helper Reference

    ' + '' + - '

    Additional Resources

    ' + - '' + - ''); } \ No newline at end of file diff --git a/user_guide/overview/appflow.html b/user_guide/overview/appflow.html index 804c81d0..7c8d4acc 100644 --- a/user_guide/overview/appflow.html +++ b/user_guide/overview/appflow.html @@ -28,7 +28,7 @@
    - +

    CodeIgniter User Guide Version 2.0.0

    CodeIgniter User Guide Version 2.0.2

    @@ -60,7 +60,7 @@

    Application Flow Chart

    The following graphic illustrates how data flows throughout the system:

    -
    CodeIgniter application flow
    +
    CodeIgniter application flow
      @@ -88,7 +88,7 @@

      Application Flow Chart

      User Guide Home   ·   Next Topic:  Model-View-Controller

      -

      CodeIgniter  ·  Copyright © 2006-2010  ·  EllisLab, Inc.

      +

      CodeIgniter  ·  Copyright © 2006 - 2011  ·  EllisLab, Inc.

    diff --git a/user_guide/overview/at_a_glance.html b/user_guide/overview/at_a_glance.html index f54a4e90..b6b81d76 100644 --- a/user_guide/overview/at_a_glance.html +++ b/user_guide/overview/at_a_glance.html @@ -28,7 +28,7 @@
    - +

    CodeIgniter User Guide Version 2.0.0

    CodeIgniter User Guide Version 2.0.2

    @@ -155,7 +155,7 @@

    CodeIgniter has a Friendly Community of Users

    User Guide Home   ·   Next Topic:  CodeIgniter Cheatsheets

    -

    CodeIgniter  ·  Copyright © 2006-2010  ·  EllisLab, Inc.

    +

    CodeIgniter  ·  Copyright © 2006 - 2011  ·  EllisLab, Inc.

    diff --git a/user_guide/overview/cheatsheets.html b/user_guide/overview/cheatsheets.html index cf200e08..1c58c584 100644 --- a/user_guide/overview/cheatsheets.html +++ b/user_guide/overview/cheatsheets.html @@ -28,7 +28,7 @@
    - +

    CodeIgniter User Guide Version 2.0.0

    CodeIgniter User Guide Version 2.0.2

    @@ -76,7 +76,7 @@

    Helpers Reference

    User Guide Home   ·   Next Topic:  CodeIgniter Features

    -

    CodeIgniter  ·  Copyright © 2006-2010  ·  EllisLab, Inc.

    +

    CodeIgniter  ·  Copyright © 2006 - 2011  ·  EllisLab, Inc.

    diff --git a/user_guide/overview/features.html b/user_guide/overview/features.html index 3ce6391f..e20219e0 100644 --- a/user_guide/overview/features.html +++ b/user_guide/overview/features.html @@ -28,7 +28,7 @@
    - +

    CodeIgniter User Guide Version 2.0.0

    CodeIgniter User Guide Version 2.0.2

    @@ -111,7 +111,7 @@

    CodeIgniter Features

    User Guide Home   ·   Next Topic:  Application Flow Chart

    -

    CodeIgniter  ·  Copyright © 2006-2010  ·  EllisLab, Inc.

    +

    CodeIgniter  ·  Copyright © 2006 - 2011  ·  EllisLab, Inc.

    diff --git a/user_guide/overview/getting_started.html b/user_guide/overview/getting_started.html index 88027eed..f120913f 100644 --- a/user_guide/overview/getting_started.html +++ b/user_guide/overview/getting_started.html @@ -28,7 +28,7 @@
    - +

    CodeIgniter User Guide Version 2.0.0

    CodeIgniter User Guide Version 2.0.2

    @@ -85,7 +85,7 @@

    Getting Started With CodeIgniter

    User Guide Home   ·   Next Topic:  CodeIgniter At a Glance

    -

    CodeIgniter  ·  Copyright © 2006-2010  ·  EllisLab, Inc.

    +

    CodeIgniter  ·  Copyright © 2006 - 2011  ·  EllisLab, Inc.

    diff --git a/user_guide/overview/goals.html b/user_guide/overview/goals.html index e708753e..754ecaae 100644 --- a/user_guide/overview/goals.html +++ b/user_guide/overview/goals.html @@ -28,7 +28,7 @@
    - +

    CodeIgniter User Guide Version 2.0.0

    CodeIgniter User Guide Version 2.0.2

    @@ -91,7 +91,7 @@

    Design and Architectural Goals

    User Guide Home   ·   Next Topic:  Getting Started

    -

    CodeIgniter  ·  Copyright © 2006-2010  ·  EllisLab, Inc.

    +

    CodeIgniter  ·  Copyright © 2006 - 2011  ·  EllisLab, Inc.

    diff --git a/user_guide/overview/index.html b/user_guide/overview/index.html index 59ee05c5..bbe3e36f 100644 --- a/user_guide/overview/index.html +++ b/user_guide/overview/index.html @@ -28,7 +28,7 @@
    - +

    CodeIgniter User Guide Version 2.0.0

    CodeIgniter User Guide Version 2.0.2

    @@ -77,7 +77,7 @@

    CodeIgniter Overview

    diff --git a/user_guide/overview/mvc.html b/user_guide/overview/mvc.html index d0b1aa2e..91cf6497 100644 --- a/user_guide/overview/mvc.html +++ b/user_guide/overview/mvc.html @@ -28,7 +28,7 @@
    - +

    CodeIgniter User Guide Version 2.0.0

    CodeIgniter User Guide Version 2.0.2

    @@ -93,7 +93,7 @@

    Model-View-Controller

    User Guide Home   ·   Next Topic:  Architectural Goals

    -

    CodeIgniter  ·  Copyright © 2006-2010  ·  EllisLab, Inc.

    +

    CodeIgniter  ·  Copyright © 2006 - 2011  ·  EllisLab, Inc.

    diff --git a/user_guide/toc.html b/user_guide/toc.html index eed673c8..f6a5fe0e 100644 --- a/user_guide/toc.html +++ b/user_guide/toc.html @@ -29,7 +29,7 @@
    - +

    CodeIgniter User Guide Version 2.0.0

    CodeIgniter User Guide Version 2.0.2

    @@ -103,6 +103,8 @@

    General Topics

  • Helpers
  • Using CodeIgniter Libraries
  • Creating Your Own Libraries
  • +
  • Using CodeIgniter Drivers
  • +
  • Creating Your Own Drivers
  • Creating Core Classes
  • Hooks - Extending the Core
  • Auto-loading Resources
  • @@ -111,13 +113,22 @@

    General Topics

  • Error Handling
  • Caching
  • Profiling Your Application
  • +
  • Running via the CLI
  • Managing Applications
  • +
  • Handling Multiple Environments
  • Alternative PHP Syntax
  • Security
  • PHP Style Guide
  • Writing Documentation
  • +

    Additional Resources

    + + + @@ -127,7 +138,6 @@

    Class Reference

  • Calendar Class
  • Cart Class
  • Config Class
  • -
  • Database Class
  • Email Class
  • Encryption Class
  • File Uploading Class
  • @@ -136,6 +146,7 @@

    Class Reference

  • HTML Table Class
  • Image Manipulation Class
  • Input Class
  • +
  • Javascript Class
  • Loader Class
  • Language Class
  • Output Class
  • @@ -156,6 +167,13 @@

    Class Reference

    +

    Driver Reference

    + +

    Helper Reference

    -

    Additional Resources

    - @@ -199,7 +212,7 @@

    Additional Resources

    diff --git a/user_guide/userguide.css b/user_guide/userguide.css index 57c2b05e..f93ff0d7 100644 --- a/user_guide/userguide.css +++ b/user_guide/userguide.css @@ -259,6 +259,9 @@ padding: 3px 0 7px 3px; margin: 10px 0 12px 0; } +li.reactor { + list-style-image: url(images/reactor-bullet.png); +} #content li { margin-bottom: 9px; }