CodeIgniter installed
authorCalin Burloiu <calin.burloiu@gmail.com>
Tue, 5 Jul 2011 13:43:36 +0000 (16:43 +0300)
committerCalin Burloiu <calin.burloiu@gmail.com>
Tue, 5 Jul 2011 13:43:36 +0000 (16:43 +0300)
323 files changed:
application/.htaccess [new file with mode: 0755]
application/cache/.htaccess [new file with mode: 0755]
application/cache/index.html [new file with mode: 0755]
application/config/autoload.php [new file with mode: 0755]
application/config/config.php [new file with mode: 0755]
application/config/constants.php [new file with mode: 0755]
application/config/database.php [new file with mode: 0755]
application/config/doctypes.php [new file with mode: 0755]
application/config/foreign_chars.php [new file with mode: 0755]
application/config/hooks.php [new file with mode: 0755]
application/config/index.html [new file with mode: 0755]
application/config/mimes.php [new file with mode: 0755]
application/config/profiler.php [new file with mode: 0755]
application/config/routes.php [new file with mode: 0755]
application/config/smileys.php [new file with mode: 0755]
application/config/user_agents.php [new file with mode: 0755]
application/controllers/index.html [new file with mode: 0755]
application/controllers/welcome.php [new file with mode: 0755]
application/core/index.html [new file with mode: 0755]
application/errors/error_404.php [new file with mode: 0755]
application/errors/error_db.php [new file with mode: 0755]
application/errors/error_general.php [new file with mode: 0755]
application/errors/error_php.php [new file with mode: 0755]
application/errors/index.html [new file with mode: 0755]
application/helpers/index.html [new file with mode: 0755]
application/hooks/index.html [new file with mode: 0755]
application/index.html [new file with mode: 0755]
application/language/english/index.html [new file with mode: 0755]
application/libraries/index.html [new file with mode: 0755]
application/logs/index.html [new file with mode: 0755]
application/models/index.html [new file with mode: 0755]
application/third_party/index.html [new file with mode: 0755]
application/views/index.html [new file with mode: 0755]
application/views/welcome_message.php [new file with mode: 0755]
index.html [deleted file]
index.php [new file with mode: 0755]
license.txt [new file with mode: 0755]
system/.htaccess [new file with mode: 0755]
system/core/Benchmark.php [new file with mode: 0755]
system/core/CodeIgniter.php [new file with mode: 0755]
system/core/Common.php [new file with mode: 0755]
system/core/Config.php [new file with mode: 0755]
system/core/Controller.php [new file with mode: 0755]
system/core/Exceptions.php [new file with mode: 0755]
system/core/Hooks.php [new file with mode: 0755]
system/core/Input.php [new file with mode: 0755]
system/core/Lang.php [new file with mode: 0755]
system/core/Loader.php [new file with mode: 0755]
system/core/Model.php [new file with mode: 0755]
system/core/Output.php [new file with mode: 0755]
system/core/Router.php [new file with mode: 0755]
system/core/Security.php [new file with mode: 0755]
system/core/URI.php [new file with mode: 0755]
system/core/Utf8.php [new file with mode: 0755]
system/core/index.html [new file with mode: 0755]
system/database/DB.php [new file with mode: 0755]
system/database/DB_active_rec.php [new file with mode: 0755]
system/database/DB_cache.php [new file with mode: 0755]
system/database/DB_driver.php [new file with mode: 0755]
system/database/DB_forge.php [new file with mode: 0755]
system/database/DB_result.php [new file with mode: 0755]
system/database/DB_utility.php [new file with mode: 0755]
system/database/drivers/index.html [new file with mode: 0755]
system/database/drivers/mssql/index.html [new file with mode: 0755]
system/database/drivers/mssql/mssql_driver.php [new file with mode: 0755]
system/database/drivers/mssql/mssql_forge.php [new file with mode: 0755]
system/database/drivers/mssql/mssql_result.php [new file with mode: 0755]
system/database/drivers/mssql/mssql_utility.php [new file with mode: 0755]
system/database/drivers/mysql/index.html [new file with mode: 0755]
system/database/drivers/mysql/mysql_driver.php [new file with mode: 0755]
system/database/drivers/mysql/mysql_forge.php [new file with mode: 0755]
system/database/drivers/mysql/mysql_result.php [new file with mode: 0755]
system/database/drivers/mysql/mysql_utility.php [new file with mode: 0755]
system/database/drivers/mysqli/index.html [new file with mode: 0755]
system/database/drivers/mysqli/mysqli_driver.php [new file with mode: 0755]
system/database/drivers/mysqli/mysqli_forge.php [new file with mode: 0755]
system/database/drivers/mysqli/mysqli_result.php [new file with mode: 0755]
system/database/drivers/mysqli/mysqli_utility.php [new file with mode: 0755]
system/database/drivers/oci8/index.html [new file with mode: 0755]
system/database/drivers/oci8/oci8_driver.php [new file with mode: 0755]
system/database/drivers/oci8/oci8_forge.php [new file with mode: 0755]
system/database/drivers/oci8/oci8_result.php [new file with mode: 0755]
system/database/drivers/oci8/oci8_utility.php [new file with mode: 0755]
system/database/drivers/odbc/index.html [new file with mode: 0755]
system/database/drivers/odbc/odbc_driver.php [new file with mode: 0755]
system/database/drivers/odbc/odbc_forge.php [new file with mode: 0755]
system/database/drivers/odbc/odbc_result.php [new file with mode: 0755]
system/database/drivers/odbc/odbc_utility.php [new file with mode: 0755]
system/database/drivers/postgre/index.html [new file with mode: 0755]
system/database/drivers/postgre/postgre_driver.php [new file with mode: 0755]
system/database/drivers/postgre/postgre_forge.php [new file with mode: 0755]
system/database/drivers/postgre/postgre_result.php [new file with mode: 0755]
system/database/drivers/postgre/postgre_utility.php [new file with mode: 0755]
system/database/drivers/sqlite/index.html [new file with mode: 0755]
system/database/drivers/sqlite/sqlite_driver.php [new file with mode: 0755]
system/database/drivers/sqlite/sqlite_forge.php [new file with mode: 0755]
system/database/drivers/sqlite/sqlite_result.php [new file with mode: 0755]
system/database/drivers/sqlite/sqlite_utility.php [new file with mode: 0755]
system/database/index.html [new file with mode: 0755]
system/fonts/index.html [new file with mode: 0755]
system/fonts/texb.ttf [new file with mode: 0755]
system/helpers/array_helper.php [new file with mode: 0755]
system/helpers/captcha_helper.php [new file with mode: 0755]
system/helpers/cookie_helper.php [new file with mode: 0755]
system/helpers/date_helper.php [new file with mode: 0755]
system/helpers/directory_helper.php [new file with mode: 0755]
system/helpers/download_helper.php [new file with mode: 0755]
system/helpers/email_helper.php [new file with mode: 0755]
system/helpers/file_helper.php [new file with mode: 0755]
system/helpers/form_helper.php [new file with mode: 0755]
system/helpers/html_helper.php [new file with mode: 0755]
system/helpers/index.html [new file with mode: 0755]
system/helpers/inflector_helper.php [new file with mode: 0755]
system/helpers/language_helper.php [new file with mode: 0755]
system/helpers/number_helper.php [new file with mode: 0755]
system/helpers/path_helper.php [new file with mode: 0755]
system/helpers/security_helper.php [new file with mode: 0755]
system/helpers/smiley_helper.php [new file with mode: 0755]
system/helpers/string_helper.php [new file with mode: 0755]
system/helpers/text_helper.php [new file with mode: 0755]
system/helpers/typography_helper.php [new file with mode: 0755]
system/helpers/url_helper.php [new file with mode: 0755]
system/helpers/xml_helper.php [new file with mode: 0755]
system/index.html [new file with mode: 0755]
system/language/english/calendar_lang.php [new file with mode: 0755]
system/language/english/date_lang.php [new file with mode: 0755]
system/language/english/db_lang.php [new file with mode: 0755]
system/language/english/email_lang.php [new file with mode: 0755]
system/language/english/form_validation_lang.php [new file with mode: 0755]
system/language/english/ftp_lang.php [new file with mode: 0755]
system/language/english/imglib_lang.php [new file with mode: 0755]
system/language/english/index.html [new file with mode: 0755]
system/language/english/number_lang.php [new file with mode: 0755]
system/language/english/profiler_lang.php [new file with mode: 0755]
system/language/english/unit_test_lang.php [new file with mode: 0755]
system/language/english/upload_lang.php [new file with mode: 0755]
system/language/index.html [new file with mode: 0755]
system/libraries/Cache/Cache.php [new file with mode: 0755]
system/libraries/Cache/drivers/Cache_apc.php [new file with mode: 0755]
system/libraries/Cache/drivers/Cache_dummy.php [new file with mode: 0755]
system/libraries/Cache/drivers/Cache_file.php [new file with mode: 0755]
system/libraries/Cache/drivers/Cache_memcached.php [new file with mode: 0755]
system/libraries/Calendar.php [new file with mode: 0755]
system/libraries/Cart.php [new file with mode: 0755]
system/libraries/Driver.php [new file with mode: 0755]
system/libraries/Email.php [new file with mode: 0755]
system/libraries/Encrypt.php [new file with mode: 0755]
system/libraries/Form_validation.php [new file with mode: 0755]
system/libraries/Ftp.php [new file with mode: 0755]
system/libraries/Image_lib.php [new file with mode: 0755]
system/libraries/Javascript.php [new file with mode: 0755]
system/libraries/Log.php [new file with mode: 0755]
system/libraries/Pagination.php [new file with mode: 0755]
system/libraries/Parser.php [new file with mode: 0755]
system/libraries/Profiler.php [new file with mode: 0755]
system/libraries/Session.php [new file with mode: 0755]
system/libraries/Sha1.php [new file with mode: 0755]
system/libraries/Table.php [new file with mode: 0755]
system/libraries/Trackback.php [new file with mode: 0755]
system/libraries/Typography.php [new file with mode: 0755]
system/libraries/Unit_test.php [new file with mode: 0755]
system/libraries/Upload.php [new file with mode: 0755]
system/libraries/User_agent.php [new file with mode: 0755]
system/libraries/Xmlrpc.php [new file with mode: 0755]
system/libraries/Xmlrpcs.php [new file with mode: 0755]
system/libraries/Zip.php [new file with mode: 0755]
system/libraries/index.html [new file with mode: 0755]
system/libraries/javascript/Jquery.php [new file with mode: 0755]
user_guide/changelog.html [new file with mode: 0755]
user_guide/database/active_record.html [new file with mode: 0755]
user_guide/database/caching.html [new file with mode: 0755]
user_guide/database/call_function.html [new file with mode: 0755]
user_guide/database/configuration.html [new file with mode: 0755]
user_guide/database/connecting.html [new file with mode: 0755]
user_guide/database/examples.html [new file with mode: 0755]
user_guide/database/fields.html [new file with mode: 0755]
user_guide/database/forge.html [new file with mode: 0755]
user_guide/database/helpers.html [new file with mode: 0755]
user_guide/database/index.html [new file with mode: 0755]
user_guide/database/queries.html [new file with mode: 0755]
user_guide/database/results.html [new file with mode: 0755]
user_guide/database/table_data.html [new file with mode: 0755]
user_guide/database/transactions.html [new file with mode: 0755]
user_guide/database/utilities.html [new file with mode: 0755]
user_guide/doc_style/index.html [new file with mode: 0755]
user_guide/doc_style/template.html [new file with mode: 0755]
user_guide/general/alternative_php.html [new file with mode: 0755]
user_guide/general/ancillary_classes.html [new file with mode: 0755]
user_guide/general/autoloader.html [new file with mode: 0755]
user_guide/general/caching.html [new file with mode: 0755]
user_guide/general/cli.html [new file with mode: 0755]
user_guide/general/common_functions.html [new file with mode: 0755]
user_guide/general/controllers.html [new file with mode: 0755]
user_guide/general/core_classes.html [new file with mode: 0755]
user_guide/general/creating_drivers.html [new file with mode: 0755]
user_guide/general/creating_libraries.html [new file with mode: 0755]
user_guide/general/credits.html [new file with mode: 0755]
user_guide/general/drivers.html [new file with mode: 0755]
user_guide/general/environments.html [new file with mode: 0755]
user_guide/general/errors.html [new file with mode: 0755]
user_guide/general/helpers.html [new file with mode: 0755]
user_guide/general/hooks.html [new file with mode: 0755]
user_guide/general/libraries.html [new file with mode: 0755]
user_guide/general/managing_apps.html [new file with mode: 0755]
user_guide/general/models.html [new file with mode: 0755]
user_guide/general/profiling.html [new file with mode: 0755]
user_guide/general/quick_reference.html [new file with mode: 0755]
user_guide/general/requirements.html [new file with mode: 0755]
user_guide/general/reserved_names.html [new file with mode: 0755]
user_guide/general/routing.html [new file with mode: 0755]
user_guide/general/security.html [new file with mode: 0755]
user_guide/general/styleguide.html [new file with mode: 0755]
user_guide/general/urls.html [new file with mode: 0755]
user_guide/general/views.html [new file with mode: 0755]
user_guide/helpers/array_helper.html [new file with mode: 0755]
user_guide/helpers/captcha_helper.html [new file with mode: 0755]
user_guide/helpers/cookie_helper.html [new file with mode: 0755]
user_guide/helpers/date_helper.html [new file with mode: 0755]
user_guide/helpers/directory_helper.html [new file with mode: 0755]
user_guide/helpers/download_helper.html [new file with mode: 0755]
user_guide/helpers/email_helper.html [new file with mode: 0755]
user_guide/helpers/file_helper.html [new file with mode: 0755]
user_guide/helpers/form_helper.html [new file with mode: 0755]
user_guide/helpers/html_helper.html [new file with mode: 0755]
user_guide/helpers/inflector_helper.html [new file with mode: 0755]
user_guide/helpers/language_helper.html [new file with mode: 0755]
user_guide/helpers/number_helper.html [new file with mode: 0755]
user_guide/helpers/path_helper.html [new file with mode: 0755]
user_guide/helpers/security_helper.html [new file with mode: 0755]
user_guide/helpers/smiley_helper.html [new file with mode: 0755]
user_guide/helpers/string_helper.html [new file with mode: 0755]
user_guide/helpers/text_helper.html [new file with mode: 0755]
user_guide/helpers/typography_helper.html [new file with mode: 0755]
user_guide/helpers/url_helper.html [new file with mode: 0755]
user_guide/helpers/xml_helper.html [new file with mode: 0755]
user_guide/images/appflowchart.gif [new file with mode: 0755]
user_guide/images/arrow.gif [new file with mode: 0755]
user_guide/images/ci_logo.jpg [new file with mode: 0755]
user_guide/images/ci_logo_flame.jpg [new file with mode: 0755]
user_guide/images/ci_quick_ref.png [new file with mode: 0755]
user_guide/images/codeigniter_1.7.1_helper_reference.pdf [new file with mode: 0755]
user_guide/images/codeigniter_1.7.1_helper_reference.png [new file with mode: 0755]
user_guide/images/codeigniter_1.7.1_library_reference.pdf [new file with mode: 0755]
user_guide/images/codeigniter_1.7.1_library_reference.png [new file with mode: 0755]
user_guide/images/file.gif [new file with mode: 0755]
user_guide/images/folder.gif [new file with mode: 0755]
user_guide/images/nav_bg_darker.jpg [new file with mode: 0755]
user_guide/images/nav_separator_darker.jpg [new file with mode: 0755]
user_guide/images/nav_toggle_darker.jpg [new file with mode: 0755]
user_guide/images/reactor-bullet.png [new file with mode: 0755]
user_guide/images/smile.gif [new file with mode: 0755]
user_guide/images/transparent.gif [new file with mode: 0755]
user_guide/index.html [new file with mode: 0755]
user_guide/installation/downloads.html [new file with mode: 0755]
user_guide/installation/index.html [new file with mode: 0755]
user_guide/installation/troubleshooting.html [new file with mode: 0755]
user_guide/installation/upgrade_120.html [new file with mode: 0755]
user_guide/installation/upgrade_130.html [new file with mode: 0755]
user_guide/installation/upgrade_131.html [new file with mode: 0755]
user_guide/installation/upgrade_132.html [new file with mode: 0755]
user_guide/installation/upgrade_133.html [new file with mode: 0755]
user_guide/installation/upgrade_140.html [new file with mode: 0755]
user_guide/installation/upgrade_141.html [new file with mode: 0755]
user_guide/installation/upgrade_150.html [new file with mode: 0755]
user_guide/installation/upgrade_152.html [new file with mode: 0755]
user_guide/installation/upgrade_153.html [new file with mode: 0755]
user_guide/installation/upgrade_154.html [new file with mode: 0755]
user_guide/installation/upgrade_160.html [new file with mode: 0755]
user_guide/installation/upgrade_161.html [new file with mode: 0755]
user_guide/installation/upgrade_162.html [new file with mode: 0755]
user_guide/installation/upgrade_163.html [new file with mode: 0755]
user_guide/installation/upgrade_170.html [new file with mode: 0755]
user_guide/installation/upgrade_171.html [new file with mode: 0755]
user_guide/installation/upgrade_172.html [new file with mode: 0755]
user_guide/installation/upgrade_200.html [new file with mode: 0755]
user_guide/installation/upgrade_201.html [new file with mode: 0755]
user_guide/installation/upgrade_202.html [new file with mode: 0755]
user_guide/installation/upgrade_b11.html [new file with mode: 0755]
user_guide/installation/upgrading.html [new file with mode: 0755]
user_guide/libraries/benchmark.html [new file with mode: 0755]
user_guide/libraries/caching.html [new file with mode: 0755]
user_guide/libraries/calendar.html [new file with mode: 0755]
user_guide/libraries/cart.html [new file with mode: 0755]
user_guide/libraries/config.html [new file with mode: 0755]
user_guide/libraries/email.html [new file with mode: 0755]
user_guide/libraries/encryption.html [new file with mode: 0755]
user_guide/libraries/file_uploading.html [new file with mode: 0755]
user_guide/libraries/form_validation.html [new file with mode: 0755]
user_guide/libraries/ftp.html [new file with mode: 0755]
user_guide/libraries/image_lib.html [new file with mode: 0755]
user_guide/libraries/input.html [new file with mode: 0755]
user_guide/libraries/javascript.html [new file with mode: 0755]
user_guide/libraries/language.html [new file with mode: 0755]
user_guide/libraries/loader.html [new file with mode: 0755]
user_guide/libraries/output.html [new file with mode: 0755]
user_guide/libraries/pagination.html [new file with mode: 0755]
user_guide/libraries/parser.html [new file with mode: 0755]
user_guide/libraries/security.html [new file with mode: 0755]
user_guide/libraries/sessions.html [new file with mode: 0755]
user_guide/libraries/table.html [new file with mode: 0755]
user_guide/libraries/trackback.html [new file with mode: 0755]
user_guide/libraries/typography.html [new file with mode: 0755]
user_guide/libraries/unit_testing.html [new file with mode: 0755]
user_guide/libraries/uri.html [new file with mode: 0755]
user_guide/libraries/user_agent.html [new file with mode: 0755]
user_guide/libraries/xmlrpc.html [new file with mode: 0755]
user_guide/libraries/zip.html [new file with mode: 0755]
user_guide/license.html [new file with mode: 0755]
user_guide/nav/hacks.txt [new file with mode: 0755]
user_guide/nav/moo.fx.js [new file with mode: 0755]
user_guide/nav/nav.js [new file with mode: 0755]
user_guide/nav/prototype.lite.js [new file with mode: 0755]
user_guide/nav/user_guide_menu.js [new file with mode: 0755]
user_guide/overview/appflow.html [new file with mode: 0755]
user_guide/overview/at_a_glance.html [new file with mode: 0755]
user_guide/overview/cheatsheets.html [new file with mode: 0755]
user_guide/overview/features.html [new file with mode: 0755]
user_guide/overview/getting_started.html [new file with mode: 0755]
user_guide/overview/goals.html [new file with mode: 0755]
user_guide/overview/index.html [new file with mode: 0755]
user_guide/overview/mvc.html [new file with mode: 0755]
user_guide/toc.html [new file with mode: 0755]
user_guide/userguide.css [new file with mode: 0755]

diff --git a/application/.htaccess b/application/.htaccess
new file mode 100755 (executable)
index 0000000..14249c5
--- /dev/null
@@ -0,0 +1 @@
+Deny from all
\ No newline at end of file
diff --git a/application/cache/.htaccess b/application/cache/.htaccess
new file mode 100755 (executable)
index 0000000..3418e55
--- /dev/null
@@ -0,0 +1 @@
+deny from all
\ No newline at end of file
diff --git a/application/cache/index.html b/application/cache/index.html
new file mode 100755 (executable)
index 0000000..c942a79
--- /dev/null
@@ -0,0 +1,10 @@
+<html>
+<head>
+       <title>403 Forbidden</title>
+</head>
+<body>
+
+<p>Directory access is forbidden.</p>
+
+</body>
+</html>
\ No newline at end of file
diff --git a/application/config/autoload.php b/application/config/autoload.php
new file mode 100755 (executable)
index 0000000..90b1a80
--- /dev/null
@@ -0,0 +1,116 @@
+<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+/*
+| -------------------------------------------------------------------
+| AUTO-LOADER
+| -------------------------------------------------------------------
+| This file specifies which systems should be loaded by default.
+|
+| In order to keep the framework as light-weight as possible only the
+| absolute minimal resources are loaded by default. For example,
+| the database is not connected to automatically since no assumption
+| is made regarding whether you intend to use it.  This file lets
+| you globally define which systems you would like loaded with every
+| request.
+|
+| -------------------------------------------------------------------
+| Instructions
+| -------------------------------------------------------------------
+|
+| These are the things you can load automatically:
+|
+| 1. Packages
+| 2. Libraries
+| 3. Helper files
+| 4. Custom config files
+| 5. Language files
+| 6. Models
+|
+*/
+
+/*
+| -------------------------------------------------------------------
+|  Auto-load Packges
+| -------------------------------------------------------------------
+| Prototype:
+|
+|  $autoload['packages'] = array(APPPATH.'third_party', '/usr/local/shared');
+|
+*/
+
+$autoload['packages'] = array(APPPATH.'third_party');
+
+
+/*
+| -------------------------------------------------------------------
+|  Auto-load Libraries
+| -------------------------------------------------------------------
+| These are the classes located in the system/libraries folder
+| or in your application/libraries folder.
+|
+| Prototype:
+|
+|      $autoload['libraries'] = array('database', 'session', 'xmlrpc');
+*/
+
+$autoload['libraries'] = array();
+
+
+/*
+| -------------------------------------------------------------------
+|  Auto-load Helper Files
+| -------------------------------------------------------------------
+| Prototype:
+|
+|      $autoload['helper'] = array('url', 'file');
+*/
+
+$autoload['helper'] = array();
+
+
+/*
+| -------------------------------------------------------------------
+|  Auto-load Config files
+| -------------------------------------------------------------------
+| Prototype:
+|
+|      $autoload['config'] = array('config1', 'config2');
+|
+| NOTE: This item is intended for use ONLY if you have created custom
+| config files.  Otherwise, leave it blank.
+|
+*/
+
+$autoload['config'] = array();
+
+
+/*
+| -------------------------------------------------------------------
+|  Auto-load Language files
+| -------------------------------------------------------------------
+| Prototype:
+|
+|      $autoload['language'] = array('lang1', 'lang2');
+|
+| NOTE: Do not include the "_lang" part of your file.  For example
+| "codeigniter_lang.php" would be referenced as array('codeigniter');
+|
+*/
+
+$autoload['language'] = array();
+
+
+/*
+| -------------------------------------------------------------------
+|  Auto-load Models
+| -------------------------------------------------------------------
+| Prototype:
+|
+|      $autoload['model'] = array('model1', 'model2');
+|
+*/
+
+$autoload['model'] = array();
+
+
+/* End of file autoload.php */
+/* Location: ./application/config/autoload.php */
\ No newline at end of file
diff --git a/application/config/config.php b/application/config/config.php
new file mode 100755 (executable)
index 0000000..1ec6543
--- /dev/null
@@ -0,0 +1,362 @@
+<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+
+/*
+|--------------------------------------------------------------------------
+| Base Site URL
+|--------------------------------------------------------------------------
+|
+| URL to your CodeIgniter root. Typically this will be your base URL,
+| WITH a trailing slash:
+|
+|      http://example.com/
+|
+| If this is not set then CodeIgniter will guess the protocol, domain and
+| path to your installation.
+|
+*/
+$config['base_url']    = '';
+
+/*
+|--------------------------------------------------------------------------
+| Index File
+|--------------------------------------------------------------------------
+|
+| Typically this will be your index.php file, unless you've renamed it to
+| something else. If you are using mod_rewrite to remove the page set this
+| variable so that it is blank.
+|
+*/
+$config['index_page'] = 'index.php';
+
+/*
+|--------------------------------------------------------------------------
+| URI PROTOCOL
+|--------------------------------------------------------------------------
+|
+| This item determines which server global should be used to retrieve the
+| URI string.  The default setting of 'AUTO' works for most servers.
+| If your links do not seem to work, try one of the other delicious flavors:
+|
+| 'AUTO'                       Default - auto detects
+| 'PATH_INFO'          Uses the PATH_INFO
+| 'QUERY_STRING'       Uses the QUERY_STRING
+| 'REQUEST_URI'                Uses the REQUEST_URI
+| 'ORIG_PATH_INFO'     Uses the ORIG_PATH_INFO
+|
+*/
+$config['uri_protocol']        = 'AUTO';
+
+/*
+|--------------------------------------------------------------------------
+| URL suffix
+|--------------------------------------------------------------------------
+|
+| This option allows you to add a suffix to all URLs generated by CodeIgniter.
+| For more information please see the user guide:
+|
+| http://codeigniter.com/user_guide/general/urls.html
+*/
+
+$config['url_suffix'] = '';
+
+/*
+|--------------------------------------------------------------------------
+| Default Language
+|--------------------------------------------------------------------------
+|
+| This determines which set of language files should be used. Make sure
+| there is an available translation if you intend to use something other
+| than english.
+|
+*/
+$config['language']    = 'english';
+
+/*
+|--------------------------------------------------------------------------
+| Default Character Set
+|--------------------------------------------------------------------------
+|
+| This determines which character set is used by default in various methods
+| that require a character set to be provided.
+|
+*/
+$config['charset'] = 'UTF-8';
+
+/*
+|--------------------------------------------------------------------------
+| Enable/Disable System Hooks
+|--------------------------------------------------------------------------
+|
+| If you would like to use the 'hooks' feature you must enable it by
+| setting this variable to TRUE (boolean).  See the user guide for details.
+|
+*/
+$config['enable_hooks'] = FALSE;
+
+
+/*
+|--------------------------------------------------------------------------
+| Class Extension Prefix
+|--------------------------------------------------------------------------
+|
+| This item allows you to set the filename/classname prefix when extending
+| native libraries.  For more information please see the user guide:
+|
+| http://codeigniter.com/user_guide/general/core_classes.html
+| http://codeigniter.com/user_guide/general/creating_libraries.html
+|
+*/
+$config['subclass_prefix'] = 'MY_';
+
+
+/*
+|--------------------------------------------------------------------------
+| Allowed URL Characters
+|--------------------------------------------------------------------------
+|
+| This lets you specify with a regular expression which characters are permitted
+| within your URLs.  When someone tries to submit a URL with disallowed
+| characters they will get a warning message.
+|
+| As a security measure you are STRONGLY encouraged to restrict URLs to
+| as few characters as possible.  By default only these are allowed: a-z 0-9~%.:_-
+|
+| Leave blank to allow all characters -- but only if you are insane.
+|
+| DO NOT CHANGE THIS UNLESS YOU FULLY UNDERSTAND THE REPERCUSSIONS!!
+|
+*/
+$config['permitted_uri_chars'] = 'a-z 0-9~%.:_\-';
+
+
+/*
+|--------------------------------------------------------------------------
+| Enable Query Strings
+|--------------------------------------------------------------------------
+|
+| By default CodeIgniter uses search-engine friendly segment based URLs:
+| example.com/who/what/where/
+|
+| By default CodeIgniter enables access to the $_GET array.  If for some
+| reason you would like to disable it, set 'allow_get_array' to FALSE.
+|
+| You can optionally enable standard query string based URLs:
+| example.com?who=me&what=something&where=here
+|
+| Options are: TRUE or FALSE (boolean)
+|
+| The other items let you set the query string 'words' that will
+| invoke your controllers and its functions:
+| example.com/index.php?c=controller&m=function
+|
+| Please note that some of the helpers won't work as expected when
+| this feature is enabled, since CodeIgniter is designed primarily to
+| use segment based URLs.
+|
+*/
+$config['allow_get_array']             = TRUE;
+$config['enable_query_strings'] = FALSE;
+$config['controller_trigger']  = 'c';
+$config['function_trigger']            = 'm';
+$config['directory_trigger']   = 'd'; // experimental not currently in use
+
+/*
+|--------------------------------------------------------------------------
+| Error Logging Threshold
+|--------------------------------------------------------------------------
+|
+| If you have enabled error logging, you can set an error threshold to
+| determine what gets logged. Threshold options are:
+| You can enable error logging by setting a threshold over zero. The
+| threshold determines what gets logged. Threshold options are:
+|
+|      0 = Disables logging, Error logging TURNED OFF
+|      1 = Error Messages (including PHP errors)
+|      2 = Debug Messages
+|      3 = Informational Messages
+|      4 = All Messages
+|
+| For a live site you'll usually only enable Errors (1) to be logged otherwise
+| your log files will fill up very fast.
+|
+*/
+$config['log_threshold'] = 0;
+
+/*
+|--------------------------------------------------------------------------
+| Error Logging Directory Path
+|--------------------------------------------------------------------------
+|
+| Leave this BLANK unless you would like to set something other than the default
+| application/logs/ folder. Use a full server path with trailing slash.
+|
+*/
+$config['log_path'] = '';
+
+/*
+|--------------------------------------------------------------------------
+| Date Format for Logs
+|--------------------------------------------------------------------------
+|
+| Each item that is logged has an associated date. You can use PHP date
+| codes to set your own date formatting
+|
+*/
+$config['log_date_format'] = 'Y-m-d H:i:s';
+
+/*
+|--------------------------------------------------------------------------
+| Cache Directory Path
+|--------------------------------------------------------------------------
+|
+| Leave this BLANK unless you would like to set something other than the default
+| system/cache/ folder.  Use a full server path with trailing slash.
+|
+*/
+$config['cache_path'] = '';
+
+/*
+|--------------------------------------------------------------------------
+| Encryption Key
+|--------------------------------------------------------------------------
+|
+| If you use the Encryption class or the Session class you
+| MUST set an encryption key.  See the user guide for info.
+|
+*/
+$config['encryption_key'] = '';
+
+/*
+|--------------------------------------------------------------------------
+| Session Variables
+|--------------------------------------------------------------------------
+|
+| 'sess_cookie_name'           = the name you want for the cookie
+| 'sess_expiration'                    = the number of SECONDS you want the session to last.
+|   by default sessions last 7200 seconds (two hours).  Set to zero for no expiration.
+| 'sess_expire_on_close'       = Whether to cause the session to expire automatically
+|   when the browser window is closed
+| 'sess_encrypt_cookie'                = Whether to encrypt the cookie
+| 'sess_use_database'          = Whether to save the session data to a database
+| 'sess_table_name'                    = The name of the session database table
+| 'sess_match_ip'                      = Whether to match the user's IP address when reading the session data
+| 'sess_match_useragent'       = Whether to match the User Agent when reading the session data
+| 'sess_time_to_update'                = how many seconds between CI refreshing Session Information
+|
+*/
+$config['sess_cookie_name']            = 'ci_session';
+$config['sess_expiration']             = 7200;
+$config['sess_expire_on_close']        = FALSE;
+$config['sess_encrypt_cookie'] = FALSE;
+$config['sess_use_database']   = FALSE;
+$config['sess_table_name']             = 'ci_sessions';
+$config['sess_match_ip']               = FALSE;
+$config['sess_match_useragent']        = TRUE;
+$config['sess_time_to_update'] = 300;
+
+/*
+|--------------------------------------------------------------------------
+| Cookie Related Variables
+|--------------------------------------------------------------------------
+|
+| '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_secure']       = FALSE;
+
+/*
+|--------------------------------------------------------------------------
+| Global XSS Filtering
+|--------------------------------------------------------------------------
+|
+| Determines whether the XSS filter is always active when GET, POST or
+| COOKIE data is encountered
+|
+*/
+$config['global_xss_filtering'] = FALSE;
+
+/*
+|--------------------------------------------------------------------------
+| Cross Site Request Forgery
+|--------------------------------------------------------------------------
+| 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;
+
+/*
+|--------------------------------------------------------------------------
+| Output Compression
+|--------------------------------------------------------------------------
+|
+| Enables Gzip output compression for faster page loads.  When enabled,
+| the output class will test whether your server supports Gzip.
+| Even if it does, however, not all browsers support compression
+| so enable only if you are reasonably sure your visitors can handle it.
+|
+| VERY IMPORTANT:  If you are getting a blank page when compression is enabled it
+| means you are prematurely outputting something to your browser. It could
+| even be a line of whitespace at the end of one of your scripts.  For
+| compression to work, nothing can be sent before the output buffer is called
+| by the output class.  Do not 'echo' any values with compression enabled.
+|
+*/
+$config['compress_output'] = FALSE;
+
+/*
+|--------------------------------------------------------------------------
+| Master Time Reference
+|--------------------------------------------------------------------------
+|
+| Options are 'local' or 'gmt'.  This pref tells the system whether to use
+| your server's local time as the master 'now' reference, or convert it to
+| GMT.  See the 'date helper' page of the user guide for information
+| regarding date handling.
+|
+*/
+$config['time_reference'] = 'local';
+
+
+/*
+|--------------------------------------------------------------------------
+| Rewrite PHP Short Tags
+|--------------------------------------------------------------------------
+|
+| If your PHP installation does not have short tag support enabled CI
+| can rewrite the tags on-the-fly, enabling you to utilize that syntax
+| in your view files.  Options are TRUE or FALSE (boolean)
+|
+*/
+$config['rewrite_short_tags'] = FALSE;
+
+
+/*
+|--------------------------------------------------------------------------
+| Reverse Proxy IPs
+|--------------------------------------------------------------------------
+|
+| If your server is behind a reverse proxy, you must whitelist the proxy IP
+| addresses from which CodeIgniter should trust the HTTP_X_FORWARDED_FOR
+| header in order to properly identify the visitor's IP address.
+| Comma-delimited, e.g. '10.0.1.200,10.0.1.201'
+|
+*/
+$config['proxy_ips'] = '';
+
+
+/* End of file config.php */
+/* Location: ./application/config/config.php */
diff --git a/application/config/constants.php b/application/config/constants.php
new file mode 100755 (executable)
index 0000000..4a879d3
--- /dev/null
@@ -0,0 +1,41 @@
+<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+
+/*
+|--------------------------------------------------------------------------
+| File and Directory Modes
+|--------------------------------------------------------------------------
+|
+| These prefs are used when checking and setting modes when working
+| with the file system.  The defaults are fine on servers with proper
+| security, but you may wish (or even need) to change the values in
+| certain environments (Apache running a separate process for each
+| user, PHP under CGI with Apache suEXEC, etc.).  Octal values should
+| always be used to set the mode correctly.
+|
+*/
+define('FILE_READ_MODE', 0644);
+define('FILE_WRITE_MODE', 0666);
+define('DIR_READ_MODE', 0755);
+define('DIR_WRITE_MODE', 0777);
+
+/*
+|--------------------------------------------------------------------------
+| File Stream Modes
+|--------------------------------------------------------------------------
+|
+| These modes are used when working with fopen()/popen()
+|
+*/
+
+define('FOPEN_READ',                                                   'rb');
+define('FOPEN_READ_WRITE',                                             'r+b');
+define('FOPEN_WRITE_CREATE_DESTRUCTIVE',               'wb'); // truncates existing file data, use with care
+define('FOPEN_READ_WRITE_CREATE_DESTRUCTIVE',  'w+b'); // truncates existing file data, use with care
+define('FOPEN_WRITE_CREATE',                                   'ab');
+define('FOPEN_READ_WRITE_CREATE',                              'a+b');
+define('FOPEN_WRITE_CREATE_STRICT',                            'xb');
+define('FOPEN_READ_WRITE_CREATE_STRICT',               'x+b');
+
+
+/* End of file constants.php */
+/* Location: ./application/config/constants.php */
\ No newline at end of file
diff --git a/application/config/database.php b/application/config/database.php
new file mode 100755 (executable)
index 0000000..24d611a
--- /dev/null
@@ -0,0 +1,62 @@
+<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+/*
+| -------------------------------------------------------------------
+| DATABASE CONNECTIVITY SETTINGS
+| -------------------------------------------------------------------
+| This file will contain the settings needed to access your database.
+|
+| For complete instructions please consult the 'Database Connection'
+| page of the User Guide.
+|
+| -------------------------------------------------------------------
+| EXPLANATION OF VARIABLES
+| -------------------------------------------------------------------
+|
+|      ['hostname'] The hostname of your database server.
+|      ['username'] The username used to connect to the database
+|      ['password'] The password used to connect to the database
+|      ['database'] The name of the database you want to connect to
+|      ['dbdriver'] The database type. ie: mysql.  Currently supported:
+                                mysql, mysqli, postgre, odbc, mssql, sqlite, oci8
+|      ['dbprefix'] You can add an optional prefix, which will be added
+|                               to the table name when using the  Active Record class
+|      ['pconnect'] TRUE/FALSE - Whether to use a persistent connection
+|      ['db_debug'] TRUE/FALSE - Whether database errors should be displayed.
+|      ['cache_on'] TRUE/FALSE - Enables/disables query caching
+|      ['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
+|      ['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
+|                                                      - good for ensuring strict SQL while developing
+|
+| The $active_group variable lets you choose which connection group to
+| make active.  By default there is only one group (the 'default' group).
+|
+| The $active_record variables lets you determine whether or not to load
+| the active record class
+*/
+
+$active_group = 'default';
+$active_record = TRUE;
+
+$db['default']['hostname'] = 'localhost';
+$db['default']['username'] = '';
+$db['default']['password'] = '';
+$db['default']['database'] = '';
+$db['default']['dbdriver'] = 'mysql';
+$db['default']['dbprefix'] = '';
+$db['default']['pconnect'] = TRUE;
+$db['default']['db_debug'] = TRUE;
+$db['default']['cache_on'] = FALSE;
+$db['default']['cachedir'] = '';
+$db['default']['char_set'] = 'utf8';
+$db['default']['dbcollat'] = 'utf8_general_ci';
+$db['default']['swap_pre'] = '';
+$db['default']['autoinit'] = TRUE;
+$db['default']['stricton'] = FALSE;
+
+
+/* End of file database.php */
+/* Location: ./application/config/database.php */
\ No newline at end of file
diff --git a/application/config/doctypes.php b/application/config/doctypes.php
new file mode 100755 (executable)
index 0000000..f7e1d19
--- /dev/null
@@ -0,0 +1,15 @@
+<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+
+$_doctypes = array(
+                                       'xhtml11'               => '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">',
+                                       'xhtml1-strict' => '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">',
+                                       'xhtml1-trans'  => '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">',
+                                       'xhtml1-frame'  => '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">',
+                                       'html5'                 => '<!DOCTYPE html>',
+                                       'html4-strict'  => '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">',
+                                       'html4-trans'   => '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">',
+                                       'html4-frame'   => '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd">'
+                                       );
+
+/* End of file doctypes.php */
+/* Location: ./application/config/doctypes.php */
\ No newline at end of file
diff --git a/application/config/foreign_chars.php b/application/config/foreign_chars.php
new file mode 100755 (executable)
index 0000000..14b0d73
--- /dev/null
@@ -0,0 +1,64 @@
+<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+/*
+| -------------------------------------------------------------------
+| Foreign Characters
+| -------------------------------------------------------------------
+| This file contains an array of foreign characters for transliteration
+| conversion used by the Text helper
+|
+*/
+$foreign_characters = array(
+       '/ä|æ|ǽ/' => 'ae',
+       '/ö|œ/' => 'oe',
+       '/ü/' => 'ue',
+       '/Ä/' => 'Ae',
+       '/Ü/' => 'Ue',
+       '/Ö/' => 'Oe',
+       '/À|Á|Â|Ã|Ä|Å|Ǻ|Ā|Ă|Ą|Ǎ/' => 'A',
+       '/à|á|â|ã|å|ǻ|ā|ă|ą|ǎ|ª/' => 'a',
+       '/Ç|Ć|Ĉ|Ċ|Č/' => 'C',
+       '/ç|ć|ĉ|ċ|č/' => 'c',
+       '/Ð|Ď|Đ/' => 'D',
+       '/ð|ď|đ/' => 'd',
+       '/È|É|Ê|Ë|Ē|Ĕ|Ė|Ę|Ě/' => 'E',
+       '/è|é|ê|ë|ē|ĕ|ė|ę|ě/' => 'e',
+       '/Ĝ|Ğ|Ġ|Ģ/' => 'G',
+       '/ĝ|ğ|ġ|ģ/' => 'g',
+       '/Ĥ|Ħ/' => 'H',
+       '/ĥ|ħ/' => 'h',
+       '/Ì|Í|Î|Ï|Ĩ|Ī|Ĭ|Ǐ|Į|İ/' => 'I',
+       '/ì|í|î|ï|ĩ|ī|ĭ|ǐ|į|ı/' => 'i',
+       '/Ĵ/' => 'J',
+       '/ĵ/' => 'j',
+       '/Ķ/' => 'K',
+       '/ķ/' => 'k',
+       '/Ĺ|Ļ|Ľ|Ŀ|Ł/' => 'L',
+       '/ĺ|ļ|ľ|ŀ|ł/' => 'l',
+       '/Ñ|Ń|Ņ|Ň/' => 'N',
+       '/ñ|ń|ņ|ň|ʼn/' => 'n',
+       '/Ò|Ó|Ô|Õ|Ō|Ŏ|Ǒ|Ő|Ơ|Ø|Ǿ/' => 'O',
+       '/ò|ó|ô|õ|ō|ŏ|ǒ|ő|ơ|ø|ǿ|º/' => 'o',
+       '/Ŕ|Ŗ|Ř/' => 'R',
+       '/ŕ|ŗ|ř/' => 'r',
+       '/Ś|Ŝ|Ş|Š/' => 'S',
+       '/ś|ŝ|ş|š|ſ/' => 's',
+       '/Ţ|Ť|Ŧ/' => 'T',
+       '/ţ|ť|ŧ/' => 't',
+       '/Ù|Ú|Û|Ũ|Ū|Ŭ|Ů|Ű|Ų|Ư|Ǔ|Ǖ|Ǘ|Ǚ|Ǜ/' => 'U',
+       '/ù|ú|û|ũ|ū|ŭ|ů|ű|ų|ư|ǔ|ǖ|ǘ|ǚ|ǜ/' => 'u',
+       '/Ý|Ÿ|Ŷ/' => 'Y',
+       '/ý|ÿ|ŷ/' => 'y',
+       '/Ŵ/' => 'W',
+       '/ŵ/' => 'w',
+       '/Ź|Ż|Ž/' => 'Z',
+       '/ź|ż|ž/' => 'z',
+       '/Æ|Ǽ/' => 'AE',
+       '/ß/'=> 'ss',
+       '/IJ/' => 'IJ',
+       '/ij/' => 'ij',
+       '/Œ/' => 'OE',
+       '/ƒ/' => 'f'
+);
+
+/* End of file foreign_chars.php */
+/* Location: ./application/config/foreign_chars.php */
\ No newline at end of file
diff --git a/application/config/hooks.php b/application/config/hooks.php
new file mode 100755 (executable)
index 0000000..a4ad2be
--- /dev/null
@@ -0,0 +1,16 @@
+<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+/*
+| -------------------------------------------------------------------------
+| Hooks
+| -------------------------------------------------------------------------
+| This file lets you define "hooks" to extend CI without hacking the core
+| files.  Please see the user guide for info:
+|
+|      http://codeigniter.com/user_guide/general/hooks.html
+|
+*/
+
+
+
+/* End of file hooks.php */
+/* Location: ./application/config/hooks.php */
\ No newline at end of file
diff --git a/application/config/index.html b/application/config/index.html
new file mode 100755 (executable)
index 0000000..c942a79
--- /dev/null
@@ -0,0 +1,10 @@
+<html>
+<head>
+       <title>403 Forbidden</title>
+</head>
+<body>
+
+<p>Directory access is forbidden.</p>
+
+</body>
+</html>
\ No newline at end of file
diff --git a/application/config/mimes.php b/application/config/mimes.php
new file mode 100755 (executable)
index 0000000..8065794
--- /dev/null
@@ -0,0 +1,106 @@
+<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+/*
+| -------------------------------------------------------------------
+| MIME TYPES
+| -------------------------------------------------------------------
+| This file contains an array of mime types.  It is used by the
+| Upload class to help identify allowed file types.
+|
+*/
+
+$mimes = array(        'hqx'   =>      'application/mac-binhex40',
+                               'cpt'   =>      'application/mac-compactpro',
+                               'csv'   =>      array('text/x-comma-separated-values', 'text/comma-separated-values', 'application/octet-stream', 'application/vnd.ms-excel', 'text/x-csv', 'text/csv', 'application/csv', 'application/excel', 'application/vnd.msexcel'),
+                               'bin'   =>      'application/macbinary',
+                               'dms'   =>      'application/octet-stream',
+                               'lha'   =>      'application/octet-stream',
+                               'lzh'   =>      'application/octet-stream',
+                               'exe'   =>      array('application/octet-stream', 'application/x-msdownload'),
+                               'class' =>      'application/octet-stream',
+                               'psd'   =>      'application/x-photoshop',
+                               'so'    =>      'application/octet-stream',
+                               'sea'   =>      'application/octet-stream',
+                               'dll'   =>      'application/octet-stream',
+                               'oda'   =>      'application/oda',
+                               'pdf'   =>      array('application/pdf', 'application/x-download'),
+                               'ai'    =>      'application/postscript',
+                               'eps'   =>      'application/postscript',
+                               'ps'    =>      'application/postscript',
+                               'smi'   =>      'application/smil',
+                               'smil'  =>      'application/smil',
+                               'mif'   =>      'application/vnd.mif',
+                               'xls'   =>      array('application/excel', 'application/vnd.ms-excel', 'application/msexcel'),
+                               'ppt'   =>      array('application/powerpoint', 'application/vnd.ms-powerpoint'),
+                               'wbxml' =>      'application/wbxml',
+                               'wmlc'  =>      'application/wmlc',
+                               'dcr'   =>      'application/x-director',
+                               'dir'   =>      'application/x-director',
+                               'dxr'   =>      'application/x-director',
+                               'dvi'   =>      'application/x-dvi',
+                               'gtar'  =>      'application/x-gtar',
+                               'gz'    =>      'application/x-gzip',
+                               'php'   =>      'application/x-httpd-php',
+                               'php4'  =>      'application/x-httpd-php',
+                               'php3'  =>      'application/x-httpd-php',
+                               'phtml' =>      'application/x-httpd-php',
+                               'phps'  =>      'application/x-httpd-php-source',
+                               'js'    =>      'application/x-javascript',
+                               'swf'   =>      'application/x-shockwave-flash',
+                               'sit'   =>      'application/x-stuffit',
+                               'tar'   =>      'application/x-tar',
+                               'tgz'   =>      array('application/x-tar', 'application/x-gzip-compressed'),
+                               'xhtml' =>      'application/xhtml+xml',
+                               'xht'   =>      'application/xhtml+xml',
+                               'zip'   =>  array('application/x-zip', 'application/zip', 'application/x-zip-compressed'),
+                               'mid'   =>      'audio/midi',
+                               'midi'  =>      'audio/midi',
+                               'mpga'  =>      'audio/mpeg',
+                               'mp2'   =>      'audio/mpeg',
+                               'mp3'   =>      array('audio/mpeg', 'audio/mpg', 'audio/mpeg3', 'audio/mp3'),
+                               'aif'   =>      'audio/x-aiff',
+                               'aiff'  =>      'audio/x-aiff',
+                               'aifc'  =>      'audio/x-aiff',
+                               'ram'   =>      'audio/x-pn-realaudio',
+                               'rm'    =>      'audio/x-pn-realaudio',
+                               'rpm'   =>      'audio/x-pn-realaudio-plugin',
+                               'ra'    =>      'audio/x-realaudio',
+                               'rv'    =>      'video/vnd.rn-realvideo',
+                               'wav'   =>      'audio/x-wav',
+                               'bmp'   =>      'image/bmp',
+                               'gif'   =>      'image/gif',
+                               'jpeg'  =>      array('image/jpeg', 'image/pjpeg'),
+                               'jpg'   =>      array('image/jpeg', 'image/pjpeg'),
+                               'jpe'   =>      array('image/jpeg', 'image/pjpeg'),
+                               'png'   =>      array('image/png',  'image/x-png'),
+                               'tiff'  =>      'image/tiff',
+                               'tif'   =>      'image/tiff',
+                               'css'   =>      'text/css',
+                               'html'  =>      'text/html',
+                               'htm'   =>      'text/html',
+                               'shtml' =>      'text/html',
+                               'txt'   =>      'text/plain',
+                               'text'  =>      'text/plain',
+                               'log'   =>      array('text/plain', 'text/x-log'),
+                               'rtx'   =>      'text/richtext',
+                               'rtf'   =>      'text/rtf',
+                               'xml'   =>      'text/xml',
+                               'xsl'   =>      'text/xml',
+                               'mpeg'  =>      'video/mpeg',
+                               'mpg'   =>      'video/mpeg',
+                               'mpe'   =>      'video/mpeg',
+                               'qt'    =>      'video/quicktime',
+                               'mov'   =>      'video/quicktime',
+                               'avi'   =>      'video/x-msvideo',
+                               'movie' =>      'video/x-sgi-movie',
+                               'doc'   =>      'application/msword',
+                               'docx'  =>      'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
+                               'xlsx'  =>      'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
+                               'word'  =>      array('application/msword', 'application/octet-stream'),
+                               'xl'    =>      'application/excel',
+                               'eml'   =>      'message/rfc822',
+                               'json' => array('application/json', 'text/json')
+                       );
+
+
+/* End of file mimes.php */
+/* Location: ./application/config/mimes.php */
\ No newline at end of file
diff --git a/application/config/profiler.php b/application/config/profiler.php
new file mode 100755 (executable)
index 0000000..f8a5b1a
--- /dev/null
@@ -0,0 +1,17 @@
+<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+/*
+| -------------------------------------------------------------------------
+| Profiler Sections
+| -------------------------------------------------------------------------
+| This file lets you determine whether or not various sections of Profiler
+| data are displayed when the Profiler is enabled.
+| Please see the user guide for info:
+|
+|      http://codeigniter.com/user_guide/general/profiling.html
+|
+*/
+
+
+
+/* End of file profiler.php */
+/* Location: ./application/config/profiler.php */
\ No newline at end of file
diff --git a/application/config/routes.php b/application/config/routes.php
new file mode 100755 (executable)
index 0000000..5f9a583
--- /dev/null
@@ -0,0 +1,46 @@
+<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+/*
+| -------------------------------------------------------------------------
+| URI ROUTING
+| -------------------------------------------------------------------------
+| This file lets you re-map URI requests to specific controller functions.
+|
+| Typically there is a one-to-one relationship between a URL string
+| and its corresponding controller class/method. The segments in a
+| URL normally follow this pattern:
+|
+|      example.com/class/method/id/
+|
+| In some instances, however, you may want to remap this relationship
+| so that a different class/function is called than the one
+| corresponding to the URL.
+|
+| Please see the user guide for complete details:
+|
+|      http://codeigniter.com/user_guide/general/routing.html
+|
+| -------------------------------------------------------------------------
+| RESERVED ROUTES
+| -------------------------------------------------------------------------
+|
+| There area two reserved routes:
+|
+|      $route['default_controller'] = 'welcome';
+|
+| This route indicates which controller class should be loaded if the
+| URI contains no data. In the above example, the "welcome" class
+| would be loaded.
+|
+|      $route['404_override'] = 'errors/page_missing';
+|
+| This route will tell the Router what URI segments to use if those provided
+| in the URL cannot be matched to a valid route.
+|
+*/
+
+$route['default_controller'] = "welcome";
+$route['404_override'] = '';
+
+
+/* End of file routes.php */
+/* Location: ./application/config/routes.php */
\ No newline at end of file
diff --git a/application/config/smileys.php b/application/config/smileys.php
new file mode 100755 (executable)
index 0000000..25d28b2
--- /dev/null
@@ -0,0 +1,66 @@
+<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+/*
+| -------------------------------------------------------------------
+| SMILEYS
+| -------------------------------------------------------------------
+| This file contains an array of smileys for use with the emoticon helper.
+| Individual images can be used to replace multiple simileys.  For example:
+| :-) and :) use the same image replacement.
+|
+| Please see user guide for more info:
+| http://codeigniter.com/user_guide/helpers/smiley_helper.html
+|
+*/
+
+$smileys = array(
+
+//     smiley                  image name                                              width   height  alt
+
+       ':-)'                   =>      array('grin.gif',                       '19',   '19',   'grin'),
+       ':lol:'                 =>      array('lol.gif',                        '19',   '19',   'LOL'),
+       ':cheese:'              =>      array('cheese.gif',                     '19',   '19',   'cheese'),
+       ':)'                    =>      array('smile.gif',                      '19',   '19',   'smile'),
+       ';-)'                   =>      array('wink.gif',                       '19',   '19',   'wink'),
+       ';)'                    =>      array('wink.gif',                       '19',   '19',   'wink'),
+       ':smirk:'               =>      array('smirk.gif',                      '19',   '19',   'smirk'),
+       ':roll:'                =>      array('rolleyes.gif',           '19',   '19',   'rolleyes'),
+       ':-S'                   =>      array('confused.gif',           '19',   '19',   'confused'),
+       ':wow:'                 =>      array('surprise.gif',           '19',   '19',   'surprised'),
+       ':bug:'                 =>      array('bigsurprise.gif',        '19',   '19',   'big surprise'),
+       ':-P'                   =>      array('tongue_laugh.gif',       '19',   '19',   'tongue laugh'),
+       '%-P'                   =>      array('tongue_rolleye.gif',     '19',   '19',   'tongue rolleye'),
+       ';-P'                   =>      array('tongue_wink.gif',        '19',   '19',   'tongue wink'),
+       ':P'                    =>      array('raspberry.gif',          '19',   '19',   'raspberry'),
+       ':blank:'               =>      array('blank.gif',                      '19',   '19',   'blank stare'),
+       ':long:'                =>      array('longface.gif',           '19',   '19',   'long face'),
+       ':ohh:'                 =>      array('ohh.gif',                        '19',   '19',   'ohh'),
+       ':grrr:'                =>      array('grrr.gif',                       '19',   '19',   'grrr'),
+       ':gulp:'                =>      array('gulp.gif',                       '19',   '19',   'gulp'),
+       '8-/'                   =>      array('ohoh.gif',                       '19',   '19',   'oh oh'),
+       ':down:'                =>      array('downer.gif',                     '19',   '19',   'downer'),
+       ':red:'                 =>      array('embarrassed.gif',        '19',   '19',   'red face'),
+       ':sick:'                =>      array('sick.gif',                       '19',   '19',   'sick'),
+       ':shut:'                =>      array('shuteye.gif',            '19',   '19',   'shut eye'),
+       ':-/'                   =>      array('hmm.gif',                        '19',   '19',   'hmmm'),
+       '>:('                   =>      array('mad.gif',                        '19',   '19',   'mad'),
+       ':mad:'                 =>      array('mad.gif',                        '19',   '19',   'mad'),
+       '>:-('                  =>      array('angry.gif',                      '19',   '19',   'angry'),
+       ':angry:'               =>      array('angry.gif',                      '19',   '19',   'angry'),
+       ':zip:'                 =>      array('zip.gif',                        '19',   '19',   'zipper'),
+       ':kiss:'                =>      array('kiss.gif',                       '19',   '19',   'kiss'),
+       ':ahhh:'                =>      array('shock.gif',                      '19',   '19',   'shock'),
+       ':coolsmile:'   =>      array('shade_smile.gif',        '19',   '19',   'cool smile'),
+       ':coolsmirk:'   =>      array('shade_smirk.gif',        '19',   '19',   'cool smirk'),
+       ':coolgrin:'    =>      array('shade_grin.gif',         '19',   '19',   'cool grin'),
+       ':coolhmm:'             =>      array('shade_hmm.gif',          '19',   '19',   'cool hmm'),
+       ':coolmad:'             =>      array('shade_mad.gif',          '19',   '19',   'cool mad'),
+       ':coolcheese:'  =>      array('shade_cheese.gif',       '19',   '19',   'cool cheese'),
+       ':vampire:'             =>      array('vampire.gif',            '19',   '19',   'vampire'),
+       ':snake:'               =>      array('snake.gif',                      '19',   '19',   'snake'),
+       ':exclaim:'             =>      array('exclaim.gif',            '19',   '19',   'excaim'),
+       ':question:'    =>      array('question.gif',           '19',   '19',   'question') // no comma after last item
+
+               );
+
+/* End of file smileys.php */
+/* Location: ./application/config/smileys.php */
\ No newline at end of file
diff --git a/application/config/user_agents.php b/application/config/user_agents.php
new file mode 100755 (executable)
index 0000000..e2d3c3a
--- /dev/null
@@ -0,0 +1,178 @@
+<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+/*
+| -------------------------------------------------------------------
+| USER AGENT TYPES
+| -------------------------------------------------------------------
+| This file contains four arrays of user agent data.  It is used by the
+| User Agent Class to help identify browser, platform, robot, and
+| mobile device data.  The array keys are used to identify the device
+| and the array values are used to set the actual name of the item.
+|
+*/
+
+$platforms = array (
+                                       'windows nt 6.0'        => 'Windows Longhorn',
+                                       'windows nt 5.2'        => 'Windows 2003',
+                                       'windows nt 5.0'        => 'Windows 2000',
+                                       'windows nt 5.1'        => 'Windows XP',
+                                       'windows nt 4.0'        => 'Windows NT 4.0',
+                                       'winnt4.0'                      => 'Windows NT 4.0',
+                                       'winnt 4.0'                     => 'Windows NT',
+                                       'winnt'                         => 'Windows NT',
+                                       'windows 98'            => 'Windows 98',
+                                       'win98'                         => 'Windows 98',
+                                       'windows 95'            => 'Windows 95',
+                                       'win95'                         => 'Windows 95',
+                                       'windows'                       => 'Unknown Windows OS',
+                                       'os x'                          => 'Mac OS X',
+                                       'ppc mac'                       => 'Power PC Mac',
+                                       'freebsd'                       => 'FreeBSD',
+                                       'ppc'                           => 'Macintosh',
+                                       'linux'                         => 'Linux',
+                                       'debian'                        => 'Debian',
+                                       'sunos'                         => 'Sun Solaris',
+                                       'beos'                          => 'BeOS',
+                                       'apachebench'           => 'ApacheBench',
+                                       'aix'                           => 'AIX',
+                                       'irix'                          => 'Irix',
+                                       'osf'                           => 'DEC OSF',
+                                       'hp-ux'                         => 'HP-UX',
+                                       'netbsd'                        => 'NetBSD',
+                                       'bsdi'                          => 'BSDi',
+                                       'openbsd'                       => 'OpenBSD',
+                                       'gnu'                           => 'GNU/Linux',
+                                       'unix'                          => 'Unknown Unix OS'
+                               );
+
+
+// The order of this array should NOT be changed. Many browsers return
+// multiple browser types so we want to identify the sub-type first.
+$browsers = array(
+                                       'Flock'                         => 'Flock',
+                                       'Chrome'                        => 'Chrome',
+                                       'Opera'                         => 'Opera',
+                                       'MSIE'                          => 'Internet Explorer',
+                                       'Internet Explorer'     => 'Internet Explorer',
+                                       'Shiira'                        => 'Shiira',
+                                       'Firefox'                       => 'Firefox',
+                                       'Chimera'                       => 'Chimera',
+                                       'Phoenix'                       => 'Phoenix',
+                                       'Firebird'                      => 'Firebird',
+                                       'Camino'                        => 'Camino',
+                                       'Netscape'                      => 'Netscape',
+                                       'OmniWeb'                       => 'OmniWeb',
+                                       'Safari'                        => 'Safari',
+                                       'Mozilla'                       => 'Mozilla',
+                                       'Konqueror'                     => 'Konqueror',
+                                       'icab'                          => 'iCab',
+                                       'Lynx'                          => 'Lynx',
+                                       'Links'                         => 'Links',
+                                       'hotjava'                       => 'HotJava',
+                                       'amaya'                         => 'Amaya',
+                                       'IBrowse'                       => 'IBrowse'
+                               );
+
+$mobiles = array(
+                                       // legacy array, old values commented out
+                                       'mobileexplorer'        => 'Mobile Explorer',
+//                                     'openwave'                      => 'Open Wave',
+//                                     'opera mini'            => 'Opera Mini',
+//                                     'operamini'                     => 'Opera Mini',
+//                                     'elaine'                        => 'Palm',
+                                       'palmsource'            => 'Palm',
+//                                     'digital paths'         => 'Palm',
+//                                     'avantgo'                       => 'Avantgo',
+//                                     'xiino'                         => 'Xiino',
+                                       'palmscape'                     => 'Palmscape',
+//                                     'nokia'                         => 'Nokia',
+//                                     'ericsson'                      => 'Ericsson',
+//                                     'blackberry'            => 'BlackBerry',
+//                                     'motorola'                      => 'Motorola'
+
+                                       // Phones and Manufacturers
+                                       'motorola'                      => "Motorola",
+                                       'nokia'                         => "Nokia",
+                                       'palm'                          => "Palm",
+                                       'iphone'                        => "Apple iPhone",
+                                       'ipad'                          => "iPad",
+                                       'ipod'                          => "Apple iPod Touch",
+                                       'sony'                          => "Sony Ericsson",
+                                       'ericsson'                      => "Sony Ericsson",
+                                       'blackberry'            => "BlackBerry",
+                                       'cocoon'                        => "O2 Cocoon",
+                                       'blazer'                        => "Treo",
+                                       'lg'                            => "LG",
+                                       'amoi'                          => "Amoi",
+                                       'xda'                           => "XDA",
+                                       'mda'                           => "MDA",
+                                       'vario'                         => "Vario",
+                                       'htc'                           => "HTC",
+                                       'samsung'                       => "Samsung",
+                                       'sharp'                         => "Sharp",
+                                       'sie-'                          => "Siemens",
+                                       'alcatel'                       => "Alcatel",
+                                       'benq'                          => "BenQ",
+                                       'ipaq'                          => "HP iPaq",
+                                       'mot-'                          => "Motorola",
+                                       'playstation portable'  => "PlayStation Portable",
+                                       'hiptop'                        => "Danger Hiptop",
+                                       'nec-'                          => "NEC",
+                                       'panasonic'                     => "Panasonic",
+                                       'philips'                       => "Philips",
+                                       'sagem'                         => "Sagem",
+                                       'sanyo'                         => "Sanyo",
+                                       'spv'                           => "SPV",
+                                       'zte'                           => "ZTE",
+                                       'sendo'                         => "Sendo",
+
+                                       // Operating Systems
+                                       'symbian'                               => "Symbian",
+                                       'SymbianOS'                             => "SymbianOS",
+                                       'elaine'                                => "Palm",
+                                       'palm'                                  => "Palm",
+                                       'series60'                              => "Symbian S60",
+                                       'windows ce'                    => "Windows CE",
+
+                                       // Browsers
+                                       'obigo'                                 => "Obigo",
+                                       'netfront'                              => "Netfront Browser",
+                                       'openwave'                              => "Openwave Browser",
+                                       'mobilexplorer'                 => "Mobile Explorer",
+                                       'operamini'                             => "Opera Mini",
+                                       'opera mini'                    => "Opera Mini",
+
+                                       // Other
+                                       'digital paths'                 => "Digital Paths",
+                                       'avantgo'                               => "AvantGo",
+                                       'xiino'                                 => "Xiino",
+                                       'novarra'                               => "Novarra Transcoder",
+                                       'vodafone'                              => "Vodafone",
+                                       'docomo'                                => "NTT DoCoMo",
+                                       'o2'                                    => "O2",
+
+                                       // Fallback
+                                       'mobile'                                => "Generic Mobile",
+                                       'wireless'                              => "Generic Mobile",
+                                       'j2me'                                  => "Generic Mobile",
+                                       'midp'                                  => "Generic Mobile",
+                                       'cldc'                                  => "Generic Mobile",
+                                       'up.link'                               => "Generic Mobile",
+                                       'up.browser'                    => "Generic Mobile",
+                                       'smartphone'                    => "Generic Mobile",
+                                       'cellphone'                             => "Generic Mobile"
+                               );
+
+// There are hundreds of bots but these are the most common.
+$robots = array(
+                                       'googlebot'                     => 'Googlebot',
+                                       'msnbot'                        => 'MSNBot',
+                                       'slurp'                         => 'Inktomi Slurp',
+                                       'yahoo'                         => 'Yahoo',
+                                       'askjeeves'                     => 'AskJeeves',
+                                       'fastcrawler'           => 'FastCrawler',
+                                       'infoseek'                      => 'InfoSeek Robot 1.0',
+                                       'lycos'                         => 'Lycos'
+                               );
+
+/* End of file user_agents.php */
+/* Location: ./application/config/user_agents.php */
\ No newline at end of file
diff --git a/application/controllers/index.html b/application/controllers/index.html
new file mode 100755 (executable)
index 0000000..c942a79
--- /dev/null
@@ -0,0 +1,10 @@
+<html>
+<head>
+       <title>403 Forbidden</title>
+</head>
+<body>
+
+<p>Directory access is forbidden.</p>
+
+</body>
+</html>
\ No newline at end of file
diff --git a/application/controllers/welcome.php b/application/controllers/welcome.php
new file mode 100755 (executable)
index 0000000..21bef43
--- /dev/null
@@ -0,0 +1,27 @@
+<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+
+class Welcome extends CI_Controller {
+
+       /**
+        * 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/<method_name>
+        * @see http://codeigniter.com/user_guide/general/urls.html
+        */
+       public function index()
+       {
+               $this->load->view('welcome_message');
+       }
+}
+
+/* End of file welcome.php */
+/* Location: ./application/controllers/welcome.php */
\ No newline at end of file
diff --git a/application/core/index.html b/application/core/index.html
new file mode 100755 (executable)
index 0000000..c942a79
--- /dev/null
@@ -0,0 +1,10 @@
+<html>
+<head>
+       <title>403 Forbidden</title>
+</head>
+<body>
+
+<p>Directory access is forbidden.</p>
+
+</body>
+</html>
\ No newline at end of file
diff --git a/application/errors/error_404.php b/application/errors/error_404.php
new file mode 100755 (executable)
index 0000000..a304f45
--- /dev/null
@@ -0,0 +1,34 @@
+<html>
+<head>
+<title>404 Page Not Found</title>
+<style type="text/css">
+
+body {
+background-color:      #fff;
+margin:                                40px;
+font-family:           Lucida Grande, Verdana, Sans-serif;
+font-size:                     12px;
+color:                         #000;
+}
+
+#content  {
+border:                                #999 1px solid;
+background-color:      #fff;
+padding:                       20px 20px 12px 20px;
+}
+
+h1 {
+font-weight:           normal;
+font-size:                     14px;
+color:                         #990000;
+margin:                                0 0 4px 0;
+}
+</style>
+</head>
+<body>
+       <div id="content">
+               <h1><?php echo $heading; ?></h1>
+               <?php echo $message; ?>
+       </div>
+</body>
+</html>
\ No newline at end of file
diff --git a/application/errors/error_db.php b/application/errors/error_db.php
new file mode 100755 (executable)
index 0000000..181de96
--- /dev/null
@@ -0,0 +1,34 @@
+<html>
+<head>
+<title>Database Error</title>
+<style type="text/css">
+
+body {
+background-color:      #fff;
+margin:                                40px;
+font-family:           Lucida Grande, Verdana, Sans-serif;
+font-size:                     12px;
+color:                         #000;
+}
+
+#content  {
+border:                                #999 1px solid;
+background-color:      #fff;
+padding:                       20px 20px 12px 20px;
+}
+
+h1 {
+font-weight:           normal;
+font-size:                     14px;
+color:                         #990000;
+margin:                                0 0 4px 0;
+}
+</style>
+</head>
+<body>
+       <div id="content">
+               <h1><?php echo $heading; ?></h1>
+               <?php echo $message; ?>
+       </div>
+</body>
+</html>
\ No newline at end of file
diff --git a/application/errors/error_general.php b/application/errors/error_general.php
new file mode 100755 (executable)
index 0000000..7734d34
--- /dev/null
@@ -0,0 +1,34 @@
+<html>
+<head>
+<title>Error</title>
+<style type="text/css">
+
+body {
+background-color:      #fff;
+margin:                                40px;
+font-family:           Lucida Grande, Verdana, Sans-serif;
+font-size:                     12px;
+color:                         #000;
+}
+
+#content  {
+border:                                #999 1px solid;
+background-color:      #fff;
+padding:                       20px 20px 12px 20px;
+}
+
+h1 {
+font-weight:           normal;
+font-size:                     14px;
+color:                         #990000;
+margin:                                0 0 4px 0;
+}
+</style>
+</head>
+<body>
+       <div id="content">
+               <h1><?php echo $heading; ?></h1>
+               <?php echo $message; ?>
+       </div>
+</body>
+</html>
\ No newline at end of file
diff --git a/application/errors/error_php.php b/application/errors/error_php.php
new file mode 100755 (executable)
index 0000000..f085c20
--- /dev/null
@@ -0,0 +1,10 @@
+<div style="border:1px solid #990000;padding-left:20px;margin:0 0 10px 0;">
+
+<h4>A PHP Error was encountered</h4>
+
+<p>Severity: <?php echo $severity; ?></p>
+<p>Message:  <?php echo $message; ?></p>
+<p>Filename: <?php echo $filepath; ?></p>
+<p>Line Number: <?php echo $line; ?></p>
+
+</div>
\ No newline at end of file
diff --git a/application/errors/index.html b/application/errors/index.html
new file mode 100755 (executable)
index 0000000..c942a79
--- /dev/null
@@ -0,0 +1,10 @@
+<html>
+<head>
+       <title>403 Forbidden</title>
+</head>
+<body>
+
+<p>Directory access is forbidden.</p>
+
+</body>
+</html>
\ No newline at end of file
diff --git a/application/helpers/index.html b/application/helpers/index.html
new file mode 100755 (executable)
index 0000000..c942a79
--- /dev/null
@@ -0,0 +1,10 @@
+<html>
+<head>
+       <title>403 Forbidden</title>
+</head>
+<body>
+
+<p>Directory access is forbidden.</p>
+
+</body>
+</html>
\ No newline at end of file
diff --git a/application/hooks/index.html b/application/hooks/index.html
new file mode 100755 (executable)
index 0000000..c942a79
--- /dev/null
@@ -0,0 +1,10 @@
+<html>
+<head>
+       <title>403 Forbidden</title>
+</head>
+<body>
+
+<p>Directory access is forbidden.</p>
+
+</body>
+</html>
\ No newline at end of file
diff --git a/application/index.html b/application/index.html
new file mode 100755 (executable)
index 0000000..c942a79
--- /dev/null
@@ -0,0 +1,10 @@
+<html>
+<head>
+       <title>403 Forbidden</title>
+</head>
+<body>
+
+<p>Directory access is forbidden.</p>
+
+</body>
+</html>
\ No newline at end of file
diff --git a/application/language/english/index.html b/application/language/english/index.html
new file mode 100755 (executable)
index 0000000..c942a79
--- /dev/null
@@ -0,0 +1,10 @@
+<html>
+<head>
+       <title>403 Forbidden</title>
+</head>
+<body>
+
+<p>Directory access is forbidden.</p>
+
+</body>
+</html>
\ No newline at end of file
diff --git a/application/libraries/index.html b/application/libraries/index.html
new file mode 100755 (executable)
index 0000000..c942a79
--- /dev/null
@@ -0,0 +1,10 @@
+<html>
+<head>
+       <title>403 Forbidden</title>
+</head>
+<body>
+
+<p>Directory access is forbidden.</p>
+
+</body>
+</html>
\ No newline at end of file
diff --git a/application/logs/index.html b/application/logs/index.html
new file mode 100755 (executable)
index 0000000..c942a79
--- /dev/null
@@ -0,0 +1,10 @@
+<html>
+<head>
+       <title>403 Forbidden</title>
+</head>
+<body>
+
+<p>Directory access is forbidden.</p>
+
+</body>
+</html>
\ No newline at end of file
diff --git a/application/models/index.html b/application/models/index.html
new file mode 100755 (executable)
index 0000000..c942a79
--- /dev/null
@@ -0,0 +1,10 @@
+<html>
+<head>
+       <title>403 Forbidden</title>
+</head>
+<body>
+
+<p>Directory access is forbidden.</p>
+
+</body>
+</html>
\ No newline at end of file
diff --git a/application/third_party/index.html b/application/third_party/index.html
new file mode 100755 (executable)
index 0000000..c942a79
--- /dev/null
@@ -0,0 +1,10 @@
+<html>
+<head>
+       <title>403 Forbidden</title>
+</head>
+<body>
+
+<p>Directory access is forbidden.</p>
+
+</body>
+</html>
\ No newline at end of file
diff --git a/application/views/index.html b/application/views/index.html
new file mode 100755 (executable)
index 0000000..c942a79
--- /dev/null
@@ -0,0 +1,10 @@
+<html>
+<head>
+       <title>403 Forbidden</title>
+</head>
+<body>
+
+<p>Directory access is forbidden.</p>
+
+</body>
+</html>
\ No newline at end of file
diff --git a/application/views/welcome_message.php b/application/views/welcome_message.php
new file mode 100755 (executable)
index 0000000..ca68fc1
--- /dev/null
@@ -0,0 +1,64 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+       <meta charset="utf-8">
+       <title>Welcome to CodeIgniter</title>
+
+<style type="text/css">
+
+body {
+ background-color: #fff;
+ margin: 40px;
+ font-family: Lucida Grande, Verdana, Sans-serif;
+ font-size: 14px;
+ color: #4F5155;
+}
+
+a {
+ color: #003399;
+ background-color: transparent;
+ font-weight: normal;
+}
+
+h1 {
+ color: #444;
+ background-color: transparent;
+ border-bottom: 1px solid #D0D0D0;
+ font-size: 16px;
+ font-weight: bold;
+ margin: 24px 0 2px 0;
+ padding: 5px 0 6px 0;
+}
+
+code {
+ font-family: Monaco, Verdana, Sans-serif;
+ font-size: 12px;
+ background-color: #f9f9f9;
+ border: 1px solid #D0D0D0;
+ color: #002166;
+ display: block;
+ margin: 14px 0 14px 0;
+ padding: 12px 10px 12px 10px;
+}
+
+</style>
+</head>
+<body>
+
+<h1>Welcome to CodeIgniter!</h1>
+
+<p>The page you are looking at is being generated dynamically by CodeIgniter.</p>
+
+<p>If you would like to edit this page you'll find it located at:</p>
+<code>application/views/welcome_message.php</code>
+
+<p>The corresponding controller for this page is found at:</p>
+<code>application/controllers/welcome.php</code>
+
+<p>If you are exploring CodeIgniter for the very first time, you should start by reading the <a href="user_guide/">User Guide</a>.</p>
+
+
+<p><br />Page rendered in {elapsed_time} seconds</p>
+
+</body>
+</html>
\ No newline at end of file
diff --git a/index.html b/index.html
deleted file mode 100644 (file)
index 62899c4..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-<html>
-       <head>
-               <title>P2P-Next UPB Living Lab</title>
-       </head>
-       <body>
-               <h1>It works!</h1>
-       </body>
-</html>
diff --git a/index.php b/index.php
new file mode 100755 (executable)
index 0000000..6e67c2d
--- /dev/null
+++ b/index.php
@@ -0,0 +1,204 @@
+<?php
+
+/*
+ *---------------------------------------------------------------
+ * APPLICATION ENVIRONMENT
+ *---------------------------------------------------------------
+ *
+ * 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
+ *
+ */
+       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_reporting(E_ALL);
+               break;
+       
+               case 'testing':
+               case 'production':
+                       error_reporting(0);
+               break;
+
+               default:
+                       exit('The application environment is not set correctly.');
+       }
+}
+
+/*
+ *---------------------------------------------------------------
+ * SYSTEM FOLDER NAME
+ *---------------------------------------------------------------
+ *
+ * This variable must contain the name of your "system" folder.
+ * Include the path if the folder is not in the same  directory
+ * as this file.
+ *
+ */
+       $system_path = 'system';
+
+/*
+ *---------------------------------------------------------------
+ * APPLICATION FOLDER NAME
+ *---------------------------------------------------------------
+ *
+ * If you want this front controller to use a different "application"
+ * folder then the default one you can set its name here. The folder
+ * can also be renamed or relocated anywhere on your server.  If
+ * you do, use a full server path. For more info please see the user guide:
+ * http://codeigniter.com/user_guide/general/managing_apps.html
+ *
+ * NO TRAILING SLASH!
+ *
+ */
+       $application_folder = 'application';
+
+/*
+ * --------------------------------------------------------------------
+ * DEFAULT CONTROLLER
+ * --------------------------------------------------------------------
+ *
+ * Normally you will set your default controller in the routes.php file.
+ * You can, however, force a custom routing by hard-coding a
+ * specific controller class/function here.  For most applications, you
+ * WILL NOT set your routing here, but it's an option for those
+ * special instances where you might want to override the standard
+ * routing in a specific front controller that shares a common CI installation.
+ *
+ * IMPORTANT:  If you set the routing here, NO OTHER controller will be
+ * callable. In essence, this preference limits your application to ONE
+ * specific controller.  Leave the function name blank if you need
+ * to call functions dynamically via the URI.
+ *
+ * Un-comment the $routing array below to use this feature
+ *
+ */
+       // The directory name, relative to the "controllers" folder.  Leave blank
+       // if your controller is not in a sub-folder within the "controllers" folder
+       // $routing['directory'] = '';
+
+       // The controller class file name.  Example:  Mycontroller.php
+       // $routing['controller'] = '';
+
+       // The controller function you wish to be called.
+       // $routing['function'] = '';
+
+
+/*
+ * -------------------------------------------------------------------
+ *  CUSTOM CONFIG VALUES
+ * -------------------------------------------------------------------
+ *
+ * The $assign_to_config array below will be passed dynamically to the
+ * config class when initialized. This allows you to set custom config
+ * items or override any default config values found in the config.php file.
+ * This can be handy as it permits you to share one application between
+ * multiple front controller files, with each file containing different
+ * config values.
+ *
+ * Un-comment the $assign_to_config array below to use this feature
+ *
+ */
+       // $assign_to_config['name_of_config_item'] = 'value of config item';
+
+
+
+// --------------------------------------------------------------------
+// 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).'/';
+       }
+
+       // ensure there's a trailing slash
+       $system_path = rtrim($system_path, '/').'/';
+
+       // Is the system path correct?
+       if ( ! is_dir($system_path))
+       {
+               exit("Your system folder path does not appear to be set correctly. Please open the following file and correct this: ".pathinfo(__FILE__, PATHINFO_BASENAME));
+       }
+
+/*
+ * -------------------------------------------------------------------
+ *  Now that we know the path, set the main path constants
+ * -------------------------------------------------------------------
+ */
+       // The name of THIS file
+       define('SELF', pathinfo(__FILE__, PATHINFO_BASENAME));
+
+       // The PHP file extension
+       define('EXT', '.php');
+
+       // Path to the system folder
+       define('BASEPATH', str_replace("\\", "/", $system_path));
+
+       // Path to the front controller (this file)
+       define('FCPATH', str_replace(SELF, '', __FILE__));
+
+       // Name of the "system folder"
+       define('SYSDIR', trim(strrchr(trim(BASEPATH, '/'), '/'), '/'));
+
+
+       // The path to the "application" folder
+       if (is_dir($application_folder))
+       {
+               define('APPPATH', $application_folder.'/');
+       }
+       else
+       {
+               if ( ! is_dir(BASEPATH.$application_folder.'/'))
+               {
+                       exit("Your application folder path does not appear to be set correctly. Please open the following file and correct this: ".SELF);
+               }
+
+               define('APPPATH', BASEPATH.$application_folder.'/');
+       }
+
+/*
+ * --------------------------------------------------------------------
+ * LOAD THE BOOTSTRAP FILE
+ * --------------------------------------------------------------------
+ *
+ * And away we go...
+ *
+ */
+require_once BASEPATH.'core/CodeIgniter'.EXT;
+
+/* End of file index.php */
+/* Location: ./index.php */
\ No newline at end of file
diff --git a/license.txt b/license.txt
new file mode 100755 (executable)
index 0000000..061cdb9
--- /dev/null
@@ -0,0 +1,51 @@
+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.
+
+PERMITTED USE
+You are permitted to use, copy, modify, and distribute the Software and its
+documentation, with or without modification, for any purpose, provided that
+the following conditions are met:
+
+1. A copy of this license agreement must be included with the distribution.
+
+2. Redistributions of source code must retain the above copyright notice in
+   all source code files.
+
+3. Redistributions in binary form must reproduce the above copyright notice
+   in the documentation and/or other materials provided with the distribution.
+
+4. Any files that have been modified must carry notices stating the nature
+   of the change and the names of those who changed them.
+
+5. Products derived from the Software must include an acknowledgment that
+   they are derived from CodeIgniter in their documentation and/or other
+   materials provided with the distribution.
+
+6. Products derived from the Software may not be called "CodeIgniter",
+   nor may "CodeIgniter" appear in their name, without prior written
+   permission from EllisLab, Inc.
+
+INDEMNITY
+You agree to indemnify and hold harmless the authors of the Software and
+any contributors for any direct, indirect, incidental, or consequential
+third-party claims, actions or suits, as well as any related expenses,
+liabilities, damages, settlements or fees arising from your use or misuse
+of the Software, or a violation of any terms of this license.
+
+DISCLAIMER OF WARRANTY
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESSED OR
+IMPLIED, INCLUDING, BUT NOT LIMITED TO, WARRANTIES OF QUALITY, PERFORMANCE,
+NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.
+
+LIMITATIONS OF LIABILITY
+YOU ASSUME ALL RISK ASSOCIATED WITH THE INSTALLATION AND USE OF THE SOFTWARE.
+IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS OF THE SOFTWARE BE LIABLE
+FOR CLAIMS, DAMAGES OR OTHER LIABILITY ARISING FROM, OUT OF, OR IN CONNECTION
+WITH THE SOFTWARE. LICENSE HOLDERS ARE SOLELY RESPONSIBLE FOR DETERMINING THE
+APPROPRIATENESS OF USE AND ASSUME ALL RISKS ASSOCIATED WITH ITS USE, INCLUDING
+BUT NOT LIMITED TO THE RISKS OF PROGRAM ERRORS, DAMAGE TO EQUIPMENT, LOSS OF
+DATA OR SOFTWARE PROGRAMS, OR UNAVAILABILITY OR INTERRUPTION OF OPERATIONS.
diff --git a/system/.htaccess b/system/.htaccess
new file mode 100755 (executable)
index 0000000..14249c5
--- /dev/null
@@ -0,0 +1 @@
+Deny from all
\ No newline at end of file
diff --git a/system/core/Benchmark.php b/system/core/Benchmark.php
new file mode 100755 (executable)
index 0000000..515550e
--- /dev/null
@@ -0,0 +1,113 @@
+<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+/**
+ * CodeIgniter
+ *
+ * An open source application development framework for PHP 5.1.6 or newer
+ *
+ * @package            CodeIgniter
+ * @author             ExpressionEngine Dev Team
+ * @copyright  Copyright (c) 2008 - 2011, EllisLab, Inc.
+ * @license            http://codeigniter.com/user_guide/license.html
+ * @link               http://codeigniter.com
+ * @since              Version 1.0
+ * @filesource
+ */
+
+// ------------------------------------------------------------------------
+
+/**
+ * CodeIgniter Benchmark Class
+ *
+ * This class enables you to mark points and calculate the time difference
+ * between them.  Memory consumption can also be displayed.
+ *
+ * @package            CodeIgniter
+ * @subpackage Libraries
+ * @category   Libraries
+ * @author             ExpressionEngine Dev Team
+ * @link               http://codeigniter.com/user_guide/libraries/benchmark.html
+ */
+class CI_Benchmark {
+
+       var $marker = array();
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Set a benchmark marker
+        *
+        * Multiple calls to this function can be made so that several
+        * execution points can be timed
+        *
+        * @access      public
+        * @param       string  $name   name of the marker
+        * @return      void
+        */
+       function mark($name)
+       {
+               $this->marker[$name] = microtime();
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Calculates the time difference between two marked points.
+        *
+        * If the first parameter is empty this function instead returns the
+        * {elapsed_time} pseudo-variable. This permits the full system
+        * execution time to be shown in a template. The output class will
+        * swap the real value for this variable.
+        *
+        * @access      public
+        * @param       string  a particular marked point
+        * @param       string  a particular marked point
+        * @param       integer the number of decimal places
+        * @return      mixed
+        */
+       function elapsed_time($point1 = '', $point2 = '', $decimals = 4)
+       {
+               if ($point1 == '')
+               {
+                       return '{elapsed_time}';
+               }
+
+               if ( ! isset($this->marker[$point1]))
+               {
+                       return '';
+               }
+
+               if ( ! isset($this->marker[$point2]))
+               {
+                       $this->marker[$point2] = microtime();
+               }
+
+               list($sm, $ss) = explode(' ', $this->marker[$point1]);
+               list($em, $es) = explode(' ', $this->marker[$point2]);
+
+               return number_format(($em + $es) - ($sm + $ss), $decimals);
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Memory Usage
+        *
+        * This function returns the {memory_usage} pseudo-variable.
+        * This permits it to be put it anywhere in a template
+        * without the memory being calculated until the end.
+        * The output class will swap the real value for this variable.
+        *
+        * @access      public
+        * @return      string
+        */
+       function memory_usage()
+       {
+               return '{memory_usage}';
+       }
+
+}
+
+// END CI_Benchmark class
+
+/* End of file Benchmark.php */
+/* Location: ./system/core/Benchmark.php */
\ No newline at end of file
diff --git a/system/core/CodeIgniter.php b/system/core/CodeIgniter.php
new file mode 100755 (executable)
index 0000000..e022e1b
--- /dev/null
@@ -0,0 +1,382 @@
+<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+/**
+ * CodeIgniter
+ *
+ * An open source application development framework for PHP 5.1.6 or newer
+ *
+ * @package            CodeIgniter
+ * @author             ExpressionEngine Dev Team
+ * @copyright  Copyright (c) 2008 - 2011, EllisLab, Inc.
+ * @license            http://codeigniter.com/user_guide/license.html
+ * @link               http://codeigniter.com
+ * @since              Version 1.0
+ * @filesource
+ */
+
+// ------------------------------------------------------------------------
+
+/**
+ * System Initialization File
+ *
+ * Loads the base classes and executes the request.
+ *
+ * @package            CodeIgniter
+ * @subpackage codeigniter
+ * @category   Front-controller
+ * @author             ExpressionEngine Dev Team
+ * @link               http://codeigniter.com/user_guide/
+ */
+
+/*
+ * ------------------------------------------------------
+ *  Define the CodeIgniter Version
+ * ------------------------------------------------------
+ */
+       define('CI_VERSION', '2.0.2');
+
+/*
+ * ------------------------------------------------------
+ *  Define the CodeIgniter Branch (Core = TRUE, Reactor = FALSE)
+ * ------------------------------------------------------
+ */
+       define('CI_CORE', FALSE);
+
+/*
+ * ------------------------------------------------------
+ *  Load the global functions
+ * ------------------------------------------------------
+ */
+       require(BASEPATH.'core/Common'.EXT);
+
+/*
+ * ------------------------------------------------------
+ *  Load the framework constants
+ * ------------------------------------------------------
+ */
+       if (defined('ENVIRONMENT') AND file_exists(APPPATH.'config/'.ENVIRONMENT.'/constants'.EXT))
+       {
+               require(APPPATH.'config/'.ENVIRONMENT.'/constants'.EXT);
+       }
+       else
+       {
+               require(APPPATH.'config/constants'.EXT);
+       }
+
+/*
+ * ------------------------------------------------------
+ *  Define a custom error handler so we can log PHP errors
+ * ------------------------------------------------------
+ */
+       set_error_handler('_exception_handler');
+
+       if ( ! is_php('5.3'))
+       {
+               @set_magic_quotes_runtime(0); // Kill magic quotes
+       }
+
+/*
+ * ------------------------------------------------------
+ *  Set the subclass_prefix
+ * ------------------------------------------------------
+ *
+ * Normally the "subclass_prefix" is set in the config file.
+ * The subclass prefix allows CI to know if a core class is
+ * being extended via a library in the local application
+ * "libraries" folder. Since CI allows config items to be
+ * overriden via data set in the main index. php file,
+ * before proceeding we need to know if a subclass_prefix
+ * override exists.  If so, we will set this value now,
+ * before any classes are loaded
+ * Note: Since the config file data is cached it doesn't
+ * hurt to load it here.
+ */
+       if (isset($assign_to_config['subclass_prefix']) AND $assign_to_config['subclass_prefix'] != '')
+       {
+               get_config(array('subclass_prefix' => $assign_to_config['subclass_prefix']));
+       }
+
+/*
+ * ------------------------------------------------------
+ *  Set a liberal script execution time limit
+ * ------------------------------------------------------
+ */
+       if (function_exists("set_time_limit") == TRUE AND @ini_get("safe_mode") == 0)
+       {
+               @set_time_limit(300);
+       }
+
+/*
+ * ------------------------------------------------------
+ *  Start the timer... tick tock tick tock...
+ * ------------------------------------------------------
+ */
+       $BM =& load_class('Benchmark', 'core');
+       $BM->mark('total_execution_time_start');
+       $BM->mark('loading_time:_base_classes_start');
+
+/*
+ * ------------------------------------------------------
+ *  Instantiate the hooks class
+ * ------------------------------------------------------
+ */
+       $EXT =& load_class('Hooks', 'core');
+
+/*
+ * ------------------------------------------------------
+ *  Is there a "pre_system" hook?
+ * ------------------------------------------------------
+ */
+       $EXT->_call_hook('pre_system');
+
+/*
+ * ------------------------------------------------------
+ *  Instantiate the config class
+ * ------------------------------------------------------
+ */
+       $CFG =& load_class('Config', 'core');
+
+       // Do we have any manually set config items in the index.php file?
+       if (isset($assign_to_config))
+       {
+               $CFG->_assign_to_config($assign_to_config);
+       }
+
+/*
+ * ------------------------------------------------------
+ *  Instantiate the UTF-8 class
+ * ------------------------------------------------------
+ *
+ * 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('Utf8', 'core');
+
+/*
+ * ------------------------------------------------------
+ *  Instantiate the URI class
+ * ------------------------------------------------------
+ */
+       $URI =& load_class('URI', 'core');
+
+/*
+ * ------------------------------------------------------
+ *  Instantiate the routing class and set the routing
+ * ------------------------------------------------------
+ */
+       $RTR =& load_class('Router', 'core');
+       $RTR->_set_routing();
+
+       // Set any routing overrides that may exist in the main index file
+       if (isset($routing))
+       {
+               $RTR->_set_overrides($routing);
+       }
+
+/*
+ * ------------------------------------------------------
+ *  Instantiate the output class
+ * ------------------------------------------------------
+ */
+       $OUT =& load_class('Output', 'core');
+
+/*
+ * ------------------------------------------------------
+ *     Is there a valid cache file?  If so, we're done...
+ * ------------------------------------------------------
+ */
+       if ($EXT->_call_hook('cache_override') === FALSE)
+       {
+               if ($OUT->_display_cache($CFG, $URI) == TRUE)
+               {
+                       exit;
+               }
+       }
+
+/*
+ * -----------------------------------------------------
+ * Load the security class for xss and csrf support
+ * -----------------------------------------------------
+ */
+       $SEC =& load_class('Security', 'core');
+
+/*
+ * ------------------------------------------------------
+ *  Load the Input class and sanitize globals
+ * ------------------------------------------------------
+ */
+       $IN     =& load_class('Input', 'core');
+
+/*
+ * ------------------------------------------------------
+ *  Load the Language class
+ * ------------------------------------------------------
+ */
+       $LANG =& load_class('Lang', 'core');
+
+/*
+ * ------------------------------------------------------
+ *  Load the app controller and local controller
+ * ------------------------------------------------------
+ *
+ */
+       // Load the base controller class
+       require BASEPATH.'core/Controller'.EXT;
+
+       function &get_instance()
+       {
+               return CI_Controller::get_instance();
+       }
+
+
+       if (file_exists(APPPATH.'core/'.$CFG->config['subclass_prefix'].'Controller'.EXT))
+       {
+               require APPPATH.'core/'.$CFG->config['subclass_prefix'].'Controller'.EXT;
+       }
+
+       // 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))
+       {
+               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);
+
+       // Set a mark point for benchmarking
+       $BM->mark('loading_time:_base_classes_end');
+
+/*
+ * ------------------------------------------------------
+ *  Security check
+ * ------------------------------------------------------
+ *
+ *  None of the functions in the app controller or the
+ *  loader class can be called via the URI, nor can
+ *  controller functions that begin with an underscore
+ */
+       $class  = $RTR->fetch_class();
+       $method = $RTR->fetch_method();
+
+       if ( ! class_exists($class)
+               OR strncmp($method, '_', 1) == 0
+               OR in_array(strtolower($method), array_map('strtolower', get_class_methods('CI_Controller')))
+               )
+       {
+               show_404("{$class}/{$method}");
+       }
+
+/*
+ * ------------------------------------------------------
+ *  Is there a "pre_controller" hook?
+ * ------------------------------------------------------
+ */
+       $EXT->_call_hook('pre_controller');
+
+/*
+ * ------------------------------------------------------
+ *  Instantiate the requested controller
+ * ------------------------------------------------------
+ */
+       // Mark a start point so we can benchmark the controller
+       $BM->mark('controller_execution_time_( '.$class.' / '.$method.' )_start');
+
+       $CI = new $class();
+
+/*
+ * ------------------------------------------------------
+ *  Is there a "post_controller_constructor" hook?
+ * ------------------------------------------------------
+ */
+       $EXT->_call_hook('post_controller_constructor');
+
+/*
+ * ------------------------------------------------------
+ *  Call the requested method
+ * ------------------------------------------------------
+ */
+       // Is there a "remap" function? If so, we call it instead
+       if (method_exists($CI, '_remap'))
+       {
+               $CI->_remap($method, array_slice($URI->rsegments, 2));
+       }
+       else
+       {
+               // is_callable() returns TRUE on some versions of PHP 5 for private and protected
+               // methods, so we'll use this workaround for consistent behavior
+               if ( ! in_array(strtolower($method), array_map('strtolower', get_class_methods($CI))))
+               {
+                       // 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.EXT))
+                                       {
+                                               show_404("{$class}/{$method}");
+                                       }
+
+                                       include_once(APPPATH.'controllers/'.$class.EXT);
+                                       unset($CI);
+                                       $CI = new $class();
+                               }
+                       }
+                       else
+                       {
+                               show_404("{$class}/{$method}");
+                       }
+               }
+
+               // Call the requested method.
+               // Any URI segments present (besides the class/function) will be passed to the method for convenience
+               call_user_func_array(array(&$CI, $method), array_slice($URI->rsegments, 2));
+       }
+
+
+       // Mark a benchmark end point
+       $BM->mark('controller_execution_time_( '.$class.' / '.$method.' )_end');
+
+/*
+ * ------------------------------------------------------
+ *  Is there a "post_controller" hook?
+ * ------------------------------------------------------
+ */
+       $EXT->_call_hook('post_controller');
+
+/*
+ * ------------------------------------------------------
+ *  Send the final rendered output to the browser
+ * ------------------------------------------------------
+ */
+       if ($EXT->_call_hook('display_override') === FALSE)
+       {
+               $OUT->_display();
+       }
+
+/*
+ * ------------------------------------------------------
+ *  Is there a "post_system" hook?
+ * ------------------------------------------------------
+ */
+       $EXT->_call_hook('post_system');
+
+/*
+ * ------------------------------------------------------
+ *  Close the DB connection if one exists
+ * ------------------------------------------------------
+ */
+       if (class_exists('CI_DB') AND isset($CI->db))
+       {
+               $CI->db->close();
+       }
+
+
+/* End of file CodeIgniter.php */
+/* Location: ./system/core/CodeIgniter.php */
\ No newline at end of file
diff --git a/system/core/Common.php b/system/core/Common.php
new file mode 100755 (executable)
index 0000000..1aca809
--- /dev/null
@@ -0,0 +1,505 @@
+<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+/**
+ * CodeIgniter
+ *
+ * An open source application development framework for PHP 5.1.6 or newer
+ *
+ * @package            CodeIgniter
+ * @author             ExpressionEngine Dev Team
+ * @copyright  Copyright (c) 2008 - 2011, EllisLab, Inc.
+ * @license            http://codeigniter.com/user_guide/license.html
+ * @link               http://codeigniter.com
+ * @since              Version 1.0
+ * @filesource
+ */
+
+// ------------------------------------------------------------------------
+
+/**
+ * Common Functions
+ *
+ * Loads the base classes and executes the request.
+ *
+ * @package            CodeIgniter
+ * @subpackage codeigniter
+ * @category   Common Functions
+ * @author             ExpressionEngine Dev Team
+ * @link               http://codeigniter.com/user_guide/
+ */
+
+// ------------------------------------------------------------------------
+
+/**
+* Determines if the current version of PHP is greater then the supplied value
+*
+* Since there are a few places where we conditionally test for PHP > 5
+* we'll set a static variable.
+*
+* @access      public
+* @param       string
+* @return      bool    TRUE if the current version is $version or higher
+*/
+       function is_php($version = '5.0.0')
+       {
+               static $_is_php;
+               $version = (string)$version;
+
+               if ( ! isset($_is_php[$version]))
+               {
+                       $_is_php[$version] = (version_compare(PHP_VERSION, $version) < 0) ? FALSE : TRUE;
+               }
+
+               return $_is_php[$version];
+       }
+
+// ------------------------------------------------------------------------
+
+/**
+ * Tests for file writability
+ *
+ * is_writable() returns TRUE on Windows servers when you really can't write to
+ * the file, based on the read-only attribute.  is_writable() is also unreliable
+ * on Unix servers if safe_mode is on.
+ *
+ * @access     private
+ * @return     void
+ */
+       function is_really_writable($file)
+       {
+               // If we're on a Unix server with safe_mode off we call is_writable
+               if (DIRECTORY_SEPARATOR == '/' AND @ini_get("safe_mode") == FALSE)
+               {
+                       return is_writable($file);
+               }
+
+               // For windows servers and safe_mode "on" installations we'll actually
+               // write a file then read it.  Bah...
+               if (is_dir($file))
+               {
+                       $file = rtrim($file, '/').'/'.md5(mt_rand(1,100).mt_rand(1,100));
+
+                       if (($fp = @fopen($file, FOPEN_WRITE_CREATE)) === FALSE)
+                       {
+                               return FALSE;
+                       }
+
+                       fclose($fp);
+                       @chmod($file, DIR_WRITE_MODE);
+                       @unlink($file);
+                       return TRUE;
+               }
+               elseif ( ! is_file($file) OR ($fp = @fopen($file, FOPEN_WRITE_CREATE)) === FALSE)
+               {
+                       return FALSE;
+               }
+
+               fclose($fp);
+               return TRUE;
+       }
+
+// ------------------------------------------------------------------------
+
+/**
+* Class registry
+*
+* This function acts as a singleton.  If the requested class does not
+* exist it is instantiated and set to a static variable.  If it has
+* previously been instantiated the variable is returned.
+*
+* @access      public
+* @param       string  the class name being requested
+* @param       string  the directory where the class should be found
+* @param       string  the class name prefix
+* @return      object
+*/
+       function &load_class($class, $directory = 'libraries', $prefix = 'CI_')
+       {
+               static $_classes = array();
+
+               // Does the class exist?  If so, we're done...
+               if (isset($_classes[$class]))
+               {
+                       return $_classes[$class];
+               }
+
+               $name = FALSE;
+
+               // Look for the class first in the native system/libraries folder
+               // thenin the local application/libraries folder
+               foreach (array(BASEPATH, APPPATH) as $path)
+               {
+                       if (file_exists($path.$directory.'/'.$class.EXT))
+                       {
+                               $name = $prefix.$class;
+
+                               if (class_exists($name) === FALSE)
+                               {
+                                       require($path.$directory.'/'.$class.EXT);
+                               }
+
+                               break;
+                       }
+               }
+
+               // Is the request a class extension?  If so we load it too
+               if (file_exists(APPPATH.$directory.'/'.config_item('subclass_prefix').$class.EXT))
+               {
+                       $name = config_item('subclass_prefix').$class;
+
+                       if (class_exists($name) === FALSE)
+                       {
+                               require(APPPATH.$directory.'/'.config_item('subclass_prefix').$class.EXT);
+                       }
+               }
+
+               // Did we find the class?
+               if ($name === FALSE)
+               {
+                       // 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);
+               }
+
+               // Keep track of what we just loaded
+               is_loaded($class);
+
+               $_classes[$class] = new $name();
+               return $_classes[$class];
+       }
+
+// --------------------------------------------------------------------
+
+/**
+* Keeps track of which libraries have been loaded.  This function is
+* called by the load_class() function above
+*
+* @access      public
+* @return      array
+*/
+       function is_loaded($class = '')
+       {
+               static $_is_loaded = array();
+
+               if ($class != '')
+               {
+                       $_is_loaded[strtolower($class)] = $class;
+               }
+
+               return $_is_loaded;
+       }
+
+// ------------------------------------------------------------------------
+
+/**
+* Loads the main config.php file
+*
+* This function lets us grab the config file even if the Config class
+* hasn't been instantiated yet
+*
+* @access      private
+* @return      array
+*/
+       function &get_config($replace = array())
+       {
+               static $_config;
+
+               if (isset($_config))
+               {
+                       return $_config[0];
+               }
+
+               // Is the config file in the environment folder?
+               if ( ! defined('ENVIRONMENT') OR ! file_exists($file_path = APPPATH.'config/'.ENVIRONMENT.'/config'.EXT))
+               {
+                       $file_path = APPPATH.'config/config'.EXT;
+               }
+
+               // Fetch the config file
+               if ( ! file_exists($file_path))
+               {
+                       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))
+               {
+                       exit('Your config file does not appear to be formatted correctly.');
+               }
+
+               // Are any values being dynamically replaced?
+               if (count($replace) > 0)
+               {
+                       foreach ($replace as $key => $val)
+                       {
+                               if (isset($config[$key]))
+                               {
+                                       $config[$key] = $val;
+                               }
+                       }
+               }
+
+               return $_config[0] =& $config;
+       }
+
+// ------------------------------------------------------------------------
+
+/**
+* Returns the specified config item
+*
+* @access      public
+* @return      mixed
+*/
+       function config_item($item)
+       {
+               static $_config_item = array();
+
+               if ( ! isset($_config_item[$item]))
+               {
+                       $config =& get_config();
+
+                       if ( ! isset($config[$item]))
+                       {
+                               return FALSE;
+                       }
+                       $_config_item[$item] = $config[$item];
+               }
+
+               return $_config_item[$item];
+       }
+
+// ------------------------------------------------------------------------
+
+/**
+* Error Handler
+*
+* This function lets us invoke the exception class and
+* display errors using the standard error template located
+* in application/errors/errors.php
+* This function will send the error page directly to the
+* browser and exit.
+*
+* @access      public
+* @return      void
+*/
+       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;
+       }
+
+// ------------------------------------------------------------------------
+
+/**
+* 404 Page Handler
+*
+* This function is similar to the show_error() function above
+* However, instead of the standard error template it displays
+* 404 errors.
+*
+* @access      public
+* @return      void
+*/
+       function show_404($page = '', $log_error = TRUE)
+       {
+               $_error =& load_class('Exceptions', 'core');
+               $_error->show_404($page, $log_error);
+               exit;
+       }
+
+// ------------------------------------------------------------------------
+
+/**
+* Error Logging Interface
+*
+* We use this as a simple mechanism to access the logging
+* class and send messages to be logged.
+*
+* @access      public
+* @return      void
+*/
+       function log_message($level = 'error', $message, $php_error = FALSE)
+       {
+               static $_log;
+
+               if (config_item('log_threshold') == 0)
+               {
+                       return;
+               }
+
+               $_log =& load_class('Log');
+               $_log->write_log($level, $message, $php_error);
+       }
+
+// ------------------------------------------------------------------------
+
+/**
+ * Set HTTP Status Header
+ *
+ * @access     public
+ * @param      int             the status code
+ * @param      string
+ * @return     void
+ */
+       function set_status_header($code = 200, $text = '')
+       {
+               $stati = array(
+                                                       200     => 'OK',
+                                                       201     => 'Created',
+                                                       202     => 'Accepted',
+                                                       203     => 'Non-Authoritative Information',
+                                                       204     => 'No Content',
+                                                       205     => 'Reset Content',
+                                                       206     => 'Partial Content',
+
+                                                       300     => 'Multiple Choices',
+                                                       301     => 'Moved Permanently',
+                                                       302     => 'Found',
+                                                       304     => 'Not Modified',
+                                                       305     => 'Use Proxy',
+                                                       307     => 'Temporary Redirect',
+
+                                                       400     => 'Bad Request',
+                                                       401     => 'Unauthorized',
+                                                       403     => 'Forbidden',
+                                                       404     => 'Not Found',
+                                                       405     => 'Method Not Allowed',
+                                                       406     => 'Not Acceptable',
+                                                       407     => 'Proxy Authentication Required',
+                                                       408     => 'Request Timeout',
+                                                       409     => 'Conflict',
+                                                       410     => 'Gone',
+                                                       411     => 'Length Required',
+                                                       412     => 'Precondition Failed',
+                                                       413     => 'Request Entity Too Large',
+                                                       414     => 'Request-URI Too Long',
+                                                       415     => 'Unsupported Media Type',
+                                                       416     => 'Requested Range Not Satisfiable',
+                                                       417     => 'Expectation Failed',
+
+                                                       500     => 'Internal Server Error',
+                                                       501     => 'Not Implemented',
+                                                       502     => 'Bad Gateway',
+                                                       503     => 'Service Unavailable',
+                                                       504     => 'Gateway Timeout',
+                                                       505     => 'HTTP Version Not Supported'
+                                               );
+
+               if ($code == '' OR ! is_numeric($code))
+               {
+                       show_error('Status codes must be numeric', 500);
+               }
+
+               if (isset($stati[$code]) AND $text == '')
+               {
+                       $text = $stati[$code];
+               }
+
+               if ($text == '')
+               {
+                       show_error('No status text available.  Please check your status code number or supply your own message text.', 500);
+               }
+
+               $server_protocol = (isset($_SERVER['SERVER_PROTOCOL'])) ? $_SERVER['SERVER_PROTOCOL'] : FALSE;
+
+               if (substr(php_sapi_name(), 0, 3) == 'cgi')
+               {
+                       header("Status: {$code} {$text}", TRUE);
+               }
+               elseif ($server_protocol == 'HTTP/1.1' OR $server_protocol == 'HTTP/1.0')
+               {
+                       header($server_protocol." {$code} {$text}", TRUE, $code);
+               }
+               else
+               {
+                       header("HTTP/1.1 {$code} {$text}", TRUE, $code);
+               }
+       }
+
+// --------------------------------------------------------------------
+
+/**
+* Exception Handler
+*
+* This is the custom exception handler that is declaired at the top
+* of Codeigniter.php.  The main reason we use this is to permit
+* PHP errors to be logged in our own log files since the user may
+* not have access to server logs. Since this function
+* effectively intercepts PHP errors, however, we also need
+* to display errors based on the current error_reporting level.
+* We do that with the use of a PHP error template.
+*
+* @access      private
+* @return      void
+*/
+       function _exception_handler($severity, $message, $filepath, $line)
+       {
+                // We don't bother with "strict" notices since they tend to fill up
+                // the log file with excess information that isn't normally very helpful.
+                // For example, if you are running PHP 5 and you use version 4 style
+                // class functions (without prefixes like "public", "private", etc.)
+                // you'll get notices telling you that these have been deprecated.
+               if ($severity == E_STRICT)
+               {
+                       return;
+               }
+
+               $_error =& load_class('Exceptions', 'core');
+
+               // 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)
+               {
+                       $_error->show_php_error($severity, $message, $filepath, $line);
+               }
+
+               // Should we log the error?  No?  We're done...
+               if (config_item('log_threshold') == 0)
+               {
+                       return;
+               }
+
+               $_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, $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)
+               {
+                       $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
+               {
+                       $str = preg_replace($non_displayables, '', $str, -1, $count);
+               }
+               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
new file mode 100755 (executable)
index 0000000..863c5ef
--- /dev/null
@@ -0,0 +1,329 @@
+<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+/**
+ * CodeIgniter
+ *
+ * An open source application development framework for PHP 5.1.6 or newer
+ *
+ * @package            CodeIgniter
+ * @author             ExpressionEngine Dev Team
+ * @copyright  Copyright (c) 2008 - 2011, EllisLab, Inc.
+ * @license            http://codeigniter.com/user_guide/license.html
+ * @link               http://codeigniter.com
+ * @since              Version 1.0
+ * @filesource
+ */
+
+// ------------------------------------------------------------------------
+
+/**
+ * CodeIgniter Config Class
+ *
+ * This class contains functions that enable config files to be managed
+ *
+ * @package            CodeIgniter
+ * @subpackage Libraries
+ * @category   Libraries
+ * @author             ExpressionEngine Dev Team
+ * @link               http://codeigniter.com/user_guide/libraries/config.html
+ */
+class CI_Config {
+
+       var $config = array();
+       var $is_loaded = array();
+       var $_config_paths = array(APPPATH);
+
+       /**
+        * Constructor
+        *
+        * Sets the $config data from the primary config.php file as a class variable
+        *
+        * @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 successfully loaded or not
+        */
+       function __construct()
+       {
+               $this->config =& get_config();
+               log_message('debug', "Config Class Initialized");
+
+               // Set the base_url automatically if none was provided
+               if ($this->config['base_url'] == '')
+               {
+                       if (isset($_SERVER['HTTP_HOST']))
+                       {
+                               $base_url = isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) !== 'off' ? 'https' : 'http';
+                               $base_url .= '://'. $_SERVER['HTTP_HOST'];
+                               $base_url .= str_replace(basename($_SERVER['SCRIPT_NAME']), '', $_SERVER['SCRIPT_NAME']);
+                       }
+
+                       else
+                       {
+                               $base_url = 'http://localhost/';
+                       }
+
+                       $this->set_item('base_url', $base_url);
+               }
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Load Config File
+        *
+        * @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);
+               $found = FALSE;
+               $loaded = FALSE;
+
+               foreach ($this->_config_paths as $path)
+               {
+                       $check_locations = defined('ENVIRONMENT')
+                               ? array(ENVIRONMENT.'/'.$file, $file)
+                               : array($file);
+
+                       foreach ($check_locations as $location)
+                       {
+                               $file_path = $path.'config/'.$location.EXT;
+
+                               if (in_array($file_path, $this->is_loaded, TRUE))
+                               {
+                                       $loaded = TRUE;
+                                       continue 2;
+                               }
+
+                               if (file_exists($file_path))
+                               {
+                                       $found = TRUE;
+                                       break;
+                               }
+                       }
+
+                       if ($found === FALSE)
+                       {
+                               continue;
+                       }
+
+                       include($file_path);
+
+                       if ( ! isset($config) OR ! is_array($config))
+                       {
+                               if ($fail_gracefully === TRUE)
+                               {
+                                       return FALSE;
+                               }
+                               show_error('Your '.$file_path.' file does not appear to contain a valid configuration array.');
+                       }
+
+                       if ($use_sections === TRUE)
+                       {
+                               if (isset($this->config[$file]))
+                               {
+                                       $this->config[$file] = array_merge($this->config[$file], $config);
+                               }
+                               else
+                               {
+                                       $this->config[$file] = $config;
+                               }
+                       }
+                       else
+                       {
+                               $this->config = array_merge($this->config, $config);
+                       }
+
+                       $this->is_loaded[] = $file_path;
+                       unset($config);
+
+                       $loaded = TRUE;
+                       log_message('debug', 'Config file loaded: '.$file_path);
+               }
+
+               if ($loaded === FALSE)
+               {
+                       if ($fail_gracefully === TRUE)
+                       {
+                               return FALSE;
+                       }
+                       show_error('The configuration file '.$file.EXT.' does not exist.');
+               }
+
+               return TRUE;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Fetch a config file item
+        *
+        *
+        * @access      public
+        * @param       string  the config item name
+        * @param       string  the index name
+        * @param       bool
+        * @return      string
+        */
+       function item($item, $index = '')
+       {
+               if ($index == '')
+               {
+                       if ( ! isset($this->config[$item]))
+                       {
+                               return FALSE;
+                       }
+
+                       $pref = $this->config[$item];
+               }
+               else
+               {
+                       if ( ! isset($this->config[$index]))
+                       {
+                               return FALSE;
+                       }
+
+                       if ( ! isset($this->config[$index][$item]))
+                       {
+                               return FALSE;
+                       }
+
+                       $pref = $this->config[$index][$item];
+               }
+
+               return $pref;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Fetch a config file item - adds slash after item
+        *
+        * The second parameter allows a slash to be added to the end of
+        * the item, in the case of a path.
+        *
+        * @access      public
+        * @param       string  the config item name
+        * @param       bool
+        * @return      string
+        */
+       function slash_item($item)
+       {
+               if ( ! isset($this->config[$item]))
+               {
+                       return FALSE;
+               }
+
+               return rtrim($this->config[$item], '/').'/';
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Site URL
+        *
+        * @access      public
+        * @param       string  the URI string
+        * @return      string
+        */
+       function site_url($uri = '')
+       {
+               if ($uri == '')
+               {
+                       return $this->slash_item('base_url').$this->item('index_page');
+               }
+
+               if ($this->item('enable_query_strings') == FALSE)
+               {
+                       if (is_array($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').$index.trim($uri, '/').$suffix;
+               }
+               else
+               {
+                       if (is_array($uri))
+                       {
+                               $i = 0;
+                               $str = '';
+                               foreach ($uri as $key => $val)
+                               {
+                                       $prefix = ($i == 0) ? '' : '&';
+                                       $str .= $prefix.$key.'='.$val;
+                                       $i++;
+                               }
+
+                               $uri = $str;
+                       }
+
+                       return $this->slash_item('base_url').$this->item('index_page').'?'.$uri;
+               }
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * System URL
+        *
+        * @access      public
+        * @return      string
+        */
+       function system_url()
+       {
+               $x = explode("/", preg_replace("|/*(.+?)/*$|", "\\1", BASEPATH));
+               return $this->slash_item('base_url').end($x).'/';
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Set a config file item
+        *
+        * @access      public
+        * @param       string  the config item key
+        * @param       string  the config item value
+        * @return      void
+        */
+       function set_item($item, $value)
+       {
+               $this->config[$item] = $value;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Assign to Config
+        *
+        * This function is called by the front controller (CodeIgniter.php)
+        * after the Config class is instantiated.  It permits config items
+        * to be assigned or overriden by variables contained in the index.php file
+        *
+        * @access      private
+        * @param       array
+        * @return      void
+        */
+       function _assign_to_config($items = array())
+       {
+               if (is_array($items))
+               {
+                       foreach ($items as $key => $val)
+                       {
+                               $this->set_item($key, $val);
+                       }
+               }
+       }
+}
+
+// END CI_Config class
+
+/* End of file Config.php */
+/* Location: ./system/core/Config.php */
\ No newline at end of file
diff --git a/system/core/Controller.php b/system/core/Controller.php
new file mode 100755 (executable)
index 0000000..469663f
--- /dev/null
@@ -0,0 +1,67 @@
+<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+/**
+ * CodeIgniter
+ *
+ * An open source application development framework for PHP 5.1.6 or newer
+ *
+ * @package            CodeIgniter
+ * @author             ExpressionEngine Dev Team
+ * @copyright  Copyright (c) 2008 - 2011, EllisLab, Inc.
+ * @license            http://codeigniter.com/user_guide/license.html
+ * @link               http://codeigniter.com
+ * @since              Version 1.0
+ * @filesource
+ */
+
+// ------------------------------------------------------------------------
+
+/**
+ * CodeIgniter Application Controller Class
+ *
+ * This class object is the super class that every library in
+ * CodeIgniter will be assigned to.
+ *
+ * @package            CodeIgniter
+ * @subpackage Libraries
+ * @category   Libraries
+ * @author             ExpressionEngine Dev Team
+ * @link               http://codeigniter.com/user_guide/general/controllers.html
+ */
+class CI_Controller {
+
+       private static $instance;
+
+       /**
+        * Constructor
+        */
+       public function __construct()
+       {
+               self::$instance =& $this;
+               
+               // Assign all the class objects that were instantiated by the
+               // bootstrap file (CodeIgniter.php) to local class variables
+               // so that CI can run as one big super object.
+               foreach (is_loaded() as $var => $class)
+               {
+                       $this->$var =& load_class($class);
+               }
+
+               $this->load =& load_class('Loader', 'core');
+
+               $this->load->_base_classes =& is_loaded();
+
+               $this->load->_ci_autoloader();
+
+               log_message('debug', "Controller Class Initialized");
+
+       }
+
+       public static function &get_instance()
+       {
+               return self::$instance;
+       }
+}
+// END Controller class
+
+/* End of file Controller.php */
+/* Location: ./system/core/Controller.php */
\ No newline at end of file
diff --git a/system/core/Exceptions.php b/system/core/Exceptions.php
new file mode 100755 (executable)
index 0000000..f565956
--- /dev/null
@@ -0,0 +1,178 @@
+<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+/**
+ * CodeIgniter
+ *
+ * An open source application development framework for PHP 5.1.6 or newer
+ *
+ * @package            CodeIgniter
+ * @author             ExpressionEngine Dev Team
+ * @copyright  Copyright (c) 2008 - 2011, EllisLab, Inc.
+ * @license            http://codeigniter.com/user_guide/license.html
+ * @link               http://codeigniter.com
+ * @since              Version 1.0
+ * @filesource
+ */
+
+// ------------------------------------------------------------------------
+
+/**
+ * Exceptions Class
+ *
+ * @package            CodeIgniter
+ * @subpackage Libraries
+ * @category   Exceptions
+ * @author             ExpressionEngine Dev Team
+ * @link               http://codeigniter.com/user_guide/libraries/exceptions.html
+ */
+class CI_Exceptions {
+       var $action;
+       var $severity;
+       var $message;
+       var $filename;
+       var $line;
+       var $ob_level;
+
+       var $levels = array(
+                                               E_ERROR                         =>      'Error',
+                                               E_WARNING                       =>      'Warning',
+                                               E_PARSE                         =>      'Parsing Error',
+                                               E_NOTICE                        =>      'Notice',
+                                               E_CORE_ERROR            =>      'Core Error',
+                                               E_CORE_WARNING          =>      'Core Warning',
+                                               E_COMPILE_ERROR         =>      'Compile Error',
+                                               E_COMPILE_WARNING       =>      'Compile Warning',
+                                               E_USER_ERROR            =>      'User Error',
+                                               E_USER_WARNING          =>      'User Warning',
+                                               E_USER_NOTICE           =>      'User Notice',
+                                               E_STRICT                        =>      'Runtime Notice'
+                                       );
+
+
+       /**
+        * Constructor
+        */
+       public function __construct()
+       {
+               $this->ob_level = ob_get_level();
+               // Note:  Do not log messages from this constructor.
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Exception Logger
+        *
+        * This function logs PHP generated error messages
+        *
+        * @access      private
+        * @param       string  the error severity
+        * @param       string  the error string
+        * @param       string  the error filepath
+        * @param       string  the error line number
+        * @return      string
+        */
+       function log_exception($severity, $message, $filepath, $line)
+       {
+               $severity = ( ! isset($this->levels[$severity])) ? $severity : $this->levels[$severity];
+
+               log_message('error', 'Severity: '.$severity.'  --> '.$message. ' '.$filepath.' '.$line, TRUE);
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * 404 Page Not Found Handler
+        *
+        * @access      private
+        * @param       string
+        * @return      string
+        */
+       function show_404($page = '', $log_error = TRUE)
+       {
+               $heading = "404 Page Not Found";
+               $message = "The page you requested was not found.";
+
+               // By default we log this, but allow a dev to skip it
+               if ($log_error)
+               {
+                       log_message('error', '404 Page Not Found --> '.$page);
+               }
+
+               echo $this->show_error($heading, $message, 'error_404', 404);
+               exit;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * General Error Page
+        *
+        * This function takes an error message as input
+        * (either as a string or an array) and displays
+        * it using the specified template.
+        *
+        * @access      private
+        * @param       string  the heading
+        * @param       string  the message
+        * @param       string  the template name
+        * @return      string
+        */
+       function show_error($heading, $message, $template = 'error_general', $status_code = 500)
+       {
+               set_status_header($status_code);
+
+               $message = '<p>'.implode('</p><p>', ( ! is_array($message)) ? array($message) : $message).'</p>';
+
+               if (ob_get_level() > $this->ob_level + 1)
+               {
+                       ob_end_flush();
+               }
+               ob_start();
+               include(APPPATH.'errors/'.$template.EXT);
+               $buffer = ob_get_contents();
+               ob_end_clean();
+               return $buffer;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Native PHP error handler
+        *
+        * @access      private
+        * @param       string  the error severity
+        * @param       string  the error string
+        * @param       string  the error filepath
+        * @param       string  the error line number
+        * @return      string
+        */
+       function show_php_error($severity, $message, $filepath, $line)
+       {
+               $severity = ( ! isset($this->levels[$severity])) ? $severity : $this->levels[$severity];
+
+               $filepath = str_replace("\\", "/", $filepath);
+
+               // For safety reasons we do not show the full file path
+               if (FALSE !== strpos($filepath, '/'))
+               {
+                       $x = explode('/', $filepath);
+                       $filepath = $x[count($x)-2].'/'.end($x);
+               }
+
+               if (ob_get_level() > $this->ob_level + 1)
+               {
+                       ob_end_flush();
+               }
+               ob_start();
+               include(APPPATH.'errors/error_php'.EXT);
+               $buffer = ob_get_contents();
+               ob_end_clean();
+               echo $buffer;
+       }
+
+
+}
+// END Exceptions Class
+
+/* End of file Exceptions.php */
+/* Location: ./system/core/Exceptions.php */
\ No newline at end of file
diff --git a/system/core/Hooks.php b/system/core/Hooks.php
new file mode 100755 (executable)
index 0000000..24fa105
--- /dev/null
@@ -0,0 +1,233 @@
+<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+/**
+ * CodeIgniter
+ *
+ * An open source application development framework for PHP 5.1.6 or newer
+ *
+ * @package            CodeIgniter
+ * @author             ExpressionEngine Dev Team
+ * @copyright  Copyright (c) 2008 - 2011, EllisLab, Inc.
+ * @license            http://codeigniter.com/user_guide/license.html
+ * @link               http://codeigniter.com
+ * @since              Version 1.0
+ * @filesource
+ */
+
+// ------------------------------------------------------------------------
+
+/**
+ * CodeIgniter Hooks Class
+ *
+ * Provides a mechanism to extend the base system without hacking.
+ *
+ * @package            CodeIgniter
+ * @subpackage Libraries
+ * @category   Libraries
+ * @author             ExpressionEngine Dev Team
+ * @link               http://codeigniter.com/user_guide/libraries/encryption.html
+ */
+class CI_Hooks {
+
+       var $enabled            = FALSE;
+       var $hooks                      = array();
+       var $in_progress        = FALSE;
+
+       /**
+        * Constructor
+        *
+        */
+       function __construct()
+       {
+               $this->_initialize();
+               log_message('debug', "Hooks Class Initialized");
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Initialize the Hooks Preferences
+        *
+        * @access      private
+        * @return      void
+        */
+       function _initialize()
+       {
+               $CFG =& load_class('Config', 'core');
+
+               // If hooks are not enabled in the config file
+               // there is nothing else to do
+
+               if ($CFG->item('enable_hooks') == FALSE)
+               {
+                       return;
+               }
+
+               // Grab the "hooks" definition file.
+               // If there are no hooks, we're done.
+
+               if (defined('ENVIRONMENT') AND is_file(APPPATH.'config/'.ENVIRONMENT.'/hooks'.EXT))
+               {
+                   include(APPPATH.'config/'.ENVIRONMENT.'/hooks'.EXT);
+               }
+               elseif (is_file(APPPATH.'config/hooks'.EXT))
+               {
+                       include(APPPATH.'config/hooks'.EXT);
+               }
+
+
+               if ( ! isset($hook) OR ! is_array($hook))
+               {
+                       return;
+               }
+
+               $this->hooks =& $hook;
+               $this->enabled = TRUE;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Call Hook
+        *
+        * Calls a particular hook
+        *
+        * @access      private
+        * @param       string  the hook name
+        * @return      mixed
+        */
+       function _call_hook($which = '')
+       {
+               if ( ! $this->enabled OR ! isset($this->hooks[$which]))
+               {
+                       return FALSE;
+               }
+
+               if (isset($this->hooks[$which][0]) AND is_array($this->hooks[$which][0]))
+               {
+                       foreach ($this->hooks[$which] as $val)
+                       {
+                               $this->_run_hook($val);
+                       }
+               }
+               else
+               {
+                       $this->_run_hook($this->hooks[$which]);
+               }
+
+               return TRUE;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Run Hook
+        *
+        * Runs a particular hook
+        *
+        * @access      private
+        * @param       array   the hook details
+        * @return      bool
+        */
+       function _run_hook($data)
+       {
+               if ( ! is_array($data))
+               {
+                       return FALSE;
+               }
+
+               // -----------------------------------
+               // Safety - Prevents run-away loops
+               // -----------------------------------
+
+               // If the script being called happens to have the same
+               // hook call within it a loop can happen
+
+               if ($this->in_progress == TRUE)
+               {
+                       return;
+               }
+
+               // -----------------------------------
+               // Set file path
+               // -----------------------------------
+
+               if ( ! isset($data['filepath']) OR ! isset($data['filename']))
+               {
+                       return FALSE;
+               }
+
+               $filepath = APPPATH.$data['filepath'].'/'.$data['filename'];
+
+               if ( ! file_exists($filepath))
+               {
+                       return FALSE;
+               }
+
+               // -----------------------------------
+               // Set class/function name
+               // -----------------------------------
+
+               $class          = FALSE;
+               $function       = FALSE;
+               $params         = '';
+
+               if (isset($data['class']) AND $data['class'] != '')
+               {
+                       $class = $data['class'];
+               }
+
+               if (isset($data['function']))
+               {
+                       $function = $data['function'];
+               }
+
+               if (isset($data['params']))
+               {
+                       $params = $data['params'];
+               }
+
+               if ($class === FALSE AND $function === FALSE)
+               {
+                       return FALSE;
+               }
+
+               // -----------------------------------
+               // Set the in_progress flag
+               // -----------------------------------
+
+               $this->in_progress = TRUE;
+
+               // -----------------------------------
+               // Call the requested class and/or function
+               // -----------------------------------
+
+               if ($class !== FALSE)
+               {
+                       if ( ! class_exists($class))
+                       {
+                               require($filepath);
+                       }
+
+                       $HOOK = new $class;
+                       $HOOK->$function($params);
+               }
+               else
+               {
+                       if ( ! function_exists($function))
+                       {
+                               require($filepath);
+                       }
+
+                       $function($params);
+               }
+
+               $this->in_progress = FALSE;
+               return TRUE;
+       }
+
+}
+
+// END CI_Hooks class
+
+/* End of file Hooks.php */
+/* Location: ./system/core/Hooks.php */
\ No newline at end of file
diff --git a/system/core/Input.php b/system/core/Input.php
new file mode 100755 (executable)
index 0000000..dc7612e
--- /dev/null
@@ -0,0 +1,682 @@
+<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+/**
+ * CodeIgniter
+ *
+ * An open source application development framework for PHP 5.1.6 or newer
+ *
+ * @package            CodeIgniter
+ * @author             ExpressionEngine Dev Team
+ * @copyright  Copyright (c) 2008 - 2011, EllisLab, Inc.
+ * @license            http://codeigniter.com/user_guide/license.html
+ * @link               http://codeigniter.com
+ * @since              Version 1.0
+ * @filesource
+ */
+
+// ------------------------------------------------------------------------
+
+/**
+ * Input Class
+ *
+ * Pre-processes global input data for security
+ *
+ * @package            CodeIgniter
+ * @subpackage Libraries
+ * @category   Input
+ * @author             ExpressionEngine Dev Team
+ * @link               http://codeigniter.com/user_guide/libraries/input.html
+ */
+class CI_Input {
+
+       var $ip_address                         = FALSE;
+       var $user_agent                         = FALSE;
+       var $_allow_get_array           = TRUE;
+       var $_standardize_newlines      = TRUE;
+       var $_enable_xss                        = FALSE; // Set automatically based on config setting
+       var $_enable_csrf                       = FALSE; // Set automatically based on config setting
+
+       protected $headers                      = array();
+       
+
+       /**
+        * Constructor
+        *
+        * Sets whether to globally enable the XSS processing
+        * and whether to allow the $_GET array
+        *
+        */
+       public function __construct()
+       {
+               log_message('debug', "Input Class Initialized");
+
+               $this->_allow_get_array = (config_item('allow_get_array') === TRUE);
+               $this->_enable_xss              = (config_item('global_xss_filtering') === TRUE);
+               $this->_enable_csrf             = (config_item('csrf_protection') === TRUE);
+
+               global $SEC;
+               $this->security =& $SEC;
+
+               // Do we need the UTF-8 class?
+               if (UTF8_ENABLED === TRUE)
+               {
+                       global $UNI;
+                       $this->uni =& $UNI;
+               }
+
+               // Sanitize global arrays
+               $this->_sanitize_globals();
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Fetch from array
+        *
+        * This is a helper function to retrieve values from global arrays
+        *
+        * @access      private
+        * @param       array
+        * @param       string
+        * @param       bool
+        * @return      string
+        */
+       function _fetch_from_array(&$array, $index = '', $xss_clean = FALSE)
+       {
+               if ( ! isset($array[$index]))
+               {
+                       return FALSE;
+               }
+
+               if ($xss_clean === TRUE)
+               {
+                       return $this->security->xss_clean($array[$index]);
+               }
+
+               return $array[$index];
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+       * Fetch an item from the GET array
+       *
+       * @access       public
+       * @param        string
+       * @param        bool
+       * @return       string
+       */
+       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);
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+       * Fetch an item from the POST array
+       *
+       * @access       public
+       * @param        string
+       * @param        bool
+       * @return       string
+       */
+       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);
+       }
+
+
+       // --------------------------------------------------------------------
+
+       /**
+       * Fetch an item from either the GET array or the POST
+       *
+       * @access       public
+       * @param        string  The index key
+       * @param        bool    XSS cleaning
+       * @return       string
+       */
+       function get_post($index = '', $xss_clean = FALSE)
+       {
+               if ( ! isset($_POST[$index]) )
+               {
+                       return $this->get($index, $xss_clean);
+               }
+               else
+               {
+                       return $this->post($index, $xss_clean);
+               }
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+       * Fetch an item from the COOKIE array
+       *
+       * @access       public
+       * @param        string
+       * @param        bool
+       * @return       string
+       */
+       function cookie($index = '', $xss_clean = FALSE)
+       {
+               return $this->_fetch_from_array($_COOKIE, $index, $xss_clean);
+       }
+
+       // ------------------------------------------------------------------------
+
+       /**
+       * Set cookie
+       *
+       * Accepts six parameter, or you can submit an associative
+       * array in the first parameter containing all the values.
+       *
+       * @access       public
+       * @param        mixed
+       * @param        string  the value of the cookie
+       * @param        string  the number of seconds until expiration
+       * @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 = '', $secure = FALSE)
+       {
+               if (is_array($name))
+               {
+                       // 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]))
+                               {
+                                       $$item = $name[$item];
+                               }
+                       }
+               }
+
+               if ($prefix == '' AND config_item('cookie_prefix') != '')
+               {
+                       $prefix = config_item('cookie_prefix');
+               }
+               if ($domain == '' AND config_item('cookie_domain') != '')
+               {
+                       $domain = config_item('cookie_domain');
+               }
+               if ($path == '/' AND config_item('cookie_path') != '/')
+               {
+                       $path = config_item('cookie_path');
+               }
+               if ($secure == FALSE AND config_item('cookie_secure') != FALSE)
+               {
+                       $secure = config_item('cookie_secure');
+               }
+
+               if ( ! is_numeric($expire))
+               {
+                       $expire = time() - 86500;
+               }
+               else
+               {
+                       $expire = ($expire > 0) ? time() + $expire : 0;
+               }
+
+               setcookie($prefix.$name, $value, $expire, $path, $domain, $secure);
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+       * Fetch an item from the SERVER array
+       *
+       * @access       public
+       * @param        string
+       * @param        bool
+       * @return       string
+       */
+       function server($index = '', $xss_clean = FALSE)
+       {
+               return $this->_fetch_from_array($_SERVER, $index, $xss_clean);
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+       * Fetch the IP Address
+       *
+       * @access       public
+       * @return       string
+       */
+       function ip_address()
+       {
+               if ($this->ip_address !== FALSE)
+               {
+                       return $this->ip_address;
+               }
+
+               if (config_item('proxy_ips') != '' && $this->server('HTTP_X_FORWARDED_FOR') && $this->server('REMOTE_ADDR'))
+               {
+                       $proxies = preg_split('/[\s,]/', config_item('proxy_ips'), -1, PREG_SPLIT_NO_EMPTY);
+                       $proxies = is_array($proxies) ? $proxies : array($proxies);
+
+                       $this->ip_address = in_array($_SERVER['REMOTE_ADDR'], $proxies) ? $_SERVER['HTTP_X_FORWARDED_FOR'] : $_SERVER['REMOTE_ADDR'];
+               }
+               elseif ($this->server('REMOTE_ADDR') AND $this->server('HTTP_CLIENT_IP'))
+               {
+                       $this->ip_address = $_SERVER['HTTP_CLIENT_IP'];
+               }
+               elseif ($this->server('REMOTE_ADDR'))
+               {
+                       $this->ip_address = $_SERVER['REMOTE_ADDR'];
+               }
+               elseif ($this->server('HTTP_CLIENT_IP'))
+               {
+                       $this->ip_address = $_SERVER['HTTP_CLIENT_IP'];
+               }
+               elseif ($this->server('HTTP_X_FORWARDED_FOR'))
+               {
+                       $this->ip_address = $_SERVER['HTTP_X_FORWARDED_FOR'];
+               }
+
+               if ($this->ip_address === FALSE)
+               {
+                       $this->ip_address = '0.0.0.0';
+                       return $this->ip_address;
+               }
+
+               if (strpos($this->ip_address, ',') !== FALSE)
+               {
+                       $x = explode(',', $this->ip_address);
+                       $this->ip_address = trim(end($x));
+               }
+
+               if ( ! $this->valid_ip($this->ip_address))
+               {
+                       $this->ip_address = '0.0.0.0';
+               }
+
+               return $this->ip_address;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+       * Validate IP Address
+       *
+       * Updated version suggested by Geert De Deckere
+       *
+       * @access       public
+       * @param        string
+       * @return       string
+       */
+       function valid_ip($ip)
+       {
+               $ip_segments = explode('.', $ip);
+
+               // Always 4 segments needed
+               if (count($ip_segments) != 4)
+               {
+                       return FALSE;
+               }
+               // IP can not start with 0
+               if ($ip_segments[0][0] == '0')
+               {
+                       return FALSE;
+               }
+               // Check each segment
+               foreach ($ip_segments as $segment)
+               {
+                       // IP segments must be digits and can not be
+                       // longer than 3 digits or greater then 255
+                       if ($segment == '' OR preg_match("/[^0-9]/", $segment) OR $segment > 255 OR strlen($segment) > 3)
+                       {
+                               return FALSE;
+                       }
+               }
+
+               return TRUE;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+       * User Agent
+       *
+       * @access       public
+       * @return       string
+       */
+       function user_agent()
+       {
+               if ($this->user_agent !== FALSE)
+               {
+                       return $this->user_agent;
+               }
+
+               $this->user_agent = ( ! isset($_SERVER['HTTP_USER_AGENT'])) ? FALSE : $_SERVER['HTTP_USER_AGENT'];
+
+               return $this->user_agent;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+       * Sanitize Globals
+       *
+       * This function does the following:
+       *
+       * Unsets $_GET data (if query strings are not enabled)
+       *
+       * Unsets all globals if register_globals is enabled
+       *
+       * Standardizes newline characters to \n
+       *
+       * @access       private
+       * @return       void
+       */
+       function _sanitize_globals()
+       {
+               // It would be "wrong" to unset any of these GLOBALS.
+               $protected = array('_SERVER', '_GET', '_POST', '_FILES', '_REQUEST', 
+                                                       '_SESSION', '_ENV', 'GLOBALS', 'HTTP_RAW_POST_DATA',
+                                                       'system_folder', 'application_folder', 'BM', 'EXT', 
+                                                       'CFG', 'URI', 'RTR', 'OUT', 'IN');
+
+               // Unset globals for securiy.
+               // This is effectively the same as register_globals = off
+               foreach (array($_GET, $_POST, $_COOKIE) as $global)
+               {
+                       if ( ! is_array($global))
+                       {
+                               if ( ! in_array($global, $protected))
+                               {
+                                       global $$global;
+                                       $$global = NULL;
+                               }
+                       }
+                       else
+                       {
+                               foreach ($global as $key => $val)
+                               {
+                                       if ( ! in_array($key, $protected))
+                                       {
+                                               global $$key;
+                                               $$key = NULL;
+                                       }
+                               }
+                       }
+               }
+
+               // Is $_GET data allowed? If not we'll set the $_GET to an empty array
+               if ($this->_allow_get_array == FALSE)
+               {
+                       $_GET = array();
+               }
+               else
+               {
+                       if (is_array($_GET) AND count($_GET) > 0)
+                       {
+                               foreach ($_GET as $key => $val)
+                               {
+                                       $_GET[$this->_clean_input_keys($key)] = $this->_clean_input_data($val);
+                               }
+                       }
+               }
+
+               // Clean $_POST Data
+               if (is_array($_POST) AND count($_POST) > 0)
+               {
+                       foreach ($_POST as $key => $val)
+                       {
+                               $_POST[$this->_clean_input_keys($key)] = $this->_clean_input_data($val);
+                       }
+               }
+
+               // Clean $_COOKIE Data
+               if (is_array($_COOKIE) AND count($_COOKIE) > 0)
+               {
+                       // Also get rid of specially treated cookies that might be set by a server
+                       // or silly application, that are of no use to a CI application anyway
+                       // but that when present will trip our 'Disallowed Key Characters' alarm
+                       // http://www.ietf.org/rfc/rfc2109.txt
+                       // note that the key names below are single quoted strings, and are not PHP variables
+                       unset($_COOKIE['$Version']);
+                       unset($_COOKIE['$Path']);
+                       unset($_COOKIE['$Domain']);
+
+                       foreach ($_COOKIE as $key => $val)
+                       {
+                               $_COOKIE[$this->_clean_input_keys($key)] = $this->_clean_input_data($val);
+                       }
+               }
+
+               // Sanitize PHP_SELF
+               $_SERVER['PHP_SELF'] = strip_tags($_SERVER['PHP_SELF']);
+
+
+               // CSRF Protection check
+               if ($this->_enable_csrf == TRUE)
+               {
+                       $this->security->csrf_verify();
+               }
+
+               log_message('debug', "Global POST and COOKIE data sanitized");
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+       * Clean Input Data
+       *
+       * This is a helper function. It escapes data and
+       * standardizes newline characters to \n
+       *
+       * @access       private
+       * @param        string
+       * @return       string
+       */
+       function _clean_input_data($str)
+       {
+               if (is_array($str))
+               {
+                       $new_array = array();
+                       foreach ($str as $key => $val)
+                       {
+                               $new_array[$this->_clean_input_keys($key)] = $this->_clean_input_data($val);
+                       }
+                       return $new_array;
+               }
+
+               // We strip slashes if magic quotes is on to keep things consistent
+               if (function_exists('get_magic_quotes_gpc') AND get_magic_quotes_gpc())
+               {
+                       $str = stripslashes($str);
+               }
+
+               // Clean UTF-8 if supported
+               if (UTF8_ENABLED === TRUE)
+               {
+                       $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)
+               {
+                       $str = $this->security->xss_clean($str);
+               }
+
+               // Standardize newlines if needed
+               if ($this->_standardize_newlines == TRUE)
+               {
+                       if (strpos($str, "\r") !== FALSE)
+                       {
+                               $str = str_replace(array("\r\n", "\r", "\r\n\n"), PHP_EOL, $str);
+                       }
+               }
+
+               return $str;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+       * Clean Keys
+       *
+       * This is a helper function. To prevent malicious users
+       * from trying to exploit keys we make sure that keys are
+       * only named with alpha-numeric text and a few other items.
+       *
+       * @access       private
+       * @param        string
+       * @return       string
+       */
+       function _clean_input_keys($str)
+       {
+               if ( ! preg_match("/^[a-z0-9:_\/-]+$/i", $str))
+               {
+                       exit('Disallowed Key Characters.');
+               }
+
+               // Clean UTF-8 if supported
+               if (UTF8_ENABLED === TRUE)
+               {
+                       $str = $this->uni->clean_string($str);
+               }
+
+               return $str;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Request Headers
+        *
+        * In Apache, you can simply call apache_request_headers(), however for 
+        * people running other webservers the function is undefined.
+        *
+        * @return array
+        */
+       public function request_headers($xss_clean = FALSE)
+       {
+               // Look at Apache go!
+               if (function_exists('apache_request_headers'))
+               {
+                       $headers = apache_request_headers();
+               }
+               else
+               {
+                       $headers['Content-Type'] = (isset($_SERVER['CONTENT_TYPE'])) ? $_SERVER['CONTENT_TYPE'] : @getenv('CONTENT_TYPE');
+
+                       foreach ($_SERVER as $key => $val)
+                       {
+                               if (strncmp($key, 'HTTP_', 5) === 0)
+                               {
+                                       $headers[substr($key, 5)] = $this->_fetch_from_array($_SERVER, $key, $xss_clean);
+                               }
+                       }
+               }
+
+               // take SOME_HEADER and turn it into Some-Header
+               foreach ($headers as $key => $val)
+               {
+                       $key = str_replace('_', ' ', strtolower($key));
+                       $key = str_replace(' ', '-', ucwords($key));
+                       
+                       $this->headers[$key] = $val;
+               }
+               
+               return $this->headers;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Get Request Header
+        *
+        * Returns the value of a single member of the headers class member
+        *
+        * @param       string          array key for $this->headers
+        * @param       boolean         XSS Clean or not
+        * @return      mixed           FALSE on failure, string on success
+        */
+       public function get_request_header($index, $xss_clean = FALSE)
+       {
+               if (empty($this->headers))
+               {
+                       $this->request_headers();
+               }
+               
+               if ( ! isset($this->headers[$index]))
+               {
+                       return FALSE;
+               }
+
+               if ($xss_clean === TRUE)
+               {
+                       return $this->security->xss_clean($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
+        */
+       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 */
diff --git a/system/core/Lang.php b/system/core/Lang.php
new file mode 100755 (executable)
index 0000000..0b926a3
--- /dev/null
@@ -0,0 +1,147 @@
+<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+/**
+ * CodeIgniter
+ *
+ * An open source application development framework for PHP 5.1.6 or newer
+ *
+ * @package            CodeIgniter
+ * @author             ExpressionEngine Dev Team
+ * @copyright  Copyright (c) 2008 - 2011, EllisLab, Inc.
+ * @license            http://codeigniter.com/user_guide/license.html
+ * @link               http://codeigniter.com
+ * @since              Version 1.0
+ * @filesource
+ */
+
+// ------------------------------------------------------------------------
+
+/**
+ * Language Class
+ *
+ * @package            CodeIgniter
+ * @subpackage Libraries
+ * @category   Language
+ * @author             ExpressionEngine Dev Team
+ * @link               http://codeigniter.com/user_guide/libraries/language.html
+ */
+class CI_Lang {
+
+       var $language   = array();
+       var $is_loaded  = array();
+
+       /**
+        * Constructor
+        *
+        * @access      public
+        */
+       function __construct()
+       {
+               log_message('debug', "Language Class Initialized");
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Load a language file
+        *
+        * @access      public
+        * @param       mixed   the name of the language file to be loaded. Can be an array
+        * @param       string  the language (english, etc.)
+        * @return      mixed
+        */
+       function load($langfile = '', $idiom = '', $return = FALSE, $add_suffix = TRUE, $alt_path = '')
+       {
+               $langfile = str_replace(EXT, '', $langfile);
+
+               if ($add_suffix == TRUE)
+               {
+                       $langfile = str_replace('_lang.', '', $langfile).'_lang';
+               }
+
+               $langfile .= EXT;
+
+               if (in_array($langfile, $this->is_loaded, TRUE))
+               {
+                       return;
+               }
+
+               $config =& get_config();
+
+               if ($idiom == '')
+               {
+                       $deft_lang = ( ! isset($config['language'])) ? 'english' : $config['language'];
+                       $idiom = ($deft_lang == '') ? 'english' : $deft_lang;
+               }
+
+               // Determine where the language file is and load it
+               if ($alt_path != '' && file_exists($alt_path.'language/'.$idiom.'/'.$langfile))
+               {
+                       include($alt_path.'language/'.$idiom.'/'.$langfile);
+               }
+               else
+               {
+                       $found = FALSE;
+
+                       foreach (get_instance()->load->get_package_paths(TRUE) as $package_path)
+                       {
+                               if (file_exists($package_path.'language/'.$idiom.'/'.$langfile))
+                               {
+                                       include($package_path.'language/'.$idiom.'/'.$langfile);
+                                       $found = TRUE;
+                                       break;
+                               }
+                       }
+
+                       if ($found !== TRUE)
+                       {
+                               show_error('Unable to load the requested language file: language/'.$idiom.'/'.$langfile);
+                       }
+               }
+
+
+               if ( ! isset($lang))
+               {
+                       log_message('error', 'Language file contains no data: language/'.$idiom.'/'.$langfile);
+                       return;
+               }
+
+               if ($return == TRUE)
+               {
+                       return $lang;
+               }
+
+               $this->is_loaded[] = $langfile;
+               $this->language = array_merge($this->language, $lang);
+               unset($lang);
+
+               log_message('debug', 'Language file loaded: language/'.$idiom.'/'.$langfile);
+               return TRUE;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Fetch a single line of text from the language array
+        *
+        * @access      public
+        * @param       string  $line   the language line
+        * @return      string
+        */
+       function line($line = '')
+       {
+               $line = ($line == '' OR ! isset($this->language[$line])) ? FALSE : $this->language[$line];
+
+               // Because killer robots like unicorns!
+               if ($line === FALSE)
+               {
+                       log_message('error', 'Could not find the language line "'.$line.'"');
+               }
+
+               return $line;
+       }
+
+}
+// END Language Class
+
+/* End of file Lang.php */
+/* Location: ./system/core/Lang.php */
\ No newline at end of file
diff --git a/system/core/Loader.php b/system/core/Loader.php
new file mode 100755 (executable)
index 0000000..e75805d
--- /dev/null
@@ -0,0 +1,1104 @@
+<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+/**
+ * CodeIgniter
+ *
+ * An open source application development framework for PHP 5.1.6 or newer
+ *
+ * @package            CodeIgniter
+ * @author             ExpressionEngine Dev Team
+ * @copyright  Copyright (c) 2008 - 2011, EllisLab, Inc.
+ * @license            http://codeigniter.com/user_guide/license.html
+ * @link               http://codeigniter.com
+ * @since              Version 1.0
+ * @filesource
+ */
+
+// ------------------------------------------------------------------------
+
+/**
+ * Loader Class
+ *
+ * Loads views and files
+ *
+ * @package            CodeIgniter
+ * @subpackage Libraries
+ * @author             ExpressionEngine Dev Team
+ * @category   Loader
+ * @link               http://codeigniter.com/user_guide/libraries/loader.html
+ */
+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');
+
+
+       /**
+        * Constructor
+        *
+        * Sets the path to the view files and gets the initial output buffering level
+        *
+        * @access      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);
+
+               log_message('debug', "Loader Class Initialized");
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * 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)
+       {
+               if (is_array($library))
+               {
+                       foreach ($library as $class)
+                       {
+                               $this->library($class, $params);
+                       }
+
+                       return;
+               }
+
+               if ($library == '' OR isset($this->_base_classes[$library]))
+               {
+                       return FALSE;
+               }
+
+               if ( ! is_null($params) && ! is_array($params))
+               {
+                       $params = NULL;
+               }
+
+               $this->_ci_load_class($library, $params, $object_name);
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Model Loader
+        *
+        * 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)
+       {
+               if (is_array($model))
+               {
+                       foreach ($model as $babe)
+                       {
+                               $this->model($babe);
+                       }
+                       return;
+               }
+
+               if ($model == '')
+               {
+                       return;
+               }
+
+               $path = '';
+
+               // Is the model in a sub-folder? If so, parse out the filename and path.
+               if (($last_slash = strrpos($model, '/')) !== FALSE)
+               {
+                       // The path is in front of the last slash
+                       $path = substr($model, 0, $last_slash + 1);
+
+                       // And the model name behind it
+                       $model = substr($model, $last_slash + 1);
+               }
+
+               if ($name == '')
+               {
+                       $name = $model;
+               }
+
+               if (in_array($name, $this->_ci_models, TRUE))
+               {
+                       return;
+               }
+
+               $CI =& get_instance();
+               if (isset($CI->$name))
+               {
+                       show_error('The model name you are loading is the name of a resource that is already being used: '.$name);
+               }
+
+               $model = strtolower($model);
+
+               foreach ($this->_ci_model_paths as $mod_path)
+               {
+                       if ( ! file_exists($mod_path.'models/'.$path.$model.EXT))
+                       {
+                               continue;
+                       }
+
+                       if ($db_conn !== FALSE AND ! class_exists('CI_DB'))
+                       {
+                               if ($db_conn === TRUE)
+                               {
+                                       $db_conn = '';
+                               }
+
+                               $CI->load->database($db_conn, FALSE, TRUE);
+                       }
+
+                       if ( ! class_exists('CI_Model'))
+                       {
+                               load_class('Model', 'core');
+                       }
+
+                       require_once($mod_path.'models/'.$path.$model.EXT);
+
+                       $model = ucfirst($model);
+
+                       $CI->$name = new $model();
+
+                       $this->_ci_models[] = $name;
+                       return;
+               }
+
+               // couldn't find the model
+               show_error('Unable to locate the model you have specified: '.$model);
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * 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)
+       {
+               // Grab the super object
+               $CI =& get_instance();
+
+               // Do we even need to load the database class?
+               if (class_exists('CI_DB') AND $return == FALSE AND $active_record == NULL AND isset($CI->db) AND is_object($CI->db))
+               {
+                       return FALSE;
+               }
+
+               require_once(BASEPATH.'database/DB'.EXT);
+
+               if ($return === TRUE)
+               {
+                       return DB($params, $active_record);
+               }
+
+               // Initialize the db variable.  Needed to prevent
+               // reference errors with some configurations
+               $CI->db = '';
+
+               // Load the DB class
+               $CI->db =& DB($params, $active_record);
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Load the Utilities Class
+        *
+        * @access      public
+        * @return      string
+        */
+       function dbutil()
+       {
+               if ( ! class_exists('CI_DB'))
+               {
+                       $this->database();
+               }
+
+               $CI =& get_instance();
+
+               // for backwards compatibility, load dbforge so we can extend dbutils off it
+               // 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);
+               $class = 'CI_DB_'.$CI->db->dbdriver.'_utility';
+
+               $CI->dbutil = new $class();
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Load the Database Forge Class
+        *
+        * @access      public
+        * @return      string
+        */
+       function dbforge()
+       {
+               if ( ! class_exists('CI_DB'))
+               {
+                       $this->database();
+               }
+
+               $CI =& get_instance();
+
+               require_once(BASEPATH.'database/DB_forge'.EXT);
+               require_once(BASEPATH.'database/drivers/'.$CI->db->dbdriver.'/'.$CI->db->dbdriver.'_forge'.EXT);
+               $class = 'CI_DB_'.$CI->db->dbdriver.'_forge';
+
+               $CI->dbforge = new $class();
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Load View
+        *
+        * This function is used to load a "view" file.  It has three parameters:
+        *
+        * 1. The name of the "view" file to be included.
+        * 2. An associative array of data to be extracted for use in the view.
+        * 3. TRUE/FALSE - whether to return the data or load it.  In
+        * 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)
+       {
+               return $this->_ci_load(array('_ci_view' => $view, '_ci_vars' => $this->_ci_object_to_array($vars), '_ci_return' => $return));
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Load File
+        *
+        * This is a generic file loader
+        *
+        * @access      public
+        * @param       string
+        * @param       bool
+        * @return      string
+        */
+       function file($path, $return = FALSE)
+       {
+               return $this->_ci_load(array('_ci_path' => $path, '_ci_return' => $return));
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Set Variables
+        *
+        * Once variables are set they become available within
+        * the controller class and its "view" files.
+        *
+        * @access      public
+        * @param       array
+        * @return      void
+        */
+       function vars($vars = array(), $val = '')
+       {
+               if ($val != '' AND is_string($vars))
+               {
+                       $vars = array($vars => $val);
+               }
+
+               $vars = $this->_ci_object_to_array($vars);
+
+               if (is_array($vars) AND count($vars) > 0)
+               {
+                       foreach ($vars as $key => $val)
+                       {
+                               $this->_ci_cached_vars[$key] = $val;
+                       }
+               }
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Load Helper
+        *
+        * This function loads the specified helper file.
+        *
+        * @access      public
+        * @param       mixed
+        * @return      void
+        */
+       function helper($helpers = array())
+       {
+               foreach ($this->_ci_prep_filename($helpers, '_helper') as $helper)
+               {
+                       if (isset($this->_ci_helpers[$helper]))
+                       {
+                               continue;
+                       }
+
+                       $ext_helper = APPPATH.'helpers/'.config_item('subclass_prefix').$helper.EXT;
+
+                       // Is this a helper extension request?
+                       if (file_exists($ext_helper))
+                       {
+                               $base_helper = BASEPATH.'helpers/'.$helper.EXT;
+
+                               if ( ! file_exists($base_helper))
+                               {
+                                       show_error('Unable to load the requested file: helpers/'.$helper.EXT);
+                               }
+
+                               include_once($ext_helper);
+                               include_once($base_helper);
+
+                               $this->_ci_helpers[$helper] = TRUE;
+                               log_message('debug', 'Helper loaded: '.$helper);
+                               continue;
+                       }
+
+                       // Try to load the helper
+                       foreach ($this->_ci_helper_paths as $path)
+                       {
+                               if (file_exists($path.'helpers/'.$helper.EXT))
+                               {
+                                       include_once($path.'helpers/'.$helper.EXT);
+
+                                       $this->_ci_helpers[$helper] = TRUE;
+                                       log_message('debug', 'Helper loaded: '.$helper);
+                                       break;
+                               }
+                       }
+
+                       // unable to load the helper
+                       if ( ! isset($this->_ci_helpers[$helper]))
+                       {
+                               show_error('Unable to load the requested file: helpers/'.$helper.EXT);
+                       }
+               }
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Load Helpers
+        *
+        * 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())
+       {
+               $this->helper($helpers);
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Loads a language file
+        *
+        * @access      public
+        * @param       array
+        * @param       string
+        * @return      void
+        */
+       function language($file = array(), $lang = '')
+       {
+               $CI =& get_instance();
+
+               if ( ! is_array($file))
+               {
+                       $file = array($file);
+               }
+
+               foreach ($file as $langfile)
+               {
+                       $CI->lang->load($langfile, $lang);
+               }
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Loads a config file
+        *
+        * @access      public
+        * @param       string
+        * @return      void
+        */
+       function config($file = '', $use_sections = FALSE, $fail_gracefully = FALSE)
+       {
+               $CI =& get_instance();
+               $CI->config->load($file, $use_sections, $fail_gracefully);
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Driver
+        *
+        * Loads a driver library
+        *
+        * @param       string  the name of the class
+        * @param       mixed   the optional parameters
+        * @param       string  an optional object name
+        * @return      void
+        */
+       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;
+               }
+
+               // We can save the loader some time since Drivers will *always* be in a subfolder,
+               // and typically identically named to the library
+               if ( ! strpos($library, '/'))
+               {
+                       $library = ucfirst($library).'/'.$library;
+               }
+
+               return $this->library($library, $params, $object_name);
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Add Package Path
+        *
+        * Prepends a parent path to the library, model, helper, and config path arrays
+        *
+        * @access      public
+        * @param       string
+        * @return      void
+        */
+       function add_package_path($path)
+       {
+               $path = rtrim($path, '/').'/';
+
+               array_unshift($this->_ci_library_paths, $path);
+               array_unshift($this->_ci_model_paths, $path);
+               array_unshift($this->_ci_helper_paths, $path);
+
+               // Add config file path
+               $config =& $this->_ci_get_component('config');
+               array_unshift($config->_config_paths, $path);
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Get Package Paths
+        *
+        * 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)
+       {
+               return $include_base === TRUE ? $this->_ci_library_paths : $this->_ci_model_paths;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Remove Package Path
+        *
+        * 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
+        * @return      type
+        */
+       function remove_package_path($path = '', $remove_config_path = TRUE)
+       {
+               $config =& $this->_ci_get_component('config');
+
+               if ($path == '')
+               {
+                       $void = array_shift($this->_ci_library_paths);
+                       $void = array_shift($this->_ci_model_paths);
+                       $void = array_shift($this->_ci_helper_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)
+                               {
+                                       unset($this->{$var}[$key]);
+                               }
+                       }
+
+                       if (($key = array_search($path, $config->_config_paths)) !== FALSE)
+                       {
+                               unset($config->_config_paths[$key]);
+                       }
+               }
+
+               // make sure the application default paths are still in the array
+               $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)));
+               $config->_config_paths = array_unique(array_merge($config->_config_paths, array(APPPATH)));
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Loader
+        *
+        * This function is used to load views and files.
+        * 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)
+       {
+               // Set the default data variables
+               foreach (array('_ci_view', '_ci_vars', '_ci_path', '_ci_return') as $_ci_val)
+               {
+                       $$_ci_val = ( ! isset($_ci_data[$_ci_val])) ? FALSE : $_ci_data[$_ci_val];
+               }
+
+               // Set the path to the requested file
+               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;
+               }
+               else
+               {
+                       $_ci_x = explode('/', $_ci_path);
+                       $_ci_file = end($_ci_x);
+               }
+
+               if ( ! file_exists($_ci_path))
+               {
+                       show_error('Unable to load the requested file: '.$_ci_file);
+               }
+
+               // This allows anything loaded using $this->load (views, files, etc.)
+               // to become accessible from within the Controller and Model functions.
+
+               $_ci_CI =& get_instance();
+               foreach (get_object_vars($_ci_CI) as $_ci_key => $_ci_var)
+               {
+                       if ( ! isset($this->$_ci_key))
+                       {
+                               $this->$_ci_key =& $_ci_CI->$_ci_key;
+                       }
+               }
+
+               /*
+                * Extract and cache variables
+                *
+                * You can either set variables using the dedicated $this->load_vars()
+                * function or via the second parameter of this function. We'll merge
+                * the two types and cache them so that views that are embedded within
+                * other views can have access to these variables.
+                */
+               if (is_array($_ci_vars))
+               {
+                       $this->_ci_cached_vars = array_merge($this->_ci_cached_vars, $_ci_vars);
+               }
+               extract($this->_ci_cached_vars);
+
+               /*
+                * Buffer the output
+                *
+                * We buffer the output for two reasons:
+                * 1. Speed. You get a significant speed boost.
+                * 2. So that the final rendered template can be
+                * post-processed by the output class.  Why do we
+                * need post processing?  For one thing, in order to
+                * show the elapsed page load time.  Unless we
+                * can intercept the content right before it's sent to
+                * the browser and then stop the timer it won't be accurate.
+                */
+               ob_start();
+
+               // If the PHP installation does not support short tags we'll
+               // do a little string replacement, changing the short tags
+               // to standard PHP echo statements.
+
+               if ((bool) @ini_get('short_open_tag') === FALSE AND config_item('rewrite_short_tags') == TRUE)
+               {
+                       echo eval('?>'.preg_replace("/;*\s*\?>/", "; ?>", str_replace('<?=', '<?php echo ', file_get_contents($_ci_path))));
+               }
+               else
+               {
+                       include($_ci_path); // include() vs include_once() allows for multiple views with the same name
+               }
+
+               log_message('debug', 'File loaded: '.$_ci_path);
+
+               // Return the file data if requested
+               if ($_ci_return === TRUE)
+               {
+                       $buffer = ob_get_contents();
+                       @ob_end_clean();
+                       return $buffer;
+               }
+
+               /*
+                * Flush the buffer... or buff the flusher?
+                *
+                * In order to permit views to be nested within
+                * other views, we need to flush the content back out whenever
+                * we are beyond the first level of output buffering so that
+                * it can be seen and included properly by the first included
+                * template and any subsequent ones. Oy!
+                *
+                */
+               if (ob_get_level() > $this->_ci_ob_level + 1)
+               {
+                       ob_end_flush();
+               }
+               else
+               {
+                       $_ci_CI->output->append_output(ob_get_contents());
+                       @ob_end_clean();
+               }
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Load class
+        *
+        * 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)
+       {
+               // 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, '/'));
+
+               // Was the path included with the class name?
+               // We look for a slash to determine this
+               $subdir = '';
+               if (($last_slash = strrpos($class, '/')) !== FALSE)
+               {
+                       // Extract the path
+                       $subdir = substr($class, 0, $last_slash + 1);
+
+                       // Get the filename from the path
+                       $class = substr($class, $last_slash + 1);
+               }
+
+               // 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;
+
+                       // Is this a class extension request?
+                       if (file_exists($subclass))
+                       {
+                               $baseclass = BASEPATH.'libraries/'.ucfirst($class).EXT;
+
+                               if ( ! file_exists($baseclass))
+                               {
+                                       log_message('error', "Unable to load the requested class: ".$class);
+                                       show_error("Unable to load the requested class: ".$class);
+                               }
+
+                               // Safety:  Was the class already loaded by a previous call?
+                               if (in_array($subclass, $this->_ci_loaded_files))
+                               {
+                                       // Before we deem this to be a duplicate request, let's see
+                                       // if a custom object name is being supplied.  If so, we'll
+                                       // return a new instance of the object
+                                       if ( ! is_null($object_name))
+                                       {
+                                               $CI =& get_instance();
+                                               if ( ! isset($CI->$object_name))
+                                               {
+                                                       return $this->_ci_init_class($class, config_item('subclass_prefix'), $params, $object_name);
+                                               }
+                                       }
+
+                                       $is_duplicate = TRUE;
+                                       log_message('debug', $class." class already loaded. Second attempt ignored.");
+                                       return;
+                               }
+
+                               include_once($baseclass);
+                               include_once($subclass);
+                               $this->_ci_loaded_files[] = $subclass;
+
+                               return $this->_ci_init_class($class, config_item('subclass_prefix'), $params, $object_name);
+                       }
+
+                       // Lets search for the requested library file and load it.
+                       $is_duplicate = FALSE;
+                       foreach ($this->_ci_library_paths as $path)
+                       {
+                               $filepath = $path.'libraries/'.$subdir.$class.EXT;
+
+                               // Does the file exist?  No?  Bummer...
+                               if ( ! file_exists($filepath))
+                               {
+                                       continue;
+                               }
+
+                               // Safety:  Was the class already loaded by a previous call?
+                               if (in_array($filepath, $this->_ci_loaded_files))
+                               {
+                                       // Before we deem this to be a duplicate request, let's see
+                                       // if a custom object name is being supplied.  If so, we'll
+                                       // return a new instance of the object
+                                       if ( ! is_null($object_name))
+                                       {
+                                               $CI =& get_instance();
+                                               if ( ! isset($CI->$object_name))
+                                               {
+                                                       return $this->_ci_init_class($class, '', $params, $object_name);
+                                               }
+                                       }
+
+                                       $is_duplicate = TRUE;
+                                       log_message('debug', $class." class already loaded. Second attempt ignored.");
+                                       return;
+                               }
+
+                               include_once($filepath);
+                               $this->_ci_loaded_files[] = $filepath;
+                               return $this->_ci_init_class($class, '', $params, $object_name);
+                       }
+
+               } // END FOREACH
+
+               // One last attempt.  Maybe the library is in a subdirectory, but it wasn't specified?
+               if ($subdir == '')
+               {
+                       $path = strtolower($class).'/'.$class;
+                       return $this->_ci_load_class($path, $params);
+               }
+
+               // If we got this far we were unable to find the requested class.
+               // We do not issue errors if the load call failed due to a duplicate request
+               if ($is_duplicate == FALSE)
+               {
+                       log_message('error', "Unable to load the requested class: ".$class);
+                       show_error("Unable to load the requested class: ".$class);
+               }
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Instantiates a class
+        *
+        * @access      private
+        * @param       string
+        * @param       string
+        * @param       string  an optional object name
+        * @return      null
+        */
+       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)
+               {
+                       // Fetch the config paths containing any package paths
+                       $config_component = $this->_ci_get_component('config');
+
+                       if (is_array($config_component->_config_paths))
+                       {
+                               // Break on the first found file, thus package files
+                               // are not overridden by default paths
+                               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. Check for environment
+                                       // first, global next
+                                       if (defined('ENVIRONMENT') AND file_exists($path .'config/'.ENVIRONMENT.'/'.strtolower($class).EXT))
+                                       {
+                                               include_once($path .'config/'.ENVIRONMENT.'/'.strtolower($class).EXT);
+                                               break;
+                                       }
+                                       elseif (defined('ENVIRONMENT') AND file_exists($path .'config/'.ENVIRONMENT.'/'.ucfirst(strtolower($class)).EXT))
+                                       {
+                                               include_once($path .'config/'.ENVIRONMENT.'/'.ucfirst(strtolower($class)).EXT);
+                                               break;
+                                       }
+                                       elseif (file_exists($path .'config/'.strtolower($class).EXT))
+                                       {
+                                               include_once($path .'config/'.strtolower($class).EXT);
+                                               break;
+                                       }
+                                       elseif (file_exists($path .'config/'.ucfirst(strtolower($class)).EXT))
+                                       {
+                                               include_once($path .'config/'.ucfirst(strtolower($class)).EXT);
+                                               break;
+                                       }
+                               }
+                       }
+               }
+
+               if ($prefix == '')
+               {
+                       if (class_exists('CI_'.$class))
+                       {
+                               $name = 'CI_'.$class;
+                       }
+                       elseif (class_exists(config_item('subclass_prefix').$class))
+                       {
+                               $name = config_item('subclass_prefix').$class;
+                       }
+                       else
+                       {
+                               $name = $class;
+                       }
+               }
+               else
+               {
+                       $name = $prefix.$class;
+               }
+
+               // Is the class name valid?
+               if ( ! class_exists($name))
+               {
+                       log_message('error', "Non-existent class: ".$name);
+                       show_error("Non-existent class: ".$class);
+               }
+
+               // Set the variable name we will assign the class to
+               // Was a custom class name supplied?  If so we'll use it
+               $class = strtolower($class);
+
+               if (is_null($object_name))
+               {
+                       $classvar = ( ! isset($this->_ci_varmap[$class])) ? $class : $this->_ci_varmap[$class];
+               }
+               else
+               {
+                       $classvar = $object_name;
+               }
+
+               // Save the class name and object name
+               $this->_ci_classes[$class] = $classvar;
+
+               // Instantiate the class
+               $CI =& get_instance();
+               if ($config !== NULL)
+               {
+                       $CI->$classvar = new $name($config);
+               }
+               else
+               {
+                       $CI->$classvar = new $name;
+               }
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Autoloader
+        *
+        * 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()
+       {
+               if (defined('ENVIRONMENT') AND file_exists(APPPATH.'config/'.ENVIRONMENT.'/autoload'.EXT))
+               {
+                       include_once(APPPATH.'config/'.ENVIRONMENT.'/autoload'.EXT);
+               }
+               else
+               {
+                       include_once(APPPATH.'config/autoload'.EXT);
+               }
+               
+
+               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)
+               {
+                       $CI =& get_instance();
+                       foreach ($autoload['config'] as $key => $val)
+                       {
+                               $CI->config->load($val);
+                       }
+               }
+
+               // Autoload helpers and languages
+               foreach (array('helper', 'language') as $type)
+               {
+                       if (isset($autoload[$type]) AND count($autoload[$type]) > 0)
+                       {
+                               $this->$type($autoload[$type]);
+                       }
+               }
+
+               // A little tweak to remain backward compatible
+               // The $autoload['core'] item was deprecated
+               if ( ! isset($autoload['libraries']) AND isset($autoload['core']))
+               {
+                       $autoload['libraries'] = $autoload['core'];
+               }
+
+               // Load libraries
+               if (isset($autoload['libraries']) AND count($autoload['libraries']) > 0)
+               {
+                       // Load the database driver.
+                       if (in_array('database', $autoload['libraries']))
+                       {
+                               $this->database();
+                               $autoload['libraries'] = array_diff($autoload['libraries'], array('database'));
+                       }
+
+                       // Load all other libraries
+                       foreach ($autoload['libraries'] as $item)
+                       {
+                               $this->library($item);
+                       }
+               }
+
+               // Autoload models
+               if (isset($autoload['model']))
+               {
+                       $this->model($autoload['model']);
+               }
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Object to Array
+        *
+        * 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)
+       {
+               return (is_object($object)) ? get_object_vars($object) : $object;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Get a reference to a specific library or model
+        *
+        * @access      private
+        * @return      bool
+        */
+       function &_ci_get_component($component)
+       {
+               $CI =& get_instance();
+               return $CI->$component;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Prep filename
+        *
+        * This function preps the name of various items to make loading them more reliable.
+        *
+        * @access      private
+        * @param       mixed
+        * @return      array
+        */
+       function _ci_prep_filename($filename, $extension)
+       {
+               if ( ! is_array($filename))
+               {
+                       return array(strtolower(str_replace(EXT, '', str_replace($extension, '', $filename)).$extension));
+               }
+               else
+               {
+                       foreach ($filename as $key => $val)
+                       {
+                               $filename[$key] = strtolower(str_replace(EXT, '', str_replace($extension, '', $val)).$extension);
+                       }
+
+                       return $filename;
+               }
+       }
+
+
+}
+
+/* End of file Loader.php */
+/* Location: ./system/core/Loader.php */
diff --git a/system/core/Model.php b/system/core/Model.php
new file mode 100755 (executable)
index 0000000..8566a0b
--- /dev/null
@@ -0,0 +1,56 @@
+<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+/**
+ * CodeIgniter
+ *
+ * An open source application development framework for PHP 5.1.6 or newer
+ *
+ * @package            CodeIgniter
+ * @author             ExpressionEngine Dev Team
+ * @copyright  Copyright (c) 2008 - 2011, EllisLab, Inc.
+ * @license            http://codeigniter.com/user_guide/license.html
+ * @link               http://codeigniter.com
+ * @since              Version 1.0
+ * @filesource
+ */
+
+// ------------------------------------------------------------------------
+
+/**
+ * CodeIgniter Model Class
+ *
+ * @package            CodeIgniter
+ * @subpackage Libraries
+ * @category   Libraries
+ * @author             ExpressionEngine Dev Team
+ * @link               http://codeigniter.com/user_guide/libraries/config.html
+ */
+class CI_Model {
+
+       /**
+        * Constructor
+        *
+        * @access public
+        */
+       function __construct()
+       {
+               log_message('debug', "Model Class Initialized");
+       }
+
+       /**
+        * __get
+        *
+        * Allows models to access CI's loaded classes using the same
+        * syntax as controllers.
+        *
+        * @access private
+        */
+       function __get($key)
+       {
+               $CI =& get_instance();
+               return $CI->$key;
+       }
+}
+// END Model Class
+
+/* End of file Model.php */
+/* Location: ./system/core/Model.php */
\ No newline at end of file
diff --git a/system/core/Output.php b/system/core/Output.php
new file mode 100755 (executable)
index 0000000..45a82f3
--- /dev/null
@@ -0,0 +1,517 @@
+<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+/**
+ * CodeIgniter
+ *
+ * An open source application development framework for PHP 5.1.6 or newer
+ *
+ * @package            CodeIgniter
+ * @author             ExpressionEngine Dev Team
+ * @copyright  Copyright (c) 2008 - 2011, EllisLab, Inc.
+ * @license            http://codeigniter.com/user_guide/license.html
+ * @link               http://codeigniter.com
+ * @since              Version 1.0
+ * @filesource
+ */
+
+// ------------------------------------------------------------------------
+
+/**
+ * Output Class
+ *
+ * Responsible for sending final output to browser
+ *
+ * @package            CodeIgniter
+ * @subpackage Libraries
+ * @category   Output
+ * @author             ExpressionEngine Dev Team
+ * @link               http://codeigniter.com/user_guide/libraries/output.html
+ */
+class CI_Output {
+
+       protected $final_output;
+       protected $cache_expiration     = 0;
+       protected $headers                      = array();
+       protected $mime_types                   = array();
+       protected $enable_profiler      = FALSE;
+       protected $_zlib_oc                     = FALSE;
+       protected $_profiler_sections = array();
+       protected $parse_exec_vars      = TRUE; // whether or not to parse variables like {elapsed_time} and {memory_usage}
+
+       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'.EXT))
+               {
+                   include APPPATH.'config/'.ENVIRONMENT.'/mimes'.EXT;
+               }
+               else
+               {
+                       include APPPATH.'config/mimes'.EXT;
+               }
+
+
+               $this->mime_types = $mimes;
+
+               log_message('debug', "Output Class Initialized");
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Get Output
+        *
+        * Returns the current output string
+        *
+        * @access      public
+        * @return      string
+        */
+       function get_output()
+       {
+               return $this->final_output;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Set Output
+        *
+        * Sets the output string
+        *
+        * @access      public
+        * @param       string
+        * @return      void
+        */
+       function set_output($output)
+       {
+               $this->final_output = $output;
+
+               return $this;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Append Output
+        *
+        * Appends data onto the output string
+        *
+        * @access      public
+        * @param       string
+        * @return      void
+        */
+       function append_output($output)
+       {
+               if ($this->final_output == '')
+               {
+                       $this->final_output = $output;
+               }
+               else
+               {
+                       $this->final_output .= $output;
+               }
+
+               return $this;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Set Header
+        *
+        * Lets you set a server header which will be outputted with the final display.
+        *
+        * Note:  If a file is cached, headers will not be sent.  We need to figure out
+        * how to permit header data to be saved with the cache data...
+        *
+        * @access      public
+        * @param       string
+        * @return      void
+        */
+       function set_header($header, $replace = TRUE)
+       {
+               // If zlib.output_compression is enabled it will compress the output,
+               // but it will not modify the content-length header to compensate for
+               // the reduction, causing the browser to hang waiting for more data.
+               // We'll just skip content-length in those cases.
+
+               if ($this->_zlib_oc && strncasecmp($header, 'content-length', 14) == 0)
+               {
+                       return;
+               }
+
+               $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;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Set HTTP Status Header
+        * moved to Common procedural functions in 1.7.2
+        *
+        * @access      public
+        * @param       int             the status code
+        * @param       string
+        * @return      void
+        */
+       function set_status_header($code = 200, $text = '')
+       {
+               set_status_header($code, $text);
+
+               return $this;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Enable/disable Profiler
+        *
+        * @access      public
+        * @param       bool
+        * @return      void
+        */
+       function enable_profiler($val = TRUE)
+       {
+               $this->enable_profiler = (is_bool($val)) ? $val : TRUE;
+
+               return $this;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Set Profiler Sections
+        *
+        * Allows override of default / config settings for Profiler section display
+        *
+        * @access      public
+        * @param       array
+        * @return      void
+        */
+       function set_profiler_sections($sections)
+       {
+               foreach ($sections as $section => $enable)
+               {
+                       $this->_profiler_sections[$section] = ($enable !== FALSE) ? TRUE : FALSE;
+               }
+
+               return $this;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Set Cache
+        *
+        * @access      public
+        * @param       integer
+        * @return      void
+        */
+       function cache($time)
+       {
+               $this->cache_expiration = ( ! is_numeric($time)) ? 0 : $time;
+
+               return $this;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Display Output
+        *
+        * All "view" data is automatically put into this variable by the controller class:
+        *
+        * $this->final_output
+        *
+        * This function sends the finalized output data to the browser along
+        * with any server headers and profile data.  It also stops the
+        * benchmark timer so the page rendering speed and memory usage can be shown.
+        *
+        * @access      public
+        * @return      mixed
+        */
+       function _display($output = '')
+       {
+               // Note:  We use globals because we can't use $CI =& get_instance()
+               // since this function is sometimes called by the caching mechanism,
+               // which happens before the CI super object is available.
+               global $BM, $CFG;
+
+               // Grab the super object if we can.
+               if (class_exists('CI_Controller'))
+               {
+                       $CI =& get_instance();
+               }
+
+               // --------------------------------------------------------------------
+
+               // Set the output data
+               if ($output == '')
+               {
+                       $output =& $this->final_output;
+               }
+
+               // --------------------------------------------------------------------
+
+               // Do we need to write a cache file?  Only if the controller does not have its
+               // own _output() method and we are not dealing with a cache file, which we
+               // can determine by the existence of the $CI object above
+               if ($this->cache_expiration > 0 && isset($CI) && ! method_exists($CI, '_output'))
+               {
+                       $this->_write_cache($output);
+               }
+
+               // --------------------------------------------------------------------
+
+               // Parse out the elapsed time and memory usage,
+               // then swap the pseudo-variables with the data
+
+               $elapsed = $BM->elapsed_time('total_execution_time_start', 'total_execution_time_end');
+
+               if ($this->parse_exec_vars === TRUE)
+               {
+                       $memory  = ( ! function_exists('memory_get_usage')) ? '0' : round(memory_get_usage()/1024/1024, 2).'MB';
+
+                       $output = str_replace('{elapsed_time}', $elapsed, $output);
+                       $output = str_replace('{memory_usage}', $memory, $output);
+               }
+
+               // --------------------------------------------------------------------
+
+               // Is compression requested?
+               if ($CFG->item('compress_output') === TRUE && $this->_zlib_oc == FALSE)
+               {
+                       if (extension_loaded('zlib'))
+                       {
+                               if (isset($_SERVER['HTTP_ACCEPT_ENCODING']) AND strpos($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip') !== FALSE)
+                               {
+                                       ob_start('ob_gzhandler');
+                               }
+                       }
+               }
+
+               // --------------------------------------------------------------------
+
+               // Are there any server headers to send?
+               if (count($this->headers) > 0)
+               {
+                       foreach ($this->headers as $header)
+                       {
+                               @header($header[0], $header[1]);
+                       }
+               }
+
+               // --------------------------------------------------------------------
+
+               // Does the $CI object exist?
+               // If not we know we are dealing with a cache file so we'll
+               // simply echo out the data and exit.
+               if ( ! isset($CI))
+               {
+                       echo $output;
+                       log_message('debug', "Final output sent to browser");
+                       log_message('debug', "Total execution time: ".$elapsed);
+                       return TRUE;
+               }
+
+               // --------------------------------------------------------------------
+
+               // Do we need to generate profile data?
+               // If so, load the Profile class and run it.
+               if ($this->enable_profiler == TRUE)
+               {
+                       $CI->load->library('profiler');
+
+                       if ( ! empty($this->_profiler_sections))
+                       {
+                               $CI->profiler->set_sections($this->_profiler_sections);
+                       }
+
+                       // If the output data contains closing </body> and </html> tags
+                       // we will remove them and add them back after we insert the profile data
+                       if (preg_match("|</body>.*?</html>|is", $output))
+                       {
+                               $output  = preg_replace("|</body>.*?</html>|is", '', $output);
+                               $output .= $CI->profiler->run();
+                               $output .= '</body></html>';
+                       }
+                       else
+                       {
+                               $output .= $CI->profiler->run();
+                       }
+               }
+
+               // --------------------------------------------------------------------
+
+               // Does the controller contain a function named _output()?
+               // If so send the output there.  Otherwise, echo it.
+               if (method_exists($CI, '_output'))
+               {
+                       $CI->_output($output);
+               }
+               else
+               {
+                       echo $output;  // Send it to the browser!
+               }
+
+               log_message('debug', "Final output sent to browser");
+               log_message('debug', "Total execution time: ".$elapsed);
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Write a Cache File
+        *
+        * @access      public
+        * @return      void
+        */
+       function _write_cache($output)
+       {
+               $CI =& get_instance();
+               $path = $CI->config->item('cache_path');
+
+               $cache_path = ($path == '') ? APPPATH.'cache/' : $path;
+
+               if ( ! is_dir($cache_path) OR ! is_really_writable($cache_path))
+               {
+                       log_message('error', "Unable to write cache file: ".$cache_path);
+                       return;
+               }
+
+               $uri =  $CI->config->item('base_url').
+                               $CI->config->item('index_page').
+                               $CI->uri->uri_string();
+
+               $cache_path .= md5($uri);
+
+               if ( ! $fp = @fopen($cache_path, FOPEN_WRITE_CREATE_DESTRUCTIVE))
+               {
+                       log_message('error', "Unable to write cache file: ".$cache_path);
+                       return;
+               }
+
+               $expire = time() + ($this->cache_expiration * 60);
+
+               if (flock($fp, LOCK_EX))
+               {
+                       fwrite($fp, $expire.'TS--->'.$output);
+                       flock($fp, LOCK_UN);
+               }
+               else
+               {
+                       log_message('error', "Unable to secure a file lock for file at: ".$cache_path);
+                       return;
+               }
+               fclose($fp);
+               @chmod($cache_path, FILE_WRITE_MODE);
+
+               log_message('debug', "Cache file written: ".$cache_path);
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Update/serve a cached file
+        *
+        * @access      public
+        * @return      void
+        */
+       function _display_cache(&$CFG, &$URI)
+       {
+               $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').
+                               $CFG->item('index_page').
+                               $URI->uri_string;
+
+               $filepath = $cache_path.md5($uri);
+
+               if ( ! @file_exists($filepath))
+               {
+                       return FALSE;
+               }
+
+               if ( ! $fp = @fopen($filepath, FOPEN_READ))
+               {
+                       return FALSE;
+               }
+
+               flock($fp, LOCK_SH);
+
+               $cache = '';
+               if (filesize($filepath) > 0)
+               {
+                       $cache = fread($fp, filesize($filepath));
+               }
+
+               flock($fp, LOCK_UN);
+               fclose($fp);
+
+               // Strip out the embedded timestamp
+               if ( ! preg_match("/(\d+TS--->)/", $cache, $match))
+               {
+                       return FALSE;
+               }
+
+               // Has the file expired? If so we'll delete it.
+               if (time() >= trim(str_replace('TS--->', '', $match['1'])))
+               {
+                       if (is_really_writable($cache_path))
+                       {
+                               @unlink($filepath);
+                               log_message('debug', "Cache file has expired. File deleted");
+                               return FALSE;
+                       }
+               }
+
+               // Display the cache
+               $this->_display(str_replace($match['0'], '', $cache));
+               log_message('debug', "Cache file is current. Sending it to browser.");
+               return TRUE;
+       }
+
+
+}
+// END Output Class
+
+/* End of file Output.php */
+/* Location: ./system/core/Output.php */
\ No newline at end of file
diff --git a/system/core/Router.php b/system/core/Router.php
new file mode 100755 (executable)
index 0000000..d451aab
--- /dev/null
@@ -0,0 +1,467 @@
+<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+/**
+ * CodeIgniter
+ *
+ * An open source application development framework for PHP 5.1.6 or newer
+ *
+ * @package            CodeIgniter
+ * @author             ExpressionEngine Dev Team
+ * @copyright  Copyright (c) 2008 - 2011, EllisLab, Inc.
+ * @license            http://codeigniter.com/user_guide/license.html
+ * @link               http://codeigniter.com
+ * @since              Version 1.0
+ * @filesource
+ */
+
+// ------------------------------------------------------------------------
+
+/**
+ * Router Class
+ *
+ * Parses URIs and determines routing
+ *
+ * @package            CodeIgniter
+ * @subpackage Libraries
+ * @author             ExpressionEngine Dev Team
+ * @category   Libraries
+ * @link               http://codeigniter.com/user_guide/general/routing.html
+ */
+class CI_Router {
+
+       var $config;
+       var $routes                     = array();
+       var $error_routes       = array();
+       var $class                      = '';
+       var $method                     = 'index';
+       var $directory          = '';
+       var $default_controller;
+
+       /**
+        * Constructor
+        *
+        * Runs the route mapping function.
+        */
+       function __construct()
+       {
+               $this->config =& load_class('Config', 'core');
+               $this->uri =& load_class('URI', 'core');
+               log_message('debug', "Router Class Initialized");
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Set the route mapping
+        *
+        * This function determines what should be served based on the URI request,
+        * as well as any "routes" that have been set in the routing config file.
+        *
+        * @access      private
+        * @return      void
+        */
+       function _set_routing()
+       {
+               // Are query strings enabled in the config file?  Normally CI doesn't utilize query strings
+               // since URI segments are more search-engine friendly, but they can optionally be used.
+               // If this feature is enabled, we will gather the directory/class/method a little differently
+               $segments = array();
+               if ($this->config->item('enable_query_strings') === TRUE AND isset($_GET[$this->config->item('controller_trigger')]))
+               {
+                       if (isset($_GET[$this->config->item('directory_trigger')]))
+                       {
+                               $this->set_directory(trim($this->uri->_filter_uri($_GET[$this->config->item('directory_trigger')])));
+                               $segments[] = $this->fetch_directory();
+                       }
+
+                       if (isset($_GET[$this->config->item('controller_trigger')]))
+                       {
+                               $this->set_class(trim($this->uri->_filter_uri($_GET[$this->config->item('controller_trigger')])));
+                               $segments[] = $this->fetch_class();
+                       }
+
+                       if (isset($_GET[$this->config->item('function_trigger')]))
+                       {
+                               $this->set_method(trim($this->uri->_filter_uri($_GET[$this->config->item('function_trigger')])));
+                               $segments[] = $this->fetch_method();
+                       }
+               }
+
+               // Load the routes.php file.
+               if (defined('ENVIRONMENT') AND is_file(APPPATH.'config/'.ENVIRONMENT.'/routes'.EXT))
+               {
+                       include(APPPATH.'config/'.ENVIRONMENT.'/routes'.EXT);
+               }
+               elseif (is_file(APPPATH.'config/routes'.EXT))
+               {
+                       include(APPPATH.'config/routes'.EXT);
+               }
+               
+               $this->routes = ( ! isset($route) OR ! is_array($route)) ? array() : $route;
+               unset($route);
+
+               // Set the default controller so we can display it in the event
+               // the URI doesn't correlated to a valid controller.
+               $this->default_controller = ( ! isset($this->routes['default_controller']) OR $this->routes['default_controller'] == '') ? FALSE : strtolower($this->routes['default_controller']);
+
+               // Were there any query string segments?  If so, we'll validate them and bail out since we're done.
+               if (count($segments) > 0)
+               {
+                       return $this->_validate_request($segments);
+               }
+
+               // Fetch the complete URI string
+               $this->uri->_fetch_uri_string();
+
+               // Is there a URI string? If not, the default controller specified in the "routes" file will be shown.
+               if ($this->uri->uri_string == '')
+               {
+                       return $this->_set_default_controller();
+               }
+
+               // Do we need to remove the URL suffix?
+               $this->uri->_remove_url_suffix();
+
+               // Compile the segments into an array
+               $this->uri->_explode_segments();
+
+               // Parse any custom routing that may exist
+               $this->_parse_routes();
+
+               // Re-index the segment array so that it starts with 1 rather than 0
+               $this->uri->_reindex_segments();
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Set the default controller
+        *
+        * @access      private
+        * @return      void
+        */
+       function _set_default_controller()
+       {
+               if ($this->default_controller === FALSE)
+               {
+                       show_error("Unable to determine what should be displayed. A default route has not been specified in the routing file.");
+               }
+               // Is the method being specified?
+               if (strpos($this->default_controller, '/') !== FALSE)
+               {
+                       $x = explode('/', $this->default_controller);
+
+                       $this->set_class($x[0]);
+                       $this->set_method($x[1]);
+                       $this->_set_request($x);
+               }
+               else
+               {
+                       $this->set_class($this->default_controller);
+                       $this->set_method('index');
+                       $this->_set_request(array($this->default_controller, 'index'));
+               }
+
+               // re-index the routed segments array so it starts with 1 rather than 0
+               $this->uri->_reindex_segments();
+
+               log_message('debug', "No URI present. Default controller set.");
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Set the Route
+        *
+        * This function takes an array of URI segments as
+        * input, and sets the current class/method
+        *
+        * @access      private
+        * @param       array
+        * @param       bool
+        * @return      void
+        */
+       function _set_request($segments = array())
+       {
+               $segments = $this->_validate_request($segments);
+
+               if (count($segments) == 0)
+               {
+                       return $this->_set_default_controller();
+               }
+
+               $this->set_class($segments[0]);
+
+               if (isset($segments[1]))
+               {
+                       // A standard method request
+                       $this->set_method($segments[1]);
+               }
+               else
+               {
+                       // This lets the "routed" segment array identify that the default
+                       // index method is being used.
+                       $segments[1] = 'index';
+               }
+
+               // Update our "routed" segment array to contain the segments.
+               // Note: If there is no custom routing, this array will be
+               // identical to $this->uri->segments
+               $this->uri->rsegments = $segments;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Validates the supplied segments.  Attempts to determine the path to
+        * the controller.
+        *
+        * @access      private
+        * @param       array
+        * @return      array
+        */
+       function _validate_request($segments)
+       {
+               if (count($segments) == 0)
+               {
+                       return $segments;
+               }
+
+               // Does the requested controller exist in the root folder?
+               if (file_exists(APPPATH.'controllers/'.$segments[0].EXT))
+               {
+                       return $segments;
+               }
+
+               // Is the controller in a sub-folder?
+               if (is_dir(APPPATH.'controllers/'.$segments[0]))
+               {
+                       // Set the directory and remove it from the segment array
+                       $this->set_directory($segments[0]);
+                       $segments = array_slice($segments, 1);
+
+                       if (count($segments) > 0)
+                       {
+                               // Does the requested controller exist in the sub-folder?
+                               if ( ! file_exists(APPPATH.'controllers/'.$this->fetch_directory().$segments[0].EXT))
+                               {
+                                       show_404($this->fetch_directory().$segments[0]);
+                               }
+                       }
+                       else
+                       {
+                               // Is the method being specified in the route?
+                               if (strpos($this->default_controller, '/') !== FALSE)
+                               {
+                                       $x = explode('/', $this->default_controller);
+
+                                       $this->set_class($x[0]);
+                                       $this->set_method($x[1]);
+                               }
+                               else
+                               {
+                                       $this->set_class($this->default_controller);
+                                       $this->set_method('index');
+                               }
+
+                               // Does the default controller exist in the sub-folder?
+                               if ( ! file_exists(APPPATH.'controllers/'.$this->fetch_directory().$this->default_controller.EXT))
+                               {
+                                       $this->directory = '';
+                                       return array();
+                               }
+
+                       }
+
+                       return $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']))
+               {
+                       $x = explode('/', $this->routes['404_override']);
+
+                       $this->set_class($x[0]);
+                       $this->set_method(isset($x[1]) ? $x[1] : 'index');
+
+                       return $x;
+               }
+
+
+               // Nothing else to do at this point but show a 404
+               show_404($segments[0]);
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        *  Parse Routes
+        *
+        * This function matches any routes that may exist in
+        * the config/routes.php file against the URI to
+        * determine if the class/method need to be remapped.
+        *
+        * @access      private
+        * @return      void
+        */
+       function _parse_routes()
+       {
+               // Turn the segment array into a URI string
+               $uri = implode('/', $this->uri->segments);
+
+               // Is there a literal match?  If so we're done
+               if (isset($this->routes[$uri]))
+               {
+                       return $this->_set_request(explode('/', $this->routes[$uri]));
+               }
+
+               // Loop through the route array looking for wild-cards
+               foreach ($this->routes as $key => $val)
+               {
+                       // Convert wild-cards to RegEx
+                       $key = str_replace(':any', '.+', str_replace(':num', '[0-9]+', $key));
+
+                       // Does the RegEx match?
+                       if (preg_match('#^'.$key.'$#', $uri))
+                       {
+                               // Do we have a back-reference?
+                               if (strpos($val, '$') !== FALSE AND strpos($key, '(') !== FALSE)
+                               {
+                                       $val = preg_replace('#^'.$key.'$#', $val, $uri);
+                               }
+
+                               return $this->_set_request(explode('/', $val));
+                       }
+               }
+
+               // If we got this far it means we didn't encounter a
+               // matching route so we'll set the site default route
+               $this->_set_request($this->uri->segments);
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Set the class name
+        *
+        * @access      public
+        * @param       string
+        * @return      void
+        */
+       function set_class($class)
+       {
+               $this->class = str_replace(array('/', '.'), '', $class);
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Fetch the current class
+        *
+        * @access      public
+        * @return      string
+        */
+       function fetch_class()
+       {
+               return $this->class;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        *  Set the method name
+        *
+        * @access      public
+        * @param       string
+        * @return      void
+        */
+       function set_method($method)
+       {
+               $this->method = $method;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        *  Fetch the current method
+        *
+        * @access      public
+        * @return      string
+        */
+       function fetch_method()
+       {
+               if ($this->method == $this->fetch_class())
+               {
+                       return 'index';
+               }
+
+               return $this->method;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        *  Set the directory name
+        *
+        * @access      public
+        * @param       string
+        * @return      void
+        */
+       function set_directory($dir)
+       {
+               $this->directory = str_replace(array('/', '.'), '', $dir).'/';
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        *  Fetch the sub-directory (if any) that contains the requested controller class
+        *
+        * @access      public
+        * @return      string
+        */
+       function fetch_directory()
+       {
+               return $this->directory;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        *  Set the controller overrides
+        *
+        * @access      public
+        * @param       array
+        * @return      null
+        */
+       function _set_overrides($routing)
+       {
+               if ( ! is_array($routing))
+               {
+                       return;
+               }
+
+               if (isset($routing['directory']))
+               {
+                       $this->set_directory($routing['directory']);
+               }
+
+               if (isset($routing['controller']) AND $routing['controller'] != '')
+               {
+                       $this->set_class($routing['controller']);
+               }
+
+               if (isset($routing['function']))
+               {
+                       $routing['function'] = ($routing['function'] == '') ? 'index' : $routing['function'];
+                       $this->set_method($routing['function']);
+               }
+       }
+
+
+}
+// END Router Class
+
+/* End of file Router.php */
+/* Location: ./system/core/Router.php */
\ No newline at end of file
diff --git a/system/core/Security.php b/system/core/Security.php
new file mode 100755 (executable)
index 0000000..ceef977
--- /dev/null
@@ -0,0 +1,820 @@
+<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+/**
+ * CodeIgniter
+ *
+ * An open source application development framework for PHP 5.1.6 or newer
+ *
+ * @package            CodeIgniter
+ * @author             ExpressionEngine Dev Team
+ * @copyright  Copyright (c) 2008 - 2011, EllisLab, Inc.
+ * @license            http://codeigniter.com/user_guide/license.html
+ * @link               http://codeigniter.com
+ * @since              Version 1.0
+ * @filesource
+ */
+
+// ------------------------------------------------------------------------
+
+/**
+ * Security Class
+ *
+ * @package            CodeIgniter
+ * @subpackage Libraries
+ * @category   Security
+ * @author             ExpressionEngine Dev Team
+ * @link               http://codeigniter.com/user_guide/libraries/security.html
+ */
+class CI_Security {
+       
+       protected $_xss_hash                    = '';
+       protected $_csrf_hash                   = '';
+       protected $_csrf_expire                 = 7200;  // Two hours (in seconds)
+       protected $_csrf_token_name             = 'ci_csrf_token';
+       protected $_csrf_cookie_name    = 'ci_csrf_token';
+
+       /* never allowed, string replacement */
+       protected $_never_allowed_str = array(
+                                       'document.cookie'       => '[removed]',
+                                       'document.write'        => '[removed]',
+                                       '.parentNode'           => '[removed]',
+                                       '.innerHTML'            => '[removed]',
+                                       'window.location'       => '[removed]',
+                                       '-moz-binding'          => '[removed]',
+                                       '<!--'                          => '&lt;!--',
+                                       '-->'                           => '--&gt;',
+                                       '<![CDATA['                     => '&lt;![CDATA['
+       );
+
+       /* never allowed, regex replacement */
+       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;
+
+               // Set the CSRF hash
+               $this->_csrf_set_hash();
+
+               log_message('debug', "Security Class Initialized");
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Verify Cross Site Request Forgery Protection
+        *
+        * @return      object
+        */
+       public function csrf_verify()
+       {
+               // If no POST data exists we will set the CSRF cookie
+               if (count($_POST) == 0)
+               {
+                       return $this->csrf_set_cookie();
+               }
+
+               // 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]))
+               {
+                       $this->csrf_show_error();
+               }
+
+               // Do the tokens match?
+               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]);
+
+               // Nothing should last forever
+               unset($_COOKIE[$this->_csrf_cookie_name]);
+               $this->_csrf_set_hash();
+               $this->csrf_set_cookie();
+
+               log_message('debug', "CSRF token verified ");
+               
+               return $this;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Set Cross Site Request Forgery Protection Cookie
+        *
+        * @return      object
+        */
+       public function csrf_set_cookie()
+       {
+               $expire = time() + $this->_csrf_expire;
+               $secure_cookie = (config_item('cookie_secure') === TRUE) ? 1 : 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;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Show CSRF Error
+        *
+        * @return      void
+        */
+       public function csrf_show_error()
+       {
+               show_error('The action you have requested is not allowed.');
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Get CSRF Hash 
+        *
+        * Getter Method 
+        *
+        * @return      string  self::_csrf_hash
+        */
+       public function get_csrf_hash()
+       {
+               return $this->_csrf_hash;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Get CSRF Token Name
+        *
+        * Getter Method
+        *
+        * @return      string  self::csrf_token_name
+        */
+       public function get_csrf_token_name()
+       {
+               return $this->_csrf_token_name;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * XSS Clean
+        *
+        * Sanitizes data so that Cross Site Scripting Hacks can be
+        * prevented.  This function does a fair amount of work but
+        * it is extremely thorough, designed to prevent even the
+        * most obscure XSS attempts.  Nothing is ever 100% foolproof,
+        * of course, but I haven't been able to get anything passed
+        * the filter.
+        *
+        * Note: This function should only be used to deal with data
+        * upon submission.  It's not something that should
+        * be used for general runtime processing.
+        *
+        * This function was based in part on some code and ideas I
+        * got from Bitflux: http://channel.bitflux.ch/wiki/XSS_Prevention
+        *
+        * To help develop this script I used this great list of
+        * vulnerabilities along with a few other hacks I've
+        * harvested from examining vulnerabilities in other programs:
+        * http://ha.ckers.org/xss.html
+        *
+        * @param       mixed   string or array
+        * @return      string
+        */
+       public function xss_clean($str, $is_image = FALSE)
+       {
+               /*
+                * Is the string an array?
+                *
+                */
+               if (is_array($str))
+               {
+                       while (list($key) = each($str))
+                       {
+                               $str[$key] = $this->xss_clean($str[$key]);
+                       }
+
+                       return $str;
+               }
+
+               /*
+                * Remove Invisible Characters
+                */
+               $str = remove_invisible_characters($str);
+
+               // Validate Entities in URLs
+               $str = $this->_validate_entities($str);
+
+               /*
+                * URL Decode
+                *
+                * Just in case stuff like this is submitted:
+                *
+                * <a href="http://%77%77%77%2E%67%6F%6F%67%6C%65%2E%63%6F%6D">Google</a>
+                *
+                * Note: Use rawurldecode() so it does not remove plus signs
+                *
+                */
+               $str = rawurldecode($str);
+
+               /*
+                * Convert character entities to ASCII
+                *
+                * This permits our tests below to work reliably.
+                * We only convert entities that are within tags since
+                * these are the ones that will pose security problems.
+                *
+                */
+
+               $str = preg_replace_callback("/[a-z]+=([\'\"]).*?\\1/si", array($this, '_convert_attribute'), $str);
+       
+               $str = preg_replace_callback("/<\w+.*?(?=>|<|$)/si", array($this, '_decode_entity'), $str);
+
+               /*
+                * Remove Invisible Characters Again!
+                */
+               $str = remove_invisible_characters($str);
+
+               /*
+                * Convert all tabs to spaces
+                *
+                * 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.
+                */
+
+               if (strpos($str, "\t") !== FALSE)
+               {
+                       $str = str_replace("\t", ' ', $str);
+               }
+
+               /*
+                * Capture converted string for later comparison
+                */
+               $converted_string = $str;
+
+               // Remove Strings that are never allowed
+               $str = $this->_do_never_allowed($str);
+
+               /*
+                * Makes PHP tags safe
+                *
+                * Note: XML tags are inadvertently replaced too:
+                *
+                * <?xml
+                *
+                * But it doesn't seem to pose a problem.
+                */
+               if ($is_image === TRUE)
+               {
+                       // Images have a tendency to have the PHP short opening and 
+                       // closing tags every so often so we skip those and only 
+                       // do the long opening tags.
+                       $str = preg_replace('/<\?(php)/i', "&lt;?\\1", $str);
+               }
+               else
+               {
+                       $str = str_replace(array('<?', '?'.'>'),  array('&lt;?', '?&gt;'), $str);
+               }
+
+               /*
+                * Compact any exploded words
+                *
+                * This corrects words like:  j a v a s c r i p t
+                * These words are compacted back to their correct state.
+                */
+               $words = array(
+                               'javascript', 'expression', 'vbscript', 'script', 
+                               'applet', 'alert', 'document', 'write', 'cookie', 'window'
+                       );
+                       
+               foreach ($words as $word)
+               {
+                       $temp = '';
+
+                       for ($i = 0, $wordlen = strlen($word); $i < $wordlen; $i++)
+                       {
+                               $temp .= substr($word, $i, 1)."\s*";
+                       }
+
+                       // We only want to do this when it is followed by a non-word character
+                       // That way valid stuff like "dealer to" does not become "dealerto"
+                       $str = preg_replace_callback('#('.substr($temp, 0, -3).')(\W)#is', array($this, '_compact_exploded_words'), $str);
+               }
+
+               /*
+                * Remove disallowed Javascript in links or img tags
+                * We used to do some version comparisons and use of stripos for PHP5, 
+                * but it is dog slow compared to these simplified non-capturing 
+                * preg_match(), especially if the pattern exists in the string
+                */
+               do
+               {
+                       $original = $str;
+
+                       if (preg_match("/<a/i", $str))
+                       {
+                               $str = preg_replace_callback("#<a\s+([^>]*?)(>|$)#si", array($this, '_js_link_removal'), $str);
+                       }
+
+                       if (preg_match("/<img/i", $str))
+                       {
+                               $str = preg_replace_callback("#<img\s+([^>]*?)(\s?/?>|$)#si", array($this, '_js_img_removal'), $str);
+                       }
+
+                       if (preg_match("/script/i", $str) OR preg_match("/xss/i", $str))
+                       {
+                               $str = preg_replace("#<(/*)(script|xss)(.*?)\>#si", '[removed]', $str);
+                       }
+               }
+               while($original != $str);
+
+               unset($original);
+
+               // Remove evil attributes such as style, onclick and xmlns
+               $str = $this->_remove_evil_attributes($str, $is_image);
+
+               /*
+                * Sanitize naughty HTML elements
+                *
+                * If a tag containing any of the words in the list
+                * below is found, the tag gets converted to entities.
+                *
+                * So this: <blink>
+                * Becomes: &lt;blink&gt;
+                */
+               $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);
+
+               /*
+                * Sanitize naughty scripting elements
+                *
+                * Similar to above, only instead of looking for
+                * tags it looks for PHP and JavaScript commands
+                * that are disallowed.  Rather than removing the
+                * code, it simply converts the parenthesis to entities
+                * rendering the code un-executable.
+                *
+                * For example: eval('some code')
+                * Becomes:             eval&#40;'some code'&#41;
+                */
+               $str = preg_replace('#(alert|cmd|passthru|eval|exec|expression|system|fopen|fsockopen|file|file_get_contents|readfile|unlink)(\s*)\((.*?)\)#si', "\\1\\2&#40;\\3&#41;", $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.
+                */
+
+               if ($is_image === TRUE)
+               {
+                       return ($str == $converted_string) ? TRUE: FALSE;
+               }
+
+               log_message('debug', "XSS Filtering completed");
+               return $str;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Random Hash for protecting URLs
+        *
+        * @return      string
+        */
+       public function 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.
+
+               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 $str;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Filename Security
+        *
+        * @param       string
+        * @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
+        *
+        * @param       type
+        * @return      type
+        */
+       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:
+        *              <a |style=document.write('hello');alert('world');| class=link>
+        *      - Everything inside the quotes 
+        *              For example, everything between the pipes:
+        *              <a |style="document.write('hello'); alert('world');"| class="link">
+        *
+        * @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
+        *
+        * @param       array
+        * @return      string
+        */
+       protected function _sanitize_naughty_html($matches)
+       {
+               // encode opening brace
+               $str = '&lt;'.$matches[1].$matches[2].$matches[3];
+
+               // encode captured opening or closing brace to prevent recursive vectors
+               $str .= str_replace(array('>', '<'), array('&gt;', '&lt;'), 
+                                                       $matches[4]);
+
+               return $str;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * JS Link Removal
+        *
+        * Callback function for xss_clean() to sanitize links
+        * This limits the PCRE backtracks, making it more performance friendly
+        * and prevents PREG_BACKTRACK_LIMIT_ERROR from being triggered in
+        * PHP 5.2+ on link-heavy strings
+        *
+        * @param       array
+        * @return      string
+        */
+       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\:|livescript\:|mocha\:|charset\=|window\.|document\.|\.cookie|<script|<xss|base64\s*,)#si", "", $attributes), $match[0]);
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * JS Image Removal
+        *
+        * Callback function for xss_clean() to sanitize image tags
+        * This limits the PCRE backtracks, making it more performance friendly
+        * and prevents PREG_BACKTRACK_LIMIT_ERROR from being triggered in
+        * PHP 5.2+ on image tag heavy strings
+        *
+        * @param       array
+        * @return      string
+        */
+       protected function _js_img_removal($match)
+       {
+               $attributes = $this->_filter_attributes(str_replace(array('<', '>'), '', $match[1]));
+               
+               return str_replace($match[1], preg_replace("#src=.*?(alert\(|alert&\#40;|javascript\:|livescript\:|mocha\:|charset\=|window\.|document\.|\.cookie|<script|<xss|base64\s*,)#si", "", $attributes), $match[0]);
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Attribute Conversion
+        *
+        * Used as a callback for XSS Clean
+        *
+        * @param       array
+        * @return      string
+        */
+       protected function _convert_attribute($match)
+       {
+               return str_replace(array('>', '<', '\\'), array('&gt;', '&lt;', '\\\\'), $match[0]);
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Filter Attributes
+        *
+        * Filters tag attributes for consistency and safety
+        *
+        * @param       string
+        * @return      string
+        */
+       protected function _filter_attributes($str)
+       {
+               $out = '';
+
+               if (preg_match_all('#\s*[a-z\-]+\s*=\s*(\042|\047)([^\\1]*?)\\1#is', $str, $matches))
+               {
+                       foreach ($matches[0] as $match)
+                       {
+                               $out .= preg_replace("#/\*.*?\*/#s", '', $match);
+                       }
+               }
+
+               return $out;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * HTML Entity Decode Callback
+        *
+        * Used as a callback for XSS Clean
+        *
+        * @param       array
+        * @return      string
+        */
+       protected function _decode_entity($match)
+       {
+               return $this->entity_decode($match[0], strtoupper(config_item('charset')));
+       }
+
+       // --------------------------------------------------------------------
+       
+       /**
+        * Validate URL entities
+        *
+        * Called by xss_clean()
+        *
+        * @param       string  
+        * @return      string
+        */
+       protected function _validate_entities($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);
+               
+               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 = str_replace($key, $val, $str);
+               }
+
+               foreach ($this->_never_allowed_regex as $key => $val)
+               {
+                       $str = preg_replace("#".$key."#i", $val, $str);
+               }
+               
+               return $str;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Set Cross Site Request Forgery Protection Cookie
+        *
+        * @return      string
+        */
+       protected function _csrf_set_hash()
+       {
+               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]) && 
+                               $_COOKIE[$this->_csrf_cookie_name] != '')
+                       {
+                               return $this->_csrf_hash = $_COOKIE[$this->_csrf_cookie_name];
+                       }
+                       
+                       return $this->_csrf_hash = md5(uniqid(rand(), TRUE));
+               }
+
+               return $this->_csrf_hash;
+       }
+
+}
+// END Security Class
+
+/* End of file Security.php */
+/* Location: ./system/libraries/Security.php */
\ No newline at end of file
diff --git a/system/core/URI.php b/system/core/URI.php
new file mode 100755 (executable)
index 0000000..80dc62e
--- /dev/null
@@ -0,0 +1,623 @@
+<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+/**
+ * CodeIgniter
+ *
+ * An open source application development framework for PHP 5.1.6 or newer
+ *
+ * @package            CodeIgniter
+ * @author             ExpressionEngine Dev Team
+ * @copyright  Copyright (c) 2008 - 2011, EllisLab, Inc.
+ * @license            http://codeigniter.com/user_guide/license.html
+ * @link               http://codeigniter.com
+ * @since              Version 1.0
+ * @filesource
+ */
+
+// ------------------------------------------------------------------------
+
+/**
+ * URI Class
+ *
+ * Parses URIs and determines routing
+ *
+ * @package            CodeIgniter
+ * @subpackage Libraries
+ * @category   URI
+ * @author             ExpressionEngine Dev Team
+ * @link               http://codeigniter.com/user_guide/libraries/uri.html
+ */
+class CI_URI {
+
+       var     $keyval                 = array();
+       var $uri_string;
+       var $segments           = array();
+       var $rsegments          = array();
+
+       /**
+        * Constructor
+        *
+        * Simply globalizes the $RTR object.  The front
+        * loads the Router class early on so it's not available
+        * normally as other classes are.
+        *
+        * @access      public
+        */
+       function __construct()
+       {
+               $this->config =& load_class('Config', 'core');
+               log_message('debug', "URI Class Initialized");
+       }
+
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Get the URI String
+        *
+        * @access      private
+        * @return      string
+        */
+       function _fetch_uri_string()
+       {
+               if (strtoupper($this->config->item('uri_protocol')) == 'AUTO')
+               {
+                       // Is the request coming from the command line?
+                       if (defined('STDIN'))
+                       {
+                               $this->_set_uri_string($this->_parse_cli_args());
+                               return;
+                       }
+
+                       // Let's try the REQUEST_URI first, this will work in most situations
+                       if ($uri = $this->_detect_uri())
+                       {
+                               $this->_set_uri_string($uri);
+                               return;
+                       }
+
+                       // Is there a PATH_INFO variable?
+                       // Note: some servers seem to have trouble with getenv() so we'll test it two ways
+                       $path = (isset($_SERVER['PATH_INFO'])) ? $_SERVER['PATH_INFO'] : @getenv('PATH_INFO');
+                       if (trim($path, '/') != '' && $path != "/".SELF)
+                       {
+                               $this->_set_uri_string($path);
+                               return;
+                       }
+
+                       // No PATH_INFO?... What about QUERY_STRING?
+                       $path =  (isset($_SERVER['QUERY_STRING'])) ? $_SERVER['QUERY_STRING'] : @getenv('QUERY_STRING');
+                       if (trim($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->_set_uri_string(key($_GET));
+                               return;
+                       }
+
+                       // We've exhausted all our options...
+                       $this->uri_string = '';
+                       return;
+               }
+
+               $uri = strtoupper($this->config->item('uri_protocol'));
+
+               if ($uri == 'REQUEST_URI')
+               {
+                       $this->_set_uri_string($this->_detect_uri());
+                       return;
+               }
+               elseif ($uri == 'CLI')
+               {
+                       $this->_set_uri_string($this->_parse_cli_args());
+                       return;
+               }
+
+               $path = (isset($_SERVER[$uri])) ? $_SERVER[$uri] : @getenv($uri);
+               $this->_set_uri_string($path);
+       }
+       
+       // --------------------------------------------------------------------
+
+       /**
+        * Set the URI String
+        *
+        * @access      public
+        * @return      string
+        */
+       function _set_uri_string($str)
+       {
+               // Filter out control characters
+               $str = remove_invisible_characters($str, FALSE);
+               
+               // If the URI contains only a slash we'll kill it
+               $this->uri_string = ($str == '/') ? '' : $str;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Detects the URI
+        *
+        * This function will detect the URI automatically and fix the query string
+        * if necessary.
+        *
+        * @access      private
+        * @return      string
+        */
+       private function _detect_uri()
+       {
+               if ( ! isset($_SERVER['REQUEST_URI']))
+               {
+                       return '';
+               }
+
+               $uri = $_SERVER['REQUEST_URI'];
+               if (strpos($uri, $_SERVER['SCRIPT_NAME']) === 0)
+               {
+                       $uri = substr($uri, strlen($_SERVER['SCRIPT_NAME']));
+               }
+               elseif (strpos($uri, dirname($_SERVER['SCRIPT_NAME'])) === 0)
+               {
+                       $uri = substr($uri, strlen(dirname($_SERVER['SCRIPT_NAME'])));
+               }
+
+               // 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)
+               {
+                       $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);
+               }
+               else
+               {
+                       $_SERVER['QUERY_STRING'] = '';
+                       $_GET = array();
+               }
+               
+               if ($uri == '/' || empty($uri))
+               {
+                       return '/';
+               }
+                               
+               $uri = parse_url($uri, PHP_URL_PATH);
+
+               // Do some final cleaning of the URI and return it
+               return str_replace(array('//', '../'), '/', trim($uri, '/'));
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Parse cli arguments
+        *
+        * Take each command line argument and assume it is a URI segment.
+        *
+        * @access      private
+        * @return      string
+        */
+       private function _parse_cli_args()
+       {
+               $args = array_slice($_SERVER['argv'], 1);
+
+               return $args ? '/' . implode('/', $args) : '';
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Filter segments for malicious characters
+        *
+        * @access      private
+        * @param       string
+        * @return      string
+        */
+       function _filter_uri($str)
+       {
+               if ($str != '' && $this->config->item('permitted_uri_chars') != '' && $this->config->item('enable_query_strings') == FALSE)
+               {
+                       // preg_quote() in PHP 5.3 escapes -, so the str_replace() and addition of - to preg_quote() is to maintain backwards
+                       // compatibility as many are unaware of how characters in the permitted_uri_chars will be parsed as a regex pattern
+                       if ( ! preg_match("|^[".str_replace(array('\\-', '\-'), '-', preg_quote($this->config->item('permitted_uri_chars'), '-'))."]+$|i", $str))
+                       {
+                               show_error('The URI you submitted has disallowed characters.', 400);
+                       }
+               }
+
+               // Convert programatic characters to entities
+               $bad    = array('$',            '(',            ')',            '%28',          '%29');
+               $good   = array('&#36;',        '&#40;',        '&#41;',        '&#40;',        '&#41;');
+
+               return str_replace($bad, $good, $str);
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Remove the suffix from the URL if needed
+        *
+        * @access      private
+        * @return      void
+        */
+       function _remove_url_suffix()
+       {
+               if  ($this->config->item('url_suffix') != "")
+               {
+                       $this->uri_string = preg_replace("|".preg_quote($this->config->item('url_suffix'))."$|", "", $this->uri_string);
+               }
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Explode the URI Segments. The individual segments will
+        * be stored in the $this->segments array.
+        *
+        * @access      private
+        * @return      void
+        */
+       function _explode_segments()
+       {
+               foreach (explode("/", preg_replace("|/*(.+?)/*$|", "\\1", $this->uri_string)) as $val)
+               {
+                       // Filter segments for security
+                       $val = trim($this->_filter_uri($val));
+
+                       if ($val != '')
+                       {
+                               $this->segments[] = $val;
+                       }
+               }
+       }
+
+       // --------------------------------------------------------------------
+       /**
+        * Re-index Segments
+        *
+        * This function re-indexes the $this->segment array so that it
+        * starts at 1 rather than 0.  Doing so makes it simpler to
+        * use functions like $this->uri->segment(n) since there is
+        * a 1:1 relationship between the segment array and the actual segments.
+        *
+        * @access      private
+        * @return      void
+        */
+       function _reindex_segments()
+       {
+               array_unshift($this->segments, NULL);
+               array_unshift($this->rsegments, NULL);
+               unset($this->segments[0]);
+               unset($this->rsegments[0]);
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Fetch a URI Segment
+        *
+        * This function returns the URI segment based on the number provided.
+        *
+        * @access      public
+        * @param       integer
+        * @param       bool
+        * @return      string
+        */
+       function segment($n, $no_result = FALSE)
+       {
+               return ( ! isset($this->segments[$n])) ? $no_result : $this->segments[$n];
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Fetch a URI "routed" Segment
+        *
+        * This function returns the re-routed URI segment (assuming routing rules are used)
+        * based on the number provided.  If there is no routing this function returns the
+        * same result as $this->segment()
+        *
+        * @access      public
+        * @param       integer
+        * @param       bool
+        * @return      string
+        */
+       function rsegment($n, $no_result = FALSE)
+       {
+               return ( ! isset($this->rsegments[$n])) ? $no_result : $this->rsegments[$n];
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Generate a key value pair from the URI string
+        *
+        * This function generates and associative array of URI data starting
+        * at the supplied segment. For example, if this is your URI:
+        *
+        *      example.com/user/search/name/joe/location/UK/gender/male
+        *
+        * You can use this function to generate an array with this prototype:
+        *
+        * array (
+        *                      name => joe
+        *                      location => UK
+        *                      gender => male
+        *               )
+        *
+        * @access      public
+        * @param       integer the starting segment number
+        * @param       array   an array of default values
+        * @return      array
+        */
+       function uri_to_assoc($n = 3, $default = array())
+       {
+               return $this->_uri_to_assoc($n, $default, 'segment');
+       }
+       /**
+        * Identical to above only it uses the re-routed segment array
+        *
+        */
+       function ruri_to_assoc($n = 3, $default = array())
+       {
+               return $this->_uri_to_assoc($n, $default, 'rsegment');
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Generate a key value pair from the URI string or Re-routed URI string
+        *
+        * @access      private
+        * @param       integer the starting segment number
+        * @param       array   an array of default values
+        * @param       string  which array we should use
+        * @return      array
+        */
+       function _uri_to_assoc($n = 3, $default = array(), $which = 'segment')
+       {
+               if ($which == 'segment')
+               {
+                       $total_segments = 'total_segments';
+                       $segment_array = 'segment_array';
+               }
+               else
+               {
+                       $total_segments = 'total_rsegments';
+                       $segment_array = 'rsegment_array';
+               }
+
+               if ( ! is_numeric($n))
+               {
+                       return $default;
+               }
+
+               if (isset($this->keyval[$n]))
+               {
+                       return $this->keyval[$n];
+               }
+
+               if ($this->$total_segments() < $n)
+               {
+                       if (count($default) == 0)
+                       {
+                               return array();
+                       }
+
+                       $retval = array();
+                       foreach ($default as $val)
+                       {
+                               $retval[$val] = FALSE;
+                       }
+                       return $retval;
+               }
+
+               $segments = array_slice($this->$segment_array(), ($n - 1));
+
+               $i = 0;
+               $lastval = '';
+               $retval  = array();
+               foreach ($segments as $seg)
+               {
+                       if ($i % 2)
+                       {
+                               $retval[$lastval] = $seg;
+                       }
+                       else
+                       {
+                               $retval[$seg] = FALSE;
+                               $lastval = $seg;
+                       }
+
+                       $i++;
+               }
+
+               if (count($default) > 0)
+               {
+                       foreach ($default as $val)
+                       {
+                               if ( ! array_key_exists($val, $retval))
+                               {
+                                       $retval[$val] = FALSE;
+                               }
+                       }
+               }
+
+               // Cache the array for reuse
+               $this->keyval[$n] = $retval;
+               return $retval;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Generate a URI string from an associative array
+        *
+        *
+        * @access      public
+        * @param       array   an associative array of key/values
+        * @return      array
+        */
+       function assoc_to_uri($array)
+       {
+               $temp = array();
+               foreach ((array)$array as $key => $val)
+               {
+                       $temp[] = $key;
+                       $temp[] = $val;
+               }
+
+               return implode('/', $temp);
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Fetch a URI Segment and add a trailing slash
+        *
+        * @access      public
+        * @param       integer
+        * @param       string
+        * @return      string
+        */
+       function slash_segment($n, $where = 'trailing')
+       {
+               return $this->_slash_segment($n, $where, 'segment');
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Fetch a URI Segment and add a trailing slash
+        *
+        * @access      public
+        * @param       integer
+        * @param       string
+        * @return      string
+        */
+       function slash_rsegment($n, $where = 'trailing')
+       {
+               return $this->_slash_segment($n, $where, 'rsegment');
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Fetch a URI Segment and add a trailing slash - helper function
+        *
+        * @access      private
+        * @param       integer
+        * @param       string
+        * @param       string
+        * @return      string
+        */
+       function _slash_segment($n, $where = 'trailing', $which = 'segment')
+       {
+               $leading        = '/';
+               $trailing       = '/';
+
+               if ($where == 'trailing')
+               {
+                       $leading        = '';
+               }
+               elseif ($where == 'leading')
+               {
+                       $trailing       = '';
+               }
+
+               return $leading.$this->$which($n).$trailing;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Segment Array
+        *
+        * @access      public
+        * @return      array
+        */
+       function segment_array()
+       {
+               return $this->segments;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Routed Segment Array
+        *
+        * @access      public
+        * @return      array
+        */
+       function rsegment_array()
+       {
+               return $this->rsegments;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Total number of segments
+        *
+        * @access      public
+        * @return      integer
+        */
+       function total_segments()
+       {
+               return count($this->segments);
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Total number of routed segments
+        *
+        * @access      public
+        * @return      integer
+        */
+       function total_rsegments()
+       {
+               return count($this->rsegments);
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Fetch the entire URI string
+        *
+        * @access      public
+        * @return      string
+        */
+       function uri_string()
+       {
+               return $this->uri_string;
+       }
+
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Fetch the entire Re-routed URI string
+        *
+        * @access      public
+        * @return      string
+        */
+       function ruri_string()
+       {
+               return '/'.implode('/', $this->rsegment_array());
+       }
+
+}
+// END URI Class
+
+/* End of file URI.php */
+/* Location: ./system/core/URI.php */
\ No newline at end of file
diff --git a/system/core/Utf8.php b/system/core/Utf8.php
new file mode 100755 (executable)
index 0000000..2a27d1f
--- /dev/null
@@ -0,0 +1,165 @@
+<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+/**
+ * CodeIgniter
+ *
+ * An open source application development framework for PHP 5.1.6 or newer
+ *
+ * @package            CodeIgniter
+ * @author             ExpressionEngine Dev Team
+ * @copyright  Copyright (c) 2008 - 2011, EllisLab, Inc.
+ * @license            http://codeigniter.com/user_guide/license.html
+ * @link               http://codeigniter.com
+ * @since              Version 2.0
+ * @filesource
+ */
+
+// ------------------------------------------------------------------------
+
+/**
+ * Utf8 Class
+ *
+ * Provides support for UTF-8 environments
+ *
+ * @package            CodeIgniter
+ * @subpackage Libraries
+ * @category   UTF-8
+ * @author             ExpressionEngine Dev Team
+ * @link               http://codeigniter.com/user_guide/libraries/utf8.html
+ */
+class CI_Utf8 {
+
+       /**
+        * Constructor
+        *
+        * Determines if UTF-8 support is to be enabled
+        *
+        */
+       function __construct()
+       {
+               log_message('debug', "Utf8 Class Initialized");
+
+               global $CFG;
+
+               if (
+                       preg_match('/./u', 'é') === 1                                  // PCRE must support UTF-8
+                       AND function_exists('iconv')                                    // iconv must be installed
+                       AND ini_get('mbstring.func_overload') != 1              // Multibyte string function overloading cannot be enabled
+                       AND $CFG->item('charset') == 'UTF-8'                    // Application charset must be UTF-8
+                       )
+               {
+                       log_message('debug', "UTF-8 Support Enabled");
+
+                       define('UTF8_ENABLED', TRUE);
+
+                       // set internal encoding for multibyte string functions if necessary
+                       // and set a flag so we don't have to repeatedly use extension_loaded()
+                       // or function_exists()
+                       if (extension_loaded('mbstring'))
+                       {
+                               define('MB_ENABLED', TRUE);
+                               mb_internal_encoding('UTF-8');
+                       }
+                       else
+                       {
+                               define('MB_ENABLED', FALSE);
+                       }
+               }
+               else
+               {
+                       log_message('debug', "UTF-8 Support Disabled");
+                       define('UTF8_ENABLED', FALSE);
+               }
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Clean UTF-8 strings
+        *
+        * Ensures strings are UTF-8
+        *
+        * @access      public
+        * @param       string
+        * @return      string
+        */
+       function clean_string($str)
+       {
+               if ($this->_is_ascii($str) === FALSE)
+               {
+                       $str = @iconv('UTF-8', 'UTF-8//IGNORE', $str);
+               }
+
+               return $str;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Remove ASCII control characters
+        *
+        * Removes all ASCII control characters except horizontal tabs,
+        * line feeds, and carriage returns, as all others can cause
+        * problems in XML
+        *
+        * @access      public
+        * @param       string
+        * @return      string
+        */
+       function safe_ascii_for_xml($str)
+       {
+               return remove_invisible_characters($str, FALSE);
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Convert to UTF-8
+        *
+        * Attempts to convert a string to UTF-8
+        *
+        * @access      public
+        * @param       string
+        * @param       string  - input encoding
+        * @return      string
+        */
+       function convert_to_utf8($str, $encoding)
+       {
+               if (function_exists('iconv'))
+               {
+                       $str = @iconv($encoding, 'UTF-8', $str);
+               }
+               elseif (function_exists('mb_convert_encoding'))
+               {
+                       $str = @mb_convert_encoding($str, 'UTF-8', $encoding);
+               }
+               else
+               {
+                       return FALSE;
+               }
+
+               return $str;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Is ASCII?
+        *
+        * Tests if a string is standard 7-bit ASCII or not
+        *
+        * @access      public
+        * @param       string
+        * @return      bool
+        */
+       function _is_ascii($str)
+       {
+               return (preg_match('/[^\x00-\x7F]/S', $str) == 0);
+       }
+
+       // --------------------------------------------------------------------
+
+}
+// End Utf8 Class
+
+/* End of file Utf8.php */
+/* Location: ./system/core/Utf8.php */
\ No newline at end of file
diff --git a/system/core/index.html b/system/core/index.html
new file mode 100755 (executable)
index 0000000..c942a79
--- /dev/null
@@ -0,0 +1,10 @@
+<html>
+<head>
+       <title>403 Forbidden</title>
+</head>
+<body>
+
+<p>Directory access is forbidden.</p>
+
+</body>
+</html>
\ No newline at end of file
diff --git a/system/database/DB.php b/system/database/DB.php
new file mode 100755 (executable)
index 0000000..8bf1ba8
--- /dev/null
@@ -0,0 +1,160 @@
+<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+/**
+ * CodeIgniter
+ *
+ * An open source application development framework for PHP 5.1.6 or newer
+ *
+ * @package            CodeIgniter
+ * @author             ExpressionEngine Dev Team
+ * @copyright  Copyright (c) 2008 - 2011, EllisLab, Inc.
+ * @license            http://codeigniter.com/user_guide/license.html
+ * @link               http://codeigniter.com
+ * @since              Version 1.0
+ * @filesource
+ */
+
+// ------------------------------------------------------------------------
+
+/**
+ * Initialize the database
+ *
+ * @category   Database
+ * @author             ExpressionEngine Dev Team
+ * @link               http://codeigniter.com/user_guide/database/
+ */
+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)
+       {
+               // Is the config file in the environment folder?
+               if ( ! defined('ENVIRONMENT') OR ! file_exists($file_path = APPPATH.'config/'.ENVIRONMENT.'/database'.EXT))
+               {
+                       if ( ! file_exists($file_path = APPPATH.'config/database'.EXT))
+                       {
+                               show_error('The configuration file database'.EXT.' does not exist.');
+                       }
+               }
+               
+               include($file_path);
+
+               if ( ! isset($db) OR count($db) == 0)
+               {
+                       show_error('No database connection settings were found in the database config file.');
+               }
+
+               if ($params != '')
+               {
+                       $active_group = $params;
+               }
+
+               if ( ! isset($active_group) OR ! isset($db[$active_group]))
+               {
+                       show_error('You have specified an invalid database connection group.');
+               }
+
+               $params = $db[$active_group];
+       }
+       elseif (is_string($params))
+       {
+
+               /* parse the URL from the DSN string
+                *  Database settings can be passed as discreet
+                *  parameters or as a data source name in the first
+                *  parameter. DSNs must have this prototype:
+                *  $dsn = 'driver://username:password@hostname/database';
+                */
+
+               if (($dns = @parse_url($params)) === FALSE)
+               {
+                       show_error('Invalid DB Connection String');
+               }
+
+               $params = array(
+                                                       'dbdriver'      => $dns['scheme'],
+                                                       'hostname'      => (isset($dns['host'])) ? rawurldecode($dns['host']) : '',
+                                                       'username'      => (isset($dns['user'])) ? rawurldecode($dns['user']) : '',
+                                                       'password'      => (isset($dns['pass'])) ? rawurldecode($dns['pass']) : '',
+                                                       'database'      => (isset($dns['path'])) ? rawurldecode(substr($dns['path'], 1)) : ''
+                                               );
+
+               // were additional config items set?
+               if (isset($dns['query']))
+               {
+                       parse_str($dns['query'], $extra);
+
+                       foreach ($extra as $key => $val)
+                       {
+                               // booleans please
+                               if (strtoupper($val) == "TRUE")
+                               {
+                                       $val = TRUE;
+                               }
+                               elseif (strtoupper($val) == "FALSE")
+                               {
+                                       $val = FALSE;
+                               }
+
+                               $params[$key] = $val;
+                       }
+               }
+       }
+
+       // No DB specified yet?  Beat them senseless...
+       if ( ! isset($params['dbdriver']) OR $params['dbdriver'] == '')
+       {
+               show_error('You have not selected a database type to connect to.');
+       }
+
+       // Load the DB classes.  Note: Since the active record class is optional
+       // we need to dynamically create a class that extends proper parent class
+       // based on whether we're using the active record class or not.
+       // Kudos to Paul for discovering this clever use of eval()
+
+       if ($active_record_override !== NULL)
+       {
+               $active_record = $active_record_override;
+       }
+
+       require_once(BASEPATH.'database/DB_driver'.EXT);
+
+       if ( ! isset($active_record) OR $active_record == TRUE)
+       {
+               require_once(BASEPATH.'database/DB_active_rec'.EXT);
+
+               if ( ! class_exists('CI_DB'))
+               {
+                       eval('class CI_DB extends CI_DB_active_record { }');
+               }
+       }
+       else
+       {
+               if ( ! class_exists('CI_DB'))
+               {
+                       eval('class CI_DB extends CI_DB_driver { }');
+               }
+       }
+
+       require_once(BASEPATH.'database/drivers/'.$params['dbdriver'].'/'.$params['dbdriver'].'_driver'.EXT);
+
+       // Instantiate the DB adapter
+       $driver = 'CI_DB_'.$params['dbdriver'].'_driver';
+       $DB = new $driver($params);
+
+       if ($DB->autoinit == TRUE)
+       {
+               $DB->initialize();
+       }
+
+       if (isset($params['stricton']) && $params['stricton'] == TRUE)
+       {
+               $DB->query('SET SESSION sql_mode="STRICT_ALL_TABLES"');
+       }
+
+       return $DB;
+}
+
+
+
+/* End of file DB.php */
+/* Location: ./system/database/DB.php */
\ No newline at end of file
diff --git a/system/database/DB_active_rec.php b/system/database/DB_active_rec.php
new file mode 100755 (executable)
index 0000000..db84713
--- /dev/null
@@ -0,0 +1,2073 @@
+<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+/**
+ * CodeIgniter
+ *
+ * An open source application development framework for PHP 5.1.6 or newer
+ *
+ * @package            CodeIgniter
+ * @author             ExpressionEngine Dev Team
+ * @copyright  Copyright (c) 2008 - 2011, EllisLab, Inc.
+ * @license            http://codeigniter.com/user_guide/license.html
+ * @link               http://codeigniter.com
+ * @since              Version 1.0
+ * @filesource
+ */
+
+// ------------------------------------------------------------------------
+
+/**
+ * Active Record Class
+ *
+ * This is the platform-independent base Active Record implementation class.
+ *
+ * @package            CodeIgniter
+ * @subpackage Drivers
+ * @category   Database
+ * @author             ExpressionEngine Dev Team
+ * @link               http://codeigniter.com/user_guide/database/
+ */
+class CI_DB_active_record extends CI_DB_driver {
+
+       var $ar_select                          = array();
+       var $ar_distinct                        = FALSE;
+       var $ar_from                            = array();
+       var $ar_join                            = array();
+       var $ar_where                           = array();
+       var $ar_like                            = array();
+       var $ar_groupby                         = array();
+       var $ar_having                          = array();
+       var $ar_keys                            = array();
+       var $ar_limit                           = FALSE;
+       var $ar_offset                          = FALSE;
+       var $ar_order                           = FALSE;
+       var $ar_orderby                         = array();
+       var $ar_set                                     = array();
+       var $ar_wherein                         = array();
+       var $ar_aliased_tables          = array();
+       var $ar_store_array                     = array();
+
+       // Active Record Caching variables
+       var $ar_caching                         = FALSE;
+       var $ar_cache_exists            = array();
+       var $ar_cache_select            = array();
+       var $ar_cache_from                      = array();
+       var $ar_cache_join                      = array();
+       var $ar_cache_where                     = array();
+       var $ar_cache_like                      = array();
+       var $ar_cache_groupby           = array();
+       var $ar_cache_having            = array();
+       var $ar_cache_orderby           = array();
+       var $ar_cache_set                       = array();
+
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Select
+        *
+        * Generates the SELECT portion of the query
+        *
+        * @access      public
+        * @param       string
+        * @return      object
+        */
+       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);
+               }
+
+               foreach ($select as $val)
+               {
+                       $val = trim($val);
+
+                       if ($val != '')
+                       {
+                               $this->ar_select[] = $val;
+
+                               if ($this->ar_caching === TRUE)
+                               {
+                                       $this->ar_cache_select[] = $val;
+                                       $this->ar_cache_exists[] = 'select';
+                               }
+                       }
+               }
+               return $this;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Select Max
+        *
+        * 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 = '')
+       {
+               return $this->_max_min_avg_sum($select, $alias, 'MAX');
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Select Min
+        *
+        * 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 = '')
+       {
+               return $this->_max_min_avg_sum($select, $alias, 'MIN');
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Select Average
+        *
+        * 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 = '')
+       {
+               return $this->_max_min_avg_sum($select, $alias, 'AVG');
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Select Sum
+        *
+        * 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 = '')
+       {
+               return $this->_max_min_avg_sum($select, $alias, 'SUM');
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Processing Function for the four functions above:
+        *
+        *      select_max()
+        *      select_min()
+        *      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')
+       {
+               if ( ! is_string($select) OR $select == '')
+               {
+                       $this->display_error('db_invalid_query');
+               }
+
+               $type = strtoupper($type);
+
+               if ( ! in_array($type, array('MAX', 'MIN', 'AVG', 'SUM')))
+               {
+                       show_error('Invalid function type: '.$type);
+               }
+
+               if ($alias == '')
+               {
+                       $alias = $this->_create_alias_from_table(trim($select));
+               }
+
+               $sql = $type.'('.$this->_protect_identifiers(trim($select)).') AS '.$alias;
+
+               $this->ar_select[] = $sql;
+
+               if ($this->ar_caching === TRUE)
+               {
+                       $this->ar_cache_select[] = $sql;
+                       $this->ar_cache_exists[] = 'select';
+               }
+
+               return $this;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Determines the alias name based on the table
+        *
+        * @access      private
+        * @param       string
+        * @return      string
+        */
+       function _create_alias_from_table($item)
+       {
+               if (strpos($item, '.') !== FALSE)
+               {
+                       return end(explode('.', $item));
+               }
+
+               return $item;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * DISTINCT
+        *
+        * Sets a flag which tells the query string compiler to add DISTINCT
+        *
+        * @access      public
+        * @param       bool
+        * @return      object
+        */
+       function distinct($val = TRUE)
+       {
+               $this->ar_distinct = (is_bool($val)) ? $val : TRUE;
+               return $this;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * From
+        *
+        * Generates the FROM portion of the query
+        *
+        * @access      public
+        * @param       mixed   can be a string or array
+        * @return      object
+        */
+       function from($from)
+       {
+               foreach ((array)$from as $val)
+               {
+                       if (strpos($val, ',') !== FALSE)
+                       {
+                               foreach (explode(',', $val) as $v)
+                               {
+                                       $v = trim($v);
+                                       $this->_track_aliases($v);
+
+                                       $this->ar_from[] = $this->_protect_identifiers($v, TRUE, NULL, FALSE);
+
+                                       if ($this->ar_caching === TRUE)
+                                       {
+                                               $this->ar_cache_from[] = $this->_protect_identifiers($v, TRUE, NULL, FALSE);
+                                               $this->ar_cache_exists[] = 'from';
+                                       }
+                               }
+
+                       }
+                       else
+                       {
+                               $val = trim($val);
+
+                               // Extract any aliases that might exist.  We use this information
+                               // in the _protect_identifiers to know whether to add a table prefix
+                               $this->_track_aliases($val);
+
+                               $this->ar_from[] = $this->_protect_identifiers($val, TRUE, NULL, FALSE);
+
+                               if ($this->ar_caching === TRUE)
+                               {
+                                       $this->ar_cache_from[] = $this->_protect_identifiers($val, TRUE, NULL, FALSE);
+                                       $this->ar_cache_exists[] = 'from';
+                               }
+                       }
+               }
+
+               return $this;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Join
+        *
+        * 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 = '')
+       {
+               if ($type != '')
+               {
+                       $type = strtoupper(trim($type));
+
+                       if ( ! in_array($type, array('LEFT', 'RIGHT', 'OUTER', 'INNER', 'LEFT OUTER', 'RIGHT OUTER')))
+                       {
+                               $type = '';
+                       }
+                       else
+                       {
+                               $type .= ' ';
+                       }
+               }
+
+               // Extract any aliases that might exist.  We use this information
+               // in the _protect_identifiers to know whether to add a table prefix
+               $this->_track_aliases($table);
+
+               // Strip apart the condition and protect the identifiers
+               if (preg_match('/([\w\.]+)([\W\s]+)(.+)/', $cond, $match))
+               {
+                       $match[1] = $this->_protect_identifiers($match[1]);
+                       $match[3] = $this->_protect_identifiers($match[3]);
+
+                       $cond = $match[1].$match[2].$match[3];
+               }
+
+               // Assemble the JOIN statement
+               $join = $type.'JOIN '.$this->_protect_identifiers($table, TRUE, NULL, FALSE).' ON '.$cond;
+
+               $this->ar_join[] = $join;
+               if ($this->ar_caching === TRUE)
+               {
+                       $this->ar_cache_join[] = $join;
+                       $this->ar_cache_exists[] = 'join';
+               }
+
+               return $this;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Where
+        *
+        * 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)
+       {
+               return $this->_where($key, $value, 'AND ', $escape);
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * OR Where
+        *
+        * 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)
+       {
+               return $this->_where($key, $value, 'OR ', $escape);
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Where
+        *
+        * Called by where() or orwhere()
+        *
+        * @access      private
+        * @param       mixed
+        * @param       mixed
+        * @param       string
+        * @return      object
+        */
+       function _where($key, $value = NULL, $type = 'AND ', $escape = NULL)
+       {
+               if ( ! is_array($key))
+               {
+                       $key = array($key => $value);
+               }
+
+               // If the escape value was not set will will base it on the global setting
+               if ( ! is_bool($escape))
+               {
+                       $escape = $this->_protect_identifiers;
+               }
+
+               foreach ($key as $k => $v)
+               {
+                       $prefix = (count($this->ar_where) == 0 AND count($this->ar_cache_where) == 0) ? '' : $type;
+
+                       if (is_null($v) && ! $this->_has_operator($k))
+                       {
+                               // value appears not to have been set, assign the test to IS NULL
+                               $k .= ' IS NULL';
+                       }
+
+                       if ( ! is_null($v))
+                       {
+                               if ($escape === TRUE)
+                               {
+                                       $k = $this->_protect_identifiers($k, FALSE, $escape);
+
+                                       $v = ' '.$this->escape($v);
+                               }
+
+                               if ( ! $this->_has_operator($k))
+                               {
+                                       $k .= ' =';
+                               }
+                       }
+                       else
+                       {
+                               $k = $this->_protect_identifiers($k, FALSE, $escape);
+                       }
+
+                       $this->ar_where[] = $prefix.$k.$v;
+
+                       if ($this->ar_caching === TRUE)
+                       {
+                               $this->ar_cache_where[] = $prefix.$k.$v;
+                               $this->ar_cache_exists[] = 'where';
+                       }
+
+               }
+
+               return $this;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Where_in
+        *
+        * 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)
+       {
+               return $this->_where_in($key, $values);
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Where_in_or
+        *
+        * 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)
+       {
+               return $this->_where_in($key, $values, FALSE, 'OR ');
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Where_not_in
+        *
+        * 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)
+       {
+               return $this->_where_in($key, $values, TRUE);
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Where_not_in_or
+        *
+        * 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)
+       {
+               return $this->_where_in($key, $values, TRUE, 'OR ');
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Where_in
+        *
+        * 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 ')
+       {
+               if ($key === NULL OR $values === NULL)
+               {
+                       return;
+               }
+
+               if ( ! is_array($values))
+               {
+                       $values = array($values);
+               }
+
+               $not = ($not) ? ' NOT' : '';
+
+               foreach ($values as $value)
+               {
+                       $this->ar_wherein[] = $this->escape($value);
+               }
+
+               $prefix = (count($this->ar_where) == 0) ? '' : $type;
+
+               $where_in = $prefix . $this->_protect_identifiers($key) . $not . " IN (" . implode(", ", $this->ar_wherein) . ") ";
+
+               $this->ar_where[] = $where_in;
+               if ($this->ar_caching === TRUE)
+               {
+                       $this->ar_cache_where[] = $where_in;
+                       $this->ar_cache_exists[] = 'where';
+               }
+
+               // reset the array for multiple calls
+               $this->ar_wherein = array();
+               return $this;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Like
+        *
+        * 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')
+       {
+               return $this->_like($field, $match, 'AND ', $side);
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Not Like
+        *
+        * 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')
+       {
+               return $this->_like($field, $match, 'AND ', $side, 'NOT');
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * OR Like
+        *
+        * 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')
+       {
+               return $this->_like($field, $match, 'OR ', $side);
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * OR Not Like
+        *
+        * 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')
+       {
+               return $this->_like($field, $match, 'OR ', $side, 'NOT');
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Like
+        *
+        * Called by like() or orlike()
+        *
+        * @access      private
+        * @param       mixed
+        * @param       mixed
+        * @param       string
+        * @return      object
+        */
+       function _like($field, $match = '', $type = 'AND ', $side = 'both', $not = '')
+       {
+               if ( ! is_array($field))
+               {
+                       $field = array($field => $match);
+               }
+
+               foreach ($field as $k => $v)
+               {
+                       $k = $this->_protect_identifiers($k);
+
+                       $prefix = (count($this->ar_like) == 0) ? '' : $type;
+
+                       $v = $this->escape_like_str($v);
+
+                       if ($side == 'before')
+                       {
+                               $like_statement = $prefix." $k $not LIKE '%{$v}'";
+                       }
+                       elseif ($side == 'after')
+                       {
+                               $like_statement = $prefix." $k $not LIKE '{$v}%'";
+                       }
+                       else
+                       {
+                               $like_statement = $prefix." $k $not LIKE '%{$v}%'";
+                       }
+
+                       // some platforms require an escape sequence definition for LIKE wildcards
+                       if ($this->_like_escape_str != '')
+                       {
+                               $like_statement = $like_statement.sprintf($this->_like_escape_str, $this->_like_escape_chr);
+                       }
+
+                       $this->ar_like[] = $like_statement;
+                       if ($this->ar_caching === TRUE)
+                       {
+                               $this->ar_cache_like[] = $like_statement;
+                               $this->ar_cache_exists[] = 'like';
+                       }
+
+               }
+               return $this;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * GROUP BY
+        *
+        * @access      public
+        * @param       string
+        * @return      object
+        */
+       function group_by($by)
+       {
+               if (is_string($by))
+               {
+                       $by = explode(',', $by);
+               }
+
+               foreach ($by as $val)
+               {
+                       $val = trim($val);
+
+                       if ($val != '')
+                       {
+                               $this->ar_groupby[] = $this->_protect_identifiers($val);
+
+                               if ($this->ar_caching === TRUE)
+                               {
+                                       $this->ar_cache_groupby[] = $this->_protect_identifiers($val);
+                                       $this->ar_cache_exists[] = 'groupby';
+                               }
+                       }
+               }
+               return $this;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Sets the HAVING value
+        *
+        * Separates multiple calls with AND
+        *
+        * @access      public
+        * @param       string
+        * @param       string
+        * @return      object
+        */
+       function having($key, $value = '', $escape = TRUE)
+       {
+               return $this->_having($key, $value, 'AND ', $escape);
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Sets the OR HAVING value
+        *
+        * Separates multiple calls with OR
+        *
+        * @access      public
+        * @param       string
+        * @param       string
+        * @return      object
+        */
+       function or_having($key, $value = '', $escape = TRUE)
+       {
+               return $this->_having($key, $value, 'OR ', $escape);
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Sets the HAVING values
+        *
+        * Called by having() or or_having()
+        *
+        * @access      private
+        * @param       string
+        * @param       string
+        * @return      object
+        */
+       function _having($key, $value = '', $type = 'AND ', $escape = TRUE)
+       {
+               if ( ! is_array($key))
+               {
+                       $key = array($key => $value);
+               }
+
+               foreach ($key as $k => $v)
+               {
+                       $prefix = (count($this->ar_having) == 0) ? '' : $type;
+
+                       if ($escape === TRUE)
+                       {
+                               $k = $this->_protect_identifiers($k);
+                       }
+
+                       if ( ! $this->_has_operator($k))
+                       {
+                               $k .= ' = ';
+                       }
+
+                       if ($v != '')
+                       {
+                               $v = ' '.$this->escape_str($v);
+                       }
+
+                       $this->ar_having[] = $prefix.$k.$v;
+                       if ($this->ar_caching === TRUE)
+                       {
+                               $this->ar_cache_having[] = $prefix.$k.$v;
+                               $this->ar_cache_exists[] = 'having';
+                       }
+               }
+
+               return $this;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Sets the ORDER BY value
+        *
+        * @access      public
+        * @param       string
+        * @param       string  direction: asc or desc
+        * @return      object
+        */
+       function order_by($orderby, $direction = '')
+       {
+               if (strtolower($direction) == 'random')
+               {
+                       $orderby = ''; // Random results want or don't need a field name
+                       $direction = $this->_random_keyword;
+               }
+               elseif (trim($direction) != '')
+               {
+                       $direction = (in_array(strtoupper(trim($direction)), array('ASC', 'DESC'), TRUE)) ? ' '.$direction : ' ASC';
+               }
+
+
+               if (strpos($orderby, ',') !== FALSE)
+               {
+                       $temp = array();
+                       foreach (explode(',', $orderby) as $part)
+                       {
+                               $part = trim($part);
+                               if ( ! in_array($part, $this->ar_aliased_tables))
+                               {
+                                       $part = $this->_protect_identifiers(trim($part));
+                               }
+
+                               $temp[] = $part;
+                       }
+
+                       $orderby = implode(', ', $temp);
+               }
+               else if ($direction != $this->_random_keyword)
+               {
+                       $orderby = $this->_protect_identifiers($orderby);
+               }
+
+               $orderby_statement = $orderby.$direction;
+
+               $this->ar_orderby[] = $orderby_statement;
+               if ($this->ar_caching === TRUE)
+               {
+                       $this->ar_cache_orderby[] = $orderby_statement;
+                       $this->ar_cache_exists[] = 'orderby';
+               }
+
+               return $this;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Sets the LIMIT value
+        *
+        * @access      public
+        * @param       integer the limit value
+        * @param       integer the offset value
+        * @return      object
+        */
+       function limit($value, $offset = '')
+       {
+               $this->ar_limit = $value;
+
+               if ($offset != '')
+               {
+                       $this->ar_offset = $offset;
+               }
+
+               return $this;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Sets the OFFSET value
+        *
+        * @access      public
+        * @param       integer the offset value
+        * @return      object
+        */
+       function offset($offset)
+       {
+               $this->ar_offset = $offset;
+               return $this;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * 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)
+       {
+               $key = $this->_object_to_array($key);
+
+               if ( ! is_array($key))
+               {
+                       $key = array($key => $value);
+               }
+
+               foreach ($key as $k => $v)
+               {
+                       if ($escape === FALSE)
+                       {
+                               $this->ar_set[$this->_protect_identifiers($k)] = $v;
+                       }
+                       else
+                       {
+                               $this->ar_set[$this->_protect_identifiers($k, FALSE, TRUE)] = $this->escape($v);
+                       }
+               }
+
+               return $this;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Get
+        *
+        * 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)
+       {
+               if ($table != '')
+               {
+                       $this->_track_aliases($table);
+                       $this->from($table);
+               }
+
+               if ( ! is_null($limit))
+               {
+                       $this->limit($limit, $offset);
+               }
+
+               $sql = $this->_compile_select();
+
+               $result = $this->query($sql);
+               $this->_reset_select();
+               return $result;
+       }
+
+       /**
+        * "Count All Results" query
+        *
+        * 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 = '')
+       {
+               if ($table != '')
+               {
+                       $this->_track_aliases($table);
+                       $this->from($table);
+               }
+
+               $sql = $this->_compile_select($this->_count_string . $this->_protect_identifiers('numrows'));
+
+               $query = $this->query($sql);
+               $this->_reset_select();
+
+               if ($query->num_rows() == 0)
+               {
+                       return 0;
+               }
+
+               $row = $query->row();
+               return (int) $row->numrows;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Get_Where
+        *
+        * 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)
+       {
+               if ($table != '')
+               {
+                       $this->from($table);
+               }
+
+               if ( ! is_null($where))
+               {
+                       $this->where($where);
+               }
+
+               if ( ! is_null($limit))
+               {
+                       $this->limit($limit, $offset);
+               }
+
+               $sql = $this->_compile_select();
+
+               $result = $this->query($sql);
+               $this->_reset_select();
+               return $result;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Insert_Batch
+        *
+        * 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)
+       {
+               if ( ! is_null($set))
+               {
+                       $this->set_insert_batch($set);
+               }
+
+               if (count($this->ar_set) == 0)
+               {
+                       if ($this->db_debug)
+                       {
+                               //No valid data array.  Folds in cases where keys and values did not match up
+                               return $this->display_error('db_must_use_set');
+                       }
+                       return FALSE;
+               }
+
+               if ($table == '')
+               {
+                       if ( ! isset($this->ar_from[0]))
+                       {
+                               if ($this->db_debug)
+                               {
+                                       return $this->display_error('db_must_set_table');
+                               }
+                               return FALSE;
+                       }
+
+                       $table = $this->ar_from[0];
+               }
+
+               // Batch this baby
+               for ($i = 0, $total = count($this->ar_set); $i < $total; $i = $i + 100)
+               {
+
+                       $sql = $this->_insert_batch($this->_protect_identifiers($table, TRUE, NULL, FALSE), $this->ar_keys, array_slice($this->ar_set, $i, 100));
+
+                       //echo $sql;
+
+                       $this->query($sql);
+               }
+
+               $this->_reset_write();
+
+
+               return TRUE;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * 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)
+       {
+               $key = $this->_object_to_array_batch($key);
+
+               if ( ! is_array($key))
+               {
+                       $key = array($key => $value);
+               }
+
+               $keys = array_keys(current($key));
+               sort($keys);
+
+               foreach ($key as $row)
+               {
+                       if (count(array_diff($keys, array_keys($row))) > 0 OR count(array_diff(array_keys($row), $keys)) > 0)
+                       {
+                               // batch function above returns an error on an empty array
+                               $this->ar_set[] = array();
+                               return;
+                       }
+
+                       ksort($row); // puts $row in the same order as our keys
+
+                       if ($escape === FALSE)
+                       {
+                               $this->ar_set[] =  '('.implode(',', $row).')';
+                       }
+                       else
+                       {
+                               $clean = array();
+
+                               foreach ($row as $value)
+                               {
+                                       $clean[] = $this->escape($value);
+                               }
+
+                               $this->ar_set[] =  '('.implode(',', $clean).')';
+                       }
+               }
+
+               foreach ($keys as $k)
+               {
+                       $this->ar_keys[] = $this->_protect_identifiers($k);
+               }
+
+               return $this;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Insert
+        *
+        * Compiles an insert string and runs the query
+        *
+        * @access      public
+        * @param       string  the table to retrieve the results from
+        * @param       array   an associative array of insert values
+        * @return      object
+        */
+       function insert($table = '', $set = NULL)
+       {
+               if ( ! is_null($set))
+               {
+                       $this->set($set);
+               }
+
+               if (count($this->ar_set) == 0)
+               {
+                       if ($this->db_debug)
+                       {
+                               return $this->display_error('db_must_use_set');
+                       }
+                       return FALSE;
+               }
+
+               if ($table == '')
+               {
+                       if ( ! isset($this->ar_from[0]))
+                       {
+                               if ($this->db_debug)
+                               {
+                                       return $this->display_error('db_must_set_table');
+                               }
+                               return FALSE;
+                       }
+
+                       $table = $this->ar_from[0];
+               }
+
+               $sql = $this->_insert($this->_protect_identifiers($table, TRUE, NULL, FALSE), array_keys($this->ar_set), array_values($this->ar_set));
+
+               $this->_reset_write();
+               return $this->query($sql);
+       }
+
+       function replace($table = '', $set = NULL)
+       {
+               if ( ! is_null($set))
+               {
+                       $this->set($set);
+               }
+
+               if (count($this->ar_set) == 0)
+               {
+                       if ($this->db_debug)
+                       {
+                               return $this->display_error('db_must_use_set');
+                       }
+                       return FALSE;
+               }
+
+               if ($table == '')
+               {
+                       if ( ! isset($this->ar_from[0]))
+                       {
+                               if ($this->db_debug)
+                               {
+                                       return $this->display_error('db_must_set_table');
+                               }
+                               return FALSE;
+                       }
+
+                       $table = $this->ar_from[0];
+               }
+
+               $sql = $this->_replace($this->_protect_identifiers($table, TRUE, NULL, FALSE), array_keys($this->ar_set), array_values($this->ar_set));
+
+               $this->_reset_write();
+               return $this->query($sql);
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Update
+        *
+        * 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)
+       {
+               // Combine any cached components with the current statements
+               $this->_merge_cache();
+
+               if ( ! is_null($set))
+               {
+                       $this->set($set);
+               }
+
+               if (count($this->ar_set) == 0)
+               {
+                       if ($this->db_debug)
+                       {
+                               return $this->display_error('db_must_use_set');
+                       }
+                       return FALSE;
+               }
+
+               if ($table == '')
+               {
+                       if ( ! isset($this->ar_from[0]))
+                       {
+                               if ($this->db_debug)
+                               {
+                                       return $this->display_error('db_must_set_table');
+                               }
+                               return FALSE;
+                       }
+
+                       $table = $this->ar_from[0];
+               }
+
+               if ($where != NULL)
+               {
+                       $this->where($where);
+               }
+
+               if ($limit != NULL)
+               {
+                       $this->limit($limit);
+               }
+
+               $sql = $this->_update($this->_protect_identifiers($table, TRUE, NULL, FALSE), $this->ar_set, $this->ar_where, $this->ar_orderby, $this->ar_limit);
+
+               $this->_reset_write();
+               return $this->query($sql);
+       }
+
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Update_Batch
+        *
+        * 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)
+       {
+               // Combine any cached components with the current statements
+               $this->_merge_cache();
+
+               if (is_null($index))
+               {
+                       if ($this->db_debug)
+                       {
+                               return $this->display_error('db_myst_use_index');
+                       }
+
+                       return FALSE;
+               }
+
+               if ( ! is_null($set))
+               {
+                       $this->set_update_batch($set, $index);
+               }
+
+               if (count($this->ar_set) == 0)
+               {
+                       if ($this->db_debug)
+                       {
+                               return $this->display_error('db_must_use_set');
+                       }
+
+                       return FALSE;
+               }
+
+               if ($table == '')
+               {
+                       if ( ! isset($this->ar_from[0]))
+                       {
+                               if ($this->db_debug)
+                               {
+                                       return $this->display_error('db_must_set_table');
+                               }
+                               return FALSE;
+                       }
+
+                       $table = $this->ar_from[0];
+               }
+
+               // Batch this baby
+               for ($i = 0, $total = count($this->ar_set); $i < $total; $i = $i + 100)
+               {
+                       $sql = $this->_update_batch($this->_protect_identifiers($table, TRUE, NULL, FALSE), array_slice($this->ar_set, $i, 100), $this->_protect_identifiers($index), $this->ar_where);
+
+                       $this->query($sql);
+               }
+
+               $this->_reset_write();
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * 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)
+       {
+               $key = $this->_object_to_array_batch($key);
+
+               if ( ! is_array($key))
+               {
+                       // @todo error
+               }
+
+               foreach ($key as $k => $v)
+               {
+                       $index_set = FALSE;
+                       $clean = array();
+
+                       foreach ($v as $k2 => $v2)
+                       {
+                               if ($k2 == $index)
+                               {
+                                       $index_set = TRUE;
+                               }
+                               else
+                               {
+                                       $not[] = $k.'-'.$v;
+                               }
+
+                               if ($escape === FALSE)
+                               {
+                                       $clean[$this->_protect_identifiers($k2)] = $v2;
+                               }
+                               else
+                               {
+                                       $clean[$this->_protect_identifiers($k2)] = $this->escape($v2);
+                               }
+                       }
+
+                       if ($index_set == FALSE)
+                       {
+                               return $this->display_error('db_batch_missing_index');
+                       }
+
+                       $this->ar_set[] = $clean;
+               }
+
+               return $this;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Empty Table
+        *
+        * Compiles a delete string and runs "DELETE FROM table"
+        *
+        * @access      public
+        * @param       string  the table to empty
+        * @return      object
+        */
+       function empty_table($table = '')
+       {
+               if ($table == '')
+               {
+                       if ( ! isset($this->ar_from[0]))
+                       {
+                               if ($this->db_debug)
+                               {
+                                       return $this->display_error('db_must_set_table');
+                               }
+                               return FALSE;
+                       }
+
+                       $table = $this->ar_from[0];
+               }
+               else
+               {
+                       $table = $this->_protect_identifiers($table, TRUE, NULL, FALSE);
+               }
+
+               $sql = $this->_delete($table);
+
+               $this->_reset_write();
+
+               return $this->query($sql);
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Truncate
+        *
+        * Compiles a truncate string and runs the query
+        * 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 = '')
+       {
+               if ($table == '')
+               {
+                       if ( ! isset($this->ar_from[0]))
+                       {
+                               if ($this->db_debug)
+                               {
+                                       return $this->display_error('db_must_set_table');
+                               }
+                               return FALSE;
+                       }
+
+                       $table = $this->ar_from[0];
+               }
+               else
+               {
+                       $table = $this->_protect_identifiers($table, TRUE, NULL, FALSE);
+               }
+
+               $sql = $this->_truncate($table);
+
+               $this->_reset_write();
+
+               return $this->query($sql);
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Delete
+        *
+        * 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)
+       {
+               // Combine any cached components with the current statements
+               $this->_merge_cache();
+
+               if ($table == '')
+               {
+                       if ( ! isset($this->ar_from[0]))
+                       {
+                               if ($this->db_debug)
+                               {
+                                       return $this->display_error('db_must_set_table');
+                               }
+                               return FALSE;
+                       }
+
+                       $table = $this->ar_from[0];
+               }
+               elseif (is_array($table))
+               {
+                       foreach ($table as $single_table)
+                       {
+                               $this->delete($single_table, $where, $limit, FALSE);
+                       }
+
+                       $this->_reset_write();
+                       return;
+               }
+               else
+               {
+                       $table = $this->_protect_identifiers($table, TRUE, NULL, FALSE);
+               }
+
+               if ($where != '')
+               {
+                       $this->where($where);
+               }
+
+               if ($limit != NULL)
+               {
+                       $this->limit($limit);
+               }
+
+               if (count($this->ar_where) == 0 && count($this->ar_wherein) == 0 && count($this->ar_like) == 0)
+               {
+                       if ($this->db_debug)
+                       {
+                               return $this->display_error('db_del_must_use_where');
+                       }
+
+                       return FALSE;
+               }
+
+               $sql = $this->_delete($table, $this->ar_where, $this->ar_like, $this->ar_limit);
+
+               if ($reset_data)
+               {
+                       $this->_reset_write();
+               }
+
+               return $this->query($sql);
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * DB Prefix
+        *
+        * Prepends a database prefix if one exists in configuration
+        *
+        * @access      public
+        * @param       string  the table
+        * @return      string
+        */
+       function dbprefix($table = '')
+       {
+               if ($table == '')
+               {
+                       $this->display_error('db_table_name_required');
+               }
+
+               return $this->dbprefix.$table;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * 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)
+       {
+               if (is_array($table))
+               {
+                       foreach ($table as $t)
+                       {
+                               $this->_track_aliases($t);
+                       }
+                       return;
+               }
+
+               // Does the string contain a comma?  If so, we need to separate
+               // the string into discreet statements
+               if (strpos($table, ',') !== FALSE)
+               {
+                       return $this->_track_aliases(explode(',', $table));
+               }
+
+               // if a table alias is used we can recognize it by a space
+               if (strpos($table, " ") !== FALSE)
+               {
+                       // if the alias is written with the AS keyword, remove it
+                       $table = preg_replace('/ AS /i', ' ', $table);
+
+                       // Grab the alias
+                       $table = trim(strrchr($table, " "));
+
+                       // Store the alias, if it doesn't already exist
+                       if ( ! in_array($table, $this->ar_aliased_tables))
+                       {
+                               $this->ar_aliased_tables[] = $table;
+                       }
+               }
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Compile the SELECT statement
+        *
+        * 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)
+       {
+               // Combine any cached components with the current statements
+               $this->_merge_cache();
+
+               // ----------------------------------------------------------------
+
+               // Write the "select" portion of the query
+
+               if ($select_override !== FALSE)
+               {
+                       $sql = $select_override;
+               }
+               else
+               {
+                       $sql = ( ! $this->ar_distinct) ? 'SELECT ' : 'SELECT DISTINCT ';
+
+                       if (count($this->ar_select) == 0)
+                       {
+                               $sql .= '*';
+                       }
+                       else
+                       {
+                               // Cycle through the "select" portion of the query and prep each column name.
+                               // The reason we protect identifiers here rather then in the select() function
+                               // 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);
+                               }
+
+                               $sql .= implode(', ', $this->ar_select);
+                       }
+               }
+
+               // ----------------------------------------------------------------
+
+               // Write the "FROM" portion of the query
+
+               if (count($this->ar_from) > 0)
+               {
+                       $sql .= "\nFROM ";
+
+                       $sql .= $this->_from_tables($this->ar_from);
+               }
+
+               // ----------------------------------------------------------------
+
+               // Write the "JOIN" portion of the query
+
+               if (count($this->ar_join) > 0)
+               {
+                       $sql .= "\n";
+
+                       $sql .= implode("\n", $this->ar_join);
+               }
+
+               // ----------------------------------------------------------------
+
+               // Write the "WHERE" portion of the query
+
+               if (count($this->ar_where) > 0 OR count($this->ar_like) > 0)
+               {
+                       $sql .= "\n";
+
+                       $sql .= "WHERE ";
+               }
+
+               $sql .= implode("\n", $this->ar_where);
+
+               // ----------------------------------------------------------------
+
+               // Write the "LIKE" portion of the query
+
+               if (count($this->ar_like) > 0)
+               {
+                       if (count($this->ar_where) > 0)
+                       {
+                               $sql .= "\nAND ";
+                       }
+
+                       $sql .= implode("\n", $this->ar_like);
+               }
+
+               // ----------------------------------------------------------------
+
+               // Write the "GROUP BY" portion of the query
+
+               if (count($this->ar_groupby) > 0)
+               {
+                       $sql .= "\nGROUP BY ";
+
+                       $sql .= implode(', ', $this->ar_groupby);
+               }
+
+               // ----------------------------------------------------------------
+
+               // Write the "HAVING" portion of the query
+
+               if (count($this->ar_having) > 0)
+               {
+                       $sql .= "\nHAVING ";
+                       $sql .= implode("\n", $this->ar_having);
+               }
+
+               // ----------------------------------------------------------------
+
+               // Write the "ORDER BY" portion of the query
+
+               if (count($this->ar_orderby) > 0)
+               {
+                       $sql .= "\nORDER BY ";
+                       $sql .= implode(', ', $this->ar_orderby);
+
+                       if ($this->ar_order !== FALSE)
+                       {
+                               $sql .= ($this->ar_order == 'desc') ? ' DESC' : ' ASC';
+                       }
+               }
+
+               // ----------------------------------------------------------------
+
+               // Write the "LIMIT" portion of the query
+
+               if (is_numeric($this->ar_limit))
+               {
+                       $sql .= "\n";
+                       $sql = $this->_limit($sql, $this->ar_limit, $this->ar_offset);
+               }
+
+               return $sql;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Object to Array
+        *
+        * 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)
+       {
+               if ( ! is_object($object))
+               {
+                       return $object;
+               }
+
+               $array = array();
+               foreach (get_object_vars($object) as $key => $val)
+               {
+                       // There are some built in keys we need to ignore for this conversion
+                       if ( ! is_object($val) && ! is_array($val) && $key != '_parent_name')
+                       {
+                               $array[$key] = $val;
+                       }
+               }
+
+               return $array;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Object to Array
+        *
+        * 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)
+       {
+               if ( ! is_object($object))
+               {
+                       return $object;
+               }
+
+               $array = array();
+               $out = get_object_vars($object);
+               $fields = array_keys($out);
+
+               foreach ($fields as $val)
+               {
+                       // There are some built in keys we need to ignore for this conversion
+                       if ($val != '_parent_name')
+                       {
+
+                               $i = 0;
+                               foreach ($out[$val] as $data)
+                               {
+                                       $array[$i][$val] = $data;
+                                       $i++;
+                               }
+                       }
+               }
+
+               return $array;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Start Cache
+        *
+        * Starts AR caching
+        *
+        * @access      public
+        * @return      void
+        */
+       function start_cache()
+       {
+               $this->ar_caching = TRUE;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Stop Cache
+        *
+        * Stops AR caching
+        *
+        * @access      public
+        * @return      void
+        */
+       function stop_cache()
+       {
+               $this->ar_caching = FALSE;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Flush Cache
+        *
+        * Empties the AR cache
+        *
+        * @access      public
+        * @return      void
+        */
+       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()
+                                                               )
+                                                       );
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Merge Cache
+        *
+        * When called, this function merges any cached AR arrays with
+        * locally called ones.
+        *
+        * @access      private
+        * @return      void
+        */
+       function _merge_cache()
+       {
+               if (count($this->ar_cache_exists) == 0)
+               {
+                       return;
+               }
+
+               foreach ($this->ar_cache_exists as $val)
+               {
+                       $ar_variable    = 'ar_'.$val;
+                       $ar_cache_var   = 'ar_cache_'.$val;
+
+                       if (count($this->$ar_cache_var) == 0)
+                       {
+                               continue;
+                       }
+
+                       $this->$ar_variable = array_unique(array_merge($this->$ar_cache_var, $this->$ar_variable));
+               }
+
+               // If we are "protecting identifiers" we need to examine the "from"
+               // portion of the query to determine if there are any aliases
+               if ($this->_protect_identifiers === TRUE AND count($this->ar_cache_from) > 0)
+               {
+                       $this->_track_aliases($this->ar_from);
+               }
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * 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)
+       {
+               foreach ($ar_reset_items as $item => $default_value)
+               {
+                       if ( ! in_array($item, $this->ar_store_array))
+                       {
+                               $this->$item = $default_value;
+                       }
+               }
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Resets the active record values.  Called by the get() function
+        *
+        * @access      private
+        * @return      void
+        */
+       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,
+                                                       );
+
+               $this->_reset_run($ar_reset_items);
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Resets the active record "write" values.
+        *
+        * Called by the insert() update() insert_batch() update_batch() and delete() functions
+        *
+        * @access      private
+        * @return      void
+        */
+       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
+                                                               );
+
+               $this->_reset_run($ar_reset_items);
+       }
+
+}
+
+/* End of file DB_active_rec.php */
+/* Location: ./system/database/DB_active_rec.php */
\ No newline at end of file
diff --git a/system/database/DB_cache.php b/system/database/DB_cache.php
new file mode 100755 (executable)
index 0000000..3bf065c
--- /dev/null
@@ -0,0 +1,195 @@
+<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+/**
+ * CodeIgniter
+ *
+ * An open source application development framework for PHP 5.1.6 or newer
+ *
+ * @package            CodeIgniter
+ * @author             ExpressionEngine Dev Team
+ * @copyright  Copyright (c) 2008 - 2011, EllisLab, Inc.
+ * @license            http://codeigniter.com/user_guide/license.html
+ * @link               http://codeigniter.com
+ * @since              Version 1.0
+ * @filesource
+ */
+
+// ------------------------------------------------------------------------
+
+/**
+ * Database Cache Class
+ *
+ * @category   Database
+ * @author             ExpressionEngine Dev Team
+ * @link               http://codeigniter.com/user_guide/database/
+ */
+class CI_DB_Cache {
+
+       var $CI;
+       var $db;        // allows passing of db object so that multiple database connections and returned db objects can be supported
+
+       /**
+        * Constructor
+        *
+        * Grabs the CI super object instance so we can access it.
+        *
+        */
+       function CI_DB_Cache(&$db)
+       {
+               // Assign the main CI object to $this->CI
+               // and load the file helper since we use it a lot
+               $this->CI =& get_instance();
+               $this->db =& $db;
+               $this->CI->load->helper('file');
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Set Cache Directory Path
+        *
+        * @access      public
+        * @param       string  the path to the cache directory
+        * @return      bool
+        */
+       function check_path($path = '')
+       {
+               if ($path == '')
+               {
+                       if ($this->db->cachedir == '')
+                       {
+                               return $this->db->cache_off();
+                       }
+
+                       $path = $this->db->cachedir;
+               }
+
+               // Add a trailing slash to the path if needed
+               $path = preg_replace("/(.+?)\/*$/", "\\1/",  $path);
+
+               if ( ! is_dir($path) OR ! is_really_writable($path))
+               {
+                       // If the path is wrong we'll turn off caching
+                       return $this->db->cache_off();
+               }
+
+               $this->db->cachedir = $path;
+               return TRUE;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Retrieve a cached query
+        *
+        * The URI being requested will become the name of the cache sub-folder.
+        * An MD5 hash of the SQL statement will become the cache file name
+        *
+        * @access      public
+        * @return      string
+        */
+       function read($sql)
+       {
+               if ( ! $this->check_path())
+               {
+                       return $this->db->cache_off();
+               }
+
+               $segment_one = ($this->CI->uri->segment(1) == FALSE) ? 'default' : $this->CI->uri->segment(1);
+
+               $segment_two = ($this->CI->uri->segment(2) == FALSE) ? 'index' : $this->CI->uri->segment(2);
+
+               $filepath = $this->db->cachedir.$segment_one.'+'.$segment_two.'/'.md5($sql);
+
+               if (FALSE === ($cachedata = read_file($filepath)))
+               {
+                       return FALSE;
+               }
+
+               return unserialize($cachedata);
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Write a query to a cache file
+        *
+        * @access      public
+        * @return      bool
+        */
+       function write($sql, $object)
+       {
+               if ( ! $this->check_path())
+               {
+                       return $this->db->cache_off();
+               }
+
+               $segment_one = ($this->CI->uri->segment(1) == FALSE) ? 'default' : $this->CI->uri->segment(1);
+
+               $segment_two = ($this->CI->uri->segment(2) == FALSE) ? 'index' : $this->CI->uri->segment(2);
+
+               $dir_path = $this->db->cachedir.$segment_one.'+'.$segment_two.'/';
+
+               $filename = md5($sql);
+
+               if ( ! @is_dir($dir_path))
+               {
+                       if ( ! @mkdir($dir_path, DIR_WRITE_MODE))
+                       {
+                               return FALSE;
+                       }
+
+                       @chmod($dir_path, DIR_WRITE_MODE);
+               }
+
+               if (write_file($dir_path.$filename, serialize($object)) === FALSE)
+               {
+                       return FALSE;
+               }
+
+               @chmod($dir_path.$filename, FILE_WRITE_MODE);
+               return TRUE;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Delete cache files within a particular directory
+        *
+        * @access      public
+        * @return      bool
+        */
+       function delete($segment_one = '', $segment_two = '')
+       {
+               if ($segment_one == '')
+               {
+                       $segment_one  = ($this->CI->uri->segment(1) == FALSE) ? 'default' : $this->CI->uri->segment(1);
+               }
+
+               if ($segment_two == '')
+               {
+                       $segment_two = ($this->CI->uri->segment(2) == FALSE) ? 'index' : $this->CI->uri->segment(2);
+               }
+
+               $dir_path = $this->db->cachedir.$segment_one.'+'.$segment_two.'/';
+
+               delete_files($dir_path, TRUE);
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Delete all existing cache files
+        *
+        * @access      public
+        * @return      bool
+        */
+       function delete_all()
+       {
+               delete_files($this->db->cachedir, TRUE);
+       }
+
+}
+
+
+/* End of file DB_cache.php */
+/* Location: ./system/database/DB_cache.php */
\ No newline at end of file
diff --git a/system/database/DB_driver.php b/system/database/DB_driver.php
new file mode 100755 (executable)
index 0000000..e7a9de4
--- /dev/null
@@ -0,0 +1,1390 @@
+<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+/**
+ * CodeIgniter
+ *
+ * An open source application development framework for PHP 5.1.6 or newer
+ *
+ * @package            CodeIgniter
+ * @author             ExpressionEngine Dev Team
+ * @copyright  Copyright (c) 2008 - 2011, EllisLab, Inc.
+ * @license            http://codeigniter.com/user_guide/license.html
+ * @link               http://codeigniter.com
+ * @since              Version 1.0
+ * @filesource
+ */
+
+// ------------------------------------------------------------------------
+
+/**
+ * Database Driver Class
+ *
+ * This is the platform-independent base DB implementation class.
+ * This class will not be called directly. Rather, the adapter
+ * class for the specific database will extend and instantiate it.
+ *
+ * @package            CodeIgniter
+ * @subpackage Drivers
+ * @category   Database
+ * @author             ExpressionEngine Dev Team
+ * @link               http://codeigniter.com/user_guide/database/
+ */
+class CI_DB_driver {
+
+       var $username;
+       var $password;
+       var $hostname;
+       var $database;
+       var $dbdriver           = 'mysql';
+       var $dbprefix           = '';
+       var $char_set           = 'utf8';
+       var $dbcollat           = 'utf8_general_ci';
+       var $autoinit           = TRUE; // Whether to automatically initialize the DB
+       var $swap_pre           = '';
+       var $port                       = '';
+       var $pconnect           = FALSE;
+       var $conn_id            = FALSE;
+       var $result_id          = FALSE;
+       var $db_debug           = FALSE;
+       var $benchmark          = 0;
+       var $query_count        = 0;
+       var $bind_marker        = '?';
+       var $save_queries       = TRUE;
+       var $queries            = array();
+       var $query_times        = array();
+       var $data_cache         = array();
+       var $trans_enabled      = TRUE;
+       var $trans_strict       = TRUE;
+       var $_trans_depth       = 0;
+       var $_trans_status      = TRUE; // Used with transactions to determine if a rollback should occur
+       var $cache_on           = FALSE;
+       var $cachedir           = '';
+       var $cache_autodel      = FALSE;
+       var $CACHE; // The cache class object
+
+       // Private variables
+       var $_protect_identifiers       = TRUE;
+       var $_reserved_identifiers      = array('*'); // Identifiers that should NOT be escaped
+
+       // These are use with Oracle
+       var $stmt_id;
+       var $curs_id;
+       var $limit_used;
+
+
+
+       /**
+        * Constructor.  Accepts one parameter containing the database
+        * connection settings.
+        *
+        * @param array
+        */
+       function CI_DB_driver($params)
+       {
+               if (is_array($params))
+               {
+                       foreach ($params as $key => $val)
+                       {
+                               $this->$key = $val;
+                       }
+               }
+
+               log_message('debug', 'Database Driver Class Initialized');
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Initialize Database Settings
+        *
+        * @access      private Called by the constructor
+        * @param       mixed
+        * @return      void
+        */
+       function initialize()
+       {
+               // If an existing connection resource is available
+               // there is no need to connect and select the database
+               if (is_resource($this->conn_id) OR is_object($this->conn_id))
+               {
+                       return TRUE;
+               }
+
+               // ----------------------------------------------------------------
+
+               // Connect to the database and set the connection ID
+               $this->conn_id = ($this->pconnect == FALSE) ? $this->db_connect() : $this->db_pconnect();
+
+               // No connection resource?  Throw an error
+               if ( ! $this->conn_id)
+               {
+                       log_message('error', 'Unable to connect to the database');
+
+                       if ($this->db_debug)
+                       {
+                               $this->display_error('db_unable_to_connect');
+                       }
+                       return FALSE;
+               }
+
+               // ----------------------------------------------------------------
+
+               // Select the DB... assuming a database name is specified in the config file
+               if ($this->database != '')
+               {
+                       if ( ! $this->db_select())
+                       {
+                               log_message('error', 'Unable to select database: '.$this->database);
+
+                               if ($this->db_debug)
+                               {
+                                       $this->display_error('db_unable_to_select', $this->database);
+                               }
+                               return FALSE;
+                       }
+                       else
+                       {
+                               // We've selected the DB. Now we set the character set
+                               if ( ! $this->db_set_charset($this->char_set, $this->dbcollat))
+                               {
+                                       return FALSE;
+                               }
+
+                               return TRUE;
+                       }
+               }
+
+               return TRUE;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Set client character set
+        *
+        * @access      public
+        * @param       string
+        * @param       string
+        * @return      resource
+        */
+       function db_set_charset($charset, $collation)
+       {
+               if ( ! $this->_db_set_charset($this->char_set, $this->dbcollat))
+               {
+                       log_message('error', 'Unable to set database connection charset: '.$this->char_set);
+
+                       if ($this->db_debug)
+                       {
+                               $this->display_error('db_unable_to_set_charset', $this->char_set);
+                       }
+
+                       return FALSE;
+               }
+
+               return TRUE;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * The name of the platform in use (mysql, mssql, etc...)
+        *
+        * @access      public
+        * @return      string
+        */
+       function platform()
+       {
+               return $this->dbdriver;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Database Version Number.  Returns a string containing the
+        * version of the database being used
+        *
+        * @access      public
+        * @return      string
+        */
+       function version()
+       {
+               if (FALSE === ($sql = $this->_version()))
+               {
+                       if ($this->db_debug)
+                       {
+                               return $this->display_error('db_unsupported_function');
+                       }
+                       return FALSE;
+               }
+
+               // 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');
+
+               if (in_array($this->dbdriver, $driver_version_exceptions))
+               {
+                       return $sql;
+               }
+               else
+               {
+                       $query = $this->query($sql);
+                       return $query->row('ver');
+               }
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Execute the query
+        *
+        * Accepts an SQL string as input and returns a result object upon
+        * successful execution of a "read" type query.  Returns boolean TRUE
+        * upon successful execution of a "write" type query. Returns boolean
+        * FALSE upon failure, and if the $db_debug variable is set to TRUE
+        * will raise an error.
+        *
+        * @access      public
+        * @param       string  An SQL query string
+        * @param       array   An array of binding data
+        * @return      mixed
+        */
+       function query($sql, $binds = FALSE, $return_object = TRUE)
+       {
+               if ($sql == '')
+               {
+                       if ($this->db_debug)
+                       {
+                               log_message('error', 'Invalid query: '.$sql);
+                               return $this->display_error('db_invalid_query');
+                       }
+                       return FALSE;
+               }
+
+               // Verify table prefix and replace if necessary
+               if ( ($this->dbprefix != '' AND $this->swap_pre != '') AND ($this->dbprefix != $this->swap_pre) )
+               {
+                       $sql = preg_replace("/(\W)".$this->swap_pre."(\S+?)/", "\\1".$this->dbprefix."\\2", $sql);
+               }
+
+               // Is query caching enabled?  If the query is a "read type"
+               // we will load the caching class and return the previously
+               // cached query if it exists
+               if ($this->cache_on == TRUE AND stristr($sql, 'SELECT'))
+               {
+                       if ($this->_cache_init())
+                       {
+                               $this->load_rdriver();
+                               if (FALSE !== ($cache = $this->CACHE->read($sql)))
+                               {
+                                       return $cache;
+                               }
+                       }
+               }
+
+               // Compile binds if needed
+               if ($binds !== FALSE)
+               {
+                       $sql = $this->compile_binds($sql, $binds);
+               }
+
+               // Save the  query for debugging
+               if ($this->save_queries == TRUE)
+               {
+                       $this->queries[] = $sql;
+               }
+
+               // Start the Query Timer
+               $time_start = list($sm, $ss) = explode(' ', microtime());
+
+               // Run the Query
+               if (FALSE === ($this->result_id = $this->simple_query($sql)))
+               {
+                       if ($this->save_queries == TRUE)
+                       {
+                               $this->query_times[] = 0;
+                       }
+
+                       // This will trigger a rollback if transactions are being used
+                       $this->_trans_status = FALSE;
+
+                       if ($this->db_debug)
+                       {
+                               // grab the error number and message now, as we might run some
+                               // additional queries before displaying the error
+                               $error_no = $this->_error_number();
+                               $error_msg = $this->_error_message();
+
+                               // We call this function in order to roll-back queries
+                               // if transactions are enabled.  If we don't call this here
+                               // the error message will trigger an exit, causing the
+                               // transactions to remain in limbo.
+                               $this->trans_complete();
+
+                               // Log and display errors
+                               log_message('error', 'Query error: '.$error_msg);
+                               return $this->display_error(
+                                                                               array(
+                                                                                               'Error Number: '.$error_no,
+                                                                                               $error_msg,
+                                                                                               $sql
+                                                                                       )
+                                                                               );
+                       }
+
+                       return FALSE;
+               }
+
+               // Stop and aggregate the query time results
+               $time_end = list($em, $es) = explode(' ', microtime());
+               $this->benchmark += ($em + $es) - ($sm + $ss);
+
+               if ($this->save_queries == TRUE)
+               {
+                       $this->query_times[] = ($em + $es) - ($sm + $ss);
+               }
+
+               // Increment the query counter
+               $this->query_count++;
+
+               // Was the query a "write" type?
+               // If so we'll simply return true
+               if ($this->is_write_type($sql) === TRUE)
+               {
+                       // If caching is enabled we'll auto-cleanup any
+                       // existing files related to this particular URI
+                       if ($this->cache_on == TRUE AND $this->cache_autodel == TRUE AND $this->_cache_init())
+                       {
+                               $this->CACHE->delete();
+                       }
+
+                       return TRUE;
+               }
+
+               // Return TRUE if we don't need to create a result object
+               // Currently only the Oracle driver uses this when stored
+               // procedures are used
+               if ($return_object !== TRUE)
+               {
+                       return TRUE;
+               }
+
+               // Load and instantiate the result driver
+
+               $driver                 = $this->load_rdriver();
+               $RES                    = new $driver();
+               $RES->conn_id   = $this->conn_id;
+               $RES->result_id = $this->result_id;
+
+               if ($this->dbdriver == 'oci8')
+               {
+                       $RES->stmt_id           = $this->stmt_id;
+                       $RES->curs_id           = NULL;
+                       $RES->limit_used        = $this->limit_used;
+                       $this->stmt_id          = FALSE;
+               }
+
+               // oci8 vars must be set before calling this
+               $RES->num_rows  = $RES->num_rows();
+
+               // Is query caching enabled?  If so, we'll serialize the
+               // result object and save it to a cache file.
+               if ($this->cache_on == TRUE AND $this->_cache_init())
+               {
+                       // We'll create a new instance of the result object
+                       // only without the platform specific driver since
+                       // we can't use it with cached data (the query result
+                       // resource ID won't be any good once we've cached the
+                       // result object, so we'll have to compile the data
+                       // and save it)
+                       $CR = new CI_DB_result();
+                       $CR->num_rows           = $RES->num_rows();
+                       $CR->result_object      = $RES->result_object();
+                       $CR->result_array       = $RES->result_array();
+
+                       // Reset these since cached objects can not utilize resource IDs.
+                       $CR->conn_id            = NULL;
+                       $CR->result_id          = NULL;
+
+                       $this->CACHE->write($sql, $CR);
+               }
+
+               return $RES;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Load the result drivers
+        *
+        * @access      public
+        * @return      string  the name of the result class
+        */
+       function load_rdriver()
+       {
+               $driver = 'CI_DB_'.$this->dbdriver.'_result';
+
+               if ( ! class_exists($driver))
+               {
+                       include_once(BASEPATH.'database/DB_result'.EXT);
+                       include_once(BASEPATH.'database/drivers/'.$this->dbdriver.'/'.$this->dbdriver.'_result'.EXT);
+               }
+
+               return $driver;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Simple Query
+        * This is a simplified version of the query() function.  Internally
+        * we only use it when running transaction commands since they do
+        * not require all the features of the main query() function.
+        *
+        * @access      public
+        * @param       string  the sql query
+        * @return      mixed
+        */
+       function simple_query($sql)
+       {
+               if ( ! $this->conn_id)
+               {
+                       $this->initialize();
+               }
+
+               return $this->_execute($sql);
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Disable Transactions
+        * This permits transactions to be disabled at run-time.
+        *
+        * @access      public
+        * @return      void
+        */
+       function trans_off()
+       {
+               $this->trans_enabled = FALSE;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Enable/disable Transaction Strict Mode
+        * When strict mode is enabled, if you are running multiple groups of
+        * transactions, if one group fails all groups will be rolled back.
+        * If strict mode is disabled, each group is treated autonomously, meaning
+        * a failure of one group will not affect any others
+        *
+        * @access      public
+        * @return      void
+        */
+       function trans_strict($mode = TRUE)
+       {
+               $this->trans_strict = is_bool($mode) ? $mode : TRUE;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Start Transaction
+        *
+        * @access      public
+        * @return      void
+        */
+       function trans_start($test_mode = FALSE)
+       {
+               if ( ! $this->trans_enabled)
+               {
+                       return FALSE;
+               }
+
+               // When transactions are nested we only begin/commit/rollback the outermost ones
+               if ($this->_trans_depth > 0)
+               {
+                       $this->_trans_depth += 1;
+                       return;
+               }
+
+               $this->trans_begin($test_mode);
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Complete Transaction
+        *
+        * @access      public
+        * @return      bool
+        */
+       function trans_complete()
+       {
+               if ( ! $this->trans_enabled)
+               {
+                       return FALSE;
+               }
+
+               // When transactions are nested we only begin/commit/rollback the outermost ones
+               if ($this->_trans_depth > 1)
+               {
+                       $this->_trans_depth -= 1;
+                       return TRUE;
+               }
+
+               // The query() function will set this flag to FALSE in the event that a query failed
+               if ($this->_trans_status === FALSE)
+               {
+                       $this->trans_rollback();
+
+                       // If we are NOT running in strict mode, we will reset
+                       // the _trans_status flag so that subsequent groups of transactions
+                       // will be permitted.
+                       if ($this->trans_strict === FALSE)
+                       {
+                               $this->_trans_status = TRUE;
+                       }
+
+                       log_message('debug', 'DB Transaction Failure');
+                       return FALSE;
+               }
+
+               $this->trans_commit();
+               return TRUE;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Lets you retrieve the transaction flag to determine if it has failed
+        *
+        * @access      public
+        * @return      bool
+        */
+       function trans_status()
+       {
+               return $this->_trans_status;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Compile Bindings
+        *
+        * @access      public
+        * @param       string  the sql statement
+        * @param       array   an array of bind data
+        * @return      string
+        */
+       function compile_binds($sql, $binds)
+       {
+               if (strpos($sql, $this->bind_marker) === FALSE)
+               {
+                       return $sql;
+               }
+
+               if ( ! is_array($binds))
+               {
+                       $binds = array($binds);
+               }
+
+               // Get the sql segments around the bind markers
+               $segments = explode($this->bind_marker, $sql);
+
+               // The count of bind should be 1 less then the count of segments
+               // If there are more bind arguments trim it down
+               if (count($binds) >= count($segments)) {
+                       $binds = array_slice($binds, 0, count($segments)-1);
+               }
+
+               // Construct the binded query
+               $result = $segments[0];
+               $i = 0;
+               foreach ($binds as $bind)
+               {
+                       $result .= $this->escape($bind);
+                       $result .= $segments[++$i];
+               }
+
+               return $result;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Determines if a query is a "write" type.
+        *
+        * @access      public
+        * @param       string  An SQL query string
+        * @return      boolean
+        */
+       function is_write_type($sql)
+       {
+               if ( ! preg_match('/^\s*"?(SET|INSERT|UPDATE|DELETE|REPLACE|CREATE|DROP|TRUNCATE|LOAD DATA|COPY|ALTER|GRANT|REVOKE|LOCK|UNLOCK)\s+/i', $sql))
+               {
+                       return FALSE;
+               }
+               return TRUE;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Calculate the aggregate query elapsed time
+        *
+        * @access      public
+        * @param       integer The number of decimal places
+        * @return      integer
+        */
+       function elapsed_time($decimals = 6)
+       {
+               return number_format($this->benchmark, $decimals);
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Returns the total number of queries
+        *
+        * @access      public
+        * @return      integer
+        */
+       function total_queries()
+       {
+               return $this->query_count;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Returns the last query that was executed
+        *
+        * @access      public
+        * @return      void
+        */
+       function last_query()
+       {
+               return end($this->queries);
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * "Smart" Escape String
+        *
+        * Escapes data based on type
+        * Sets boolean and null types
+        *
+        * @access      public
+        * @param       string
+        * @return      mixed
+        */
+       function escape($str)
+       {
+               if (is_string($str))
+               {
+                       $str = "'".$this->escape_str($str)."'";
+               }
+               elseif (is_bool($str))
+               {
+                       $str = ($str === FALSE) ? 0 : 1;
+               }
+               elseif (is_null($str))
+               {
+                       $str = 'NULL';
+               }
+
+               return $str;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Escape LIKE String
+        *
+        * Calls the individual driver for platform
+        * specific escaping for LIKE conditions
+        *
+        * @access      public
+        * @param       string
+        * @return      mixed
+        */
+       function escape_like_str($str)
+       {
+               return $this->escape_str($str, TRUE);
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Primary
+        *
+        * Retrieves the primary key.  It assumes that the row in the first
+        * position is the primary key
+        *
+        * @access      public
+        * @param       string  the table name
+        * @return      string
+        */
+       function primary($table = '')
+       {
+               $fields = $this->list_fields($table);
+
+               if ( ! is_array($fields))
+               {
+                       return FALSE;
+               }
+
+               return current($fields);
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Returns an array of table names
+        *
+        * @access      public
+        * @return      array
+        */
+       function list_tables($constrain_by_prefix = FALSE)
+       {
+               // Is there a cached result?
+               if (isset($this->data_cache['table_names']))
+               {
+                       return $this->data_cache['table_names'];
+               }
+
+               if (FALSE === ($sql = $this->_list_tables($constrain_by_prefix)))
+               {
+                       if ($this->db_debug)
+                       {
+                               return $this->display_error('db_unsupported_function');
+                       }
+                       return FALSE;
+               }
+
+               $retval = array();
+               $query = $this->query($sql);
+
+               if ($query->num_rows() > 0)
+               {
+                       foreach ($query->result_array() as $row)
+                       {
+                               if (isset($row['TABLE_NAME']))
+                               {
+                                       $retval[] = $row['TABLE_NAME'];
+                               }
+                               else
+                               {
+                                       $retval[] = array_shift($row);
+                               }
+                       }
+               }
+
+               $this->data_cache['table_names'] = $retval;
+               return $this->data_cache['table_names'];
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Determine if a particular table exists
+        * @access      public
+        * @return      boolean
+        */
+       function table_exists($table_name)
+       {
+               return ( ! in_array($this->_protect_identifiers($table_name, TRUE, FALSE, FALSE), $this->list_tables())) ? FALSE : TRUE;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Fetch MySQL Field Names
+        *
+        * @access      public
+        * @param       string  the table name
+        * @return      array
+        */
+       function list_fields($table = '')
+       {
+               // Is there a cached result?
+               if (isset($this->data_cache['field_names'][$table]))
+               {
+                       return $this->data_cache['field_names'][$table];
+               }
+
+               if ($table == '')
+               {
+                       if ($this->db_debug)
+                       {
+                               return $this->display_error('db_field_param_missing');
+                       }
+                       return FALSE;
+               }
+
+               if (FALSE === ($sql = $this->_list_columns($table)))
+               {
+                       if ($this->db_debug)
+                       {
+                               return $this->display_error('db_unsupported_function');
+                       }
+                       return FALSE;
+               }
+
+               $query = $this->query($sql);
+
+               $retval = array();
+               foreach ($query->result_array() as $row)
+               {
+                       if (isset($row['COLUMN_NAME']))
+                       {
+                               $retval[] = $row['COLUMN_NAME'];
+                       }
+                       else
+                       {
+                               $retval[] = current($row);
+                       }
+               }
+
+               $this->data_cache['field_names'][$table] = $retval;
+               return $this->data_cache['field_names'][$table];
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Determine if a particular field exists
+        * @access      public
+        * @param       string
+        * @param       string
+        * @return      boolean
+        */
+       function field_exists($field_name, $table_name)
+       {
+               return ( ! in_array($field_name, $this->list_fields($table_name))) ? FALSE : TRUE;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Returns an object with field data
+        *
+        * @access      public
+        * @param       string  the table name
+        * @return      object
+        */
+       function field_data($table = '')
+       {
+               if ($table == '')
+               {
+                       if ($this->db_debug)
+                       {
+                               return $this->display_error('db_field_param_missing');
+                       }
+                       return FALSE;
+               }
+
+               $query = $this->query($this->_field_data($this->_protect_identifiers($table, TRUE, NULL, FALSE)));
+
+               return $query->field_data();
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Generate an insert string
+        *
+        * @access      public
+        * @param       string  the table upon which the query will be performed
+        * @param       array   an associative array data of key/values
+        * @return      string
+        */
+       function insert_string($table, $data)
+       {
+               $fields = array();
+               $values = array();
+
+               foreach ($data as $key => $val)
+               {
+                       $fields[] = $this->_escape_identifiers($key);
+                       $values[] = $this->escape($val);
+               }
+
+               return $this->_insert($this->_protect_identifiers($table, TRUE, NULL, FALSE), $fields, $values);
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Generate an update string
+        *
+        * @access      public
+        * @param       string  the table upon which the query will be performed
+        * @param       array   an associative array data of key/values
+        * @param       mixed   the "where" statement
+        * @return      string
+        */
+       function update_string($table, $data, $where)
+       {
+               if ($where == '')
+               {
+                       return false;
+               }
+
+               $fields = array();
+               foreach ($data as $key => $val)
+               {
+                       $fields[$this->_protect_identifiers($key)] = $this->escape($val);
+               }
+
+               if ( ! is_array($where))
+               {
+                       $dest = array($where);
+               }
+               else
+               {
+                       $dest = array();
+                       foreach ($where as $key => $val)
+                       {
+                               $prefix = (count($dest) == 0) ? '' : ' AND ';
+
+                               if ($val !== '')
+                               {
+                                       if ( ! $this->_has_operator($key))
+                                       {
+                                               $key .= ' =';
+                                       }
+
+                                       $val = ' '.$this->escape($val);
+                               }
+
+                               $dest[] = $prefix.$key.$val;
+                       }
+               }
+
+               return $this->_update($this->_protect_identifiers($table, TRUE, NULL, FALSE), $fields, $dest);
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Tests whether the string has an SQL operator
+        *
+        * @access      private
+        * @param       string
+        * @return      bool
+        */
+       function _has_operator($str)
+       {
+               $str = trim($str);
+               if ( ! preg_match("/(\s|<|>|!|=|is null|is not null)/i", $str))
+               {
+                       return FALSE;
+               }
+
+               return TRUE;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Enables a native PHP function to be run, using a platform agnostic wrapper.
+        *
+        * @access      public
+        * @param       string  the function name
+        * @param       mixed   any parameters needed by the function
+        * @return      mixed
+        */
+       function call_function($function)
+       {
+               $driver = ($this->dbdriver == 'postgre') ? 'pg_' : $this->dbdriver.'_';
+
+               if (FALSE === strpos($driver, $function))
+               {
+                       $function = $driver.$function;
+               }
+
+               if ( ! function_exists($function))
+               {
+                       if ($this->db_debug)
+                       {
+                               return $this->display_error('db_unsupported_function');
+                       }
+                       return FALSE;
+               }
+               else
+               {
+                       $args = (func_num_args() > 1) ? array_splice(func_get_args(), 1) : null;
+
+                       return call_user_func_array($function, $args);
+               }
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Set Cache Directory Path
+        *
+        * @access      public
+        * @param       string  the path to the cache directory
+        * @return      void
+        */
+       function cache_set_path($path = '')
+       {
+               $this->cachedir = $path;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Enable Query Caching
+        *
+        * @access      public
+        * @return      void
+        */
+       function cache_on()
+       {
+               $this->cache_on = TRUE;
+               return TRUE;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Disable Query Caching
+        *
+        * @access      public
+        * @return      void
+        */
+       function cache_off()
+       {
+               $this->cache_on = FALSE;
+               return FALSE;
+       }
+
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Delete the cache files associated with a particular URI
+        *
+        * @access      public
+        * @return      void
+        */
+       function cache_delete($segment_one = '', $segment_two = '')
+       {
+               if ( ! $this->_cache_init())
+               {
+                       return FALSE;
+               }
+               return $this->CACHE->delete($segment_one, $segment_two);
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Delete All cache files
+        *
+        * @access      public
+        * @return      void
+        */
+       function cache_delete_all()
+       {
+               if ( ! $this->_cache_init())
+               {
+                       return FALSE;
+               }
+
+               return $this->CACHE->delete_all();
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Initialize the Cache Class
+        *
+        * @access      private
+        * @return      void
+        */
+       function _cache_init()
+       {
+               if (is_object($this->CACHE) AND class_exists('CI_DB_Cache'))
+               {
+                       return TRUE;
+               }
+
+               if ( ! class_exists('CI_DB_Cache'))
+               {
+                       if ( ! @include(BASEPATH.'database/DB_cache'.EXT))
+                       {
+                               return $this->cache_off();
+                       }
+               }
+
+               $this->CACHE = new CI_DB_Cache($this); // pass db object to support multiple db connections and returned db objects
+               return TRUE;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Close DB Connection
+        *
+        * @access      public
+        * @return      void
+        */
+       function close()
+       {
+               if (is_resource($this->conn_id) OR is_object($this->conn_id))
+               {
+                       $this->_close($this->conn_id);
+               }
+               $this->conn_id = FALSE;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Display an error message
+        *
+        * @access      public
+        * @param       string  the error message
+        * @param       string  any "swap" values
+        * @param       boolean whether to localize the message
+        * @return      string  sends the application/error_db.php template
+        */
+       function display_error($error = '', $swap = '', $native = FALSE)
+       {
+               $LANG =& load_class('Lang', 'core');
+               $LANG->load('db');
+
+               $heading = $LANG->line('db_error_heading');
+
+               if ($native == TRUE)
+               {
+                       $message = $error;
+               }
+               else
+               {
+                       $message = ( ! is_array($error)) ? array(str_replace('%s', $swap, $LANG->line($error))) : $error;
+               }
+
+               // Find the most likely culprit of the error by going through
+               // the backtrace until the source file is no longer in the
+               // database folder.
+
+               $trace = debug_backtrace();
+
+               foreach ($trace as $call)
+               {
+                       if (isset($call['file']) && strpos($call['file'], BASEPATH.'database') === FALSE)
+                       {
+                               // Found it - use a relative path for safety
+                               $message[] = 'Filename: '.str_replace(array(BASEPATH, APPPATH), '', $call['file']);
+                               $message[] = 'Line Number: '.$call['line'];
+
+                               break;
+                       }
+               }
+
+               $error =& load_class('Exceptions', 'core');
+               echo $error->show_error($heading, $message, 'error_db');
+               exit;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Protect Identifiers
+        *
+        * This function adds backticks if appropriate based on db type
+        *
+        * @access      private
+        * @param       mixed   the item to escape
+        * @return      mixed   the item with backticks
+        */
+       function protect_identifiers($item, $prefix_single = FALSE)
+       {
+               return $this->_protect_identifiers($item, $prefix_single);
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Protect Identifiers
+        *
+        * This function is used extensively by the Active Record class, and by
+        * a couple functions in this class.
+        * It takes a column or table name (optionally with an alias) and inserts
+        * the table prefix onto it.  Some logic is necessary in order to deal with
+        * column names that include the path.  Consider a query like this:
+        *
+        * SELECT * FROM hostname.database.table.column AS c FROM hostname.database.table
+        *
+        * Or a query with aliasing:
+        *
+        * SELECT m.member_id, m.member_name FROM members AS m
+        *
+        * Since the column name can include up to four segments (host, DB, table, column)
+        * or also have an alias prefix, we need to do a bit of work to figure this out and
+        * insert the table prefix (if it exists) in the proper position, and escape only
+        * the correct identifiers.
+        *
+        * @access      private
+        * @param       string
+        * @param       bool
+        * @param       mixed
+        * @param       bool
+        * @return      string
+        */
+       function _protect_identifiers($item, $prefix_single = FALSE, $protect_identifiers = NULL, $field_exists = TRUE)
+       {
+               if ( ! is_bool($protect_identifiers))
+               {
+                       $protect_identifiers = $this->_protect_identifiers;
+               }
+
+               if (is_array($item))
+               {
+                       $escaped_array = array();
+
+                       foreach ($item as $k => $v)
+                       {
+                               $escaped_array[$this->_protect_identifiers($k)] = $this->_protect_identifiers($v);
+                       }
+
+                       return $escaped_array;
+               }
+
+               // Convert tabs or multiple spaces into single spaces
+               $item = preg_replace('/[\t ]+/', ' ', $item);
+
+               // If the item has an alias declaration we remove it and set it aside.
+               // Basically we remove everything to the right of the first space
+               $alias = '';
+               if (strpos($item, ' ') !== FALSE)
+               {
+                       $alias = strstr($item, " ");
+                       $item = substr($item, 0, - strlen($alias));
+               }
+
+               // This is basically a bug fix for queries that use MAX, MIN, etc.
+               // If a parenthesis is found we know that we do not need to
+               // escape the data or add a prefix.  There's probably a more graceful
+               // way to deal with this, but I'm not thinking of it -- Rick
+               if (strpos($item, '(') !== FALSE)
+               {
+                       return $item.$alias;
+               }
+
+               // Break the string apart if it contains periods, then insert the table prefix
+               // in the correct location, assuming the period doesn't indicate that we're dealing
+               // with an alias. While we're at it, we will escape the components
+               if (strpos($item, '.') !== FALSE)
+               {
+                       $parts  = explode('.', $item);
+
+                       // Does the first segment of the exploded item match
+                       // one of the aliases previously identified?  If so,
+                       // we have nothing more to do other than escape the item
+                       if (in_array($parts[0], $this->ar_aliased_tables))
+                       {
+                               if ($protect_identifiers === TRUE)
+                               {
+                                       foreach ($parts as $key => $val)
+                                       {
+                                               if ( ! in_array($val, $this->_reserved_identifiers))
+                                               {
+                                                       $parts[$key] = $this->_escape_identifiers($val);
+                                               }
+                                       }
+
+                                       $item = implode('.', $parts);
+                               }
+                               return $item.$alias;
+                       }
+
+                       // Is there a table prefix defined in the config file?  If not, no need to do anything
+                       if ($this->dbprefix != '')
+                       {
+                               // We now add the table prefix based on some logic.
+                               // Do we have 4 segments (hostname.database.table.column)?
+                               // If so, we add the table prefix to the column name in the 3rd segment.
+                               if (isset($parts[3]))
+                               {
+                                       $i = 2;
+                               }
+                               // Do we have 3 segments (database.table.column)?
+                               // If so, we add the table prefix to the column name in 2nd position
+                               elseif (isset($parts[2]))
+                               {
+                                       $i = 1;
+                               }
+                               // Do we have 2 segments (table.column)?
+                               // If so, we add the table prefix to the column name in 1st segment
+                               else
+                               {
+                                       $i = 0;
+                               }
+
+                               // This flag is set when the supplied $item does not contain a field name.
+                               // This can happen when this function is being called from a JOIN.
+                               if ($field_exists == FALSE)
+                               {
+                                       $i++;
+                               }
+
+                               // Verify table prefix and replace if necessary
+                               if ($this->swap_pre != '' && strncmp($parts[$i], $this->swap_pre, strlen($this->swap_pre)) === 0)
+                               {
+                                       $parts[$i] = preg_replace("/^".$this->swap_pre."(\S+?)/", $this->dbprefix."\\1", $parts[$i]);
+                               }
+
+                               // We only add the table prefix if it does not already exist
+                               if (substr($parts[$i], 0, strlen($this->dbprefix)) != $this->dbprefix)
+                               {
+                                       $parts[$i] = $this->dbprefix.$parts[$i];
+                               }
+
+                               // Put the parts back together
+                               $item = implode('.', $parts);
+                       }
+
+                       if ($protect_identifiers === TRUE)
+                       {
+                               $item = $this->_escape_identifiers($item);
+                       }
+
+                       return $item.$alias;
+               }
+
+               // Is there a table prefix?  If not, no need to insert it
+               if ($this->dbprefix != '')
+               {
+                       // Verify table prefix and replace if necessary
+                       if ($this->swap_pre != '' && strncmp($item, $this->swap_pre, strlen($this->swap_pre)) === 0)
+                       {
+                               $item = preg_replace("/^".$this->swap_pre."(\S+?)/", $this->dbprefix."\\1", $item);
+                       }
+
+                       // Do we prefix an item with no segments?
+                       if ($prefix_single == TRUE AND substr($item, 0, strlen($this->dbprefix)) != $this->dbprefix)
+                       {
+                               $item = $this->dbprefix.$item;
+                       }
+               }
+
+               if ($protect_identifiers === TRUE AND ! in_array($item, $this->_reserved_identifiers))
+               {
+                       $item = $this->_escape_identifiers($item);
+               }
+
+               return $item.$alias;
+       }
+
+
+}
+
+
+/* End of file DB_driver.php */
+/* Location: ./system/database/DB_driver.php */
\ No newline at end of file
diff --git a/system/database/DB_forge.php b/system/database/DB_forge.php
new file mode 100755 (executable)
index 0000000..a71fca7
--- /dev/null
@@ -0,0 +1,382 @@
+<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+/**
+ * Code Igniter
+ *
+ * An open source application development framework for PHP 5.1.6 or newer
+ *
+ * @package            CodeIgniter
+ * @author             ExpressionEngine Dev Team
+ * @copyright  Copyright (c) 2008 - 2011, EllisLab, Inc.
+ * @license            http://codeigniter.com/user_guide/license.html
+ * @link               http://codeigniter.com
+ * @since              Version 1.0
+ * @filesource
+ */
+
+// ------------------------------------------------------------------------
+
+/**
+ * Database Utility Class
+ *
+ * @category   Database
+ * @author             ExpressionEngine Dev Team
+ * @link               http://codeigniter.com/user_guide/database/
+ */
+class CI_DB_forge {
+
+       var $fields                     = array();
+       var $keys                       = array();
+       var $primary_keys       = array();
+       var $db_char_set        =       '';
+
+       /**
+        * Constructor
+        *
+        * Grabs the CI super object instance so we can access it.
+        *
+        */
+       function CI_DB_forge()
+       {
+               // Assign the main database object to $this->db
+               $CI =& get_instance();
+               $this->db =& $CI->db;
+               log_message('debug', "Database Forge Class Initialized");
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Create database
+        *
+        * @access      public
+        * @param       string  the database name
+        * @return      bool
+        */
+       function create_database($db_name)
+       {
+               $sql = $this->_create_database($db_name);
+
+               if (is_bool($sql))
+               {
+                       return $sql;
+               }
+
+               return $this->db->query($sql);
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Drop database
+        *
+        * @access      public
+        * @param       string  the database name
+        * @return      bool
+        */
+       function drop_database($db_name)
+       {
+               $sql = $this->_drop_database($db_name);
+
+               if (is_bool($sql))
+               {
+                       return $sql;
+               }
+
+               return $this->db->query($sql);
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Add Key
+        *
+        * @access      public
+        * @param       string  key
+        * @param       string  type
+        * @return      void
+        */
+       function add_key($key = '', $primary = FALSE)
+       {
+               if (is_array($key))
+               {
+                       foreach ($key as $one)
+                       {
+                               $this->add_key($one, $primary);
+                       }
+
+                       return;
+               }
+
+               if ($key == '')
+               {
+                       show_error('Key information is required for that operation.');
+               }
+
+               if ($primary === TRUE)
+               {
+                       $this->primary_keys[] = $key;
+               }
+               else
+               {
+                       $this->keys[] = $key;
+               }
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Add Field
+        *
+        * @access      public
+        * @param       string  collation
+        * @return      void
+        */
+       function add_field($field = '')
+       {
+               if ($field == '')
+               {
+                       show_error('Field information is required.');
+               }
+
+               if (is_string($field))
+               {
+                       if ($field == 'id')
+                       {
+                               $this->add_field(array(
+                                                                               'id' => array(
+                                                                                                       'type' => 'INT',
+                                                                                                       'constraint' => 9,
+                                                                                                       'auto_increment' => TRUE
+                                                                                                       )
+                                                               ));
+                               $this->add_key('id', TRUE);
+                       }
+                       else
+                       {
+                               if (strpos($field, ' ') === FALSE)
+                               {
+                                       show_error('Field information is required for that operation.');
+                               }
+
+                               $this->fields[] = $field;
+                       }
+               }
+
+               if (is_array($field))
+               {
+                       $this->fields = array_merge($this->fields, $field);
+               }
+
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Create Table
+        *
+        * @access      public
+        * @param       string  the table name
+        * @return      bool
+        */
+       function create_table($table = '', $if_not_exists = FALSE)
+       {
+               if ($table == '')
+               {
+                       show_error('A table name is required for that operation.');
+               }
+
+               if (count($this->fields) == 0)
+               {
+                       show_error('Field information is required.');
+               }
+
+               $sql = $this->_create_table($this->db->dbprefix.$table, $this->fields, $this->primary_keys, $this->keys, $if_not_exists);
+
+               $this->_reset();
+               return $this->db->query($sql);
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Drop Table
+        *
+        * @access      public
+        * @param       string  the table name
+        * @return      bool
+        */
+       function drop_table($table_name)
+       {
+               $sql = $this->_drop_table($this->db->dbprefix.$table_name);
+
+               if (is_bool($sql))
+               {
+                       return $sql;
+               }
+
+               return $this->db->query($sql);
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Rename Table
+        *
+        * @access      public
+        * @param       string  the old table name
+        * @param       string  the new table name
+        * @return      bool
+        */
+       function rename_table($table_name, $new_table_name)
+       {
+               if ($table_name == '' OR $new_table_name == '')
+               {
+                       show_error('A table name is required for that operation.');
+               }
+
+               $sql = $this->_rename_table($table_name, $new_table_name);
+               return $this->db->query($sql);
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Column Add
+        *
+        * @access      public
+        * @param       string  the table name
+        * @param       string  the column name
+        * @param       string  the column definition
+        * @return      bool
+        */
+       function add_column($table = '', $field = array(), $after_field = '')
+       {
+               if ($table == '')
+               {
+                       show_error('A table name is required for that operation.');
+               }
+
+               // add field info into field array, but we can only do one at a time
+               // so we cycle through
+
+               foreach ($field as $k => $v)
+               {
+                       $this->add_field(array($k => $field[$k]));
+
+                       if (count($this->fields) == 0)
+                       {
+                               show_error('Field information is required.');
+                       }
+
+                       $sql = $this->_alter_table('ADD', $this->db->dbprefix.$table, $this->fields, $after_field);
+
+                       $this->_reset();
+
+                       if ($this->db->query($sql) === FALSE)
+                       {
+                               return FALSE;
+                       }
+               }
+
+               return TRUE;
+
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Column Drop
+        *
+        * @access      public
+        * @param       string  the table name
+        * @param       string  the column name
+        * @return      bool
+        */
+       function drop_column($table = '', $column_name = '')
+       {
+
+               if ($table == '')
+               {
+                       show_error('A table name is required for that operation.');
+               }
+
+               if ($column_name == '')
+               {
+                       show_error('A column name is required for that operation.');
+               }
+
+               $sql = $this->_alter_table('DROP', $this->db->dbprefix.$table, $column_name);
+
+               return $this->db->query($sql);
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Column Modify
+        *
+        * @access      public
+        * @param       string  the table name
+        * @param       string  the column name
+        * @param       string  the column definition
+        * @return      bool
+        */
+       function modify_column($table = '', $field = array())
+       {
+               if ($table == '')
+               {
+                       show_error('A table name is required for that operation.');
+               }
+
+               // add field info into field array, but we can only do one at a time
+               // so we cycle through
+
+               foreach ($field as $k => $v)
+               {
+                       // If no name provided, use the current name
+                       if ( ! isset($field[$k]['name']))
+                       {
+                               $field[$k]['name'] = $k;
+                       }
+
+                       $this->add_field(array($k => $field[$k]));
+
+                       if (count($this->fields) == 0)
+                       {
+                               show_error('Field information is required.');
+                       }
+
+                       $sql = $this->_alter_table('CHANGE', $this->db->dbprefix.$table, $this->fields);
+
+                       $this->_reset();
+
+                       if ($this->db->query($sql) === FALSE)
+                       {
+                               return FALSE;
+                       }
+               }
+
+               return TRUE;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Reset
+        *
+        * Resets table creation vars
+        *
+        * @access      private
+        * @return      void
+        */
+       function _reset()
+       {
+               $this->fields           = array();
+               $this->keys                     = array();
+               $this->primary_keys     = array();
+       }
+
+}
+
+/* End of file DB_forge.php */
+/* Location: ./system/database/DB_forge.php */
\ No newline at end of file
diff --git a/system/database/DB_result.php b/system/database/DB_result.php
new file mode 100755 (executable)
index 0000000..76e1d6a
--- /dev/null
@@ -0,0 +1,405 @@
+<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+/**
+ * CodeIgniter
+ *
+ * An open source application development framework for PHP 5.1.6 or newer
+ *
+ * @package            CodeIgniter
+ * @author             ExpressionEngine Dev Team
+ * @copyright  Copyright (c) 2008 - 2011, EllisLab, Inc.
+ * @license            http://codeigniter.com/user_guide/license.html
+ * @link               http://codeigniter.com
+ * @since              Version 1.0
+ * @filesource
+ */
+
+// ------------------------------------------------------------------------
+
+/**
+ * Database Result Class
+ *
+ * This is the platform-independent result class.
+ * This class will not be called directly. Rather, the adapter
+ * class for the specific database will extend and instantiate it.
+ *
+ * @category   Database
+ * @author             ExpressionEngine Dev Team
+ * @link               http://codeigniter.com/user_guide/database/
+ */
+class CI_DB_result {
+
+       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;
+
+
+       /**
+        * Query result.  Acts as a wrapper function for the following functions.
+        *
+        * @access      public
+        * @param       string  can be "object" or "array"
+        * @return      mixed   either a result object or array
+        */
+       function result($type = 'object')
+       {
+        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;
+    }
+
+       /**
+        * Query result.  "object" version.
+        *
+        * @access      public
+        * @return      object
+        */
+       function result_object()
+       {
+               if (count($this->result_object) > 0)
+               {
+                       return $this->result_object;
+               }
+
+               // In the event that query caching is on the result_id variable
+               // will return FALSE since there isn't a valid SQL resource so
+               // we'll simply return an empty array.
+               if ($this->result_id === FALSE OR $this->num_rows() == 0)
+               {
+                       return array();
+               }
+
+               $this->_data_seek(0);
+               while ($row = $this->_fetch_object())
+               {
+                       $this->result_object[] = $row;
+               }
+
+               return $this->result_object;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Query result.  "array" version.
+        *
+        * @access      public
+        * @return      array
+        */
+       function result_array()
+       {
+               if (count($this->result_array) > 0)
+               {
+                       return $this->result_array;
+               }
+
+               // In the event that query caching is on the result_id variable
+               // will return FALSE since there isn't a valid SQL resource so
+               // we'll simply return an empty array.
+               if ($this->result_id === FALSE OR $this->num_rows() == 0)
+               {
+                       return array();
+               }
+
+               $this->_data_seek(0);
+               while ($row = $this->_fetch_assoc())
+               {
+                       $this->result_array[] = $row;
+               }
+
+               return $this->result_array;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Query result.  Acts as a wrapper function for the following functions.
+        *
+        * @access      public
+        * @param       string
+        * @param       string  can be "object" or "array"
+        * @return      mixed   either a result object or array
+        */
+       function row($n = 0, $type = 'object')
+       {
+               if ( ! is_numeric($n))
+               {
+                       // We cache the row data for subsequent uses
+                       if ( ! is_array($this->row_data))
+                       {
+                               $this->row_data = $this->row_array(0);
+                       }
+
+                       // array_key_exists() instead of isset() to allow for MySQL NULL values
+                       if (array_key_exists($n, $this->row_data))
+                       {
+                               return $this->row_data[$n];
+                       }
+                       // reset the $n variable if the result was not achieved
+                       $n = 0;
+               }
+
+        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);
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Assigns an item into a particular column slot
+        *
+        * @access      public
+        * @return      object
+        */
+       function set_row($key, $value = NULL)
+       {
+               // We cache the row data for subsequent uses
+               if ( ! is_array($this->row_data))
+               {
+                       $this->row_data = $this->row_array(0);
+               }
+
+               if (is_array($key))
+               {
+                       foreach ($key as $k => $v)
+                       {
+                               $this->row_data[$k] = $v;
+                       }
+
+                       return;
+               }
+
+               if ($key != '' AND ! is_null($value))
+               {
+                       $this->row_data[$key] = $value;
+               }
+       }
+
+       // --------------------------------------------------------------------
+
+    /**
+        * 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
+        *
+        * @access      public
+        * @return      object
+        */
+       function row_object($n = 0)
+       {
+               $result = $this->result_object();
+
+               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 - array version
+        *
+        * @access      public
+        * @return      array
+        */
+       function row_array($n = 0)
+       {
+               $result = $this->result_array();
+
+               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 the "first" row
+        *
+        * @access      public
+        * @return      object
+        */
+       function first_row($type = 'object')
+       {
+               $result = $this->result($type);
+
+               if (count($result) == 0)
+               {
+                       return $result;
+               }
+               return $result[0];
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Returns the "last" row
+        *
+        * @access      public
+        * @return      object
+        */
+       function last_row($type = 'object')
+       {
+               $result = $this->result($type);
+
+               if (count($result) == 0)
+               {
+                       return $result;
+               }
+               return $result[count($result) -1];
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Returns the "next" row
+        *
+        * @access      public
+        * @return      object
+        */
+       function next_row($type = 'object')
+       {
+               $result = $this->result($type);
+
+               if (count($result) == 0)
+               {
+                       return $result;
+               }
+
+               if (isset($result[$this->current_row + 1]))
+               {
+                       ++$this->current_row;
+               }
+
+               return $result[$this->current_row];
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Returns the "previous" row
+        *
+        * @access      public
+        * @return      object
+        */
+       function previous_row($type = 'object')
+       {
+               $result = $this->result($type);
+
+               if (count($result) == 0)
+               {
+                       return $result;
+               }
+
+               if (isset($result[$this->current_row - 1]))
+               {
+                       --$this->current_row;
+               }
+               return $result[$this->current_row];
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * The following functions are normally overloaded by the identically named
+        * methods in the platform-specific driver -- except when query caching
+        * is used.  When caching is enabled we do not load the other driver.
+        * These functions are primarily here to prevent undefined function errors
+        * when a cached result object is in use.  They are not otherwise fully
+        * operational due to the unavailability of the database resource IDs with
+        * cached results.
+        */
+       function num_rows() { return $this->num_rows; }
+       function num_fields() { return 0; }
+       function list_fields() { return array(); }
+       function field_data() { return array(); }
+       function free_result() { return TRUE; }
+       function _data_seek() { return TRUE; }
+       function _fetch_assoc() { return array(); }
+       function _fetch_object() { return array(); }
+
+}
+// END DB_result class
+
+/* End of file DB_result.php */
+/* Location: ./system/database/DB_result.php */
diff --git a/system/database/DB_utility.php b/system/database/DB_utility.php
new file mode 100755 (executable)
index 0000000..a5f174f
--- /dev/null
@@ -0,0 +1,414 @@
+<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+/**
+ * Code Igniter
+ *
+ * An open source application development framework for PHP 5.1.6 or newer
+ *
+ * @package            CodeIgniter
+ * @author             ExpressionEngine Dev Team
+ * @copyright  Copyright (c) 2008 - 2011, EllisLab, Inc.
+ * @license            http://codeigniter.com/user_guide/license.html
+ * @link               http://codeigniter.com
+ * @since              Version 1.0
+ * @filesource
+ */
+
+// ------------------------------------------------------------------------
+
+/**
+ * Database Utility Class
+ *
+ * @category   Database
+ * @author             ExpressionEngine Dev Team
+ * @link               http://codeigniter.com/user_guide/database/
+ */
+class CI_DB_utility extends CI_DB_forge {
+
+       var $db;
+       var $data_cache         = array();
+
+       /**
+        * Constructor
+        *
+        * Grabs the CI super object instance so we can access it.
+        *
+        */
+       function CI_DB_utility()
+       {
+               // Assign the main database object to $this->db
+               $CI =& get_instance();
+               $this->db =& $CI->db;
+
+               log_message('debug', "Database Utility Class Initialized");
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * List databases
+        *
+        * @access      public
+        * @return      bool
+        */
+       function list_databases()
+       {
+               // Is there a cached result?
+               if (isset($this->data_cache['db_names']))
+               {
+                       return $this->data_cache['db_names'];
+               }
+
+               $query = $this->db->query($this->_list_databases());
+               $dbs = array();
+               if ($query->num_rows() > 0)
+               {
+                       foreach ($query->result_array() as $row)
+                       {
+                               $dbs[] = current($row);
+                       }
+               }
+
+               $this->data_cache['db_names'] = $dbs;
+               return $this->data_cache['db_names'];
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Determine if a particular database exists
+        *
+        * @access      public
+        * @param       string
+        * @return      boolean
+        */
+       function database_exists($database_name)
+       {
+               // Some databases won't have access to the list_databases() function, so
+               // this is intended to allow them to override with their own functions as
+               // defined in $driver_utility.php
+               if (method_exists($this, '_database_exists'))
+               {
+                       return $this->_database_exists($database_name);
+               }
+               else
+               {
+                       return ( ! in_array($database_name, $this->list_databases())) ? FALSE : TRUE;
+               }
+       }
+
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Optimize Table
+        *
+        * @access      public
+        * @param       string  the table name
+        * @return      bool
+        */
+       function optimize_table($table_name)
+       {
+               $sql = $this->_optimize_table($table_name);
+
+               if (is_bool($sql))
+               {
+                               show_error('db_must_use_set');
+               }
+
+               $query = $this->db->query($sql);
+               $res = $query->result_array();
+
+               // Note: Due to a bug in current() that affects some versions
+               // of PHP we can not pass function call directly into it
+               return current($res);
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Optimize Database
+        *
+        * @access      public
+        * @return      array
+        */
+       function optimize_database()
+       {
+               $result = array();
+               foreach ($this->db->list_tables() as $table_name)
+               {
+                       $sql = $this->_optimize_table($table_name);
+
+                       if (is_bool($sql))
+                       {
+                               return $sql;
+                       }
+
+                       $query = $this->db->query($sql);
+
+                       // Build the result array...
+                       // Note: Due to a bug in current() that affects some versions
+                       // of PHP we can not pass function call directly into it
+                       $res = $query->result_array();
+                       $res = current($res);
+                       $key = str_replace($this->db->database.'.', '', current($res));
+                       $keys = array_keys($res);
+                       unset($res[$keys[0]]);
+
+                       $result[$key] = $res;
+               }
+
+               return $result;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Repair Table
+        *
+        * @access      public
+        * @param       string  the table name
+        * @return      bool
+        */
+       function repair_table($table_name)
+       {
+               $sql = $this->_repair_table($table_name);
+
+               if (is_bool($sql))
+               {
+                       return $sql;
+               }
+
+               $query = $this->db->query($sql);
+
+               // Note: Due to a bug in current() that affects some versions
+               // of PHP we can not pass function call directly into it
+               $res = $query->result_array();
+               return current($res);
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Generate CSV from a query result object
+        *
+        * @access      public
+        * @param       object  The query result object
+        * @param       string  The delimiter - comma by default
+        * @param       string  The newline character - \n by default
+        * @param       string  The enclosure - double quote by default
+        * @return      string
+        */
+       function csv_from_result($query, $delim = ",", $newline = "\n", $enclosure = '"')
+       {
+               if ( ! is_object($query) OR ! method_exists($query, 'list_fields'))
+               {
+                       show_error('You must submit a valid result object');
+               }
+
+               $out = '';
+
+               // First generate the headings from the table column names
+               foreach ($query->list_fields() as $name)
+               {
+                       $out .= $enclosure.str_replace($enclosure, $enclosure.$enclosure, $name).$enclosure.$delim;
+               }
+
+               $out = rtrim($out);
+               $out .= $newline;
+
+               // Next blast through the result array and build out the rows
+               foreach ($query->result_array() as $row)
+               {
+                       foreach ($row as $item)
+                       {
+                               $out .= $enclosure.str_replace($enclosure, $enclosure.$enclosure, $item).$enclosure.$delim;
+                       }
+                       $out = rtrim($out);
+                       $out .= $newline;
+               }
+
+               return $out;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Generate XML data from a query result object
+        *
+        * @access      public
+        * @param       object  The query result object
+        * @param       array   Any preferences
+        * @return      string
+        */
+       function xml_from_result($query, $params = array())
+       {
+               if ( ! is_object($query) OR ! method_exists($query, 'list_fields'))
+               {
+                       show_error('You must submit a valid result object');
+               }
+
+               // Set our default values
+               foreach (array('root' => 'root', 'element' => 'element', 'newline' => "\n", 'tab' => "\t") as $key => $val)
+               {
+                       if ( ! isset($params[$key]))
+                       {
+                               $params[$key] = $val;
+                       }
+               }
+
+               // Create variables for convenience
+               extract($params);
+
+               // Load the xml helper
+               $CI =& get_instance();
+               $CI->load->helper('xml');
+
+               // Generate the result
+               $xml = "<{$root}>".$newline;
+               foreach ($query->result_array() as $row)
+               {
+                       $xml .= $tab."<{$element}>".$newline;
+
+                       foreach ($row as $key => $val)
+                       {
+                               $xml .= $tab.$tab."<{$key}>".xml_convert($val)."</{$key}>".$newline;
+                       }
+                       $xml .= $tab."</{$element}>".$newline;
+               }
+               $xml .= "</$root>".$newline;
+
+               return $xml;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Database Backup
+        *
+        * @access      public
+        * @return      void
+        */
+       function backup($params = array())
+       {
+               // If the parameters have not been submitted as an
+               // array then we know that it is simply the table
+               // name, which is a valid short cut.
+               if (is_string($params))
+               {
+                       $params = array('tables' => $params);
+               }
+
+               // ------------------------------------------------------
+
+               // Set up our default preferences
+               $prefs = array(
+                                                       'tables'                => array(),
+                                                       'ignore'                => array(),
+                                                       'filename'              => '',
+                                                       'format'                => 'gzip', // gzip, zip, txt
+                                                       'add_drop'              => TRUE,
+                                                       'add_insert'    => TRUE,
+                                                       'newline'               => "\n"
+                                               );
+
+               // Did the user submit any preferences? If so set them....
+               if (count($params) > 0)
+               {
+                       foreach ($prefs as $key => $val)
+                       {
+                               if (isset($params[$key]))
+                               {
+                                       $prefs[$key] = $params[$key];
+                               }
+                       }
+               }
+
+               // ------------------------------------------------------
+
+               // Are we backing up a complete database or individual tables?
+               // If no table names were submitted we'll fetch the entire table list
+               if (count($prefs['tables']) == 0)
+               {
+                       $prefs['tables'] = $this->db->list_tables();
+               }
+
+               // ------------------------------------------------------
+
+               // Validate the format
+               if ( ! in_array($prefs['format'], array('gzip', 'zip', 'txt'), TRUE))
+               {
+                       $prefs['format'] = 'txt';
+               }
+
+               // ------------------------------------------------------
+
+               // Is the encoder supported?  If not, we'll either issue an
+               // error or use plain text depending on the debug settings
+               if (($prefs['format'] == 'gzip' AND ! @function_exists('gzencode'))
+               OR ($prefs['format'] == 'zip'  AND ! @function_exists('gzcompress')))
+               {
+                       if ($this->db->db_debug)
+                       {
+                               return $this->db->display_error('db_unsuported_compression');
+                       }
+
+                       $prefs['format'] = 'txt';
+               }
+
+               // ------------------------------------------------------
+
+               // Set the filename if not provided - Only needed with Zip files
+               if ($prefs['filename'] == '' AND $prefs['format'] == 'zip')
+               {
+                       $prefs['filename'] = (count($prefs['tables']) == 1) ? $prefs['tables'] : $this->db->database;
+                       $prefs['filename'] .= '_'.date('Y-m-d_H-i', time());
+               }
+
+               // ------------------------------------------------------
+
+               // Was a Gzip file requested?
+               if ($prefs['format'] == 'gzip')
+               {
+                       return gzencode($this->_backup($prefs));
+               }
+
+               // ------------------------------------------------------
+
+               // Was a text file requested?
+               if ($prefs['format'] == 'txt')
+               {
+                       return $this->_backup($prefs);
+               }
+
+               // ------------------------------------------------------
+
+               // Was a Zip file requested?
+               if ($prefs['format'] == 'zip')
+               {
+                       // If they included the .zip file extension we'll remove it
+                       if (preg_match("|.+?\.zip$|", $prefs['filename']))
+                       {
+                               $prefs['filename'] = str_replace('.zip', '', $prefs['filename']);
+                       }
+
+                       // Tack on the ".sql" file extension if needed
+                       if ( ! preg_match("|.+?\.sql$|", $prefs['filename']))
+                       {
+                               $prefs['filename'] .= '.sql';
+                       }
+
+                       // Load the Zip class and output it
+
+                       $CI =& get_instance();
+                       $CI->load->library('zip');
+                       $CI->zip->add_data($prefs['filename'], $this->_backup($prefs));
+                       return $CI->zip->get_zip();
+               }
+
+       }
+
+}
+
+
+/* End of file DB_utility.php */
+/* Location: ./system/database/DB_utility.php */
\ No newline at end of file
diff --git a/system/database/drivers/index.html b/system/database/drivers/index.html
new file mode 100755 (executable)
index 0000000..c942a79
--- /dev/null
@@ -0,0 +1,10 @@
+<html>
+<head>
+       <title>403 Forbidden</title>
+</head>
+<body>
+
+<p>Directory access is forbidden.</p>
+
+</body>
+</html>
\ No newline at end of file
diff --git a/system/database/drivers/mssql/index.html b/system/database/drivers/mssql/index.html
new file mode 100755 (executable)
index 0000000..c942a79
--- /dev/null
@@ -0,0 +1,10 @@
+<html>
+<head>
+       <title>403 Forbidden</title>
+</head>
+<body>
+
+<p>Directory access is forbidden.</p>
+
+</body>
+</html>
\ No newline at end of file
diff --git a/system/database/drivers/mssql/mssql_driver.php b/system/database/drivers/mssql/mssql_driver.php
new file mode 100755 (executable)
index 0000000..65397ed
--- /dev/null
@@ -0,0 +1,666 @@
+<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+/**
+ * CodeIgniter
+ *
+ * An open source application development framework for PHP 5.1.6 or newer
+ *
+ * @package            CodeIgniter
+ * @author             ExpressionEngine Dev Team
+ * @copyright  Copyright (c) 2008 - 2011, EllisLab, Inc.
+ * @license            http://codeigniter.com/user_guide/license.html
+ * @link               http://codeigniter.com
+ * @since              Version 1.0
+ * @filesource
+ */
+
+// ------------------------------------------------------------------------
+
+/**
+ * MS SQL Database Adapter Class
+ *
+ * Note: _DB is an extender class that the app controller
+ * creates dynamically based on whether the active record
+ * class is being used or not.
+ *
+ * @package            CodeIgniter
+ * @subpackage Drivers
+ * @category   Database
+ * @author             ExpressionEngine Dev Team
+ * @link               http://codeigniter.com/user_guide/database/
+ */
+class CI_DB_mssql_driver extends CI_DB {
+
+       var $dbdriver = 'mssql';
+
+       // The character used for escaping
+       var $_escape_char = '';
+
+       // clause and character used for LIKE escape sequences
+       var $_like_escape_str = " ESCAPE '%s' ";
+       var $_like_escape_chr = '!';
+
+       /**
+        * The syntax to count rows is slightly different across different
+        * database engines, so this string appears in each driver and is
+        * used for the count_all() and count_all_results() functions.
+        */
+       var $_count_string = "SELECT COUNT(*) AS ";
+       var $_random_keyword = ' ASC'; // not currently supported
+
+       /**
+        * Non-persistent database connection
+        *
+        * @access      private called by the base class
+        * @return      resource
+        */
+       function db_connect()
+       {
+               if ($this->port != '')
+               {
+                       $this->hostname .= ','.$this->port;
+               }
+
+               return @mssql_connect($this->hostname, $this->username, $this->password);
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Persistent database connection
+        *
+        * @access      private called by the base class
+        * @return      resource
+        */
+       function db_pconnect()
+       {
+               if ($this->port != '')
+               {
+                       $this->hostname .= ','.$this->port;
+               }
+
+               return @mssql_pconnect($this->hostname, $this->username, $this->password);
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * 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()
+       {
+               // not implemented in MSSQL
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Select the database
+        *
+        * @access      private called by the base class
+        * @return      resource
+        */
+       function db_select()
+       {
+               // Note: The brackets are required in the event that the DB name
+               // contains reserved characters
+               return @mssql_select_db('['.$this->database.']', $this->conn_id);
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Set client character set
+        *
+        * @access      public
+        * @param       string
+        * @param       string
+        * @return      resource
+        */
+       function db_set_charset($charset, $collation)
+       {
+               // @todo - add support if needed
+               return TRUE;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * 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 @mssql_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)
+       {
+               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;
+
+               $this->simple_query('BEGIN TRAN');
+               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;
+               }
+
+               $this->simple_query('COMMIT TRAN');
+               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;
+               }
+
+               $this->simple_query('ROLLBACK TRAN');
+               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;
+               }
+
+               // Escape single quotes
+               $str = str_replace("'", "''", remove_invisible_characters($str));
+
+               // 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
+                       );
+               }
+
+               return $str;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Affected Rows
+        *
+        * @access      public
+        * @return      integer
+        */
+       function affected_rows()
+       {
+               return @mssql_rows_affected($this->conn_id);
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+       * Insert ID
+       *
+       * Returns the last id created in the Identity column.
+       *
+       * @access public
+       * @return integer
+       */
+       function insert_id()
+       {
+               $ver = self::_parse_major_version($this->version());
+               $sql = ($ver >= 8 ? "SELECT SCOPE_IDENTITY() AS last_id" : "SELECT @@IDENTITY AS last_id");
+               $query = $this->query($sql);
+               $row = $query->row();
+               return $row->last_id;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+       * Parse major version
+       *
+       * Grabs the major version number from the
+       * database server version string passed in.
+       *
+       * @access private
+       * @param string $version
+       * @return int16 major version number
+       */
+       function _parse_major_version($version)
+       {
+               preg_match('/([0-9]+)\.([0-9]+)\.([0-9]+)/', $version, $ver_info);
+               return $ver_info[1]; // return the major version b/c that's all we're interested in.
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+       * Version number query string
+       *
+       * @access public
+       * @return string
+       */
+       function _version()
+       {
+               return "SELECT @@VERSION AS ver";
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * "Count All" query
+        *
+        * Generates a platform-specific query string that counts all records in
+        * the specified database
+        *
+        * @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 = "SELECT name FROM sysobjects WHERE type = 'U' ORDER BY name";
+
+               // for future compatibility
+               if ($prefix_limit !== FALSE AND $this->dbprefix != '')
+               {
+                       //$sql .= " LIKE '".$this->escape_like_str($this->dbprefix)."%' ".sprintf($this->_like_escape_str, $this->_like_escape_chr);
+                       return FALSE; // not currently supported
+               }
+
+               return $sql;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * List column query
+        *
+        * Generates a platform-specific query string so that the column names can be fetched
+        *
+        * @access      private
+        * @param       string  the table name
+        * @return      string
+        */
+       function _list_columns($table = '')
+       {
+               return "SELECT * FROM INFORMATION_SCHEMA.Columns WHERE TABLE_NAME = '".$table."'";
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * 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 TOP 1 * FROM ".$table;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * The error message string
+        *
+        * @access      private
+        * @return      string
+        */
+       function _error_message()
+       {
+               return mssql_get_last_message();
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * The error message number
+        *
+        * @access      private
+        * @return      integer
+        */
+       function _error_number()
+       {
+               // Are error numbers supported?
+               return '';
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * 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).")";
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * 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[] = $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;
+       }
+
+
+       // --------------------------------------------------------------------
+
+       /**
+        * 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)
+       {
+               $i = $limit + $offset;
+
+               return preg_replace('/(^\SELECT (DISTINCT)?)/i','\\1 TOP '.$i.' ', $sql);
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Close DB Connection
+        *
+        * @access      public
+        * @param       resource
+        * @return      void
+        */
+       function _close($conn_id)
+       {
+               @mssql_close($conn_id);
+       }
+
+}
+
+
+
+/* End of file mssql_driver.php */
+/* Location: ./system/database/drivers/mssql/mssql_driver.php */
\ No newline at end of file
diff --git a/system/database/drivers/mssql/mssql_forge.php b/system/database/drivers/mssql/mssql_forge.php
new file mode 100755 (executable)
index 0000000..70b20ec
--- /dev/null
@@ -0,0 +1,248 @@
+<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+/**
+ * CodeIgniter
+ *
+ * An open source application development framework for PHP 5.1.6 or newer
+ *
+ * @package            CodeIgniter
+ * @author             ExpressionEngine Dev Team
+ * @copyright  Copyright (c) 2008 - 2011, EllisLab, Inc.
+ * @license            http://codeigniter.com/user_guide/license.html
+ * @link               http://codeigniter.com
+ * @since              Version 1.0
+ * @filesource
+ */
+
+// ------------------------------------------------------------------------
+
+/**
+ * MS SQL Forge Class
+ *
+ * @category   Database
+ * @author             ExpressionEngine Dev Team
+ * @link               http://codeigniter.com/user_guide/database/
+ */
+class CI_DB_mssql_forge extends CI_DB_forge {
+
+       /**
+        * Create database
+        *
+        * @access      private
+        * @param       string  the database name
+        * @return      bool
+        */
+       function _create_database($name)
+       {
+               return "CREATE DATABASE ".$name;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Drop database
+        *
+        * @access      private
+        * @param       string  the database name
+        * @return      bool
+        */
+       function _drop_database($name)
+       {
+               return "DROP DATABASE ".$name;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Drop Table
+        *
+        * @access      private
+        * @return      bool
+        */
+       function _drop_table($table)
+       {
+               return "DROP TABLE ".$this->db->_escape_identifiers($table);
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Create Table
+        *
+        * @access      private
+        * @param       string  the table name
+        * @param       array   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 ';
+               }
+
+               $sql .= $this->db->_escape_identifiers($table)." (";
+               $current_field_count = 0;
+
+               foreach ($fields as $field=>$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);
+
+                               $sql .=  ' '.$attributes['TYPE'];
+
+                               if (array_key_exists('CONSTRAINT', $attributes))
+                               {
+                                       $sql .= '('.$attributes['CONSTRAINT'].')';
+                               }
+
+                               if (array_key_exists('UNSIGNED', $attributes) && $attributes['UNSIGNED'] === TRUE)
+                               {
+                                       $sql .= ' UNSIGNED';
+                               }
+
+                               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';
+                               }
+                       }
+
+                       // don't add a comma on the end of the last field
+                       if (++$current_field_count < count($fields))
+                       {
+                               $sql .= ',';
+                       }
+               }
+
+               if (count($primary_keys) > 0)
+               {
+                       $primary_keys = $this->db->_protect_identifiers($primary_keys);
+                       $sql .= ",\n\tPRIMARY KEY (" . implode(', ', $primary_keys) . ")";
+               }
+
+               if (is_array($keys) && count($keys) > 0)
+               {
+                       foreach ($keys as $key)
+                       {
+                               if (is_array($key))
+                               {
+                                       $key = $this->db->_protect_identifiers($key);
+                               }
+                               else
+                               {
+                                       $key = array($this->db->_protect_identifiers($key));
+                               }
+
+                               $sql .= ",\n\tFOREIGN KEY (" . implode(', ', $key) . ")";
+                       }
+               }
+
+               $sql .= "\n)";
+
+               return $sql;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * 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       string  the table name
+        * @param       string  the column definition
+        * @param       string  the default value
+        * @param       boolean should 'NOT NULL' be added
+        * @param       string  the field after which we should add the new field
+        * @return      object
+        */
+       function _alter_table($alter_type, $table, $column_name, $column_definition = '', $default_value = '', $null = '', $after_field = '')
+       {
+               $sql = 'ALTER TABLE '.$this->db->_protect_identifiers($table)." $alter_type ".$this->db->_protect_identifiers($column_name);
+
+               // DROP has everything it needs now.
+               if ($alter_type == 'DROP')
+               {
+                       return $sql;
+               }
+
+               $sql .= " $column_definition";
+
+               if ($default_value != '')
+               {
+                       $sql .= " DEFAULT \"$default_value\"";
+               }
+
+               if ($null === NULL)
+               {
+                       $sql .= ' NULL';
+               }
+               else
+               {
+                       $sql .= ' NOT NULL';
+               }
+
+               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)
+       {
+               // I think this syntax will work, but can find little documentation on renaming tables in MSSQL
+               $sql = 'ALTER TABLE '.$this->db->_protect_identifiers($table_name)." RENAME TO ".$this->db->_protect_identifiers($new_table_name);
+               return $sql;
+       }
+
+}
+
+/* End of file mssql_forge.php */
+/* Location: ./system/database/drivers/mssql/mssql_forge.php */
\ No newline at end of file
diff --git a/system/database/drivers/mssql/mssql_result.php b/system/database/drivers/mssql/mssql_result.php
new file mode 100755 (executable)
index 0000000..2897ca5
--- /dev/null
@@ -0,0 +1,169 @@
+<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+/**
+ * CodeIgniter
+ *
+ * An open source application development framework for PHP 5.1.6 or newer
+ *
+ * @package            CodeIgniter
+ * @author             ExpressionEngine Dev Team
+ * @copyright  Copyright (c) 2008 - 2011, EllisLab, Inc.
+ * @license            http://codeigniter.com/user_guide/license.html
+ * @link               http://codeigniter.com
+ * @since              Version 1.0
+ * @filesource
+ */
+
+// ------------------------------------------------------------------------
+
+/**
+ * MS SQL Result Class
+ *
+ * This class extends the parent result class: CI_DB_result
+ *
+ * @category   Database
+ * @author             ExpressionEngine Dev Team
+ * @link               http://codeigniter.com/user_guide/database/
+ */
+class CI_DB_mssql_result extends CI_DB_result {
+
+       /**
+        * Number of rows in the result set
+        *
+        * @access      public
+        * @return      integer
+        */
+       function num_rows()
+       {
+               return @mssql_num_rows($this->result_id);
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Number of fields in the result set
+        *
+        * @access      public
+        * @return      integer
+        */
+       function num_fields()
+       {
+               return @mssql_num_fields($this->result_id);
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Fetch Field Names
+        *
+        * Generates an array of column names
+        *
+        * @access      public
+        * @return      array
+        */
+       function list_fields()
+       {
+               $field_names = array();
+               while ($field = mssql_fetch_field($this->result_id))
+               {
+                       $field_names[] = $field->name;
+               }
+
+               return $field_names;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Field data
+        *
+        * Generates an array of objects containing field meta-data
+        *
+        * @access      public
+        * @return      array
+        */
+       function field_data()
+       {
+               $retval = array();
+               while ($field = mssql_fetch_field($this->result_id))
+               {
+                       $F                              = new stdClass();
+                       $F->name                = $field->name;
+                       $F->type                = $field->type;
+                       $F->max_length  = $field->max_length;
+                       $F->primary_key = 0;
+                       $F->default             = '';
+
+                       $retval[] = $F;
+               }
+
+               return $retval;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Free the result
+        *
+        * @return      null
+        */
+       function free_result()
+       {
+               if (is_resource($this->result_id))
+               {
+                       mssql_free_result($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 mssql_data_seek($this->result_id, $n);
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Result - associative array
+        *
+        * Returns the result set as an array
+        *
+        * @access      private
+        * @return      array
+        */
+       function _fetch_assoc()
+       {
+               return mssql_fetch_assoc($this->result_id);
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Result - object
+        *
+        * Returns the result set as an object
+        *
+        * @access      private
+        * @return      object
+        */
+       function _fetch_object()
+       {
+               return mssql_fetch_object($this->result_id);
+       }
+
+}
+
+
+/* End of file mssql_result.php */
+/* Location: ./system/database/drivers/mssql/mssql_result.php */
\ No newline at end of file
diff --git a/system/database/drivers/mssql/mssql_utility.php b/system/database/drivers/mssql/mssql_utility.php
new file mode 100755 (executable)
index 0000000..48ecbc7
--- /dev/null
@@ -0,0 +1,88 @@
+<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+/**
+ * CodeIgniter
+ *
+ * An open source application development framework for PHP 5.1.6 or newer
+ *
+ * @package            CodeIgniter
+ * @author             ExpressionEngine Dev Team
+ * @copyright  Copyright (c) 2008 - 2011, EllisLab, Inc.
+ * @license            http://codeigniter.com/user_guide/license.html
+ * @link               http://codeigniter.com
+ * @since              Version 1.0
+ * @filesource
+ */
+
+// ------------------------------------------------------------------------
+
+/**
+ * MS SQL Utility Class
+ *
+ * @category   Database
+ * @author             ExpressionEngine Dev Team
+ * @link               http://codeigniter.com/user_guide/database/
+ */
+class CI_DB_mssql_utility extends CI_DB_utility {
+
+       /**
+        * List databases
+        *
+        * @access      private
+        * @return      bool
+        */
+       function _list_databases()
+       {
+               return "EXEC sp_helpdb"; // Can also be: EXEC sp_databases
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Optimize table query
+        *
+        * Generates a platform-specific query so that a table can be optimized
+        *
+        * @access      private
+        * @param       string  the table name
+        * @return      object
+        */
+       function _optimize_table($table)
+       {
+               return FALSE; // Is this supported in MS SQL?
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Repair table query
+        *
+        * Generates a platform-specific query so that a table can be repaired
+        *
+        * @access      private
+        * @param       string  the table name
+        * @return      object
+        */
+       function _repair_table($table)
+       {
+               return FALSE; // Is this supported in MS SQL?
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * MSSQL Export
+        *
+        * @access      private
+        * @param       array   Preferences
+        * @return      mixed
+        */
+       function _backup($params = array())
+       {
+               // Currently unsupported
+               return $this->db->display_error('db_unsuported_feature');
+       }
+
+}
+
+/* End of file mssql_utility.php */
+/* Location: ./system/database/drivers/mssql/mssql_utility.php */
\ No newline at end of file
diff --git a/system/database/drivers/mysql/index.html b/system/database/drivers/mysql/index.html
new file mode 100755 (executable)
index 0000000..c942a79
--- /dev/null
@@ -0,0 +1,10 @@
+<html>
+<head>
+       <title>403 Forbidden</title>
+</head>
+<body>
+
+<p>Directory access is forbidden.</p>
+
+</body>
+</html>
\ No newline at end of file
diff --git a/system/database/drivers/mysql/mysql_driver.php b/system/database/drivers/mysql/mysql_driver.php
new file mode 100755 (executable)
index 0000000..4ff9b0a
--- /dev/null
@@ -0,0 +1,762 @@
+<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+/**
+ * CodeIgniter
+ *
+ * An open source application development framework for PHP 5.1.6 or newer
+ *
+ * @package            CodeIgniter
+ * @author             ExpressionEngine Dev Team
+ * @copyright  Copyright (c) 2008 - 2011, EllisLab, Inc.
+ * @license            http://codeigniter.com/user_guide/license.html
+ * @link               http://codeigniter.com
+ * @since              Version 1.0
+ * @filesource
+ */
+
+// ------------------------------------------------------------------------
+
+/**
+ * MySQL Database Adapter Class
+ *
+ * Note: _DB is an extender class that the app controller
+ * creates dynamically based on whether the active record
+ * class is being used or not.
+ *
+ * @package            CodeIgniter
+ * @subpackage Drivers
+ * @category   Database
+ * @author             ExpressionEngine Dev Team
+ * @link               http://codeigniter.com/user_guide/database/
+ */
+class CI_DB_mysql_driver extends CI_DB {
+
+       var $dbdriver = 'mysql';
+
+       // The character used for escaping
+       var     $_escape_char = '`';
+
+       // clause and character used for LIKE escape sequences - not used in MySQL
+       var $_like_escape_str = '';
+       var $_like_escape_chr = '';
+
+       /**
+        * Whether to use the MySQL "delete hack" which allows the number
+        * of affected rows to be shown. Uses a preg_replace when enabled,
+        * adding a bit more processing to all queries.
+        */
+       var $delete_hack = TRUE;
+
+       /**
+        * The syntax to count rows is slightly different across different
+        * database engines, so this string appears in each driver and is
+        * used for the count_all() and count_all_results() functions.
+        */
+       var $_count_string = 'SELECT COUNT(*) AS ';
+       var $_random_keyword = ' RAND()'; // database specific random keyword
+
+       /**
+        * Non-persistent database connection
+        *
+        * @access      private called by the base class
+        * @return      resource
+        */
+       function db_connect()
+       {
+               if ($this->port != '')
+               {
+                       $this->hostname .= ':'.$this->port;
+               }
+
+               return @mysql_connect($this->hostname, $this->username, $this->password, TRUE);
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Persistent database connection
+        *
+        * @access      private called by the base class
+        * @return      resource
+        */
+       function db_pconnect()
+       {
+               if ($this->port != '')
+               {
+                       $this->hostname .= ':'.$this->port;
+               }
+
+               return @mysql_pconnect($this->hostname, $this->username, $this->password);
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * 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 (mysql_ping($this->conn_id) === FALSE)
+               {
+                       $this->conn_id = FALSE;
+               }
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Select the database
+        *
+        * @access      private called by the base class
+        * @return      resource
+        */
+       function db_select()
+       {
+               return @mysql_select_db($this->database, $this->conn_id);
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Set client character set
+        *
+        * @access      public
+        * @param       string
+        * @param       string
+        * @return      resource
+        */
+       function db_set_charset($charset, $collation)
+       {
+               return @mysql_query("SET NAMES '".$this->escape_str($charset)."' COLLATE '".$this->escape_str($collation)."'", $this->conn_id);
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Version number query string
+        *
+        * @access      public
+        * @return      string
+        */
+       function _version()
+       {
+               return "SELECT version() AS ver";
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * 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 @mysql_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)
+       {
+               // "DELETE FROM TABLE" returns 0 affected rows This hack modifies
+               // the query so that it returns the number of affected rows
+               if ($this->delete_hack === TRUE)
+               {
+                       if (preg_match('/^\s*DELETE\s+FROM\s+(\S+)\s*$/i', $sql))
+                       {
+                               $sql = preg_replace("/^\s*DELETE\s+FROM\s+(\S+)\s*$/", "DELETE FROM \\1 WHERE 1=1", $sql);
+                       }
+               }
+
+               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;
+
+               $this->simple_query('SET AUTOCOMMIT=0');
+               $this->simple_query('START TRANSACTION'); // can also be BEGIN or BEGIN WORK
+               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;
+               }
+
+               $this->simple_query('COMMIT');
+               $this->simple_query('SET AUTOCOMMIT=1');
+               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;
+               }
+
+               $this->simple_query('ROLLBACK');
+               $this->simple_query('SET AUTOCOMMIT=1');
+               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('mysql_real_escape_string') AND is_resource($this->conn_id))
+               {
+                       $str = mysql_real_escape_string($str, $this->conn_id);
+               }
+               elseif (function_exists('mysql_escape_string'))
+               {
+                       $str = mysql_escape_string($str);
+               }
+               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 @mysql_affected_rows($this->conn_id);
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Insert ID
+        *
+        * @access      public
+        * @return      integer
+        */
+       function insert_id()
+       {
+               return @mysql_insert_id($this->conn_id);
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * "Count All" query
+        *
+        * Generates a platform-specific query string that counts all records in
+        * the specified database
+        *
+        * @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 FROM ".$this->_escape_char.$this->database.$this->_escape_char;
+
+               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 mysql_error($this->conn_id);
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * The error message number
+        *
+        * @access      private
+        * @return      integer
+        */
+       function _error_number()
+       {
+               return mysql_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[] = $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)
+       {
+               @mysql_close($conn_id);
+       }
+
+}
+
+
+/* End of file mysql_driver.php */
+/* Location: ./system/database/drivers/mysql/mysql_driver.php */
\ No newline at end of file
diff --git a/system/database/drivers/mysql/mysql_forge.php b/system/database/drivers/mysql/mysql_forge.php
new file mode 100755 (executable)
index 0000000..529ec98
--- /dev/null
@@ -0,0 +1,269 @@
+<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+/**
+ * CodeIgniter
+ *
+ * An open source application development framework for PHP 5.1.6 or newer
+ *
+ * @package            CodeIgniter
+ * @author             ExpressionEngine Dev Team
+ * @copyright  Copyright (c) 2008 - 2011, EllisLab, Inc.
+ * @license            http://codeigniter.com/user_guide/license.html
+ * @link               http://codeigniter.com
+ * @since              Version 1.0
+ * @filesource
+ */
+
+// ------------------------------------------------------------------------
+
+/**
+ * MySQL Forge Class
+ *
+ * @category   Database
+ * @author             ExpressionEngine Dev Team
+ * @link               http://codeigniter.com/user_guide/database/
+ */
+class CI_DB_mysql_forge extends CI_DB_forge {
+
+       /**
+        * Create database
+        *
+        * @access      private
+        * @param       string  the database name
+        * @return      bool
+        */
+       function _create_database($name)
+       {
+               return "CREATE DATABASE ".$name;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Drop database
+        *
+        * @access      private
+        * @param       string  the database name
+        * @return      bool
+        */
+       function _drop_database($name)
+       {
+               return "DROP DATABASE ".$name;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Process Fields
+        *
+        * @access      private
+        * @param       mixed   the fields
+        * @return      string
+        */
+       function _process_fields($fields)
+       {
+               $current_field_count = 0;
+               $sql = '';
+
+               foreach ($fields as $field=>$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':
+                                                       case 'set':
+                                                               $sql .= '("'.implode('","', $attributes['CONSTRAINT']).'")';
+                                                       break;
+
+                                                       default:
+                                                               $sql .= '('.$attributes['CONSTRAINT'].')';
+                                               }
+                                       }
+                               }
+
+                               if (array_key_exists('UNSIGNED', $attributes) && $attributes['UNSIGNED'] === TRUE)
+                               {
+                                       $sql .= ' UNSIGNED';
+                               }
+
+                               if (array_key_exists('DEFAULT', $attributes))
+                               {
+                                       $sql .= ' DEFAULT \''.$attributes['DEFAULT'].'\'';
+                               }
+
+                               if (array_key_exists('NULL', $attributes))
+                               {
+                                       $sql .= ($attributes['NULL'] === TRUE) ? ' NULL' : ' NOT NULL';
+                               }
+
+                               if (array_key_exists('AUTO_INCREMENT', $attributes) && $attributes['AUTO_INCREMENT'] === TRUE)
+                               {
+                                       $sql .= ' AUTO_INCREMENT';
+                               }
+                       }
+
+                       // 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 ';
+               }
+
+               $sql .= $this->db->_escape_identifiers($table)." (";
+
+               $sql .= $this->_process_fields($fields);
+
+               if (count($primary_keys) > 0)
+               {
+                       $key_name = $this->db->_protect_identifiers(implode('_', $primary_keys));
+                       $primary_keys = $this->db->_protect_identifiers($primary_keys);
+                       $sql .= ",\n\tPRIMARY KEY ".$key_name." (" . 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) DEFAULT CHARACTER SET {$this->db->char_set} COLLATE {$this->db->dbcollat};";
+
+               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 = 'ALTER TABLE '.$this->db->_protect_identifiers($table_name)." RENAME TO ".$this->db->_protect_identifiers($new_table_name);
+               return $sql;
+       }
+
+}
+
+/* End of file mysql_forge.php */
+/* Location: ./system/database/drivers/mysql/mysql_forge.php */
\ No newline at end of file
diff --git a/system/database/drivers/mysql/mysql_result.php b/system/database/drivers/mysql/mysql_result.php
new file mode 100755 (executable)
index 0000000..5073896
--- /dev/null
@@ -0,0 +1,169 @@
+<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+/**
+ * CodeIgniter
+ *
+ * An open source application development framework for PHP 5.1.6 or newer
+ *
+ * @package            CodeIgniter
+ * @author             ExpressionEngine Dev Team
+ * @copyright  Copyright (c) 2008 - 2011, EllisLab, Inc.
+ * @license            http://codeigniter.com/user_guide/license.html
+ * @link               http://codeigniter.com
+ * @since              Version 1.0
+ * @filesource
+ */
+
+// --------------------------------------------------------------------
+
+/**
+ * MySQL Result Class
+ *
+ * This class extends the parent result class: CI_DB_result
+ *
+ * @category   Database
+ * @author             ExpressionEngine Dev Team
+ * @link               http://codeigniter.com/user_guide/database/
+ */
+class CI_DB_mysql_result extends CI_DB_result {
+
+       /**
+        * Number of rows in the result set
+        *
+        * @access      public
+        * @return      integer
+        */
+       function num_rows()
+       {
+               return @mysql_num_rows($this->result_id);
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Number of fields in the result set
+        *
+        * @access      public
+        * @return      integer
+        */
+       function num_fields()
+       {
+               return @mysql_num_fields($this->result_id);
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Fetch Field Names
+        *
+        * Generates an array of column names
+        *
+        * @access      public
+        * @return      array
+        */
+       function list_fields()
+       {
+               $field_names = array();
+               while ($field = mysql_fetch_field($this->result_id))
+               {
+                       $field_names[] = $field->name;
+               }
+
+               return $field_names;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Field data
+        *
+        * Generates an array of objects containing field meta-data
+        *
+        * @access      public
+        * @return      array
+        */
+       function field_data()
+       {
+               $retval = array();
+               while ($field = mysql_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;
+                       $F->primary_key = $field->primary_key;
+
+                       $retval[] = $F;
+               }
+
+               return $retval;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Free the result
+        *
+        * @return      null
+        */
+       function free_result()
+       {
+               if (is_resource($this->result_id))
+               {
+                       mysql_free_result($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 mysql_data_seek($this->result_id, $n);
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Result - associative array
+        *
+        * Returns the result set as an array
+        *
+        * @access      private
+        * @return      array
+        */
+       function _fetch_assoc()
+       {
+               return mysql_fetch_assoc($this->result_id);
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Result - object
+        *
+        * Returns the result set as an object
+        *
+        * @access      private
+        * @return      object
+        */
+       function _fetch_object()
+       {
+               return mysql_fetch_object($this->result_id);
+       }
+
+}
+
+
+/* End of file mysql_result.php */
+/* Location: ./system/database/drivers/mysql/mysql_result.php */
\ No newline at end of file
diff --git a/system/database/drivers/mysql/mysql_utility.php b/system/database/drivers/mysql/mysql_utility.php
new file mode 100755 (executable)
index 0000000..e9747c5
--- /dev/null
@@ -0,0 +1,210 @@
+<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+/**
+ * CodeIgniter
+ *
+ * An open source application development framework for PHP 5.1.6 or newer
+ *
+ * @package            CodeIgniter
+ * @author             ExpressionEngine Dev Team
+ * @copyright  Copyright (c) 2008 - 2011, EllisLab, Inc.
+ * @license            http://codeigniter.com/user_guide/license.html
+ * @link               http://codeigniter.com
+ * @since              Version 1.0
+ * @filesource
+ */
+
+// ------------------------------------------------------------------------
+
+/**
+ * MySQL Utility Class
+ *
+ * @category   Database
+ * @author             ExpressionEngine Dev Team
+ * @link               http://codeigniter.com/user_guide/database/
+ */
+class CI_DB_mysql_utility extends CI_DB_utility {
+
+       /**
+        * List databases
+        *
+        * @access      private
+        * @return      bool
+        */
+       function _list_databases()
+       {
+               return "SHOW DATABASES";
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Optimize table query
+        *
+        * Generates a platform-specific query so that a table can be optimized
+        *
+        * @access      private
+        * @param       string  the table name
+        * @return      object
+        */
+       function _optimize_table($table)
+       {
+               return "OPTIMIZE TABLE ".$this->db->_escape_identifiers($table);
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Repair table query
+        *
+        * Generates a platform-specific query so that a table can be repaired
+        *
+        * @access      private
+        * @param       string  the table name
+        * @return      object
+        */
+       function _repair_table($table)
+       {
+               return "REPAIR TABLE ".$this->db->_escape_identifiers($table);
+       }
+
+       // --------------------------------------------------------------------
+       /**
+        * MySQL Export
+        *
+        * @access      private
+        * @param       array   Preferences
+        * @return      mixed
+        */
+       function _backup($params = array())
+       {
+               if (count($params) == 0)
+               {
+                       return FALSE;
+               }
+
+               // Extract the prefs for simplicity
+               extract($params);
+
+               // Build the output
+               $output = '';
+               foreach ((array)$tables as $table)
+               {
+                       // Is the table in the "ignore" list?
+                       if (in_array($table, (array)$ignore, TRUE))
+                       {
+                               continue;
+                       }
+
+                       // Get the table schema
+                       $query = $this->db->query("SHOW CREATE TABLE `".$this->db->database.'`.'.$table);
+
+                       // No result means the table name was invalid
+                       if ($query === FALSE)
+                       {
+                               continue;
+                       }
+
+                       // Write out the table schema
+                       $output .= '#'.$newline.'# TABLE STRUCTURE FOR: '.$table.$newline.'#'.$newline.$newline;
+
+                       if ($add_drop == TRUE)
+                       {
+                               $output .= 'DROP TABLE IF EXISTS '.$table.';'.$newline.$newline;
+                       }
+
+                       $i = 0;
+                       $result = $query->result_array();
+                       foreach ($result[0] as $val)
+                       {
+                               if ($i++ % 2)
+                               {
+                                       $output .= $val.';'.$newline.$newline;
+                               }
+                       }
+
+                       // If inserts are not needed we're done...
+                       if ($add_insert == FALSE)
+                       {
+                               continue;
+                       }
+
+                       // Grab all the data from the current table
+                       $query = $this->db->query("SELECT * FROM $table");
+
+                       if ($query->num_rows() == 0)
+                       {
+                               continue;
+                       }
+
+                       // Fetch the field names and determine if the field is an
+                       // integer type.  We use this info to decide whether to
+                       // surround the data with quotes or not
+
+                       $i = 0;
+                       $field_str = '';
+                       $is_int = array();
+                       while ($field = mysql_fetch_field($query->result_id))
+                       {
+                               // Most versions of MySQL store timestamp as a string
+                               $is_int[$i] = (in_array(
+                                                                               strtolower(mysql_field_type($query->result_id, $i)),
+                                                                               array('tinyint', 'smallint', 'mediumint', 'int', 'bigint'), //, 'timestamp'),
+                                                                               TRUE)
+                                                                               ) ? TRUE : FALSE;
+
+                               // Create a string of field names
+                               $field_str .= '`'.$field->name.'`, ';
+                               $i++;
+                       }
+
+                       // Trim off the end comma
+                       $field_str = preg_replace( "/, $/" , "" , $field_str);
+
+
+                       // Build the insert string
+                       foreach ($query->result_array() as $row)
+                       {
+                               $val_str = '';
+
+                               $i = 0;
+                               foreach ($row as $v)
+                               {
+                                       // Is the value NULL?
+                                       if ($v === NULL)
+                                       {
+                                               $val_str .= 'NULL';
+                                       }
+                                       else
+                                       {
+                                               // Escape the data if it's not an integer
+                                               if ($is_int[$i] == FALSE)
+                                               {
+                                                       $val_str .= $this->db->escape($v);
+                                               }
+                                               else
+                                               {
+                                                       $val_str .= $v;
+                                               }
+                                       }
+
+                                       // Append a comma
+                                       $val_str .= ', ';
+                                       $i++;
+                               }
+
+                               // Remove the comma at the end of the string
+                               $val_str = preg_replace( "/, $/" , "" , $val_str);
+
+                               // Build the INSERT string
+                               $output .= 'INSERT INTO '.$table.' ('.$field_str.') VALUES ('.$val_str.');'.$newline;
+                       }
+
+                       $output .= $newline.$newline;
+               }
+
+               return $output;
+       }
+}
+
+/* End of file mysql_utility.php */
+/* Location: ./system/database/drivers/mysql/mysql_utility.php */
\ No newline at end of file
diff --git a/system/database/drivers/mysqli/index.html b/system/database/drivers/mysqli/index.html
new file mode 100755 (executable)
index 0000000..c942a79
--- /dev/null
@@ -0,0 +1,10 @@
+<html>
+<head>
+       <title>403 Forbidden</title>
+</head>
+<body>
+
+<p>Directory access is forbidden.</p>
+
+</body>
+</html>
\ No newline at end of file
diff --git a/system/database/drivers/mysqli/mysqli_driver.php b/system/database/drivers/mysqli/mysqli_driver.php
new file mode 100755 (executable)
index 0000000..ccdabce
--- /dev/null
@@ -0,0 +1,740 @@
+<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+/**
+ * CodeIgniter
+ *
+ * An open source application development framework for PHP 5.1.6 or newer
+ *
+ * @package            CodeIgniter
+ * @author             ExpressionEngine Dev Team
+ * @copyright  Copyright (c) 2008 - 2011, EllisLab, Inc.
+ * @license            http://codeigniter.com/user_guide/license.html
+ * @link               http://codeigniter.com
+ * @since              Version 1.0
+ * @filesource
+ */
+
+// ------------------------------------------------------------------------
+
+/**
+ * MySQLi Database Adapter Class - MySQLi only works with PHP 5
+ *
+ * Note: _DB is an extender class that the app controller
+ * creates dynamically based on whether the active record
+ * class is being used or not.
+ *
+ * @package            CodeIgniter
+ * @subpackage Drivers
+ * @category   Database
+ * @author             ExpressionEngine Dev Team
+ * @link               http://codeigniter.com/user_guide/database/
+ */
+class CI_DB_mysqli_driver extends CI_DB {
+
+       var $dbdriver = 'mysqli';
+
+       // The character used for escaping
+       var $_escape_char = '`';
+
+       // clause and character used for LIKE escape sequences - not used in MySQL
+       var $_like_escape_str = '';
+       var $_like_escape_chr = '';
+
+       /**
+        * The syntax to count rows is slightly different across different
+        * database engines, so this string appears in each driver and is
+        * used for the count_all() and count_all_results() functions.
+        */
+       var $_count_string = "SELECT COUNT(*) AS ";
+       var $_random_keyword = ' RAND()'; // database specific random keyword
+
+       /**
+        * Whether to use the MySQL "delete hack" which allows the number
+        * of affected rows to be shown. Uses a preg_replace when enabled,
+        * adding a bit more processing to all queries.
+        */
+       var $delete_hack = TRUE;
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Non-persistent database connection
+        *
+        * @access      private called by the base class
+        * @return      resource
+        */
+       function db_connect()
+       {
+               if ($this->port != '')
+               {
+                       return @mysqli_connect($this->hostname, $this->username, $this->password, $this->database, $this->port);
+               }
+               else
+               {
+                       return @mysqli_connect($this->hostname, $this->username, $this->password, $this->database);
+               }
+
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Persistent database connection
+        *
+        * @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 (mysqli_ping($this->conn_id) === FALSE)
+               {
+                       $this->conn_id = FALSE;
+               }
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Select the database
+        *
+        * @access      private called by the base class
+        * @return      resource
+        */
+       function db_select()
+       {
+               return @mysqli_select_db($this->conn_id, $this->database);
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Set client character set
+        *
+        * @access      private
+        * @param       string
+        * @param       string
+        * @return      resource
+        */
+       function _db_set_charset($charset, $collation)
+       {
+               return @mysqli_query($this->conn_id, "SET NAMES '".$this->escape_str($charset)."' COLLATE '".$this->escape_str($collation)."'");
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Version number query string
+        *
+        * @access      public
+        * @return      string
+        */
+       function _version()
+       {
+               return "SELECT version() AS ver";
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * 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);
+               $result = @mysqli_query($this->conn_id, $sql);
+               return $result;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * 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)
+       {
+               // "DELETE FROM TABLE" returns 0 affected rows This hack modifies
+               // the query so that it returns the number of affected rows
+               if ($this->delete_hack === TRUE)
+               {
+                       if (preg_match('/^\s*DELETE\s+FROM\s+(\S+)\s*$/i', $sql))
+                       {
+                               $sql = preg_replace("/^\s*DELETE\s+FROM\s+(\S+)\s*$/", "DELETE FROM \\1 WHERE 1=1", $sql);
+                       }
+               }
+
+               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;
+
+               $this->simple_query('SET AUTOCOMMIT=0');
+               $this->simple_query('START TRANSACTION'); // can also be BEGIN or BEGIN WORK
+               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;
+               }
+
+               $this->simple_query('COMMIT');
+               $this->simple_query('SET AUTOCOMMIT=1');
+               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;
+               }
+
+               $this->simple_query('ROLLBACK');
+               $this->simple_query('SET AUTOCOMMIT=1');
+               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('mysqli_real_escape_string') AND is_object($this->conn_id))
+               {
+                       $str = mysqli_real_escape_string($this->conn_id, $str);
+               }
+               elseif (function_exists('mysql_escape_string'))
+               {
+                       $str = mysql_escape_string($str);
+               }
+               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 @mysqli_affected_rows($this->conn_id);
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Insert ID
+        *
+        * @access      public
+        * @return      integer
+        */
+       function insert_id()
+       {
+               return @mysqli_insert_id($this->conn_id);
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * "Count All" query
+        *
+        * Generates a platform-specific query string that counts all records in
+        * the specified database
+        *
+        * @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 FROM ".$this->_escape_char.$this->database.$this->_escape_char;
+
+               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 mysqli_error($this->conn_id);
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * The error message number
+        *
+        * @access      private
+        * @return      integer
+        */
+       function _error_number()
+       {
+               return mysqli_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).")";
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * 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[] = $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)
+       {
+               $sql .= "LIMIT ".$limit;
+
+               if ($offset > 0)
+               {
+                       $sql .= " OFFSET ".$offset;
+               }
+
+               return $sql;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Close DB Connection
+        *
+        * @access      public
+        * @param       resource
+        * @return      void
+        */
+       function _close($conn_id)
+       {
+               @mysqli_close($conn_id);
+       }
+
+
+}
+
+
+/* End of file mysqli_driver.php */
+/* Location: ./system/database/drivers/mysqli/mysqli_driver.php */
\ No newline at end of file
diff --git a/system/database/drivers/mysqli/mysqli_forge.php b/system/database/drivers/mysqli/mysqli_forge.php
new file mode 100755 (executable)
index 0000000..d509733
--- /dev/null
@@ -0,0 +1,254 @@
+<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+/**
+ * CodeIgniter
+ *
+ * An open source application development framework for PHP 5.1.6 or newer
+ *
+ * @package            CodeIgniter
+ * @author             ExpressionEngine Dev Team
+ * @copyright  Copyright (c) 2008 - 2011, EllisLab, Inc.
+ * @license            http://codeigniter.com/user_guide/license.html
+ * @link               http://codeigniter.com
+ * @since              Version 1.0
+ * @filesource
+ */
+
+// ------------------------------------------------------------------------
+
+/**
+ * MySQLi Forge Class
+ *
+ * @category   Database
+ * @author             ExpressionEngine Dev Team
+ * @link               http://codeigniter.com/user_guide/database/
+ */
+class CI_DB_mysqli_forge extends CI_DB_forge {
+
+       /**
+        * Create database
+        *
+        * @access      private
+        * @param       string  the database name
+        * @return      bool
+        */
+       function _create_database($name)
+       {
+               return "CREATE DATABASE ".$name;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Drop database
+        *
+        * @access      private
+        * @param       string  the database name
+        * @return      bool
+        */
+       function _drop_database($name)
+       {
+               return "DROP DATABASE ".$name;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Process Fields
+        *
+        * @access      private
+        * @param       mixed   the fields
+        * @return      string
+        */
+       function _process_fields($fields)
+       {
+               $current_field_count = 0;
+               $sql = '';
+
+               foreach ($fields as $field=>$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))
+                               {
+                                       $sql .= '('.$attributes['CONSTRAINT'].')';
+                               }
+
+                               if (array_key_exists('UNSIGNED', $attributes) && $attributes['UNSIGNED'] === TRUE)
+                               {
+                                       $sql .= ' UNSIGNED';
+                               }
+
+                               if (array_key_exists('DEFAULT', $attributes))
+                               {
+                                       $sql .= ' DEFAULT \''.$attributes['DEFAULT'].'\'';
+                               }
+
+                               if (array_key_exists('NULL', $attributes))
+                               {
+                                       $sql .= ($attributes['NULL'] === TRUE) ? ' NULL' : ' NOT NULL';
+                               }
+
+                               if (array_key_exists('AUTO_INCREMENT', $attributes) && $attributes['AUTO_INCREMENT'] === TRUE)
+                               {
+                                       $sql .= ' AUTO_INCREMENT';
+                               }
+                       }
+
+                       // 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 ';
+               }
+
+               $sql .= $this->db->_escape_identifiers($table)." (";
+
+               $sql .= $this->_process_fields($fields);
+
+               if (count($primary_keys) > 0)
+               {
+                       $key_name = $this->db->_protect_identifiers(implode('_', $primary_keys));
+                       $primary_keys = $this->db->_protect_identifiers($primary_keys);
+                       $sql .= ",\n\tPRIMARY KEY ".$key_name." (" . 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) DEFAULT CHARACTER SET {$this->db->char_set} COLLATE {$this->db->dbcollat};";
+
+               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 = 'ALTER TABLE '.$this->db->_protect_identifiers($table_name)." RENAME TO ".$this->db->_protect_identifiers($new_table_name);
+               return $sql;
+       }
+
+}
+
+/* End of file mysqli_forge.php */
+/* Location: ./system/database/drivers/mysqli/mysqli_forge.php */
\ No newline at end of file
diff --git a/system/database/drivers/mysqli/mysqli_result.php b/system/database/drivers/mysqli/mysqli_result.php
new file mode 100755 (executable)
index 0000000..c4d8f5d
--- /dev/null
@@ -0,0 +1,169 @@
+<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+/**
+ * CodeIgniter
+ *
+ * An open source application development framework for PHP 5.1.6 or newer
+ *
+ * @package            CodeIgniter
+ * @author             ExpressionEngine Dev Team
+ * @copyright  Copyright (c) 2008 - 2011, EllisLab, Inc.
+ * @license            http://codeigniter.com/user_guide/license.html
+ * @link               http://codeigniter.com
+ * @since              Version 1.0
+ * @filesource
+ */
+
+// ------------------------------------------------------------------------
+
+/**
+ * MySQLi Result Class
+ *
+ * This class extends the parent result class: CI_DB_result
+ *
+ * @category   Database
+ * @author             ExpressionEngine Dev Team
+ * @link               http://codeigniter.com/user_guide/database/
+ */
+class CI_DB_mysqli_result extends CI_DB_result {
+
+       /**
+        * Number of rows in the result set
+        *
+        * @access      public
+        * @return      integer
+        */
+       function num_rows()
+       {
+               return @mysqli_num_rows($this->result_id);
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Number of fields in the result set
+        *
+        * @access      public
+        * @return      integer
+        */
+       function num_fields()
+       {
+               return @mysqli_num_fields($this->result_id);
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Fetch Field Names
+        *
+        * Generates an array of column names
+        *
+        * @access      public
+        * @return      array
+        */
+       function list_fields()
+       {
+               $field_names = array();
+               while ($field = mysqli_fetch_field($this->result_id))
+               {
+                       $field_names[] = $field->name;
+               }
+
+               return $field_names;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Field data
+        *
+        * Generates an array of objects containing field meta-data
+        *
+        * @access      public
+        * @return      array
+        */
+       function field_data()
+       {
+               $retval = array();
+               while ($field = mysqli_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;
+                       $F->primary_key = ($field->flags & MYSQLI_PRI_KEY_FLAG) ? 1 : 0;
+
+                       $retval[] = $F;
+               }
+
+               return $retval;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Free the result
+        *
+        * @return      null
+        */
+       function free_result()
+       {
+               if (is_object($this->result_id))
+               {
+                       mysqli_free_result($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 mysqli_data_seek($this->result_id, $n);
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Result - associative array
+        *
+        * Returns the result set as an array
+        *
+        * @access      private
+        * @return      array
+        */
+       function _fetch_assoc()
+       {
+               return mysqli_fetch_assoc($this->result_id);
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Result - object
+        *
+        * Returns the result set as an object
+        *
+        * @access      private
+        * @return      object
+        */
+       function _fetch_object()
+       {
+               return mysqli_fetch_object($this->result_id);
+       }
+
+}
+
+
+/* End of file mysqli_result.php */
+/* Location: ./system/database/drivers/mysqli/mysqli_result.php */
\ No newline at end of file
diff --git a/system/database/drivers/mysqli/mysqli_utility.php b/system/database/drivers/mysqli/mysqli_utility.php
new file mode 100755 (executable)
index 0000000..e17889b
--- /dev/null
@@ -0,0 +1,87 @@
+<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+/**
+ * CodeIgniter
+ *
+ * An open source application development framework for PHP 5.1.6 or newer
+ *
+ * @package            CodeIgniter
+ * @author             ExpressionEngine Dev Team
+ * @copyright  Copyright (c) 2008 - 2011, EllisLab, Inc.
+ * @license            http://codeigniter.com/user_guide/license.html
+ * @link               http://codeigniter.com
+ * @since              Version 1.0
+ * @filesource
+ */
+
+// ------------------------------------------------------------------------
+
+/**
+ * MySQLi Utility Class
+ *
+ * @category   Database
+ * @author             ExpressionEngine Dev Team
+ * @link               http://codeigniter.com/user_guide/database/
+ */
+class CI_DB_mysqli_utility extends CI_DB_utility {
+
+       /**
+        * List databases
+        *
+        * @access      private
+        * @return      bool
+        */
+       function _list_databases()
+       {
+               return "SHOW DATABASES";
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Optimize table query
+        *
+        * Generates a platform-specific query so that a table can be optimized
+        *
+        * @access      private
+        * @param       string  the table name
+        * @return      object
+        */
+       function _optimize_table($table)
+       {
+               return "OPTIMIZE TABLE ".$this->db->_escape_identifiers($table);
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Repair table query
+        *
+        * Generates a platform-specific query so that a table can be repaired
+        *
+        * @access      private
+        * @param       string  the table name
+        * @return      object
+        */
+       function _repair_table($table)
+       {
+               return "REPAIR TABLE ".$this->db->_escape_identifiers($table);
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * MySQLi Export
+        *
+        * @access      private
+        * @param       array   Preferences
+        * @return      mixed
+        */
+       function _backup($params = array())
+       {
+               // Currently unsupported
+               return $this->db->display_error('db_unsuported_feature');
+       }
+}
+
+/* End of file mysqli_utility.php */
+/* Location: ./system/database/drivers/mysqli/mysqli_utility.php */
\ No newline at end of file
diff --git a/system/database/drivers/oci8/index.html b/system/database/drivers/oci8/index.html
new file mode 100755 (executable)
index 0000000..c942a79
--- /dev/null
@@ -0,0 +1,10 @@
+<html>
+<head>
+       <title>403 Forbidden</title>
+</head>
+<body>
+
+<p>Directory access is forbidden.</p>
+
+</body>
+</html>
\ No newline at end of file
diff --git a/system/database/drivers/oci8/oci8_driver.php b/system/database/drivers/oci8/oci8_driver.php
new file mode 100755 (executable)
index 0000000..14df104
--- /dev/null
@@ -0,0 +1,777 @@
+<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+/**
+ * CodeIgniter
+ *
+ * An open source application development framework for PHP 5.1.6 or newer
+ *
+ * @package            CodeIgniter
+ * @author             ExpressionEngine Dev Team
+ * @copyright   Copyright (c) 2008 - 2011, EllisLab, Inc.
+ * @license            http://codeigniter.com/user_guide/license.html
+ * @link               http://codeigniter.com
+ * @since              Version 1.0
+ * @filesource
+ */
+
+// ------------------------------------------------------------------------
+
+/**
+ * oci8 Database Adapter Class
+ *
+ * Note: _DB is an extender class that the app controller
+ * creates dynamically based on whether the active record
+ * class is being used or not.
+ *
+ * @package            CodeIgniter
+ * @subpackage  Drivers
+ * @category   Database
+ * @author             ExpressionEngine Dev Team
+ * @link               http://codeigniter.com/user_guide/database/
+ */
+
+/**
+ * oci8 Database Adapter Class
+ *
+ * This is a modification of the DB_driver class to
+ * permit access to oracle databases
+ *
+ * NOTE: this uses the PHP 4 oci methods
+ *
+ * @author       Kelly McArdle
+ *
+ */
+
+class CI_DB_oci8_driver extends CI_DB {
+
+       var $dbdriver = 'oci8';
+
+       // The character used for excaping
+       var $_escape_char = '"';
+
+       // clause and character used for LIKE escape sequences
+       var $_like_escape_str = " escape '%s' ";
+       var $_like_escape_chr = '!';
+
+       /**
+        * The syntax to count rows is slightly different across different
+        * database engines, so this string appears in each driver and is
+        * used for the count_all() and count_all_results() functions.
+        */
+       var $_count_string = "SELECT COUNT(1) AS ";
+       var $_random_keyword = ' ASC'; // not currently supported
+
+       // Set "auto commit" by default
+       var $_commit = OCI_COMMIT_ON_SUCCESS;
+
+       // need to track statement id and cursor id
+       var $stmt_id;
+       var $curs_id;
+
+       // if we use a limit, we will add a field that will
+       // throw off num_fields later
+       var $limit_used;
+
+       /**
+        * Non-persistent database connection
+        *
+        * @access  private called by the base class
+        * @return  resource
+        */
+       function db_connect()
+       {
+               return @ocilogon($this->username, $this->password, $this->hostname);
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Persistent database connection
+        *
+        * @access  private called by the base class
+        * @return  resource
+        */
+       function db_pconnect()
+       {
+               return @ociplogon($this->username, $this->password, $this->hostname);
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * 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()
+       {
+               // not implemented in oracle
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Select the database
+        *
+        * @access  private called by the base class
+        * @return  resource
+        */
+       function db_select()
+       {
+               return TRUE;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Set client character set
+        *
+        * @access      public
+        * @param       string
+        * @param       string
+        * @return      resource
+        */
+       function db_set_charset($charset, $collation)
+       {
+               // @todo - add support if needed
+               return TRUE;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Version number query string
+        *
+        * @access  public
+        * @return  string
+        */
+       function _version()
+       {
+               return ociserverversion($this->conn_id);
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Execute the query
+        *
+        * @access  private called by the base class
+        * @param   string  an SQL query
+        * @return  resource
+        */
+       function _execute($sql)
+       {
+               // oracle must parse the query before it is run. All of the actions with
+               // the query are based on the statement id returned by ociparse
+               $this->stmt_id = FALSE;
+               $this->_set_stmt_id($sql);
+               ocisetprefetch($this->stmt_id, 1000);
+               return @ociexecute($this->stmt_id, $this->_commit);
+       }
+
+       /**
+        * Generate a statement ID
+        *
+        * @access  private
+        * @param   string  an SQL query
+        * @return  none
+        */
+       function _set_stmt_id($sql)
+       {
+               if ( ! is_resource($this->stmt_id))
+               {
+                       $this->stmt_id = ociparse($this->conn_id, $this->_prep_query($sql));
+               }
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * 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)
+       {
+               return $sql;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * getCursor.  Returns a cursor from the datbase
+        *
+        * @access  public
+        * @return  cursor id
+        */
+       function get_cursor()
+       {
+               $this->curs_id = ocinewcursor($this->conn_id);
+               return $this->curs_id;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Stored Procedure.  Executes a stored procedure
+        *
+        * @access  public
+        * @param   package      package stored procedure is in
+        * @param   procedure   stored procedure to execute
+        * @param   params        array of parameters
+        * @return  array
+        *
+        * params array keys
+        *
+        * KEY    OPTIONAL      NOTES
+        * name         no              the name of the parameter should be in :<param_name> format
+        * value        no              the value of the parameter.  If this is an OUT or IN OUT parameter,
+        *                                      this should be a reference to a variable
+        * type         yes             the type of the parameter
+        * length       yes             the max size of the parameter
+        */
+       function stored_procedure($package, $procedure, $params)
+       {
+               if ($package == '' OR $procedure == '' OR ! is_array($params))
+               {
+                       if ($this->db_debug)
+                       {
+                               log_message('error', 'Invalid query: '.$package.'.'.$procedure);
+                               return $this->display_error('db_invalid_query');
+                       }
+                       return FALSE;
+               }
+
+               // build the query string
+               $sql = "begin $package.$procedure(";
+
+               $have_cursor = FALSE;
+               foreach ($params as $param)
+               {
+                       $sql .= $param['name'] . ",";
+
+                       if (array_key_exists('type', $param) && ($param['type'] == OCI_B_CURSOR))
+                       {
+                               $have_cursor = TRUE;
+                       }
+               }
+               $sql = trim($sql, ",") . "); end;";
+
+               $this->stmt_id = FALSE;
+               $this->_set_stmt_id($sql);
+               $this->_bind_params($params);
+               $this->query($sql, FALSE, $have_cursor);
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Bind parameters
+        *
+        * @access  private
+        * @return  none
+        */
+       function _bind_params($params)
+       {
+               if ( ! is_array($params) OR ! is_resource($this->stmt_id))
+               {
+                       return;
+               }
+
+               foreach ($params as $param)
+               {
+                       foreach (array('name', 'value', 'type', 'length') as $val)
+                       {
+                               if ( ! isset($param[$val]))
+                               {
+                                       $param[$val] = '';
+                               }
+                       }
+
+                       ocibindbyname($this->stmt_id, $param['name'], $param['value'], $param['length'], $param['type']);
+               }
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * 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;
+
+               $this->_commit = OCI_DEFAULT;
+               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;
+               }
+
+               $ret = OCIcommit($this->conn_id);
+               $this->_commit = OCI_COMMIT_ON_SUCCESS;
+               return $ret;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * 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;
+               }
+
+               $ret = OCIrollback($this->conn_id);
+               $this->_commit = OCI_COMMIT_ON_SUCCESS;
+               return $ret;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * 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;
+               }
+
+               $str = remove_invisible_characters($str);
+
+               // 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);
+               }
+
+               return $str;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Affected Rows
+        *
+        * @access  public
+        * @return  integer
+        */
+       function affected_rows()
+       {
+               return @ocirowcount($this->stmt_id);
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Insert ID
+        *
+        * @access  public
+        * @return  integer
+        */
+       function insert_id()
+       {
+               // not supported in oracle
+               return $this->display_error('db_unsupported_function');
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * "Count All" query
+        *
+        * Generates a platform-specific query string that counts all records in
+        * the specified database
+        *
+        * @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 == FALSE)
+               {
+                       return 0;
+               }
+
+               $row = $query->row();
+               return (int) $row->numrows;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Show 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 = "SELECT TABLE_NAME FROM ALL_TABLES";
+
+               if ($prefix_limit !== FALSE AND $this->dbprefix != '')
+               {
+                       $sql .= " WHERE TABLE_NAME LIKE '".$this->escape_like_str($this->dbprefix)."%' ".sprintf($this->_like_escape_str, $this->_like_escape_chr);
+               }
+
+               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 "SELECT COLUMN_NAME FROM all_tab_columns WHERE table_name = '$table'";
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * 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." where rownum = 1";
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * The error message string
+        *
+        * @access  private
+        * @return  string
+        */
+       function _error_message()
+       {
+               $error = ocierror($this->conn_id);
+               return $error['message'];
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * The error message number
+        *
+        * @access  private
+        * @return  integer
+        */
+       function _error_number()
+       {
+               $error = ocierror($this->conn_id);
+               return $error['code'];
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * 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).")";
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * 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[] = $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;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * 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 ".$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)
+       {
+               $limit = $offset + $limit;
+               $newsql = "SELECT * FROM (select inner_query.*, rownum rnum FROM ($sql) inner_query WHERE rownum < $limit)";
+
+               if ($offset != 0)
+               {
+                       $newsql .= " WHERE rnum >= $offset";
+               }
+
+               // remember that we used limits
+               $this->limit_used = TRUE;
+
+               return $newsql;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Close DB Connection
+        *
+        * @access  public
+        * @param   resource
+        * @return  void
+        */
+       function _close($conn_id)
+       {
+               @ocilogoff($conn_id);
+       }
+
+
+}
+
+
+
+/* End of file oci8_driver.php */
+/* Location: ./system/database/drivers/oci8/oci8_driver.php */
\ No newline at end of file
diff --git a/system/database/drivers/oci8/oci8_forge.php b/system/database/drivers/oci8/oci8_forge.php
new file mode 100755 (executable)
index 0000000..3cd1758
--- /dev/null
@@ -0,0 +1,248 @@
+<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+/**
+ * CodeIgniter
+ *
+ * An open source application development framework for PHP 5.1.6 or newer
+ *
+ * @package            CodeIgniter
+ * @author             ExpressionEngine Dev Team
+ * @copyright  Copyright (c) 2008 - 2011, EllisLab, Inc.
+ * @license            http://codeigniter.com/user_guide/license.html
+ * @link               http://codeigniter.com
+ * @since              Version 1.0
+ * @filesource
+ */
+
+// ------------------------------------------------------------------------
+
+/**
+ * Oracle Forge Class
+ *
+ * @category   Database
+ * @author             ExpressionEngine Dev Team
+ * @link               http://codeigniter.com/user_guide/database/
+ */
+class CI_DB_oci8_forge extends CI_DB_forge {
+
+       /**
+        * Create database
+        *
+        * @access      public
+        * @param       string  the database name
+        * @return      bool
+        */
+       function _create_database($name)
+       {
+               return FALSE;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Drop database
+        *
+        * @access      private
+        * @param       string  the database name
+        * @return      bool
+        */
+       function _drop_database($name)
+       {
+               return FALSE;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Create Table
+        *
+        * @access      private
+        * @param       string  the table name
+        * @param       array   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 ';
+               }
+
+               $sql .= $this->db->_escape_identifiers($table)." (";
+               $current_field_count = 0;
+
+               foreach ($fields as $field=>$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);
+
+                               $sql .=  ' '.$attributes['TYPE'];
+
+                               if (array_key_exists('CONSTRAINT', $attributes))
+                               {
+                                       $sql .= '('.$attributes['CONSTRAINT'].')';
+                               }
+
+                               if (array_key_exists('UNSIGNED', $attributes) && $attributes['UNSIGNED'] === TRUE)
+                               {
+                                       $sql .= ' UNSIGNED';
+                               }
+
+                               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';
+                               }
+                       }
+
+                       // don't add a comma on the end of the last field
+                       if (++$current_field_count < count($fields))
+                       {
+                               $sql .= ',';
+                       }
+               }
+
+               if (count($primary_keys) > 0)
+               {
+                       $primary_keys = $this->db->_protect_identifiers($primary_keys);
+                       $sql .= ",\n\tPRIMARY KEY (" . implode(', ', $primary_keys) . ")";
+               }
+
+               if (is_array($keys) && count($keys) > 0)
+               {
+                       foreach ($keys as $key)
+                       {
+                               if (is_array($key))
+                               {
+                                       $key = $this->db->_protect_identifiers($key);
+                               }
+                               else
+                               {
+                                       $key = array($this->db->_protect_identifiers($key));
+                               }
+
+                               $sql .= ",\n\tUNIQUE COLUMNS (" . implode(', ', $key) . ")";
+                       }
+               }
+
+               $sql .= "\n)";
+
+               return $sql;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Drop Table
+        *
+        * @access      private
+        * @return      bool
+        */
+       function _drop_table($table)
+       {
+               return FALSE;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * 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       string  the table name
+        * @param       string  the column definition
+        * @param       string  the default value
+        * @param       boolean should 'NOT NULL' be added
+        * @param       string  the field after which we should add the new field
+        * @return      object
+        */
+       function _alter_table($alter_type, $table, $column_name, $column_definition = '', $default_value = '', $null = '', $after_field = '')
+       {
+               $sql = 'ALTER TABLE '.$this->db->_protect_identifiers($table)." $alter_type ".$this->db->_protect_identifiers($column_name);
+
+               // DROP has everything it needs now.
+               if ($alter_type == 'DROP')
+               {
+                       return $sql;
+               }
+
+               $sql .= " $column_definition";
+
+               if ($default_value != '')
+               {
+                       $sql .= " DEFAULT \"$default_value\"";
+               }
+
+               if ($null === NULL)
+               {
+                       $sql .= ' NULL';
+               }
+               else
+               {
+                       $sql .= ' NOT NULL';
+               }
+
+               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 = 'ALTER TABLE '.$this->db->_protect_identifiers($table_name)." RENAME TO ".$this->db->_protect_identifiers($new_table_name);
+               return $sql;
+       }
+
+
+}
+
+/* End of file oci8_forge.php */
+/* Location: ./system/database/drivers/oci8/oci8_forge.php */
\ No newline at end of file
diff --git a/system/database/drivers/oci8/oci8_result.php b/system/database/drivers/oci8/oci8_result.php
new file mode 100755 (executable)
index 0000000..88531b4
--- /dev/null
@@ -0,0 +1,249 @@
+<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+/**
+ * CodeIgniter
+ *
+ * An open source application development framework for PHP 5.1.6 or newer
+ *
+ * @package            CodeIgniter
+ * @author             ExpressionEngine Dev Team
+ * @copyright   Copyright (c) 2008 - 2011, EllisLab, Inc.
+ * @license            http://codeigniter.com/user_guide/license.html
+ * @link               http://codeigniter.com
+ * @since              Version 1.0
+ * @filesource
+ */
+
+// ------------------------------------------------------------------------
+
+/**
+ * oci8 Result Class
+ *
+ * This class extends the parent result class: CI_DB_result
+ *
+ * @category   Database
+ * @author             ExpressionEngine Dev Team
+ * @link               http://codeigniter.com/user_guide/database/
+ */
+class CI_DB_oci8_result extends CI_DB_result {
+
+       var $stmt_id;
+       var $curs_id;
+       var $limit_used;
+
+       /**
+        * Number of rows in the result set.
+        *
+        * Oracle doesn't have a graceful way to retun the number of rows
+        * so we have to use what amounts to a hack.
+        *
+        *
+        * @access  public
+        * @return  integer
+        */
+       function num_rows()
+       {
+               $rowcount = count($this->result_array());
+               @ociexecute($this->stmt_id);
+
+               if ($this->curs_id)
+               {
+                       @ociexecute($this->curs_id);
+               }
+
+               return $rowcount;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Number of fields in the result set
+        *
+        * @access  public
+        * @return  integer
+        */
+       function num_fields()
+       {
+               $count = @ocinumcols($this->stmt_id);
+
+               // if we used a limit we subtract it
+               if ($this->limit_used)
+               {
+                       $count = $count - 1;
+               }
+
+               return $count;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Fetch Field Names
+        *
+        * Generates an array of column names
+        *
+        * @access      public
+        * @return      array
+        */
+       function list_fields()
+       {
+               $field_names = array();
+               $fieldCount = $this->num_fields();
+               for ($c = 1; $c <= $fieldCount; $c++)
+               {
+                       $field_names[] = ocicolumnname($this->stmt_id, $c);
+               }
+               return $field_names;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Field data
+        *
+        * Generates an array of objects containing field meta-data
+        *
+        * @access  public
+        * @return  array
+        */
+       function field_data()
+       {
+               $retval = array();
+               $fieldCount = $this->num_fields();
+               for ($c = 1; $c <= $fieldCount; $c++)
+               {
+                       $F                              = new stdClass();
+                       $F->name                = ocicolumnname($this->stmt_id, $c);
+                       $F->type                = ocicolumntype($this->stmt_id, $c);
+                       $F->max_length  = ocicolumnsize($this->stmt_id, $c);
+
+                       $retval[] = $F;
+               }
+
+               return $retval;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Free the result
+        *
+        * @return      null
+        */
+       function free_result()
+       {
+               if (is_resource($this->result_id))
+               {
+                       ocifreestatement($this->result_id);
+                       $this->result_id = FALSE;
+               }
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Result - associative array
+        *
+        * Returns the result set as an array
+        *
+        * @access  private
+        * @return  array
+        */
+       function _fetch_assoc(&$row)
+       {
+               $id = ($this->curs_id) ? $this->curs_id : $this->stmt_id;
+
+               return ocifetchinto($id, $row, OCI_ASSOC + OCI_RETURN_NULLS);
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Result - object
+        *
+        * Returns the result set as an object
+        *
+        * @access  private
+        * @return  object
+        */
+       function _fetch_object()
+       {
+               $result = array();
+
+               // If PHP 5 is being used we can fetch an result object
+               if (function_exists('oci_fetch_object'))
+               {
+                       $id = ($this->curs_id) ? $this->curs_id : $this->stmt_id;
+
+                       return @oci_fetch_object($id);
+               }
+
+               // If PHP 4 is being used we have to build our own result
+               foreach ($this->result_array() as $key => $val)
+               {
+                       $obj = new stdClass();
+                       if (is_array($val))
+                       {
+                               foreach ($val as $k => $v)
+                               {
+                                       $obj->$k = $v;
+                               }
+                       }
+                       else
+                       {
+                               $obj->$key = $val;
+                       }
+
+                       $result[] = $obj;
+               }
+
+               return $result;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Query result.  "array" version.
+        *
+        * @access  public
+        * @return  array
+        */
+       function result_array()
+       {
+               if (count($this->result_array) > 0)
+               {
+                       return $this->result_array;
+               }
+
+               // oracle's fetch functions do not return arrays.
+               // The information is returned in reference parameters
+               $row = NULL;
+               while ($this->_fetch_assoc($row))
+               {
+                       $this->result_array[] = $row;
+               }
+
+               return $this->result_array;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * 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 FALSE; // Not needed
+       }
+
+}
+
+
+/* End of file oci8_result.php */
+/* Location: ./system/database/drivers/oci8/oci8_result.php */
\ No newline at end of file
diff --git a/system/database/drivers/oci8/oci8_utility.php b/system/database/drivers/oci8/oci8_utility.php
new file mode 100755 (executable)
index 0000000..854b467
--- /dev/null
@@ -0,0 +1,87 @@
+<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+/**
+ * CodeIgniter
+ *
+ * An open source application development framework for PHP 5.1.6 or newer
+ *
+ * @package            CodeIgniter
+ * @author             ExpressionEngine Dev Team
+ * @copyright  Copyright (c) 2008 - 2011, EllisLab, Inc.
+ * @license            http://codeigniter.com/user_guide/license.html
+ * @link               http://codeigniter.com
+ * @since              Version 1.0
+ * @filesource
+ */
+
+// ------------------------------------------------------------------------
+
+/**
+ * Oracle Utility Class
+ *
+ * @category   Database
+ * @author             ExpressionEngine Dev Team
+ * @link               http://codeigniter.com/user_guide/database/
+ */
+class CI_DB_oci8_utility extends CI_DB_utility {
+
+       /**
+        * List databases
+        *
+        * @access      private
+        * @return      bool
+        */
+       function _list_databases()
+       {
+               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
+        */
+       function _optimize_table($table)
+       {
+               return FALSE; // Is this supported in Oracle?
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Repair table query
+        *
+        * Generates a platform-specific query so that a table can be repaired
+        *
+        * @access      private
+        * @param       string  the table name
+        * @return      object
+        */
+       function _repair_table($table)
+       {
+               return FALSE; // Is this supported in Oracle?
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Oracle Export
+        *
+        * @access      private
+        * @param       array   Preferences
+        * @return      mixed
+        */
+       function _backup($params = array())
+       {
+               // Currently unsupported
+               return $this->db->display_error('db_unsuported_feature');
+       }
+}
+
+/* End of file oci8_utility.php */
+/* Location: ./system/database/drivers/oci8/oci8_utility.php */
\ No newline at end of file
diff --git a/system/database/drivers/odbc/index.html b/system/database/drivers/odbc/index.html
new file mode 100755 (executable)
index 0000000..c942a79
--- /dev/null
@@ -0,0 +1,10 @@
+<html>
+<head>
+       <title>403 Forbidden</title>
+</head>
+<body>
+
+<p>Directory access is forbidden.</p>
+
+</body>
+</html>
\ No newline at end of file
diff --git a/system/database/drivers/odbc/odbc_driver.php b/system/database/drivers/odbc/odbc_driver.php
new file mode 100755 (executable)
index 0000000..81e0d7c
--- /dev/null
@@ -0,0 +1,636 @@
+<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+/**
+ * CodeIgniter
+ *
+ * An open source application development framework for PHP 5.1.6 or newer
+ *
+ * @package            CodeIgniter
+ * @author             ExpressionEngine Dev Team
+ * @copyright  Copyright (c) 2008 - 2011, EllisLab, Inc.
+ * @license            http://codeigniter.com/user_guide/license.html
+ * @link               http://codeigniter.com
+ * @since              Version 1.0
+ * @filesource
+ */
+
+// ------------------------------------------------------------------------
+
+/**
+ * ODBC Database Adapter Class
+ *
+ * Note: _DB is an extender class that the app controller
+ * creates dynamically based on whether the active record
+ * class is being used or not.
+ *
+ * @package            CodeIgniter
+ * @subpackage Drivers
+ * @category   Database
+ * @author             ExpressionEngine Dev Team
+ * @link               http://codeigniter.com/user_guide/database/
+ */
+class CI_DB_odbc_driver extends CI_DB {
+
+       var $dbdriver = 'odbc';
+
+       // the character used to excape - not necessary for ODBC
+       var $_escape_char = '';
+
+       // clause and character used for LIKE escape sequences
+       var $_like_escape_str = " {escape '%s'} ";
+       var $_like_escape_chr = '!';
+
+       /**
+        * The syntax to count rows is slightly different across different
+        * database engines, so this string appears in each driver and is
+        * used for the count_all() and count_all_results() functions.
+        */
+       var $_count_string = "SELECT COUNT(*) AS ";
+       var $_random_keyword;
+
+
+       function CI_DB_odbc_driver($params)
+       {
+               parent::CI_DB($params);
+
+               $this->_random_keyword = ' RND('.time().')'; // database specific random keyword
+       }
+
+       /**
+        * Non-persistent database connection
+        *
+        * @access      private called by the base class
+        * @return      resource
+        */
+       function db_connect()
+       {
+               return @odbc_connect($this->hostname, $this->username, $this->password);
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Persistent database connection
+        *
+        * @access      private called by the base class
+        * @return      resource
+        */
+       function db_pconnect()
+       {
+               return @odbc_pconnect($this->hostname, $this->username, $this->password);
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * 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()
+       {
+               // not implemented in odbc
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Select the database
+        *
+        * @access      private called by the base class
+        * @return      resource
+        */
+       function db_select()
+       {
+               // Not needed for ODBC
+               return TRUE;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Set client character set
+        *
+        * @access      public
+        * @param       string
+        * @param       string
+        * @return      resource
+        */
+       function db_set_charset($charset, $collation)
+       {
+               // @todo - add support if needed
+               return TRUE;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Version number query string
+        *
+        * @access      public
+        * @return      string
+        */
+       function _version()
+       {
+               return "SELECT version() AS ver";
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * 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 @odbc_exec($this->conn_id, $sql);
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * 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)
+       {
+               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;
+
+               return odbc_autocommit($this->conn_id, FALSE);
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * 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;
+               }
+
+               $ret = odbc_commit($this->conn_id);
+               odbc_autocommit($this->conn_id, TRUE);
+               return $ret;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * 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;
+               }
+
+               $ret = odbc_rollback($this->conn_id);
+               odbc_autocommit($this->conn_id, TRUE);
+               return $ret;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * 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;
+               }
+
+               // ODBC doesn't require escaping
+               $str = remove_invisible_characters($str);
+
+               // 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);
+               }
+
+               return $str;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Affected Rows
+        *
+        * @access      public
+        * @return      integer
+        */
+       function affected_rows()
+       {
+               return @odbc_num_rows($this->conn_id);
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Insert ID
+        *
+        * @access      public
+        * @return      integer
+        */
+       function insert_id()
+       {
+               return @odbc_insert_id($this->conn_id);
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * "Count All" query
+        *
+        * Generates a platform-specific query string that counts all records in
+        * the specified database
+        *
+        * @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;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Show 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 FROM `".$this->database."`";
+
+               if ($prefix_limit !== FALSE AND $this->dbprefix != '')
+               {
+                       //$sql .= " LIKE '".$this->escape_like_str($this->dbprefix)."%' ".sprintf($this->_like_escape_str, $this->_like_escape_chr);
+                       return FALSE; // not currently supported
+               }
+
+               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 ".$table;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * 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 TOP 1 FROM ".$table;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * The error message string
+        *
+        * @access      private
+        * @return      string
+        */
+       function _error_message()
+       {
+               return odbc_errormsg($this->conn_id);
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * The error message number
+        *
+        * @access      private
+        * @return      integer
+        */
+       function _error_number()
+       {
+               return odbc_error($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).")";
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * 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[] = $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;
+       }
+
+
+       // --------------------------------------------------------------------
+
+       /**
+        * 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 $this->_delete($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)
+       {
+               // Does ODBC doesn't use the LIMIT clause?
+               return $sql;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Close DB Connection
+        *
+        * @access      public
+        * @param       resource
+        * @return      void
+        */
+       function _close($conn_id)
+       {
+               @odbc_close($conn_id);
+       }
+
+
+}
+
+
+
+/* End of file odbc_driver.php */
+/* Location: ./system/database/drivers/odbc/odbc_driver.php */
\ No newline at end of file
diff --git a/system/database/drivers/odbc/odbc_forge.php b/system/database/drivers/odbc/odbc_forge.php
new file mode 100755 (executable)
index 0000000..3ec86b4
--- /dev/null
@@ -0,0 +1,266 @@
+<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+/**
+ * CodeIgniter
+ *
+ * An open source application development framework for PHP 5.1.6 or newer
+ *
+ * @package            CodeIgniter
+ * @author             ExpressionEngine Dev Team
+ * @copyright  Copyright (c) 2008 - 2011, EllisLab, Inc.
+ * @license            http://codeigniter.com/user_guide/license.html
+ * @link               http://codeigniter.com
+ * @since              Version 1.0
+ * @filesource
+ */
+
+// ------------------------------------------------------------------------
+
+/**
+ * ODBC Forge Class
+ *
+ * @category   Database
+ * @author             ExpressionEngine Dev Team
+ * @link               http://codeigniter.com/database/
+ */
+class CI_DB_odbc_forge extends CI_DB_forge {
+
+       /**
+        * Create database
+        *
+        * @access      private
+        * @param       string  the database name
+        * @return      bool
+        */
+       function _create_database()
+       {
+               // ODBC has no "create database" command since it's
+               // designed to connect to an existing database
+               if ($this->db->db_debug)
+               {
+                       return $this->db->display_error('db_unsuported_feature');
+               }
+               return FALSE;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Drop database
+        *
+        * @access      private
+        * @param       string  the database name
+        * @return      bool
+        */
+       function _drop_database($name)
+       {
+               // ODBC has no "drop database" command since it's
+               // designed to connect to an existing database
+               if ($this->db->db_debug)
+               {
+                       return $this->db->display_error('db_unsuported_feature');
+               }
+               return FALSE;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Create Table
+        *
+        * @access      private
+        * @param       string  the table name
+        * @param       array   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 ';
+               }
+
+               $sql .= $this->db->_escape_identifiers($table)." (";
+               $current_field_count = 0;
+
+               foreach ($fields as $field=>$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);
+
+                               $sql .=  ' '.$attributes['TYPE'];
+
+                               if (array_key_exists('CONSTRAINT', $attributes))
+                               {
+                                       $sql .= '('.$attributes['CONSTRAINT'].')';
+                               }
+
+                               if (array_key_exists('UNSIGNED', $attributes) && $attributes['UNSIGNED'] === TRUE)
+                               {
+                                       $sql .= ' UNSIGNED';
+                               }
+
+                               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';
+                               }
+                       }
+
+                       // don't add a comma on the end of the last field
+                       if (++$current_field_count < count($fields))
+                       {
+                               $sql .= ',';
+                       }
+               }
+
+               if (count($primary_keys) > 0)
+               {
+                       $primary_keys = $this->db->_protect_identifiers($primary_keys);
+                       $sql .= ",\n\tPRIMARY KEY (" . implode(', ', $primary_keys) . ")";
+               }
+
+               if (is_array($keys) && count($keys) > 0)
+               {
+                       foreach ($keys as $key)
+                       {
+                               if (is_array($key))
+                               {
+                                       $key = $this->db->_protect_identifiers($key);
+                               }
+                               else
+                               {
+                                       $key = array($this->db->_protect_identifiers($key));
+                               }
+
+                               $sql .= ",\n\tFOREIGN KEY (" . implode(', ', $key) . ")";
+                       }
+               }
+
+               $sql .= "\n)";
+
+               return $sql;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Drop Table
+        *
+        * @access      private
+        * @return      bool
+        */
+       function _drop_table($table)
+       {
+               // Not a supported ODBC feature
+               if ($this->db->db_debug)
+               {
+                       return $this->db->display_error('db_unsuported_feature');
+               }
+               return FALSE;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * 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       string  the table name
+        * @param       string  the column definition
+        * @param       string  the default value
+        * @param       boolean should 'NOT NULL' be added
+        * @param       string  the field after which we should add the new field
+        * @return      object
+        */
+       function _alter_table($alter_type, $table, $column_name, $column_definition = '', $default_value = '', $null = '', $after_field = '')
+       {
+               $sql = 'ALTER TABLE '.$this->db->_protect_identifiers($table)." $alter_type ".$this->db->_protect_identifiers($column_name);
+
+               // DROP has everything it needs now.
+               if ($alter_type == 'DROP')
+               {
+                       return $sql;
+               }
+
+               $sql .= " $column_definition";
+
+               if ($default_value != '')
+               {
+                       $sql .= " DEFAULT \"$default_value\"";
+               }
+
+               if ($null === NULL)
+               {
+                       $sql .= ' NULL';
+               }
+               else
+               {
+                       $sql .= ' NOT NULL';
+               }
+
+               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 = 'ALTER TABLE '.$this->db->_protect_identifiers($table_name)." RENAME TO ".$this->db->_protect_identifiers($new_table_name);
+               return $sql;
+       }
+
+
+}
+
+/* End of file odbc_forge.php */
+/* Location: ./system/database/drivers/odbc/odbc_forge.php */
\ No newline at end of file
diff --git a/system/database/drivers/odbc/odbc_result.php b/system/database/drivers/odbc/odbc_result.php
new file mode 100755 (executable)
index 0000000..5d64a46
--- /dev/null
@@ -0,0 +1,228 @@
+<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+/**
+ * CodeIgniter
+ *
+ * An open source application development framework for PHP 5.1.6 or newer
+ *
+ * @package            CodeIgniter
+ * @author             ExpressionEngine Dev Team
+ * @copyright  Copyright (c) 2008 - 2011, EllisLab, Inc.
+ * @license            http://codeigniter.com/user_guide/license.html
+ * @link               http://codeigniter.com
+ * @since              Version 1.0
+ * @filesource
+ */
+
+// ------------------------------------------------------------------------
+
+/**
+ * ODBC Result Class
+ *
+ * This class extends the parent result class: CI_DB_result
+ *
+ * @category   Database
+ * @author             ExpressionEngine Dev Team
+ * @link               http://codeigniter.com/user_guide/database/
+ */
+class CI_DB_odbc_result extends CI_DB_result {
+
+       /**
+        * Number of rows in the result set
+        *
+        * @access      public
+        * @return      integer
+        */
+       function num_rows()
+       {
+               return @odbc_num_rows($this->result_id);
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Number of fields in the result set
+        *
+        * @access      public
+        * @return      integer
+        */
+       function num_fields()
+       {
+               return @odbc_num_fields($this->result_id);
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Fetch Field Names
+        *
+        * Generates an array of column names
+        *
+        * @access      public
+        * @return      array
+        */
+       function list_fields()
+       {
+               $field_names = array();
+               for ($i = 0; $i < $this->num_fields(); $i++)
+               {
+                       $field_names[]  = odbc_field_name($this->result_id, $i);
+               }
+
+               return $field_names;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Field data
+        *
+        * Generates an array of objects containing field meta-data
+        *
+        * @access      public
+        * @return      array
+        */
+       function field_data()
+       {
+               $retval = array();
+               for ($i = 0; $i < $this->num_fields(); $i++)
+               {
+                       $F                              = new stdClass();
+                       $F->name                = odbc_field_name($this->result_id, $i);
+                       $F->type                = odbc_field_type($this->result_id, $i);
+                       $F->max_length  = odbc_field_len($this->result_id, $i);
+                       $F->primary_key = 0;
+                       $F->default             = '';
+
+                       $retval[] = $F;
+               }
+
+               return $retval;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Free the result
+        *
+        * @return      null
+        */
+       function free_result()
+       {
+               if (is_resource($this->result_id))
+               {
+                       odbc_free_result($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 FALSE;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Result - associative array
+        *
+        * Returns the result set as an array
+        *
+        * @access      private
+        * @return      array
+        */
+       function _fetch_assoc()
+       {
+               if (function_exists('odbc_fetch_object'))
+               {
+                       return odbc_fetch_array($this->result_id);
+               }
+               else
+               {
+                       return $this->_odbc_fetch_array($this->result_id);
+               }
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Result - object
+        *
+        * Returns the result set as an object
+        *
+        * @access      private
+        * @return      object
+        */
+       function _fetch_object()
+       {
+               if (function_exists('odbc_fetch_object'))
+               {
+                       return odbc_fetch_object($this->result_id);
+               }
+               else
+               {
+                       return $this->_odbc_fetch_object($this->result_id);
+               }
+       }
+
+
+       /**
+        * Result - object
+        *
+        * subsititutes the odbc_fetch_object function when
+        * not available (odbc_fetch_object requires unixODBC)
+        *
+        * @access      private
+        * @return      object
+        */
+       function _odbc_fetch_object(& $odbc_result) {
+               $rs = array();
+               $rs_obj = FALSE;
+               if (odbc_fetch_into($odbc_result, $rs)) {
+                       foreach ($rs as $k=>$v) {
+                               $field_name= odbc_field_name($odbc_result, $k+1);
+                               $rs_obj->$field_name = $v;
+                       }
+               }
+               return $rs_obj;
+       }
+
+
+       /**
+        * Result - array
+        *
+        * subsititutes the odbc_fetch_array function when
+        * not available (odbc_fetch_array requires unixODBC)
+        *
+        * @access      private
+        * @return      array
+        */
+       function _odbc_fetch_array(& $odbc_result) {
+               $rs = array();
+               $rs_assoc = FALSE;
+               if (odbc_fetch_into($odbc_result, $rs)) {
+                       $rs_assoc=array();
+                       foreach ($rs as $k=>$v) {
+                               $field_name= odbc_field_name($odbc_result, $k+1);
+                               $rs_assoc[$field_name] = $v;
+                       }
+               }
+               return $rs_assoc;
+       }
+
+}
+
+
+/* End of file odbc_result.php */
+/* Location: ./system/database/drivers/odbc/odbc_result.php */
\ No newline at end of file
diff --git a/system/database/drivers/odbc/odbc_utility.php b/system/database/drivers/odbc/odbc_utility.php
new file mode 100755 (executable)
index 0000000..d335bed
--- /dev/null
@@ -0,0 +1,103 @@
+<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+/**
+ * CodeIgniter
+ *
+ * An open source application development framework for PHP 5.1.6 or newer
+ *
+ * @package            CodeIgniter
+ * @author             ExpressionEngine Dev Team
+ * @copyright  Copyright (c) 2008 - 2011, EllisLab, Inc.
+ * @license            http://codeigniter.com/user_guide/license.html
+ * @link               http://codeigniter.com
+ * @since              Version 1.0
+ * @filesource
+ */
+
+// ------------------------------------------------------------------------
+
+/**
+ * ODBC Utility Class
+ *
+ * @category   Database
+ * @author             ExpressionEngine Dev Team
+ * @link               http://codeigniter.com/database/
+ */
+class CI_DB_odbc_utility extends CI_DB_utility {
+
+       /**
+        * List databases
+        *
+        * @access      private
+        * @return      bool
+        */
+       function _list_databases()
+       {
+               // Not sure if ODBC lets you list all databases...
+               if ($this->db->db_debug)
+               {
+                       return $this->db->display_error('db_unsuported_feature');
+               }
+               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
+        */
+       function _optimize_table($table)
+       {
+               // Not a supported ODBC feature
+               if ($this->db->db_debug)
+               {
+                       return $this->db->display_error('db_unsuported_feature');
+               }
+               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
+        */
+       function _repair_table($table)
+       {
+               // Not a supported ODBC feature
+               if ($this->db->db_debug)
+               {
+                       return $this->db->display_error('db_unsuported_feature');
+               }
+               return FALSE;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * ODBC Export
+        *
+        * @access      private
+        * @param       array   Preferences
+        * @return      mixed
+        */
+       function _backup($params = array())
+       {
+               // Currently unsupported
+               return $this->db->display_error('db_unsuported_feature');
+       }
+
+}
+
+/* End of file odbc_utility.php */
+/* Location: ./system/database/drivers/odbc/odbc_utility.php */
\ No newline at end of file
diff --git a/system/database/drivers/postgre/index.html b/system/database/drivers/postgre/index.html
new file mode 100755 (executable)
index 0000000..c942a79
--- /dev/null
@@ -0,0 +1,10 @@
+<html>
+<head>
+       <title>403 Forbidden</title>
+</head>
+<body>
+
+<p>Directory access is forbidden.</p>
+
+</body>
+</html>
\ No newline at end of file
diff --git a/system/database/drivers/postgre/postgre_driver.php b/system/database/drivers/postgre/postgre_driver.php
new file mode 100755 (executable)
index 0000000..47ff362
--- /dev/null
@@ -0,0 +1,684 @@
+<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+/**
+ * CodeIgniter
+ *
+ * An open source application development framework for PHP 5.1.6 or newer
+ *
+ * @package            CodeIgniter
+ * @author             ExpressionEngine Dev Team
+ * @copyright  Copyright (c) 2008 - 2011, EllisLab, Inc.
+ * @license            http://codeigniter.com/user_guide/license.html
+ * @link               http://codeigniter.com
+ * @since              Version 1.0
+ * @filesource
+ */
+
+// ------------------------------------------------------------------------
+
+/**
+ * Postgre Database Adapter Class
+ *
+ * Note: _DB is an extender class that the app controller
+ * creates dynamically based on whether the active record
+ * class is being used or not.
+ *
+ * @package            CodeIgniter
+ * @subpackage Drivers
+ * @category   Database
+ * @author             ExpressionEngine Dev Team
+ * @link               http://codeigniter.com/user_guide/database/
+ */
+class CI_DB_postgre_driver extends CI_DB {
+
+       var $dbdriver = 'postgre';
+
+       var $_escape_char = '"';
+
+       // clause and character used for LIKE escape sequences
+       var $_like_escape_str = " ESCAPE '%s' ";
+       var $_like_escape_chr = '!';
+
+       /**
+        * The syntax to count rows is slightly different across different
+        * database engines, so this string appears in each driver and is
+        * used for the count_all() and count_all_results() functions.
+        */
+       var $_count_string = "SELECT COUNT(*) AS ";
+       var $_random_keyword = ' RANDOM()'; // database specific random keyword
+
+       /**
+        * Connection String
+        *
+        * @access      private
+        * @return      string
+        */
+       function _connect_string()
+       {
+               $components = array(
+                                                               'hostname'      => 'host',
+                                                               'port'          => 'port',
+                                                               'database'      => 'dbname',
+                                                               'username'      => 'user',
+                                                               'password'      => 'password'
+                                                       );
+
+               $connect_string = "";
+               foreach ($components as $key => $val)
+               {
+                       if (isset($this->$key) && $this->$key != '')
+                       {
+                               $connect_string .= " $val=".$this->$key;
+                       }
+               }
+               return trim($connect_string);
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Non-persistent database connection
+        *
+        * @access      private called by the base class
+        * @return      resource
+        */
+       function db_connect()
+       {
+               return @pg_connect($this->_connect_string());
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Persistent database connection
+        *
+        * @access      private called by the base class
+        * @return      resource
+        */
+       function db_pconnect()
+       {
+               return @pg_pconnect($this->_connect_string());
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * 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 (pg_ping($this->conn_id) === FALSE)
+               {
+                       $this->conn_id = FALSE;
+               }
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Select the database
+        *
+        * @access      private called by the base class
+        * @return      resource
+        */
+       function db_select()
+       {
+               // Not needed for Postgre so we'll return TRUE
+               return TRUE;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Set client character set
+        *
+        * @access      public
+        * @param       string
+        * @param       string
+        * @return      resource
+        */
+       function db_set_charset($charset, $collation)
+       {
+               // @todo - add support if needed
+               return TRUE;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Version number query string
+        *
+        * @access      public
+        * @return      string
+        */
+       function _version()
+       {
+               return "SELECT version() AS ver";
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * 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 @pg_query($this->conn_id, $sql);
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * 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)
+       {
+               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;
+
+               return @pg_exec($this->conn_id, "begin");
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * 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;
+               }
+
+               return @pg_exec($this->conn_id, "commit");
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * 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;
+               }
+
+               return @pg_exec($this->conn_id, "rollback");
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * 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;
+               }
+
+               $str = pg_escape_string($str);
+
+               // 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);
+               }
+
+               return $str;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Affected Rows
+        *
+        * @access      public
+        * @return      integer
+        */
+       function affected_rows()
+       {
+               return @pg_affected_rows($this->result_id);
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Insert ID
+        *
+        * @access      public
+        * @return      integer
+        */
+       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;
+
+               if ($table == NULL && $v >= '8.1')
+               {
+                       $sql='SELECT LASTVAL() as ins_id';
+               }
+               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)
+               {
+                       // seq_name passed in table parameter
+                       $sql = sprintf("SELECT CURRVAL('%s') as ins_id", $table);
+               }
+               else
+               {
+                       return pg_last_oid($this->result_id);
+               }
+               $query = $this->query($sql);
+               $row = $query->row();
+               return $row->ins_id;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * "Count All" query
+        *
+        * Generates a platform-specific query string that counts all records in
+        * the specified database
+        *
+        * @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;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Show 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 = "SELECT table_name FROM information_schema.tables WHERE table_schema = 'public'";
+
+               if ($prefix_limit !== FALSE AND $this->dbprefix != '')
+               {
+                       $sql .= " AND table_name LIKE '".$this->escape_like_str($this->dbprefix)."%' ".sprintf($this->_like_escape_str, $this->_like_escape_chr);
+               }
+
+               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 "SELECT column_name FROM information_schema.columns WHERE table_name ='".$table."'";
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * 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 pg_last_error($this->conn_id);
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * The error message number
+        *
+        * @access      private
+        * @return      integer
+        */
+       function _error_number()
+       {
+               return '';
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * 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).")";
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * 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[] = $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;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * 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)
+       {
+               $sql .= "LIMIT ".$limit;
+
+               if ($offset > 0)
+               {
+                       $sql .= " OFFSET ".$offset;
+               }
+
+               return $sql;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Close DB Connection
+        *
+        * @access      public
+        * @param       resource
+        * @return      void
+        */
+       function _close($conn_id)
+       {
+               @pg_close($conn_id);
+       }
+
+
+}
+
+
+/* End of file postgre_driver.php */
+/* Location: ./system/database/drivers/postgre/postgre_driver.php */
\ No newline at end of file
diff --git a/system/database/drivers/postgre/postgre_forge.php b/system/database/drivers/postgre/postgre_forge.php
new file mode 100755 (executable)
index 0000000..91a1c68
--- /dev/null
@@ -0,0 +1,299 @@
+<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+/**
+ * CodeIgniter
+ *
+ * An open source application development framework for PHP 5.1.6 or newer
+ *
+ * @package            CodeIgniter
+ * @author             ExpressionEngine Dev Team
+ * @copyright  Copyright (c) 2008 - 2011, EllisLab, Inc.
+ * @license            http://codeigniter.com/user_guide/license.html
+ * @link               http://codeigniter.com
+ * @since              Version 1.0
+ * @filesource
+ */
+
+// ------------------------------------------------------------------------
+
+/**
+ * Postgre Forge Class
+ *
+ * @category   Database
+ * @author             ExpressionEngine Dev Team
+ * @link               http://codeigniter.com/user_guide/database/
+ */
+class CI_DB_postgre_forge extends CI_DB_forge {
+
+       /**
+        * Create database
+        *
+        * @access      private
+        * @param       string  the database name
+        * @return      bool
+        */
+       function _create_database($name)
+       {
+               return "CREATE DATABASE ".$name;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Drop database
+        *
+        * @access      private
+        * @param       string  the database name
+        * @return      bool
+        */
+       function _drop_database($name)
+       {
+               return "DROP DATABASE ".$name;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Create Table
+        *
+        * @access      private
+        * @param       string  the table name
+        * @param       array   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)
+               {
+                       if ($this->db->table_exists($table))
+                       {
+                               return "SELECT * FROM $table"; // Needs to return innocous but valid SQL statement
+                       }
+               }
+
+               $sql .= $this->db->_escape_identifiers($table)." (";
+               $current_field_count = 0;
+
+               foreach ($fields as $field=>$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);
+
+                               $is_unsigned = (array_key_exists('UNSIGNED', $attributes) && $attributes['UNSIGNED'] === TRUE);
+
+                               // Convert datatypes to be PostgreSQL-compatible
+                               switch (strtoupper($attributes['TYPE']))
+                               {
+                                       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 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 .=  ' '.$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))
+                               {
+                                       $sql .= ' DEFAULT \''.$attributes['DEFAULT'].'\'';
+                               }
+
+                               if (array_key_exists('NULL', $attributes) && $attributes['NULL'] === TRUE)
+                               {
+                                       $sql .= ' NULL';
+                               }
+                               else
+                               {
+                                       $sql .= ' NOT NULL';
+                               }
+
+                               // Added new attribute to create unqite fields. Also works with MySQL
+                               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 .= ',';
+                       }
+               }
+
+               if (count($primary_keys) > 0)
+               {
+                       // 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)
+                       {
+                               if (is_array($key))
+                               {
+                                       $key = $this->db->_protect_identifiers($key);
+                               }
+                               else
+                               {
+                                       $key = array($this->db->_protect_identifiers($key));
+                               }
+
+                               foreach ($key as $field)
+                               {
+                                       $sql .= "CREATE INDEX " . $table . "_" . str_replace(array('"', "'"), '', $field) . "_index ON $table ($field); ";
+                               }
+                       }
+               }
+
+               return $sql;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Drop Table
+        *
+        * @access    private
+        * @return    bool
+        */
+       function _drop_table($table)
+       {
+               return "DROP TABLE IF EXISTS ".$this->db->_escape_identifiers($table)." CASCADE";
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * 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       string  the table name
+        * @param       string  the column definition
+        * @param       string  the default value
+        * @param       boolean should 'NOT NULL' be added
+        * @param       string  the field after which we should add the new field
+        * @return      object
+        */
+       function _alter_table($alter_type, $table, $column_name, $column_definition = '', $default_value = '', $null = '', $after_field = '')
+       {
+               $sql = 'ALTER TABLE '.$this->db->_protect_identifiers($table)." $alter_type ".$this->db->_protect_identifiers($column_name);
+
+               // DROP has everything it needs now.
+               if ($alter_type == 'DROP')
+               {
+                       return $sql;
+               }
+
+               $sql .= " $column_definition";
+
+               if ($default_value != '')
+               {
+                       $sql .= " DEFAULT \"$default_value\"";
+               }
+
+               if ($null === NULL)
+               {
+                       $sql .= ' NULL';
+               }
+               else
+               {
+                       $sql .= ' NOT NULL';
+               }
+
+               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 = 'ALTER TABLE '.$this->db->_protect_identifiers($table_name)." RENAME TO ".$this->db->_protect_identifiers($new_table_name);
+               return $sql;
+       }
+
+
+}
+
+/* End of file postgre_forge.php */
+/* Location: ./system/database/drivers/postgre/postgre_forge.php */
\ No newline at end of file
diff --git a/system/database/drivers/postgre/postgre_result.php b/system/database/drivers/postgre/postgre_result.php
new file mode 100755 (executable)
index 0000000..e9a1d16
--- /dev/null
@@ -0,0 +1,169 @@
+<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+/**
+ * CodeIgniter
+ *
+ * An open source application development framework for PHP 5.1.6 or newer
+ *
+ * @package            CodeIgniter
+ * @author             ExpressionEngine Dev Team
+ * @copyright  Copyright (c) 2008 - 2011, EllisLab, Inc.
+ * @license            http://codeigniter.com/user_guide/license.html
+ * @link               http://codeigniter.com
+ * @since              Version 1.0
+ * @filesource
+ */
+
+// ------------------------------------------------------------------------
+
+/**
+ * Postgres Result Class
+ *
+ * This class extends the parent result class: CI_DB_result
+ *
+ * @category   Database
+ * @author             ExpressionEngine Dev Team
+ * @link               http://codeigniter.com/user_guide/database/
+ */
+class CI_DB_postgre_result extends CI_DB_result {
+
+       /**
+        * Number of rows in the result set
+        *
+        * @access      public
+        * @return      integer
+        */
+       function num_rows()
+       {
+               return @pg_num_rows($this->result_id);
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Number of fields in the result set
+        *
+        * @access      public
+        * @return      integer
+        */
+       function num_fields()
+       {
+               return @pg_num_fields($this->result_id);
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Fetch Field Names
+        *
+        * Generates an array of column names
+        *
+        * @access      public
+        * @return      array
+        */
+       function list_fields()
+       {
+               $field_names = array();
+               for ($i = 0; $i < $this->num_fields(); $i++)
+               {
+                       $field_names[] = pg_field_name($this->result_id, $i);
+               }
+
+               return $field_names;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Field data
+        *
+        * Generates an array of objects containing field meta-data
+        *
+        * @access      public
+        * @return      array
+        */
+       function field_data()
+       {
+               $retval = array();
+               for ($i = 0; $i < $this->num_fields(); $i++)
+               {
+                       $F                              = new stdClass();
+                       $F->name                = pg_field_name($this->result_id, $i);
+                       $F->type                = pg_field_type($this->result_id, $i);
+                       $F->max_length  = pg_field_size($this->result_id, $i);
+                       $F->primary_key = 0;
+                       $F->default             = '';
+
+                       $retval[] = $F;
+               }
+
+               return $retval;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Free the result
+        *
+        * @return      null
+        */
+       function free_result()
+       {
+               if (is_resource($this->result_id))
+               {
+                       pg_free_result($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 pg_result_seek($this->result_id, $n);
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Result - associative array
+        *
+        * Returns the result set as an array
+        *
+        * @access      private
+        * @return      array
+        */
+       function _fetch_assoc()
+       {
+               return pg_fetch_assoc($this->result_id);
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Result - object
+        *
+        * Returns the result set as an object
+        *
+        * @access      private
+        * @return      object
+        */
+       function _fetch_object()
+       {
+               return pg_fetch_object($this->result_id);
+       }
+
+}
+
+
+/* End of file postgre_result.php */
+/* Location: ./system/database/drivers/postgre/postgre_result.php */
\ No newline at end of file
diff --git a/system/database/drivers/postgre/postgre_utility.php b/system/database/drivers/postgre/postgre_utility.php
new file mode 100755 (executable)
index 0000000..741c52e
--- /dev/null
@@ -0,0 +1,88 @@
+<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+/**
+ * CodeIgniter
+ *
+ * An open source application development framework for PHP 5.1.6 or newer
+ *
+ * @package            CodeIgniter
+ * @author             ExpressionEngine Dev Team
+ * @copyright  Copyright (c) 2008 - 2011, EllisLab, Inc.
+ * @license            http://codeigniter.com/user_guide/license.html
+ * @link               http://codeigniter.com
+ * @since              Version 1.0
+ * @filesource
+ */
+
+// ------------------------------------------------------------------------
+
+/**
+ * Postgre Utility Class
+ *
+ * @category   Database
+ * @author             ExpressionEngine Dev Team
+ * @link               http://codeigniter.com/user_guide/database/
+ */
+class CI_DB_postgre_utility extends CI_DB_utility {
+
+       /**
+        * List databases
+        *
+        * @access      private
+        * @return      bool
+        */
+       function _list_databases()
+       {
+               return "SELECT datname FROM pg_database";
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Optimize table query
+        *
+        * Is table optimization supported in Postgre?
+        *
+        * @access      private
+        * @param       string  the table name
+        * @return      object
+        */
+       function _optimize_table($table)
+       {
+               return FALSE;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Repair table query
+        *
+        * Are table repairs supported in Postgre?
+        *
+        * @access      private
+        * @param       string  the table name
+        * @return      object
+        */
+       function _repair_table($table)
+       {
+               return FALSE;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Postgre Export
+        *
+        * @access      private
+        * @param       array   Preferences
+        * @return      mixed
+        */
+       function _backup($params = array())
+       {
+               // Currently unsupported
+               return $this->db->display_error('db_unsuported_feature');
+       }
+}
+
+
+/* End of file postgre_utility.php */
+/* Location: ./system/database/drivers/postgre/postgre_utility.php */
\ No newline at end of file
diff --git a/system/database/drivers/sqlite/index.html b/system/database/drivers/sqlite/index.html
new file mode 100755 (executable)
index 0000000..c942a79
--- /dev/null
@@ -0,0 +1,10 @@
+<html>
+<head>
+       <title>403 Forbidden</title>
+</head>
+<body>
+
+<p>Directory access is forbidden.</p>
+
+</body>
+</html>
\ No newline at end of file
diff --git a/system/database/drivers/sqlite/sqlite_driver.php b/system/database/drivers/sqlite/sqlite_driver.php
new file mode 100755 (executable)
index 0000000..eb4e585
--- /dev/null
@@ -0,0 +1,657 @@
+<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+/**
+ * CodeIgniter
+ *
+ * An open source application development framework for PHP 5.1.6 or newer
+ *
+ * @package            CodeIgniter
+ * @author             ExpressionEngine Dev Team
+ * @copyright  Copyright (c) 2008 - 2011, EllisLab, Inc.
+ * @license            http://codeigniter.com/user_guide/license.html
+ * @link               http://codeigniter.com
+ * @since              Version 1.0
+ * @filesource
+ */
+
+// ------------------------------------------------------------------------
+
+
+
+/**
+ * SQLite Database Adapter Class
+ *
+ * Note: _DB is an extender class that the app controller
+ * creates dynamically based on whether the active record
+ * class is being used or not.
+ *
+ * @package            CodeIgniter
+ * @subpackage Drivers
+ * @category   Database
+ * @author             ExpressionEngine Dev Team
+ * @link               http://codeigniter.com/user_guide/database/
+ */
+class CI_DB_sqlite_driver extends CI_DB {
+
+       var $dbdriver = 'sqlite';
+
+       // The character used to escape with - not needed for SQLite
+       var $_escape_char = '';
+
+       // clause and character used for LIKE escape sequences
+       var $_like_escape_str = " ESCAPE '%s' ";
+       var $_like_escape_chr = '!';
+
+       /**
+        * The syntax to count rows is slightly different across different
+        * database engines, so this string appears in each driver and is
+        * used for the count_all() and count_all_results() functions.
+        */
+       var $_count_string = "SELECT COUNT(*) AS ";
+       var $_random_keyword = ' Random()'; // database specific random keyword
+
+       /**
+        * Non-persistent database connection
+        *
+        * @access      private called by the base class
+        * @return      resource
+        */
+       function db_connect()
+       {
+               if ( ! $conn_id = @sqlite_open($this->database, FILE_WRITE_MODE, $error))
+               {
+                       log_message('error', $error);
+
+                       if ($this->db_debug)
+                       {
+                               $this->display_error($error, '', TRUE);
+                       }
+
+                       return FALSE;
+               }
+
+               return $conn_id;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Persistent database connection
+        *
+        * @access      private called by the base class
+        * @return      resource
+        */
+       function db_pconnect()
+       {
+               if ( ! $conn_id = @sqlite_popen($this->database, FILE_WRITE_MODE, $error))
+               {
+                       log_message('error', $error);
+
+                       if ($this->db_debug)
+                       {
+                               $this->display_error($error, '', TRUE);
+                       }
+
+                       return FALSE;
+               }
+
+               return $conn_id;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * 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()
+       {
+               // not implemented in SQLite
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Select the database
+        *
+        * @access      private called by the base class
+        * @return      resource
+        */
+       function db_select()
+       {
+               return TRUE;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Set client character set
+        *
+        * @access      public
+        * @param       string
+        * @param       string
+        * @return      resource
+        */
+       function db_set_charset($charset, $collation)
+       {
+               // @todo - add support if needed
+               return TRUE;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Version number query string
+        *
+        * @access      public
+        * @return      string
+        */
+       function _version()
+       {
+               return sqlite_libversion();
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * 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 @sqlite_query($this->conn_id, $sql);
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * 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)
+       {
+               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;
+
+               $this->simple_query('BEGIN TRANSACTION');
+               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;
+               }
+
+               $this->simple_query('COMMIT');
+               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;
+               }
+
+               $this->simple_query('ROLLBACK');
+               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;
+               }
+
+               $str = sqlite_escape_string($str);
+
+               // 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);
+               }
+
+               return $str;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Affected Rows
+        *
+        * @access      public
+        * @return      integer
+        */
+       function affected_rows()
+       {
+               return sqlite_changes($this->conn_id);
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Insert ID
+        *
+        * @access      public
+        * @return      integer
+        */
+       function insert_id()
+       {
+               return @sqlite_last_insert_rowid($this->conn_id);
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * "Count All" query
+        *
+        * Generates a platform-specific query string that counts all records in
+        * the specified database
+        *
+        * @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 = "SELECT name from sqlite_master WHERE type='table'";
+
+               if ($prefix_limit !== FALSE AND $this->dbprefix != '')
+               {
+                       $sql .= " AND 'name' LIKE '".$this->escape_like_str($this->dbprefix)."%' ".sprintf($this->_like_escape_str, $this->_like_escape_chr);
+               }
+               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 = '')
+       {
+               // Not supported
+               return 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 sqlite_error_string(sqlite_last_error($this->conn_id));
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * The error message number
+        *
+        * @access      private
+        * @return      integer
+        */
+       function _error_number()
+       {
+               return sqlite_last_error($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).")";
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * 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[] = $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;
+       }
+
+
+       // --------------------------------------------------------------------
+
+       /**
+        * 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 $this->_delete($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)
+       {
+               @sqlite_close($conn_id);
+       }
+
+
+}
+
+
+/* End of file sqlite_driver.php */
+/* Location: ./system/database/drivers/sqlite/sqlite_driver.php */
\ No newline at end of file
diff --git a/system/database/drivers/sqlite/sqlite_forge.php b/system/database/drivers/sqlite/sqlite_forge.php
new file mode 100755 (executable)
index 0000000..5690408
--- /dev/null
@@ -0,0 +1,265 @@
+<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+/**
+ * CodeIgniter
+ *
+ * An open source application development framework for PHP 5.1.6 or newer
+ *
+ * @package            CodeIgniter
+ * @author             ExpressionEngine Dev Team
+ * @copyright  Copyright (c) 2008 - 2011, EllisLab, Inc.
+ * @license            http://codeigniter.com/user_guide/license.html
+ * @link               http://codeigniter.com
+ * @since              Version 1.0
+ * @filesource
+ */
+
+// ------------------------------------------------------------------------
+
+/**
+ * SQLite Forge Class
+ *
+ * @category   Database
+ * @author             ExpressionEngine Dev Team
+ * @link               http://codeigniter.com/user_guide/database/
+ */
+class CI_DB_sqlite_forge extends CI_DB_forge {
+
+       /**
+        * Create database
+        *
+        * @access      public
+        * @param       string  the database name
+        * @return      bool
+        */
+       function _create_database()
+       {
+               // In SQLite, a database is created when you connect to the database.
+               // We'll return TRUE so that an error isn't generated
+               return TRUE;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Drop database
+        *
+        * @access      private
+        * @param       string  the database name
+        * @return      bool
+        */
+       function _drop_database($name)
+       {
+               if ( ! @file_exists($this->db->database) OR ! @unlink($this->db->database))
+               {
+                       if ($this->db->db_debug)
+                       {
+                               return $this->db->display_error('db_unable_to_drop');
+                       }
+                       return FALSE;
+               }
+               return TRUE;
+       }
+       // --------------------------------------------------------------------
+
+       /**
+        * Create Table
+        *
+        * @access      private
+        * @param       string  the table name
+        * @param       array   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 NOT EXISTS added to SQLite in 3.3.0
+               if ($if_not_exists === TRUE && version_compare($this->db->_version(), '3.3.0', '>=') === TRUE)
+               {
+                       $sql .= 'IF NOT EXISTS ';
+               }
+
+               $sql .= $this->db->_escape_identifiers($table)."(";
+               $current_field_count = 0;
+
+               foreach ($fields as $field=>$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);
+
+                               $sql .=  ' '.$attributes['TYPE'];
+
+                               if (array_key_exists('CONSTRAINT', $attributes))
+                               {
+                                       $sql .= '('.$attributes['CONSTRAINT'].')';
+                               }
+
+                               if (array_key_exists('UNSIGNED', $attributes) && $attributes['UNSIGNED'] === TRUE)
+                               {
+                                       $sql .= ' UNSIGNED';
+                               }
+
+                               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';
+                               }
+                       }
+
+                       // don't add a comma on the end of the last field
+                       if (++$current_field_count < count($fields))
+                       {
+                               $sql .= ',';
+                       }
+               }
+
+               if (count($primary_keys) > 0)
+               {
+                       $primary_keys = $this->db->_protect_identifiers($primary_keys);
+                       $sql .= ",\n\tPRIMARY KEY (" . implode(', ', $primary_keys) . ")";
+               }
+
+               if (is_array($keys) && count($keys) > 0)
+               {
+                       foreach ($keys as $key)
+                       {
+                               if (is_array($key))
+                               {
+                                       $key = $this->db->_protect_identifiers($key);
+                               }
+                               else
+                               {
+                                       $key = array($this->db->_protect_identifiers($key));
+                               }
+
+                               $sql .= ",\n\tUNIQUE (" . implode(', ', $key) . ")";
+                       }
+               }
+
+               $sql .= "\n)";
+
+               return $sql;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Drop Table
+        *
+        *  Unsupported feature in SQLite
+        *
+        * @access      private
+        * @return      bool
+        */
+       function _drop_table($table)
+       {
+               if ($this->db->db_debug)
+               {
+                       return $this->db->display_error('db_unsuported_feature');
+               }
+               return array();
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * 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       string  the table name
+        * @param       string  the column definition
+        * @param       string  the default value
+        * @param       boolean should 'NOT NULL' be added
+        * @param       string  the field after which we should add the new field
+        * @return      object
+        */
+       function _alter_table($alter_type, $table, $column_name, $column_definition = '', $default_value = '', $null = '', $after_field = '')
+       {
+               $sql = 'ALTER TABLE '.$this->db->_protect_identifiers($table)." $alter_type ".$this->db->_protect_identifiers($column_name);
+
+               // DROP has everything it needs now.
+               if ($alter_type == 'DROP')
+               {
+                       // SQLite does not support dropping columns
+                       // http://www.sqlite.org/omitted.html
+                       // http://www.sqlite.org/faq.html#q11
+                       return FALSE;
+               }
+
+               $sql .= " $column_definition";
+
+               if ($default_value != '')
+               {
+                       $sql .= " DEFAULT \"$default_value\"";
+               }
+
+               if ($null === NULL)
+               {
+                       $sql .= ' NULL';
+               }
+               else
+               {
+                       $sql .= ' NOT NULL';
+               }
+
+               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 = 'ALTER TABLE '.$this->db->_protect_identifiers($table_name)." RENAME TO ".$this->db->_protect_identifiers($new_table_name);
+               return $sql;
+       }
+}
+
+/* End of file sqlite_forge.php */
+/* Location: ./system/database/drivers/sqlite/sqlite_forge.php */
\ No newline at end of file
diff --git a/system/database/drivers/sqlite/sqlite_result.php b/system/database/drivers/sqlite/sqlite_result.php
new file mode 100755 (executable)
index 0000000..7bd30db
--- /dev/null
@@ -0,0 +1,179 @@
+<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+/**
+ * CodeIgniter
+ *
+ * An open source application development framework for PHP 5.1.6 or newer
+ *
+ * @package            CodeIgniter
+ * @author             ExpressionEngine Dev Team
+ * @copyright  Copyright (c) 2008 - 2011, EllisLab, Inc.
+ * @license            http://codeigniter.com/user_guide/license.html
+ * @link               http://codeigniter.com
+ * @since              Version 1.0
+ * @filesource
+ */
+
+// ------------------------------------------------------------------------
+
+/**
+ * SQLite Result Class
+ *
+ * This class extends the parent result class: CI_DB_result
+ *
+ * @category   Database
+ * @author             ExpressionEngine Dev Team
+ * @link               http://codeigniter.com/user_guide/database/
+ */
+class CI_DB_sqlite_result extends CI_DB_result {
+
+       /**
+        * Number of rows in the result set
+        *
+        * @access      public
+        * @return      integer
+        */
+       function num_rows()
+       {
+               return @sqlite_num_rows($this->result_id);
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Number of fields in the result set
+        *
+        * @access      public
+        * @return      integer
+        */
+       function num_fields()
+       {
+               return @sqlite_num_fields($this->result_id);
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Fetch Field Names
+        *
+        * Generates an array of column names
+        *
+        * @access      public
+        * @return      array
+        */
+       function list_fields()
+       {
+               $field_names = array();
+               for ($i = 0; $i < $this->num_fields(); $i++)
+               {
+                       $field_names[] = sqlite_field_name($this->result_id, $i);
+               }
+
+               return $field_names;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Field data
+        *
+        * Generates an array of objects containing field meta-data
+        *
+        * @access      public
+        * @return      array
+        */
+       function field_data()
+       {
+               $retval = array();
+               for ($i = 0; $i < $this->num_fields(); $i++)
+               {
+                       $F                              = new stdClass();
+                       $F->name                = sqlite_field_name($this->result_id, $i);
+                       $F->type                = 'varchar';
+                       $F->max_length  = 0;
+                       $F->primary_key = 0;
+                       $F->default             = '';
+
+                       $retval[] = $F;
+               }
+
+               return $retval;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Free the result
+        *
+        * @return      null
+        */
+       function free_result()
+       {
+               // Not implemented in SQLite
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * 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 sqlite_seek($this->result_id, $n);
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Result - associative array
+        *
+        * Returns the result set as an array
+        *
+        * @access      private
+        * @return      array
+        */
+       function _fetch_assoc()
+       {
+               return sqlite_fetch_array($this->result_id);
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Result - object
+        *
+        * Returns the result set as an object
+        *
+        * @access      private
+        * @return      object
+        */
+       function _fetch_object()
+       {
+               if (function_exists('sqlite_fetch_object'))
+               {
+                       return sqlite_fetch_object($this->result_id);
+               }
+               else
+               {
+                       $arr = sqlite_fetch_array($this->result_id, SQLITE_ASSOC);
+                       if (is_array($arr))
+                       {
+                               $obj = (object) $arr;
+                               return $obj;
+                       } else {
+                               return NULL;
+                       }
+               }
+       }
+
+}
+
+
+/* End of file sqlite_result.php */
+/* Location: ./system/database/drivers/sqlite/sqlite_result.php */
\ No newline at end of file
diff --git a/system/database/drivers/sqlite/sqlite_utility.php b/system/database/drivers/sqlite/sqlite_utility.php
new file mode 100755 (executable)
index 0000000..508023e
--- /dev/null
@@ -0,0 +1,96 @@
+<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+/**
+ * CodeIgniter
+ *
+ * An open source application development framework for PHP 5.1.6 or newer
+ *
+ * @package            CodeIgniter
+ * @author             ExpressionEngine Dev Team
+ * @copyright  Copyright (c) 2008 - 2011, EllisLab, Inc.
+ * @license            http://codeigniter.com/user_guide/license.html
+ * @link               http://codeigniter.com
+ * @since              Version 1.0
+ * @filesource
+ */
+
+// ------------------------------------------------------------------------
+
+/**
+ * SQLite Utility Class
+ *
+ * @category   Database
+ * @author             ExpressionEngine Dev Team
+ * @link               http://codeigniter.com/user_guide/database/
+ */
+class CI_DB_sqlite_utility extends CI_DB_utility {
+
+       /**
+        * List databases
+        *
+        * I don't believe you can do a database listing with SQLite
+        * since each database is its own file.  I suppose we could
+        * try reading a directory looking for SQLite files, but
+        * that doesn't seem like a terribly good idea
+        *
+        * @access      private
+        * @return      bool
+        */
+       function _list_databases()
+       {
+               if ($this->db_debug)
+               {
+                       return $this->db->display_error('db_unsuported_feature');
+               }
+               return array();
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Optimize table query
+        *
+        * Is optimization even supported in SQLite?
+        *
+        * @access      private
+        * @param       string  the table name
+        * @return      object
+        */
+       function _optimize_table($table)
+       {
+               return FALSE;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Repair table query
+        *
+        * Are table repairs even supported in SQLite?
+        *
+        * @access      private
+        * @param       string  the table name
+        * @return      object
+        */
+       function _repair_table($table)
+       {
+               return FALSE;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * SQLite Export
+        *
+        * @access      private
+        * @param       array   Preferences
+        * @return      mixed
+        */
+       function _backup($params = array())
+       {
+               // Currently unsupported
+               return $this->db->display_error('db_unsuported_feature');
+       }
+}
+
+/* End of file sqlite_utility.php */
+/* Location: ./system/database/drivers/sqlite/sqlite_utility.php */
\ No newline at end of file
diff --git a/system/database/index.html b/system/database/index.html
new file mode 100755 (executable)
index 0000000..c942a79
--- /dev/null
@@ -0,0 +1,10 @@
+<html>
+<head>
+       <title>403 Forbidden</title>
+</head>
+<body>
+
+<p>Directory access is forbidden.</p>
+
+</body>
+</html>
\ No newline at end of file
diff --git a/system/fonts/index.html b/system/fonts/index.html
new file mode 100755 (executable)
index 0000000..c942a79
--- /dev/null
@@ -0,0 +1,10 @@
+<html>
+<head>
+       <title>403 Forbidden</title>
+</head>
+<body>
+
+<p>Directory access is forbidden.</p>
+
+</body>
+</html>
\ No newline at end of file
diff --git a/system/fonts/texb.ttf b/system/fonts/texb.ttf
new file mode 100755 (executable)
index 0000000..6792342
Binary files /dev/null and b/system/fonts/texb.ttf differ
diff --git a/system/helpers/array_helper.php b/system/helpers/array_helper.php
new file mode 100755 (executable)
index 0000000..075a31f
--- /dev/null
@@ -0,0 +1,119 @@
+<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+/**
+ * CodeIgniter
+ *
+ * An open source application development framework for PHP 5.1.6 or newer
+ *
+ * @package            CodeIgniter
+ * @author             ExpressionEngine Dev Team
+ * @copyright  Copyright (c) 2008 - 2011, EllisLab, Inc.
+ * @license            http://codeigniter.com/user_guide/license.html
+ * @link               http://codeigniter.com
+ * @since              Version 1.0
+ * @filesource
+ */
+
+// ------------------------------------------------------------------------
+
+/**
+ * CodeIgniter Array Helpers
+ *
+ * @package            CodeIgniter
+ * @subpackage Helpers
+ * @category   Helpers
+ * @author             ExpressionEngine Dev Team
+ * @link               http://codeigniter.com/user_guide/helpers/array_helper.html
+ */
+
+// ------------------------------------------------------------------------
+
+/**
+ * Element
+ *
+ * Lets you determine whether an array index is set and whether it has a value.
+ * If the element is empty it returns FALSE (or whatever you specify as the default value.)
+ *
+ * @access     public
+ * @param      string
+ * @param      array
+ * @param      mixed
+ * @return     mixed   depends on what the array contains
+ */
+if ( ! function_exists('element'))
+{
+       function element($item, $array, $default = FALSE)
+       {
+               if ( ! isset($array[$item]) OR $array[$item] == "")
+               {
+                       return $default;
+               }
+
+               return $array[$item];
+       }
+}
+
+// ------------------------------------------------------------------------
+
+/**
+ * Random Element - Takes an array as input and returns a random element
+ *
+ * @access     public
+ * @param      array
+ * @return     mixed   depends on what the array contains
+ */
+if ( ! function_exists('random_element'))
+{
+       function random_element($array)
+       {
+               if ( ! is_array($array))
+               {
+                       return $array;
+               }
+
+               return $array[array_rand($array)];
+       }
+}
+
+// --------------------------------------------------------------------
+
+/**
+ * Elements
+ *
+ * Returns only the array items specified.  Will return a default value if
+ * it is not set.
+ *
+ * @access     public
+ * @param      array
+ * @param      array
+ * @param      mixed
+ * @return     mixed   depends on what the array contains
+ */
+if ( ! function_exists('elements'))
+{
+       function elements($items, $array, $default = FALSE)
+       {
+               $return = array();
+               
+               if ( ! is_array($items))
+               {
+                       $items = array($items);
+               }
+               
+               foreach ($items as $item)
+               {
+                       if (isset($array[$item]))
+                       {
+                               $return[$item] = $array[$item];
+                       }
+                       else
+                       {
+                               $return[$item] = $default;
+                       }
+               }
+
+               return $return;
+       }
+}
+
+/* End of file array_helper.php */
+/* Location: ./system/helpers/array_helper.php */
\ No newline at end of file
diff --git a/system/helpers/captcha_helper.php b/system/helpers/captcha_helper.php
new file mode 100755 (executable)
index 0000000..19ec0c7
--- /dev/null
@@ -0,0 +1,246 @@
+<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+/**
+ * CodeIgniter
+ *
+ * An open source application development framework for PHP 5.1.6 or newer
+ *
+ * @package            CodeIgniter
+ * @author             ExpressionEngine Dev Team
+ * @copyright  Copyright (c) 2008 - 2011, EllisLab, Inc.
+ * @license            http://codeigniter.com/user_guide/license.html
+ * @link               http://codeigniter.com
+ * @since              Version 1.0
+ * @filesource
+ */
+
+// ------------------------------------------------------------------------
+
+/**
+ * CodeIgniter CAPTCHA Helper
+ *
+ * @package            CodeIgniter
+ * @subpackage Helpers
+ * @category   Helpers
+ * @author             ExpressionEngine Dev Team
+ * @link               http://codeigniter.com/user_guide/helpers/xml_helper.html
+ */
+
+// ------------------------------------------------------------------------
+
+/**
+ * Create CAPTCHA
+ *
+ * @access     public
+ * @param      array   array of data for the CAPTCHA
+ * @param      string  path to create the image in
+ * @param      string  URL to the CAPTCHA image folder
+ * @param      string  server path to font
+ * @return     string
+ */
+if ( ! function_exists('create_captcha'))
+{
+       function create_captcha($data = '', $img_path = '', $img_url = '', $font_path = '')
+       {
+               $defaults = array('word' => '', 'img_path' => '', 'img_url' => '', 'img_width' => '150', 'img_height' => '30', 'font_path' => '', 'expiration' => 7200);
+
+               foreach ($defaults as $key => $val)
+               {
+                       if ( ! is_array($data))
+                       {
+                               if ( ! isset($$key) OR $$key == '')
+                               {
+                                       $$key = $val;
+                               }
+                       }
+                       else
+                       {
+                               $$key = ( ! isset($data[$key])) ? $val : $data[$key];
+                       }
+               }
+
+               if ($img_path == '' OR $img_url == '')
+               {
+                       return FALSE;
+               }
+
+               if ( ! @is_dir($img_path))
+               {
+                       return FALSE;
+               }
+
+               if ( ! is_writable($img_path))
+               {
+                       return FALSE;
+               }
+
+               if ( ! extension_loaded('gd'))
+               {
+                       return FALSE;
+               }
+
+               // -----------------------------------
+               // Remove old images
+               // -----------------------------------
+
+               list($usec, $sec) = explode(" ", microtime());
+               $now = ((float)$usec + (float)$sec);
+
+               $current_dir = @opendir($img_path);
+
+               while ($filename = @readdir($current_dir))
+               {
+                       if ($filename != "." and $filename != ".." and $filename != "index.html")
+                       {
+                               $name = str_replace(".jpg", "", $filename);
+
+                               if (($name + $expiration) < $now)
+                               {
+                                       @unlink($img_path.$filename);
+                               }
+                       }
+               }
+
+               @closedir($current_dir);
+
+               // -----------------------------------
+               // Do we have a "word" yet?
+               // -----------------------------------
+
+          if ($word == '')
+          {
+                       $pool = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
+
+                       $str = '';
+                       for ($i = 0; $i < 8; $i++)
+                       {
+                               $str .= substr($pool, mt_rand(0, strlen($pool) -1), 1);
+                       }
+
+                       $word = $str;
+          }
+
+               // -----------------------------------
+               // Determine angle and position
+               // -----------------------------------
+
+               $length = strlen($word);
+               $angle  = ($length >= 6) ? rand(-($length-6), ($length-6)) : 0;
+               $x_axis = rand(6, (360/$length)-16);
+               $y_axis = ($angle >= 0 ) ? rand($img_height, $img_width) : rand(6, $img_height);
+
+               // -----------------------------------
+               // Create image
+               // -----------------------------------
+
+               // PHP.net recommends imagecreatetruecolor(), but it isn't always available
+               if (function_exists('imagecreatetruecolor'))
+               {
+                       $im = imagecreatetruecolor($img_width, $img_height);
+               }
+               else
+               {
+                       $im = imagecreate($img_width, $img_height);
+               }
+
+               // -----------------------------------
+               //  Assign colors
+               // -----------------------------------
+
+               $bg_color               = imagecolorallocate ($im, 255, 255, 255);
+               $border_color   = imagecolorallocate ($im, 153, 102, 102);
+               $text_color             = imagecolorallocate ($im, 204, 153, 153);
+               $grid_color             = imagecolorallocate($im, 255, 182, 182);
+               $shadow_color   = imagecolorallocate($im, 255, 240, 240);
+
+               // -----------------------------------
+               //  Create the rectangle
+               // -----------------------------------
+
+               ImageFilledRectangle($im, 0, 0, $img_width, $img_height, $bg_color);
+
+               // -----------------------------------
+               //  Create the spiral pattern
+               // -----------------------------------
+
+               $theta          = 1;
+               $thetac         = 7;
+               $radius         = 16;
+               $circles        = 20;
+               $points         = 32;
+
+               for ($i = 0; $i < ($circles * $points) - 1; $i++)
+               {
+                       $theta = $theta + $thetac;
+                       $rad = $radius * ($i / $points );
+                       $x = ($rad * cos($theta)) + $x_axis;
+                       $y = ($rad * sin($theta)) + $y_axis;
+                       $theta = $theta + $thetac;
+                       $rad1 = $radius * (($i + 1) / $points);
+                       $x1 = ($rad1 * cos($theta)) + $x_axis;
+                       $y1 = ($rad1 * sin($theta )) + $y_axis;
+                       imageline($im, $x, $y, $x1, $y1, $grid_color);
+                       $theta = $theta - $thetac;
+               }
+
+               // -----------------------------------
+               //  Write the text
+               // -----------------------------------
+
+               $use_font = ($font_path != '' AND file_exists($font_path) AND function_exists('imagettftext')) ? TRUE : FALSE;
+
+               if ($use_font == FALSE)
+               {
+                       $font_size = 5;
+                       $x = rand(0, $img_width/($length/3));
+                       $y = 0;
+               }
+               else
+               {
+                       $font_size      = 16;
+                       $x = rand(0, $img_width/($length/1.5));
+                       $y = $font_size+2;
+               }
+
+               for ($i = 0; $i < strlen($word); $i++)
+               {
+                       if ($use_font == FALSE)
+                       {
+                               $y = rand(0 , $img_height/2);
+                               imagestring($im, $font_size, $x, $y, substr($word, $i, 1), $text_color);
+                               $x += ($font_size*2);
+                       }
+                       else
+                       {
+                               $y = rand($img_height/2, $img_height-3);
+                               imagettftext($im, $font_size, $angle, $x, $y, $text_color, $font_path, substr($word, $i, 1));
+                               $x += $font_size;
+                       }
+               }
+
+
+               // -----------------------------------
+               //  Create the border
+               // -----------------------------------
+
+               imagerectangle($im, 0, 0, $img_width-1, $img_height-1, $border_color);
+
+               // -----------------------------------
+               //  Generate the image
+               // -----------------------------------
+
+               $img_name = $now.'.jpg';
+
+               ImageJPEG($im, $img_path.$img_name);
+
+               $img = "<img src=\"$img_url$img_name\" width=\"$img_width\" height=\"$img_height\" style=\"border:0;\" alt=\" \" />";
+
+               ImageDestroy($im);
+
+               return array('word' => $word, 'time' => $now, 'image' => $img);
+       }
+}
+
+// ------------------------------------------------------------------------
+
+/* End of file captcha_helper.php */
+/* Location: ./system/heleprs/captcha_helper.php */
\ No newline at end of file
diff --git a/system/helpers/cookie_helper.php b/system/helpers/cookie_helper.php
new file mode 100755 (executable)
index 0000000..7cee028
--- /dev/null
@@ -0,0 +1,103 @@
+<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+/**
+ * CodeIgniter
+ *
+ * An open source application development framework for PHP 5.1.6 or newer
+ *
+ * @package            CodeIgniter
+ * @author             ExpressionEngine Dev Team
+ * @copyright  Copyright (c) 2008 - 2011, EllisLab, Inc.
+ * @license            http://codeigniter.com/user_guide/license.html
+ * @link               http://codeigniter.com
+ * @since              Version 1.0
+ * @filesource
+ */
+
+// ------------------------------------------------------------------------
+
+/**
+ * CodeIgniter Cookie Helpers
+ *
+ * @package            CodeIgniter
+ * @subpackage Helpers
+ * @category   Helpers
+ * @author             ExpressionEngine Dev Team
+ * @link               http://codeigniter.com/user_guide/helpers/cookie_helper.html
+ */
+
+// ------------------------------------------------------------------------
+
+/**
+ * Set cookie
+ *
+ * Accepts six parameter, or you can submit an associative
+ * array in the first parameter containing all the values.
+ *
+ * @access     public
+ * @param      mixed
+ * @param      string  the value of the cookie
+ * @param      string  the number of seconds until expiration
+ * @param      string  the cookie domain.  Usually:  .yourdomain.com
+ * @param      string  the cookie path
+ * @param      string  the cookie prefix
+ * @return     void
+ */
+if ( ! function_exists('set_cookie'))
+{
+       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, $secure);
+       }
+}
+
+// --------------------------------------------------------------------
+
+/**
+ * Fetch an item from the COOKIE array
+ *
+ * @access     public
+ * @param      string
+ * @param      bool
+ * @return     mixed
+ */
+if ( ! function_exists('get_cookie'))
+{
+       function get_cookie($index = '', $xss_clean = FALSE)
+       {
+               $CI =& get_instance();
+
+               $prefix = '';
+
+               if ( ! isset($_COOKIE[$index]) && config_item('cookie_prefix') != '')
+               {
+                       $prefix = config_item('cookie_prefix');
+               }
+
+               return $CI->input->cookie($prefix.$index, $xss_clean);
+       }
+}
+
+// --------------------------------------------------------------------
+
+/**
+ * Delete a COOKIE
+ *
+ * @param      mixed
+ * @param      string  the cookie domain.  Usually:  .yourdomain.com
+ * @param      string  the cookie path
+ * @param      string  the cookie prefix
+ * @return     void
+ */
+if ( ! function_exists('delete_cookie'))
+{
+       function delete_cookie($name = '', $domain = '', $path = '/', $prefix = '')
+       {
+               set_cookie($name, '', '', $domain, $path, $prefix);
+       }
+}
+
+
+/* End of file cookie_helper.php */
+/* Location: ./system/helpers/cookie_helper.php */
\ No newline at end of file
diff --git a/system/helpers/date_helper.php b/system/helpers/date_helper.php
new file mode 100755 (executable)
index 0000000..553e8d7
--- /dev/null
@@ -0,0 +1,611 @@
+<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+/**
+ * CodeIgniter
+ *
+ * An open source application development framework for PHP 5.1.6 or newer
+ *
+ * @package            CodeIgniter
+ * @author             ExpressionEngine Dev Team
+ * @copyright  Copyright (c) 2008 - 2011, EllisLab, Inc.
+ * @license            http://codeigniter.com/user_guide/license.html
+ * @link               http://codeigniter.com
+ * @since              Version 1.0
+ * @filesource
+ */
+
+// ------------------------------------------------------------------------
+
+/**
+ * CodeIgniter Date Helpers
+ *
+ * @package            CodeIgniter
+ * @subpackage Helpers
+ * @category   Helpers
+ * @author             ExpressionEngine Dev Team
+ * @link               http://codeigniter.com/user_guide/helpers/date_helper.html
+ */
+
+// ------------------------------------------------------------------------
+
+/**
+ * Get "now" time
+ *
+ * Returns time() or its GMT equivalent based on the config file preference
+ *
+ * @access     public
+ * @return     integer
+ */
+if ( ! function_exists('now'))
+{
+       function now()
+       {
+               $CI =& get_instance();
+
+               if (strtolower($CI->config->item('time_reference')) == 'gmt')
+               {
+                       $now = time();
+                       $system_time = mktime(gmdate("H", $now), gmdate("i", $now), gmdate("s", $now), gmdate("m", $now), gmdate("d", $now), gmdate("Y", $now));
+
+                       if (strlen($system_time) < 10)
+                       {
+                               $system_time = time();
+                               log_message('error', 'The Date class could not set a proper GMT timestamp so the local time() value was used.');
+                       }
+
+                       return $system_time;
+               }
+               else
+               {
+                       return time();
+               }
+       }
+}
+
+// ------------------------------------------------------------------------
+
+/**
+ * Convert MySQL Style Datecodes
+ *
+ * This function is identical to PHPs date() function,
+ * except that it allows date codes to be formatted using
+ * the MySQL style, where each code letter is preceded
+ * with a percent sign:  %Y %m %d etc...
+ *
+ * The benefit of doing dates this way is that you don't
+ * have to worry about escaping your text letters that
+ * match the date codes.
+ *
+ * @access     public
+ * @param      string
+ * @param      integer
+ * @return     integer
+ */
+if ( ! function_exists('mdate'))
+{
+       function mdate($datestr = '', $time = '')
+       {
+               if ($datestr == '')
+                       return '';
+
+               if ($time == '')
+                       $time = now();
+
+               $datestr = str_replace('%\\', '', preg_replace("/([a-z]+?){1}/i", "\\\\\\1", $datestr));
+               return date($datestr, $time);
+       }
+}
+
+// ------------------------------------------------------------------------
+
+/**
+ * Standard Date
+ *
+ * Returns a date formatted according to the submitted standard.
+ *
+ * @access     public
+ * @param      string  the chosen format
+ * @param      integer Unix timestamp
+ * @return     string
+ */
+if ( ! function_exists('standard_date'))
+{
+       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%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',
+                                               'DATE_RFC1123'  =>      '%D, %d %M %Y %H:%i:%s %O',
+                                               'DATE_RSS'              =>      '%D, %d %M %Y %H:%i:%s %O',
+                                               'DATE_W3C'              =>      '%Y-%m-%dT%H:%i:%s%Q'
+                                               );
+
+               if ( ! isset($formats[$fmt]))
+               {
+                       return FALSE;
+               }
+
+               return mdate($formats[$fmt], $time);
+       }
+}
+
+// ------------------------------------------------------------------------
+
+/**
+ * Timespan
+ *
+ * Returns a span of seconds in this format:
+ *     10 days 14 hours 36 minutes 47 seconds
+ *
+ * @access     public
+ * @param      integer a number of seconds
+ * @param      integer Unix timestamp
+ * @return     integer
+ */
+if ( ! function_exists('timespan'))
+{
+       function timespan($seconds = 1, $time = '')
+       {
+               $CI =& get_instance();
+               $CI->lang->load('date');
+
+               if ( ! is_numeric($seconds))
+               {
+                       $seconds = 1;
+               }
+
+               if ( ! is_numeric($time))
+               {
+                       $time = time();
+               }
+
+               if ($time <= $seconds)
+               {
+                       $seconds = 1;
+               }
+               else
+               {
+                       $seconds = $time - $seconds;
+               }
+
+               $str = '';
+               $years = floor($seconds / 31536000);
+
+               if ($years > 0)
+               {
+                       $str .= $years.' '.$CI->lang->line((($years     > 1) ? 'date_years' : 'date_year')).', ';
+               }
+
+               $seconds -= $years * 31536000;
+               $months = floor($seconds / 2628000);
+
+               if ($years > 0 OR $months > 0)
+               {
+                       if ($months > 0)
+                       {
+                               $str .= $months.' '.$CI->lang->line((($months   > 1) ? 'date_months' : 'date_month')).', ';
+                       }
+
+                       $seconds -= $months * 2628000;
+               }
+
+               $weeks = floor($seconds / 604800);
+
+               if ($years > 0 OR $months > 0 OR $weeks > 0)
+               {
+                       if ($weeks > 0)
+                       {
+                               $str .= $weeks.' '.$CI->lang->line((($weeks     > 1) ? 'date_weeks' : 'date_week')).', ';
+                       }
+
+                       $seconds -= $weeks * 604800;
+               }
+
+               $days = floor($seconds / 86400);
+
+               if ($months > 0 OR $weeks > 0 OR $days > 0)
+               {
+                       if ($days > 0)
+                       {
+                               $str .= $days.' '.$CI->lang->line((($days       > 1) ? 'date_days' : 'date_day')).', ';
+                       }
+
+                       $seconds -= $days * 86400;
+               }
+
+               $hours = floor($seconds / 3600);
+
+               if ($days > 0 OR $hours > 0)
+               {
+                       if ($hours > 0)
+                       {
+                               $str .= $hours.' '.$CI->lang->line((($hours     > 1) ? 'date_hours' : 'date_hour')).', ';
+                       }
+
+                       $seconds -= $hours * 3600;
+               }
+
+               $minutes = floor($seconds / 60);
+
+               if ($days > 0 OR $hours > 0 OR $minutes > 0)
+               {
+                       if ($minutes > 0)
+                       {
+                               $str .= $minutes.' '.$CI->lang->line((($minutes > 1) ? 'date_minutes' : 'date_minute')).', ';
+                       }
+
+                       $seconds -= $minutes * 60;
+               }
+
+               if ($str == '')
+               {
+                       $str .= $seconds.' '.$CI->lang->line((($seconds > 1) ? 'date_seconds' : 'date_second')).', ';
+               }
+
+               return substr(trim($str), 0, -1);
+       }
+}
+
+// ------------------------------------------------------------------------
+
+/**
+ * Number of days in a month
+ *
+ * Takes a month/year as input and returns the number of days
+ * for the given month/year. Takes leap years into consideration.
+ *
+ * @access     public
+ * @param      integer a numeric month
+ * @param      integer a numeric year
+ * @return     integer
+ */
+if ( ! function_exists('days_in_month'))
+{
+       function days_in_month($month = 0, $year = '')
+       {
+               if ($month < 1 OR $month > 12)
+               {
+                       return 0;
+               }
+
+               if ( ! is_numeric($year) OR strlen($year) != 4)
+               {
+                       $year = date('Y');
+               }
+
+               if ($month == 2)
+               {
+                       if ($year % 400 == 0 OR ($year % 4 == 0 AND $year % 100 != 0))
+                       {
+                               return 29;
+                       }
+               }
+
+               $days_in_month  = array(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
+               return $days_in_month[$month - 1];
+       }
+}
+
+// ------------------------------------------------------------------------
+
+/**
+ * Converts a local Unix timestamp to GMT
+ *
+ * @access     public
+ * @param      integer Unix timestamp
+ * @return     integer
+ */
+if ( ! function_exists('local_to_gmt'))
+{
+       function local_to_gmt($time = '')
+       {
+               if ($time == '')
+                       $time = time();
+
+               return mktime( gmdate("H", $time), gmdate("i", $time), gmdate("s", $time), gmdate("m", $time), gmdate("d", $time), gmdate("Y", $time));
+       }
+}
+
+// ------------------------------------------------------------------------
+
+/**
+ * Converts GMT time to a localized value
+ *
+ * Takes a Unix timestamp (in GMT) as input, and returns
+ * at the local value based on the timezone and DST setting
+ * submitted
+ *
+ * @access     public
+ * @param      integer Unix timestamp
+ * @param      string  timezone
+ * @param      bool    whether DST is active
+ * @return     integer
+ */
+if ( ! function_exists('gmt_to_local'))
+{
+       function gmt_to_local($time = '', $timezone = 'UTC', $dst = FALSE)
+       {
+               if ($time == '')
+               {
+                       return now();
+               }
+
+               $time += timezones($timezone) * 3600;
+
+               if ($dst == TRUE)
+               {
+                       $time += 3600;
+               }
+
+               return $time;
+       }
+}
+
+// ------------------------------------------------------------------------
+
+/**
+ * Converts a MySQL Timestamp to Unix
+ *
+ * @access     public
+ * @param      integer Unix timestamp
+ * @return     integer
+ */
+if ( ! function_exists('mysql_to_unix'))
+{
+       function mysql_to_unix($time = '')
+       {
+               // We'll remove certain characters for backward compatibility
+               // since the formatting changed with MySQL 4.1
+               // YYYY-MM-DD HH:MM:SS
+
+               $time = str_replace('-', '', $time);
+               $time = str_replace(':', '', $time);
+               $time = str_replace(' ', '', $time);
+
+               // YYYYMMDDHHMMSS
+               return  mktime(
+                                               substr($time, 8, 2),
+                                               substr($time, 10, 2),
+                                               substr($time, 12, 2),
+                                               substr($time, 4, 2),
+                                               substr($time, 6, 2),
+                                               substr($time, 0, 4)
+                                               );
+       }
+}
+
+// ------------------------------------------------------------------------
+
+/**
+ * Unix to "Human"
+ *
+ * Formats Unix timestamp to the following prototype: 2006-08-21 11:35 PM
+ *
+ * @access     public
+ * @param      integer Unix timestamp
+ * @param      bool    whether to show seconds
+ * @param      string  format: us or euro
+ * @return     string
+ */
+if ( ! function_exists('unix_to_human'))
+{
+       function unix_to_human($time = '', $seconds = FALSE, $fmt = 'us')
+       {
+               $r  = date('Y', $time).'-'.date('m', $time).'-'.date('d', $time).' ';
+
+               if ($fmt == 'us')
+               {
+                       $r .= date('h', $time).':'.date('i', $time);
+               }
+               else
+               {
+                       $r .= date('H', $time).':'.date('i', $time);
+               }
+
+               if ($seconds)
+               {
+                       $r .= ':'.date('s', $time);
+               }
+
+               if ($fmt == 'us')
+               {
+                       $r .= ' '.date('A', $time);
+               }
+
+               return $r;
+       }
+}
+
+// ------------------------------------------------------------------------
+
+/**
+ * Convert "human" date to GMT
+ *
+ * Reverses the above process
+ *
+ * @access     public
+ * @param      string  format: us or euro
+ * @return     integer
+ */
+if ( ! function_exists('human_to_unix'))
+{
+       function human_to_unix($datestr = '')
+       {
+               if ($datestr == '')
+               {
+                       return FALSE;
+               }
+
+               $datestr = trim($datestr);
+               $datestr = preg_replace("/\040+/", ' ', $datestr);
+
+               if ( ! preg_match('/^[0-9]{2,4}\-[0-9]{1,2}\-[0-9]{1,2}\s[0-9]{1,2}:[0-9]{1,2}(?::[0-9]{1,2})?(?:\s[AP]M)?$/i', $datestr))
+               {
+                       return FALSE;
+               }
+
+               $split = explode(' ', $datestr);
+
+               $ex = explode("-", $split['0']);
+
+               $year  = (strlen($ex['0']) == 2) ? '20'.$ex['0'] : $ex['0'];
+               $month = (strlen($ex['1']) == 1) ? '0'.$ex['1']  : $ex['1'];
+               $day   = (strlen($ex['2']) == 1) ? '0'.$ex['2']  : $ex['2'];
+
+               $ex = explode(":", $split['1']);
+
+               $hour = (strlen($ex['0']) == 1) ? '0'.$ex['0'] : $ex['0'];
+               $min  = (strlen($ex['1']) == 1) ? '0'.$ex['1'] : $ex['1'];
+
+               if (isset($ex['2']) && preg_match('/[0-9]{1,2}/', $ex['2']))
+               {
+                       $sec  = (strlen($ex['2']) == 1) ? '0'.$ex['2'] : $ex['2'];
+               }
+               else
+               {
+                       // Unless specified, seconds get set to zero.
+                       $sec = '00';
+               }
+
+               if (isset($split['2']))
+               {
+                       $ampm = strtolower($split['2']);
+
+                       if (substr($ampm, 0, 1) == 'p' AND $hour < 12)
+                               $hour = $hour + 12;
+
+                       if (substr($ampm, 0, 1) == 'a' AND $hour == 12)
+                               $hour =  '00';
+
+                       if (strlen($hour) == 1)
+                               $hour = '0'.$hour;
+               }
+
+               return mktime($hour, $min, $sec, $month, $day, $year);
+       }
+}
+
+// ------------------------------------------------------------------------
+
+/**
+ * Timezone Menu
+ *
+ * Generates a drop-down menu of timezones.
+ *
+ * @access     public
+ * @param      string  timezone
+ * @param      string  classname
+ * @param      string  menu name
+ * @return     string
+ */
+if ( ! function_exists('timezone_menu'))
+{
+       function timezone_menu($default = 'UTC', $class = "", $name = 'timezones')
+       {
+               $CI =& get_instance();
+               $CI->lang->load('date');
+
+               if ($default == 'GMT')
+                       $default = 'UTC';
+
+               $menu = '<select name="'.$name.'"';
+
+               if ($class != '')
+               {
+                       $menu .= ' class="'.$class.'"';
+               }
+
+               $menu .= ">\n";
+
+               foreach (timezones() as $key => $val)
+               {
+                       $selected = ($default == $key) ? " selected='selected'" : '';
+                       $menu .= "<option value='{$key}'{$selected}>".$CI->lang->line($key)."</option>\n";
+               }
+
+               $menu .= "</select>";
+
+               return $menu;
+       }
+}
+
+// ------------------------------------------------------------------------
+
+/**
+ * Timezones
+ *
+ * Returns an array of timezones.  This is a helper function
+ * for various other ones in this library
+ *
+ * @access     public
+ * @param      string  timezone
+ * @return     string
+ */
+if ( ! function_exists('timezones'))
+{
+       function timezones($tz = '')
+       {
+               // Note: Don't change the order of these even though
+               // some items appear to be in the wrong order
+
+               $zones = array(
+                                               'UM12'          => -12,
+                                               'UM11'          => -11,
+                                               'UM10'          => -10,
+                                               'UM95'          => -9.5,
+                                               'UM9'           => -9,
+                                               'UM8'           => -8,
+                                               'UM7'           => -7,
+                                               'UM6'           => -6,
+                                               'UM5'           => -5,
+                                               'UM45'          => -4.5,
+                                               'UM4'           => -4,
+                                               'UM35'          => -3.5,
+                                               'UM3'           => -3,
+                                               'UM2'           => -2,
+                                               'UM1'           => -1,
+                                               'UTC'           => 0,
+                                               'UP1'           => +1,
+                                               'UP2'           => +2,
+                                               'UP3'           => +3,
+                                               'UP35'          => +3.5,
+                                               'UP4'           => +4,
+                                               'UP45'          => +4.5,
+                                               'UP5'           => +5,
+                                               'UP55'          => +5.5,
+                                               'UP575'         => +5.75,
+                                               'UP6'           => +6,
+                                               'UP65'          => +6.5,
+                                               'UP7'           => +7,
+                                               'UP8'           => +8,
+                                               'UP875'         => +8.75,
+                                               'UP9'           => +9,
+                                               'UP95'          => +9.5,
+                                               'UP10'          => +10,
+                                               'UP105'         => +10.5,
+                                               'UP11'          => +11,
+                                               'UP115'         => +11.5,
+                                               'UP12'          => +12,
+                                               'UP1275'        => +12.75,
+                                               'UP13'          => +13,
+                                               'UP14'          => +14
+                                       );
+
+               if ($tz == '')
+               {
+                       return $zones;
+               }
+
+               if ($tz == 'GMT')
+                       $tz = 'UTC';
+
+               return ( ! isset($zones[$tz])) ? 0 : $zones[$tz];
+       }
+}
+
+
+/* End of file date_helper.php */
+/* Location: ./system/helpers/date_helper.php */
\ No newline at end of file
diff --git a/system/helpers/directory_helper.php b/system/helpers/directory_helper.php
new file mode 100755 (executable)
index 0000000..38347fa
--- /dev/null
@@ -0,0 +1,80 @@
+<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+/**
+ * CodeIgniter
+ *
+ * An open source application development framework for PHP 5.1.6 or newer
+ *
+ * @package            CodeIgniter
+ * @author             ExpressionEngine Dev Team
+ * @copyright  Copyright (c) 2008 - 2011, EllisLab, Inc.
+ * @license            http://codeigniter.com/user_guide/license.html
+ * @link               http://codeigniter.com
+ * @since              Version 1.0
+ * @filesource
+ */
+
+// ------------------------------------------------------------------------
+
+/**
+ * CodeIgniter Directory Helpers
+ *
+ * @package            CodeIgniter
+ * @subpackage Helpers
+ * @category   Helpers
+ * @author             ExpressionEngine Dev Team
+ * @link               http://codeigniter.com/user_guide/helpers/directory_helper.html
+ */
+
+// ------------------------------------------------------------------------
+
+/**
+ * Create a Directory Map
+ *
+ * Reads the specified directory and builds an array
+ * representation of it.  Sub-folders contained with the
+ * directory will be mapped as well.
+ *
+ * @access     public
+ * @param      string  path to source
+ * @param      int             depth of directories to traverse (0 = fully recursive, 1 = current dir, etc)
+ * @return     array
+ */
+if ( ! function_exists('directory_map'))
+{
+       function directory_map($source_dir, $directory_depth = 0, $hidden = FALSE)
+       {
+               if ($fp = @opendir($source_dir))
+               {
+                       $filedata       = array();
+                       $new_depth      = $directory_depth - 1;
+                       $source_dir     = rtrim($source_dir, DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR;
+
+                       while (FALSE !== ($file = readdir($fp)))
+                       {
+                               // Remove '.', '..', and hidden files [optional]
+                               if ( ! trim($file, '.') OR ($hidden == FALSE && $file[0] == '.'))
+                               {
+                                       continue;
+                               }
+
+                               if (($directory_depth < 1 OR $new_depth > 0) && @is_dir($source_dir.$file))
+                               {
+                                       $filedata[$file] = directory_map($source_dir.$file.DIRECTORY_SEPARATOR, $new_depth, $hidden);
+                               }
+                               else
+                               {
+                                       $filedata[] = $file;
+                               }
+                       }
+
+                       closedir($fp);
+                       return $filedata;
+               }
+
+               return FALSE;
+       }
+}
+
+
+/* End of file directory_helper.php */
+/* Location: ./system/helpers/directory_helper.php */
\ No newline at end of file
diff --git a/system/helpers/download_helper.php b/system/helpers/download_helper.php
new file mode 100755 (executable)
index 0000000..f8073d2
--- /dev/null
@@ -0,0 +1,107 @@
+<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+/**
+ * CodeIgniter
+ *
+ * An open source application development framework for PHP 5.1.6 or newer
+ *
+ * @package            CodeIgniter
+ * @author             ExpressionEngine Dev Team
+ * @copyright  Copyright (c) 2008 - 2011, EllisLab, Inc.
+ * @license            http://codeigniter.com/user_guide/license.html
+ * @link               http://codeigniter.com
+ * @since              Version 1.0
+ * @filesource
+ */
+
+// ------------------------------------------------------------------------
+
+/**
+ * CodeIgniter Download Helpers
+ *
+ * @package            CodeIgniter
+ * @subpackage Helpers
+ * @category   Helpers
+ * @author             ExpressionEngine Dev Team
+ * @link               http://codeigniter.com/user_guide/helpers/download_helper.html
+ */
+
+// ------------------------------------------------------------------------
+
+/**
+ * Force Download
+ *
+ * Generates headers that force a download to happen
+ *
+ * @access     public
+ * @param      string  filename
+ * @param      mixed   the data to be downloaded
+ * @return     void
+ */
+if ( ! function_exists('force_download'))
+{
+       function force_download($filename = '', $data = '')
+       {
+               if ($filename == '' OR $data == '')
+               {
+                       return FALSE;
+               }
+
+               // Try to determine if the filename includes a file extension.
+               // We need it in order to set the MIME type
+               if (FALSE === strpos($filename, '.'))
+               {
+                       return FALSE;
+               }
+
+               // Grab the file extension
+               $x = explode('.', $filename);
+               $extension = end($x);
+
+               // Load the mime types
+               if (defined('ENVIRONMENT') AND is_file(APPPATH.'config/'.ENVIRONMENT.'/mimes'.EXT))
+               {
+                       include(APPPATH.'config/'.ENVIRONMENT.'/mimes'.EXT);
+               }
+               elseif (is_file(APPPATH.'config/mimes'.EXT))
+               {
+                       include(APPPATH.'config/mimes'.EXT);
+               }
+
+               // Set a default mime if we can't find it
+               if ( ! isset($mimes[$extension]))
+               {
+                       $mime = 'application/octet-stream';
+               }
+               else
+               {
+                       $mime = (is_array($mimes[$extension])) ? $mimes[$extension][0] : $mimes[$extension];
+               }
+
+               // Generate the server headers
+               if (strpos($_SERVER['HTTP_USER_AGENT'], "MSIE") !== FALSE)
+               {
+                       header('Content-Type: "'.$mime.'"');
+                       header('Content-Disposition: attachment; filename="'.$filename.'"');
+                       header('Expires: 0');
+                       header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
+                       header("Content-Transfer-Encoding: binary");
+                       header('Pragma: public');
+                       header("Content-Length: ".strlen($data));
+               }
+               else
+               {
+                       header('Content-Type: "'.$mime.'"');
+                       header('Content-Disposition: attachment; filename="'.$filename.'"');
+                       header("Content-Transfer-Encoding: binary");
+                       header('Expires: 0');
+                       header('Pragma: no-cache');
+                       header("Content-Length: ".strlen($data));
+               }
+
+               exit($data);
+       }
+}
+
+
+/* End of file download_helper.php */
+/* Location: ./system/helpers/download_helper.php */
\ No newline at end of file
diff --git a/system/helpers/email_helper.php b/system/helpers/email_helper.php
new file mode 100755 (executable)
index 0000000..651aef4
--- /dev/null
@@ -0,0 +1,62 @@
+<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+/**
+ * CodeIgniter
+ *
+ * An open source application development framework for PHP 5.1.6 or newer
+ *
+ * @package            CodeIgniter
+ * @author             ExpressionEngine Dev Team
+ * @copyright  Copyright (c) 2008 - 2011, EllisLab, Inc.
+ * @license            http://codeigniter.com/user_guide/license.html
+ * @link               http://codeigniter.com
+ * @since              Version 1.0
+ * @filesource
+ */
+
+// ------------------------------------------------------------------------
+
+/**
+ * CodeIgniter Email Helpers
+ *
+ * @package            CodeIgniter
+ * @subpackage Helpers
+ * @category   Helpers
+ * @author             ExpressionEngine Dev Team
+ * @link               http://codeigniter.com/user_guide/helpers/email_helper.html
+ */
+
+// ------------------------------------------------------------------------
+
+/**
+ * Validate email address
+ *
+ * @access     public
+ * @return     bool
+ */
+if ( ! function_exists('valid_email'))
+{
+       function valid_email($address)
+       {
+               return ( ! preg_match("/^([a-z0-9\+_\-]+)(\.[a-z0-9\+_\-]+)*@([a-z0-9\-]+\.)+[a-z]{2,6}$/ix", $address)) ? FALSE : TRUE;
+       }
+}
+
+// ------------------------------------------------------------------------
+
+/**
+ * Send an email
+ *
+ * @access     public
+ * @return     bool
+ */
+if ( ! function_exists('send_email'))
+{
+       function send_email($recipient, $subject = 'Test email', $message = 'Hello World')
+       {
+               return mail($recipient, $subject, $message);
+       }
+}
+
+
+/* End of file email_helper.php */
+/* Location: ./system/helpers/email_helper.php */
\ No newline at end of file
diff --git a/system/helpers/file_helper.php b/system/helpers/file_helper.php
new file mode 100755 (executable)
index 0000000..4434494
--- /dev/null
@@ -0,0 +1,479 @@
+<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+/**
+ * CodeIgniter
+ *
+ * An open source application development framework for PHP 5.1.6 or newer
+ *
+ * @package            CodeIgniter
+ * @author             ExpressionEngine Dev Team
+ * @copyright  Copyright (c) 2008 - 2011, EllisLab, Inc.
+ * @license            http://codeigniter.com/user_guide/license.html
+ * @link               http://codeigniter.com
+ * @since              Version 1.0
+ * @filesource
+ */
+
+// ------------------------------------------------------------------------
+
+/**
+ * CodeIgniter File Helpers
+ *
+ * @package            CodeIgniter
+ * @subpackage Helpers
+ * @category   Helpers
+ * @author             ExpressionEngine Dev Team
+ * @link               http://codeigniter.com/user_guide/helpers/file_helpers.html
+ */
+
+// ------------------------------------------------------------------------
+
+/**
+ * Read File
+ *
+ * Opens the file specfied in the path and returns it as a string.
+ *
+ * @access     public
+ * @param      string  path to file
+ * @return     string
+ */
+if ( ! function_exists('read_file'))
+{
+       function read_file($file)
+       {
+               if ( ! file_exists($file))
+               {
+                       return FALSE;
+               }
+
+               if (function_exists('file_get_contents'))
+               {
+                       return file_get_contents($file);
+               }
+
+               if ( ! $fp = @fopen($file, FOPEN_READ))
+               {
+                       return FALSE;
+               }
+
+               flock($fp, LOCK_SH);
+
+               $data = '';
+               if (filesize($file) > 0)
+               {
+                       $data =& fread($fp, filesize($file));
+               }
+
+               flock($fp, LOCK_UN);
+               fclose($fp);
+
+               return $data;
+       }
+}
+
+// ------------------------------------------------------------------------
+
+/**
+ * Write File
+ *
+ * Writes data to the file specified in the path.
+ * Creates a new file if non-existent.
+ *
+ * @access     public
+ * @param      string  path to file
+ * @param      string  file data
+ * @return     bool
+ */
+if ( ! function_exists('write_file'))
+{
+       function write_file($path, $data, $mode = FOPEN_WRITE_CREATE_DESTRUCTIVE)
+       {
+               if ( ! $fp = @fopen($path, $mode))
+               {
+                       return FALSE;
+               }
+
+               flock($fp, LOCK_EX);
+               fwrite($fp, $data);
+               flock($fp, LOCK_UN);
+               fclose($fp);
+
+               return TRUE;
+       }
+}
+
+// ------------------------------------------------------------------------
+
+/**
+ * Delete Files
+ *
+ * Deletes all files contained in the supplied directory path.
+ * Files must be writable or owned by the system in order to be deleted.
+ * If the second parameter is set to TRUE, any directories contained
+ * within the supplied base directory will be nuked as well.
+ *
+ * @access     public
+ * @param      string  path to file
+ * @param      bool    whether to delete any directories found in the path
+ * @return     bool
+ */
+if ( ! function_exists('delete_files'))
+{
+       function delete_files($path, $del_dir = FALSE, $level = 0)
+       {
+               // Trim the trailing slash
+               $path = rtrim($path, DIRECTORY_SEPARATOR);
+
+               if ( ! $current_dir = @opendir($path))
+               {
+                       return FALSE;
+               }
+
+               while (FALSE !== ($filename = @readdir($current_dir)))
+               {
+                       if ($filename != "." and $filename != "..")
+                       {
+                               if (is_dir($path.DIRECTORY_SEPARATOR.$filename))
+                               {
+                                       // Ignore empty folders
+                                       if (substr($filename, 0, 1) != '.')
+                                       {
+                                               delete_files($path.DIRECTORY_SEPARATOR.$filename, $del_dir, $level + 1);
+                                       }
+                               }
+                               else
+                               {
+                                       unlink($path.DIRECTORY_SEPARATOR.$filename);
+                               }
+                       }
+               }
+               @closedir($current_dir);
+
+               if ($del_dir == TRUE AND $level > 0)
+               {
+                       return @rmdir($path);
+               }
+
+               return TRUE;
+       }
+}
+
+// ------------------------------------------------------------------------
+
+/**
+ * Get Filenames
+ *
+ * Reads the specified directory and builds an array containing the filenames.
+ * Any sub-folders contained within the specified path are read as well.
+ *
+ * @access     public
+ * @param      string  path to source
+ * @param      bool    whether to include the path as part of the filename
+ * @param      bool    internal variable to determine recursion status - do not use in calls
+ * @return     array
+ */
+if ( ! function_exists('get_filenames'))
+{
+       function get_filenames($source_dir, $include_path = FALSE, $_recursion = FALSE)
+       {
+               static $_filedata = array();
+
+               if ($fp = @opendir($source_dir))
+               {
+                       // reset the array and make sure $source_dir has a trailing slash on the initial call
+                       if ($_recursion === FALSE)
+                       {
+                               $_filedata = array();
+                               $source_dir = rtrim(realpath($source_dir), DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR;
+                       }
+
+                       while (FALSE !== ($file = readdir($fp)))
+                       {
+                               if (@is_dir($source_dir.$file) && strncmp($file, '.', 1) !== 0)
+                               {
+                                       get_filenames($source_dir.$file.DIRECTORY_SEPARATOR, $include_path, TRUE);
+                               }
+                               elseif (strncmp($file, '.', 1) !== 0)
+                               {
+                                       $_filedata[] = ($include_path == TRUE) ? $source_dir.$file : $file;
+                               }
+                       }
+                       return $_filedata;
+               }
+               else
+               {
+                       return FALSE;
+               }
+       }
+}
+
+// --------------------------------------------------------------------
+
+/**
+ * Get Directory File Information
+ *
+ * Reads the specified directory and builds an array containing the filenames,
+ * filesize, dates, and permissions
+ *
+ * Any sub-folders contained within the specified path are read as well.
+ *
+ * @access     public
+ * @param      string  path to source
+ * @param      bool    Look only at the top level directory specified?
+ * @param      bool    internal variable to determine recursion status - do not use in calls
+ * @return     array
+ */
+if ( ! function_exists('get_dir_file_info'))
+{
+       function get_dir_file_info($source_dir, $top_level_only = TRUE, $_recursion = FALSE)
+       {
+               static $_filedata = array();
+               $relative_path = $source_dir;
+
+               if ($fp = @opendir($source_dir))
+               {
+                       // reset the array and make sure $source_dir has a trailing slash on the initial call
+                       if ($_recursion === FALSE)
+                       {
+                               $_filedata = array();
+                               $source_dir = rtrim(realpath($source_dir), DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR;
+                       }
+
+                       // foreach (scandir($source_dir, 1) as $file) // In addition to being PHP5+, scandir() is simply not as fast
+                       while (FALSE !== ($file = readdir($fp)))
+                       {
+                               if (@is_dir($source_dir.$file) AND strncmp($file, '.', 1) !== 0 AND $top_level_only === FALSE)
+                               {
+                                       get_dir_file_info($source_dir.$file.DIRECTORY_SEPARATOR, $top_level_only, TRUE);
+                               }
+                               elseif (strncmp($file, '.', 1) !== 0)
+                               {
+                                       $_filedata[$file] = get_file_info($source_dir.$file);
+                                       $_filedata[$file]['relative_path'] = $relative_path;
+                               }
+                       }
+
+                       return $_filedata;
+               }
+               else
+               {
+                       return FALSE;
+               }
+       }
+}
+
+// --------------------------------------------------------------------
+
+/**
+* Get File Info
+*
+* Given a file and path, returns the name, path, size, date modified
+* Second parameter allows you to explicitly declare what information you want returned
+* Options are: name, server_path, size, date, readable, writable, executable, fileperms
+* Returns FALSE if the file cannot be found.
+*
+* @access      public
+* @param       string  path to file
+* @param       mixed   array or comma separated string of information returned
+* @return      array
+*/
+if ( ! function_exists('get_file_info'))
+{
+       function get_file_info($file, $returned_values = array('name', 'server_path', 'size', 'date'))
+       {
+
+               if ( ! file_exists($file))
+               {
+                       return FALSE;
+               }
+
+               if (is_string($returned_values))
+               {
+                       $returned_values = explode(',', $returned_values);
+               }
+
+               foreach ($returned_values as $key)
+               {
+                       switch ($key)
+                       {
+                               case 'name':
+                                       $fileinfo['name'] = substr(strrchr($file, DIRECTORY_SEPARATOR), 1);
+                                       break;
+                               case 'server_path':
+                                       $fileinfo['server_path'] = $file;
+                                       break;
+                               case 'size':
+                                       $fileinfo['size'] = filesize($file);
+                                       break;
+                               case 'date':
+                                       $fileinfo['date'] = filemtime($file);
+                                       break;
+                               case 'readable':
+                                       $fileinfo['readable'] = is_readable($file);
+                                       break;
+                               case 'writable':
+                                       // There are known problems using is_weritable on IIS.  It may not be reliable - consider fileperms()
+                                       $fileinfo['writable'] = is_writable($file);
+                                       break;
+                               case 'executable':
+                                       $fileinfo['executable'] = is_executable($file);
+                                       break;
+                               case 'fileperms':
+                                       $fileinfo['fileperms'] = fileperms($file);
+                                       break;
+                       }
+               }
+
+               return $fileinfo;
+       }
+}
+
+// --------------------------------------------------------------------
+
+/**
+ * Get Mime by Extension
+ *
+ * Translates a file extension into a mime type based on config/mimes.php.
+ * Returns FALSE if it can't determine the type, or open the mime config file
+ *
+ * Note: this is NOT an accurate way of determining file mime types, and is here strictly as a convenience
+ * It should NOT be trusted, and should certainly NOT be used for security
+ *
+ * @access     public
+ * @param      string  path to file
+ * @return     mixed
+ */
+if ( ! function_exists('get_mime_by_extension'))
+{
+       function get_mime_by_extension($file)
+       {
+               $extension = strtolower(substr(strrchr($file, '.'), 1));
+
+               global $mimes;
+
+               if ( ! is_array($mimes))
+               {
+                       if (defined('ENVIRONMENT') AND is_file(APPPATH.'config/'.ENVIRONMENT.'/mimes'.EXT))
+                       {
+                               include(APPPATH.'config/'.ENVIRONMENT.'/mimes'.EXT);
+                       }
+                       elseif (is_file(APPPATH.'config/mimes'.EXT))
+                       {
+                               include(APPPATH.'config/mimes'.EXT);
+                       }
+
+                       if ( ! is_array($mimes))
+                       {
+                               return FALSE;
+                       }
+               }
+
+               if (array_key_exists($extension, $mimes))
+               {
+                       if (is_array($mimes[$extension]))
+                       {
+                               // Multiple mime types, just give the first one
+                               return current($mimes[$extension]);
+                       }
+                       else
+                       {
+                               return $mimes[$extension];
+                       }
+               }
+               else
+               {
+                       return FALSE;
+               }
+       }
+}
+
+// --------------------------------------------------------------------
+
+/**
+ * Symbolic Permissions
+ *
+ * Takes a numeric value representing a file's permissions and returns
+ * standard symbolic notation representing that value
+ *
+ * @access     public
+ * @param      int
+ * @return     string
+ */
+if ( ! function_exists('symbolic_permissions'))
+{
+       function symbolic_permissions($perms)
+       {
+               if (($perms & 0xC000) == 0xC000)
+               {
+                       $symbolic = 's'; // Socket
+               }
+               elseif (($perms & 0xA000) == 0xA000)
+               {
+                       $symbolic = 'l'; // Symbolic Link
+               }
+               elseif (($perms & 0x8000) == 0x8000)
+               {
+                       $symbolic = '-'; // Regular
+               }
+               elseif (($perms & 0x6000) == 0x6000)
+               {
+                       $symbolic = 'b'; // Block special
+               }
+               elseif (($perms & 0x4000) == 0x4000)
+               {
+                       $symbolic = 'd'; // Directory
+               }
+               elseif (($perms & 0x2000) == 0x2000)
+               {
+                       $symbolic = 'c'; // Character special
+               }
+               elseif (($perms & 0x1000) == 0x1000)
+               {
+                       $symbolic = 'p'; // FIFO pipe
+               }
+               else
+               {
+                       $symbolic = 'u'; // Unknown
+               }
+
+               // Owner
+               $symbolic .= (($perms & 0x0100) ? 'r' : '-');
+               $symbolic .= (($perms & 0x0080) ? 'w' : '-');
+               $symbolic .= (($perms & 0x0040) ? (($perms & 0x0800) ? 's' : 'x' ) : (($perms & 0x0800) ? 'S' : '-'));
+
+               // Group
+               $symbolic .= (($perms & 0x0020) ? 'r' : '-');
+               $symbolic .= (($perms & 0x0010) ? 'w' : '-');
+               $symbolic .= (($perms & 0x0008) ? (($perms & 0x0400) ? 's' : 'x' ) : (($perms & 0x0400) ? 'S' : '-'));
+
+               // World
+               $symbolic .= (($perms & 0x0004) ? 'r' : '-');
+               $symbolic .= (($perms & 0x0002) ? 'w' : '-');
+               $symbolic .= (($perms & 0x0001) ? (($perms & 0x0200) ? 't' : 'x' ) : (($perms & 0x0200) ? 'T' : '-'));
+
+               return $symbolic;
+       }
+}
+
+// --------------------------------------------------------------------
+
+/**
+ * Octal Permissions
+ *
+ * Takes a numeric value representing a file's permissions and returns
+ * a three character string representing the file's octal permissions
+ *
+ * @access     public
+ * @param      int
+ * @return     string
+ */
+if ( ! function_exists('octal_permissions'))
+{
+       function octal_permissions($perms)
+       {
+               return substr(sprintf('%o', $perms), -3);
+       }
+}
+
+
+/* End of file file_helper.php */
+/* Location: ./system/helpers/file_helper.php */
\ No newline at end of file
diff --git a/system/helpers/form_helper.php b/system/helpers/form_helper.php
new file mode 100755 (executable)
index 0000000..acd75c2
--- /dev/null
@@ -0,0 +1,1056 @@
+<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+/**
+ * CodeIgniter
+ *
+ * An open source application development framework for PHP 5.1.6 or newer
+ *
+ * @package            CodeIgniter
+ * @author             ExpressionEngine Dev Team
+ * @copyright  Copyright (c) 2008 - 2011, EllisLab, Inc.
+ * @license            http://codeigniter.com/user_guide/license.html
+ * @link               http://codeigniter.com
+ * @since              Version 1.0
+ * @filesource
+ */
+
+// ------------------------------------------------------------------------
+
+/**
+ * CodeIgniter Form Helpers
+ *
+ * @package            CodeIgniter
+ * @subpackage Helpers
+ * @category   Helpers
+ * @author             ExpressionEngine Dev Team
+ * @link               http://codeigniter.com/user_guide/helpers/form_helper.html
+ */
+
+// ------------------------------------------------------------------------
+
+/**
+ * Form Declaration
+ *
+ * Creates the opening portion of the form.
+ *
+ * @access     public
+ * @param      string  the URI segments of the form destination
+ * @param      array   a key/value pair of attributes
+ * @param      array   a key/value pair hidden data
+ * @return     string
+ */
+if ( ! function_exists('form_open'))
+{
+       function form_open($action = '', $attributes = '', $hidden = array())
+       {
+               $CI =& get_instance();
+
+               if ($attributes == '')
+               {
+                       $attributes = 'method="post"';
+               }
+
+               // 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 = '<form action="'.$action.'"';
+
+               $form .= _attributes_to_string($attributes, TRUE);
+
+               $form .= '>';
+
+               // CSRF
+               if ($CI->config->item('csrf_protection') === TRUE)
+               {
+                       $hidden[$CI->security->get_csrf_token_name()] = $CI->security->get_csrf_hash();
+               }
+
+               if (is_array($hidden) AND count($hidden) > 0)
+               {
+                       $form .= sprintf("\n<div class=\"hidden\">%s</div>", form_hidden($hidden));
+               }
+
+               return $form;
+       }
+}
+
+// ------------------------------------------------------------------------
+
+/**
+ * Form Declaration - Multipart type
+ *
+ * Creates the opening portion of the form, but with "multipart/form-data".
+ *
+ * @access     public
+ * @param      string  the URI segments of the form destination
+ * @param      array   a key/value pair of attributes
+ * @param      array   a key/value pair hidden data
+ * @return     string
+ */
+if ( ! function_exists('form_open_multipart'))
+{
+       function form_open_multipart($action, $attributes = array(), $hidden = array())
+       {
+               if (is_string($attributes))
+               {
+                       $attributes .= ' enctype="multipart/form-data"';
+               }
+               else
+               {
+                       $attributes['enctype'] = 'multipart/form-data';
+               }
+
+               return form_open($action, $attributes, $hidden);
+       }
+}
+
+// ------------------------------------------------------------------------
+
+/**
+ * Hidden Input Field
+ *
+ * Generates hidden fields.  You can pass a simple key/value string or an associative
+ * array with multiple values.
+ *
+ * @access     public
+ * @param      mixed
+ * @param      string
+ * @return     string
+ */
+if ( ! function_exists('form_hidden'))
+{
+       function form_hidden($name, $value = '', $recursing = FALSE)
+       {
+               static $form;
+
+               if ($recursing === FALSE)
+               {
+                       $form = "\n";
+               }
+
+               if (is_array($name))
+               {
+                       foreach ($name as $key => $val)
+                       {
+                               form_hidden($key, $val, TRUE);
+                       }
+                       return $form;
+               }
+
+               if ( ! is_array($value))
+               {
+                       $form .= '<input type="hidden" name="'.$name.'" value="'.form_prep($value, $name).'" />'."\n";
+               }
+               else
+               {
+                       foreach ($value as $k => $v)
+                       {
+                               $k = (is_int($k)) ? '' : $k;
+                               form_hidden($name.'['.$k.']', $v, TRUE);
+                       }
+               }
+
+               return $form;
+       }
+}
+
+// ------------------------------------------------------------------------
+
+/**
+ * Text Input Field
+ *
+ * @access     public
+ * @param      mixed
+ * @param      string
+ * @param      string
+ * @return     string
+ */
+if ( ! function_exists('form_input'))
+{
+       function form_input($data = '', $value = '', $extra = '')
+       {
+               $defaults = array('type' => 'text', 'name' => (( ! is_array($data)) ? $data : ''), 'value' => $value);
+
+               return "<input "._parse_form_attributes($data, $defaults).$extra." />";
+       }
+}
+
+// ------------------------------------------------------------------------
+
+/**
+ * Password Field
+ *
+ * Identical to the input function but adds the "password" type
+ *
+ * @access     public
+ * @param      mixed
+ * @param      string
+ * @param      string
+ * @return     string
+ */
+if ( ! function_exists('form_password'))
+{
+       function form_password($data = '', $value = '', $extra = '')
+       {
+               if ( ! is_array($data))
+               {
+                       $data = array('name' => $data);
+               }
+
+               $data['type'] = 'password';
+               return form_input($data, $value, $extra);
+       }
+}
+
+// ------------------------------------------------------------------------
+
+/**
+ * Upload Field
+ *
+ * Identical to the input function but adds the "file" type
+ *
+ * @access     public
+ * @param      mixed
+ * @param      string
+ * @param      string
+ * @return     string
+ */
+if ( ! function_exists('form_upload'))
+{
+       function form_upload($data = '', $value = '', $extra = '')
+       {
+               if ( ! is_array($data))
+               {
+                       $data = array('name' => $data);
+               }
+
+               $data['type'] = 'file';
+               return form_input($data, $value, $extra);
+       }
+}
+
+// ------------------------------------------------------------------------
+
+/**
+ * Textarea field
+ *
+ * @access     public
+ * @param      mixed
+ * @param      string
+ * @param      string
+ * @return     string
+ */
+if ( ! function_exists('form_textarea'))
+{
+       function form_textarea($data = '', $value = '', $extra = '')
+       {
+               $defaults = array('name' => (( ! is_array($data)) ? $data : ''), 'cols' => '90', 'rows' => '12');
+
+               if ( ! is_array($data) OR ! isset($data['value']))
+               {
+                       $val = $value;
+               }
+               else
+               {
+                       $val = $data['value'];
+                       unset($data['value']); // textareas don't use the value attribute
+               }
+
+               $name = (is_array($data)) ? $data['name'] : $data;
+               return "<textarea "._parse_form_attributes($data, $defaults).$extra.">".form_prep($val, $name)."</textarea>";
+       }
+}
+
+// ------------------------------------------------------------------------
+
+/**
+ * Multi-select menu
+ *
+ * @access     public
+ * @param      string
+ * @param      array
+ * @param      mixed
+ * @param      string
+ * @return     type
+ */
+if ( ! function_exists('form_multiselect'))
+{
+       function form_multiselect($name = '', $options = array(), $selected = array(), $extra = '')
+       {
+               if ( ! strpos($extra, 'multiple'))
+               {
+                       $extra .= ' multiple="multiple"';
+               }
+
+               return form_dropdown($name, $options, $selected, $extra);
+       }
+}
+
+// --------------------------------------------------------------------
+
+/**
+ * Drop-down Menu
+ *
+ * @access     public
+ * @param      string
+ * @param      array
+ * @param      string
+ * @param      string
+ * @return     string
+ */
+if ( ! function_exists('form_dropdown'))
+{
+       function form_dropdown($name = '', $options = array(), $selected = array(), $extra = '')
+       {
+               if ( ! is_array($selected))
+               {
+                       $selected = array($selected);
+               }
+
+               // If no selected state was submitted we will attempt to set it automatically
+               if (count($selected) === 0)
+               {
+                       // If the form name appears in the $_POST array we have a winner!
+                       if (isset($_POST[$name]))
+                       {
+                               $selected = array($_POST[$name]);
+                       }
+               }
+
+               if ($extra != '') $extra = ' '.$extra;
+
+               $multiple = (count($selected) > 1 && strpos($extra, 'multiple') === FALSE) ? ' multiple="multiple"' : '';
+
+               $form = '<select name="'.$name.'"'.$extra.$multiple.">\n";
+
+               foreach ($options as $key => $val)
+               {
+                       $key = (string) $key;
+
+                       if (is_array($val) && ! empty($val))
+                       {
+                               $form .= '<optgroup label="'.$key.'">'."\n";
+
+                               foreach ($val as $optgroup_key => $optgroup_val)
+                               {
+                                       $sel = (in_array($optgroup_key, $selected)) ? ' selected="selected"' : '';
+
+                                       $form .= '<option value="'.$optgroup_key.'"'.$sel.'>'.(string) $optgroup_val."</option>\n";
+                               }
+
+                               $form .= '</optgroup>'."\n";
+                       }
+                       else
+                       {
+                               $sel = (in_array($key, $selected)) ? ' selected="selected"' : '';
+
+                               $form .= '<option value="'.$key.'"'.$sel.'>'.(string) $val."</option>\n";
+                       }
+               }
+
+               $form .= '</select>';
+
+               return $form;
+       }
+}
+
+// ------------------------------------------------------------------------
+
+/**
+ * Checkbox Field
+ *
+ * @access     public
+ * @param      mixed
+ * @param      string
+ * @param      bool
+ * @param      string
+ * @return     string
+ */
+if ( ! function_exists('form_checkbox'))
+{
+       function form_checkbox($data = '', $value = '', $checked = FALSE, $extra = '')
+       {
+               $defaults = array('type' => 'checkbox', 'name' => (( ! is_array($data)) ? $data : ''), 'value' => $value);
+
+               if (is_array($data) AND array_key_exists('checked', $data))
+               {
+                       $checked = $data['checked'];
+
+                       if ($checked == FALSE)
+                       {
+                               unset($data['checked']);
+                       }
+                       else
+                       {
+                               $data['checked'] = 'checked';
+                       }
+               }
+
+               if ($checked == TRUE)
+               {
+                       $defaults['checked'] = 'checked';
+               }
+               else
+               {
+                       unset($defaults['checked']);
+               }
+
+               return "<input "._parse_form_attributes($data, $defaults).$extra." />";
+       }
+}
+
+// ------------------------------------------------------------------------
+
+/**
+ * Radio Button
+ *
+ * @access     public
+ * @param      mixed
+ * @param      string
+ * @param      bool
+ * @param      string
+ * @return     string
+ */
+if ( ! function_exists('form_radio'))
+{
+       function form_radio($data = '', $value = '', $checked = FALSE, $extra = '')
+       {
+               if ( ! is_array($data))
+               {
+                       $data = array('name' => $data);
+               }
+
+               $data['type'] = 'radio';
+               return form_checkbox($data, $value, $checked, $extra);
+       }
+}
+
+// ------------------------------------------------------------------------
+
+/**
+ * Submit Button
+ *
+ * @access     public
+ * @param      mixed
+ * @param      string
+ * @param      string
+ * @return     string
+ */
+if ( ! function_exists('form_submit'))
+{
+       function form_submit($data = '', $value = '', $extra = '')
+       {
+               $defaults = array('type' => 'submit', 'name' => (( ! is_array($data)) ? $data : ''), 'value' => $value);
+
+               return "<input "._parse_form_attributes($data, $defaults).$extra." />";
+       }
+}
+
+// ------------------------------------------------------------------------
+
+/**
+ * Reset Button
+ *
+ * @access     public
+ * @param      mixed
+ * @param      string
+ * @param      string
+ * @return     string
+ */
+if ( ! function_exists('form_reset'))
+{
+       function form_reset($data = '', $value = '', $extra = '')
+       {
+               $defaults = array('type' => 'reset', 'name' => (( ! is_array($data)) ? $data : ''), 'value' => $value);
+
+               return "<input "._parse_form_attributes($data, $defaults).$extra." />";
+       }
+}
+
+// ------------------------------------------------------------------------
+
+/**
+ * Form Button
+ *
+ * @access     public
+ * @param      mixed
+ * @param      string
+ * @param      string
+ * @return     string
+ */
+if ( ! function_exists('form_button'))
+{
+       function form_button($data = '', $content = '', $extra = '')
+       {
+               $defaults = array('name' => (( ! is_array($data)) ? $data : ''), 'type' => 'button');
+
+               if ( is_array($data) AND isset($data['content']))
+               {
+                       $content = $data['content'];
+                       unset($data['content']); // content is not an attribute
+               }
+
+               return "<button "._parse_form_attributes($data, $defaults).$extra.">".$content."</button>";
+       }
+}
+
+// ------------------------------------------------------------------------
+
+/**
+ * Form Label Tag
+ *
+ * @access     public
+ * @param      string  The text to appear onscreen
+ * @param      string  The id the label applies to
+ * @param      string  Additional attributes
+ * @return     string
+ */
+if ( ! function_exists('form_label'))
+{
+       function form_label($label_text = '', $id = '', $attributes = array())
+       {
+
+               $label = '<label';
+
+               if ($id != '')
+               {
+                       $label .= " for=\"$id\"";
+               }
+
+               if (is_array($attributes) AND count($attributes) > 0)
+               {
+                       foreach ($attributes as $key => $val)
+                       {
+                               $label .= ' '.$key.'="'.$val.'"';
+                       }
+               }
+
+               $label .= ">$label_text</label>";
+
+               return $label;
+       }
+}
+
+// ------------------------------------------------------------------------
+/**
+ * Fieldset Tag
+ *
+ * Used to produce <fieldset><legend>text</legend>.  To close fieldset
+ * use form_fieldset_close()
+ *
+ * @access     public
+ * @param      string  The legend text
+ * @param      string  Additional attributes
+ * @return     string
+ */
+if ( ! function_exists('form_fieldset'))
+{
+       function form_fieldset($legend_text = '', $attributes = array())
+       {
+               $fieldset = "<fieldset";
+
+               $fieldset .= _attributes_to_string($attributes, FALSE);
+
+               $fieldset .= ">\n";
+
+               if ($legend_text != '')
+               {
+                       $fieldset .= "<legend>$legend_text</legend>\n";
+               }
+
+               return $fieldset;
+       }
+}
+
+// ------------------------------------------------------------------------
+
+/**
+ * Fieldset Close Tag
+ *
+ * @access     public
+ * @param      string
+ * @return     string
+ */
+if ( ! function_exists('form_fieldset_close'))
+{
+       function form_fieldset_close($extra = '')
+       {
+               return "</fieldset>".$extra;
+       }
+}
+
+// ------------------------------------------------------------------------
+
+/**
+ * Form Close Tag
+ *
+ * @access     public
+ * @param      string
+ * @return     string
+ */
+if ( ! function_exists('form_close'))
+{
+       function form_close($extra = '')
+       {
+               return "</form>".$extra;
+       }
+}
+
+// ------------------------------------------------------------------------
+
+/**
+ * Form Prep
+ *
+ * Formats text so that it can be safely placed in a form field in the event it has HTML tags.
+ *
+ * @access     public
+ * @param      string
+ * @return     string
+ */
+if ( ! function_exists('form_prep'))
+{
+       function form_prep($str = '', $field_name = '')
+       {
+               static $prepped_fields = array();
+
+               // if the field name is an array we do this recursively
+               if (is_array($str))
+               {
+                       foreach ($str as $key => $val)
+                       {
+                               $str[$key] = form_prep($val);
+                       }
+
+                       return $str;
+               }
+
+               if ($str === '')
+               {
+                       return '';
+               }
+
+               // we've already prepped a field with this name
+               // @todo need to figure out a way to namespace this so
+               // that we know the *exact* field and not just one with
+               // the same name
+               if (isset($prepped_fields[$field_name]))
+               {
+                       return $str;
+               }
+
+               $str = htmlspecialchars($str);
+
+               // In case htmlspecialchars misses these.
+               $str = str_replace(array("'", '"'), array("&#39;", "&quot;"), $str);
+
+               if ($field_name != '')
+               {
+                       $prepped_fields[$field_name] = $field_name;
+               }
+
+               return $str;
+       }
+}
+
+// ------------------------------------------------------------------------
+
+/**
+ * Form Value
+ *
+ * Grabs a value from the POST array for the specified field so you can
+ * re-populate an input field or textarea.  If Form Validation
+ * is active it retrieves the info from the validation class
+ *
+ * @access     public
+ * @param      string
+ * @return     mixed
+ */
+if ( ! function_exists('set_value'))
+{
+       function set_value($field = '', $default = '')
+       {
+               if (FALSE === ($OBJ =& _get_validation_object()))
+               {
+                       if ( ! isset($_POST[$field]))
+                       {
+                               return $default;
+                       }
+
+                       return form_prep($_POST[$field], $field);
+               }
+
+               return form_prep($OBJ->set_value($field, $default), $field);
+       }
+}
+
+// ------------------------------------------------------------------------
+
+/**
+ * Set Select
+ *
+ * Let's you set the selected value of a <select> menu via data in the POST array.
+ * If Form Validation is active it retrieves the info from the validation class
+ *
+ * @access     public
+ * @param      string
+ * @param      string
+ * @param      bool
+ * @return     string
+ */
+if ( ! function_exists('set_select'))
+{
+       function set_select($field = '', $value = '', $default = FALSE)
+       {
+               $OBJ =& _get_validation_object();
+
+               if ($OBJ === FALSE)
+               {
+                       if ( ! isset($_POST[$field]))
+                       {
+                               if (count($_POST) === 0 AND $default == TRUE)
+                               {
+                                       return ' selected="selected"';
+                               }
+                               return '';
+                       }
+
+                       $field = $_POST[$field];
+
+                       if (is_array($field))
+                       {
+                               if ( ! in_array($value, $field))
+                               {
+                                       return '';
+                               }
+                       }
+                       else
+                       {
+                               if (($field == '' OR $value == '') OR ($field != $value))
+                               {
+                                       return '';
+                               }
+                       }
+
+                       return ' selected="selected"';
+               }
+
+               return $OBJ->set_select($field, $value, $default);
+       }
+}
+
+// ------------------------------------------------------------------------
+
+/**
+ * Set Checkbox
+ *
+ * Let's you set the selected value of a checkbox via the value in the POST array.
+ * If Form Validation is active it retrieves the info from the validation class
+ *
+ * @access     public
+ * @param      string
+ * @param      string
+ * @param      bool
+ * @return     string
+ */
+if ( ! function_exists('set_checkbox'))
+{
+       function set_checkbox($field = '', $value = '', $default = FALSE)
+       {
+               $OBJ =& _get_validation_object();
+
+               if ($OBJ === FALSE)
+               {
+                       if ( ! isset($_POST[$field]))
+                       {
+                               if (count($_POST) === 0 AND $default == TRUE)
+                               {
+                                       return ' checked="checked"';
+                               }
+                               return '';
+                       }
+
+                       $field = $_POST[$field];
+
+                       if (is_array($field))
+                       {
+                               if ( ! in_array($value, $field))
+                               {
+                                       return '';
+                               }
+                       }
+                       else
+                       {
+                               if (($field == '' OR $value == '') OR ($field != $value))
+                               {
+                                       return '';
+                               }
+                       }
+
+                       return ' checked="checked"';
+               }
+
+               return $OBJ->set_checkbox($field, $value, $default);
+       }
+}
+
+// ------------------------------------------------------------------------
+
+/**
+ * Set Radio
+ *
+ * Let's you set the selected value of a radio field via info in the POST array.
+ * If Form Validation is active it retrieves the info from the validation class
+ *
+ * @access     public
+ * @param      string
+ * @param      string
+ * @param      bool
+ * @return     string
+ */
+if ( ! function_exists('set_radio'))
+{
+       function set_radio($field = '', $value = '', $default = FALSE)
+       {
+               $OBJ =& _get_validation_object();
+
+               if ($OBJ === FALSE)
+               {
+                       if ( ! isset($_POST[$field]))
+                       {
+                               if (count($_POST) === 0 AND $default == TRUE)
+                               {
+                                       return ' checked="checked"';
+                               }
+                               return '';
+                       }
+
+                       $field = $_POST[$field];
+
+                       if (is_array($field))
+                       {
+                               if ( ! in_array($value, $field))
+                               {
+                                       return '';
+                               }
+                       }
+                       else
+                       {
+                               if (($field == '' OR $value == '') OR ($field != $value))
+                               {
+                                       return '';
+                               }
+                       }
+
+                       return ' checked="checked"';
+               }
+
+               return $OBJ->set_radio($field, $value, $default);
+       }
+}
+
+// ------------------------------------------------------------------------
+
+/**
+ * Form Error
+ *
+ * Returns the error for a specific form field.  This is a helper for the
+ * form validation class.
+ *
+ * @access     public
+ * @param      string
+ * @param      string
+ * @param      string
+ * @return     string
+ */
+if ( ! function_exists('form_error'))
+{
+       function form_error($field = '', $prefix = '', $suffix = '')
+       {
+               if (FALSE === ($OBJ =& _get_validation_object()))
+               {
+                       return '';
+               }
+
+               return $OBJ->error($field, $prefix, $suffix);
+       }
+}
+
+// ------------------------------------------------------------------------
+
+/**
+ * Validation Error String
+ *
+ * Returns all the errors associated with a form submission.  This is a helper
+ * function for the form validation class.
+ *
+ * @access     public
+ * @param      string
+ * @param      string
+ * @return     string
+ */
+if ( ! function_exists('validation_errors'))
+{
+       function validation_errors($prefix = '', $suffix = '')
+       {
+               if (FALSE === ($OBJ =& _get_validation_object()))
+               {
+                       return '';
+               }
+
+               return $OBJ->error_string($prefix, $suffix);
+       }
+}
+
+// ------------------------------------------------------------------------
+
+/**
+ * Parse the form attributes
+ *
+ * Helper function used by some of the form helpers
+ *
+ * @access     private
+ * @param      array
+ * @param      array
+ * @return     string
+ */
+if ( ! function_exists('_parse_form_attributes'))
+{
+       function _parse_form_attributes($attributes, $default)
+       {
+               if (is_array($attributes))
+               {
+                       foreach ($default as $key => $val)
+                       {
+                               if (isset($attributes[$key]))
+                               {
+                                       $default[$key] = $attributes[$key];
+                                       unset($attributes[$key]);
+                               }
+                       }
+
+                       if (count($attributes) > 0)
+                       {
+                               $default = array_merge($default, $attributes);
+                       }
+               }
+
+               $att = '';
+
+               foreach ($default as $key => $val)
+               {
+                       if ($key == 'value')
+                       {
+                               $val = form_prep($val, $default['name']);
+                       }
+
+                       $att .= $key . '="' . $val . '" ';
+               }
+
+               return $att;
+       }
+}
+
+// ------------------------------------------------------------------------
+
+/**
+ * Attributes To String
+ *
+ * Helper function used by some of the form helpers
+ *
+ * @access     private
+ * @param      mixed
+ * @param      bool
+ * @return     string
+ */
+if ( ! function_exists('_attributes_to_string'))
+{
+       function _attributes_to_string($attributes, $formtag = FALSE)
+       {
+               if (is_string($attributes) AND strlen($attributes) > 0)
+               {
+                       if ($formtag == TRUE AND strpos($attributes, 'method=') === FALSE)
+                       {
+                               $attributes .= ' method="post"';
+                       }
+
+                       if ($formtag == TRUE AND strpos($attributes, 'accept-charset=') === FALSE)
+                       {
+                               $attributes .= ' accept-charset="'.strtolower(config_item('charset')).'"';
+                       }
+
+               return ' '.$attributes;
+               }
+
+               if (is_object($attributes) AND count($attributes) > 0)
+               {
+                       $attributes = (array)$attributes;
+               }
+
+               if (is_array($attributes) AND count($attributes) > 0)
+               {
+                       $atts = '';
+
+                       if ( ! isset($attributes['method']) AND $formtag === TRUE)
+                       {
+                               $atts .= ' method="post"';
+                       }
+
+                       if ( ! isset($attributes['accept-charset']) AND $formtag === TRUE)
+                       {
+                               $atts .= ' accept-charset="'.strtolower(config_item('charset')).'"';
+                       }
+
+                       foreach ($attributes as $key => $val)
+                       {
+                               $atts .= ' '.$key.'="'.$val.'"';
+                       }
+
+                       return $atts;
+               }
+       }
+}
+
+// ------------------------------------------------------------------------
+
+/**
+ * Validation Object
+ *
+ * Determines what the form validation class was instantiated as, fetches
+ * the object and returns it.
+ *
+ * @access     private
+ * @return     mixed
+ */
+if ( ! function_exists('_get_validation_object'))
+{
+       function &_get_validation_object()
+       {
+               $CI =& get_instance();
+
+               // 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']))
+               {
+                       return $return;
+               }
+
+               $object = $CI->load->_ci_classes['form_validation'];
+
+               if ( ! isset($CI->$object) OR ! is_object($CI->$object))
+               {
+                       return $return;
+               }
+
+               return $CI->$object;
+       }
+}
+
+
+/* End of file form_helper.php */
+/* Location: ./system/helpers/form_helper.php */
\ No newline at end of file
diff --git a/system/helpers/html_helper.php b/system/helpers/html_helper.php
new file mode 100755 (executable)
index 0000000..c6103ab
--- /dev/null
@@ -0,0 +1,431 @@
+<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+/**
+ * CodeIgniter
+ *
+ * An open source application development framework for PHP 5.1.6 or newer
+ *
+ * @package            CodeIgniter
+ * @author             ExpressionEngine Dev Team
+ * @copyright  Copyright (c) 2008 - 2011, EllisLab, Inc.
+ * @license            http://codeigniter.com/user_guide/license.html
+ * @link               http://codeigniter.com
+ * @since              Version 1.0
+ * @filesource
+ */
+
+// ------------------------------------------------------------------------
+
+/**
+ * CodeIgniter HTML Helpers
+ *
+ * @package            CodeIgniter
+ * @subpackage Helpers
+ * @category   Helpers
+ * @author             ExpressionEngine Dev Team
+ * @link               http://codeigniter.com/user_guide/helpers/html_helper.html
+ */
+
+// ------------------------------------------------------------------------
+
+/**
+ * Heading
+ *
+ * Generates an HTML heading tag.  First param is the data.
+ * Second param is the size of the heading tag.
+ *
+ * @access     public
+ * @param      string
+ * @param      integer
+ * @return     string
+ */
+if ( ! function_exists('heading'))
+{
+       function heading($data = '', $h = '1')
+       {
+               return "<h".$h.">".$data."</h".$h.">";
+       }
+}
+
+// ------------------------------------------------------------------------
+
+/**
+ * Unordered List
+ *
+ * Generates an HTML unordered list from an single or multi-dimensional array.
+ *
+ * @access     public
+ * @param      array
+ * @param      mixed
+ * @return     string
+ */
+if ( ! function_exists('ul'))
+{
+       function ul($list, $attributes = '')
+       {
+               return _list('ul', $list, $attributes);
+       }
+}
+
+// ------------------------------------------------------------------------
+
+/**
+ * Ordered List
+ *
+ * Generates an HTML ordered list from an single or multi-dimensional array.
+ *
+ * @access     public
+ * @param      array
+ * @param      mixed
+ * @return     string
+ */
+if ( ! function_exists('ol'))
+{
+       function ol($list, $attributes = '')
+       {
+               return _list('ol', $list, $attributes);
+       }
+}
+
+// ------------------------------------------------------------------------
+
+/**
+ * Generates the list
+ *
+ * Generates an HTML ordered list from an single or multi-dimensional array.
+ *
+ * @access     private
+ * @param      string
+ * @param      mixed
+ * @param      mixed
+ * @param      integer
+ * @return     string
+ */
+if ( ! function_exists('_list'))
+{
+       function _list($type = 'ul', $list, $attributes = '', $depth = 0)
+       {
+               // If an array wasn't submitted there's nothing to do...
+               if ( ! is_array($list))
+               {
+                       return $list;
+               }
+
+               // Set the indentation based on the depth
+               $out = str_repeat(" ", $depth);
+
+               // Were any attributes submitted?  If so generate a string
+               if (is_array($attributes))
+               {
+                       $atts = '';
+                       foreach ($attributes as $key => $val)
+                       {
+                               $atts .= ' ' . $key . '="' . $val . '"';
+                       }
+                       $attributes = $atts;
+               }
+
+               // Write the opening list tag
+               $out .= "<".$type.$attributes.">\n";
+
+               // Cycle through the list elements.  If an array is
+               // encountered we will recursively call _list()
+
+               static $_last_list_item = '';
+               foreach ($list as $key => $val)
+               {
+                       $_last_list_item = $key;
+
+                       $out .= str_repeat(" ", $depth + 2);
+                       $out .= "<li>";
+
+                       if ( ! is_array($val))
+                       {
+                               $out .= $val;
+                       }
+                       else
+                       {
+                               $out .= $_last_list_item."\n";
+                               $out .= _list($type, $val, '', $depth + 4);
+                               $out .= str_repeat(" ", $depth + 2);
+                       }
+
+                       $out .= "</li>\n";
+               }
+
+               // Set the indentation for the closing tag
+               $out .= str_repeat(" ", $depth);
+
+               // Write the closing list tag
+               $out .= "</".$type.">\n";
+
+               return $out;
+       }
+}
+
+// ------------------------------------------------------------------------
+
+/**
+ * Generates HTML BR tags based on number supplied
+ *
+ * @access     public
+ * @param      integer
+ * @return     string
+ */
+if ( ! function_exists('br'))
+{
+       function br($num = 1)
+       {
+               return str_repeat("<br />", $num);
+       }
+}
+
+// ------------------------------------------------------------------------
+
+/**
+ * Image
+ *
+ * Generates an <img /> element
+ *
+ * @access     public
+ * @param      mixed
+ * @return     string
+ */
+if ( ! function_exists('img'))
+{
+       function img($src = '', $index_page = FALSE)
+       {
+               if ( ! is_array($src) )
+               {
+                       $src = array('src' => $src);
+               }
+
+               // If there is no alt attribute defined, set it to an empty string
+               if ( ! isset($src['alt']))
+               {
+                       $src['alt'] = '';
+               }
+
+               $img = '<img';
+
+               foreach ($src as $k=>$v)
+               {
+
+                       if ($k == 'src' AND strpos($v, '://') === FALSE)
+                       {
+                               $CI =& get_instance();
+
+                               if ($index_page === TRUE)
+                               {
+                                       $img .= ' src="'.$CI->config->site_url($v).'"';
+                               }
+                               else
+                               {
+                                       $img .= ' src="'.$CI->config->slash_item('base_url').$v.'"';
+                               }
+                       }
+                       else
+                       {
+                               $img .= " $k=\"$v\"";
+                       }
+               }
+
+               $img .= '/>';
+
+               return $img;
+       }
+}
+
+// ------------------------------------------------------------------------
+
+/**
+ * Doctype
+ *
+ * Generates a page document type declaration
+ *
+ * Valid options are xhtml-11, xhtml-strict, xhtml-trans, xhtml-frame,
+ * html4-strict, html4-trans, and html4-frame.  Values are saved in the
+ * doctypes config file.
+ *
+ * @access     public
+ * @param      string  type    The doctype to be generated
+ * @return     string
+ */
+if ( ! function_exists('doctype'))
+{
+       function doctype($type = 'xhtml1-strict')
+       {
+               global $_doctypes;
+
+               if ( ! is_array($_doctypes))
+               {
+                       if (defined('ENVIRONMENT') AND is_file(APPPATH.'config/'.ENVIRONMENT.'/doctypes'.EXT))
+                       {
+                               include(APPPATH.'config/'.ENVIRONMENT.'/doctypes'.EXT);
+                       }
+                       elseif (is_file(APPPATH.'config/doctypes'.EXT))
+                       {
+                               include(APPPATH.'config/doctypes'.EXT);
+                       }
+
+                       if ( ! is_array($_doctypes))
+                       {
+                               return FALSE;
+                       }
+               }
+
+               if (isset($_doctypes[$type]))
+               {
+                       return $_doctypes[$type];
+               }
+               else
+               {
+                       return FALSE;
+               }
+       }
+}
+
+// ------------------------------------------------------------------------
+
+/**
+ * Link
+ *
+ * Generates link to a CSS file
+ *
+ * @access     public
+ * @param      mixed   stylesheet hrefs or an array
+ * @param      string  rel
+ * @param      string  type
+ * @param      string  title
+ * @param      string  media
+ * @param      boolean should index_page be added to the css path
+ * @return     string
+ */
+if ( ! function_exists('link_tag'))
+{
+       function link_tag($href = '', $rel = 'stylesheet', $type = 'text/css', $title = '', $media = '', $index_page = FALSE)
+       {
+               $CI =& get_instance();
+
+               $link = '<link ';
+
+               if (is_array($href))
+               {
+                       foreach ($href as $k=>$v)
+                       {
+                               if ($k == 'href' AND strpos($v, '://') === FALSE)
+                               {
+                                       if ($index_page === TRUE)
+                                       {
+                                               $link .= 'href="'.$CI->config->site_url($v).'" ';
+                                       }
+                                       else
+                                       {
+                                               $link .= 'href="'.$CI->config->slash_item('base_url').$v.'" ';
+                                       }
+                               }
+                               else
+                               {
+                                       $link .= "$k=\"$v\" ";
+                               }
+                       }
+
+                       $link .= "/>";
+               }
+               else
+               {
+                       if ( strpos($href, '://') !== FALSE)
+                       {
+                               $link .= 'href="'.$href.'" ';
+                       }
+                       elseif ($index_page === TRUE)
+                       {
+                               $link .= 'href="'.$CI->config->site_url($href).'" ';
+                       }
+                       else
+                       {
+                               $link .= 'href="'.$CI->config->slash_item('base_url').$href.'" ';
+                       }
+
+                       $link .= 'rel="'.$rel.'" type="'.$type.'" ';
+
+                       if ($media      != '')
+                       {
+                               $link .= 'media="'.$media.'" ';
+                       }
+
+                       if ($title      != '')
+                       {
+                               $link .= 'title="'.$title.'" ';
+                       }
+
+                       $link .= '/>';
+               }
+
+
+               return $link;
+       }
+}
+
+// ------------------------------------------------------------------------
+
+/**
+ * Generates meta tags from an array of key/values
+ *
+ * @access     public
+ * @param      array
+ * @return     string
+ */
+if ( ! function_exists('meta'))
+{
+       function meta($name = '', $content = '', $type = 'name', $newline = "\n")
+       {
+               // Since we allow the data to be passes as a string, a simple array
+               // or a multidimensional one, we need to do a little prepping.
+               if ( ! is_array($name))
+               {
+                       $name = array(array('name' => $name, 'content' => $content, 'type' => $type, 'newline' => $newline));
+               }
+               else
+               {
+                       // Turn single array into multidimensional
+                       if (isset($name['name']))
+                       {
+                               $name = array($name);
+                       }
+               }
+
+               $str = '';
+               foreach ($name as $meta)
+               {
+                       $type           = ( ! isset($meta['type']) OR $meta['type'] == 'name') ? 'name' : 'http-equiv';
+                       $name           = ( ! isset($meta['name']))             ? ''    : $meta['name'];
+                       $content        = ( ! isset($meta['content']))  ? ''    : $meta['content'];
+                       $newline        = ( ! isset($meta['newline']))  ? "\n"  : $meta['newline'];
+
+                       $str .= '<meta '.$type.'="'.$name.'" content="'.$content.'" />'.$newline;
+               }
+
+               return $str;
+       }
+}
+
+// ------------------------------------------------------------------------
+
+/**
+ * Generates non-breaking space entities based on number supplied
+ *
+ * @access     public
+ * @param      integer
+ * @return     string
+ */
+if ( ! function_exists('nbs'))
+{
+       function nbs($num = 1)
+       {
+               return str_repeat("&nbsp;", $num);
+       }
+}
+
+
+/* End of file html_helper.php */
+/* Location: ./system/helpers/html_helper.php */
\ No newline at end of file
diff --git a/system/helpers/index.html b/system/helpers/index.html
new file mode 100755 (executable)
index 0000000..c942a79
--- /dev/null
@@ -0,0 +1,10 @@
+<html>
+<head>
+       <title>403 Forbidden</title>
+</head>
+<body>
+
+<p>Directory access is forbidden.</p>
+
+</body>
+</html>
\ No newline at end of file
diff --git a/system/helpers/inflector_helper.php b/system/helpers/inflector_helper.php
new file mode 100755 (executable)
index 0000000..c7c113b
--- /dev/null
@@ -0,0 +1,184 @@
+<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+/**
+ * CodeIgniter
+ *
+ * An open source application development framework for PHP 5.1.6 or newer
+ *
+ * @package            CodeIgniter
+ * @author             ExpressionEngine Dev Team
+ * @copyright  Copyright (c) 2008 - 2011, EllisLab, Inc.
+ * @license            http://codeigniter.com/user_guide/license.html
+ * @link               http://codeigniter.com
+ * @since              Version 1.0
+ * @filesource
+ */
+
+// ------------------------------------------------------------------------
+
+/**
+ * CodeIgniter Inflector Helpers
+ *
+ * @package            CodeIgniter
+ * @subpackage Helpers
+ * @category   Helpers
+ * @author             ExpressionEngine Dev Team
+ * @link               http://codeigniter.com/user_guide/helpers/directory_helper.html
+ */
+
+
+// --------------------------------------------------------------------
+
+/**
+ * Singular
+ *
+ * Takes a plural word and makes it singular
+ *
+ * @access     public
+ * @param      string
+ * @return     str
+ */
+if ( ! function_exists('singular'))
+{
+       function singular($str)
+       {
+               $str = trim($str);
+               $end = substr($str, -3);
+        
+        $str = preg_replace('/(.*)?([s|c]h)es/i','$1$2',$str);
+        
+               if (strtolower($end) == 'ies')
+               {
+                       $str = substr($str, 0, strlen($str)-3).(preg_match('/[a-z]/',$end) ? 'y' : 'Y');
+               }
+               elseif (strtolower($end) == 'ses')
+               {
+                       $str = substr($str, 0, strlen($str)-2);
+               }
+               else
+               {
+                       $end = strtolower(substr($str, -1));
+
+                       if ($end == 's')
+                       {
+                               $str = substr($str, 0, strlen($str)-1);
+                       }
+               }
+
+               return $str;
+       }
+}
+
+// --------------------------------------------------------------------
+
+/**
+ * Plural
+ *
+ * Takes a singular word and makes it plural
+ *
+ * @access     public
+ * @param      string
+ * @param      bool
+ * @return     str
+ */
+if ( ! function_exists('plural'))
+{
+       function plural($str, $force = FALSE)
+       {   
+        $str = trim($str);
+               $end = substr($str, -1);
+
+               if (preg_match('/y/i',$end))
+               {
+                       // Y preceded by vowel => regular plural
+                       $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 (preg_match('/h/i',$end))
+               {
+            if(preg_match('/^[c|s]h$/i',substr($str, -2)))
+                       {
+                               $str .= 'es';
+                       }
+                       else
+                       {
+                               $str .= 's';
+                       }
+               }
+               elseif (preg_match('/s/i',$end))
+               {
+                       if ($force == TRUE)
+                       {
+                               $str .= 'es';
+                       }
+               }
+               else
+               {
+                       $str .= 's';
+               }
+
+               return $str;
+       }
+}
+
+// --------------------------------------------------------------------
+
+/**
+ * Camelize
+ *
+ * Takes multiple words separated by spaces or underscores and camelizes them
+ *
+ * @access     public
+ * @param      string
+ * @return     str
+ */
+if ( ! function_exists('camelize'))
+{
+       function camelize($str)
+       {
+               $str = 'x'.strtolower(trim($str));
+               $str = ucwords(preg_replace('/[\s_]+/', ' ', $str));
+               return substr(str_replace(' ', '', $str), 1);
+       }
+}
+
+// --------------------------------------------------------------------
+
+/**
+ * Underscore
+ *
+ * Takes multiple words separated by spaces and underscores them
+ *
+ * @access     public
+ * @param      string
+ * @return     str
+ */
+if ( ! function_exists('underscore'))
+{
+       function underscore($str)
+       {
+               return preg_replace('/[\s]+/', '_', strtolower(trim($str)));
+       }
+}
+
+// --------------------------------------------------------------------
+
+/**
+ * Humanize
+ *
+ * Takes multiple words separated by underscores and changes them to spaces
+ *
+ * @access     public
+ * @param      string
+ * @return     str
+ */
+if ( ! function_exists('humanize'))
+{
+       function humanize($str)
+       {
+               return ucwords(preg_replace('/[_]+/', ' ', strtolower(trim($str))));
+       }
+}
+
+
+/* End of file inflector_helper.php */
+/* Location: ./system/helpers/inflector_helper.php */
\ No newline at end of file
diff --git a/system/helpers/language_helper.php b/system/helpers/language_helper.php
new file mode 100755 (executable)
index 0000000..ac0d69d
--- /dev/null
@@ -0,0 +1,58 @@
+<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+/**
+ * CodeIgniter
+ *
+ * An open source application development framework for PHP 5.1.6 or newer
+ *
+ * @package            CodeIgniter
+ * @author             ExpressionEngine Dev Team
+ * @copyright  Copyright (c) 2008 - 2011, EllisLab, Inc.
+ * @license            http://codeigniter.com/user_guide/license.html
+ * @link               http://codeigniter.com
+ * @since              Version 1.0
+ * @filesource
+ */
+
+// ------------------------------------------------------------------------
+
+/**
+ * CodeIgniter Language Helpers
+ *
+ * @package            CodeIgniter
+ * @subpackage Helpers
+ * @category   Helpers
+ * @author             ExpressionEngine Dev Team
+ * @link               http://codeigniter.com/user_guide/helpers/language_helper.html
+ */
+
+// ------------------------------------------------------------------------
+
+/**
+ * Lang
+ *
+ * Fetches a language variable and optionally outputs a form label
+ *
+ * @access     public
+ * @param      string  the language line
+ * @param      string  the id of the form element
+ * @return     string
+ */
+if ( ! function_exists('lang'))
+{
+       function lang($line, $id = '')
+       {
+               $CI =& get_instance();
+               $line = $CI->lang->line($line);
+
+               if ($id != '')
+               {
+                       $line = '<label for="'.$id.'">'.$line."</label>";
+               }
+
+               return $line;
+       }
+}
+
+// ------------------------------------------------------------------------
+/* End of file language_helper.php */
+/* Location: ./system/helpers/language_helper.php */
\ No newline at end of file
diff --git a/system/helpers/number_helper.php b/system/helpers/number_helper.php
new file mode 100755 (executable)
index 0000000..6117775
--- /dev/null
@@ -0,0 +1,76 @@
+<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+/**
+ * CodeIgniter
+ *
+ * An open source application development framework for PHP 5.1.6 or newer
+ *
+ * @package            CodeIgniter
+ * @author             ExpressionEngine Dev Team
+ * @copyright  Copyright (c) 2008 - 2011, EllisLab, Inc.
+ * @license            http://codeigniter.com/user_guide/license.html
+ * @link               http://codeigniter.com
+ * @since              Version 1.0
+ * @filesource
+ */
+
+// ------------------------------------------------------------------------
+
+/**
+ * CodeIgniter Number Helpers
+ *
+ * @package            CodeIgniter
+ * @subpackage Helpers
+ * @category   Helpers
+ * @author             ExpressionEngine Dev Team
+ * @link               http://codeigniter.com/user_guide/helpers/number_helper.html
+ */
+
+// ------------------------------------------------------------------------
+
+/**
+ * Formats a numbers as bytes, based on size, and adds the appropriate suffix
+ *
+ * @access     public
+ * @param      mixed   // will be cast as int
+ * @return     string
+ */
+if ( ! function_exists('byte_format'))
+{
+       function byte_format($num, $precision = 1)
+       {
+               $CI =& get_instance();
+               $CI->lang->load('number');
+
+               if ($num >= 1000000000000)
+               {
+                       $num = round($num / 1099511627776, $precision);
+                       $unit = $CI->lang->line('terabyte_abbr');
+               }
+               elseif ($num >= 1000000000)
+               {
+                       $num = round($num / 1073741824, $precision);
+                       $unit = $CI->lang->line('gigabyte_abbr');
+               }
+               elseif ($num >= 1000000)
+               {
+                       $num = round($num / 1048576, $precision);
+                       $unit = $CI->lang->line('megabyte_abbr');
+               }
+               elseif ($num >= 1000)
+               {
+                       $num = round($num / 1024, $precision);
+                       $unit = $CI->lang->line('kilobyte_abbr');
+               }
+               else
+               {
+                       $unit = $CI->lang->line('bytes');
+                       return number_format($num).' '.$unit;
+               }
+
+               return number_format($num, $precision).' '.$unit;
+       }
+}
+
+
+/* End of file number_helper.php */
+/* Location: ./system/helpers/number_helper.php */
\ No newline at end of file
diff --git a/system/helpers/path_helper.php b/system/helpers/path_helper.php
new file mode 100755 (executable)
index 0000000..ffcf468
--- /dev/null
@@ -0,0 +1,72 @@
+<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+/**
+ * CodeIgniter
+ *
+ * An open source application development framework for PHP 5.1.6 or newer
+ *
+ * @package            CodeIgniter
+ * @author             ExpressionEngine Dev Team
+ * @copyright  Copyright (c) 2008 - 2011, EllisLab, Inc.
+ * @license            http://codeigniter.com/user_guide/license.html
+ * @link               http://codeigniter.com
+ * @since              Version 1.0
+ * @filesource
+ */
+
+// ------------------------------------------------------------------------
+
+/**
+ * CodeIgniter Path Helpers
+ *
+ * @package            CodeIgniter
+ * @subpackage Helpers
+ * @category   Helpers
+ * @author             ExpressionEngine Dev Team
+ * @link               http://codeigniter.com/user_guide/helpers/xml_helper.html
+ */
+
+// ------------------------------------------------------------------------
+
+/**
+ * Set Realpath
+ *
+ * @access     public
+ * @param      string
+ * @param      bool    checks to see if the path exists
+ * @return     string
+ */
+if ( ! function_exists('set_realpath'))
+{
+       function set_realpath($path, $check_existance = FALSE)
+       {
+               // Security check to make sure the path is NOT a URL.  No remote file inclusion!
+               if (preg_match("#^(http:\/\/|https:\/\/|www\.|ftp|[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3})#i", $path))
+               {
+                       show_error('The path you submitted must be a local server path, not a URL');
+               }
+
+               // Resolve the path
+               if (function_exists('realpath') AND @realpath($path) !== FALSE)
+               {
+                       $path = realpath($path).'/';
+               }
+
+               // Add a trailing slash
+               $path = preg_replace("#([^/])/*$#", "\\1/", $path);
+
+               // Make sure the path exists
+               if ($check_existance == TRUE)
+               {
+                       if ( ! is_dir($path))
+                       {
+                               show_error('Not a valid path: '.$path);
+                       }
+               }
+
+               return $path;
+       }
+}
+
+
+/* End of file path_helper.php */
+/* Location: ./system/helpers/path_helper.php */
\ No newline at end of file
diff --git a/system/helpers/security_helper.php b/system/helpers/security_helper.php
new file mode 100755 (executable)
index 0000000..678dac8
--- /dev/null
@@ -0,0 +1,128 @@
+<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+/**
+ * CodeIgniter
+ *
+ * An open source application development framework for PHP 5.1.6 or newer
+ *
+ * @package            CodeIgniter
+ * @author             ExpressionEngine Dev Team
+ * @copyright  Copyright (c) 2008 - 2011, EllisLab, Inc.
+ * @license            http://codeigniter.com/user_guide/license.html
+ * @link               http://codeigniter.com
+ * @since              Version 1.0
+ * @filesource
+ */
+
+// ------------------------------------------------------------------------
+
+/**
+ * CodeIgniter Security Helpers
+ *
+ * @package            CodeIgniter
+ * @subpackage Helpers
+ * @category   Helpers
+ * @author             ExpressionEngine Dev Team
+ * @link               http://codeigniter.com/user_guide/helpers/security_helper.html
+ */
+
+// ------------------------------------------------------------------------
+
+/**
+ * XSS Filtering
+ *
+ * @access     public
+ * @param      string
+ * @param      bool    whether or not the content is an image file
+ * @return     string
+ */
+if ( ! function_exists('xss_clean'))
+{
+       function xss_clean($str, $is_image = FALSE)
+       {
+               $CI =& get_instance();
+               return $CI->security->xss_clean($str, $is_image);
+       }
+}
+
+// ------------------------------------------------------------------------
+
+/**
+ * Sanitize Filename
+ *
+ * @access     public
+ * @param      string
+ * @return     string
+ */
+if ( ! function_exists('sanitize_filename'))
+{
+       function sanitize_filename($filename)
+       {
+               $CI =& get_instance();
+               return $CI->security->sanitize_filename($filename);
+       }
+}
+
+// --------------------------------------------------------------------
+
+/**
+ * Hash encode a string
+ *
+ * @access     public
+ * @param      string
+ * @return     string
+ */
+if ( ! function_exists('do_hash'))
+{
+       function do_hash($str, $type = 'sha1')
+       {
+               if ($type == 'sha1')
+               {
+                       return sha1($str);
+               }
+               else
+               {
+                       return md5($str);
+               }
+       }
+}
+
+// ------------------------------------------------------------------------
+
+/**
+ * Strip Image Tags
+ *
+ * @access     public
+ * @param      string
+ * @return     string
+ */
+if ( ! function_exists('strip_image_tags'))
+{
+       function strip_image_tags($str)
+       {
+               $str = preg_replace("#<img\s+.*?src\s*=\s*[\"'](.+?)[\"'].*?\>#", "\\1", $str);
+               $str = preg_replace("#<img\s+.*?src\s*=\s*(.+?).*?\>#", "\\1", $str);
+
+               return $str;
+       }
+}
+
+// ------------------------------------------------------------------------
+
+/**
+ * Convert PHP tags to entities
+ *
+ * @access     public
+ * @param      string
+ * @return     string
+ */
+if ( ! function_exists('encode_php_tags'))
+{
+       function encode_php_tags($str)
+       {
+               return str_replace(array('<?php', '<?PHP', '<?', '?>'),  array('&lt;?php', '&lt;?PHP', '&lt;?', '?&gt;'), $str);
+       }
+}
+
+
+/* End of file security_helper.php */
+/* Location: ./system/helpers/security_helper.php */
\ No newline at end of file
diff --git a/system/helpers/smiley_helper.php b/system/helpers/smiley_helper.php
new file mode 100755 (executable)
index 0000000..a2d1031
--- /dev/null
@@ -0,0 +1,281 @@
+<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+/**
+ * CodeIgniter
+ *
+ * An open source application development framework for PHP 5.1.6 or newer
+ *
+ * @package            CodeIgniter
+ * @author             ExpressionEngine Dev Team
+ * @copyright  Copyright (c) 2008 - 2011, EllisLab, Inc.
+ * @license            http://codeigniter.com/user_guide/license.html
+ * @link               http://codeigniter.com
+ * @since              Version 1.0
+ * @filesource
+ */
+
+// ------------------------------------------------------------------------
+
+/**
+ * CodeIgniter Smiley Helpers
+ *
+ * @package            CodeIgniter
+ * @subpackage Helpers
+ * @category   Helpers
+ * @author             ExpressionEngine Dev Team
+ * @link               http://codeigniter.com/user_guide/helpers/smiley_helper.html
+ */
+
+// ------------------------------------------------------------------------
+
+/**
+ * Smiley Javascript
+ *
+ * Returns the javascript required for the smiley insertion.  Optionally takes
+ * an array of aliases to loosely couple the smiley array to the view.
+ *
+ * @access     public
+ * @param      mixed   alias name or array of alias->field_id pairs
+ * @param      string  field_id if alias name was passed in
+ * @return     array
+ */
+if ( ! function_exists('smiley_js'))
+{
+       function smiley_js($alias = '', $field_id = '', $inline = TRUE)
+       {
+               static $do_setup = TRUE;
+
+               $r = '';
+
+               if ($alias != '' && ! is_array($alias))
+               {
+                       $alias = array($alias => $field_id);
+               }
+
+               if ($do_setup === TRUE)
+               {
+                               $do_setup = FALSE;
+
+                               $m = array();
+
+                               if (is_array($alias))
+                               {
+                                       foreach ($alias as $name => $id)
+                                       {
+                                               $m[] = '"'.$name.'" : "'.$id.'"';
+                                       }
+                               }
+
+                               $m = '{'.implode(',', $m).'}';
+
+                               $r .= <<<EOF
+                               var smiley_map = {$m};
+
+                               function insert_smiley(smiley, field_id) {
+                                       var el = document.getElementById(field_id), newStart;
+
+                                       if ( ! el && smiley_map[field_id]) {
+                                               el = document.getElementById(smiley_map[field_id]);
+
+                                               if ( ! el)
+                                                       return false;
+                                       }
+
+                                       el.focus();
+                                       smiley = " " + smiley;
+
+                                       if ('selectionStart' in el) {
+                                               newStart = el.selectionStart + smiley.length;
+
+                                               el.value = el.value.substr(0, el.selectionStart) +
+                                                                               smiley +
+                                                                               el.value.substr(el.selectionEnd, el.value.length);
+                                               el.setSelectionRange(newStart, newStart);
+                                       }
+                                       else if (document.selection) {
+                                               document.selection.createRange().text = smiley;
+                                       }
+                               }
+EOF;
+               }
+               else
+               {
+                       if (is_array($alias))
+                       {
+                               foreach ($alias as $name => $id)
+                               {
+                                       $r .= 'smiley_map["'.$name.'"] = "'.$id.'";'."\n";
+                               }
+                       }
+               }
+
+               if ($inline)
+               {
+                       return '<script type="text/javascript" charset="utf-8">/*<![CDATA[ */'.$r.'// ]]></script>';
+               }
+               else
+               {
+                       return $r;
+               }
+       }
+}
+
+// ------------------------------------------------------------------------
+
+/**
+ * Get Clickable Smileys
+ *
+ * Returns an array of image tag links that can be clicked to be inserted
+ * into a form field.
+ *
+ * @access     public
+ * @param      string  the URL to the folder containing the smiley images
+ * @return     array
+ */
+if ( ! function_exists('get_clickable_smileys'))
+{
+       function get_clickable_smileys($image_url, $alias = '', $smileys = NULL)
+       {
+               // For backward compatibility with js_insert_smiley
+
+               if (is_array($alias))
+               {
+                       $smileys = $alias;
+               }
+
+               if ( ! is_array($smileys))
+               {
+                       if (FALSE === ($smileys = _get_smiley_array()))
+                       {
+                               return $smileys;
+                       }
+               }
+
+               // Add a trailing slash to the file path if needed
+               $image_url = rtrim($image_url, '/').'/';
+
+               $used = array();
+               foreach ($smileys as $key => $val)
+               {
+                       // Keep duplicates from being used, which can happen if the
+                       // mapping array contains multiple identical replacements.  For example:
+                       // :-) and :) might be replaced with the same image so both smileys
+                       // will be in the array.
+                       if (isset($used[$smileys[$key][0]]))
+                       {
+                               continue;
+                       }
+
+                       $link[] = "<a href=\"javascript:void(0);\" onclick=\"insert_smiley('".$key."', '".$alias."')\"><img src=\"".$image_url.$smileys[$key][0]."\" width=\"".$smileys[$key][1]."\" height=\"".$smileys[$key][2]."\" alt=\"".$smileys[$key][3]."\" style=\"border:0;\" /></a>";
+
+                       $used[$smileys[$key][0]] = TRUE;
+               }
+
+               return $link;
+       }
+}
+
+// ------------------------------------------------------------------------
+
+/**
+ * Parse Smileys
+ *
+ * Takes a string as input and swaps any contained smileys for the actual image
+ *
+ * @access     public
+ * @param      string  the text to be parsed
+ * @param      string  the URL to the folder containing the smiley images
+ * @return     string
+ */
+if ( ! function_exists('parse_smileys'))
+{
+       function parse_smileys($str = '', $image_url = '', $smileys = NULL)
+       {
+               if ($image_url == '')
+               {
+                       return $str;
+               }
+
+               if ( ! is_array($smileys))
+               {
+                       if (FALSE === ($smileys = _get_smiley_array()))
+                       {
+                               return $str;
+                       }
+               }
+
+               // Add a trailing slash to the file path if needed
+               $image_url = preg_replace("/(.+?)\/*$/", "\\1/",  $image_url);
+
+               foreach ($smileys as $key => $val)
+               {
+                       $str = str_replace($key, "<img src=\"".$image_url.$smileys[$key][0]."\" width=\"".$smileys[$key][1]."\" height=\"".$smileys[$key][2]."\" alt=\"".$smileys[$key][3]."\" style=\"border:0;\" />", $str);
+               }
+
+               return $str;
+       }
+}
+
+// ------------------------------------------------------------------------
+
+/**
+ * Get Smiley Array
+ *
+ * Fetches the config/smiley.php file
+ *
+ * @access     private
+ * @return     mixed
+ */
+if ( ! function_exists('_get_smiley_array'))
+{
+       function _get_smiley_array()
+       {
+               if (defined('ENVIRONMENT') AND file_exists(APPPATH.'config/'.ENVIRONMENT.'/smileys'.EXT))
+               {
+                   include(APPPATH.'config/'.ENVIRONMENT.'/smileys'.EXT);
+               }
+               elseif (file_exists(APPPATH.'config/smileys'.EXT))
+               {
+                       include(APPPATH.'config/smileys'.EXT);
+               }
+               
+               if (isset($smileys) AND is_array($smileys))
+               {
+                       return $smileys;
+               }
+
+               return FALSE;
+       }
+}
+
+// ------------------------------------------------------------------------
+
+/**
+ * JS Insert Smiley
+ *
+ * Generates the javascript function needed to insert smileys into a form field
+ *
+ * DEPRECATED as of version 1.7.2, use smiley_js instead
+ *
+ * @access     public
+ * @param      string  form name
+ * @param      string  field name
+ * @return     string
+ */
+if ( ! function_exists('js_insert_smiley'))
+{
+       function js_insert_smiley($form_name = '', $form_field = '')
+       {
+               return <<<EOF
+<script type="text/javascript">
+       function insert_smiley(smiley)
+       {
+               document.{$form_name}.{$form_field}.value += " " + smiley;
+       }
+</script>
+EOF;
+       }
+}
+
+
+/* End of file smiley_helper.php */
+/* Location: ./system/helpers/smiley_helper.php */
\ No newline at end of file
diff --git a/system/helpers/string_helper.php b/system/helpers/string_helper.php
new file mode 100755 (executable)
index 0000000..7765bba
--- /dev/null
@@ -0,0 +1,290 @@
+<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+/**
+ * CodeIgniter
+ *
+ * An open source application development framework for PHP 5.1.6 or newer
+ *
+ * @package            CodeIgniter
+ * @author             ExpressionEngine Dev Team
+ * @copyright  Copyright (c) 2008 - 2011, EllisLab, Inc.
+ * @license            http://codeigniter.com/user_guide/license.html
+ * @link               http://codeigniter.com
+ * @since              Version 1.0
+ * @filesource
+ */
+
+// ------------------------------------------------------------------------
+
+/**
+ * CodeIgniter String Helpers
+ *
+ * @package            CodeIgniter
+ * @subpackage Helpers
+ * @category   Helpers
+ * @author             ExpressionEngine Dev Team
+ * @link               http://codeigniter.com/user_guide/helpers/string_helper.html
+ */
+
+// ------------------------------------------------------------------------
+
+/**
+ * Trim Slashes
+ *
+ * Removes any leading/trailing slashes from a string:
+ *
+ * /this/that/theother/
+ *
+ * becomes:
+ *
+ * this/that/theother
+ *
+ * @access     public
+ * @param      string
+ * @return     string
+ */
+if ( ! function_exists('trim_slashes'))
+{
+       function trim_slashes($str)
+       {
+               return trim($str, '/');
+       }
+}
+
+// ------------------------------------------------------------------------
+
+/**
+ * Strip Slashes
+ *
+ * Removes slashes contained in a string or in an array
+ *
+ * @access     public
+ * @param      mixed   string or array
+ * @return     mixed   string or array
+ */
+if ( ! function_exists('strip_slashes'))
+{
+       function strip_slashes($str)
+       {
+               if (is_array($str))
+               {
+                       foreach ($str as $key => $val)
+                       {
+                               $str[$key] = strip_slashes($val);
+                       }
+               }
+               else
+               {
+                       $str = stripslashes($str);
+               }
+
+               return $str;
+       }
+}
+
+// ------------------------------------------------------------------------
+
+/**
+ * Strip Quotes
+ *
+ * Removes single and double quotes from a string
+ *
+ * @access     public
+ * @param      string
+ * @return     string
+ */
+if ( ! function_exists('strip_quotes'))
+{
+       function strip_quotes($str)
+       {
+               return str_replace(array('"', "'"), '', $str);
+       }
+}
+
+// ------------------------------------------------------------------------
+
+/**
+ * Quotes to Entities
+ *
+ * Converts single and double quotes to entities
+ *
+ * @access     public
+ * @param      string
+ * @return     string
+ */
+if ( ! function_exists('quotes_to_entities'))
+{
+       function quotes_to_entities($str)
+       {
+               return str_replace(array("\'","\"","'",'"'), array("&#39;","&quot;","&#39;","&quot;"), $str);
+       }
+}
+
+// ------------------------------------------------------------------------
+
+/**
+ * Reduce Double Slashes
+ *
+ * Converts double slashes in a string to a single slash,
+ * except those found in http://
+ *
+ * http://www.some-site.com//index.php
+ *
+ * becomes:
+ *
+ * http://www.some-site.com/index.php
+ *
+ * @access     public
+ * @param      string
+ * @return     string
+ */
+if ( ! function_exists('reduce_double_slashes'))
+{
+       function reduce_double_slashes($str)
+       {
+               return preg_replace("#(^|[^:])//+#", "\\1/", $str);
+       }
+}
+
+// ------------------------------------------------------------------------
+
+/**
+ * Reduce Multiples
+ *
+ * Reduces multiple instances of a particular character.  Example:
+ *
+ * Fred, Bill,, Joe, Jimmy
+ *
+ * becomes:
+ *
+ * Fred, Bill, Joe, Jimmy
+ *
+ * @access     public
+ * @param      string
+ * @param      string  the character you wish to reduce
+ * @param      bool    TRUE/FALSE - whether to trim the character from the beginning/end
+ * @return     string
+ */
+if ( ! function_exists('reduce_multiples'))
+{
+       function reduce_multiples($str, $character = ',', $trim = FALSE)
+       {
+               $str = preg_replace('#'.preg_quote($character, '#').'{2,}#', $character, $str);
+
+               if ($trim === TRUE)
+               {
+                       $str = trim($str, $character);
+               }
+
+               return $str;
+       }
+}
+
+// ------------------------------------------------------------------------
+
+/**
+ * Create a Random String
+ *
+ * Useful for generating passwords or hashes.
+ *
+ * @access     public
+ * @param      string  type of random string.  basic, alpha, alunum, numeric, nozero, unique, md5, encrypt and sha1
+ * @param      integer number of characters
+ * @return     string
+ */
+if ( ! function_exists('random_string'))
+{
+       function random_string($type = 'alnum', $len = 8)
+       {
+               switch($type)
+               {
+                       case 'basic'    : return mt_rand();
+                               break;
+                       case 'alnum'    :
+                       case 'numeric'  :
+                       case 'nozero'   :
+                       case 'alpha'    :
+
+                                       switch ($type)
+                                       {
+                                               case 'alpha'    :       $pool = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
+                                                       break;
+                                               case 'alnum'    :       $pool = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
+                                                       break;
+                                               case 'numeric'  :       $pool = '0123456789';
+                                                       break;
+                                               case 'nozero'   :       $pool = '123456789';
+                                                       break;
+                                       }
+
+                                       $str = '';
+                                       for ($i=0; $i < $len; $i++)
+                                       {
+                                               $str .= substr($pool, mt_rand(0, strlen($pool) -1), 1);
+                                       }
+                                       return $str;
+                               break;
+                       case 'unique'   :
+                       case 'md5'              :
+
+                                               return md5(uniqid(mt_rand()));
+                               break;
+                       case 'encrypt'  :
+                       case 'sha1'     :
+
+                                               $CI =& get_instance();
+                                               $CI->load->helper('security');
+
+                                               return do_hash(uniqid(mt_rand(), TRUE), 'sha1');
+                               break;
+               }
+       }
+}
+
+// ------------------------------------------------------------------------
+
+/**
+ * Alternator
+ *
+ * Allows strings to be alternated.  See docs...
+ *
+ * @access     public
+ * @param      string (as many parameters as needed)
+ * @return     string
+ */
+if ( ! function_exists('alternator'))
+{
+       function alternator()
+       {
+               static $i;
+
+               if (func_num_args() == 0)
+               {
+                       $i = 0;
+                       return '';
+               }
+               $args = func_get_args();
+               return $args[($i++ % count($args))];
+       }
+}
+
+// ------------------------------------------------------------------------
+
+/**
+ * Repeater function
+ *
+ * @access     public
+ * @param      string
+ * @param      integer number of repeats
+ * @return     string
+ */
+if ( ! function_exists('repeater'))
+{
+       function repeater($data, $num = 1)
+       {
+               return (($num > 0) ? str_repeat($data, $num) : '');
+       }
+}
+
+
+/* End of file string_helper.php */
+/* Location: ./system/helpers/string_helper.php */
\ No newline at end of file
diff --git a/system/helpers/text_helper.php b/system/helpers/text_helper.php
new file mode 100755 (executable)
index 0000000..cca0939
--- /dev/null
@@ -0,0 +1,535 @@
+<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+/**
+ * CodeIgniter
+ *
+ * An open source application development framework for PHP 5.1.6 or newer
+ *
+ * @package            CodeIgniter
+ * @author             ExpressionEngine Dev Team
+ * @copyright  Copyright (c) 2008 - 2011, EllisLab, Inc.
+ * @license            http://codeigniter.com/user_guide/license.html
+ * @link               http://codeigniter.com
+ * @since              Version 1.0
+ * @filesource
+ */
+
+// ------------------------------------------------------------------------
+
+/**
+ * CodeIgniter Text Helpers
+ *
+ * @package            CodeIgniter
+ * @subpackage Helpers
+ * @category   Helpers
+ * @author             ExpressionEngine Dev Team
+ * @link               http://codeigniter.com/user_guide/helpers/text_helper.html
+ */
+
+// ------------------------------------------------------------------------
+
+/**
+ * Word Limiter
+ *
+ * Limits a string to X number of words.
+ *
+ * @access     public
+ * @param      string
+ * @param      integer
+ * @param      string  the end character. Usually an ellipsis
+ * @return     string
+ */
+if ( ! function_exists('word_limiter'))
+{
+       function word_limiter($str, $limit = 100, $end_char = '&#8230;')
+       {
+               if (trim($str) == '')
+               {
+                       return $str;
+               }
+
+               preg_match('/^\s*+(?:\S++\s*+){1,'.(int) $limit.'}/', $str, $matches);
+
+               if (strlen($str) == strlen($matches[0]))
+               {
+                       $end_char = '';
+               }
+
+               return rtrim($matches[0]).$end_char;
+       }
+}
+
+// ------------------------------------------------------------------------
+
+/**
+ * Character Limiter
+ *
+ * Limits the string based on the character count.  Preserves complete words
+ * so the character count may not be exactly as specified.
+ *
+ * @access     public
+ * @param      string
+ * @param      integer
+ * @param      string  the end character. Usually an ellipsis
+ * @return     string
+ */
+if ( ! function_exists('character_limiter'))
+{
+       function character_limiter($str, $n = 500, $end_char = '&#8230;')
+       {
+               if (strlen($str) < $n)
+               {
+                       return $str;
+               }
+
+               $str = preg_replace("/\s+/", ' ', str_replace(array("\r\n", "\r", "\n"), ' ', $str));
+
+               if (strlen($str) <= $n)
+               {
+                       return $str;
+               }
+
+               $out = "";
+               foreach (explode(' ', trim($str)) as $val)
+               {
+                       $out .= $val.' ';
+
+                       if (strlen($out) >= $n)
+                       {
+                               $out = trim($out);
+                               return (strlen($out) == strlen($str)) ? $out : $out.$end_char;
+                       }
+               }
+       }
+}
+
+// ------------------------------------------------------------------------
+
+/**
+ * High ASCII to Entities
+ *
+ * Converts High ascii text and MS Word special characters to character entities
+ *
+ * @access     public
+ * @param      string
+ * @return     string
+ */
+if ( ! function_exists('ascii_to_entities'))
+{
+       function ascii_to_entities($str)
+       {
+               $count  = 1;
+               $out    = '';
+               $temp   = array();
+
+               for ($i = 0, $s = strlen($str); $i < $s; $i++)
+               {
+                       $ordinal = ord($str[$i]);
+
+                       if ($ordinal < 128)
+                       {
+                               /*
+                                       If the $temp array has a value but we have moved on, then it seems only
+                                       fair that we output that entity and restart $temp before continuing. -Paul
+                               */
+                               if (count($temp) == 1)
+                               {
+                                       $out  .= '&#'.array_shift($temp).';';
+                                       $count = 1;
+                               }
+
+                               $out .= $str[$i];
+                       }
+                       else
+                       {
+                               if (count($temp) == 0)
+                               {
+                                       $count = ($ordinal < 224) ? 2 : 3;
+                               }
+
+                               $temp[] = $ordinal;
+
+                               if (count($temp) == $count)
+                               {
+                                       $number = ($count == 3) ? (($temp['0'] % 16) * 4096) + (($temp['1'] % 64) * 64) + ($temp['2'] % 64) : (($temp['0'] % 32) * 64) + ($temp['1'] % 64);
+
+                                       $out .= '&#'.$number.';';
+                                       $count = 1;
+                                       $temp = array();
+                               }
+                       }
+               }
+
+               return $out;
+       }
+}
+
+// ------------------------------------------------------------------------
+
+/**
+ * Entities to ASCII
+ *
+ * Converts character entities back to ASCII
+ *
+ * @access     public
+ * @param      string
+ * @param      bool
+ * @return     string
+ */
+if ( ! function_exists('entities_to_ascii'))
+{
+       function entities_to_ascii($str, $all = TRUE)
+       {
+               if (preg_match_all('/\&#(\d+)\;/', $str, $matches))
+               {
+                       for ($i = 0, $s = count($matches['0']); $i < $s; $i++)
+                       {
+                               $digits = $matches['1'][$i];
+
+                               $out = '';
+
+                               if ($digits < 128)
+                               {
+                                       $out .= chr($digits);
+
+                               }
+                               elseif ($digits < 2048)
+                               {
+                                       $out .= chr(192 + (($digits - ($digits % 64)) / 64));
+                                       $out .= chr(128 + ($digits % 64));
+                               }
+                               else
+                               {
+                                       $out .= chr(224 + (($digits - ($digits % 4096)) / 4096));
+                                       $out .= chr(128 + ((($digits % 4096) - ($digits % 64)) / 64));
+                                       $out .= chr(128 + ($digits % 64));
+                               }
+
+                               $str = str_replace($matches['0'][$i], $out, $str);
+                       }
+               }
+
+               if ($all)
+               {
+                       $str = str_replace(array("&amp;", "&lt;", "&gt;", "&quot;", "&apos;", "&#45;"),
+                                                               array("&","<",">","\"", "'", "-"),
+                                                               $str);
+               }
+
+               return $str;
+       }
+}
+
+// ------------------------------------------------------------------------
+
+/**
+ * Word Censoring Function
+ *
+ * Supply a string and an array of disallowed words and any
+ * matched words will be converted to #### or to the replacement
+ * word you've submitted.
+ *
+ * @access     public
+ * @param      string  the text string
+ * @param      string  the array of censoered words
+ * @param      string  the optional replacement value
+ * @return     string
+ */
+if ( ! function_exists('word_censor'))
+{
+       function word_censor($str, $censored, $replacement = '')
+       {
+               if ( ! is_array($censored))
+               {
+                       return $str;
+               }
+
+               $str = ' '.$str.' ';
+
+               // \w, \b and a few others do not match on a unicode character
+               // set for performance reasons. As a result words like über
+               // will not match on a word boundary. Instead, we'll assume that
+               // a bad word will be bookeneded by any of these characters.
+               $delim = '[-_\'\"`(){}<>\[\]|!?@#%&,.:;^~*+=\/ 0-9\n\r\t]';
+
+               foreach ($censored as $badword)
+               {
+                       if ($replacement != '')
+                       {
+                               $str = preg_replace("/({$delim})(".str_replace('\*', '\w*?', preg_quote($badword, '/')).")({$delim})/i", "\\1{$replacement}\\3", $str);
+                       }
+                       else
+                       {
+                               $str = preg_replace("/({$delim})(".str_replace('\*', '\w*?', preg_quote($badword, '/')).")({$delim})/ie", "'\\1'.str_repeat('#', strlen('\\2')).'\\3'", $str);
+                       }
+               }
+
+               return trim($str);
+       }
+}
+
+// ------------------------------------------------------------------------
+
+/**
+ * Code Highlighter
+ *
+ * Colorizes code strings
+ *
+ * @access     public
+ * @param      string  the text string
+ * @return     string
+ */
+if ( ! function_exists('highlight_code'))
+{
+       function highlight_code($str)
+       {
+               // The highlight string function encodes and highlights
+               // brackets so we need them to start raw
+               $str = str_replace(array('&lt;', '&gt;'), array('<', '>'), $str);
+
+               // Replace any existing PHP tags to temporary markers so they don't accidentally
+               // break the string out of PHP, and thus, thwart the highlighting.
+
+               $str = str_replace(array('<?', '?>', '<%', '%>', '\\', '</script>'),
+                                                       array('phptagopen', 'phptagclose', 'asptagopen', 'asptagclose', 'backslashtmp', 'scriptclose'), $str);
+
+               // The highlight_string function requires that the text be surrounded
+               // by PHP tags, which we will remove later
+               $str = '<?php '.$str.' ?>'; // <?
+
+               // All the magic happens here, baby!
+               $str = highlight_string($str, TRUE);
+
+               // Prior to PHP 5, the highligh function used icky <font> tags
+               // so we'll replace them with <span> tags.
+
+               if (abs(PHP_VERSION) < 5)
+               {
+                       $str = str_replace(array('<font ', '</font>'), array('<span ', '</span>'), $str);
+                       $str = preg_replace('#color="(.*?)"#', 'style="color: \\1"', $str);
+               }
+
+               // Remove our artificially added PHP, and the syntax highlighting that came with it
+               $str = preg_replace('/<span style="color: #([A-Z0-9]+)">&lt;\?php(&nbsp;| )/i', '<span style="color: #$1">', $str);
+               $str = preg_replace('/(<span style="color: #[A-Z0-9]+">.*?)\?&gt;<\/span>\n<\/span>\n<\/code>/is', "$1</span>\n</span>\n</code>", $str);
+               $str = preg_replace('/<span style="color: #[A-Z0-9]+"\><\/span>/i', '', $str);
+
+               // Replace our markers back to PHP tags.
+               $str = str_replace(array('phptagopen', 'phptagclose', 'asptagopen', 'asptagclose', 'backslashtmp', 'scriptclose'),
+                                                       array('&lt;?', '?&gt;', '&lt;%', '%&gt;', '\\', '&lt;/script&gt;'), $str);
+
+               return $str;
+       }
+}
+
+// ------------------------------------------------------------------------
+
+/**
+ * Phrase Highlighter
+ *
+ * Highlights a phrase within a text string
+ *
+ * @access     public
+ * @param      string  the text string
+ * @param      string  the phrase you'd like to highlight
+ * @param      string  the openging tag to precede the phrase with
+ * @param      string  the closing tag to end the phrase with
+ * @return     string
+ */
+if ( ! function_exists('highlight_phrase'))
+{
+       function highlight_phrase($str, $phrase, $tag_open = '<strong>', $tag_close = '</strong>')
+       {
+               if ($str == '')
+               {
+                       return '';
+               }
+
+               if ($phrase != '')
+               {
+                       return preg_replace('/('.preg_quote($phrase, '/').')/i', $tag_open."\\1".$tag_close, $str);
+               }
+
+               return $str;
+       }
+}
+
+// ------------------------------------------------------------------------
+
+/**
+ * Convert Accented Foreign Characters to ASCII
+ *
+ * @access     public
+ * @param      string  the text string
+ * @return     string
+ */
+if ( ! function_exists('convert_accented_characters'))
+{
+       function convert_accented_characters($str)
+       {
+               if (defined('ENVIRONMENT') AND is_file(APPPATH.'config/'.ENVIRONMENT.'/foreign_chars'.EXT))
+               {
+                       include(APPPATH.'config/'.ENVIRONMENT.'/foreign_chars'.EXT);
+               }
+               elseif (is_file(APPPATH.'config/foreign_chars'.EXT))
+               {
+                       include(APPPATH.'config/foreign_chars'.EXT);
+               }
+
+               if ( ! isset($foreign_characters))
+               {
+                       return $str;
+               }
+
+               return preg_replace(array_keys($foreign_characters), array_values($foreign_characters), $str);
+       }
+}
+
+// ------------------------------------------------------------------------
+
+/**
+ * Word Wrap
+ *
+ * Wraps text at the specified character.  Maintains the integrity of words.
+ * Anything placed between {unwrap}{/unwrap} will not be word wrapped, nor
+ * will URLs.
+ *
+ * @access     public
+ * @param      string  the text string
+ * @param      integer the number of characters to wrap at
+ * @return     string
+ */
+if ( ! function_exists('word_wrap'))
+{
+       function word_wrap($str, $charlim = '76')
+       {
+               // Se the character limit
+               if ( ! is_numeric($charlim))
+                       $charlim = 76;
+
+               // Reduce multiple spaces
+               $str = preg_replace("| +|", " ", $str);
+
+               // Standardize newlines
+               if (strpos($str, "\r") !== FALSE)
+               {
+                       $str = str_replace(array("\r\n", "\r"), "\n", $str);
+               }
+
+               // If the current word is surrounded by {unwrap} tags we'll
+               // strip the entire chunk and replace it with a marker.
+               $unwrap = array();
+               if (preg_match_all("|(\{unwrap\}.+?\{/unwrap\})|s", $str, $matches))
+               {
+                       for ($i = 0; $i < count($matches['0']); $i++)
+                       {
+                               $unwrap[] = $matches['1'][$i];
+                               $str = str_replace($matches['1'][$i], "{{unwrapped".$i."}}", $str);
+                       }
+               }
+
+               // Use PHP's native function to do the initial wordwrap.
+               // We set the cut flag to FALSE so that any individual words that are
+               // too long get left alone.  In the next step we'll deal with them.
+               $str = wordwrap($str, $charlim, "\n", FALSE);
+
+               // Split the string into individual lines of text and cycle through them
+               $output = "";
+               foreach (explode("\n", $str) as $line)
+               {
+                       // Is the line within the allowed character count?
+                       // If so we'll join it to the output and continue
+                       if (strlen($line) <= $charlim)
+                       {
+                               $output .= $line."\n";
+                               continue;
+                       }
+
+                       $temp = '';
+                       while ((strlen($line)) > $charlim)
+                       {
+                               // If the over-length word is a URL we won't wrap it
+                               if (preg_match("!\[url.+\]|://|wwww.!", $line))
+                               {
+                                       break;
+                               }
+
+                               // Trim the word down
+                               $temp .= substr($line, 0, $charlim-1);
+                               $line = substr($line, $charlim-1);
+                       }
+
+                       // If $temp contains data it means we had to split up an over-length
+                       // word into smaller chunks so we'll add it back to our current line
+                       if ($temp != '')
+                       {
+                               $output .= $temp."\n".$line;
+                       }
+                       else
+                       {
+                               $output .= $line;
+                       }
+
+                       $output .= "\n";
+               }
+
+               // Put our markers back
+               if (count($unwrap) > 0)
+               {
+                       foreach ($unwrap as $key => $val)
+                       {
+                               $output = str_replace("{{unwrapped".$key."}}", $val, $output);
+                       }
+               }
+
+               // Remove the unwrap tags
+               $output = str_replace(array('{unwrap}', '{/unwrap}'), '', $output);
+
+               return $output;
+       }
+}
+
+// ------------------------------------------------------------------------
+
+/**
+ * Ellipsize String
+ *
+ * This function will strip tags from a string, split it at its max_length and ellipsize
+ *
+ * @param      string          string to ellipsize
+ * @param      integer         max length of string
+ * @param      mixed           int (1|0) or float, .5, .2, etc for position to split
+ * @param      string          ellipsis ; Default '...'
+ * @return     string          ellipsized string
+ */
+if ( ! function_exists('ellipsize'))
+{
+       function ellipsize($str, $max_length, $position = 1, $ellipsis = '&hellip;')
+       {
+               // Strip tags
+               $str = trim(strip_tags($str));
+
+               // Is the string long enough to ellipsize?
+               if (strlen($str) <= $max_length)
+               {
+                       return $str;
+               }
+
+               $beg = substr($str, 0, floor($max_length * $position));
+
+               $position = ($position > 1) ? 1 : $position;
+
+               if ($position === 1)
+               {
+                       $end = substr($str, 0, -($max_length - strlen($beg)));
+               }
+               else
+               {
+                       $end = substr($str, -($max_length - strlen($beg)));
+               }
+
+               return $beg.$ellipsis.$end;
+       }
+}
+
+/* End of file text_helper.php */
+/* Location: ./system/helpers/text_helper.php */
\ No newline at end of file
diff --git a/system/helpers/typography_helper.php b/system/helpers/typography_helper.php
new file mode 100755 (executable)
index 0000000..19b4eec
--- /dev/null
@@ -0,0 +1,93 @@
+<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+/**
+ * CodeIgniter
+ *
+ * An open source application development framework for PHP 5.1.6 or newer
+ *
+ * @package            CodeIgniter
+ * @author             ExpressionEngine Dev Team
+ * @copyright  Copyright (c) 2008 - 2011, EllisLab, Inc.
+ * @license            http://codeigniter.com/user_guide/license.html
+ * @link               http://codeigniter.com
+ * @since              Version 1.0
+ * @filesource
+ */
+
+// ------------------------------------------------------------------------
+
+/**
+ * CodeIgniter Typography Helpers
+ *
+ * @package            CodeIgniter
+ * @subpackage Helpers
+ * @category   Helpers
+ * @author             ExpressionEngine Dev Team
+ * @link               http://codeigniter.com/user_guide/helpers/typography_helper.html
+ */
+
+// ------------------------------------------------------------------------
+
+/**
+ * Convert newlines to HTML line breaks except within PRE tags
+ *
+ * @access     public
+ * @param      string
+ * @return     string
+ */
+if ( ! function_exists('nl2br_except_pre'))
+{
+       function nl2br_except_pre($str)
+       {
+               $CI =& get_instance();
+
+               $CI->load->library('typography');
+
+               return $CI->typography->nl2br_except_pre($str);
+       }
+}
+
+// ------------------------------------------------------------------------
+
+/**
+ * Auto Typography Wrapper Function
+ *
+ *
+ * @access     public
+ * @param      string
+ * @param      bool    whether to allow javascript event handlers
+ * @param      bool    whether to reduce multiple instances of double newlines to two
+ * @return     string
+ */
+if ( ! function_exists('auto_typography'))
+{
+       function auto_typography($str, $strip_js_event_handlers = TRUE, $reduce_linebreaks = FALSE)
+       {
+               $CI =& get_instance();
+               $CI->load->library('typography');
+               return $CI->typography->auto_typography($str, $strip_js_event_handlers, $reduce_linebreaks);
+       }
+}
+
+
+// --------------------------------------------------------------------
+
+/**
+ * HTML Entities Decode
+ *
+ * This function is a replacement for html_entity_decode()
+ *
+ * @access     public
+ * @param      string
+ * @return     string
+ */
+if ( ! function_exists('entity_decode'))
+{
+       function entity_decode($str, $charset='UTF-8')
+       {
+               global $SEC;
+               return $SEC->entity_decode($str, $charset);
+       }
+}
+
+/* End of file typography_helper.php */
+/* Location: ./system/helpers/typography_helper.php */
\ No newline at end of file
diff --git a/system/helpers/url_helper.php b/system/helpers/url_helper.php
new file mode 100755 (executable)
index 0000000..d0516ce
--- /dev/null
@@ -0,0 +1,595 @@
+<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+/**
+ * CodeIgniter
+ *
+ * An open source application development framework for PHP 5.1.6 or newer
+ *
+ * @package            CodeIgniter
+ * @author             ExpressionEngine Dev Team
+ * @copyright  Copyright (c) 2008 - 2011, EllisLab, Inc.
+ * @license            http://codeigniter.com/user_guide/license.html
+ * @link               http://codeigniter.com
+ * @since              Version 1.0
+ * @filesource
+ */
+
+// ------------------------------------------------------------------------
+
+/**
+ * CodeIgniter URL Helpers
+ *
+ * @package            CodeIgniter
+ * @subpackage Helpers
+ * @category   Helpers
+ * @author             ExpressionEngine Dev Team
+ * @link               http://codeigniter.com/user_guide/helpers/url_helper.html
+ */
+
+// ------------------------------------------------------------------------
+
+/**
+ * Site URL
+ *
+ * Create a local URL based on your basepath. Segments can be passed via the
+ * first parameter either as a string or an array.
+ *
+ * @access     public
+ * @param      string
+ * @return     string
+ */
+if ( ! function_exists('site_url'))
+{
+       function site_url($uri = '')
+       {
+               $CI =& get_instance();
+               return $CI->config->site_url($uri);
+       }
+}
+
+// ------------------------------------------------------------------------
+
+/**
+ * Base URL
+ *
+ * Returns the "base_url" item from your config file
+ *
+ * @access     public
+ * @return     string
+ */
+if ( ! function_exists('base_url'))
+{
+       function base_url()
+       {
+               $CI =& get_instance();
+               return $CI->config->slash_item('base_url');
+       }
+}
+
+// ------------------------------------------------------------------------
+
+/**
+ * Current URL
+ *
+ * Returns the full URL (including segments) of the page where this
+ * function is placed
+ *
+ * @access     public
+ * @return     string
+ */
+if ( ! function_exists('current_url'))
+{
+       function current_url()
+       {
+               $CI =& get_instance();
+               return $CI->config->site_url($CI->uri->uri_string());
+       }
+}
+
+// ------------------------------------------------------------------------
+/**
+ * URL String
+ *
+ * Returns the URI segments.
+ *
+ * @access     public
+ * @return     string
+ */
+if ( ! function_exists('uri_string'))
+{
+       function uri_string()
+       {
+               $CI =& get_instance();
+               return $CI->uri->uri_string();
+       }
+}
+
+// ------------------------------------------------------------------------
+
+/**
+ * Index page
+ *
+ * Returns the "index_page" from your config file
+ *
+ * @access     public
+ * @return     string
+ */
+if ( ! function_exists('index_page'))
+{
+       function index_page()
+       {
+               $CI =& get_instance();
+               return $CI->config->item('index_page');
+       }
+}
+
+// ------------------------------------------------------------------------
+
+/**
+ * Anchor Link
+ *
+ * Creates an anchor based on the local URL.
+ *
+ * @access     public
+ * @param      string  the URL
+ * @param      string  the link title
+ * @param      mixed   any attributes
+ * @return     string
+ */
+if ( ! function_exists('anchor'))
+{
+       function anchor($uri = '', $title = '', $attributes = '')
+       {
+               $title = (string) $title;
+
+               if ( ! is_array($uri))
+               {
+                       $site_url = ( ! preg_match('!^\w+://! i', $uri)) ? site_url($uri) : $uri;
+               }
+               else
+               {
+                       $site_url = site_url($uri);
+               }
+
+               if ($title == '')
+               {
+                       $title = $site_url;
+               }
+
+               if ($attributes != '')
+               {
+                       $attributes = _parse_attributes($attributes);
+               }
+
+               return '<a href="'.$site_url.'"'.$attributes.'>'.$title.'</a>';
+       }
+}
+
+// ------------------------------------------------------------------------
+
+/**
+ * Anchor Link - Pop-up version
+ *
+ * Creates an anchor based on the local URL. The link
+ * opens a new window based on the attributes specified.
+ *
+ * @access     public
+ * @param      string  the URL
+ * @param      string  the link title
+ * @param      mixed   any attributes
+ * @return     string
+ */
+if ( ! function_exists('anchor_popup'))
+{
+       function anchor_popup($uri = '', $title = '', $attributes = FALSE)
+       {
+               $title = (string) $title;
+
+               $site_url = ( ! preg_match('!^\w+://! i', $uri)) ? site_url($uri) : $uri;
+
+               if ($title == '')
+               {
+                       $title = $site_url;
+               }
+
+               if ($attributes === FALSE)
+               {
+                       return "<a href='javascript:void(0);' onclick=\"window.open('".$site_url."', '_blank');\">".$title."</a>";
+               }
+
+               if ( ! is_array($attributes))
+               {
+                       $attributes = array();
+               }
+
+               foreach (array('width' => '800', 'height' => '600', 'scrollbars' => 'yes', 'status' => 'yes', 'resizable' => 'yes', 'screenx' => '0', 'screeny' => '0', ) as $key => $val)
+               {
+                       $atts[$key] = ( ! isset($attributes[$key])) ? $val : $attributes[$key];
+                       unset($attributes[$key]);
+               }
+
+               if ($attributes != '')
+               {
+                       $attributes = _parse_attributes($attributes);
+               }
+
+               return "<a href='javascript:void(0);' onclick=\"window.open('".$site_url."', '_blank', '"._parse_attributes($atts, TRUE)."');\"$attributes>".$title."</a>";
+       }
+}
+
+// ------------------------------------------------------------------------
+
+/**
+ * Mailto Link
+ *
+ * @access     public
+ * @param      string  the email address
+ * @param      string  the link title
+ * @param      mixed   any attributes
+ * @return     string
+ */
+if ( ! function_exists('mailto'))
+{
+       function mailto($email, $title = '', $attributes = '')
+       {
+               $title = (string) $title;
+
+               if ($title == "")
+               {
+                       $title = $email;
+               }
+
+               $attributes = _parse_attributes($attributes);
+
+               return '<a href="mailto:'.$email.'"'.$attributes.'>'.$title.'</a>';
+       }
+}
+
+// ------------------------------------------------------------------------
+
+/**
+ * Encoded Mailto Link
+ *
+ * Create a spam-protected mailto link written in Javascript
+ *
+ * @access     public
+ * @param      string  the email address
+ * @param      string  the link title
+ * @param      mixed   any attributes
+ * @return     string
+ */
+if ( ! function_exists('safe_mailto'))
+{
+       function safe_mailto($email, $title = '', $attributes = '')
+       {
+               $title = (string) $title;
+
+               if ($title == "")
+               {
+                       $title = $email;
+               }
+
+               for ($i = 0; $i < 16; $i++)
+               {
+                       $x[] = substr('<a href="mailto:', $i, 1);
+               }
+
+               for ($i = 0; $i < strlen($email); $i++)
+               {
+                       $x[] = "|".ord(substr($email, $i, 1));
+               }
+
+               $x[] = '"';
+
+               if ($attributes != '')
+               {
+                       if (is_array($attributes))
+                       {
+                               foreach ($attributes as $key => $val)
+                               {
+                                       $x[] =  ' '.$key.'="';
+                                       for ($i = 0; $i < strlen($val); $i++)
+                                       {
+                                               $x[] = "|".ord(substr($val, $i, 1));
+                                       }
+                                       $x[] = '"';
+                               }
+                       }
+                       else
+                       {
+                               for ($i = 0; $i < strlen($attributes); $i++)
+                               {
+                                       $x[] = substr($attributes, $i, 1);
+                               }
+                       }
+               }
+
+               $x[] = '>';
+
+               $temp = array();
+               for ($i = 0; $i < strlen($title); $i++)
+               {
+                       $ordinal = ord($title[$i]);
+
+                       if ($ordinal < 128)
+                       {
+                               $x[] = "|".$ordinal;
+                       }
+                       else
+                       {
+                               if (count($temp) == 0)
+                               {
+                                       $count = ($ordinal < 224) ? 2 : 3;
+                               }
+
+                               $temp[] = $ordinal;
+                               if (count($temp) == $count)
+                               {
+                                       $number = ($count == 3) ? (($temp['0'] % 16) * 4096) + (($temp['1'] % 64) * 64) + ($temp['2'] % 64) : (($temp['0'] % 32) * 64) + ($temp['1'] % 64);
+                                       $x[] = "|".$number;
+                                       $count = 1;
+                                       $temp = array();
+                               }
+                       }
+               }
+
+               $x[] = '<'; $x[] = '/'; $x[] = 'a'; $x[] = '>';
+
+               $x = array_reverse($x);
+               ob_start();
+
+       ?><script type="text/javascript">
+       //<![CDATA[
+       var l=new Array();
+       <?php
+       $i = 0;
+       foreach ($x as $val){ ?>l[<?php echo $i++; ?>]='<?php echo $val; ?>';<?php } ?>
+
+       for (var i = l.length-1; i >= 0; i=i-1){
+       if (l[i].substring(0, 1) == '|') document.write("&#"+unescape(l[i].substring(1))+";");
+       else document.write(unescape(l[i]));}
+       //]]>
+       </script><?php
+
+               $buffer = ob_get_contents();
+               ob_end_clean();
+               return $buffer;
+       }
+}
+
+// ------------------------------------------------------------------------
+
+/**
+ * Auto-linker
+ *
+ * Automatically links URL and Email addresses.
+ * Note: There's a bit of extra code here to deal with
+ * URLs or emails that end in a period.  We'll strip these
+ * off and add them after the link.
+ *
+ * @access     public
+ * @param      string  the string
+ * @param      string  the type: email, url, or both
+ * @param      bool    whether to create pop-up links
+ * @return     string
+ */
+if ( ! function_exists('auto_link'))
+{
+       function auto_link($str, $type = 'both', $popup = FALSE)
+       {
+               if ($type != 'email')
+               {
+                       if (preg_match_all("#(^|\s|\()((http(s?)://)|(www\.))(\w+[^\s\)\<]+)#i", $str, $matches))
+                       {
+                               $pop = ($popup == TRUE) ? " target=\"_blank\" " : "";
+
+                               for ($i = 0; $i < count($matches['0']); $i++)
+                               {
+                                       $period = '';
+                                       if (preg_match("|\.$|", $matches['6'][$i]))
+                                       {
+                                               $period = '.';
+                                               $matches['6'][$i] = substr($matches['6'][$i], 0, -1);
+                                       }
+
+                                       $str = str_replace($matches['0'][$i],
+                                                                               $matches['1'][$i].'<a href="http'.
+                                                                               $matches['4'][$i].'://'.
+                                                                               $matches['5'][$i].
+                                                                               $matches['6'][$i].'"'.$pop.'>http'.
+                                                                               $matches['4'][$i].'://'.
+                                                                               $matches['5'][$i].
+                                                                               $matches['6'][$i].'</a>'.
+                                                                               $period, $str);
+                               }
+                       }
+               }
+
+               if ($type != 'url')
+               {
+                       if (preg_match_all("/([a-zA-Z0-9_\.\-\+]+)@([a-zA-Z0-9\-]+)\.([a-zA-Z0-9\-\.]*)/i", $str, $matches))
+                       {
+                               for ($i = 0; $i < count($matches['0']); $i++)
+                               {
+                                       $period = '';
+                                       if (preg_match("|\.$|", $matches['3'][$i]))
+                                       {
+                                               $period = '.';
+                                               $matches['3'][$i] = substr($matches['3'][$i], 0, -1);
+                                       }
+
+                                       $str = str_replace($matches['0'][$i], safe_mailto($matches['1'][$i].'@'.$matches['2'][$i].'.'.$matches['3'][$i]).$period, $str);
+                               }
+                       }
+               }
+
+               return $str;
+       }
+}
+
+// ------------------------------------------------------------------------
+
+/**
+ * Prep URL
+ *
+ * Simply adds the http:// part if no scheme is included
+ *
+ * @access     public
+ * @param      string  the URL
+ * @return     string
+ */
+if ( ! function_exists('prep_url'))
+{
+       function prep_url($str = '')
+       {
+               if ($str == 'http://' OR $str == '')
+               {
+                       return '';
+               }
+
+               $url = parse_url($str);
+
+               if ( ! $url OR ! isset($url['scheme']))
+               {
+                       $str = 'http://'.$str;
+               }
+
+               return $str;
+       }
+}
+
+// ------------------------------------------------------------------------
+
+/**
+ * Create URL Title
+ *
+ * Takes a "title" string as input and creates a
+ * human-friendly URL string with either a dash
+ * or an underscore as the word separator.
+ *
+ * @access     public
+ * @param      string  the string
+ * @param      string  the separator: dash, or underscore
+ * @return     string
+ */
+if ( ! function_exists('url_title'))
+{
+       function url_title($str, $separator = 'dash', $lowercase = FALSE)
+       {
+               if ($separator == 'dash')
+               {
+                       $search         = '_';
+                       $replace        = '-';
+               }
+               else
+               {
+                       $search         = '-';
+                       $replace        = '_';
+               }
+
+               $trans = array(
+                                               '&\#\d+?;'                              => '',
+                                               '&\S+?;'                                => '',
+                                               '\s+'                                   => $replace,
+                                               '[^a-z0-9\-\._]'                => '',
+                                               $replace.'+'                    => $replace,
+                                               $replace.'$'                    => $replace,
+                                               '^'.$replace                    => $replace,
+                                               '\.+$'                                  => ''
+                                       );
+
+               $str = strip_tags($str);
+
+               foreach ($trans as $key => $val)
+               {
+                       $str = preg_replace("#".$key."#i", $val, $str);
+               }
+
+               if ($lowercase === TRUE)
+               {
+                       $str = strtolower($str);
+               }
+
+               return trim(stripslashes($str));
+       }
+}
+
+// ------------------------------------------------------------------------
+
+/**
+ * Header Redirect
+ *
+ * Header redirect in two flavors
+ * For very fine grained control over headers, you could use the Output
+ * Library's set_header() function.
+ *
+ * @access     public
+ * @param      string  the URL
+ * @param      string  the method: location or redirect
+ * @return     string
+ */
+if ( ! function_exists('redirect'))
+{
+       function redirect($uri = '', $method = 'location', $http_response_code = 302)
+       {
+               if ( ! preg_match('#^https?://#i', $uri))
+               {
+                       $uri = site_url($uri);
+               }
+
+               switch($method)
+               {
+                       case 'refresh'  : header("Refresh:0;url=".$uri);
+                               break;
+                       default                 : header("Location: ".$uri, TRUE, $http_response_code);
+                               break;
+               }
+               exit;
+       }
+}
+
+// ------------------------------------------------------------------------
+
+/**
+ * Parse out the attributes
+ *
+ * Some of the functions use this
+ *
+ * @access     private
+ * @param      array
+ * @param      bool
+ * @return     string
+ */
+if ( ! function_exists('_parse_attributes'))
+{
+       function _parse_attributes($attributes, $javascript = FALSE)
+       {
+               if (is_string($attributes))
+               {
+                       return ($attributes != '') ? ' '.$attributes : '';
+               }
+
+               $att = '';
+               foreach ($attributes as $key => $val)
+               {
+                       if ($javascript == TRUE)
+                       {
+                               $att .= $key . '=' . $val . ',';
+                       }
+                       else
+                       {
+                               $att .= ' ' . $key . '="' . $val . '"';
+                       }
+               }
+
+               if ($javascript == TRUE AND $att != '')
+               {
+                       $att = substr($att, 0, -1);
+               }
+
+               return $att;
+       }
+}
+
+
+/* End of file url_helper.php */
+/* Location: ./system/helpers/url_helper.php */
\ No newline at end of file
diff --git a/system/helpers/xml_helper.php b/system/helpers/xml_helper.php
new file mode 100755 (executable)
index 0000000..cdd81ad
--- /dev/null
@@ -0,0 +1,71 @@
+<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+/**
+ * CodeIgniter
+ *
+ * An open source application development framework for PHP 5.1.6 or newer
+ *
+ * @package            CodeIgniter
+ * @author             ExpressionEngine Dev Team
+ * @copyright  Copyright (c) 2008 - 2011, EllisLab, Inc.
+ * @license            http://codeigniter.com/user_guide/license.html
+ * @link               http://codeigniter.com
+ * @since              Version 1.0
+ * @filesource
+ */
+
+// ------------------------------------------------------------------------
+
+/**
+ * CodeIgniter XML Helpers
+ *
+ * @package            CodeIgniter
+ * @subpackage Helpers
+ * @category   Helpers
+ * @author             ExpressionEngine Dev Team
+ * @link               http://codeigniter.com/user_guide/helpers/xml_helper.html
+ */
+
+// ------------------------------------------------------------------------
+
+/**
+ * Convert Reserved XML characters to Entities
+ *
+ * @access     public
+ * @param      string
+ * @return     string
+ */
+if ( ! function_exists('xml_convert'))
+{
+       function xml_convert($str, $protect_all = FALSE)
+       {
+               $temp = '__TEMP_AMPERSANDS__';
+
+               // Replace entities to temporary markers so that
+               // ampersands won't get messed up
+               $str = preg_replace("/&#(\d+);/", "$temp\\1;", $str);
+
+               if ($protect_all === TRUE)
+               {
+                       $str = preg_replace("/&(\w+);/",  "$temp\\1;", $str);
+               }
+
+               $str = str_replace(array("&","<",">","\"", "'", "-"),
+                                                       array("&amp;", "&lt;", "&gt;", "&quot;", "&apos;", "&#45;"),
+                                                       $str);
+
+               // Decode the temp markers back to entities
+               $str = preg_replace("/$temp(\d+);/","&#\\1;",$str);
+
+               if ($protect_all === TRUE)
+               {
+                       $str = preg_replace("/$temp(\w+);/","&\\1;", $str);
+               }
+
+               return $str;
+       }
+}
+
+// ------------------------------------------------------------------------
+
+/* End of file xml_helper.php */
+/* Location: ./system/helpers/xml_helper.php */
\ No newline at end of file
diff --git a/system/index.html b/system/index.html
new file mode 100755 (executable)
index 0000000..c942a79
--- /dev/null
@@ -0,0 +1,10 @@
+<html>
+<head>
+       <title>403 Forbidden</title>
+</head>
+<body>
+
+<p>Directory access is forbidden.</p>
+
+</body>
+</html>
\ No newline at end of file
diff --git a/system/language/english/calendar_lang.php b/system/language/english/calendar_lang.php
new file mode 100755 (executable)
index 0000000..3e63123
--- /dev/null
@@ -0,0 +1,51 @@
+<?php
+
+$lang['cal_su']                        = "Su";
+$lang['cal_mo']                        = "Mo";
+$lang['cal_tu']                        = "Tu";
+$lang['cal_we']                        = "We";
+$lang['cal_th']                        = "Th";
+$lang['cal_fr']                        = "Fr";
+$lang['cal_sa']                        = "Sa";
+$lang['cal_sun']               = "Sun";
+$lang['cal_mon']               = "Mon";
+$lang['cal_tue']               = "Tue";
+$lang['cal_wed']               = "Wed";
+$lang['cal_thu']               = "Thu";
+$lang['cal_fri']               = "Fri";
+$lang['cal_sat']               = "Sat";
+$lang['cal_sunday']            = "Sunday";
+$lang['cal_monday']            = "Monday";
+$lang['cal_tuesday']   = "Tuesday";
+$lang['cal_wednesday'] = "Wednesday";
+$lang['cal_thursday']  = "Thursday";
+$lang['cal_friday']            = "Friday";
+$lang['cal_saturday']  = "Saturday";
+$lang['cal_jan']               = "Jan";
+$lang['cal_feb']               = "Feb";
+$lang['cal_mar']               = "Mar";
+$lang['cal_apr']               = "Apr";
+$lang['cal_may']               = "May";
+$lang['cal_jun']               = "Jun";
+$lang['cal_jul']               = "Jul";
+$lang['cal_aug']               = "Aug";
+$lang['cal_sep']               = "Sep";
+$lang['cal_oct']               = "Oct";
+$lang['cal_nov']               = "Nov";
+$lang['cal_dec']               = "Dec";
+$lang['cal_january']   = "January";
+$lang['cal_february']  = "February";
+$lang['cal_march']             = "March";
+$lang['cal_april']             = "April";
+$lang['cal_mayl']              = "May";
+$lang['cal_june']              = "June";
+$lang['cal_july']              = "July";
+$lang['cal_august']            = "August";
+$lang['cal_september'] = "September";
+$lang['cal_october']   = "October";
+$lang['cal_november']  = "November";
+$lang['cal_december']  = "December";
+
+
+/* End of file calendar_lang.php */
+/* Location: ./system/language/english/calendar_lang.php */
\ No newline at end of file
diff --git a/system/language/english/date_lang.php b/system/language/english/date_lang.php
new file mode 100755 (executable)
index 0000000..c0ace16
--- /dev/null
@@ -0,0 +1,61 @@
+<?php
+
+$lang['date_year'] = "Year";
+$lang['date_years'] = "Years";
+$lang['date_month'] = "Month";
+$lang['date_months'] = "Months";
+$lang['date_week'] = "Week";
+$lang['date_weeks'] = "Weeks";
+$lang['date_day'] = "Day";
+$lang['date_days'] = "Days";
+$lang['date_hour'] = "Hour";
+$lang['date_hours'] = "Hours";
+$lang['date_minute'] = "Minute";
+$lang['date_minutes'] = "Minutes";
+$lang['date_second'] = "Second";
+$lang['date_seconds'] = "Seconds";
+
+$lang['UM12']  = '(UTC -12:00) Baker/Howland Island';
+$lang['UM11']  = '(UTC -11:00) Samoa Time Zone, Niue';
+$lang['UM10']  = '(UTC -10:00) Hawaii-Aleutian Standard Time, Cook Islands, Tahiti';
+$lang['UM95']  = '(UTC -9:30) Marquesas Islands';
+$lang['UM9']   = '(UTC -9:00) Alaska Standard Time, Gambier Islands';
+$lang['UM8']   = '(UTC -8:00) Pacific Standard Time, Clipperton Island';
+$lang['UM7']   = '(UTC -7:00) Mountain Standard Time';
+$lang['UM6']   = '(UTC -6:00) Central Standard Time';
+$lang['UM5']   = '(UTC -5:00) Eastern Standard Time, Western Caribbean Standard Time';
+$lang['UM45']  = '(UTC -4:30) Venezuelan Standard Time';
+$lang['UM4']   = '(UTC -4:00) Atlantic Standard Time, Eastern Caribbean Standard Time';
+$lang['UM35']  = '(UTC -3:30) Newfoundland Standard Time';
+$lang['UM3']   = '(UTC -3:00) Argentina, Brazil, French Guiana, Uruguay';
+$lang['UM2']   = '(UTC -2:00) South Georgia/South Sandwich Islands';
+$lang['UM1']   = '(UTC -1:00) Azores, Cape Verde Islands';
+$lang['UTC']   = '(UTC) Greenwich Mean Time, Western European Time';
+$lang['UP1']   = '(UTC +1:00) Central European Time, West Africa Time';
+$lang['UP2']   = '(UTC +2:00) Central Africa Time, Eastern European Time, Kaliningrad Time';
+$lang['UP3']   = '(UTC +3:00) Moscow Time, East Africa Time';
+$lang['UP35']  = '(UTC +3:30) Iran Standard Time';
+$lang['UP4']   = '(UTC +4:00) Azerbaijan Standard Time, Samara Time';
+$lang['UP45']  = '(UTC +4:30) Afghanistan';
+$lang['UP5']   = '(UTC +5:00) Pakistan Standard Time, Yekaterinburg Time';
+$lang['UP55']  = '(UTC +5:30) Indian Standard Time, Sri Lanka Time';
+$lang['UP575'] = '(UTC +5:45) Nepal Time';
+$lang['UP6']   = '(UTC +6:00) Bangladesh Standard Time, Bhutan Time, Omsk Time';
+$lang['UP65']  = '(UTC +6:30) Cocos Islands, Myanmar';
+$lang['UP7']   = '(UTC +7:00) Krasnoyarsk Time, Cambodia, Laos, Thailand, Vietnam';
+$lang['UP8']   = '(UTC +8:00) Australian Western Standard Time, Beijing Time, Irkutsk Time';
+$lang['UP875'] = '(UTC +8:45) Australian Central Western Standard Time';
+$lang['UP9']   = '(UTC +9:00) Japan Standard Time, Korea Standard Time, Yakutsk Time';
+$lang['UP95']  = '(UTC +9:30) Australian Central Standard Time';
+$lang['UP10']  = '(UTC +10:00) Australian Eastern Standard Time, Vladivostok Time';
+$lang['UP105'] = '(UTC +10:30) Lord Howe Island';
+$lang['UP11']  = '(UTC +11:00) Magadan Time, Solomon Islands, Vanuatu';
+$lang['UP115'] = '(UTC +11:30) Norfolk Island';
+$lang['UP12']  = '(UTC +12:00) Fiji, Gilbert Islands, Kamchatka Time, New Zealand Standard Time';
+$lang['UP1275']        = '(UTC +12:45) Chatham Islands Standard Time';
+$lang['UP13']  = '(UTC +13:00) Phoenix Islands Time, Tonga';
+$lang['UP14']  = '(UTC +14:00) Line Islands';
+
+
+/* End of file date_lang.php */
+/* Location: ./system/language/english/date_lang.php */
\ No newline at end of file
diff --git a/system/language/english/db_lang.php b/system/language/english/db_lang.php
new file mode 100755 (executable)
index 0000000..79b82c7
--- /dev/null
@@ -0,0 +1,29 @@
+<?php
+
+$lang['db_invalid_connection_str'] = 'Unable to determine the database settings based on the connection string you submitted.';
+$lang['db_unable_to_connect'] = 'Unable to connect to your database server using the provided settings.';
+$lang['db_unable_to_select'] = 'Unable to select the specified database: %s';
+$lang['db_unable_to_create'] = 'Unable to create the specified database: %s';
+$lang['db_invalid_query'] = 'The query you submitted is not valid.';
+$lang['db_must_set_table'] = 'You must set the database table to be used with your query.';
+$lang['db_must_use_set'] = 'You must use the "set" method to update an entry.';
+$lang['db_must_use_index'] = 'You must specify an index to match on for batch updates.';
+$lang['db_batch_missing_index'] = 'One or more rows submitted for batch updating is missing the specified index.';
+$lang['db_must_use_where'] = 'Updates are not allowed unless they contain a "where" clause.';
+$lang['db_del_must_use_where'] = 'Deletes are not allowed unless they contain a "where" or "like" clause.';
+$lang['db_field_param_missing'] = 'To fetch fields requires the name of the table as a parameter.';
+$lang['db_unsupported_function'] = 'This feature is not available for the database you are using.';
+$lang['db_transaction_failure'] = 'Transaction failure: Rollback performed.';
+$lang['db_unable_to_drop'] = 'Unable to drop the specified database.';
+$lang['db_unsuported_feature'] = 'Unsupported feature of the database platform you are using.';
+$lang['db_unsuported_compression'] = 'The file compression format you chose is not supported by your server.';
+$lang['db_filepath_error'] = 'Unable to write data to the file path you have submitted.';
+$lang['db_invalid_cache_path'] = 'The cache path you submitted is not valid or writable.';
+$lang['db_table_name_required'] = 'A table name is required for that operation.';
+$lang['db_column_name_required'] = 'A column name is required for that operation.';
+$lang['db_column_definition_required'] = 'A column definition is required for that operation.';
+$lang['db_unable_to_set_charset'] = 'Unable to set client connection character set: %s';
+$lang['db_error_heading'] = 'A Database Error Occurred';
+
+/* End of file db_lang.php */
+/* Location: ./system/language/english/db_lang.php */
\ No newline at end of file
diff --git a/system/language/english/email_lang.php b/system/language/english/email_lang.php
new file mode 100755 (executable)
index 0000000..e3bd113
--- /dev/null
@@ -0,0 +1,24 @@
+<?php
+
+$lang['email_must_be_array'] = "The email validation method must be passed an array.";
+$lang['email_invalid_address'] = "Invalid email address: %s";
+$lang['email_attachment_missing'] = "Unable to locate the following email attachment: %s";
+$lang['email_attachment_unreadable'] = "Unable to open this attachment: %s";
+$lang['email_no_recipients'] = "You must include recipients: To, Cc, or Bcc";
+$lang['email_send_failure_phpmail'] = "Unable to send email using PHP mail().  Your server might not be configured to send mail using this method.";
+$lang['email_send_failure_sendmail'] = "Unable to send email using PHP Sendmail.  Your server might not be configured to send mail using this method.";
+$lang['email_send_failure_smtp'] = "Unable to send email using PHP SMTP.  Your server might not be configured to send mail using this method.";
+$lang['email_sent'] = "Your message has been successfully sent using the following protocol: %s";
+$lang['email_no_socket'] = "Unable to open a socket to Sendmail. Please check settings.";
+$lang['email_no_hostname'] = "You did not specify a SMTP hostname.";
+$lang['email_smtp_error'] = "The following SMTP error was encountered: %s";
+$lang['email_no_smtp_unpw'] = "Error: You must assign a SMTP username and password.";
+$lang['email_failed_smtp_login'] = "Failed to send AUTH LOGIN command. Error: %s";
+$lang['email_smtp_auth_un'] = "Failed to authenticate username. Error: %s";
+$lang['email_smtp_auth_pw'] = "Failed to authenticate password. Error: %s";
+$lang['email_smtp_data_failure'] = "Unable to send data: %s";
+$lang['email_exit_status'] = "Exit status code: %s";
+
+
+/* End of file email_lang.php */
+/* Location: ./system/language/english/email_lang.php */
\ No newline at end of file
diff --git a/system/language/english/form_validation_lang.php b/system/language/english/form_validation_lang.php
new file mode 100755 (executable)
index 0000000..3f24090
--- /dev/null
@@ -0,0 +1,28 @@
+<?php
+
+$lang['required']                      = "The %s field is required.";
+$lang['isset']                         = "The %s field must have a value.";
+$lang['valid_email']           = "The %s field must contain a valid email address.";
+$lang['valid_emails']          = "The %s field must contain all valid email addresses.";
+$lang['valid_url']                     = "The %s field must contain a valid URL.";
+$lang['valid_ip']                      = "The %s field must contain a valid IP.";
+$lang['min_length']                    = "The %s field must be at least %s characters in length.";
+$lang['max_length']                    = "The %s field can not exceed %s characters in length.";
+$lang['exact_length']          = "The %s field must be exactly %s characters in length.";
+$lang['alpha']                         = "The %s field may only contain alphabetical characters.";
+$lang['alpha_numeric']         = "The %s field may only contain alpha-numeric characters.";
+$lang['alpha_dash']                    = "The %s field may only contain alpha-numeric characters, underscores, and dashes.";
+$lang['numeric']                       = "The %s field must contain only numbers.";
+$lang['is_numeric']                    = "The %s field must contain only numeric characters.";
+$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_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.";
+
+
+/* End of file form_validation_lang.php */
+/* Location: ./system/language/english/form_validation_lang.php */
\ No newline at end of file
diff --git a/system/language/english/ftp_lang.php b/system/language/english/ftp_lang.php
new file mode 100755 (executable)
index 0000000..1e5168c
--- /dev/null
@@ -0,0 +1,18 @@
+<?php
+
+$lang['ftp_no_connection']                     = "Unable to locate a valid connection ID. Please make sure you are connected before peforming any file routines.";
+$lang['ftp_unable_to_connect']         = "Unable to connect to your FTP server using the supplied hostname.";
+$lang['ftp_unable_to_login']           = "Unable to login to your FTP server. Please check your username and password.";
+$lang['ftp_unable_to_makdir']          = "Unable to create the directory you have specified.";
+$lang['ftp_unable_to_changedir']       = "Unable to change directories.";
+$lang['ftp_unable_to_chmod']           = "Unable to set file permissions. Please check your path. Note: This feature is only available in PHP 5 or higher.";
+$lang['ftp_unable_to_upload']          = "Unable to upload the specified file. Please check your path.";
+$lang['ftp_unable_to_download']                = "Unable to download the specified file. Please check your path.";
+$lang['ftp_no_source_file']                    = "Unable to locate the source file. Please check your path.";
+$lang['ftp_unable_to_rename']          = "Unable to rename the file.";
+$lang['ftp_unable_to_delete']          = "Unable to delete the file.";
+$lang['ftp_unable_to_move']                    = "Unable to move the file. Please make sure the destination directory exists.";
+
+
+/* End of file ftp_lang.php */
+/* Location: ./system/language/english/ftp_lang.php */
\ No newline at end of file
diff --git a/system/language/english/imglib_lang.php b/system/language/english/imglib_lang.php
new file mode 100755 (executable)
index 0000000..66505da
--- /dev/null
@@ -0,0 +1,24 @@
+<?php
+
+$lang['imglib_source_image_required'] = "You must specify a source image in your preferences.";
+$lang['imglib_gd_required'] = "The GD image library is required for this feature.";
+$lang['imglib_gd_required_for_props'] = "Your server must support the GD image library in order to determine the image properties.";
+$lang['imglib_unsupported_imagecreate'] = "Your server does not support the GD function required to process this type of image.";
+$lang['imglib_gif_not_supported'] = "GIF images are often not supported due to licensing restrictions.  You may have to use JPG or PNG images instead.";
+$lang['imglib_jpg_not_supported'] = "JPG images are not supported.";
+$lang['imglib_png_not_supported'] = "PNG images are not supported.";
+$lang['imglib_jpg_or_png_required'] = "The image resize protocol specified in your preferences only works with JPEG or PNG image types.";
+$lang['imglib_copy_error'] = "An error was encountered while attempting to replace the file.  Please make sure your file directory is writable.";
+$lang['imglib_rotate_unsupported'] = "Image rotation does not appear to be supported by your server.";
+$lang['imglib_libpath_invalid'] = "The path to your image library is not correct.  Please set the correct path in your image preferences.";
+$lang['imglib_image_process_failed'] = "Image processing failed.  Please verify that your server supports the chosen protocol and that the path to your image library is correct.";
+$lang['imglib_rotation_angle_required'] = "An angle of rotation is required to rotate the image.";
+$lang['imglib_writing_failed_gif'] = "GIF image.";
+$lang['imglib_invalid_path'] = "The path to the image is not correct.";
+$lang['imglib_copy_failed'] = "The image copy routine failed.";
+$lang['imglib_missing_font'] = "Unable to find a font to use.";
+$lang['imglib_save_failed'] = "Unable to save the image.  Please make sure the image and file directory are writable.";
+
+
+/* End of file imglib_lang.php */
+/* Location: ./system/language/english/imglib_lang.php */
\ No newline at end of file
diff --git a/system/language/english/index.html b/system/language/english/index.html
new file mode 100755 (executable)
index 0000000..c942a79
--- /dev/null
@@ -0,0 +1,10 @@
+<html>
+<head>
+       <title>403 Forbidden</title>
+</head>
+<body>
+
+<p>Directory access is forbidden.</p>
+
+</body>
+</html>
\ No newline at end of file
diff --git a/system/language/english/number_lang.php b/system/language/english/number_lang.php
new file mode 100755 (executable)
index 0000000..9085809
--- /dev/null
@@ -0,0 +1,10 @@
+<?php
+
+$lang['terabyte_abbr'] = "TB";
+$lang['gigabyte_abbr'] = "GB";
+$lang['megabyte_abbr'] = "MB";
+$lang['kilobyte_abbr'] = "KB";
+$lang['bytes'] = "Bytes";
+
+/* End of file number_lang.php */
+/* Location: ./system/language/english/number_lang.php */
\ No newline at end of file
diff --git a/system/language/english/profiler_lang.php b/system/language/english/profiler_lang.php
new file mode 100755 (executable)
index 0000000..b6460fb
--- /dev/null
@@ -0,0 +1,22 @@
+<?php
+
+$lang['profiler_database']             = 'DATABASE';
+$lang['profiler_controller_info'] = 'CLASS/METHOD';
+$lang['profiler_benchmarks']   = 'BENCHMARKS';
+$lang['profiler_queries']              = 'QUERIES';
+$lang['profiler_get_data']             = 'GET DATA';
+$lang['profiler_post_data']            = 'POST DATA';
+$lang['profiler_uri_string']   = 'URI STRING';
+$lang['profiler_memory_usage'] = 'MEMORY USAGE';
+$lang['profiler_config']               = 'CONFIG VARIABLES';
+$lang['profiler_headers']              = 'HTTP HEADERS';
+$lang['profiler_no_db']                        = 'Database driver is not currently loaded';
+$lang['profiler_no_queries']   = 'No queries were run';
+$lang['profiler_no_post']              = 'No POST data exists';
+$lang['profiler_no_get']               = 'No GET data exists';
+$lang['profiler_no_uri']               = 'No URI data exists';
+$lang['profiler_no_memory']            = 'Memory Usage Unavailable';
+$lang['profiler_no_profiles']  = 'No Profile data - all Profiler sections have been disabled.';
+
+/* End of file profiler_lang.php */
+/* Location: ./system/language/english/profiler_lang.php */
\ No newline at end of file
diff --git a/system/language/english/unit_test_lang.php b/system/language/english/unit_test_lang.php
new file mode 100755 (executable)
index 0000000..070bcd1
--- /dev/null
@@ -0,0 +1,25 @@
+<?php
+
+$lang['ut_test_name']          = 'Test Name';
+$lang['ut_test_datatype']      = 'Test Datatype';
+$lang['ut_res_datatype']       = 'Expected Datatype';
+$lang['ut_result']                     = 'Result';
+$lang['ut_undefined']          = 'Undefined Test Name';
+$lang['ut_file']                       = 'File Name';
+$lang['ut_line']                       = 'Line Number';
+$lang['ut_passed']                     = 'Passed';
+$lang['ut_failed']                     = 'Failed';
+$lang['ut_boolean']                    = 'Boolean';
+$lang['ut_integer']                    = 'Integer';
+$lang['ut_float']                      = 'Float';
+$lang['ut_double']                     = 'Float'; // can be the same as float
+$lang['ut_string']                     = 'String';
+$lang['ut_array']                      = 'Array';
+$lang['ut_object']                     = 'Object';
+$lang['ut_resource']           = 'Resource';
+$lang['ut_null']                       = 'Null';
+$lang['ut_notes']                      = 'Notes';
+
+
+/* End of file unit_test_lang.php */
+/* Location: ./system/language/english/unit_test_lang.php */
\ No newline at end of file
diff --git a/system/language/english/upload_lang.php b/system/language/english/upload_lang.php
new file mode 100755 (executable)
index 0000000..4de9e9e
--- /dev/null
@@ -0,0 +1,22 @@
+<?php
+
+$lang['upload_userfile_not_set'] = "Unable to find a post variable called userfile.";
+$lang['upload_file_exceeds_limit'] = "The uploaded file exceeds the maximum allowed size in your PHP configuration file.";
+$lang['upload_file_exceeds_form_limit'] = "The uploaded file exceeds the maximum size allowed by the submission form.";
+$lang['upload_file_partial'] = "The file was only partially uploaded.";
+$lang['upload_no_temp_directory'] = "The temporary folder is missing.";
+$lang['upload_unable_to_write_file'] = "The file could not be written to disk.";
+$lang['upload_stopped_by_extension'] = "The file upload was stopped by extension.";
+$lang['upload_no_file_selected'] = "You did not select a file to upload.";
+$lang['upload_invalid_filetype'] = "The filetype you are attempting to upload is not allowed.";
+$lang['upload_invalid_filesize'] = "The file you are attempting to upload is larger than the permitted size.";
+$lang['upload_invalid_dimensions'] = "The image you are attempting to upload exceedes the maximum height or width.";
+$lang['upload_destination_error'] = "A problem was encountered while attempting to move the uploaded file to the final destination.";
+$lang['upload_no_filepath'] = "The upload path does not appear to be valid.";
+$lang['upload_no_file_types'] = "You have not specified any allowed file types.";
+$lang['upload_bad_filename'] = "The file name you submitted already exists on the server.";
+$lang['upload_not_writable'] = "The upload destination folder does not appear to be writable.";
+
+
+/* End of file upload_lang.php */
+/* Location: ./system/language/english/upload_lang.php */
\ No newline at end of file
diff --git a/system/language/index.html b/system/language/index.html
new file mode 100755 (executable)
index 0000000..c942a79
--- /dev/null
@@ -0,0 +1,10 @@
+<html>
+<head>
+       <title>403 Forbidden</title>
+</head>
+<body>
+
+<p>Directory access is forbidden.</p>
+
+</body>
+</html>
\ No newline at end of file
diff --git a/system/libraries/Cache/Cache.php b/system/libraries/Cache/Cache.php
new file mode 100755 (executable)
index 0000000..61e7aa7
--- /dev/null
@@ -0,0 +1,216 @@
+<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+/**
+ * CodeIgniter
+ *
+ * An open source application development framework for PHP 4.3.2 or newer
+ *
+ * @package            CodeIgniter
+ * @author             ExpressionEngine Dev Team
+ * @copyright  Copyright (c) 2006 - 2011 EllisLab, Inc.
+ * @license            http://codeigniter.com/user_guide/license.html
+ * @link               http://codeigniter.com
+ * @since              Version 2.0
+ * @filesource 
+ */
+
+// ------------------------------------------------------------------------
+
+/**
+ * CodeIgniter Caching Class 
+ *
+ * @package            CodeIgniter
+ * @subpackage Libraries
+ * @category   Core
+ * @author             ExpressionEngine Dev Team
+ * @link               
+ */
+class CI_Cache extends CI_Driver_Library {
+       
+       protected $valid_drivers        = array(
+               'cache_apc', 'cache_file', 'cache_memcached', 'cache_dummy'
+       );
+
+       protected $_cache_path          = NULL;         // Path of cache files (if file-based cache)
+       protected $_adapter                     = 'dummy';
+       protected $_backup_driver;
+       
+       // ------------------------------------------------------------------------
+
+       /**
+        * Constructor
+        *
+        * @param array
+        */
+       public function __construct($config = array())
+       {
+               if ( ! empty($config))
+               {
+                       $this->_initialize($config);
+               }
+       }
+
+       // ------------------------------------------------------------------------
+
+       /**
+        * Get 
+        *
+        * Look for a value in the cache.  If it exists, return the data 
+        * if not, return FALSE
+        *
+        * @param       string  
+        * @return      mixed           value that is stored/FALSE on failure
+        */
+       public function get($id)
+       {       
+               return $this->{$this->_adapter}->get($id);
+       }
+
+       // ------------------------------------------------------------------------
+
+       /**
+        * Cache Save
+        *
+        * @param       string          Unique Key
+        * @param       mixed           Data to store
+        * @param       int                     Length of time (in seconds) to cache the data
+        *
+        * @return      boolean         true on success/false on failure
+        */
+       public function save($id, $data, $ttl = 60)
+       {
+               return $this->{$this->_adapter}->save($id, $data, $ttl);
+       }
+
+       // ------------------------------------------------------------------------
+
+       /**
+        * Delete from Cache
+        *
+        * @param       mixed           unique identifier of the item in the cache
+        * @return      boolean         true on success/false on failure
+        */
+       public function delete($id)
+       {
+               return $this->{$this->_adapter}->delete($id);
+       }
+
+       // ------------------------------------------------------------------------
+
+       /**
+        * Clean the cache
+        *
+        * @return      boolean         false on failure/true on success
+        */
+       public function clean()
+       {
+               return $this->{$this->_adapter}->clean();
+       }
+
+       // ------------------------------------------------------------------------
+
+       /**
+        * Cache Info
+        *
+        * @param       string          user/filehits
+        * @return      mixed           array on success, false on failure      
+        */
+       public function cache_info($type = 'user')
+       {
+               return $this->{$this->_adapter}->cache_info($type);
+       }
+
+       // ------------------------------------------------------------------------
+       
+       /**
+        * Get Cache Metadata
+        *
+        * @param       mixed           key to get cache metadata on
+        * @return      mixed           return value from child method
+        */
+       public function get_metadata($id)
+       {
+               return $this->{$this->_adapter}->get_metadata($id);
+       }
+       
+       // ------------------------------------------------------------------------
+
+       /**
+        * Initialize
+        *
+        * Initialize class properties based on the configuration array.
+        *
+        * @param       array   
+        * @return      void
+        */
+       private function _initialize($config)
+       {        
+               $default_config = array(
+                               'adapter',
+                               'memcached'
+                       );
+
+               foreach ($default_config as $key)
+               {
+                       if (isset($config[$key]))
+                       {
+                               $param = '_'.$key;
+
+                               $this->{$param} = $config[$key];
+                       }
+               }
+
+               if (isset($config['backup']))
+               {
+                       if (in_array('cache_'.$config['backup'], $this->valid_drivers))
+                       {
+                               $this->_backup_driver = $config['backup'];
+                       }
+               }
+       }
+
+       // ------------------------------------------------------------------------
+
+       /**
+        * Is the requested driver supported in this environment?
+        *
+        * @param       string  The driver to test.
+        * @return      array
+        */
+       public function is_supported($driver)
+       {
+               static $support = array();
+
+               if ( ! isset($support[$driver]))
+               {
+                       $support[$driver] = $this->{$driver}->is_supported();
+               }
+
+               return $support[$driver];
+       }
+
+       // ------------------------------------------------------------------------
+
+       /**
+        * __get()
+        *
+        * @param       child
+        * @return      object
+        */
+       public function __get($child)
+       {
+               $obj = parent::__get($child);
+
+               if ( ! $this->is_supported($child))
+               {
+                       $this->_adapter = $this->_backup_driver;
+               }
+
+               return $obj;
+       }
+       
+       // ------------------------------------------------------------------------
+}
+// End Class
+
+/* End of file Cache.php */
+/* Location: ./system/libraries/Cache/Cache.php */
\ No newline at end of file
diff --git a/system/libraries/Cache/drivers/Cache_apc.php b/system/libraries/Cache/drivers/Cache_apc.php
new file mode 100755 (executable)
index 0000000..de75719
--- /dev/null
@@ -0,0 +1,151 @@
+<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+/**
+ * CodeIgniter
+ *
+ * An open source application development framework for PHP 5.1.6 or newer
+ *
+ * @package            CodeIgniter
+ * @author             ExpressionEngine Dev Team
+ * @copyright  Copyright (c) 2006 - 2011 EllisLab, Inc.
+ * @license            http://codeigniter.com/user_guide/license.html
+ * @link               http://codeigniter.com
+ * @since              Version 2.0
+ * @filesource 
+ */
+
+// ------------------------------------------------------------------------
+
+/**
+ * CodeIgniter APC Caching Class 
+ *
+ * @package            CodeIgniter
+ * @subpackage Libraries
+ * @category   Core
+ * @author             ExpressionEngine Dev Team
+ * @link               
+ */
+
+class CI_Cache_apc extends CI_Driver {
+
+       /**
+        * Get 
+        *
+        * Look for a value in the cache.  If it exists, return the data 
+        * if not, return FALSE
+        *
+        * @param       string  
+        * @return      mixed           value that is stored/FALSE on failure
+        */
+       public function get($id)
+       {
+               $data = apc_fetch($id);
+
+               return (is_array($data)) ? $data[0] : FALSE;
+       }
+
+       // ------------------------------------------------------------------------     
+       
+       /**
+        * Cache Save
+        *
+        * @param       string          Unique Key
+        * @param       mixed           Data to store
+        * @param       int                     Length of time (in seconds) to cache the data
+        *
+        * @return      boolean         true on success/false on failure
+        */
+       public function save($id, $data, $ttl = 60)
+       {
+               return apc_store($id, array($data, time(), $ttl), $ttl);
+       }
+       
+       // ------------------------------------------------------------------------
+
+       /**
+        * Delete from Cache
+        *
+        * @param       mixed           unique identifier of the item in the cache
+        * @param       boolean         true on success/false on failure
+        */
+       public function delete($id)
+       {
+               return apc_delete($id);
+       }
+
+       // ------------------------------------------------------------------------
+
+       /**
+        * Clean the cache
+        *
+        * @return      boolean         false on failure/true on success
+        */
+       public function clean()
+       {
+               return apc_clear_cache('user');
+       }
+
+       // ------------------------------------------------------------------------
+
+       /**
+        * Cache Info
+        *
+        * @param       string          user/filehits
+        * @return      mixed           array on success, false on failure      
+        */
+        public function cache_info($type = NULL)
+        {
+                return apc_cache_info($type);
+        }
+
+       // ------------------------------------------------------------------------
+
+       /**
+        * Get Cache Metadata
+        *
+        * @param       mixed           key to get cache metadata on
+        * @return      mixed           array on success/false on failure
+        */
+       public function get_metadata($id)
+       {
+               $stored = apc_fetch($id);
+
+               if (count($stored) !== 3)
+               {
+                       return FALSE;
+               }
+
+               list($data, $time, $ttl) = $stored;
+
+               return array(
+                       'expire'        => $time + $ttl,
+                       'mtime'         => $time,
+                       'data'          => $data
+               );
+       }
+
+       // ------------------------------------------------------------------------
+
+       /**
+        * is_supported()
+        *
+        * Check to see if APC is available on this system, bail if it isn't.
+        */
+       public function is_supported()
+       {
+               if ( ! extension_loaded('apc') OR ! function_exists('apc_store'))
+               {
+                       log_message('error', 'The APC PHP extension must be loaded to use APC Cache.');
+                       return FALSE;
+               }
+               
+               return TRUE;
+       }
+
+       // ------------------------------------------------------------------------
+
+       
+}
+// End Class
+
+/* End of file Cache_apc.php */
+/* Location: ./system/libraries/Cache/drivers/Cache_apc.php */
\ No newline at end of file
diff --git a/system/libraries/Cache/drivers/Cache_dummy.php b/system/libraries/Cache/drivers/Cache_dummy.php
new file mode 100755 (executable)
index 0000000..de47acb
--- /dev/null
@@ -0,0 +1,129 @@
+<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+/**
+ * CodeIgniter
+ *
+ * An open source application development framework for PHP 4.3.2 or newer
+ *
+ * @package            CodeIgniter
+ * @author             ExpressionEngine Dev Team
+ * @copyright  Copyright (c) 2006 - 2011 EllisLab, Inc.
+ * @license            http://codeigniter.com/user_guide/license.html
+ * @link               http://codeigniter.com
+ * @since              Version 2.0
+ * @filesource 
+ */
+
+// ------------------------------------------------------------------------
+
+/**
+ * CodeIgniter Dummy Caching Class 
+ *
+ * @package            CodeIgniter
+ * @subpackage Libraries
+ * @category   Core
+ * @author             ExpressionEngine Dev Team
+ * @link               
+ */
+
+class CI_Cache_dummy extends CI_Driver {
+
+       /**
+        * Get 
+        *
+        * Since this is the dummy class, it's always going to return FALSE.
+        *
+        * @param       string  
+        * @return      Boolean         FALSE
+        */
+       public function get($id)
+       {
+               return FALSE;
+       }
+
+       // ------------------------------------------------------------------------     
+       
+       /**
+        * Cache Save
+        *
+        * @param       string          Unique Key
+        * @param       mixed           Data to store
+        * @param       int                     Length of time (in seconds) to cache the data
+        *
+        * @return      boolean         TRUE, Simulating success
+        */
+       public function save($id, $data, $ttl = 60)
+       {
+               return TRUE;
+       }
+       
+       // ------------------------------------------------------------------------
+
+       /**
+        * Delete from Cache
+        *
+        * @param       mixed           unique identifier of the item in the cache
+        * @param       boolean         TRUE, simulating success
+        */
+       public function delete($id)
+       {
+               return TRUE;
+       }
+
+       // ------------------------------------------------------------------------
+
+       /**
+        * Clean the cache
+        *
+        * @return      boolean         TRUE, simulating success
+        */
+       public function clean()
+       {
+               return TRUE;
+       }
+
+       // ------------------------------------------------------------------------
+
+       /**
+        * Cache Info
+        *
+        * @param       string          user/filehits
+        * @return      boolean         FALSE
+        */
+        public function cache_info($type = NULL)
+        {
+                return FALSE;
+        }
+
+       // ------------------------------------------------------------------------
+
+       /**
+        * Get Cache Metadata
+        *
+        * @param       mixed           key to get cache metadata on
+        * @return      boolean         FALSE
+        */
+       public function get_metadata($id)
+       {
+               return FALSE;
+       }
+
+       // ------------------------------------------------------------------------
+
+       /**
+        * Is this caching driver supported on the system?
+        * Of course this one is.
+        * 
+        * @return TRUE;
+        */
+       public function is_supported()
+       {
+               return TRUE;
+       }
+
+       // ------------------------------------------------------------------------
+       
+}
+// End Class
+
+/* End of file Cache_apc.php */
+/* Location: ./system/libraries/Cache/drivers/Cache_apc.php */
\ No newline at end of file
diff --git a/system/libraries/Cache/drivers/Cache_file.php b/system/libraries/Cache/drivers/Cache_file.php
new file mode 100755 (executable)
index 0000000..13e2d1a
--- /dev/null
@@ -0,0 +1,196 @@
+<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+/**
+ * CodeIgniter
+ *
+ * An open source application development framework for PHP 4.3.2 or newer
+ *
+ * @package            CodeIgniter
+ * @author             ExpressionEngine Dev Team
+ * @copyright  Copyright (c) 2006 - 2011 EllisLab, Inc.
+ * @license            http://codeigniter.com/user_guide/license.html
+ * @link               http://codeigniter.com
+ * @since              Version 2.0
+ * @filesource 
+ */
+
+// ------------------------------------------------------------------------
+
+/**
+ * CodeIgniter Memcached Caching Class 
+ *
+ * @package            CodeIgniter
+ * @subpackage Libraries
+ * @category   Core
+ * @author             ExpressionEngine Dev Team
+ * @link               
+ */
+
+class CI_Cache_file extends CI_Driver {
+
+       protected $_cache_path;
+
+       /**
+        * Constructor
+        */
+       public function __construct()
+       {
+               $CI =& get_instance();
+               $CI->load->helper('file');
+               
+               $path = $CI->config->item('cache_path');
+       
+               $this->_cache_path = ($path == '') ? APPPATH.'cache/' : $path;
+       }
+
+       // ------------------------------------------------------------------------
+
+       /**
+        * Fetch from cache
+        *
+        * @param       mixed           unique key id
+        * @return      mixed           data on success/false on failure
+        */
+       public function get($id)
+       {
+               if ( ! file_exists($this->_cache_path.$id))
+               {
+                       return FALSE;
+               }
+               
+               $data = read_file($this->_cache_path.$id);
+               $data = unserialize($data);
+               
+               if (time() >  $data['time'] + $data['ttl'])
+               {
+                       unlink($this->_cache_path.$id);
+                       return FALSE;
+               }
+               
+               return $data['data'];
+       }
+
+       // ------------------------------------------------------------------------
+
+       /**
+        * Save into cache
+        *
+        * @param       string          unique key
+        * @param       mixed           data to store
+        * @param       int                     length of time (in seconds) the cache is valid 
+        *                                              - Default is 60 seconds
+        * @return      boolean         true on success/false on failure
+        */
+       public function save($id, $data, $ttl = 60)
+       {               
+               $contents = array(
+                               'time'          => time(),
+                               'ttl'           => $ttl,                        
+                               'data'          => $data
+                       );
+               
+               if (write_file($this->_cache_path.$id, serialize($contents)))
+               {
+                       @chmod($this->_cache_path.$id, 0777);
+                       return TRUE;                    
+               }
+
+               return FALSE;
+       }
+
+       // ------------------------------------------------------------------------
+
+       /**
+        * Delete from Cache
+        *
+        * @param       mixed           unique identifier of item in cache
+        * @return      boolean         true on success/false on failure
+        */
+       public function delete($id)
+       {
+               return unlink($this->_cache_path.$id);
+       }
+
+       // ------------------------------------------------------------------------
+
+       /**
+        * Clean the Cache
+        *
+        * @return      boolean         false on failure/true on success
+        */     
+       public function clean()
+       {
+               return delete_files($this->_cache_path);
+       }
+
+       // ------------------------------------------------------------------------
+
+       /**
+        * Cache Info
+        *
+        * Not supported by file-based caching
+        *
+        * @param       string  user/filehits
+        * @return      mixed   FALSE
+        */
+       public function cache_info($type = NULL)
+       {
+               return get_dir_file_info($this->_cache_path);
+       }
+
+       // ------------------------------------------------------------------------
+
+       /**
+        * Get Cache Metadata
+        *
+        * @param       mixed           key to get cache metadata on
+        * @return      mixed           FALSE on failure, array on success.
+        */
+       public function get_metadata($id)
+       {
+               if ( ! file_exists($this->_cache_path.$id))
+               {
+                       return FALSE;
+               }
+               
+               $data = read_file($this->_cache_path.$id);              
+               $data = unserialize($data);
+               
+               if (is_array($data))
+               {
+                       $data = $data['data'];
+                       $mtime = filemtime($this->_cache_path.$id);
+
+                       if ( ! isset($data['ttl']))
+                       {
+                               return FALSE;
+                       }
+
+                       return array(
+                               'expire'        => $mtime + $data['ttl'],
+                               'mtime'         => $mtime
+                       );
+               }
+               
+               return FALSE;
+       }
+
+       // ------------------------------------------------------------------------
+
+       /**
+        * Is supported
+        *
+        * In the file driver, check to see that the cache directory is indeed writable
+        * 
+        * @return boolean
+        */
+       public function is_supported()
+       {
+               return is_really_writable($this->_cache_path);
+       }
+
+       // ------------------------------------------------------------------------
+}
+// End Class
+
+/* End of file Cache_file.php */
+/* Location: ./system/libraries/Cache/drivers/Cache_file.php */
\ No newline at end of file
diff --git a/system/libraries/Cache/drivers/Cache_memcached.php b/system/libraries/Cache/drivers/Cache_memcached.php
new file mode 100755 (executable)
index 0000000..ec2fd21
--- /dev/null
@@ -0,0 +1,209 @@
+<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+/**
+ * CodeIgniter
+ *
+ * An open source application development framework for PHP 4.3.2 or newer
+ *
+ * @package            CodeIgniter
+ * @author             ExpressionEngine Dev Team
+ * @copyright  Copyright (c) 2006 - 2011 EllisLab, Inc.
+ * @license            http://codeigniter.com/user_guide/license.html
+ * @link               http://codeigniter.com
+ * @since              Version 2.0
+ * @filesource 
+ */
+
+// ------------------------------------------------------------------------
+
+/**
+ * CodeIgniter Memcached Caching Class 
+ *
+ * @package            CodeIgniter
+ * @subpackage Libraries
+ * @category   Core
+ * @author             ExpressionEngine Dev Team
+ * @link               
+ */
+
+class CI_Cache_memcached extends CI_Driver {
+
+       private $_memcached;    // Holds the memcached object
+
+       protected $_memcache_conf       = array(
+                                       'default' => array(
+                                               'default_host'          => '127.0.0.1',
+                                               'default_port'          => 11211,
+                                               'default_weight'        => 1
+                                       )
+                               );
+
+       // ------------------------------------------------------------------------     
+
+       /**
+        * Fetch from cache
+        *
+        * @param       mixed           unique key id
+        * @return      mixed           data on success/false on failure
+        */     
+       public function get($id)
+       {       
+               $data = $this->_memcached->get($id);
+               
+               return (is_array($data)) ? $data[0] : FALSE;
+       }
+
+       // ------------------------------------------------------------------------
+
+       /**
+        * Save
+        *
+        * @param       string          unique identifier
+        * @param       mixed           data being cached
+        * @param       int                     time to live
+        * @return      boolean         true on success, false on failure
+        */
+       public function save($id, $data, $ttl = 60)
+       {
+               return $this->_memcached->add($id, array($data, time(), $ttl), $ttl);
+       }
+
+       // ------------------------------------------------------------------------
+       
+       /**
+        * Delete from Cache
+        *
+        * @param       mixed           key to be deleted.
+        * @return      boolean         true on success, false on failure
+        */
+       public function delete($id)
+       {
+               return $this->_memcached->delete($id);
+       }
+
+       // ------------------------------------------------------------------------
+       
+       /**
+        * Clean the Cache
+        *
+        * @return      boolean         false on failure/true on success
+        */
+       public function clean()
+       {
+               return $this->_memcached->flush();
+       }
+
+       // ------------------------------------------------------------------------
+
+       /**
+        * Cache Info
+        *
+        * @param       null            type not supported in memcached
+        * @return      mixed           array on success, false on failure
+        */
+       public function cache_info($type = NULL)
+       {
+               return $this->_memcached->getStats();
+       }
+
+       // ------------------------------------------------------------------------
+       
+       /**
+        * Get Cache Metadata
+        *
+        * @param       mixed           key to get cache metadata on
+        * @return      mixed           FALSE on failure, array on success.
+        */
+       public function get_metadata($id)
+       {
+               $stored = $this->_memcached->get($id);
+
+               if (count($stored) !== 3)
+               {
+                       return FALSE;
+               }
+
+               list($data, $time, $ttl) = $stored;
+
+               return array(
+                       'expire'        => $time + $ttl,
+                       'mtime'         => $time,
+                       'data'          => $data
+               );
+       }
+
+       // ------------------------------------------------------------------------
+
+       /**
+        * Setup memcached.
+        */
+       private function _setup_memcached()
+       {
+               // Try to load memcached server info from the config file.
+               $CI =& get_instance();
+               if ($CI->config->load('memcached', TRUE, TRUE))
+               {
+                       if (is_array($CI->config->config['memcached']))
+                       {
+                               $this->_memcache_conf = NULL;
+
+                               foreach ($CI->config->config['memcached'] as $name => $conf)
+                               {
+                                       $this->_memcache_conf[$name] = $conf;
+                               }                               
+                       }                       
+               }
+               
+               $this->_memcached = new Memcached();
+
+               foreach ($this->_memcache_conf as $name => $cache_server)
+               {
+                       if ( ! array_key_exists('hostname', $cache_server))
+                       {
+                               $cache_server['hostname'] = $this->_default_options['default_host'];
+                       }
+       
+                       if ( ! array_key_exists('port', $cache_server))
+                       {
+                               $cache_server['port'] = $this->_default_options['default_port'];
+                       }
+       
+                       if ( ! array_key_exists('weight', $cache_server))
+                       {
+                               $cache_server['weight'] = $this->_default_options['default_weight'];
+                       }
+       
+                       $this->_memcached->addServer(
+                                       $cache_server['hostname'], $cache_server['port'], $cache_server['weight']
+                       );
+               }
+       }
+
+       // ------------------------------------------------------------------------
+
+
+       /**
+        * Is supported
+        *
+        * Returns FALSE if memcached is not supported on the system.
+        * If it is, we setup the memcached object & return TRUE
+        */
+       public function is_supported()
+       {
+               if ( ! extension_loaded('memcached'))
+               {
+                       log_message('error', 'The Memcached Extension must be loaded to use Memcached Cache.');
+                       
+                       return FALSE;
+               }
+               
+               $this->_setup_memcached();
+               return TRUE;
+       }
+
+       // ------------------------------------------------------------------------
+
+}
+// End Class
+
+/* End of file Cache_memcached.php */
+/* Location: ./system/libraries/Cache/drivers/Cache_memcached.php */
\ No newline at end of file
diff --git a/system/libraries/Calendar.php b/system/libraries/Calendar.php
new file mode 100755 (executable)
index 0000000..72d228e
--- /dev/null
@@ -0,0 +1,475 @@
+<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+/**
+ * CodeIgniter
+ *
+ * An open source application development framework for PHP 5.1.6 or newer
+ *
+ * @package            CodeIgniter
+ * @author             ExpressionEngine Dev Team
+ * @copyright  Copyright (c) 2008 - 2011, EllisLab, Inc.
+ * @license            http://codeigniter.com/user_guide/license.html
+ * @link               http://codeigniter.com
+ * @since              Version 1.0
+ * @filesource
+ */
+
+// ------------------------------------------------------------------------
+
+/**
+ * CodeIgniter Calendar Class
+ *
+ * This class enables the creation of calendars
+ *
+ * @package            CodeIgniter
+ * @subpackage Libraries
+ * @category   Libraries
+ * @author             ExpressionEngine Dev Team
+ * @link               http://codeigniter.com/user_guide/libraries/calendar.html
+ */
+class CI_Calendar {
+
+       var $CI;
+       var $lang;
+       var $local_time;
+       var $template           = '';
+       var $start_day          = 'sunday';
+       var $month_type         = 'long';
+       var $day_type           = 'abr';
+       var $show_next_prev     = FALSE;
+       var $next_prev_url      = '';
+
+       /**
+        * Constructor
+        *
+        * Loads the calendar language file and sets the default time reference
+        */
+       public function __construct($config = array())
+       {
+               $this->CI =& get_instance();
+
+               if ( ! in_array('calendar_lang'.EXT, $this->CI->lang->is_loaded, TRUE))
+               {
+                       $this->CI->lang->load('calendar');
+               }
+
+               $this->local_time = time();
+
+               if (count($config) > 0)
+               {
+                       $this->initialize($config);
+               }
+
+               log_message('debug', "Calendar Class Initialized");
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Initialize the user preferences
+        *
+        * Accepts an associative array as input, containing display preferences
+        *
+        * @access      public
+        * @param       array   config preferences
+        * @return      void
+        */
+       function initialize($config = array())
+       {
+               foreach ($config as $key => $val)
+               {
+                       if (isset($this->$key))
+                       {
+                               $this->$key = $val;
+                       }
+               }
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Generate the calendar
+        *
+        * @access      public
+        * @param       integer the year
+        * @param       integer the month
+        * @param       array   the data to be shown in the calendar cells
+        * @return      string
+        */
+       function generate($year = '', $month = '', $data = array())
+       {
+               // Set and validate the supplied month/year
+               if ($year == '')
+                       $year  = date("Y", $this->local_time);
+
+               if ($month == '')
+                       $month = date("m", $this->local_time);
+
+               if (strlen($year) == 1)
+                       $year = '200'.$year;
+
+               if (strlen($year) == 2)
+                       $year = '20'.$year;
+
+               if (strlen($month) == 1)
+                       $month = '0'.$month;
+
+               $adjusted_date = $this->adjust_date($month, $year);
+
+               $month  = $adjusted_date['month'];
+               $year   = $adjusted_date['year'];
+
+               // Determine the total days in the month
+               $total_days = $this->get_total_days($month, $year);
+
+               // Set the starting day of the week
+               $start_days     = array('sunday' => 0, 'monday' => 1, 'tuesday' => 2, 'wednesday' => 3, 'thursday' => 4, 'friday' => 5, 'saturday' => 6);
+               $start_day = ( ! isset($start_days[$this->start_day])) ? 0 : $start_days[$this->start_day];
+
+               // Set the starting day number
+               $local_date = mktime(12, 0, 0, $month, 1, $year);
+               $date = getdate($local_date);
+               $day  = $start_day + 1 - $date["wday"];
+
+               while ($day > 1)
+               {
+                       $day -= 7;
+               }
+
+               // Set the current month/year/day
+               // We use this to determine the "today" date
+               $cur_year       = date("Y", $this->local_time);
+               $cur_month      = date("m", $this->local_time);
+               $cur_day        = date("j", $this->local_time);
+
+               $is_current_month = ($cur_year == $year AND $cur_month == $month) ? TRUE : FALSE;
+
+               // Generate the template data array
+               $this->parse_template();
+
+               // Begin building the calendar output
+               $out = $this->temp['table_open'];
+               $out .= "\n";
+
+               $out .= "\n";
+               $out .= $this->temp['heading_row_start'];
+               $out .= "\n";
+
+               // "previous" month link
+               if ($this->show_next_prev == TRUE)
+               {
+                       // Add a trailing slash to the  URL if needed
+                       $this->next_prev_url = preg_replace("/(.+?)\/*$/", "\\1/",  $this->next_prev_url);
+
+                       $adjusted_date = $this->adjust_date($month - 1, $year);
+                       $out .= str_replace('{previous_url}', $this->next_prev_url.$adjusted_date['year'].'/'.$adjusted_date['month'], $this->temp['heading_previous_cell']);
+                       $out .= "\n";
+               }
+
+               // Heading containing the month/year
+               $colspan = ($this->show_next_prev == TRUE) ? 5 : 7;
+
+               $this->temp['heading_title_cell'] = str_replace('{colspan}', $colspan, $this->temp['heading_title_cell']);
+               $this->temp['heading_title_cell'] = str_replace('{heading}', $this->get_month_name($month)."&nbsp;".$year, $this->temp['heading_title_cell']);
+
+               $out .= $this->temp['heading_title_cell'];
+               $out .= "\n";
+
+               // "next" month link
+               if ($this->show_next_prev == TRUE)
+               {
+                       $adjusted_date = $this->adjust_date($month + 1, $year);
+                       $out .= str_replace('{next_url}', $this->next_prev_url.$adjusted_date['year'].'/'.$adjusted_date['month'], $this->temp['heading_next_cell']);
+               }
+
+               $out .= "\n";
+               $out .= $this->temp['heading_row_end'];
+               $out .= "\n";
+
+               // Write the cells containing the days of the week
+               $out .= "\n";
+               $out .= $this->temp['week_row_start'];
+               $out .= "\n";
+
+               $day_names = $this->get_day_names();
+
+               for ($i = 0; $i < 7; $i ++)
+               {
+                       $out .= str_replace('{week_day}', $day_names[($start_day + $i) %7], $this->temp['week_day_cell']);
+               }
+
+               $out .= "\n";
+               $out .= $this->temp['week_row_end'];
+               $out .= "\n";
+
+               // Build the main body of the calendar
+               while ($day <= $total_days)
+               {
+                       $out .= "\n";
+                       $out .= $this->temp['cal_row_start'];
+                       $out .= "\n";
+
+                       for ($i = 0; $i < 7; $i++)
+                       {
+                               $out .= ($is_current_month == TRUE AND $day == $cur_day) ? $this->temp['cal_cell_start_today'] : $this->temp['cal_cell_start'];
+
+                               if ($day > 0 AND $day <= $total_days)
+                               {
+                                       if (isset($data[$day]))
+                                       {
+                                               // Cells with content
+                                               $temp = ($is_current_month == TRUE AND $day == $cur_day) ? $this->temp['cal_cell_content_today'] : $this->temp['cal_cell_content'];
+                                               $out .= str_replace('{day}', $day, str_replace('{content}', $data[$day], $temp));
+                                       }
+                                       else
+                                       {
+                                               // Cells with no content
+                                               $temp = ($is_current_month == TRUE AND $day == $cur_day) ? $this->temp['cal_cell_no_content_today'] : $this->temp['cal_cell_no_content'];
+                                               $out .= str_replace('{day}', $day, $temp);
+                                       }
+                               }
+                               else
+                               {
+                                       // Blank cells
+                                       $out .= $this->temp['cal_cell_blank'];
+                               }
+
+                               $out .= ($is_current_month == TRUE AND $day == $cur_day) ? $this->temp['cal_cell_end_today'] : $this->temp['cal_cell_end'];                                     
+                               $day++;
+                       }
+
+                       $out .= "\n";
+                       $out .= $this->temp['cal_row_end'];
+                       $out .= "\n";
+               }
+
+               $out .= "\n";
+               $out .= $this->temp['table_close'];
+
+               return $out;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Get Month Name
+        *
+        * Generates a textual month name based on the numeric
+        * month provided.
+        *
+        * @access      public
+        * @param       integer the month
+        * @return      string
+        */
+       function get_month_name($month)
+       {
+               if ($this->month_type == 'short')
+               {
+                       $month_names = array('01' => 'cal_jan', '02' => 'cal_feb', '03' => 'cal_mar', '04' => 'cal_apr', '05' => 'cal_may', '06' => 'cal_jun', '07' => 'cal_jul', '08' => 'cal_aug', '09' => 'cal_sep', '10' => 'cal_oct', '11' => 'cal_nov', '12' => 'cal_dec');
+               }
+               else
+               {
+                       $month_names = array('01' => 'cal_january', '02' => 'cal_february', '03' => 'cal_march', '04' => 'cal_april', '05' => 'cal_mayl', '06' => 'cal_june', '07' => 'cal_july', '08' => 'cal_august', '09' => 'cal_september', '10' => 'cal_october', '11' => 'cal_november', '12' => 'cal_december');
+               }
+
+               $month = $month_names[$month];
+
+               if ($this->CI->lang->line($month) === FALSE)
+               {
+                       return ucfirst(str_replace('cal_', '', $month));
+               }
+
+               return $this->CI->lang->line($month);
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Get Day Names
+        *
+        * Returns an array of day names (Sunday, Monday, etc.) based
+        * on the type.  Options: long, short, abrev
+        *
+        * @access      public
+        * @param       string
+        * @return      array
+        */
+       function get_day_names($day_type = '')
+       {
+               if ($day_type != '')
+                       $this->day_type = $day_type;
+
+               if ($this->day_type == 'long')
+               {
+                       $day_names = array('sunday', 'monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday');
+               }
+               elseif ($this->day_type == 'short')
+               {
+                       $day_names = array('sun', 'mon', 'tue', 'wed', 'thu', 'fri', 'sat');
+               }
+               else
+               {
+                       $day_names = array('su', 'mo', 'tu', 'we', 'th', 'fr', 'sa');
+               }
+
+               $days = array();
+               foreach ($day_names as $val)
+               {
+                       $days[] = ($this->CI->lang->line('cal_'.$val) === FALSE) ? ucfirst($val) : $this->CI->lang->line('cal_'.$val);
+               }
+
+               return $days;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Adjust Date
+        *
+        * This function makes sure that we have a valid month/year.
+        * For example, if you submit 13 as the month, the year will
+        * increment and the month will become January.
+        *
+        * @access      public
+        * @param       integer the month
+        * @param       integer the year
+        * @return      array
+        */
+       function adjust_date($month, $year)
+       {
+               $date = array();
+
+               $date['month']  = $month;
+               $date['year']   = $year;
+
+               while ($date['month'] > 12)
+               {
+                       $date['month'] -= 12;
+                       $date['year']++;
+               }
+
+               while ($date['month'] <= 0)
+               {
+                       $date['month'] += 12;
+                       $date['year']--;
+               }
+
+               if (strlen($date['month']) == 1)
+               {
+                       $date['month'] = '0'.$date['month'];
+               }
+
+               return $date;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Total days in a given month
+        *
+        * @access      public
+        * @param       integer the month
+        * @param       integer the year
+        * @return      integer
+        */
+       function get_total_days($month, $year)
+       {
+               $days_in_month  = array(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
+
+               if ($month < 1 OR $month > 12)
+               {
+                       return 0;
+               }
+
+               // Is the year a leap year?
+               if ($month == 2)
+               {
+                       if ($year % 400 == 0 OR ($year % 4 == 0 AND $year % 100 != 0))
+                       {
+                               return 29;
+                       }
+               }
+
+               return $days_in_month[$month - 1];
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Set Default Template Data
+        *
+        * This is used in the event that the user has not created their own template
+        *
+        * @access      public
+        * @return array
+        */
+       function default_template()
+       {
+               return  array (
+                                               'table_open'                            => '<table border="0" cellpadding="4" cellspacing="0">',
+                                               'heading_row_start'                     => '<tr>',
+                                               'heading_previous_cell'         => '<th><a href="{previous_url}">&lt;&lt;</a></th>',
+                                               'heading_title_cell'            => '<th colspan="{colspan}">{heading}</th>',
+                                               'heading_next_cell'                     => '<th><a href="{next_url}">&gt;&gt;</a></th>',
+                                               'heading_row_end'                       => '</tr>',
+                                               'week_row_start'                        => '<tr>',
+                                               'week_day_cell'                         => '<td>{week_day}</td>',
+                                               'week_row_end'                          => '</tr>',
+                                               'cal_row_start'                         => '<tr>',
+                                               'cal_cell_start'                        => '<td>',
+                                               'cal_cell_start_today'          => '<td>',
+                                               'cal_cell_content'                      => '<a href="{content}">{day}</a>',
+                                               'cal_cell_content_today'        => '<a href="{content}"><strong>{day}</strong></a>',
+                                               'cal_cell_no_content'           => '{day}',
+                                               'cal_cell_no_content_today'     => '<strong>{day}</strong>',
+                                               'cal_cell_blank'                        => '&nbsp;',
+                                               'cal_cell_end'                          => '</td>',
+                                               'cal_cell_end_today'            => '</td>',
+                                               'cal_row_end'                           => '</tr>',
+                                               'table_close'                           => '</table>'
+                                       );
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Parse Template
+        *
+        * Harvests the data within the template {pseudo-variables}
+        * used to display the calendar
+        *
+        * @access      public
+        * @return      void
+        */
+       function parse_template()
+       {
+               $this->temp = $this->default_template();
+
+               if ($this->template == '')
+               {
+                       return;
+               }
+
+               $today = array('cal_cell_start_today', 'cal_cell_content_today', 'cal_cell_no_content_today', 'cal_cell_end_today');
+
+               foreach (array('table_open', 'table_close', 'heading_row_start', 'heading_previous_cell', 'heading_title_cell', 'heading_next_cell', 'heading_row_end', 'week_row_start', 'week_day_cell', 'week_row_end', 'cal_row_start', 'cal_cell_start', 'cal_cell_content', 'cal_cell_no_content',  'cal_cell_blank', 'cal_cell_end', 'cal_row_end', 'cal_cell_start_today', 'cal_cell_content_today', 'cal_cell_no_content_today', 'cal_cell_end_today') as $val)
+               {
+                       if (preg_match("/\{".$val."\}(.*?)\{\/".$val."\}/si", $this->template, $match))
+                       {
+                               $this->temp[$val] = $match['1'];
+                       }
+                       else
+                       {
+                               if (in_array($val, $today, TRUE))
+                               {
+                                       $this->temp[$val] = $this->temp[str_replace('_today', '', $val)];
+                               }
+                       }
+               }
+       }
+
+}
+
+// END CI_Calendar class
+
+/* End of file Calendar.php */
+/* Location: ./system/libraries/Calendar.php */
\ No newline at end of file
diff --git a/system/libraries/Cart.php b/system/libraries/Cart.php
new file mode 100755 (executable)
index 0000000..7f65b48
--- /dev/null
@@ -0,0 +1,550 @@
+<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+/**
+ * CodeIgniter
+ *
+ * An open source application development framework for PHP 5.1.6 or newer
+ *
+ * @package            CodeIgniter
+ * @author             ExpressionEngine Dev Team
+ * @copyright  Copyright (c) 2006 - 2011, EllisLab, Inc.
+ * @license            http://codeigniter.com/user_guide/license.html
+ * @link               http://codeigniter.com
+ * @since              Version 1.0
+ * @filesource
+ */
+
+// ------------------------------------------------------------------------
+
+/**
+ * Shopping Cart Class
+ *
+ * @package            CodeIgniter
+ * @subpackage Libraries
+ * @category   Shopping Cart
+ * @author             ExpressionEngine Dev Team
+ * @link               http://codeigniter.com/user_guide/libraries/cart.html
+ */
+class CI_Cart {
+
+       // These are the regular expression rules that we use to validate the product ID and product name
+       var $product_id_rules   = '\.a-z0-9_-'; // alpha-numeric, dashes, underscores, or periods
+       var $product_name_rules = '\.\:\-_ a-z0-9'; // alpha-numeric, dashes, underscores, colons or periods
+
+       // Private variables.  Do not change!
+       var $CI;
+       var $_cart_contents     = array();
+
+
+       /**
+        * Shopping Class Constructor
+        *
+        * The constructor loads the Session class, used to store the shopping cart contents.
+        */
+       public function __construct($params = array())
+       {
+               // Set the super object to a local variable for use later
+               $this->CI =& get_instance();
+
+               // Are any config settings being passed manually?  If so, set them
+               $config = array();
+               if (count($params) > 0)
+               {
+                       foreach ($params as $key => $val)
+                       {
+                               $config[$key] = $val;
+                       }
+               }
+
+               // Load the Sessions class
+               $this->CI->load->library('session', $config);
+
+               // Grab the shopping cart array from the session table, if it exists
+               if ($this->CI->session->userdata('cart_contents') !== FALSE)
+               {
+                       $this->_cart_contents = $this->CI->session->userdata('cart_contents');
+               }
+               else
+               {
+                       // No cart exists so we'll set some base values
+                       $this->_cart_contents['cart_total'] = 0;
+                       $this->_cart_contents['total_items'] = 0;
+               }
+
+               log_message('debug', "Cart Class Initialized");
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Insert items into the cart and save it to the session table
+        *
+        * @access      public
+        * @param       array
+        * @return      bool
+        */
+       function insert($items = array())
+       {
+               // Was any cart data passed? No? Bah...
+               if ( ! is_array($items) OR count($items) == 0)
+               {
+                       log_message('error', 'The insert method must be passed an array containing data.');
+                       return FALSE;
+               }
+
+               // You can either insert a single product using a one-dimensional array,
+               // or multiple products using a multi-dimensional one. The way we
+               // determine the array type is by looking for a required array key named "id"
+               // at the top level. If it's not found, we will assume it's a multi-dimensional array.
+
+               $save_cart = FALSE;
+               if (isset($items['id']))
+               {
+                       if ($this->_insert($items) == TRUE)
+                       {
+                               $save_cart = TRUE;
+                       }
+               }
+               else
+               {
+                       foreach ($items as $val)
+                       {
+                               if (is_array($val) AND isset($val['id']))
+                               {
+                                       if ($this->_insert($val) == TRUE)
+                                       {
+                                               $save_cart = TRUE;
+                                       }
+                               }
+                       }
+               }
+
+               // Save the cart data if the insert was successful
+               if ($save_cart == TRUE)
+               {
+                       $this->_save_cart();
+                       return TRUE;
+               }
+
+               return FALSE;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Insert
+        *
+        * @access      private
+        * @param       array
+        * @return      bool
+        */
+       function _insert($items = array())
+       {
+               // Was any cart data passed? No? Bah...
+               if ( ! is_array($items) OR count($items) == 0)
+               {
+                       log_message('error', 'The insert method must be passed an array containing data.');
+                       return FALSE;
+               }
+
+               // --------------------------------------------------------------------
+
+               // Does the $items array contain an id, quantity, price, and name?  These are required
+               if ( ! isset($items['id']) OR ! isset($items['qty']) OR ! isset($items['price']) OR ! isset($items['name']))
+               {
+                       log_message('error', 'The cart array must contain a product ID, quantity, price, and name.');
+                       return FALSE;
+               }
+
+               // --------------------------------------------------------------------
+
+               // Prep the quantity. It can only be a number.  Duh...
+               $items['qty'] = trim(preg_replace('/([^0-9])/i', '', $items['qty']));
+               // Trim any leading zeros
+               $items['qty'] = trim(preg_replace('/(^[0]+)/i', '', $items['qty']));
+
+               // If the quantity is zero or blank there's nothing for us to do
+               if ( ! is_numeric($items['qty']) OR $items['qty'] == 0)
+               {
+                       return FALSE;
+               }
+
+               // --------------------------------------------------------------------
+
+               // Validate the product ID. It can only be alpha-numeric, dashes, underscores or periods
+               // Not totally sure we should impose this rule, but it seems prudent to standardize IDs.
+               // Note: These can be user-specified by setting the $this->product_id_rules variable.
+               if ( ! preg_match("/^[".$this->product_id_rules."]+$/i", $items['id']))
+               {
+                       log_message('error', 'Invalid product ID.  The product ID can only contain alpha-numeric characters, dashes, and underscores');
+                       return FALSE;
+               }
+
+               // --------------------------------------------------------------------
+
+               // Validate the product name. It can only be alpha-numeric, dashes, underscores, colons or periods.
+               // Note: These can be user-specified by setting the $this->product_name_rules variable.
+               if ( ! preg_match("/^[".$this->product_name_rules."]+$/i", $items['name']))
+               {
+                       log_message('error', 'An invalid name was submitted as the product name: '.$items['name'].' The name can only contain alpha-numeric characters, dashes, underscores, colons, and spaces');
+                       return FALSE;
+               }
+
+               // --------------------------------------------------------------------
+
+               // Prep the price.  Remove anything that isn't a number or decimal point.
+               $items['price'] = trim(preg_replace('/([^0-9\.])/i', '', $items['price']));
+               // Trim any leading zeros
+               $items['price'] = trim(preg_replace('/(^[0]+)/i', '', $items['price']));
+
+               // Is the price a valid number?
+               if ( ! is_numeric($items['price']))
+               {
+                       log_message('error', 'An invalid price was submitted for product ID: '.$items['id']);
+                       return FALSE;
+               }
+
+               // --------------------------------------------------------------------
+
+               // We now need to create a unique identifier for the item being inserted into the cart.
+               // Every time something is added to the cart it is stored in the master cart array.
+               // Each row in the cart array, however, must have a unique index that identifies not only
+               // a particular product, but makes it possible to store identical products with different options.
+               // For example, what if someone buys two identical t-shirts (same product ID), but in
+               // different sizes?  The product ID (and other attributes, like the name) will be identical for
+               // both sizes because it's the same shirt. The only difference will be the size.
+               // Internally, we need to treat identical submissions, but with different options, as a unique product.
+               // Our solution is to convert the options array to a string and MD5 it along with the product ID.
+               // This becomes the unique "row ID"
+               if (isset($items['options']) AND count($items['options']) > 0)
+               {
+                       $rowid = md5($items['id'].implode('', $items['options']));
+               }
+               else
+               {
+                       // No options were submitted so we simply MD5 the product ID.
+                       // Technically, we don't need to MD5 the ID in this case, but it makes
+                       // sense to standardize the format of array indexes for both conditions
+                       $rowid = md5($items['id']);
+               }
+
+               // --------------------------------------------------------------------
+
+               // Now that we have our unique "row ID", we'll add our cart items to the master array
+
+               // let's unset this first, just to make sure our index contains only the data from this submission
+               unset($this->_cart_contents[$rowid]);
+
+               // Create a new index with our new row ID
+               $this->_cart_contents[$rowid]['rowid'] = $rowid;
+
+               // And add the new items to the cart array
+               foreach ($items as $key => $val)
+               {
+                       $this->_cart_contents[$rowid][$key] = $val;
+               }
+
+               // Woot!
+               return TRUE;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Update the cart
+        *
+        * This function permits the quantity of a given item to be changed.
+        * Typically it is called from the "view cart" page if a user makes
+        * changes to the quantity before checkout. That array must contain the
+        * product ID and quantity for each item.
+        *
+        * @access      public
+        * @param       array
+        * @param       string
+        * @return      bool
+        */
+       function update($items = array())
+       {
+               // Was any cart data passed?
+               if ( ! is_array($items) OR count($items) == 0)
+               {
+                       return FALSE;
+               }
+
+               // You can either update a single product using a one-dimensional array,
+               // or multiple products using a multi-dimensional one.  The way we
+               // determine the array type is by looking for a required array key named "id".
+               // If it's not found we assume it's a multi-dimensional array
+               $save_cart = FALSE;
+               if (isset($items['rowid']) AND isset($items['qty']))
+               {
+                       if ($this->_update($items) == TRUE)
+                       {
+                               $save_cart = TRUE;
+                       }
+               }
+               else
+               {
+                       foreach ($items as $val)
+                       {
+                               if (is_array($val) AND isset($val['rowid']) AND isset($val['qty']))
+                               {
+                                       if ($this->_update($val) == TRUE)
+                                       {
+                                               $save_cart = TRUE;
+                                       }
+                               }
+                       }
+               }
+
+               // Save the cart data if the insert was successful
+               if ($save_cart == TRUE)
+               {
+                       $this->_save_cart();
+                       return TRUE;
+               }
+
+               return FALSE;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Update the cart
+        *
+        * This function permits the quantity of a given item to be changed.
+        * Typically it is called from the "view cart" page if a user makes
+        * changes to the quantity before checkout. That array must contain the
+        * product ID and quantity for each item.
+        *
+        * @access      private
+        * @param       array
+        * @return      bool
+        */
+       function _update($items = array())
+       {
+               // Without these array indexes there is nothing we can do
+               if ( ! isset($items['qty']) OR ! isset($items['rowid']) OR ! isset($this->_cart_contents[$items['rowid']]))
+               {
+                       return FALSE;
+               }
+
+               // Prep the quantity
+               $items['qty'] = preg_replace('/([^0-9])/i', '', $items['qty']);
+
+               // Is the quantity a number?
+               if ( ! is_numeric($items['qty']))
+               {
+                       return FALSE;
+               }
+
+               // Is the new quantity different than what is already saved in the cart?
+               // If it's the same there's nothing to do
+               if ($this->_cart_contents[$items['rowid']]['qty'] == $items['qty'])
+               {
+                       return FALSE;
+               }
+
+               // Is the quantity zero?  If so we will remove the item from the cart.
+               // If the quantity is greater than zero we are updating
+               if ($items['qty'] == 0)
+               {
+                       unset($this->_cart_contents[$items['rowid']]);
+               }
+               else
+               {
+                       $this->_cart_contents[$items['rowid']]['qty'] = $items['qty'];
+               }
+
+               return TRUE;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Save the cart array to the session DB
+        *
+        * @access      private
+        * @return      bool
+        */
+       function _save_cart()
+       {
+               // Unset these so our total can be calculated correctly below
+               unset($this->_cart_contents['total_items']);
+               unset($this->_cart_contents['cart_total']);
+
+               // Lets add up the individual prices and set the cart sub-total
+               $total = 0;
+               foreach ($this->_cart_contents as $key => $val)
+               {
+                       // We make sure the array contains the proper indexes
+                       if ( ! is_array($val) OR ! isset($val['price']) OR ! isset($val['qty']))
+                       {
+                               continue;
+                       }
+
+                       $total += ($val['price'] * $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['cart_total'] = $total;
+
+               // Is our cart empty?  If so we delete it from the session
+               if (count($this->_cart_contents) <= 2)
+               {
+                       $this->CI->session->unset_userdata('cart_contents');
+
+                       // Nothing more to do... coffee time!
+                       return FALSE;
+               }
+
+               // If we made it this far it means that our cart has data.
+               // Let's pass it to the Session class so it can be stored
+               $this->CI->session->set_userdata(array('cart_contents' => $this->_cart_contents));
+
+               // Woot!
+               return TRUE;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Cart Total
+        *
+        * @access      public
+        * @return      integer
+        */
+       function total()
+       {
+               return $this->_cart_contents['cart_total'];
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Total Items
+        *
+        * Returns the total item count
+        *
+        * @access      public
+        * @return      integer
+        */
+       function total_items()
+       {
+               return $this->_cart_contents['total_items'];
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Cart Contents
+        *
+        * Returns the entire cart array
+        *
+        * @access      public
+        * @return      array
+        */
+       function contents()
+       {
+               $cart = $this->_cart_contents;
+
+               // Remove these so they don't create a problem when showing the cart table
+               unset($cart['total_items']);
+               unset($cart['cart_total']);
+
+               return $cart;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Has options
+        *
+        * Returns TRUE if the rowid passed to this function correlates to an item
+        * that has options associated with it.
+        *
+        * @access      public
+        * @return      array
+        */
+       function has_options($rowid = '')
+       {
+               if ( ! isset($this->_cart_contents[$rowid]['options']) OR count($this->_cart_contents[$rowid]['options']) === 0)
+               {
+                       return FALSE;
+               }
+
+               return TRUE;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Product options
+        *
+        * Returns the an array of options, for a particular product row ID
+        *
+        * @access      public
+        * @return      array
+        */
+       function product_options($rowid = '')
+       {
+               if ( ! isset($this->_cart_contents[$rowid]['options']))
+               {
+                       return array();
+               }
+
+               return $this->_cart_contents[$rowid]['options'];
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Format Number
+        *
+        * Returns the supplied number with commas and a decimal point.
+        *
+        * @access      public
+        * @return      integer
+        */
+       function format_number($n = '')
+       {
+               if ($n == '')
+               {
+                       return '';
+               }
+
+               // Remove anything that isn't a number or decimal point.
+               $n = trim(preg_replace('/([^0-9\.])/i', '', $n));
+
+               return number_format($n, 2, '.', ',');
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Destroy the cart
+        *
+        * Empties the cart and kills the session
+        *
+        * @access      public
+        * @return      null
+        */
+       function destroy()
+       {
+               unset($this->_cart_contents);
+
+               $this->_cart_contents['cart_total'] = 0;
+               $this->_cart_contents['total_items'] = 0;
+
+               $this->CI->session->unset_userdata('cart_contents');
+       }
+
+
+}
+// END Cart Class
+
+/* End of file Cart.php */
+/* Location: ./system/libraries/Cart.php */
\ No newline at end of file
diff --git a/system/libraries/Driver.php b/system/libraries/Driver.php
new file mode 100755 (executable)
index 0000000..d1838f2
--- /dev/null
@@ -0,0 +1,229 @@
+<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+/**
+ * CodeIgniter
+ *
+ * An open source application development framework for PHP 5.1.6 or newer
+ *
+ * @package            CodeIgniter
+ * @author             EllisLab Dev Team
+ * @copyright  Copyright (c) 2006 - 2011, EllisLab, Inc.
+ * @license            http://codeigniter.com/user_guide/license.html
+ * @link               http://codeigniter.com
+ * @since              Version 1.0
+ * @filesource
+ */
+
+// ------------------------------------------------------------------------
+
+/**
+ * CodeIgniter Driver Library Class
+ *
+ * This class enables you to create "Driver" libraries that add runtime ability
+ * to extend the capabilities of a class via additional driver objects
+ *
+ * @package            CodeIgniter
+ * @subpackage Libraries
+ * @category   Libraries
+ * @author             EllisLab Dev Team
+ * @link
+ */
+class CI_Driver_Library {
+
+       protected $valid_drivers        = array();
+       protected static $lib_name;
+
+       // The first time a child is used it won't exist, so we instantiate it
+       // subsequents calls will go straight to the proper child.
+       function __get($child)
+       {
+               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;
+
+               // Remove the CI_ prefix and lowercase
+               $lib_name = strtolower(preg_replace('/^CI_/', '', $this->lib_name));
+               $driver_name = strtolower(preg_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))
+                       {
+                               // check application path first
+                               foreach (array(APPPATH, BASEPATH) as $path)
+                               {
+                                       // loves me some nesting!
+                                       foreach (array(ucfirst($driver_name), $driver_name) as $class)
+                                       {
+                                               $filepath = $path.'libraries/'.$lib_name.'/drivers/'.$class.EXT;
+
+                                               if (file_exists($filepath))
+                                               {
+                                                       include_once $filepath;
+                                                       break;
+                                               }
+                                       }
+                               }
+
+                               // it's a valid driver, but the file simply can't be found
+                               if ( ! class_exists($child_class))
+                               {
+                                       log_message('error', "Unable to load the requested driver: ".$child_class);
+                                       show_error("Unable to load the requested driver: ".$child_class);
+                               }
+                       }
+
+                       $obj = new $child_class;
+                       $obj->decorate($this);
+                       $this->$child = $obj;
+                       return $this->$child;
+               }
+
+               // The requested driver isn't valid!
+               log_message('error', "Invalid driver requested: ".$child_class);
+               show_error("Invalid driver requested: ".$child_class);
+       }
+
+       // --------------------------------------------------------------------
+
+}
+// END CI_Driver_Library CLASS
+
+
+/**
+ * CodeIgniter Driver Class
+ *
+ * This class enables you to create drivers for a Library based on the Driver Library.
+ * It handles the drivers' access to the parent library
+ *
+ * @package            CodeIgniter
+ * @subpackage Libraries
+ * @category   Libraries
+ * @author             EllisLab Dev Team
+ * @link
+ */
+class CI_Driver {
+       protected $parent;
+
+       private $methods = array();
+       private $properties = array();
+
+       private static $reflections = array();
+
+       /**
+        * Decorate
+        *
+        * Decorates the child with the parent driver lib's methods and properties
+        *
+        * @param       object
+        * @return      void
+        */
+       public function decorate($parent)
+       {
+               $this->parent = $parent;
+
+               // Lock down attributes to what is defined in the class
+               // and speed up references in magic methods
+
+               $class_name = get_class($parent);
+
+               if ( ! isset(self::$reflections[$class_name]))
+               {
+                       $r = new ReflectionObject($parent);
+
+                       foreach ($r->getMethods() as $method)
+                       {
+                               if ($method->isPublic())
+                               {
+                                       $this->methods[] = $method->getName();
+                               }
+                       }
+
+                       foreach ($r->getProperties() as $prop)
+                       {
+                               if ($prop->isPublic())
+                               {
+                                       $this->properties[] = $prop->getName();
+                               }
+                       }
+
+                       self::$reflections[$class_name] = array($this->methods, $this->properties);
+               }
+               else
+               {
+                       list($this->methods, $this->properties) = self::$reflections[$class_name];
+               }
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * __call magic method
+        *
+        * Handles access to the parent driver library's methods
+        *
+        * @access      public
+        * @param       string
+        * @param       array
+        * @return      mixed
+        */
+       public function __call($method, $args = array())
+       {
+               if (in_array($method, $this->methods))
+               {
+                       return call_user_func_array(array($this->parent, $method), $args);
+               }
+
+               $trace = debug_backtrace();
+               _exception_handler(E_ERROR, "No such method '{$method}'", $trace[1]['file'], $trace[1]['line']);
+               exit;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * __get magic method
+        *
+        * Handles reading of the parent driver library's properties
+        *
+        * @param       string
+        * @return      mixed
+        */
+       public function __get($var)
+       {
+               if (in_array($var, $this->properties))
+               {
+                       return $this->parent->$var;
+               }
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * __set magic method
+        *
+        * Handles writing to the parent driver library's properties
+        *
+        * @param       string
+        * @param       array
+        * @return      mixed
+        */
+       public function __set($var, $val)
+       {
+               if (in_array($var, $this->properties))
+               {
+                       $this->parent->$var = $val;
+               }
+       }
+
+       // --------------------------------------------------------------------
+
+}
+// END CI_Driver CLASS
+
+/* End of file Driver.php */
+/* Location: ./system/libraries/Driver.php */
\ No newline at end of file
diff --git a/system/libraries/Email.php b/system/libraries/Email.php
new file mode 100755 (executable)
index 0000000..6c21f11
--- /dev/null
@@ -0,0 +1,2062 @@
+<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+/**
+ * CodeIgniter
+ *
+ * An open source application development framework for PHP 5.1.6 or newer
+ *
+ * @package            CodeIgniter
+ * @author             ExpressionEngine Dev Team
+ * @copyright  Copyright (c) 2008 - 2011, EllisLab, Inc.
+ * @license            http://codeigniter.com/user_guide/license.html
+ * @link               http://codeigniter.com
+ * @since              Version 1.0
+ * @filesource
+ */
+
+// ------------------------------------------------------------------------
+
+/**
+ * CodeIgniter Email Class
+ *
+ * Permits email to be sent using Mail, Sendmail, or SMTP.
+ *
+ * @package            CodeIgniter
+ * @subpackage Libraries
+ * @category   Libraries
+ * @author             ExpressionEngine Dev Team
+ * @link               http://codeigniter.com/user_guide/libraries/email.html
+ */
+class CI_Email {
+
+       var     $useragent              = "CodeIgniter";
+       var     $mailpath               = "/usr/sbin/sendmail"; // Sendmail path
+       var     $protocol               = "mail";       // mail/sendmail/smtp
+       var     $smtp_host              = "";           // SMTP Server.  Example: mail.earthlink.net
+       var     $smtp_user              = "";           // SMTP Username
+       var     $smtp_pass              = "";           // SMTP Password
+       var     $smtp_port              = "25";         // SMTP Port
+       var     $smtp_timeout   = 5;            // SMTP Timeout in seconds
+       var     $wordwrap               = TRUE;         // TRUE/FALSE  Turns word-wrap on/off
+       var     $wrapchars              = "76";         // Number of characters to wrap at.
+       var     $mailtype               = "text";       // text/html  Defines email formatting
+       var     $charset                = "utf-8";      // Default char set: iso-8859-1 or us-ascii
+       var     $multipart              = "mixed";      // "mixed" (in the body) or "related" (separate)
+       var $alt_message        = '';           // Alternative message for HTML emails
+       var     $validate               = FALSE;        // TRUE/FALSE.  Enables email validation
+       var     $priority               = "3";          // Default priority (1 - 5)
+       var     $newline                = "\n";         // Default newline. "\r\n" or "\n" (Use "\r\n" to comply with RFC 822)
+       var $crlf                       = "\n";         // The RFC 2045 compliant CRLF for quoted-printable is "\r\n".  Apparently some servers,
+                                                                       // even on the receiving end think they need to muck with CRLFs, so using "\n", while
+                                                                       // distasteful, is the only thing that seems to work for all environments.
+       var $send_multipart     = TRUE;         // TRUE/FALSE - Yahoo does not like multipart alternative, so this is an override.  Set to FALSE for Yahoo.
+       var     $bcc_batch_mode = FALSE;        // TRUE/FALSE  Turns on/off Bcc batch feature
+       var     $bcc_batch_size = 200;          // If bcc_batch_mode = TRUE, sets max number of Bccs in each batch
+       var $_safe_mode         = FALSE;
+       var     $_subject               = "";
+       var     $_body                  = "";
+       var     $_finalbody             = "";
+       var     $_alt_boundary  = "";
+       var     $_atc_boundary  = "";
+       var     $_header_str    = "";
+       var     $_smtp_connect  = "";
+       var     $_encoding              = "8bit";
+       var $_IP                        = FALSE;
+       var     $_smtp_auth             = FALSE;
+       var $_replyto_flag      = FALSE;
+       var     $_debug_msg             = array();
+       var     $_recipients    = array();
+       var     $_cc_array              = array();
+       var     $_bcc_array             = array();
+       var     $_headers               = array();
+       var     $_attach_name   = array();
+       var     $_attach_type   = array();
+       var     $_attach_disp   = array();
+       var     $_protocols             = array('mail', 'sendmail', 'smtp');
+       var     $_base_charsets = array('us-ascii', 'iso-2022-');       // 7-bit charsets (excluding language suffix)
+       var     $_bit_depths    = array('7bit', '8bit');
+       var     $_priorities    = array('1 (Highest)', '2 (High)', '3 (Normal)', '4 (Low)', '5 (Lowest)');
+
+
+       /**
+        * Constructor - Sets Email Preferences
+        *
+        * The constructor can be passed an array of config values
+        */
+       public function __construct($config = array())
+       {
+               if (count($config) > 0)
+               {
+                       $this->initialize($config);
+               }
+               else
+               {
+                       $this->_smtp_auth = ($this->smtp_user == '' AND $this->smtp_pass == '') ? FALSE : TRUE;
+                       $this->_safe_mode = ((boolean)@ini_get("safe_mode") === FALSE) ? FALSE : TRUE;
+               }
+
+               log_message('debug', "Email Class Initialized");
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Initialize preferences
+        *
+        * @access      public
+        * @param       array
+        * @return      void
+        */
+       public function initialize($config = array())
+       {
+               foreach ($config as $key => $val)
+               {
+                       if (isset($this->$key))
+                       {
+                               $method = 'set_'.$key;
+
+                               if (method_exists($this, $method))
+                               {
+                                       $this->$method($val);
+                               }
+                               else
+                               {
+                                       $this->$key = $val;
+                               }
+                       }
+               }
+               $this->clear();
+
+               $this->_smtp_auth = ($this->smtp_user == '' AND $this->smtp_pass == '') ? FALSE : TRUE;
+               $this->_safe_mode = ((boolean)@ini_get("safe_mode") === FALSE) ? FALSE : TRUE;
+
+               return $this;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Initialize the Email Data
+        *
+        * @access      public
+        * @return      void
+        */
+       public function clear($clear_attachments = FALSE)
+       {
+               $this->_subject         = "";
+               $this->_body            = "";
+               $this->_finalbody       = "";
+               $this->_header_str      = "";
+               $this->_replyto_flag = FALSE;
+               $this->_recipients      = array();
+               $this->_cc_array        = array();
+               $this->_bcc_array       = array();
+               $this->_headers         = array();
+               $this->_debug_msg       = array();
+
+               $this->_set_header('User-Agent', $this->useragent);
+               $this->_set_header('Date', $this->_set_date());
+
+               if ($clear_attachments !== FALSE)
+               {
+                       $this->_attach_name = array();
+                       $this->_attach_type = array();
+                       $this->_attach_disp = array();
+               }
+
+               return $this;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Set FROM
+        *
+        * @access      public
+        * @param       string
+        * @param       string
+        * @return      void
+        */
+       public function from($from, $name = '')
+       {
+               if (preg_match( '/\<(.*)\>/', $from, $match))
+               {
+                       $from = $match['1'];
+               }
+
+               if ($this->validate)
+               {
+                       $this->validate_email($this->_str_to_array($from));
+               }
+
+               // prepare the display name
+               if ($name != '')
+               {
+                       // only use Q encoding if there are characters that would require it
+                       if ( ! preg_match('/[\200-\377]/', $name))
+                       {
+                               // add slashes for non-printing characters, slashes, and double quotes, and surround it in double quotes
+                               $name = '"'.addcslashes($name, "\0..\37\177'\"\\").'"';
+                       }
+                       else
+                       {
+                               $name = $this->_prep_q_encoding($name, TRUE);
+                       }
+               }
+
+               $this->_set_header('From', $name.' <'.$from.'>');
+               $this->_set_header('Return-Path', '<'.$from.'>');
+
+               return $this;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Set Reply-to
+        *
+        * @access      public
+        * @param       string
+        * @param       string
+        * @return      void
+        */
+       public function reply_to($replyto, $name = '')
+       {
+               if (preg_match( '/\<(.*)\>/', $replyto, $match))
+               {
+                       $replyto = $match['1'];
+               }
+
+               if ($this->validate)
+               {
+                       $this->validate_email($this->_str_to_array($replyto));
+               }
+
+               if ($name == '')
+               {
+                       $name = $replyto;
+               }
+
+               if (strncmp($name, '"', 1) != 0)
+               {
+                       $name = '"'.$name.'"';
+               }
+
+               $this->_set_header('Reply-To', $name.' <'.$replyto.'>');
+               $this->_replyto_flag = TRUE;
+
+               return $this;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Set Recipients
+        *
+        * @access      public
+        * @param       string
+        * @return      void
+        */
+       public function to($to)
+       {
+               $to = $this->_str_to_array($to);
+               $to = $this->clean_email($to);
+
+               if ($this->validate)
+               {
+                       $this->validate_email($to);
+               }
+
+               if ($this->_get_protocol() != 'mail')
+               {
+                       $this->_set_header('To', implode(", ", $to));
+               }
+
+               switch ($this->_get_protocol())
+               {
+                       case 'smtp'             :
+                               $this->_recipients = $to;
+                       break;
+                       case 'sendmail' :
+                       case 'mail'             :
+                               $this->_recipients = implode(", ", $to);
+                       break;
+               }
+
+               return $this;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Set CC
+        *
+        * @access      public
+        * @param       string
+        * @return      void
+        */
+       public function cc($cc)
+       {
+               $cc = $this->_str_to_array($cc);
+               $cc = $this->clean_email($cc);
+
+               if ($this->validate)
+               {
+                       $this->validate_email($cc);
+               }
+
+               $this->_set_header('Cc', implode(", ", $cc));
+
+               if ($this->_get_protocol() == "smtp")
+               {
+                       $this->_cc_array = $cc;
+               }
+
+               return $this;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Set BCC
+        *
+        * @access      public
+        * @param       string
+        * @param       string
+        * @return      void
+        */
+       public function bcc($bcc, $limit = '')
+       {
+               if ($limit != '' && is_numeric($limit))
+               {
+                       $this->bcc_batch_mode = TRUE;
+                       $this->bcc_batch_size = $limit;
+               }
+
+               $bcc = $this->_str_to_array($bcc);
+               $bcc = $this->clean_email($bcc);
+
+               if ($this->validate)
+               {
+                       $this->validate_email($bcc);
+               }
+
+               if (($this->_get_protocol() == "smtp") OR ($this->bcc_batch_mode && count($bcc) > $this->bcc_batch_size))
+               {
+                       $this->_bcc_array = $bcc;
+               }
+               else
+               {
+                       $this->_set_header('Bcc', implode(", ", $bcc));
+               }
+
+               return $this;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Set Email Subject
+        *
+        * @access      public
+        * @param       string
+        * @return      void
+        */
+       public function subject($subject)
+       {
+               $subject = $this->_prep_q_encoding($subject);
+               $this->_set_header('Subject', $subject);
+               return $this;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Set Body
+        *
+        * @access      public
+        * @param       string
+        * @return      void
+        */
+       public function message($body)
+       {
+               $this->_body = stripslashes(rtrim(str_replace("\r", "", $body)));
+               return $this;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Assign file attachments
+        *
+        * @access      public
+        * @param       string
+        * @return      void
+        */
+       public function attach($filename, $disposition = 'attachment')
+       {
+               $this->_attach_name[] = $filename;
+               $this->_attach_type[] = $this->_mime_types(next(explode('.', basename($filename))));
+               $this->_attach_disp[] = $disposition; // Can also be 'inline'  Not sure if it matters
+               return $this;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Add a Header Item
+        *
+        * @access      private
+        * @param       string
+        * @param       string
+        * @return      void
+        */
+       private function _set_header($header, $value)
+       {
+               $this->_headers[$header] = $value;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Convert a String to an Array
+        *
+        * @access      private
+        * @param       string
+        * @return      array
+        */
+       private function _str_to_array($email)
+       {
+               if ( ! is_array($email))
+               {
+                       if (strpos($email, ',') !== FALSE)
+                       {
+                               $email = preg_split('/[\s,]/', $email, -1, PREG_SPLIT_NO_EMPTY);
+                       }
+                       else
+                       {
+                               $email = trim($email);
+                               settype($email, "array");
+                       }
+               }
+               return $email;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Set Multipart Value
+        *
+        * @access      public
+        * @param       string
+        * @return      void
+        */
+       public function set_alt_message($str = '')
+       {
+               $this->alt_message = ($str == '') ? '' : $str;
+               return $this;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Set Mailtype
+        *
+        * @access      public
+        * @param       string
+        * @return      void
+        */
+       public function set_mailtype($type = 'text')
+       {
+               $this->mailtype = ($type == 'html') ? 'html' : 'text';
+               return $this;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Set Wordwrap
+        *
+        * @access      public
+        * @param       string
+        * @return      void
+        */
+       public function set_wordwrap($wordwrap = TRUE)
+       {
+               $this->wordwrap = ($wordwrap === FALSE) ? FALSE : TRUE;
+               return $this;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Set Protocol
+        *
+        * @access      public
+        * @param       string
+        * @return      void
+        */
+       public function set_protocol($protocol = 'mail')
+       {
+               $this->protocol = ( ! in_array($protocol, $this->_protocols, TRUE)) ? 'mail' : strtolower($protocol);
+               return $this;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Set Priority
+        *
+        * @access      public
+        * @param       integer
+        * @return      void
+        */
+       public function set_priority($n = 3)
+       {
+               if ( ! is_numeric($n))
+               {
+                       $this->priority = 3;
+                       return;
+               }
+
+               if ($n < 1 OR $n > 5)
+               {
+                       $this->priority = 3;
+                       return;
+               }
+
+               $this->priority = $n;
+               return $this;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Set Newline Character
+        *
+        * @access      public
+        * @param       string
+        * @return      void
+        */
+       public function set_newline($newline = "\n")
+       {
+               if ($newline != "\n" AND $newline != "\r\n" AND $newline != "\r")
+               {
+                       $this->newline  = "\n";
+                       return;
+               }
+
+               $this->newline  = $newline;
+
+               return $this;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Set CRLF
+        *
+        * @access      public
+        * @param       string
+        * @return      void
+        */
+       public function set_crlf($crlf = "\n")
+       {
+               if ($crlf != "\n" AND $crlf != "\r\n" AND $crlf != "\r")
+               {
+                       $this->crlf     = "\n";
+                       return;
+               }
+
+               $this->crlf     = $crlf;
+
+               return $this;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Set Message Boundary
+        *
+        * @access      private
+        * @return      void
+        */
+       private function _set_boundaries()
+       {
+               $this->_alt_boundary = "B_ALT_".uniqid(''); // multipart/alternative
+               $this->_atc_boundary = "B_ATC_".uniqid(''); // attachment boundary
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Get the Message ID
+        *
+        * @access      private
+        * @return      string
+        */
+       private function _get_message_id()
+       {
+               $from = $this->_headers['Return-Path'];
+               $from = str_replace(">", "", $from);
+               $from = str_replace("<", "", $from);
+
+               return  "<".uniqid('').strstr($from, '@').">";
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Get Mail Protocol
+        *
+        * @access      private
+        * @param       bool
+        * @return      string
+        */
+       private function _get_protocol($return = TRUE)
+       {
+               $this->protocol = strtolower($this->protocol);
+               $this->protocol = ( ! in_array($this->protocol, $this->_protocols, TRUE)) ? 'mail' : $this->protocol;
+
+               if ($return == TRUE)
+               {
+                       return $this->protocol;
+               }
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Get Mail Encoding
+        *
+        * @access      private
+        * @param       bool
+        * @return      string
+        */
+       private function _get_encoding($return = TRUE)
+       {
+               $this->_encoding = ( ! in_array($this->_encoding, $this->_bit_depths)) ? '8bit' : $this->_encoding;
+
+               foreach ($this->_base_charsets as $charset)
+               {
+                       if (strncmp($charset, $this->charset, strlen($charset)) == 0)
+                       {
+                               $this->_encoding = '7bit';
+                       }
+               }
+
+               if ($return == TRUE)
+               {
+                       return $this->_encoding;
+               }
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Get content type (text/html/attachment)
+        *
+        * @access      private
+        * @return      string
+        */
+       private function _get_content_type()
+       {
+               if      ($this->mailtype == 'html' &&  count($this->_attach_name) == 0)
+               {
+                       return 'html';
+               }
+               elseif  ($this->mailtype == 'html' &&  count($this->_attach_name)  > 0)
+               {
+                       return 'html-attach';
+               }
+               elseif  ($this->mailtype == 'text' &&  count($this->_attach_name)  > 0)
+               {
+                       return 'plain-attach';
+               }
+               else
+               {
+                       return 'plain';
+               }
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Set RFC 822 Date
+        *
+        * @access      private
+        * @return      string
+        */
+       private function _set_date()
+       {
+               $timezone = date("Z");
+               $operator = (strncmp($timezone, '-', 1) == 0) ? '-' : '+';
+               $timezone = abs($timezone);
+               $timezone = floor($timezone/3600) * 100 + ($timezone % 3600 ) / 60;
+
+               return sprintf("%s %s%04d", date("D, j M Y H:i:s"), $operator, $timezone);
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Mime message
+        *
+        * @access      private
+        * @return      string
+        */
+       private function _get_mime_message()
+       {
+               return "This is a multi-part message in MIME format.".$this->newline."Your email application may not support this format.";
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Validate Email Address
+        *
+        * @access      public
+        * @param       string
+        * @return      bool
+        */
+       public function validate_email($email)
+       {
+               if ( ! is_array($email))
+               {
+                       $this->_set_error_message('email_must_be_array');
+                       return FALSE;
+               }
+
+               foreach ($email as $val)
+               {
+                       if ( ! $this->valid_email($val))
+                       {
+                               $this->_set_error_message('email_invalid_address', $val);
+                               return FALSE;
+                       }
+               }
+
+               return TRUE;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Email Validation
+        *
+        * @access      public
+        * @param       string
+        * @return      bool
+        */
+       public function valid_email($address)
+       {
+               return ( ! preg_match("/^([a-z0-9\+_\-]+)(\.[a-z0-9\+_\-]+)*@([a-z0-9\-]+\.)+[a-z]{2,6}$/ix", $address)) ? FALSE : TRUE;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Clean Extended Email Address: Joe Smith <joe@smith.com>
+        *
+        * @access      public
+        * @param       string
+        * @return      string
+        */
+       public function clean_email($email)
+       {
+               if ( ! is_array($email))
+               {
+                       if (preg_match('/\<(.*)\>/', $email, $match))
+                       {
+                               return $match['1'];
+                       }
+                       else
+                       {
+                               return $email;
+                       }
+               }
+
+               $clean_email = array();
+
+               foreach ($email as $addy)
+               {
+                       if (preg_match( '/\<(.*)\>/', $addy, $match))
+                       {
+                               $clean_email[] = $match['1'];
+                       }
+                       else
+                       {
+                               $clean_email[] = $addy;
+                       }
+               }
+
+               return $clean_email;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Build alternative plain text message
+        *
+        * This public function provides the raw message for use
+        * in plain-text headers of HTML-formatted emails.
+        * If the user hasn't specified his own alternative message
+        * it creates one by stripping the HTML
+        *
+        * @access      private
+        * @return      string
+        */
+       private function _get_alt_message()
+       {
+               if ($this->alt_message != "")
+               {
+                       return $this->word_wrap($this->alt_message, '76');
+               }
+
+               if (preg_match('/\<body.*?\>(.*)\<\/body\>/si', $this->_body, $match))
+               {
+                       $body = $match['1'];
+               }
+               else
+               {
+                       $body = $this->_body;
+               }
+
+               $body = trim(strip_tags($body));
+               $body = preg_replace( '#<!--(.*)--\>#', "", $body);
+               $body = str_replace("\t", "", $body);
+
+               for ($i = 20; $i >= 3; $i--)
+               {
+                       $n = "";
+
+                       for ($x = 1; $x <= $i; $x ++)
+                       {
+                               $n .= "\n";
+                       }
+
+                       $body = str_replace($n, "\n\n", $body);
+               }
+
+               return $this->word_wrap($body, '76');
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Word Wrap
+        *
+        * @access      public
+        * @param       string
+        * @param       integer
+        * @return      string
+        */
+       public function word_wrap($str, $charlim = '')
+       {
+               // Se the character limit
+               if ($charlim == '')
+               {
+                       $charlim = ($this->wrapchars == "") ? "76" : $this->wrapchars;
+               }
+
+               // Reduce multiple spaces
+               $str = preg_replace("| +|", " ", $str);
+
+               // Standardize newlines
+               if (strpos($str, "\r") !== FALSE)
+               {
+                       $str = str_replace(array("\r\n", "\r"), "\n", $str);
+               }
+
+               // If the current word is surrounded by {unwrap} tags we'll
+               // strip the entire chunk and replace it with a marker.
+               $unwrap = array();
+               if (preg_match_all("|(\{unwrap\}.+?\{/unwrap\})|s", $str, $matches))
+               {
+                       for ($i = 0; $i < count($matches['0']); $i++)
+                       {
+                               $unwrap[] = $matches['1'][$i];
+                               $str = str_replace($matches['1'][$i], "{{unwrapped".$i."}}", $str);
+                       }
+               }
+
+               // Use PHP's native public function to do the initial wordwrap.
+               // We set the cut flag to FALSE so that any individual words that are
+               // too long get left alone.  In the next step we'll deal with them.
+               $str = wordwrap($str, $charlim, "\n", FALSE);
+
+               // Split the string into individual lines of text and cycle through them
+               $output = "";
+               foreach (explode("\n", $str) as $line)
+               {
+                       // Is the line within the allowed character count?
+                       // If so we'll join it to the output and continue
+                       if (strlen($line) <= $charlim)
+                       {
+                               $output .= $line.$this->newline;
+                               continue;
+                       }
+
+                       $temp = '';
+                       while ((strlen($line)) > $charlim)
+                       {
+                               // If the over-length word is a URL we won't wrap it
+                               if (preg_match("!\[url.+\]|://|wwww.!", $line))
+                               {
+                                       break;
+                               }
+
+                               // Trim the word down
+                               $temp .= substr($line, 0, $charlim-1);
+                               $line = substr($line, $charlim-1);
+                       }
+
+                       // If $temp contains data it means we had to split up an over-length
+                       // word into smaller chunks so we'll add it back to our current line
+                       if ($temp != '')
+                       {
+                               $output .= $temp.$this->newline.$line;
+                       }
+                       else
+                       {
+                               $output .= $line;
+                       }
+
+                       $output .= $this->newline;
+               }
+
+               // Put our markers back
+               if (count($unwrap) > 0)
+               {
+                       foreach ($unwrap as $key => $val)
+                       {
+                               $output = str_replace("{{unwrapped".$key."}}", $val, $output);
+                       }
+               }
+
+               return $output;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Build final headers
+        *
+        * @access      private
+        * @param       string
+        * @return      string
+        */
+       private function _build_headers()
+       {
+               $this->_set_header('X-Sender', $this->clean_email($this->_headers['From']));
+               $this->_set_header('X-Mailer', $this->useragent);
+               $this->_set_header('X-Priority', $this->_priorities[$this->priority - 1]);
+               $this->_set_header('Message-ID', $this->_get_message_id());
+               $this->_set_header('Mime-Version', '1.0');
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Write Headers as a string
+        *
+        * @access      private
+        * @return      void
+        */
+       private function _write_headers()
+       {
+               if ($this->protocol == 'mail')
+               {
+                       $this->_subject = $this->_headers['Subject'];
+                       unset($this->_headers['Subject']);
+               }
+
+               reset($this->_headers);
+               $this->_header_str = "";
+
+               foreach ($this->_headers as $key => $val)
+               {
+                       $val = trim($val);
+
+                       if ($val != "")
+                       {
+                               $this->_header_str .= $key.": ".$val.$this->newline;
+                       }
+               }
+
+               if ($this->_get_protocol() == 'mail')
+               {
+                       $this->_header_str = rtrim($this->_header_str);
+               }
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Build Final Body and attachments
+        *
+        * @access      private
+        * @return      void
+        */
+       private function _build_message()
+       {
+               if ($this->wordwrap === TRUE  AND  $this->mailtype != 'html')
+               {
+                       $this->_body = $this->word_wrap($this->_body);
+               }
+
+               $this->_set_boundaries();
+               $this->_write_headers();
+
+               $hdr = ($this->_get_protocol() == 'mail') ? $this->newline : '';
+               $body = '';
+
+               switch ($this->_get_content_type())
+               {
+                       case 'plain' :
+
+                               $hdr .= "Content-Type: text/plain; charset=" . $this->charset . $this->newline;
+                               $hdr .= "Content-Transfer-Encoding: " . $this->_get_encoding();
+
+                               if ($this->_get_protocol() == 'mail')
+                               {
+                                       $this->_header_str .= $hdr;
+                                       $this->_finalbody = $this->_body;
+                               }
+                               else
+                               {
+                                       $this->_finalbody = $hdr . $this->newline . $this->newline . $this->_body;
+                               }
+
+                               return;
+
+                       break;
+                       case 'html' :
+
+                               if ($this->send_multipart === FALSE)
+                               {
+                                       $hdr .= "Content-Type: text/html; charset=" . $this->charset . $this->newline;
+                                       $hdr .= "Content-Transfer-Encoding: quoted-printable";
+                               }
+                               else
+                               {
+                                       $hdr .= "Content-Type: multipart/alternative; boundary=\"" . $this->_alt_boundary . "\"" . $this->newline . $this->newline;
+
+                                       $body .= $this->_get_mime_message() . $this->newline . $this->newline;
+                                       $body .= "--" . $this->_alt_boundary . $this->newline;
+
+                                       $body .= "Content-Type: text/plain; charset=" . $this->charset . $this->newline;
+                                       $body .= "Content-Transfer-Encoding: " . $this->_get_encoding() . $this->newline . $this->newline;
+                                       $body .= $this->_get_alt_message() . $this->newline . $this->newline . "--" . $this->_alt_boundary . $this->newline;
+
+                                       $body .= "Content-Type: text/html; charset=" . $this->charset . $this->newline;
+                                       $body .= "Content-Transfer-Encoding: quoted-printable" . $this->newline . $this->newline;
+                               }
+
+                               $this->_finalbody = $body . $this->_prep_quoted_printable($this->_body) . $this->newline . $this->newline;
+
+
+                               if ($this->_get_protocol() == 'mail')
+                               {
+                                       $this->_header_str .= $hdr;
+                               }
+                               else
+                               {
+                                       $this->_finalbody = $hdr . $this->_finalbody;
+                               }
+
+
+                               if ($this->send_multipart !== FALSE)
+                               {
+                                       $this->_finalbody .= "--" . $this->_alt_boundary . "--";
+                               }
+
+                               return;
+
+                       break;
+                       case 'plain-attach' :
+
+                               $hdr .= "Content-Type: multipart/".$this->multipart."; boundary=\"" . $this->_atc_boundary."\"" . $this->newline . $this->newline;
+
+                               if ($this->_get_protocol() == 'mail')
+                               {
+                                       $this->_header_str .= $hdr;
+                               }
+
+                               $body .= $this->_get_mime_message() . $this->newline . $this->newline;
+                               $body .= "--" . $this->_atc_boundary . $this->newline;
+
+                               $body .= "Content-Type: text/plain; charset=" . $this->charset . $this->newline;
+                               $body .= "Content-Transfer-Encoding: " . $this->_get_encoding() . $this->newline . $this->newline;
+
+                               $body .= $this->_body . $this->newline . $this->newline;
+
+                       break;
+                       case 'html-attach' :
+
+                               $hdr .= "Content-Type: multipart/".$this->multipart."; boundary=\"" . $this->_atc_boundary."\"" . $this->newline . $this->newline;
+
+                               if ($this->_get_protocol() == 'mail')
+                               {
+                                       $this->_header_str .= $hdr;
+                               }
+
+                               $body .= $this->_get_mime_message() . $this->newline . $this->newline;
+                               $body .= "--" . $this->_atc_boundary . $this->newline;
+
+                               $body .= "Content-Type: multipart/alternative; boundary=\"" . $this->_alt_boundary . "\"" . $this->newline .$this->newline;
+                               $body .= "--" . $this->_alt_boundary . $this->newline;
+
+                               $body .= "Content-Type: text/plain; charset=" . $this->charset . $this->newline;
+                               $body .= "Content-Transfer-Encoding: " . $this->_get_encoding() . $this->newline . $this->newline;
+                               $body .= $this->_get_alt_message() . $this->newline . $this->newline . "--" . $this->_alt_boundary . $this->newline;
+
+                               $body .= "Content-Type: text/html; charset=" . $this->charset . $this->newline;
+                               $body .= "Content-Transfer-Encoding: quoted-printable" . $this->newline . $this->newline;
+
+                               $body .= $this->_prep_quoted_printable($this->_body) . $this->newline . $this->newline;
+                               $body .= "--" . $this->_alt_boundary . "--" . $this->newline . $this->newline;
+
+                       break;
+               }
+
+               $attachment = array();
+
+               $z = 0;
+
+               for ($i=0; $i < count($this->_attach_name); $i++)
+               {
+                       $filename = $this->_attach_name[$i];
+                       $basename = basename($filename);
+                       $ctype = $this->_attach_type[$i];
+
+                       if ( ! file_exists($filename))
+                       {
+                               $this->_set_error_message('email_attachment_missing', $filename);
+                               return FALSE;
+                       }
+
+                       $h  = "--".$this->_atc_boundary.$this->newline;
+                       $h .= "Content-type: ".$ctype."; ";
+                       $h .= "name=\"".$basename."\"".$this->newline;
+                       $h .= "Content-Disposition: ".$this->_attach_disp[$i].";".$this->newline;
+                       $h .= "Content-Transfer-Encoding: base64".$this->newline;
+
+                       $attachment[$z++] = $h;
+                       $file = filesize($filename) +1;
+
+                       if ( ! $fp = fopen($filename, FOPEN_READ))
+                       {
+                               $this->_set_error_message('email_attachment_unreadable', $filename);
+                               return FALSE;
+                       }
+
+                       $attachment[$z++] = chunk_split(base64_encode(fread($fp, $file)));
+                       fclose($fp);
+               }
+
+               $body .= implode($this->newline, $attachment).$this->newline."--".$this->_atc_boundary."--";
+
+
+               if ($this->_get_protocol() == 'mail')
+               {
+                       $this->_finalbody = $body;
+               }
+               else
+               {
+                       $this->_finalbody = $hdr . $body;
+               }
+
+               return;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Prep Quoted Printable
+        *
+        * Prepares string for Quoted-Printable Content-Transfer-Encoding
+        * Refer to RFC 2045 http://www.ietf.org/rfc/rfc2045.txt
+        *
+        * @access      private
+        * @param       string
+        * @param       integer
+        * @return      string
+        */
+       private function _prep_quoted_printable($str, $charlim = '')
+       {
+               // Set the character limit
+               // Don't allow over 76, as that will make servers and MUAs barf
+               // all over quoted-printable data
+               if ($charlim == '' OR $charlim > '76')
+               {
+                       $charlim = '76';
+               }
+
+               // Reduce multiple spaces
+               $str = preg_replace("| +|", " ", $str);
+
+               // kill nulls
+               $str = preg_replace('/\x00+/', '', $str);
+
+               // Standardize newlines
+               if (strpos($str, "\r") !== FALSE)
+               {
+                       $str = str_replace(array("\r\n", "\r"), "\n", $str);
+               }
+
+               // We are intentionally wrapping so mail servers will encode characters
+               // properly and MUAs will behave, so {unwrap} must go!
+               $str = str_replace(array('{unwrap}', '{/unwrap}'), '', $str);
+
+               // Break into an array of lines
+               $lines = explode("\n", $str);
+
+               $escape = '=';
+               $output = '';
+
+               foreach ($lines as $line)
+               {
+                       $length = strlen($line);
+                       $temp = '';
+
+                       // Loop through each character in the line to add soft-wrap
+                       // characters at the end of a line " =\r\n" and add the newly
+                       // processed line(s) to the output (see comment on $crlf class property)
+                       for ($i = 0; $i < $length; $i++)
+                       {
+                               // Grab the next character
+                               $char = substr($line, $i, 1);
+                               $ascii = ord($char);
+
+                               // Convert spaces and tabs but only if it's the end of the line
+                               if ($i == ($length - 1))
+                               {
+                                       $char = ($ascii == '32' OR $ascii == '9') ? $escape.sprintf('%02s', dechex($ascii)) : $char;
+                               }
+
+                               // encode = signs
+                               if ($ascii == '61')
+                               {
+                                       $char = $escape.strtoupper(sprintf('%02s', dechex($ascii)));  // =3D
+                               }
+
+                               // If we're at the character limit, add the line to the output,
+                               // reset our temp variable, and keep on chuggin'
+                               if ((strlen($temp) + strlen($char)) >= $charlim)
+                               {
+                                       $output .= $temp.$escape.$this->crlf;
+                                       $temp = '';
+                               }
+
+                               // Add the character to our temporary line
+                               $temp .= $char;
+                       }
+
+                       // Add our completed line to the output
+                       $output .= $temp.$this->crlf;
+               }
+
+               // get rid of extra CRLF tacked onto the end
+               $output = substr($output, 0, strlen($this->crlf) * -1);
+
+               return $output;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Prep Q Encoding
+        *
+        * Performs "Q Encoding" on a string for use in email headers.  It's related
+        * but not identical to quoted-printable, so it has its own method
+        *
+        * @access      public
+        * @param       str
+        * @param       bool    // set to TRUE for processing From: headers
+        * @return      str
+        */
+       private function _prep_q_encoding($str, $from = FALSE)
+       {
+               $str = str_replace(array("\r", "\n"), array('', ''), $str);
+
+               // Line length must not exceed 76 characters, so we adjust for
+               // a space, 7 extra characters =??Q??=, and the charset that we will add to each line
+               $limit = 75 - 7 - strlen($this->charset);
+
+               // these special characters must be converted too
+               $convert = array('_', '=', '?');
+
+               if ($from === TRUE)
+               {
+                       $convert[] = ',';
+                       $convert[] = ';';
+               }
+
+               $output = '';
+               $temp = '';
+
+               for ($i = 0, $length = strlen($str); $i < $length; $i++)
+               {
+                       // Grab the next character
+                       $char = substr($str, $i, 1);
+                       $ascii = ord($char);
+
+                       // convert ALL non-printable ASCII characters and our specials
+                       if ($ascii < 32 OR $ascii > 126 OR in_array($char, $convert))
+                       {
+                               $char = '='.dechex($ascii);
+                       }
+
+                       // handle regular spaces a bit more compactly than =20
+                       if ($ascii == 32)
+                       {
+                               $char = '_';
+                       }
+
+                       // If we're at the character limit, add the line to the output,
+                       // reset our temp variable, and keep on chuggin'
+                       if ((strlen($temp) + strlen($char)) >= $limit)
+                       {
+                               $output .= $temp.$this->crlf;
+                               $temp = '';
+                       }
+
+                       // Add the character to our temporary line
+                       $temp .= $char;
+               }
+
+               $str = $output.$temp;
+
+               // wrap each line with the shebang, charset, and transfer encoding
+               // the preceding space on successive lines is required for header "folding"
+               $str = trim(preg_replace('/^(.*)$/m', ' =?'.$this->charset.'?Q?$1?=', $str));
+
+               return $str;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Send Email
+        *
+        * @access      public
+        * @return      bool
+        */
+       public function send()
+       {
+               if ($this->_replyto_flag == FALSE)
+               {
+                       $this->reply_to($this->_headers['From']);
+               }
+
+               if (( ! isset($this->_recipients) AND ! isset($this->_headers['To']))  AND
+                       ( ! isset($this->_bcc_array) AND ! isset($this->_headers['Bcc'])) AND
+                       ( ! isset($this->_headers['Cc'])))
+               {
+                       $this->_set_error_message('email_no_recipients');
+                       return FALSE;
+               }
+
+               $this->_build_headers();
+
+               if ($this->bcc_batch_mode  AND  count($this->_bcc_array) > 0)
+               {
+                       if (count($this->_bcc_array) > $this->bcc_batch_size)
+                               return $this->batch_bcc_send();
+               }
+
+               $this->_build_message();
+
+               if ( ! $this->_spool_email())
+               {
+                       return FALSE;
+               }
+               else
+               {
+                       return TRUE;
+               }
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Batch Bcc Send.  Sends groups of BCCs in batches
+        *
+        * @access      public
+        * @return      bool
+        */
+       public function batch_bcc_send()
+       {
+               $float = $this->bcc_batch_size -1;
+
+               $set = "";
+
+               $chunk = array();
+
+               for ($i = 0; $i < count($this->_bcc_array); $i++)
+               {
+                       if (isset($this->_bcc_array[$i]))
+                       {
+                               $set .= ", ".$this->_bcc_array[$i];
+                       }
+
+                       if ($i == $float)
+                       {
+                               $chunk[] = substr($set, 1);
+                               $float = $float + $this->bcc_batch_size;
+                               $set = "";
+                       }
+
+                       if ($i == count($this->_bcc_array)-1)
+                       {
+                               $chunk[] = substr($set, 1);
+                       }
+               }
+
+               for ($i = 0; $i < count($chunk); $i++)
+               {
+                       unset($this->_headers['Bcc']);
+                       unset($bcc);
+
+                       $bcc = $this->_str_to_array($chunk[$i]);
+                       $bcc = $this->clean_email($bcc);
+
+                       if ($this->protocol != 'smtp')
+                       {
+                               $this->_set_header('Bcc', implode(", ", $bcc));
+                       }
+                       else
+                       {
+                               $this->_bcc_array = $bcc;
+                       }
+
+                       $this->_build_message();
+                       $this->_spool_email();
+               }
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Unwrap special elements
+        *
+        * @access      private
+        * @return      void
+        */
+       private function _unwrap_specials()
+       {
+               $this->_finalbody = preg_replace_callback("/\{unwrap\}(.*?)\{\/unwrap\}/si", array($this, '_remove_nl_callback'), $this->_finalbody);
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Strip line-breaks via callback
+        *
+        * @access      private
+        * @return      string
+        */
+       private function _remove_nl_callback($matches)
+       {
+               if (strpos($matches[1], "\r") !== FALSE OR strpos($matches[1], "\n") !== FALSE)
+               {
+                       $matches[1] = str_replace(array("\r\n", "\r", "\n"), '', $matches[1]);
+               }
+
+               return $matches[1];
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Spool mail to the mail server
+        *
+        * @access      private
+        * @return      bool
+        */
+       private function _spool_email()
+       {
+               $this->_unwrap_specials();
+
+               switch ($this->_get_protocol())
+               {
+                       case 'mail'     :
+
+                                       if ( ! $this->_send_with_mail())
+                                       {
+                                               $this->_set_error_message('email_send_failure_phpmail');
+                                               return FALSE;
+                                       }
+                       break;
+                       case 'sendmail' :
+
+                                       if ( ! $this->_send_with_sendmail())
+                                       {
+                                               $this->_set_error_message('email_send_failure_sendmail');
+                                               return FALSE;
+                                       }
+                       break;
+                       case 'smtp'     :
+
+                                       if ( ! $this->_send_with_smtp())
+                                       {
+                                               $this->_set_error_message('email_send_failure_smtp');
+                                               return FALSE;
+                                       }
+                       break;
+
+               }
+
+               $this->_set_error_message('email_sent', $this->_get_protocol());
+               return TRUE;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Send using mail()
+        *
+        * @access      private
+        * @return      bool
+        */
+       private function _send_with_mail()
+       {
+               if ($this->_safe_mode == TRUE)
+               {
+                       if ( ! mail($this->_recipients, $this->_subject, $this->_finalbody, $this->_header_str))
+                       {
+                               return FALSE;
+                       }
+                       else
+                       {
+                               return TRUE;
+                       }
+               }
+               else
+               {
+                       // most documentation of sendmail using the "-f" flag lacks a space after it, however
+                       // we've encountered servers that seem to require it to be in place.
+
+                       if ( ! mail($this->_recipients, $this->_subject, $this->_finalbody, $this->_header_str, "-f ".$this->clean_email($this->_headers['From'])))
+                       {
+                               return FALSE;
+                       }
+                       else
+                       {
+                               return TRUE;
+                       }
+               }
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Send using Sendmail
+        *
+        * @access      private
+        * @return      bool
+        */
+       private function _send_with_sendmail()
+       {
+               $fp = @popen($this->mailpath . " -oi -f ".$this->clean_email($this->_headers['From'])." -t", 'w');
+
+               if ($fp === FALSE OR $fp === NULL)
+               {
+                       // server probably has popen disabled, so nothing we can do to get a verbose error.
+                       return FALSE;
+               }
+
+               fputs($fp, $this->_header_str);
+               fputs($fp, $this->_finalbody);
+
+               $status = pclose($fp);
+
+               if (version_compare(PHP_VERSION, '4.2.3') == -1)
+               {
+                       $status = $status >> 8 & 0xFF;
+               }
+
+               if ($status != 0)
+               {
+                       $this->_set_error_message('email_exit_status', $status);
+                       $this->_set_error_message('email_no_socket');
+                       return FALSE;
+               }
+
+               return TRUE;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Send using SMTP
+        *
+        * @access      private
+        * @return      bool
+        */
+       private function _send_with_smtp()
+       {
+               if ($this->smtp_host == '')
+               {
+                       $this->_set_error_message('email_no_hostname');
+                       return FALSE;
+               }
+
+               $this->_smtp_connect();
+               $this->_smtp_authenticate();
+
+               $this->_send_command('from', $this->clean_email($this->_headers['From']));
+
+               foreach ($this->_recipients as $val)
+               {
+                       $this->_send_command('to', $val);
+               }
+
+               if (count($this->_cc_array) > 0)
+               {
+                       foreach ($this->_cc_array as $val)
+                       {
+                               if ($val != "")
+                               {
+                                       $this->_send_command('to', $val);
+                               }
+                       }
+               }
+
+               if (count($this->_bcc_array) > 0)
+               {
+                       foreach ($this->_bcc_array as $val)
+                       {
+                               if ($val != "")
+                               {
+                                       $this->_send_command('to', $val);
+                               }
+                       }
+               }
+
+               $this->_send_command('data');
+
+               // perform dot transformation on any lines that begin with a dot
+               $this->_send_data($this->_header_str . preg_replace('/^\./m', '..$1', $this->_finalbody));
+
+               $this->_send_data('.');
+
+               $reply = $this->_get_smtp_data();
+
+               $this->_set_error_message($reply);
+
+               if (strncmp($reply, '250', 3) != 0)
+               {
+                       $this->_set_error_message('email_smtp_error', $reply);
+                       return FALSE;
+               }
+
+               $this->_send_command('quit');
+               return TRUE;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * SMTP Connect
+        *
+        * @access      private
+        * @param       string
+        * @return      string
+        */
+       private function _smtp_connect()
+       {
+               $this->_smtp_connect = fsockopen($this->smtp_host,
+                                                                               $this->smtp_port,
+                                                                               $errno,
+                                                                               $errstr,
+                                                                               $this->smtp_timeout);
+
+               if ( ! is_resource($this->_smtp_connect))
+               {
+                       $this->_set_error_message('email_smtp_error', $errno." ".$errstr);
+                       return FALSE;
+               }
+
+               $this->_set_error_message($this->_get_smtp_data());
+               return $this->_send_command('hello');
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Send SMTP command
+        *
+        * @access      private
+        * @param       string
+        * @param       string
+        * @return      string
+        */
+       private function _send_command($cmd, $data = '')
+       {
+               switch ($cmd)
+               {
+                       case 'hello' :
+
+                                       if ($this->_smtp_auth OR $this->_get_encoding() == '8bit')
+                                               $this->_send_data('EHLO '.$this->_get_hostname());
+                                       else
+                                               $this->_send_data('HELO '.$this->_get_hostname());
+
+                                               $resp = 250;
+                       break;
+                       case 'from' :
+
+                                               $this->_send_data('MAIL FROM:<'.$data.'>');
+
+                                               $resp = 250;
+                       break;
+                       case 'to'       :
+
+                                               $this->_send_data('RCPT TO:<'.$data.'>');
+
+                                               $resp = 250;
+                       break;
+                       case 'data'     :
+
+                                               $this->_send_data('DATA');
+
+                                               $resp = 354;
+                       break;
+                       case 'quit'     :
+
+                                               $this->_send_data('QUIT');
+
+                                               $resp = 221;
+                       break;
+               }
+
+               $reply = $this->_get_smtp_data();
+
+               $this->_debug_msg[] = "<pre>".$cmd.": ".$reply."</pre>";
+
+               if (substr($reply, 0, 3) != $resp)
+               {
+                       $this->_set_error_message('email_smtp_error', $reply);
+                       return FALSE;
+               }
+
+               if ($cmd == 'quit')
+               {
+                       fclose($this->_smtp_connect);
+               }
+
+               return TRUE;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        *  SMTP Authenticate
+        *
+        * @access      private
+        * @return      bool
+        */
+       private function _smtp_authenticate()
+       {
+               if ( ! $this->_smtp_auth)
+               {
+                       return TRUE;
+               }
+
+               if ($this->smtp_user == ""  AND  $this->smtp_pass == "")
+               {
+                       $this->_set_error_message('email_no_smtp_unpw');
+                       return FALSE;
+               }
+
+               $this->_send_data('AUTH LOGIN');
+
+               $reply = $this->_get_smtp_data();
+
+               if (strncmp($reply, '334', 3) != 0)
+               {
+                       $this->_set_error_message('email_failed_smtp_login', $reply);
+                       return FALSE;
+               }
+
+               $this->_send_data(base64_encode($this->smtp_user));
+
+               $reply = $this->_get_smtp_data();
+
+               if (strncmp($reply, '334', 3) != 0)
+               {
+                       $this->_set_error_message('email_smtp_auth_un', $reply);
+                       return FALSE;
+               }
+
+               $this->_send_data(base64_encode($this->smtp_pass));
+
+               $reply = $this->_get_smtp_data();
+
+               if (strncmp($reply, '235', 3) != 0)
+               {
+                       $this->_set_error_message('email_smtp_auth_pw', $reply);
+                       return FALSE;
+               }
+
+               return TRUE;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Send SMTP data
+        *
+        * @access      private
+        * @return      bool
+        */
+       private function _send_data($data)
+       {
+               if ( ! fwrite($this->_smtp_connect, $data . $this->newline))
+               {
+                       $this->_set_error_message('email_smtp_data_failure', $data);
+                       return FALSE;
+               }
+               else
+               {
+                       return TRUE;
+               }
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Get SMTP data
+        *
+        * @access      private
+        * @return      string
+        */
+       private function _get_smtp_data()
+       {
+               $data = "";
+
+               while ($str = fgets($this->_smtp_connect, 512))
+               {
+                       $data .= $str;
+
+                       if (substr($str, 3, 1) == " ")
+                       {
+                               break;
+                       }
+               }
+
+               return $data;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Get Hostname
+        *
+        * @access      private
+        * @return      string
+        */
+       private function _get_hostname()
+       {
+               return (isset($_SERVER['SERVER_NAME'])) ? $_SERVER['SERVER_NAME'] : 'localhost.localdomain';
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Get IP
+        *
+        * @access      private
+        * @return      string
+        */
+       private function _get_ip()
+       {
+               if ($this->_IP !== FALSE)
+               {
+                       return $this->_IP;
+               }
+
+               $cip = (isset($_SERVER['HTTP_CLIENT_IP']) AND $_SERVER['HTTP_CLIENT_IP'] != "") ? $_SERVER['HTTP_CLIENT_IP'] : FALSE;
+               $rip = (isset($_SERVER['REMOTE_ADDR']) AND $_SERVER['REMOTE_ADDR'] != "") ? $_SERVER['REMOTE_ADDR'] : FALSE;
+               $fip = (isset($_SERVER['HTTP_X_FORWARDED_FOR']) AND $_SERVER['HTTP_X_FORWARDED_FOR'] != "") ? $_SERVER['HTTP_X_FORWARDED_FOR'] : FALSE;
+
+               if ($cip && $rip)       $this->_IP = $cip;
+               elseif ($rip)           $this->_IP = $rip;
+               elseif ($cip)           $this->_IP = $cip;
+               elseif ($fip)           $this->_IP = $fip;
+
+               if (strpos($this->_IP, ',') !== FALSE)
+               {
+                       $x = explode(',', $this->_IP);
+                       $this->_IP = end($x);
+               }
+
+               if ( ! preg_match( "/^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$/", $this->_IP))
+               {
+                       $this->_IP = '0.0.0.0';
+               }
+
+               unset($cip);
+               unset($rip);
+               unset($fip);
+
+               return $this->_IP;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Get Debug Message
+        *
+        * @access      public
+        * @return      string
+        */
+       public function print_debugger()
+       {
+               $msg = '';
+
+               if (count($this->_debug_msg) > 0)
+               {
+                       foreach ($this->_debug_msg as $val)
+                       {
+                               $msg .= $val;
+                       }
+               }
+
+               $msg .= "<pre>".$this->_header_str."\n".htmlspecialchars($this->_subject)."\n".htmlspecialchars($this->_finalbody).'</pre>';
+               return $msg;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Set Message
+        *
+        * @access      private
+        * @param       string
+        * @return      string
+        */
+       private function _set_error_message($msg, $val = '')
+       {
+               $CI =& get_instance();
+               $CI->lang->load('email');
+
+               if (FALSE === ($line = $CI->lang->line($msg)))
+               {
+                       $this->_debug_msg[] = str_replace('%s', $val, $msg)."<br />";
+               }
+               else
+               {
+                       $this->_debug_msg[] = str_replace('%s', $val, $line)."<br />";
+               }
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Mime Types
+        *
+        * @access      private
+        * @param       string
+        * @return      string
+        */
+       private function _mime_types($ext = "")
+       {
+               $mimes = array( 'hqx'   =>      'application/mac-binhex40',
+                                               'cpt'   =>      'application/mac-compactpro',
+                                               'doc'   =>      'application/msword',
+                                               'bin'   =>      'application/macbinary',
+                                               'dms'   =>      'application/octet-stream',
+                                               'lha'   =>      'application/octet-stream',
+                                               'lzh'   =>      'application/octet-stream',
+                                               'exe'   =>      'application/octet-stream',
+                                               'class' =>      'application/octet-stream',
+                                               'psd'   =>      'application/octet-stream',
+                                               'so'    =>      'application/octet-stream',
+                                               'sea'   =>      'application/octet-stream',
+                                               'dll'   =>      'application/octet-stream',
+                                               'oda'   =>      'application/oda',
+                                               'pdf'   =>      'application/pdf',
+                                               'ai'    =>      'application/postscript',
+                                               'eps'   =>      'application/postscript',
+                                               'ps'    =>      'application/postscript',
+                                               'smi'   =>      'application/smil',
+                                               'smil'  =>      'application/smil',
+                                               'mif'   =>      'application/vnd.mif',
+                                               'xls'   =>      'application/vnd.ms-excel',
+                                               'ppt'   =>      'application/vnd.ms-powerpoint',
+                                               'wbxml' =>      'application/vnd.wap.wbxml',
+                                               'wmlc'  =>      'application/vnd.wap.wmlc',
+                                               'dcr'   =>      'application/x-director',
+                                               'dir'   =>      'application/x-director',
+                                               'dxr'   =>      'application/x-director',
+                                               'dvi'   =>      'application/x-dvi',
+                                               'gtar'  =>      'application/x-gtar',
+                                               'php'   =>      'application/x-httpd-php',
+                                               'php4'  =>      'application/x-httpd-php',
+                                               'php3'  =>      'application/x-httpd-php',
+                                               'phtml' =>      'application/x-httpd-php',
+                                               'phps'  =>      'application/x-httpd-php-source',
+                                               'js'    =>      'application/x-javascript',
+                                               'swf'   =>      'application/x-shockwave-flash',
+                                               'sit'   =>      'application/x-stuffit',
+                                               'tar'   =>      'application/x-tar',
+                                               'tgz'   =>      'application/x-tar',
+                                               'xhtml' =>      'application/xhtml+xml',
+                                               'xht'   =>      'application/xhtml+xml',
+                                               'zip'   =>      'application/zip',
+                                               'mid'   =>      'audio/midi',
+                                               'midi'  =>      'audio/midi',
+                                               'mpga'  =>      'audio/mpeg',
+                                               'mp2'   =>      'audio/mpeg',
+                                               'mp3'   =>      'audio/mpeg',
+                                               'aif'   =>      'audio/x-aiff',
+                                               'aiff'  =>      'audio/x-aiff',
+                                               'aifc'  =>      'audio/x-aiff',
+                                               'ram'   =>      'audio/x-pn-realaudio',
+                                               'rm'    =>      'audio/x-pn-realaudio',
+                                               'rpm'   =>      'audio/x-pn-realaudio-plugin',
+                                               'ra'    =>      'audio/x-realaudio',
+                                               'rv'    =>      'video/vnd.rn-realvideo',
+                                               'wav'   =>      'audio/x-wav',
+                                               'bmp'   =>      'image/bmp',
+                                               'gif'   =>      'image/gif',
+                                               'jpeg'  =>      'image/jpeg',
+                                               'jpg'   =>      'image/jpeg',
+                                               'jpe'   =>      'image/jpeg',
+                                               'png'   =>      'image/png',
+                                               'tiff'  =>      'image/tiff',
+                                               'tif'   =>      'image/tiff',
+                                               'css'   =>      'text/css',
+                                               'html'  =>      'text/html',
+                                               'htm'   =>      'text/html',
+                                               'shtml' =>      'text/html',
+                                               'txt'   =>      'text/plain',
+                                               'text'  =>      'text/plain',
+                                               'log'   =>      'text/plain',
+                                               'rtx'   =>      'text/richtext',
+                                               'rtf'   =>      'text/rtf',
+                                               'xml'   =>      'text/xml',
+                                               'xsl'   =>      'text/xml',
+                                               'mpeg'  =>      'video/mpeg',
+                                               'mpg'   =>      'video/mpeg',
+                                               'mpe'   =>      'video/mpeg',
+                                               'qt'    =>      'video/quicktime',
+                                               'mov'   =>      'video/quicktime',
+                                               'avi'   =>      'video/x-msvideo',
+                                               'movie' =>      'video/x-sgi-movie',
+                                               'doc'   =>      'application/msword',
+                                               'word'  =>      'application/msword',
+                                               'xl'    =>      'application/excel',
+                                               'eml'   =>      'message/rfc822'
+                                       );
+
+               return ( ! isset($mimes[strtolower($ext)])) ? "application/x-unknown-content-type" : $mimes[strtolower($ext)];
+       }
+
+}
+// END CI_Email class
+
+/* End of file Email.php */
+/* Location: ./system/libraries/Email.php */
\ No newline at end of file
diff --git a/system/libraries/Encrypt.php b/system/libraries/Encrypt.php
new file mode 100755 (executable)
index 0000000..e5f6587
--- /dev/null
@@ -0,0 +1,547 @@
+<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+/**
+ * CodeIgniter
+ *
+ * An open source application development framework for PHP 5.1.6 or newer
+ *
+ * @package            CodeIgniter
+ * @author             ExpressionEngine Dev Team
+ * @copyright  Copyright (c) 2008 - 2011, EllisLab, Inc.
+ * @license            http://codeigniter.com/user_guide/license.html
+ * @link               http://codeigniter.com
+ * @since              Version 1.0
+ * @filesource
+ */
+
+// ------------------------------------------------------------------------
+
+/**
+ * CodeIgniter Encryption Class
+ *
+ * Provides two-way keyed encoding using XOR Hashing and Mcrypt
+ *
+ * @package            CodeIgniter
+ * @subpackage Libraries
+ * @category   Libraries
+ * @author             ExpressionEngine Dev Team
+ * @link               http://codeigniter.com/user_guide/libraries/encryption.html
+ */
+class CI_Encrypt {
+
+       var $CI;
+       var $encryption_key     = '';
+       var $_hash_type = 'sha1';
+       var $_mcrypt_exists = FALSE;
+       var $_mcrypt_cipher;
+       var $_mcrypt_mode;
+
+       /**
+        * Constructor
+        *
+        * Simply determines whether the mcrypt library exists.
+        *
+        */
+       public function __construct()
+       {
+               $this->CI =& get_instance();
+               $this->_mcrypt_exists = ( ! function_exists('mcrypt_encrypt')) ? FALSE : TRUE;
+               log_message('debug', "Encrypt Class Initialized");
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Fetch the encryption key
+        *
+        * Returns it as MD5 in order to have an exact-length 128 bit key.
+        * Mcrypt is sensitive to keys that are not the correct length
+        *
+        * @access      public
+        * @param       string
+        * @return      string
+        */
+       function get_key($key = '')
+       {
+               if ($key == '')
+               {
+                       if ($this->encryption_key != '')
+                       {
+                               return $this->encryption_key;
+                       }
+
+                       $CI =& get_instance();
+                       $key = $CI->config->item('encryption_key');
+
+                       if ($key == FALSE)
+                       {
+                               show_error('In order to use the encryption class requires that you set an encryption key in your config file.');
+                       }
+               }
+
+               return md5($key);
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Set the encryption key
+        *
+        * @access      public
+        * @param       string
+        * @return      void
+        */
+       function set_key($key = '')
+       {
+               $this->encryption_key = $key;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Encode
+        *
+        * Encodes the message string using bitwise XOR encoding.
+        * The key is combined with a random hash, and then it
+        * too gets converted using XOR. The whole thing is then run
+        * through mcrypt (if supported) using the randomized key.
+        * The end result is a double-encrypted message string
+        * that is randomized with each call to this function,
+        * even if the supplied message and key are the same.
+        *
+        * @access      public
+        * @param       string  the string to encode
+        * @param       string  the key
+        * @return      string
+        */
+       function encode($string, $key = '')
+       {
+               $key = $this->get_key($key);
+
+               if ($this->_mcrypt_exists === TRUE)
+               {
+                       $enc = $this->mcrypt_encode($string, $key);
+               }
+               else
+               {
+                       $enc = $this->_xor_encode($string, $key);
+               }
+
+               return base64_encode($enc);
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Decode
+        *
+        * Reverses the above process
+        *
+        * @access      public
+        * @param       string
+        * @param       string
+        * @return      string
+        */
+       function decode($string, $key = '')
+       {
+               $key = $this->get_key($key);
+
+               if (preg_match('/[^a-zA-Z0-9\/\+=]/', $string))
+               {
+                       return FALSE;
+               }
+
+               $dec = base64_decode($string);
+
+               if ($this->_mcrypt_exists === TRUE)
+               {
+                       if (($dec = $this->mcrypt_decode($dec, $key)) === FALSE)
+                       {
+                               return FALSE;
+                       }
+               }
+               else
+               {
+                       $dec = $this->_xor_decode($dec, $key);
+               }
+
+               return $dec;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Encode from Legacy
+        *
+        * Takes an encoded string from the original Encryption class algorithms and
+        * returns a newly encoded string using the improved method added in 2.0.0
+        * This allows for backwards compatibility and a method to transition to the
+        * new encryption algorithms.
+        *
+        * For more details, see http://codeigniter.com/user_guide/installation/upgrade_200.html#encryption
+        *
+        * @access      public
+        * @param       string
+        * @param       int             (mcrypt mode constant)
+        * @param       string
+        * @return      string
+        */
+       function encode_from_legacy($string, $legacy_mode = MCRYPT_MODE_ECB, $key = '')
+       {
+               if ($this->_mcrypt_exists === FALSE)
+               {
+                       log_message('error', 'Encoding from legacy is available only when Mcrypt is in use.');
+                       return FALSE;
+               }
+
+               // decode it first
+               // set mode temporarily to what it was when string was encoded with the legacy
+               // algorithm - typically MCRYPT_MODE_ECB
+               $current_mode = $this->_get_mode();
+               $this->set_mode($legacy_mode);
+
+               $key = $this->get_key($key);
+
+               if (preg_match('/[^a-zA-Z0-9\/\+=]/', $string))
+               {
+                       return FALSE;
+               }
+
+               $dec = base64_decode($string);
+
+               if (($dec = $this->mcrypt_decode($dec, $key)) === FALSE)
+               {
+                       return FALSE;
+               }
+
+               $dec = $this->_xor_decode($dec, $key);
+
+               // set the mcrypt mode back to what it should be, typically MCRYPT_MODE_CBC
+               $this->set_mode($current_mode);
+
+               // and re-encode
+               return base64_encode($this->mcrypt_encode($dec, $key));
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * XOR Encode
+        *
+        * Takes a plain-text string and key as input and generates an
+        * encoded bit-string using XOR
+        *
+        * @access      private
+        * @param       string
+        * @param       string
+        * @return      string
+        */
+       function _xor_encode($string, $key)
+       {
+               $rand = '';
+               while (strlen($rand) < 32)
+               {
+                       $rand .= mt_rand(0, mt_getrandmax());
+               }
+
+               $rand = $this->hash($rand);
+
+               $enc = '';
+               for ($i = 0; $i < strlen($string); $i++)
+               {
+                       $enc .= substr($rand, ($i % strlen($rand)), 1).(substr($rand, ($i % strlen($rand)), 1) ^ substr($string, $i, 1));
+               }
+
+               return $this->_xor_merge($enc, $key);
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * XOR Decode
+        *
+        * Takes an encoded string and key as input and generates the
+        * plain-text original message
+        *
+        * @access      private
+        * @param       string
+        * @param       string
+        * @return      string
+        */
+       function _xor_decode($string, $key)
+       {
+               $string = $this->_xor_merge($string, $key);
+
+               $dec = '';
+               for ($i = 0; $i < strlen($string); $i++)
+               {
+                       $dec .= (substr($string, $i++, 1) ^ substr($string, $i, 1));
+               }
+
+               return $dec;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * XOR key + string Combiner
+        *
+        * Takes a string and key as input and computes the difference using XOR
+        *
+        * @access      private
+        * @param       string
+        * @param       string
+        * @return      string
+        */
+       function _xor_merge($string, $key)
+       {
+               $hash = $this->hash($key);
+               $str = '';
+               for ($i = 0; $i < strlen($string); $i++)
+               {
+                       $str .= substr($string, $i, 1) ^ substr($hash, ($i % strlen($hash)), 1);
+               }
+
+               return $str;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Encrypt using Mcrypt
+        *
+        * @access      public
+        * @param       string
+        * @param       string
+        * @return      string
+        */
+       function mcrypt_encode($data, $key)
+       {
+               $init_size = mcrypt_get_iv_size($this->_get_cipher(), $this->_get_mode());
+               $init_vect = mcrypt_create_iv($init_size, MCRYPT_RAND);
+               return $this->_add_cipher_noise($init_vect.mcrypt_encrypt($this->_get_cipher(), $key, $data, $this->_get_mode(), $init_vect), $key);
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Decrypt using Mcrypt
+        *
+        * @access      public
+        * @param       string
+        * @param       string
+        * @return      string
+        */
+       function mcrypt_decode($data, $key)
+       {
+               $data = $this->_remove_cipher_noise($data, $key);
+               $init_size = mcrypt_get_iv_size($this->_get_cipher(), $this->_get_mode());
+
+               if ($init_size > strlen($data))
+               {
+                       return FALSE;
+               }
+
+               $init_vect = substr($data, 0, $init_size);
+               $data = substr($data, $init_size);
+               return rtrim(mcrypt_decrypt($this->_get_cipher(), $key, $data, $this->_get_mode(), $init_vect), "\0");
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Adds permuted noise to the IV + encrypted data to protect
+        * against Man-in-the-middle attacks on CBC mode ciphers
+        * http://www.ciphersbyritter.com/GLOSSARY.HTM#IV
+        *
+        * Function description
+        *
+        * @access      private
+        * @param       string
+        * @param       string
+        * @return      string
+        */
+       function _add_cipher_noise($data, $key)
+       {
+               $keyhash = $this->hash($key);
+               $keylen = strlen($keyhash);
+               $str = '';
+
+               for ($i = 0, $j = 0, $len = strlen($data); $i < $len; ++$i, ++$j)
+               {
+                       if ($j >= $keylen)
+                       {
+                               $j = 0;
+                       }
+
+                       $str .= chr((ord($data[$i]) + ord($keyhash[$j])) % 256);
+               }
+
+               return $str;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Removes permuted noise from the IV + encrypted data, reversing
+        * _add_cipher_noise()
+        *
+        * Function description
+        *
+        * @access      public
+        * @param       type
+        * @return      type
+        */
+       function _remove_cipher_noise($data, $key)
+       {
+               $keyhash = $this->hash($key);
+               $keylen = strlen($keyhash);
+               $str = '';
+
+               for ($i = 0, $j = 0, $len = strlen($data); $i < $len; ++$i, ++$j)
+               {
+                       if ($j >= $keylen)
+                       {
+                               $j = 0;
+                       }
+
+                       $temp = ord($data[$i]) - ord($keyhash[$j]);
+
+                       if ($temp < 0)
+                       {
+                               $temp = $temp + 256;
+                       }
+
+                       $str .= chr($temp);
+               }
+
+               return $str;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Set the Mcrypt Cipher
+        *
+        * @access      public
+        * @param       constant
+        * @return      string
+        */
+       function set_cipher($cipher)
+       {
+               $this->_mcrypt_cipher = $cipher;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Set the Mcrypt Mode
+        *
+        * @access      public
+        * @param       constant
+        * @return      string
+        */
+       function set_mode($mode)
+       {
+               $this->_mcrypt_mode = $mode;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Get Mcrypt cipher Value
+        *
+        * @access      private
+        * @return      string
+        */
+       function _get_cipher()
+       {
+               if ($this->_mcrypt_cipher == '')
+               {
+                       $this->_mcrypt_cipher = MCRYPT_RIJNDAEL_256;
+               }
+
+               return $this->_mcrypt_cipher;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Get Mcrypt Mode Value
+        *
+        * @access      private
+        * @return      string
+        */
+       function _get_mode()
+       {
+               if ($this->_mcrypt_mode == '')
+               {
+                       $this->_mcrypt_mode = MCRYPT_MODE_CBC;
+               }
+
+               return $this->_mcrypt_mode;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Set the Hash type
+        *
+        * @access      public
+        * @param       string
+        * @return      string
+        */
+       function set_hash($type = 'sha1')
+       {
+               $this->_hash_type = ($type != 'sha1' AND $type != 'md5') ? 'sha1' : $type;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Hash encode a string
+        *
+        * @access      public
+        * @param       string
+        * @return      string
+        */
+       function hash($str)
+       {
+               return ($this->_hash_type == 'sha1') ? $this->sha1($str) : md5($str);
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Generate an SHA1 Hash
+        *
+        * @access      public
+        * @param       string
+        * @return      string
+        */
+       function sha1($str)
+       {
+               if ( ! function_exists('sha1'))
+               {
+                       if ( ! function_exists('mhash'))
+                       {
+                               require_once(BASEPATH.'libraries/Sha1'.EXT);
+                               $SH = new CI_SHA;
+                               return $SH->generate($str);
+                       }
+                       else
+                       {
+                               return bin2hex(mhash(MHASH_SHA1, $str));
+                       }
+               }
+               else
+               {
+                       return sha1($str);
+               }
+       }
+
+}
+
+// END CI_Encrypt class
+
+/* End of file Encrypt.php */
+/* Location: ./system/libraries/Encrypt.php */
\ No newline at end of file
diff --git a/system/libraries/Form_validation.php b/system/libraries/Form_validation.php
new file mode 100755 (executable)
index 0000000..cfc02ed
--- /dev/null
@@ -0,0 +1,1360 @@
+<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+/**
+ * CodeIgniter
+ *
+ * An open source application development framework for PHP 5.1.6 or newer
+ *
+ * @package            CodeIgniter
+ * @author             ExpressionEngine Dev Team
+ * @copyright  Copyright (c) 2008 - 2011, EllisLab, Inc.
+ * @license            http://codeigniter.com/user_guide/license.html
+ * @link               http://codeigniter.com
+ * @since              Version 1.0
+ * @filesource
+ */
+
+// ------------------------------------------------------------------------
+
+/**
+ * Form Validation Class
+ *
+ * @package            CodeIgniter
+ * @subpackage Libraries
+ * @category   Validation
+ * @author             ExpressionEngine Dev Team
+ * @link               http://codeigniter.com/user_guide/libraries/form_validation.html
+ */
+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                      = '<p>';
+       var $_error_suffix                      = '</p>';
+       var $error_string                       = '';
+       var $_safe_form_data            = FALSE;
+
+
+       /**
+        * Constructor
+        */
+       public function __construct($rules = array())
+       {
+               $this->CI =& get_instance();
+
+               // Validation rules can be stored in a config file.
+               $this->_config_rules = $rules;
+
+               // Automatically load the form helper
+               $this->CI->load->helper('form');
+
+               // Set the character encoding in MB.
+               if (function_exists('mb_internal_encoding'))
+               {
+                       mb_internal_encoding($this->CI->config->item('charset'));
+               }
+
+               log_message('debug', "Form Validation Class Initialized");
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Set Rules
+        *
+        * This function takes an array of field names and validation
+        * rules as input, validates the info, and stores it
+        *
+        * @access      public
+        * @param       mixed
+        * @param       string
+        * @return      void
+        */
+       function set_rules($field, $label = '', $rules = '')
+       {
+               // No reason to set rules if we have no POST data
+               if (count($_POST) == 0)
+               {
+                       return $this;
+               }
+
+               // If an array was passed via the first parameter instead of indidual string
+               // values we cycle through it and recursively call this function.
+               if (is_array($field))
+               {
+                       foreach ($field as $row)
+                       {
+                               // Houston, we have a problem...
+                               if ( ! isset($row['field']) OR ! isset($row['rules']))
+                               {
+                                       continue;
+                               }
+
+                               // If the field label wasn't passed we use the field name
+                               $label = ( ! isset($row['label'])) ? $row['field'] : $row['label'];
+
+                               // Here we go!
+                               $this->set_rules($row['field'], $label, $row['rules']);
+                       }
+                       return $this;
+               }
+
+               // No fields? Nothing to do...
+               if ( ! is_string($field) OR  ! is_string($rules) OR $field == '')
+               {
+                       return $this;
+               }
+
+               // If the field label wasn't passed we use the field name
+               $label = ($label == '') ? $field : $label;
+
+               // Is the field name an array?  We test for the existence of a bracket "[" in
+               // the field name to determine this.  If it is an array, we break it apart
+               // into its components so that we can fetch the corresponding POST data later
+               if (strpos($field, '[') !== FALSE AND preg_match_all('/\[(.*?)\]/', $field, $matches))
+               {
+                       // Note: Due to a bug in current() that affects some versions
+                       // of PHP we can not pass function call directly into it
+                       $x = explode('[', $field);
+                       $indexes[] = current($x);
+
+                       for ($i = 0; $i < count($matches['0']); $i++)
+                       {
+                               if ($matches['1'][$i] != '')
+                               {
+                                       $indexes[] = $matches['1'][$i];
+                               }
+                       }
+
+                       $is_array = TRUE;
+               }
+               else
+               {
+                       $indexes        = array();
+                       $is_array       = FALSE;
+               }
+
+               // Build our master array
+               $this->_field_data[$field] = array(
+                       'field'                         => $field,
+                       'label'                         => $label,
+                       'rules'                         => $rules,
+                       'is_array'                      => $is_array,
+                       'keys'                          => $indexes,
+                       'postdata'                      => NULL,
+                       'error'                         => ''
+               );
+
+               return $this;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Set Error Message
+        *
+        * Lets users set their own error messages on the fly.  Note:  The key
+        * name has to match the  function name that it corresponds to.
+        *
+        * @access      public
+        * @param       string
+        * @param       string
+        * @return      string
+        */
+       function set_message($lang, $val = '')
+       {
+               if ( ! is_array($lang))
+               {
+                       $lang = array($lang => $val);
+               }
+
+               $this->_error_messages = array_merge($this->_error_messages, $lang);
+
+               return $this;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Set The Error Delimiter
+        *
+        * Permits a prefix/suffix to be added to each error message
+        *
+        * @access      public
+        * @param       string
+        * @param       string
+        * @return      void
+        */
+       function set_error_delimiters($prefix = '<p>', $suffix = '</p>')
+       {
+               $this->_error_prefix = $prefix;
+               $this->_error_suffix = $suffix;
+
+               return $this;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Get Error Message
+        *
+        * Gets the error message associated with a particular field
+        *
+        * @access      public
+        * @param       string  the field name
+        * @return      void
+        */
+       function error($field = '', $prefix = '', $suffix = '')
+       {
+               if ( ! isset($this->_field_data[$field]['error']) OR $this->_field_data[$field]['error'] == '')
+               {
+                       return '';
+               }
+
+               if ($prefix == '')
+               {
+                       $prefix = $this->_error_prefix;
+               }
+
+               if ($suffix == '')
+               {
+                       $suffix = $this->_error_suffix;
+               }
+
+               return $prefix.$this->_field_data[$field]['error'].$suffix;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Error String
+        *
+        * Returns the error messages as a string, wrapped in the error delimiters
+        *
+        * @access      public
+        * @param       string
+        * @param       string
+        * @return      str
+        */
+       function error_string($prefix = '', $suffix = '')
+       {
+               // No errrors, validation passes!
+               if (count($this->_error_array) === 0)
+               {
+                       return '';
+               }
+
+               if ($prefix == '')
+               {
+                       $prefix = $this->_error_prefix;
+               }
+
+               if ($suffix == '')
+               {
+                       $suffix = $this->_error_suffix;
+               }
+
+               // Generate the error string
+               $str = '';
+               foreach ($this->_error_array as $val)
+               {
+                       if ($val != '')
+                       {
+                               $str .= $prefix.$val.$suffix."\n";
+                       }
+               }
+
+               return $str;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Run the Validator
+        *
+        * This function does all the work.
+        *
+        * @access      public
+        * @return      bool
+        */
+       function run($group = '')
+       {
+               // Do we even have any data to process?  Mm?
+               if (count($_POST) == 0)
+               {
+                       return FALSE;
+               }
+
+               // Does the _field_data array containing the validation rules exist?
+               // If not, we look to see if they were assigned via a config file
+               if (count($this->_field_data) == 0)
+               {
+                       // No validation rules?  We're done...
+                       if (count($this->_config_rules) == 0)
+                       {
+                               return FALSE;
+                       }
+
+                       // Is there a validation rule for the particular URI being accessed?
+                       $uri = ($group == '') ? trim($this->CI->uri->ruri_string(), '/') : $group;
+
+                       if ($uri != '' AND isset($this->_config_rules[$uri]))
+                       {
+                               $this->set_rules($this->_config_rules[$uri]);
+                       }
+                       else
+                       {
+                               $this->set_rules($this->_config_rules);
+                       }
+
+                       // We're we able to set the rules correctly?
+                       if (count($this->_field_data) == 0)
+                       {
+                               log_message('debug', "Unable to find validation rules");
+                               return FALSE;
+                       }
+               }
+
+               // Load the language file containing error messages
+               $this->CI->lang->load('form_validation');
+
+               // Cycle through the rules for each field, match the
+               // corresponding $_POST item and test for errors
+               foreach ($this->_field_data as $field => $row)
+               {
+                       // Fetch the data from the corresponding $_POST array and cache it in the _field_data array.
+                       // Depending on whether the field name is an array or a string will determine where we get it from.
+
+                       if ($row['is_array'] == TRUE)
+                       {
+                               $this->_field_data[$field]['postdata'] = $this->_reduce_array($_POST, $row['keys']);
+                       }
+                       else
+                       {
+                               if (isset($_POST[$field]) AND $_POST[$field] != "")
+                               {
+                                       $this->_field_data[$field]['postdata'] = $_POST[$field];
+                               }
+                       }
+
+                       $this->_execute($row, explode('|', $row['rules']), $this->_field_data[$field]['postdata']);
+               }
+
+               // Did we end up with any errors?
+               $total_errors = count($this->_error_array);
+
+               if ($total_errors > 0)
+               {
+                       $this->_safe_form_data = TRUE;
+               }
+
+               // Now we need to re-set the POST data with the new, processed data
+               $this->_reset_post_array();
+
+               // No errors, validation passes!
+               if ($total_errors == 0)
+               {
+                       return TRUE;
+               }
+
+               // Validation fails
+               return FALSE;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Traverse a multidimensional $_POST array index until the data is found
+        *
+        * @access      private
+        * @param       array
+        * @param       array
+        * @param       integer
+        * @return      mixed
+        */
+       function _reduce_array($array, $keys, $i = 0)
+       {
+               if (is_array($array))
+               {
+                       if (isset($keys[$i]))
+                       {
+                               if (isset($array[$keys[$i]]))
+                               {
+                                       $array = $this->_reduce_array($array[$keys[$i]], $keys, ($i+1));
+                               }
+                               else
+                               {
+                                       return NULL;
+                               }
+                       }
+                       else
+                       {
+                               return $array;
+                       }
+               }
+
+               return $array;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Re-populate the _POST array with our finalized and processed data
+        *
+        * @access      private
+        * @return      null
+        */
+       function _reset_post_array()
+       {
+               foreach ($this->_field_data as $field => $row)
+               {
+                       if ( ! is_null($row['postdata']))
+                       {
+                               if ($row['is_array'] == FALSE)
+                               {
+                                       if (isset($_POST[$row['field']]))
+                                       {
+                                               $_POST[$row['field']] = $this->prep_for_form($row['postdata']);
+                                       }
+                               }
+                               else
+                               {
+                                       // start with a reference
+                                       $post_ref =& $_POST;
+
+                                       // before we assign values, make a reference to the right POST key
+                                       if (count($row['keys']) == 1)
+                                       {
+                                               $post_ref =& $post_ref[current($row['keys'])];
+                                       }
+                                       else
+                                       {
+                                               foreach ($row['keys'] as $val)
+                                               {
+                                                       $post_ref =& $post_ref[$val];
+                                               }
+                                       }
+
+                                       if (is_array($row['postdata']))
+                                       {
+                                               $array = array();
+                                               foreach ($row['postdata'] as $k => $v)
+                                               {
+                                                       $array[$k] = $this->prep_for_form($v);
+                                               }
+
+                                               $post_ref = $array;
+                                       }
+                                       else
+                                       {
+                                               $post_ref = $this->prep_for_form($row['postdata']);
+                                       }
+                               }
+                       }
+               }
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Executes the Validation routines
+        *
+        * @access      private
+        * @param       array
+        * @param       array
+        * @param       mixed
+        * @param       integer
+        * @return      mixed
+        */
+       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))
+               {
+                       foreach ($postdata as $key => $val)
+                       {
+                               $this->_execute($row, $rules, $val, $cycles);
+                               $cycles++;
+                       }
+
+                       return;
+               }
+
+               // --------------------------------------------------------------------
+
+               // If the field is blank, but NOT required, no further tests are necessary
+               $callback = FALSE;
+               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))
+                       {
+                               $callback = TRUE;
+                               $rules = (array('1' => $match[1]));
+                       }
+                       else
+                       {
+                               return;
+                       }
+               }
+
+               // --------------------------------------------------------------------
+
+               // Isset Test. Typically this rule will only apply to checkboxes.
+               if (is_null($postdata) AND $callback == FALSE)
+               {
+                       if (in_array('isset', $rules, TRUE) OR in_array('required', $rules))
+                       {
+                               // Set the message type
+                               $type = (in_array('required', $rules)) ? 'required' : 'isset';
+
+                               if ( ! isset($this->_error_messages[$type]))
+                               {
+                                       if (FALSE === ($line = $this->CI->lang->line($type)))
+                                       {
+                                               $line = 'The field was not set';
+                                       }
+                               }
+                               else
+                               {
+                                       $line = $this->_error_messages[$type];
+                               }
+
+                               // Build the error message
+                               $message = sprintf($line, $this->_translate_fieldname($row['label']));
+
+                               // Save the error message
+                               $this->_field_data[$row['field']]['error'] = $message;
+
+                               if ( ! isset($this->_error_array[$row['field']]))
+                               {
+                                       $this->_error_array[$row['field']] = $message;
+                               }
+                       }
+
+                       return;
+               }
+
+               // --------------------------------------------------------------------
+
+               // Cycle through each rule and run it
+               foreach ($rules As $rule)
+               {
+                       $_in_array = FALSE;
+
+                       // We set the $postdata variable with the current data in our master array so that
+                       // each cycle of the loop is dealing with the processed data from the last cycle
+                       if ($row['is_array'] == TRUE AND is_array($this->_field_data[$row['field']]['postdata']))
+                       {
+                               // We shouldn't need this safety, but just in case there isn't an array index
+                               // associated with this cycle we'll bail out
+                               if ( ! isset($this->_field_data[$row['field']]['postdata'][$cycles]))
+                               {
+                                       continue;
+                               }
+
+                               $postdata = $this->_field_data[$row['field']]['postdata'][$cycles];
+                               $_in_array = TRUE;
+                       }
+                       else
+                       {
+                               $postdata = $this->_field_data[$row['field']]['postdata'];
+                       }
+
+                       // --------------------------------------------------------------------
+
+                       // Is the rule a callback?
+                       $callback = FALSE;
+                       if (substr($rule, 0, 9) == 'callback_')
+                       {
+                               $rule = substr($rule, 9);
+                               $callback = TRUE;
+                       }
+
+                       // Strip the parameter (if exists) from the rule
+                       // Rules can contain a parameter: max_length[5]
+                       $param = FALSE;
+                       if (preg_match("/(.*?)\[(.*)\]/", $rule, $match))
+                       {
+                               $rule   = $match[1];
+                               $param  = $match[2];
+                       }
+
+                       // Call the function that corresponds to the rule
+                       if ($callback === TRUE)
+                       {
+                               if ( ! method_exists($this->CI, $rule))
+                               {
+                                       continue;
+                               }
+
+                               // Run the function and grab the result
+                               $result = $this->CI->$rule($postdata, $param);
+
+                               // Re-assign the result to the master data array
+                               if ($_in_array == TRUE)
+                               {
+                                       $this->_field_data[$row['field']]['postdata'][$cycles] = (is_bool($result)) ? $postdata : $result;
+                               }
+                               else
+                               {
+                                       $this->_field_data[$row['field']]['postdata'] = (is_bool($result)) ? $postdata : $result;
+                               }
+
+                               // If the field isn't required and we just processed a callback we'll move on...
+                               if ( ! in_array('required', $rules, TRUE) AND $result !== FALSE)
+                               {
+                                       continue;
+                               }
+                       }
+                       else
+                       {
+                               if ( ! method_exists($this, $rule))
+                               {
+                                       // If our own wrapper function doesn't exist we see if a native PHP function does.
+                                       // Users can use any native PHP function call that has one param.
+                                       if (function_exists($rule))
+                                       {
+                                               $result = $rule($postdata);
+
+                                               if ($_in_array == TRUE)
+                                               {
+                                                       $this->_field_data[$row['field']]['postdata'][$cycles] = (is_bool($result)) ? $postdata : $result;
+                                               }
+                                               else
+                                               {
+                                                       $this->_field_data[$row['field']]['postdata'] = (is_bool($result)) ? $postdata : $result;
+                                               }
+                                       }
+
+                                       continue;
+                               }
+
+                               $result = $this->$rule($postdata, $param);
+
+                               if ($_in_array == TRUE)
+                               {
+                                       $this->_field_data[$row['field']]['postdata'][$cycles] = (is_bool($result)) ? $postdata : $result;
+                               }
+                               else
+                               {
+                                       $this->_field_data[$row['field']]['postdata'] = (is_bool($result)) ? $postdata : $result;
+                               }
+                       }
+
+                       // Did the rule test negatively?  If so, grab the error.
+                       if ($result === FALSE)
+                       {
+                               if ( ! isset($this->_error_messages[$rule]))
+                               {
+                                       if (FALSE === ($line = $this->CI->lang->line($rule)))
+                                       {
+                                               $line = 'Unable to access an error message corresponding to your field name.';
+                                       }
+                               }
+                               else
+                               {
+                                       $line = $this->_error_messages[$rule];
+                               }
+
+                               // Is the parameter we are inserting into the error message the name
+                               // of another field?  If so we need to grab its "field label"
+                               if (isset($this->_field_data[$param]) AND isset($this->_field_data[$param]['label']))
+                               {
+                                       $param = $this->_translate_fieldname($this->_field_data[$param]['label']);
+                               }
+
+                               // Build the error message
+                               $message = sprintf($line, $this->_translate_fieldname($row['label']), $param);
+
+                               // Save the error message
+                               $this->_field_data[$row['field']]['error'] = $message;
+
+                               if ( ! isset($this->_error_array[$row['field']]))
+                               {
+                                       $this->_error_array[$row['field']] = $message;
+                               }
+
+                               return;
+                       }
+               }
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Translate a field name
+        *
+        * @access      private
+        * @param       string  the field name
+        * @return      string
+        */
+       function _translate_fieldname($fieldname)
+       {
+               // Do we need to translate the field name?
+               // We look for the prefix lang: to determine this
+               if (substr($fieldname, 0, 5) == 'lang:')
+               {
+                       // Grab the variable
+                       $line = substr($fieldname, 5);
+
+                       // Were we able to translate the field name?  If not we use $line
+                       if (FALSE === ($fieldname = $this->CI->lang->line($line)))
+                       {
+                               return $line;
+                       }
+               }
+
+               return $fieldname;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Get the value from a form
+        *
+        * Permits you to repopulate a form field with the value it was submitted
+        * with, or, if that value doesn't exist, with the default
+        *
+        * @access      public
+        * @param       string  the field name
+        * @param       string
+        * @return      void
+        */
+       function set_value($field = '', $default = '')
+       {
+               if ( ! isset($this->_field_data[$field]))
+               {
+                       return $default;
+               }
+
+               // If the data is an array output them one at a time.
+               //     E.g: form_input('name[]', set_value('name[]');
+               if (is_array($this->_field_data[$field]['postdata']))
+               {
+                       return array_shift($this->_field_data[$field]['postdata']);
+               }
+
+               return $this->_field_data[$field]['postdata'];
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Set Select
+        *
+        * Enables pull-down lists to be set to the value the user
+        * selected in the event of an error
+        *
+        * @access      public
+        * @param       string
+        * @param       string
+        * @return      string
+        */
+       function set_select($field = '', $value = '', $default = FALSE)
+       {
+               if ( ! isset($this->_field_data[$field]) OR ! isset($this->_field_data[$field]['postdata']))
+               {
+                       if ($default === TRUE AND count($this->_field_data) === 0)
+                       {
+                               return ' selected="selected"';
+                       }
+                       return '';
+               }
+
+               $field = $this->_field_data[$field]['postdata'];
+
+               if (is_array($field))
+               {
+                       if ( ! in_array($value, $field))
+                       {
+                               return '';
+                       }
+               }
+               else
+               {
+                       if (($field == '' OR $value == '') OR ($field != $value))
+                       {
+                               return '';
+                       }
+               }
+
+               return ' selected="selected"';
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Set Radio
+        *
+        * Enables radio buttons to be set to the value the user
+        * selected in the event of an error
+        *
+        * @access      public
+        * @param       string
+        * @param       string
+        * @return      string
+        */
+       function set_radio($field = '', $value = '', $default = FALSE)
+       {
+               if ( ! isset($this->_field_data[$field]) OR ! isset($this->_field_data[$field]['postdata']))
+               {
+                       if ($default === TRUE AND count($this->_field_data) === 0)
+                       {
+                               return ' checked="checked"';
+                       }
+                       return '';
+               }
+
+               $field = $this->_field_data[$field]['postdata'];
+
+               if (is_array($field))
+               {
+                       if ( ! in_array($value, $field))
+                       {
+                               return '';
+                       }
+               }
+               else
+               {
+                       if (($field == '' OR $value == '') OR ($field != $value))
+                       {
+                               return '';
+                       }
+               }
+
+               return ' checked="checked"';
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Set Checkbox
+        *
+        * Enables checkboxes to be set to the value the user
+        * selected in the event of an error
+        *
+        * @access      public
+        * @param       string
+        * @param       string
+        * @return      string
+        */
+       function set_checkbox($field = '', $value = '', $default = FALSE)
+       {
+               if ( ! isset($this->_field_data[$field]) OR ! isset($this->_field_data[$field]['postdata']))
+               {
+                       if ($default === TRUE AND count($this->_field_data) === 0)
+                       {
+                               return ' checked="checked"';
+                       }
+                       return '';
+               }
+
+               $field = $this->_field_data[$field]['postdata'];
+
+               if (is_array($field))
+               {
+                       if ( ! in_array($value, $field))
+                       {
+                               return '';
+                       }
+               }
+               else
+               {
+                       if (($field == '' OR $value == '') OR ($field != $value))
+                       {
+                               return '';
+                       }
+               }
+
+               return ' checked="checked"';
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Required
+        *
+        * @access      public
+        * @param       string
+        * @return      bool
+        */
+       function required($str)
+       {
+               if ( ! is_array($str))
+               {
+                       return (trim($str) == '') ? FALSE : TRUE;
+               }
+               else
+               {
+                       return ( ! empty($str));
+               }
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Performs a Regular Expression match test.
+        *
+        * @access      public
+        * @param       string
+        * @param       regex
+        * @return      bool
+        */
+       function regex_match($str, $regex)
+       {
+               if ( ! preg_match($regex, $str))
+               {
+                       return FALSE;
+               }
+
+               return  TRUE;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Match one field to another
+        *
+        * @access      public
+        * @param       string
+        * @param       field
+        * @return      bool
+        */
+       function matches($str, $field)
+       {
+               if ( ! isset($_POST[$field]))
+               {
+                       return FALSE;
+               }
+
+               $field = $_POST[$field];
+
+               return ($str !== $field) ? FALSE : TRUE;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Minimum Length
+        *
+        * @access      public
+        * @param       string
+        * @param       value
+        * @return      bool
+        */
+       function min_length($str, $val)
+       {
+               if (preg_match("/[^0-9]/", $val))
+               {
+                       return FALSE;
+               }
+
+               if (function_exists('mb_strlen'))
+               {
+                       return (mb_strlen($str) < $val) ? FALSE : TRUE;
+               }
+
+               return (strlen($str) < $val) ? FALSE : TRUE;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Max Length
+        *
+        * @access      public
+        * @param       string
+        * @param       value
+        * @return      bool
+        */
+       function max_length($str, $val)
+       {
+               if (preg_match("/[^0-9]/", $val))
+               {
+                       return FALSE;
+               }
+
+               if (function_exists('mb_strlen'))
+               {
+                       return (mb_strlen($str) > $val) ? FALSE : TRUE;
+               }
+
+               return (strlen($str) > $val) ? FALSE : TRUE;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Exact Length
+        *
+        * @access      public
+        * @param       string
+        * @param       value
+        * @return      bool
+        */
+       function exact_length($str, $val)
+       {
+               if (preg_match("/[^0-9]/", $val))
+               {
+                       return FALSE;
+               }
+
+               if (function_exists('mb_strlen'))
+               {
+                       return (mb_strlen($str) != $val) ? FALSE : TRUE;
+               }
+
+               return (strlen($str) != $val) ? FALSE : TRUE;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Valid Email
+        *
+        * @access      public
+        * @param       string
+        * @return      bool
+        */
+       function valid_email($str)
+       {
+               return ( ! preg_match("/^([a-z0-9\+_\-]+)(\.[a-z0-9\+_\-]+)*@([a-z0-9\-]+\.)+[a-z]{2,6}$/ix", $str)) ? FALSE : TRUE;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Valid Emails
+        *
+        * @access      public
+        * @param       string
+        * @return      bool
+        */
+       function valid_emails($str)
+       {
+               if (strpos($str, ',') === FALSE)
+               {
+                       return $this->valid_email(trim($str));
+               }
+
+               foreach (explode(',', $str) as $email)
+               {
+                       if (trim($email) != '' && $this->valid_email(trim($email)) === FALSE)
+                       {
+                               return FALSE;
+                       }
+               }
+
+               return TRUE;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Validate IP Address
+        *
+        * @access      public
+        * @param       string
+        * @return      string
+        */
+       function valid_ip($ip)
+       {
+               return $this->CI->input->valid_ip($ip);
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Alpha
+        *
+        * @access      public
+        * @param       string
+        * @return      bool
+        */
+       function alpha($str)
+       {
+               return ( ! preg_match("/^([a-z])+$/i", $str)) ? FALSE : TRUE;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Alpha-numeric
+        *
+        * @access      public
+        * @param       string
+        * @return      bool
+        */
+       function alpha_numeric($str)
+       {
+               return ( ! preg_match("/^([a-z0-9])+$/i", $str)) ? FALSE : TRUE;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Alpha-numeric with underscores and dashes
+        *
+        * @access      public
+        * @param       string
+        * @return      bool
+        */
+       function alpha_dash($str)
+       {
+               return ( ! preg_match("/^([-a-z0-9_-])+$/i", $str)) ? FALSE : TRUE;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Numeric
+        *
+        * @access      public
+        * @param       string
+        * @return      bool
+        */
+       function numeric($str)
+       {
+               return (bool)preg_match( '/^[\-+]?[0-9]*\.?[0-9]+$/', $str);
+
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Is Numeric
+        *
+        * @access      public
+        * @param       string
+        * @return      bool
+        */
+       function is_numeric($str)
+       {
+               return ( ! is_numeric($str)) ? FALSE : TRUE;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Integer
+        *
+        * @access      public
+        * @param       string
+        * @return      bool
+        */
+       function integer($str)
+       {
+               return (bool) preg_match('/^[\-+]?[0-9]+$/', $str);
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Decimal number
+        *
+        * @access      public
+        * @param       string
+        * @return      bool
+        */
+       function decimal($str)
+       {
+               return (bool) preg_match('/^[\-+]?[0-9]+\.[0-9]+$/', $str);
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Greather than
+        *
+        * @access      public
+        * @param       string
+        * @return      bool
+        */
+       function greater_than($str, $min)
+       {
+               if ( ! is_numeric($str))
+               {
+                       return FALSE;
+               }
+               return $str > $min;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Less than
+        *
+        * @access      public
+        * @param       string
+        * @return      bool
+        */
+       function less_than($str, $max)
+       {
+               if ( ! is_numeric($str))
+               {
+                       return FALSE;
+               }
+               return $str < $max;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Is a Natural number  (0,1,2,3, etc.)
+        *
+        * @access      public
+        * @param       string
+        * @return      bool
+        */
+       function is_natural($str)
+       {
+               return (bool) preg_match( '/^[0-9]+$/', $str);
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Is a Natural number, but not a zero  (1,2,3, etc.)
+        *
+        * @access      public
+        * @param       string
+        * @return      bool
+        */
+       function is_natural_no_zero($str)
+       {
+               if ( ! preg_match( '/^[0-9]+$/', $str))
+               {
+                       return FALSE;
+               }
+
+               if ($str == 0)
+               {
+                       return FALSE;
+               }
+
+               return TRUE;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Valid Base64
+        *
+        * Tests a string for characters outside of the Base64 alphabet
+        * as defined by RFC 2045 http://www.faqs.org/rfcs/rfc2045
+        *
+        * @access      public
+        * @param       string
+        * @return      bool
+        */
+       function valid_base64($str)
+       {
+               return (bool) ! preg_match('/[^a-zA-Z0-9\/\+=]/', $str);
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Prep data for form
+        *
+        * This function allows HTML to be safely shown in a form.
+        * Special characters are converted.
+        *
+        * @access      public
+        * @param       string
+        * @return      string
+        */
+       function prep_for_form($data = '')
+       {
+               if (is_array($data))
+               {
+                       foreach ($data as $key => $val)
+                       {
+                               $data[$key] = $this->prep_for_form($val);
+                       }
+
+                       return $data;
+               }
+
+               if ($this->_safe_form_data == FALSE OR $data === '')
+               {
+                       return $data;
+               }
+
+               return str_replace(array("'", '"', '<', '>'), array("&#39;", "&quot;", '&lt;', '&gt;'), stripslashes($data));
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Prep URL
+        *
+        * @access      public
+        * @param       string
+        * @return      string
+        */
+       function prep_url($str = '')
+       {
+               if ($str == 'http://' OR $str == '')
+               {
+                       return '';
+               }
+
+               if (substr($str, 0, 7) != 'http://' && substr($str, 0, 8) != 'https://')
+               {
+                       $str = 'http://'.$str;
+               }
+
+               return $str;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Strip Image Tags
+        *
+        * @access      public
+        * @param       string
+        * @return      string
+        */
+       function strip_image_tags($str)
+       {
+               return $this->CI->input->strip_image_tags($str);
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * XSS Clean
+        *
+        * @access      public
+        * @param       string
+        * @return      string
+        */
+       function xss_clean($str)
+       {
+               return $this->CI->security->xss_clean($str);
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Convert PHP tags to entities
+        *
+        * @access      public
+        * @param       string
+        * @return      string
+        */
+       function encode_php_tags($str)
+       {
+               return str_replace(array('<?php', '<?PHP', '<?', '?>'),  array('&lt;?php', '&lt;?PHP', '&lt;?', '?&gt;'), $str);
+       }
+
+}
+// END Form Validation Class
+
+/* End of file Form_validation.php */
+/* Location: ./system/libraries/Form_validation.php */
\ No newline at end of file
diff --git a/system/libraries/Ftp.php b/system/libraries/Ftp.php
new file mode 100755 (executable)
index 0000000..d7a8b3b
--- /dev/null
@@ -0,0 +1,660 @@
+<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+/**
+ * CodeIgniter
+ *
+ * An open source application development framework for PHP 5.1.6 or newer
+ *
+ * @package            CodeIgniter
+ * @author             ExpressionEngine Dev Team
+ * @copyright  Copyright (c) 2008 - 2011, EllisLab, Inc.
+ * @license            http://codeigniter.com/user_guide/license.html
+ * @link               http://codeigniter.com
+ * @since              Version 1.0
+ * @filesource
+ */
+
+// ------------------------------------------------------------------------
+
+/**
+ * FTP Class
+ *
+ * @package            CodeIgniter
+ * @subpackage Libraries
+ * @category   Libraries
+ * @author             ExpressionEngine Dev Team
+ * @link               http://codeigniter.com/user_guide/libraries/ftp.html
+ */
+class CI_FTP {
+
+       var $hostname   = '';
+       var $username   = '';
+       var $password   = '';
+       var $port               = 21;
+       var $passive    = TRUE;
+       var $debug              = FALSE;
+       var $conn_id    = FALSE;
+
+
+       /**
+        * Constructor - Sets Preferences
+        *
+        * The constructor can be passed an array of config values
+        */
+       public function __construct($config = array())
+       {
+               if (count($config) > 0)
+               {
+                       $this->initialize($config);
+               }
+
+               log_message('debug', "FTP Class Initialized");
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Initialize preferences
+        *
+        * @access      public
+        * @param       array
+        * @return      void
+        */
+       function initialize($config = array())
+       {
+               foreach ($config as $key => $val)
+               {
+                       if (isset($this->$key))
+                       {
+                               $this->$key = $val;
+                       }
+               }
+
+               // Prep the hostname
+               $this->hostname = preg_replace('|.+?://|', '', $this->hostname);
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * FTP Connect
+        *
+        * @access      public
+        * @param       array    the connection values
+        * @return      bool
+        */
+       function connect($config = array())
+       {
+               if (count($config) > 0)
+               {
+                       $this->initialize($config);
+               }
+
+               if (FALSE === ($this->conn_id = @ftp_connect($this->hostname, $this->port)))
+               {
+                       if ($this->debug == TRUE)
+                       {
+                               $this->_error('ftp_unable_to_connect');
+                       }
+                       return FALSE;
+               }
+
+               if ( ! $this->_login())
+               {
+                       if ($this->debug == TRUE)
+                       {
+                               $this->_error('ftp_unable_to_login');
+                       }
+                       return FALSE;
+               }
+
+               // Set passive mode if needed
+               if ($this->passive == TRUE)
+               {
+                       ftp_pasv($this->conn_id, TRUE);
+               }
+
+               return TRUE;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * FTP Login
+        *
+        * @access      private
+        * @return      bool
+        */
+       function _login()
+       {
+               return @ftp_login($this->conn_id, $this->username, $this->password);
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Validates the connection ID
+        *
+        * @access      private
+        * @return      bool
+        */
+       function _is_conn()
+       {
+               if ( ! is_resource($this->conn_id))
+               {
+                       if ($this->debug == TRUE)
+                       {
+                               $this->_error('ftp_no_connection');
+                       }
+                       return FALSE;
+               }
+               return TRUE;
+       }
+
+       // --------------------------------------------------------------------
+
+
+       /**
+        * Change directory
+        *
+        * The second parameter lets us momentarily turn off debugging so that
+        * this function can be used to test for the existence of a folder
+        * without throwing an error.  There's no FTP equivalent to is_dir()
+        * so we do it by trying to change to a particular directory.
+        * Internally, this parameter is only used by the "mirror" function below.
+        *
+        * @access      public
+        * @param       string
+        * @param       bool
+        * @return      bool
+        */
+       function changedir($path = '', $supress_debug = FALSE)
+       {
+               if ($path == '' OR ! $this->_is_conn())
+               {
+                       return FALSE;
+               }
+
+               $result = @ftp_chdir($this->conn_id, $path);
+
+               if ($result === FALSE)
+               {
+                       if ($this->debug == TRUE AND $supress_debug == FALSE)
+                       {
+                               $this->_error('ftp_unable_to_changedir');
+                       }
+                       return FALSE;
+               }
+
+               return TRUE;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Create a directory
+        *
+        * @access      public
+        * @param       string
+        * @return      bool
+        */
+       function mkdir($path = '', $permissions = NULL)
+       {
+               if ($path == '' OR ! $this->_is_conn())
+               {
+                       return FALSE;
+               }
+
+               $result = @ftp_mkdir($this->conn_id, $path);
+
+               if ($result === FALSE)
+               {
+                       if ($this->debug == TRUE)
+                       {
+                               $this->_error('ftp_unable_to_makdir');
+                       }
+                       return FALSE;
+               }
+
+               // Set file permissions if needed
+               if ( ! is_null($permissions))
+               {
+                       $this->chmod($path, (int)$permissions);
+               }
+
+               return TRUE;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Upload a file to the server
+        *
+        * @access      public
+        * @param       string
+        * @param       string
+        * @param       string
+        * @return      bool
+        */
+       function upload($locpath, $rempath, $mode = 'auto', $permissions = NULL)
+       {
+               if ( ! $this->_is_conn())
+               {
+                       return FALSE;
+               }
+
+               if ( ! file_exists($locpath))
+               {
+                       $this->_error('ftp_no_source_file');
+                       return FALSE;
+               }
+
+               // Set the mode if not specified
+               if ($mode == 'auto')
+               {
+                       // Get the file extension so we can set the upload type
+                       $ext = $this->_getext($locpath);
+                       $mode = $this->_settype($ext);
+               }
+
+               $mode = ($mode == 'ascii') ? FTP_ASCII : FTP_BINARY;
+
+               $result = @ftp_put($this->conn_id, $rempath, $locpath, $mode);
+
+               if ($result === FALSE)
+               {
+                       if ($this->debug == TRUE)
+                       {
+                               $this->_error('ftp_unable_to_upload');
+                       }
+                       return FALSE;
+               }
+
+               // Set file permissions if needed
+               if ( ! is_null($permissions))
+               {
+                       $this->chmod($rempath, (int)$permissions);
+               }
+
+               return TRUE;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Download a file from a remote server to the local server
+        *
+        * @access      public
+        * @param       string
+        * @param       string
+        * @param       string
+        * @return      bool
+        */
+       function download($rempath, $locpath, $mode = 'auto')
+       {
+               if ( ! $this->_is_conn())
+               {
+                       return FALSE;
+               }
+
+               // Set the mode if not specified
+               if ($mode == 'auto')
+               {
+                       // Get the file extension so we can set the upload type
+                       $ext = $this->_getext($rempath);
+                       $mode = $this->_settype($ext);
+               }
+
+               $mode = ($mode == 'ascii') ? FTP_ASCII : FTP_BINARY;
+
+               $result = @ftp_get($this->conn_id, $locpath, $rempath, $mode);
+
+               if ($result === FALSE)
+               {
+                       if ($this->debug == TRUE)
+                       {
+                               $this->_error('ftp_unable_to_download');
+                       }
+                       return FALSE;
+               }
+
+               return TRUE;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Rename (or move) a file
+        *
+        * @access      public
+        * @param       string
+        * @param       string
+        * @param       bool
+        * @return      bool
+        */
+       function rename($old_file, $new_file, $move = FALSE)
+       {
+               if ( ! $this->_is_conn())
+               {
+                       return FALSE;
+               }
+
+               $result = @ftp_rename($this->conn_id, $old_file, $new_file);
+
+               if ($result === FALSE)
+               {
+                       if ($this->debug == TRUE)
+                       {
+                               $msg = ($move == FALSE) ? 'ftp_unable_to_rename' : 'ftp_unable_to_move';
+
+                               $this->_error($msg);
+                       }
+                       return FALSE;
+               }
+
+               return TRUE;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Move a file
+        *
+        * @access      public
+        * @param       string
+        * @param       string
+        * @return      bool
+        */
+       function move($old_file, $new_file)
+       {
+               return $this->rename($old_file, $new_file, TRUE);
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Rename (or move) a file
+        *
+        * @access      public
+        * @param       string
+        * @return      bool
+        */
+       function delete_file($filepath)
+       {
+               if ( ! $this->_is_conn())
+               {
+                       return FALSE;
+               }
+
+               $result = @ftp_delete($this->conn_id, $filepath);
+
+               if ($result === FALSE)
+               {
+                       if ($this->debug == TRUE)
+                       {
+                               $this->_error('ftp_unable_to_delete');
+                       }
+                       return FALSE;
+               }
+
+               return TRUE;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Delete a folder and recursively delete everything (including sub-folders)
+        * containted within it.
+        *
+        * @access      public
+        * @param       string
+        * @return      bool
+        */
+       function delete_dir($filepath)
+       {
+               if ( ! $this->_is_conn())
+               {
+                       return FALSE;
+               }
+
+               // Add a trailing slash to the file path if needed
+               $filepath = preg_replace("/(.+?)\/*$/", "\\1/",  $filepath);
+
+               $list = $this->list_files($filepath);
+
+               if ($list !== FALSE AND count($list) > 0)
+               {
+                       foreach ($list as $item)
+                       {
+                               // If we can't delete the item it's probaly a folder so
+                               // we'll recursively call delete_dir()
+                               if ( ! @ftp_delete($this->conn_id, $item))
+                               {
+                                       $this->delete_dir($item);
+                               }
+                       }
+               }
+
+               $result = @ftp_rmdir($this->conn_id, $filepath);
+
+               if ($result === FALSE)
+               {
+                       if ($this->debug == TRUE)
+                       {
+                               $this->_error('ftp_unable_to_delete');
+                       }
+                       return FALSE;
+               }
+
+               return TRUE;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Set file permissions
+        *
+        * @access      public
+        * @param       string  the file path
+        * @param       string  the permissions
+        * @return      bool
+        */
+       function chmod($path, $perm)
+       {
+               if ( ! $this->_is_conn())
+               {
+                       return FALSE;
+               }
+
+               // Permissions can only be set when running PHP 5
+               if ( ! function_exists('ftp_chmod'))
+               {
+                       if ($this->debug == TRUE)
+                       {
+                               $this->_error('ftp_unable_to_chmod');
+                       }
+                       return FALSE;
+               }
+
+               $result = @ftp_chmod($this->conn_id, $perm, $path);
+
+               if ($result === FALSE)
+               {
+                       if ($this->debug == TRUE)
+                       {
+                               $this->_error('ftp_unable_to_chmod');
+                       }
+                       return FALSE;
+               }
+
+               return TRUE;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * FTP List files in the specified directory
+        *
+        * @access      public
+        * @return      array
+        */
+       function list_files($path = '.')
+       {
+               if ( ! $this->_is_conn())
+               {
+                       return FALSE;
+               }
+
+               return ftp_nlist($this->conn_id, $path);
+       }
+
+       // ------------------------------------------------------------------------
+
+       /**
+        * Read a directory and recreate it remotely
+        *
+        * This function recursively reads a folder and everything it contains (including
+        * sub-folders) and creates a mirror via FTP based on it.  Whatever the directory structure
+        * of the original file path will be recreated on the server.
+        *
+        * @access      public
+        * @param       string  path to source with trailing slash
+        * @param       string  path to destination - include the base folder with trailing slash
+        * @return      bool
+        */
+       function mirror($locpath, $rempath)
+       {
+               if ( ! $this->_is_conn())
+               {
+                       return FALSE;
+               }
+
+               // Open the local file path
+               if ($fp = @opendir($locpath))
+               {
+                       // Attempt to open the remote file path.
+                       if ( ! $this->changedir($rempath, TRUE))
+                       {
+                               // If it doesn't exist we'll attempt to create the direcotory
+                               if ( ! $this->mkdir($rempath) OR ! $this->changedir($rempath))
+                               {
+                                       return FALSE;
+                               }
+                       }
+
+                       // Recursively read the local directory
+                       while (FALSE !== ($file = readdir($fp)))
+                       {
+                               if (@is_dir($locpath.$file) && substr($file, 0, 1) != '.')
+                               {
+                                       $this->mirror($locpath.$file."/", $rempath.$file."/");
+                               }
+                               elseif (substr($file, 0, 1) != ".")
+                               {
+                                       // Get the file extension so we can se the upload type
+                                       $ext = $this->_getext($file);
+                                       $mode = $this->_settype($ext);
+
+                                       $this->upload($locpath.$file, $rempath.$file, $mode);
+                               }
+                       }
+                       return TRUE;
+               }
+
+               return FALSE;
+       }
+
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Extract the file extension
+        *
+        * @access      private
+        * @param       string
+        * @return      string
+        */
+       function _getext($filename)
+       {
+               if (FALSE === strpos($filename, '.'))
+               {
+                       return 'txt';
+               }
+
+               $x = explode('.', $filename);
+               return end($x);
+       }
+
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Set the upload type
+        *
+        * @access      private
+        * @param       string
+        * @return      string
+        */
+       function _settype($ext)
+       {
+               $text_types = array(
+                                                       'txt',
+                                                       'text',
+                                                       'php',
+                                                       'phps',
+                                                       'php4',
+                                                       'js',
+                                                       'css',
+                                                       'htm',
+                                                       'html',
+                                                       'phtml',
+                                                       'shtml',
+                                                       'log',
+                                                       'xml'
+                                                       );
+
+
+               return (in_array($ext, $text_types)) ? 'ascii' : 'binary';
+       }
+
+       // ------------------------------------------------------------------------
+
+       /**
+        * Close the connection
+        *
+        * @access      public
+        * @param       string  path to source
+        * @param       string  path to destination
+        * @return      bool
+        */
+       function close()
+       {
+               if ( ! $this->_is_conn())
+               {
+                       return FALSE;
+               }
+
+               @ftp_close($this->conn_id);
+       }
+
+       // ------------------------------------------------------------------------
+
+       /**
+        * Display error message
+        *
+        * @access      private
+        * @param       string
+        * @return      bool
+        */
+       function _error($line)
+       {
+               $CI =& get_instance();
+               $CI->lang->load('ftp');
+               show_error($CI->lang->line($line));
+       }
+
+
+}
+// END FTP Class
+
+/* End of file Ftp.php */
+/* Location: ./system/libraries/Ftp.php */
\ No newline at end of file
diff --git a/system/libraries/Image_lib.php b/system/libraries/Image_lib.php
new file mode 100755 (executable)
index 0000000..8902f52
--- /dev/null
@@ -0,0 +1,1537 @@
+<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+/**
+ * CodeIgniter
+ *
+ * An open source application development framework for PHP 5.1.6 or newer
+ *
+ * @package            CodeIgniter
+ * @author             ExpressionEngine Dev Team
+ * @copyright  Copyright (c) 2008 - 2011, EllisLab, Inc.
+ * @license            http://codeigniter.com/user_guide/license.html
+ * @link               http://codeigniter.com
+ * @since              Version 1.0
+ * @filesource
+ */
+
+// ------------------------------------------------------------------------
+
+/**
+ * Image Manipulation class
+ *
+ * @package            CodeIgniter
+ * @subpackage Libraries
+ * @category   Image_lib
+ * @author             ExpressionEngine Dev Team
+ * @link               http://codeigniter.com/user_guide/libraries/image_lib.html
+ */
+class CI_Image_lib {
+
+       var $image_library              = 'gd2';        // Can be:  imagemagick, netpbm, gd, gd2
+       var $library_path               = '';
+       var $dynamic_output             = FALSE;        // Whether to send to browser or write to disk
+       var $source_image               = '';
+       var $new_image                  = '';
+       var $width                              = '';
+       var $height                             = '';
+       var $quality                    = '90';
+       var $create_thumb               = FALSE;
+       var $thumb_marker               = '_thumb';
+       var $maintain_ratio             = TRUE;         // Whether to maintain aspect ratio when resizing or use hard values
+       var $master_dim                 = 'auto';       // auto, height, or width.  Determines what to use as the master dimension
+       var $rotation_angle             = '';
+       var $x_axis                             = '';
+       var     $y_axis                         = '';
+
+       // Watermark Vars
+       var $wm_text                    = '';                   // Watermark text if graphic is not used
+       var $wm_type                    = 'text';               // Type of watermarking.  Options:  text/overlay
+       var $wm_x_transp                = 4;
+       var $wm_y_transp                = 4;
+       var $wm_overlay_path    = '';                   // Watermark image path
+       var $wm_font_path               = '';                   // TT font
+       var $wm_font_size               = 17;                   // Font size (different versions of GD will either use points or pixels)
+       var $wm_vrt_alignment   = 'B';                  // Vertical alignment:   T M B
+       var $wm_hor_alignment   = 'C';                  // Horizontal alignment: L R C
+       var $wm_padding                 = 0;                    // Padding around text
+       var $wm_hor_offset              = 0;                    // Lets you push text to the right
+       var $wm_vrt_offset              = 0;                    // Lets you push  text down
+       var $wm_font_color              = '#ffffff';    // Text color
+       var $wm_shadow_color    = '';                   // Dropshadow color
+       var $wm_shadow_distance = 2;                    // Dropshadow distance
+       var $wm_opacity                 = 50;                   // Image opacity: 1 - 100  Only works with image
+
+       // Private Vars
+       var $source_folder              = '';
+       var $dest_folder                = '';
+       var $mime_type                  = '';
+       var $orig_width                 = '';
+       var $orig_height                = '';
+       var $image_type                 = '';
+       var $size_str                   = '';
+       var $full_src_path              = '';
+       var $full_dst_path              = '';
+       var $create_fnc                 = 'imagecreatetruecolor';
+       var $copy_fnc                   = 'imagecopyresampled';
+       var $error_msg                  = array();
+       var $wm_use_drop_shadow = FALSE;
+       var $wm_use_truetype    = FALSE;
+
+       /**
+        * Constructor
+        *
+        * @param       string
+        * @return      void
+        */
+       public function __construct($props = array())
+       {
+               if (count($props) > 0)
+               {
+                       $this->initialize($props);
+               }
+
+               log_message('debug', "Image Lib Class Initialized");
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Initialize image properties
+        *
+        * Resets values in case this class is used in a loop
+        *
+        * @access      public
+        * @return      void
+        */
+       function clear()
+       {
+               $props = array('source_folder', 'dest_folder', 'source_image', 'full_src_path', 'full_dst_path', 'new_image', 'image_type', 'size_str', 'quality', 'orig_width', 'orig_height', 'rotation_angle', 'x_axis', 'y_axis', 'create_fnc', 'copy_fnc', 'wm_overlay_path', 'wm_use_truetype', 'dynamic_output', 'wm_font_size', 'wm_text', 'wm_vrt_alignment', 'wm_hor_alignment', 'wm_padding', 'wm_hor_offset', 'wm_vrt_offset', 'wm_font_color', 'wm_use_drop_shadow', 'wm_shadow_color', 'wm_shadow_distance', 'wm_opacity');
+
+               foreach ($props as $val)
+               {
+                       $this->$val = '';
+               }
+
+               // special consideration for master_dim
+               $this->master_dim = 'auto';
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * initialize image preferences
+        *
+        * @access      public
+        * @param       array
+        * @return      bool
+        */
+       function initialize($props = array())
+       {
+               /*
+                * Convert array elements into class variables
+                */
+               if (count($props) > 0)
+               {
+                       foreach ($props as $key => $val)
+                       {
+                               $this->$key = $val;
+                       }
+               }
+
+               /*
+                * Is there a source image?
+                *
+                * If not, there's no reason to continue
+                *
+                */
+               if ($this->source_image == '')
+               {
+                       $this->set_error('imglib_source_image_required');
+                       return FALSE;   
+               }
+
+               /*
+                * Is getimagesize() Available?
+                *
+                * We use it to determine the image properties (width/height).
+                * Note:  We need to figure out how to determine image
+                * properties using ImageMagick and NetPBM
+                *
+                */
+               if ( ! function_exists('getimagesize'))
+               {
+                       $this->set_error('imglib_gd_required_for_props');
+                       return FALSE;
+               }
+
+               $this->image_library = strtolower($this->image_library);
+
+               /*
+                * Set the full server path
+                *
+                * The source image may or may not contain a path.
+                * Either way, we'll try use realpath to generate the
+                * full server path in order to more reliably read it.
+                *
+                */
+               if (function_exists('realpath') AND @realpath($this->source_image) !== FALSE)
+               {
+                       $full_source_path = str_replace("\\", "/", realpath($this->source_image));
+               }
+               else
+               {
+                       $full_source_path = $this->source_image;
+               }
+
+               $x = explode('/', $full_source_path);
+               $this->source_image = end($x);
+               $this->source_folder = str_replace($this->source_image, '', $full_source_path);
+
+               // Set the Image Properties
+               if ( ! $this->get_image_properties($this->source_folder.$this->source_image))
+               {
+                       return FALSE;   
+               }
+
+               /*
+                * Assign the "new" image name/path
+                *
+                * If the user has set a "new_image" name it means
+                * we are making a copy of the source image. If not
+                * it means we are altering the original.  We'll
+                * set the destination filename and path accordingly.
+                *
+                */
+               if ($this->new_image == '')
+               {
+                       $this->dest_image = $this->source_image;
+                       $this->dest_folder = $this->source_folder;
+               }
+               else
+               {
+                       if (strpos($this->new_image, '/') === FALSE)
+                       {
+                               $this->dest_folder = $this->source_folder;
+                               $this->dest_image = $this->new_image;
+                       }
+                       else
+                       {
+                               if (function_exists('realpath') AND @realpath($this->new_image) !== FALSE)
+                               {
+                                       $full_dest_path = str_replace("\\", "/", realpath($this->new_image));
+                               }
+                               else
+                               {
+                                       $full_dest_path = $this->new_image;
+                               }
+
+                               // Is there a file name?
+                               if ( ! preg_match("#\.(jpg|jpeg|gif|png)$#i", $full_dest_path))
+                               {
+                                       $this->dest_folder = $full_dest_path.'/';
+                                       $this->dest_image = $this->source_image;
+                               }
+                               else
+                               {
+                                       $x = explode('/', $full_dest_path);
+                                       $this->dest_image = end($x);
+                                       $this->dest_folder = str_replace($this->dest_image, '', $full_dest_path);
+                               }
+                       }
+               }
+
+               /*
+                * Compile the finalized filenames/paths
+                *
+                * We'll create two master strings containing the
+                * full server path to the source image and the
+                * full server path to the destination image.
+                * We'll also split the destination image name
+                * so we can insert the thumbnail marker if needed.
+                *
+                */
+               if ($this->create_thumb === FALSE OR $this->thumb_marker == '')
+               {
+                       $this->thumb_marker = '';
+               }
+
+               $xp     = $this->explode_name($this->dest_image);
+
+               $filename = $xp['name'];
+               $file_ext = $xp['ext'];
+
+               $this->full_src_path = $this->source_folder.$this->source_image;
+               $this->full_dst_path = $this->dest_folder.$filename.$this->thumb_marker.$file_ext;
+
+               /*
+                * Should we maintain image proportions?
+                *
+                * When creating thumbs or copies, the target width/height
+                * might not be in correct proportion with the source
+                * image's width/height.  We'll recalculate it here.
+                *
+                */
+               if ($this->maintain_ratio === TRUE && ($this->width != '' AND $this->height != ''))
+               {
+                       $this->image_reproportion();
+               }
+
+               /*
+                * Was a width and height specified?
+                *
+                * If the destination width/height was
+                * not submitted we will use the values
+                * from the actual file
+                *
+                */
+               if ($this->width == '')
+                       $this->width = $this->orig_width;
+
+               if ($this->height == '')
+                       $this->height = $this->orig_height;
+
+               // Set the quality
+               $this->quality = trim(str_replace("%", "", $this->quality));
+
+               if ($this->quality == '' OR $this->quality == 0 OR ! is_numeric($this->quality))
+                       $this->quality = 90;
+
+               // Set the x/y coordinates
+               $this->x_axis = ($this->x_axis == '' OR ! is_numeric($this->x_axis)) ? 0 : $this->x_axis;
+               $this->y_axis = ($this->y_axis == '' OR ! is_numeric($this->y_axis)) ? 0 : $this->y_axis;
+
+               // Watermark-related Stuff...
+               if ($this->wm_font_color != '')
+               {
+                       if (strlen($this->wm_font_color) == 6)
+                       {
+                               $this->wm_font_color = '#'.$this->wm_font_color;
+                       }
+               }
+
+               if ($this->wm_shadow_color != '')
+               {
+                       if (strlen($this->wm_shadow_color) == 6)
+                       {
+                               $this->wm_shadow_color = '#'.$this->wm_shadow_color;
+                       }
+               }
+
+               if ($this->wm_overlay_path != '')
+               {
+                       $this->wm_overlay_path = str_replace("\\", "/", realpath($this->wm_overlay_path));
+               }
+
+               if ($this->wm_shadow_color != '')
+               {
+                       $this->wm_use_drop_shadow = TRUE;
+               }
+
+               if ($this->wm_font_path != '')
+               {
+                       $this->wm_use_truetype = TRUE;
+               }
+
+               return TRUE;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Image Resize
+        *
+        * This is a wrapper function that chooses the proper
+        * resize function based on the protocol specified
+        *
+        * @access      public
+        * @return      bool
+        */
+       function resize()
+       {
+               $protocol = 'image_process_'.$this->image_library;
+
+               if (preg_match('/gd2$/i', $protocol))
+               {
+                       $protocol = 'image_process_gd';
+               }
+
+               return $this->$protocol('resize');
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Image Crop
+        *
+        * This is a wrapper function that chooses the proper
+        * cropping function based on the protocol specified
+        *
+        * @access      public
+        * @return      bool
+        */
+       function crop()
+       {
+               $protocol = 'image_process_'.$this->image_library;
+
+               if (preg_match('/gd2$/i', $protocol))
+               {
+                       $protocol = 'image_process_gd';
+               }
+
+               return $this->$protocol('crop');
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Image Rotate
+        *
+        * This is a wrapper function that chooses the proper
+        * rotation function based on the protocol specified
+        *
+        * @access      public
+        * @return      bool
+        */
+       function rotate()
+       {
+               // Allowed rotation values
+               $degs = array(90, 180, 270, 'vrt', 'hor');
+
+               if ($this->rotation_angle == '' OR ! in_array($this->rotation_angle, $degs))
+               {
+                       $this->set_error('imglib_rotation_angle_required');
+                       return FALSE;   
+               }
+
+               // Reassign the width and height
+               if ($this->rotation_angle == 90 OR $this->rotation_angle == 270)
+               {
+                       $this->width    = $this->orig_height;
+                       $this->height   = $this->orig_width;
+               }
+               else
+               {
+                       $this->width    = $this->orig_width;
+                       $this->height   = $this->orig_height;
+               }
+
+
+               // Choose resizing function
+               if ($this->image_library == 'imagemagick' OR $this->image_library == 'netpbm')
+               {
+                       $protocol = 'image_process_'.$this->image_library;
+
+                       return $this->$protocol('rotate');
+               }
+
+               if ($this->rotation_angle == 'hor' OR $this->rotation_angle == 'vrt')
+               {
+                       return $this->image_mirror_gd();
+               }
+               else
+               {
+                       return $this->image_rotate_gd();
+               }
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Image Process Using GD/GD2
+        *
+        * This function will resize or crop
+        *
+        * @access      public
+        * @param       string
+        * @return      bool
+        */
+       function image_process_gd($action = 'resize')
+       {
+               $v2_override = FALSE;
+
+               // If the target width/height match the source, AND if the new file name is not equal to the old file name
+               // we'll simply make a copy of the original with the new name... assuming dynamic rendering is off.
+               if ($this->dynamic_output === FALSE)
+               {
+                       if ($this->orig_width == $this->width AND $this->orig_height == $this->height)
+                       {
+                               if ($this->source_image != $this->new_image)
+                               {
+                                       if (@copy($this->full_src_path, $this->full_dst_path))
+                                       {
+                                               @chmod($this->full_dst_path, FILE_WRITE_MODE);
+                                       }
+                               }
+
+                               return TRUE;
+                       }
+               }
+
+               // Let's set up our values based on the action
+               if ($action == 'crop')
+               {
+                       //  Reassign the source width/height if cropping
+                       $this->orig_width  = $this->width;
+                       $this->orig_height = $this->height;
+
+                       // GD 2.0 has a cropping bug so we'll test for it
+                       if ($this->gd_version() !== FALSE)
+                       {
+                               $gd_version = str_replace('0', '', $this->gd_version());
+                               $v2_override = ($gd_version == 2) ? TRUE : FALSE;
+                       }
+               }
+               else
+               {
+                       // If resizing the x/y axis must be zero
+                       $this->x_axis = 0;
+                       $this->y_axis = 0;
+               }
+
+               //  Create the image handle
+               if ( ! ($src_img = $this->image_create_gd()))
+               {
+                       return FALSE;
+               }
+
+               //  Create The Image
+               //
+               //  old conditional which users report cause problems with shared GD libs who report themselves as "2.0 or greater"
+               //  it appears that this is no longer the issue that it was in 2004, so we've removed it, retaining it in the comment
+               //  below should that ever prove inaccurate.
+               //
+               //  if ($this->image_library == 'gd2' AND function_exists('imagecreatetruecolor') AND $v2_override == FALSE)
+               if ($this->image_library == 'gd2' AND function_exists('imagecreatetruecolor'))
+               {
+                       $create = 'imagecreatetruecolor';
+                       $copy   = 'imagecopyresampled';
+               }
+               else
+               {
+                       $create = 'imagecreate';
+                       $copy   = 'imagecopyresized';
+               }
+
+               $dst_img = $create($this->width, $this->height);
+
+               if ($this->image_type == 3) // png we can actually preserve transparency
+               {
+                       imagealphablending($dst_img, FALSE);
+                       imagesavealpha($dst_img, TRUE);
+               }
+
+               $copy($dst_img, $src_img, 0, 0, $this->x_axis, $this->y_axis, $this->width, $this->height, $this->orig_width, $this->orig_height);
+
+               //  Show the image
+               if ($this->dynamic_output == TRUE)
+               {
+                       $this->image_display_gd($dst_img);
+               }
+               else
+               {
+                       // Or save it
+                       if ( ! $this->image_save_gd($dst_img))
+                       {
+                               return FALSE;
+                       }
+               }
+
+               //  Kill the file handles
+               imagedestroy($dst_img);
+               imagedestroy($src_img);
+
+               // Set the file to 777
+               @chmod($this->full_dst_path, FILE_WRITE_MODE);
+
+               return TRUE;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Image Process Using ImageMagick
+        *
+        * This function will resize, crop or rotate
+        *
+        * @access      public
+        * @param       string
+        * @return      bool
+        */
+       function image_process_imagemagick($action = 'resize')
+       {
+               //  Do we have a vaild library path?
+               if ($this->library_path == '')
+               {
+                       $this->set_error('imglib_libpath_invalid');
+                       return FALSE;
+               }
+
+               if ( ! preg_match("/convert$/i", $this->library_path))
+               {
+                       $this->library_path = rtrim($this->library_path, '/').'/';
+
+                       $this->library_path .= 'convert';
+               }
+
+               // Execute the command
+               $cmd = $this->library_path." -quality ".$this->quality;
+
+               if ($action == 'crop')
+               {
+                       $cmd .= " -crop ".$this->width."x".$this->height."+".$this->x_axis."+".$this->y_axis." \"$this->full_src_path\" \"$this->full_dst_path\" 2>&1";
+               }
+               elseif ($action == 'rotate')
+               {
+                       switch ($this->rotation_angle)
+                       {
+                               case 'hor'      : $angle = '-flop';
+                                       break;
+                               case 'vrt'      : $angle = '-flip';
+                                       break;
+                               default         : $angle = '-rotate '.$this->rotation_angle;
+                                       break;
+                       }
+
+                       $cmd .= " ".$angle." \"$this->full_src_path\" \"$this->full_dst_path\" 2>&1";
+               }
+               else  // Resize
+               {
+                       $cmd .= " -resize ".$this->width."x".$this->height." \"$this->full_src_path\" \"$this->full_dst_path\" 2>&1";
+               }
+
+               $retval = 1;
+
+               @exec($cmd, $output, $retval);
+
+               //      Did it work?
+               if ($retval > 0)
+               {
+                       $this->set_error('imglib_image_process_failed');
+                       return FALSE;
+               }
+
+               // Set the file to 777
+               @chmod($this->full_dst_path, FILE_WRITE_MODE);
+
+               return TRUE;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Image Process Using NetPBM
+        *
+        * This function will resize, crop or rotate
+        *
+        * @access      public
+        * @param       string
+        * @return      bool
+        */
+       function image_process_netpbm($action = 'resize')
+       {
+               if ($this->library_path == '')
+               {
+                       $this->set_error('imglib_libpath_invalid');
+                       return FALSE;
+               }
+
+               //  Build the resizing command
+               switch ($this->image_type)
+               {
+                       case 1 :
+                                               $cmd_in         = 'giftopnm';
+                                               $cmd_out        = 'ppmtogif';
+                               break;
+                       case 2 :
+                                               $cmd_in         = 'jpegtopnm';
+                                               $cmd_out        = 'ppmtojpeg';
+                               break;
+                       case 3 :
+                                               $cmd_in         = 'pngtopnm';
+                                               $cmd_out        = 'ppmtopng';
+                               break;
+               }
+
+               if ($action == 'crop')
+               {
+                       $cmd_inner = 'pnmcut -left '.$this->x_axis.' -top '.$this->y_axis.' -width '.$this->width.' -height '.$this->height;
+               }
+               elseif ($action == 'rotate')
+               {
+                       switch ($this->rotation_angle)
+                       {
+                               case 90         :       $angle = 'r270';
+                                       break;
+                               case 180        :       $angle = 'r180';
+                                       break;
+                               case 270        :       $angle = 'r90';
+                                       break;
+                               case 'vrt'      :       $angle = 'tb';
+                                       break;
+                               case 'hor'      :       $angle = 'lr';
+                                       break;
+                       }
+
+                       $cmd_inner = 'pnmflip -'.$angle.' ';
+               }
+               else // Resize
+               {
+                       $cmd_inner = 'pnmscale -xysize '.$this->width.' '.$this->height;
+               }
+
+               $cmd = $this->library_path.$cmd_in.' '.$this->full_src_path.' | '.$cmd_inner.' | '.$cmd_out.' > '.$this->dest_folder.'netpbm.tmp';
+
+               $retval = 1;
+
+               @exec($cmd, $output, $retval);
+
+               //  Did it work?
+               if ($retval > 0)
+               {
+                       $this->set_error('imglib_image_process_failed');
+                       return FALSE;
+               }
+
+               // With NetPBM we have to create a temporary image.
+               // If you try manipulating the original it fails so
+               // we have to rename the temp file.
+               copy ($this->dest_folder.'netpbm.tmp', $this->full_dst_path);
+               unlink ($this->dest_folder.'netpbm.tmp');
+               @chmod($this->full_dst_path, FILE_WRITE_MODE);
+
+               return TRUE;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Image Rotate Using GD
+        *
+        * @access      public
+        * @return      bool
+        */
+       function image_rotate_gd()
+       {
+               //  Create the image handle
+               if ( ! ($src_img = $this->image_create_gd()))
+               {
+                       return FALSE;
+               }
+
+               // Set the background color
+               // This won't work with transparent PNG files so we are
+               // going to have to figure out how to determine the color
+               // of the alpha channel in a future release.
+
+               $white  = imagecolorallocate($src_img, 255, 255, 255);
+
+               //  Rotate it!
+               $dst_img = imagerotate($src_img, $this->rotation_angle, $white);
+
+               //  Save the Image
+               if ($this->dynamic_output == TRUE)
+               {
+                       $this->image_display_gd($dst_img);
+               }
+               else
+               {
+                       // Or save it
+                       if ( ! $this->image_save_gd($dst_img))
+                       {
+                               return FALSE;
+                       }
+               }
+
+               //  Kill the file handles
+               imagedestroy($dst_img);
+               imagedestroy($src_img);
+
+               // Set the file to 777
+
+               @chmod($this->full_dst_path, FILE_WRITE_MODE);
+
+               return TRUE;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Create Mirror Image using GD
+        *
+        * This function will flip horizontal or vertical
+        *
+        * @access      public
+        * @return      bool
+        */
+       function image_mirror_gd()
+       {
+               if ( ! $src_img = $this->image_create_gd())
+               {
+                       return FALSE;
+               }
+
+               $width  = $this->orig_width;
+               $height = $this->orig_height;
+
+               if ($this->rotation_angle == 'hor')
+               {
+                       for ($i = 0; $i < $height; $i++)
+                       {
+                               $left  = 0;
+                               $right = $width-1;
+
+                               while ($left < $right)
+                               {
+                                       $cl = imagecolorat($src_img, $left, $i);
+                                       $cr = imagecolorat($src_img, $right, $i);
+
+                                       imagesetpixel($src_img, $left, $i, $cr);
+                                       imagesetpixel($src_img, $right, $i, $cl);
+
+                                       $left++;
+                                       $right--;
+                               }
+                       }
+               }
+               else
+               {
+                       for ($i = 0; $i < $width; $i++)
+                       {
+                               $top = 0;
+                               $bot = $height-1;
+
+                               while ($top < $bot)
+                               {
+                                       $ct = imagecolorat($src_img, $i, $top);
+                                       $cb = imagecolorat($src_img, $i, $bot);
+
+                                       imagesetpixel($src_img, $i, $top, $cb);
+                                       imagesetpixel($src_img, $i, $bot, $ct);
+
+                                       $top++;
+                                       $bot--;
+                               }
+                       }
+               }
+
+               //  Show the image
+               if ($this->dynamic_output == TRUE)
+               {
+                       $this->image_display_gd($src_img);
+               }
+               else
+               {
+                       // Or save it
+                       if ( ! $this->image_save_gd($src_img))
+                       {
+                               return FALSE;
+                       }
+               }
+
+               //  Kill the file handles
+               imagedestroy($src_img);
+
+               // Set the file to 777
+               @chmod($this->full_dst_path, FILE_WRITE_MODE);
+
+               return TRUE;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Image Watermark
+        *
+        * This is a wrapper function that chooses the type
+        * of watermarking based on the specified preference.
+        *
+        * @access      public
+        * @param       string
+        * @return      bool
+        */
+       function watermark()
+       {
+               if ($this->wm_type == 'overlay')
+               {
+                       return $this->overlay_watermark();
+               }
+               else
+               {
+                       return $this->text_watermark();
+               }
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Watermark - Graphic Version
+        *
+        * @access      public
+        * @return      bool
+        */
+       function overlay_watermark()
+       {
+               if ( ! function_exists('imagecolortransparent'))
+               {
+                       $this->set_error('imglib_gd_required');
+                       return FALSE;
+               }
+
+               //  Fetch source image properties
+               $this->get_image_properties();
+
+               //  Fetch watermark image properties
+               $props                  = $this->get_image_properties($this->wm_overlay_path, TRUE);
+               $wm_img_type    = $props['image_type'];
+               $wm_width               = $props['width'];
+               $wm_height              = $props['height'];
+
+               //  Create two image resources
+               $wm_img  = $this->image_create_gd($this->wm_overlay_path, $wm_img_type);
+               $src_img = $this->image_create_gd($this->full_src_path);
+
+               // Reverse the offset if necessary
+               // When the image is positioned at the bottom
+               // we don't want the vertical offset to push it
+               // further down.  We want the reverse, so we'll
+               // invert the offset.  Same with the horizontal
+               // offset when the image is at the right
+
+               $this->wm_vrt_alignment = strtoupper(substr($this->wm_vrt_alignment, 0, 1));
+               $this->wm_hor_alignment = strtoupper(substr($this->wm_hor_alignment, 0, 1));
+
+               if ($this->wm_vrt_alignment == 'B')
+                       $this->wm_vrt_offset = $this->wm_vrt_offset * -1;
+
+               if ($this->wm_hor_alignment == 'R')
+                       $this->wm_hor_offset = $this->wm_hor_offset * -1;
+
+               //  Set the base x and y axis values
+               $x_axis = $this->wm_hor_offset + $this->wm_padding;
+               $y_axis = $this->wm_vrt_offset + $this->wm_padding;
+
+               //  Set the vertical position
+               switch ($this->wm_vrt_alignment)
+               {
+                       case 'T':
+                               break;
+                       case 'M':       $y_axis += ($this->orig_height / 2) - ($wm_height / 2);
+                               break;
+                       case 'B':       $y_axis += $this->orig_height - $wm_height;
+                               break;
+               }
+
+               //  Set the horizontal position
+               switch ($this->wm_hor_alignment)
+               {
+                       case 'L':
+                               break;
+                       case 'C':       $x_axis += ($this->orig_width / 2) - ($wm_width / 2);
+                               break;
+                       case 'R':       $x_axis += $this->orig_width - $wm_width;
+                               break;
+               }
+
+               //  Build the finalized image
+               if ($wm_img_type == 3 AND function_exists('imagealphablending'))
+               {
+                       @imagealphablending($src_img, TRUE);
+               }
+
+               // Set RGB values for text and shadow
+               $rgba = imagecolorat($wm_img, $this->wm_x_transp, $this->wm_y_transp);
+               $alpha = ($rgba & 0x7F000000) >> 24;
+
+               // make a best guess as to whether we're dealing with an image with alpha transparency or no/binary transparency
+               if ($alpha > 0)
+               {
+                       // copy the image directly, the image's alpha transparency being the sole determinant of blending
+                       imagecopy($src_img, $wm_img, $x_axis, $y_axis, 0, 0, $wm_width, $wm_height);
+               }
+               else
+               {
+                       // set our RGB value from above to be transparent and merge the images with the specified opacity
+                       imagecolortransparent($wm_img, imagecolorat($wm_img, $this->wm_x_transp, $this->wm_y_transp));
+                       imagecopymerge($src_img, $wm_img, $x_axis, $y_axis, 0, 0, $wm_width, $wm_height, $this->wm_opacity);
+               }
+
+               //  Output the image
+               if ($this->dynamic_output == TRUE)
+               {
+                       $this->image_display_gd($src_img);
+               }
+               else
+               {
+                       if ( ! $this->image_save_gd($src_img))
+                       {
+                               return FALSE;
+                       }
+               }
+
+               imagedestroy($src_img);
+               imagedestroy($wm_img);
+
+               return TRUE;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Watermark - Text Version
+        *
+        * @access      public
+        * @return      bool
+        */
+       function text_watermark()
+       {
+               if ( ! ($src_img = $this->image_create_gd()))
+               {
+                       return FALSE;
+               }
+
+               if ($this->wm_use_truetype == TRUE AND ! file_exists($this->wm_font_path))
+               {
+                       $this->set_error('imglib_missing_font');
+                       return FALSE;
+               }
+
+               //  Fetch source image properties
+               $this->get_image_properties();
+
+               // Set RGB values for text and shadow
+               $this->wm_font_color    = str_replace('#', '', $this->wm_font_color);
+               $this->wm_shadow_color  = str_replace('#', '', $this->wm_shadow_color);
+
+               $R1 = hexdec(substr($this->wm_font_color, 0, 2));
+               $G1 = hexdec(substr($this->wm_font_color, 2, 2));
+               $B1 = hexdec(substr($this->wm_font_color, 4, 2));
+
+               $R2 = hexdec(substr($this->wm_shadow_color, 0, 2));
+               $G2 = hexdec(substr($this->wm_shadow_color, 2, 2));
+               $B2 = hexdec(substr($this->wm_shadow_color, 4, 2));
+
+               $txt_color      = imagecolorclosest($src_img, $R1, $G1, $B1);
+               $drp_color      = imagecolorclosest($src_img, $R2, $G2, $B2);
+
+               // Reverse the vertical offset
+               // When the image is positioned at the bottom
+               // we don't want the vertical offset to push it
+               // further down.  We want the reverse, so we'll
+               // invert the offset.  Note: The horizontal
+               // offset flips itself automatically
+
+               if ($this->wm_vrt_alignment == 'B')
+                       $this->wm_vrt_offset = $this->wm_vrt_offset * -1;
+
+               if ($this->wm_hor_alignment == 'R')
+                       $this->wm_hor_offset = $this->wm_hor_offset * -1;
+
+               // Set font width and height
+               // These are calculated differently depending on
+               // whether we are using the true type font or not
+               if ($this->wm_use_truetype == TRUE)
+               {
+                       if ($this->wm_font_size == '')
+                               $this->wm_font_size = '17';
+
+                       $fontwidth  = $this->wm_font_size-($this->wm_font_size/4);
+                       $fontheight = $this->wm_font_size;
+                       $this->wm_vrt_offset += $this->wm_font_size;
+               }
+               else
+               {
+                       $fontwidth  = imagefontwidth($this->wm_font_size);
+                       $fontheight = imagefontheight($this->wm_font_size);
+               }
+
+               // Set base X and Y axis values
+               $x_axis = $this->wm_hor_offset + $this->wm_padding;
+               $y_axis = $this->wm_vrt_offset + $this->wm_padding;
+
+               // Set verticle alignment
+               if ($this->wm_use_drop_shadow == FALSE)
+                       $this->wm_shadow_distance = 0;
+
+               $this->wm_vrt_alignment = strtoupper(substr($this->wm_vrt_alignment, 0, 1));
+               $this->wm_hor_alignment = strtoupper(substr($this->wm_hor_alignment, 0, 1));
+
+               switch ($this->wm_vrt_alignment)
+               {
+                       case     "T" :
+                               break;
+                       case "M":       $y_axis += ($this->orig_height/2)+($fontheight/2);
+                               break;
+                       case "B":       $y_axis += ($this->orig_height - $fontheight - $this->wm_shadow_distance - ($fontheight/2));
+                               break;
+               }
+
+               $x_shad = $x_axis + $this->wm_shadow_distance;
+               $y_shad = $y_axis + $this->wm_shadow_distance;
+
+               // Set horizontal alignment
+               switch ($this->wm_hor_alignment)
+               {
+                       case "L":
+                               break;
+                       case "R":
+                                               if ($this->wm_use_drop_shadow)
+                                                       $x_shad += ($this->orig_width - $fontwidth*strlen($this->wm_text));
+                                                       $x_axis += ($this->orig_width - $fontwidth*strlen($this->wm_text));
+                               break;
+                       case "C":
+                                               if ($this->wm_use_drop_shadow)
+                                                       $x_shad += floor(($this->orig_width - $fontwidth*strlen($this->wm_text))/2);
+                                                       $x_axis += floor(($this->orig_width  -$fontwidth*strlen($this->wm_text))/2);
+                               break;
+               }
+
+               //  Add the text to the source image
+               if ($this->wm_use_truetype)
+               {
+                       if ($this->wm_use_drop_shadow)
+                               imagettftext($src_img, $this->wm_font_size, 0, $x_shad, $y_shad, $drp_color, $this->wm_font_path, $this->wm_text);
+                               imagettftext($src_img, $this->wm_font_size, 0, $x_axis, $y_axis, $txt_color, $this->wm_font_path, $this->wm_text);
+               }
+               else
+               {
+                       if ($this->wm_use_drop_shadow)
+                               imagestring($src_img, $this->wm_font_size, $x_shad, $y_shad, $this->wm_text, $drp_color);
+                               imagestring($src_img, $this->wm_font_size, $x_axis, $y_axis, $this->wm_text, $txt_color);
+               }
+
+               //  Output the final image
+               if ($this->dynamic_output == TRUE)
+               {
+                       $this->image_display_gd($src_img);
+               }
+               else
+               {
+                       $this->image_save_gd($src_img);
+               }
+
+               imagedestroy($src_img);
+
+               return TRUE;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Create Image - GD
+        *
+        * This simply creates an image resource handle
+        * based on the type of image being processed
+        *
+        * @access      public
+        * @param       string
+        * @return      resource
+        */
+       function image_create_gd($path = '', $image_type = '')
+       {
+               if ($path == '')
+                       $path = $this->full_src_path;
+
+               if ($image_type == '')
+                       $image_type = $this->image_type;
+
+
+               switch ($image_type)
+               {
+                       case     1 :
+                                               if ( ! function_exists('imagecreatefromgif'))
+                                               {
+                                                       $this->set_error(array('imglib_unsupported_imagecreate', 'imglib_gif_not_supported'));
+                                                       return FALSE;
+                                               }
+
+                                               return imagecreatefromgif($path);
+                               break;
+                       case 2 :
+                                               if ( ! function_exists('imagecreatefromjpeg'))
+                                               {
+                                                       $this->set_error(array('imglib_unsupported_imagecreate', 'imglib_jpg_not_supported'));
+                                                       return FALSE;
+                                               }
+
+                                               return imagecreatefromjpeg($path);
+                               break;
+                       case 3 :
+                                               if ( ! function_exists('imagecreatefrompng'))
+                                               {
+                                                       $this->set_error(array('imglib_unsupported_imagecreate', 'imglib_png_not_supported'));
+                                                       return FALSE;
+                                               }
+
+                                               return imagecreatefrompng($path);
+                               break;
+
+               }
+
+               $this->set_error(array('imglib_unsupported_imagecreate'));
+               return FALSE;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Write image file to disk - GD
+        *
+        * Takes an image resource as input and writes the file
+        * to the specified destination
+        *
+        * @access      public
+        * @param       resource
+        * @return      bool
+        */
+       function image_save_gd($resource)
+       {
+               switch ($this->image_type)
+               {
+                       case 1 :
+                                               if ( ! function_exists('imagegif'))
+                                               {
+                                                       $this->set_error(array('imglib_unsupported_imagecreate', 'imglib_gif_not_supported'));
+                                                       return FALSE;
+                                               }
+
+                                               if ( ! @imagegif($resource, $this->full_dst_path))
+                                               {
+                                                       $this->set_error('imglib_save_failed');
+                                                       return FALSE;
+                                               }
+                               break;
+                       case 2  :
+                                               if ( ! function_exists('imagejpeg'))
+                                               {
+                                                       $this->set_error(array('imglib_unsupported_imagecreate', 'imglib_jpg_not_supported'));
+                                                       return FALSE;
+                                               }
+
+                                               if ( ! @imagejpeg($resource, $this->full_dst_path, $this->quality))
+                                               {
+                                                       $this->set_error('imglib_save_failed');
+                                                       return FALSE;
+                                               }
+                               break;
+                       case 3  :
+                                               if ( ! function_exists('imagepng'))
+                                               {
+                                                       $this->set_error(array('imglib_unsupported_imagecreate', 'imglib_png_not_supported'));
+                                                       return FALSE;
+                                               }
+
+                                               if ( ! @imagepng($resource, $this->full_dst_path))
+                                               {
+                                                       $this->set_error('imglib_save_failed');
+                                                       return FALSE;
+                                               }
+                               break;
+                       default         :
+                                                       $this->set_error(array('imglib_unsupported_imagecreate'));
+                                                       return FALSE;
+                               break;
+               }
+
+               return TRUE;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Dynamically outputs an image
+        *
+        * @access      public
+        * @param       resource
+        * @return      void
+        */
+       function image_display_gd($resource)
+       {
+               header("Content-Disposition: filename={$this->source_image};");
+               header("Content-Type: {$this->mime_type}");
+               header('Content-Transfer-Encoding: binary');
+               header('Last-Modified: '.gmdate('D, d M Y H:i:s', time()).' GMT');
+
+               switch ($this->image_type)
+               {
+                       case 1          :       imagegif($resource);
+                               break;
+                       case 2          :       imagejpeg($resource, '', $this->quality);
+                               break;
+                       case 3          :       imagepng($resource);
+                               break;
+                       default         :       echo 'Unable to display the image';
+                               break;
+               }
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Re-proportion Image Width/Height
+        *
+        * When creating thumbs, the desired width/height
+        * can end up warping the image due to an incorrect
+        * ratio between the full-sized image and the thumb.
+        *
+        * This function lets us re-proportion the width/height
+        * if users choose to maintain the aspect ratio when resizing.
+        *
+        * @access      public
+        * @return      void
+        */
+       function image_reproportion()
+       {
+               if ( ! is_numeric($this->width) OR ! is_numeric($this->height) OR $this->width == 0 OR $this->height == 0)
+                       return;
+
+               if ( ! is_numeric($this->orig_width) OR ! is_numeric($this->orig_height) OR $this->orig_width == 0 OR $this->orig_height == 0)
+                       return;
+
+               $new_width      = ceil($this->orig_width*$this->height/$this->orig_height);
+               $new_height     = ceil($this->width*$this->orig_height/$this->orig_width);
+
+               $ratio = (($this->orig_height/$this->orig_width) - ($this->height/$this->width));
+
+               if ($this->master_dim != 'width' AND $this->master_dim != 'height')
+               {
+                       $this->master_dim = ($ratio < 0) ? 'width' : 'height';
+               }
+
+               if (($this->width != $new_width) AND ($this->height != $new_height))
+               {
+                       if ($this->master_dim == 'height')
+                       {
+                               $this->width = $new_width;
+                       }
+                       else
+                       {
+                               $this->height = $new_height;
+                       }
+               }
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Get image properties
+        *
+        * A helper function that gets info about the file
+        *
+        * @access      public
+        * @param       string
+        * @return      mixed
+        */
+       function get_image_properties($path = '', $return = FALSE)
+       {
+               // For now we require GD but we should
+               // find a way to determine this using IM or NetPBM
+
+               if ($path == '')
+                       $path = $this->full_src_path;
+
+               if ( ! file_exists($path))
+               {
+                       $this->set_error('imglib_invalid_path');
+                       return FALSE;
+               }
+
+               $vals = @getimagesize($path);
+
+               $types = array(1 => 'gif', 2 => 'jpeg', 3 => 'png');
+
+               $mime = (isset($types[$vals['2']])) ? 'image/'.$types[$vals['2']] : 'image/jpg';
+
+               if ($return == TRUE)
+               {
+                       $v['width']                     = $vals['0'];
+                       $v['height']            = $vals['1'];
+                       $v['image_type']        = $vals['2'];
+                       $v['size_str']          = $vals['3'];
+                       $v['mime_type']         = $mime;
+
+                       return $v;
+               }
+
+               $this->orig_width       = $vals['0'];
+               $this->orig_height      = $vals['1'];
+               $this->image_type       = $vals['2'];
+               $this->size_str         = $vals['3'];
+               $this->mime_type        = $mime;
+
+               return TRUE;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Size calculator
+        *
+        * This function takes a known width x height and
+        * recalculates it to a new size.  Only one
+        * new variable needs to be known
+        *
+        *      $props = array(
+        *                                      'width'                 => $width,
+        *                                      'height'                => $height,
+        *                                      'new_width'             => 40,
+        *                                      'new_height'    => ''
+        *                                );
+        *
+        * @access      public
+        * @param       array
+        * @return      array
+        */
+       function size_calculator($vals)
+       {
+               if ( ! is_array($vals))
+               {
+                       return;
+               }
+
+               $allowed = array('new_width', 'new_height', 'width', 'height');
+
+               foreach ($allowed as $item)
+               {
+                       if ( ! isset($vals[$item]) OR $vals[$item] == '')
+                               $vals[$item] = 0;
+               }
+
+               if ($vals['width'] == 0 OR $vals['height'] == 0)
+               {
+                       return $vals;
+               }
+
+               if ($vals['new_width'] == 0)
+               {
+                       $vals['new_width'] = ceil($vals['width']*$vals['new_height']/$vals['height']);
+               }
+               elseif ($vals['new_height'] == 0)
+               {
+                       $vals['new_height'] = ceil($vals['new_width']*$vals['height']/$vals['width']);
+               }
+
+               return $vals;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Explode source_image
+        *
+        * This is a helper function that extracts the extension
+        * from the source_image.  This function lets us deal with
+        * source_images with multiple periods, like:  my.cool.jpg
+        * It returns an associative array with two elements:
+        * $array['ext']  = '.jpg';
+        * $array['name'] = 'my.cool';
+        *
+        * @access      public
+        * @param       array
+        * @return      array
+        */
+       function explode_name($source_image)
+       {
+               $ext = strrchr($source_image, '.');
+               $name = ($ext === FALSE) ? $source_image : substr($source_image, 0, -strlen($ext));
+
+               return array('ext' => $ext, 'name' => $name);
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Is GD Installed?
+        *
+        * @access      public
+        * @return      bool
+        */
+       function gd_loaded()
+       {
+               if ( ! extension_loaded('gd'))
+               {
+                       if ( ! dl('gd.so'))
+                       {
+                               return FALSE;
+                       }
+               }
+
+               return TRUE;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Get GD version
+        *
+        * @access      public
+        * @return      mixed
+        */
+       function gd_version()
+       {
+               if (function_exists('gd_info'))
+               {
+                       $gd_version = @gd_info();
+                       $gd_version = preg_replace("/\D/", "", $gd_version['GD Version']);
+
+                       return $gd_version;
+               }
+
+               return FALSE;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Set error message
+        *
+        * @access      public
+        * @param       string
+        * @return      void
+        */
+       function set_error($msg)
+       {
+               $CI =& get_instance();
+               $CI->lang->load('imglib');
+
+               if (is_array($msg))
+               {
+                       foreach ($msg as $val)
+                       {
+
+                               $msg = ($CI->lang->line($val) == FALSE) ? $val : $CI->lang->line($val);
+                               $this->error_msg[] = $msg;
+                               log_message('error', $msg);
+                       }
+               }
+               else
+               {
+                       $msg = ($CI->lang->line($msg) == FALSE) ? $msg : $CI->lang->line($msg);
+                       $this->error_msg[] = $msg;
+                       log_message('error', $msg);
+               }
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Show error messages
+        *
+        * @access      public
+        * @param       string
+        * @return      string
+        */
+       function display_errors($open = '<p>', $close = '</p>')
+       {
+               $str = '';
+               foreach ($this->error_msg as $val)
+               {
+                       $str .= $open.$val.$close;
+               }
+
+               return $str;
+       }
+
+}
+// END Image_lib Class
+
+/* End of file Image_lib.php */
+/* Location: ./system/libraries/Image_lib.php */
\ No newline at end of file
diff --git a/system/libraries/Javascript.php b/system/libraries/Javascript.php
new file mode 100755 (executable)
index 0000000..34e0d70
--- /dev/null
@@ -0,0 +1,871 @@
+<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+/**
+ * CodeIgniter
+ *
+ * An open source application development framework for PHP 5.1.6 or newer
+ *
+ * @package            CodeIgniter
+ * @author             ExpressionEngine Dev Team
+ * @copyright  Copyright (c) 2008 - 2011, EllisLab, Inc.
+ * @license            http://codeigniter.com/user_guide/license.html
+ * @link               http://codeigniter.com
+ * @since              Version 1.0
+ * @filesource
+ */
+
+// ------------------------------------------------------------------------
+
+/**
+ * Javascript Class
+ *
+ * @package            CodeIgniter
+ * @subpackage Libraries
+ * @category   Javascript
+ * @author             ExpressionEngine Dev Team
+ * @link               http://codeigniter.com/user_guide/libraries/javascript.html
+ */
+class CI_Javascript {
+
+       var $_javascript_location = 'js';
+
+       public function __construct($params = array())
+       {
+               $defaults = array('js_library_driver' => 'jquery', 'autoload' => TRUE);
+
+               foreach ($defaults as $key => $val)
+               {
+                       if (isset($params[$key]) && $params[$key] !== "")
+                       {
+                               $defaults[$key] = $params[$key];
+                       }
+               }
+
+               extract($defaults);
+
+               $this->CI =& get_instance();
+
+               // load the requested js library
+               $this->CI->load->library('javascript/'.$js_library_driver, array('autoload' => $autoload));
+               // make js to refer to current library
+               $this->js =& $this->CI->$js_library_driver;
+
+               log_message('debug', "Javascript Class Initialized and loaded.  Driver used: $js_library_driver");
+       }
+
+       // -------------------------------------------------------------------- 
+       // Event Code
+       // --------------------------------------------------------------------
+
+       /**
+        * Blur
+        *
+        * Outputs a javascript library blur event
+        *
+        * @access      public
+        * @param       string  The element to attach the event to
+        * @param       string  The code to execute
+        * @return      string
+        */
+       function blur($element = 'this', $js = '')
+       {
+               return $this->js->_blur($element, $js);
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Change
+        *
+        * Outputs a javascript library change event
+        *
+        * @access      public
+        * @param       string  The element to attach the event to
+        * @param       string  The code to execute
+        * @return      string
+        */
+       function change($element = 'this', $js = '')
+       {
+               return $this->js->_change($element, $js);
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Click
+        *
+        * Outputs a javascript library click event
+        *
+        * @access      public
+        * @param       string  The element to attach the event to
+        * @param       string  The code to execute
+        * @param       boolean whether or not to return false
+        * @return      string
+        */
+       function click($element = 'this', $js = '', $ret_false = TRUE)
+       {
+               return $this->js->_click($element, $js, $ret_false);
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Double Click
+        *
+        * Outputs a javascript library dblclick event
+        *
+        * @access      public
+        * @param       string  The element to attach the event to
+        * @param       string  The code to execute
+        * @return      string
+        */
+       function dblclick($element = 'this', $js = '')
+       {
+               return $this->js->_dblclick($element, $js);
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Error
+        *
+        * Outputs a javascript library error event
+        *
+        * @access      public
+        * @param       string  The element to attach the event to
+        * @param       string  The code to execute
+        * @return      string
+        */
+       function error($element = 'this', $js = '')
+       {
+               return $this->js->_error($element, $js);
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Focus
+        *
+        * Outputs a javascript library focus event
+        *
+        * @access      public
+        * @param       string  The element to attach the event to
+        * @param       string  The code to execute
+        * @return      string
+        */
+       function focus($element = 'this', $js = '')
+       {
+               return $this->js->__add_event($focus, $js);
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Hover
+        *
+        * Outputs a javascript library hover event
+        *
+        * @access      public
+        * @param       string  - element
+        * @param       string  - Javascript code for mouse over
+        * @param       string  - Javascript code for mouse out
+        * @return      string
+        */
+       function hover($element = 'this', $over, $out)
+       {
+               return $this->js->__hover($element, $over, $out);
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Keydown
+        *
+        * Outputs a javascript library keydown event
+        *
+        * @access      public
+        * @param       string  The element to attach the event to
+        * @param       string  The code to execute
+        * @return      string
+        */
+       function keydown($element = 'this', $js = '')
+       {
+               return $this->js->_keydown($element, $js);
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Keyup
+        *
+        * Outputs a javascript library keydown event
+        *
+        * @access      public
+        * @param       string  The element to attach the event to
+        * @param       string  The code to execute
+        * @return      string
+        */
+       function keyup($element = 'this', $js = '')
+       {
+               return $this->js->_keyup($element, $js);
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Load
+        *
+        * Outputs a javascript library load event
+        *
+        * @access      public
+        * @param       string  The element to attach the event to
+        * @param       string  The code to execute
+        * @return      string
+        */
+       function load($element = 'this', $js = '')
+       {
+               return $this->js->_load($element, $js);
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Mousedown
+        *
+        * Outputs a javascript library mousedown event
+        *
+        * @access      public
+        * @param       string  The element to attach the event to
+        * @param       string  The code to execute
+        * @return      string
+        */
+       function mousedown($element = 'this', $js = '')
+       {
+               return $this->js->_mousedown($element, $js);
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Mouse Out
+        *
+        * Outputs a javascript library mouseout event
+        *
+        * @access      public
+        * @param       string  The element to attach the event to
+        * @param       string  The code to execute
+        * @return      string
+        */
+       function mouseout($element = 'this', $js = '')
+       {
+               return $this->js->_mouseout($element, $js);
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Mouse Over
+        *
+        * Outputs a javascript library mouseover event
+        *
+        * @access      public
+        * @param       string  The element to attach the event to
+        * @param       string  The code to execute
+        * @return      string
+        */
+       function mouseover($element = 'this', $js = '')
+       {
+               return $this->js->_mouseover($element, $js);
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Mouseup
+        *
+        * Outputs a javascript library mouseup event
+        *
+        * @access      public
+        * @param       string  The element to attach the event to
+        * @param       string  The code to execute
+        * @return      string
+        */
+       function mouseup($element = 'this', $js = '')
+       {
+               return $this->js->_mouseup($element, $js);
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Output
+        *
+        * Outputs the called javascript to the screen
+        *
+        * @access      public
+        * @param       string  The code to output
+        * @return      string
+        */
+       function output($js)
+       {
+               return $this->js->_output($js);
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Ready
+        *
+        * Outputs a javascript library mouseup event
+        *
+        * @access      public
+        * @param       string  The element to attach the event to
+        * @param       string  The code to execute
+        * @return      string
+        */
+       function ready($js)
+       {
+               return $this->js->_document_ready($js);
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Resize
+        *
+        * Outputs a javascript library resize event
+        *
+        * @access      public
+        * @param       string  The element to attach the event to
+        * @param       string  The code to execute
+        * @return      string
+        */
+       function resize($element = 'this', $js = '')
+       {
+               return $this->js->_resize($element, $js);
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Scroll
+        *
+        * Outputs a javascript library scroll event
+        *
+        * @access      public
+        * @param       string  The element to attach the event to
+        * @param       string  The code to execute
+        * @return      string
+        */
+       function scroll($element = 'this', $js = '')
+       {
+               return $this->js->_scroll($element, $js);
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Unload
+        *
+        * Outputs a javascript library unload event
+        *
+        * @access      public
+        * @param       string  The element to attach the event to
+        * @param       string  The code to execute
+        * @return      string
+        */
+       function unload($element = 'this', $js = '')
+       {
+               return $this->js->_unload($element, $js);
+       }
+
+       // -------------------------------------------------------------------- 
+       // Effects
+       // --------------------------------------------------------------------
+
+
+       /**
+        * Add Class
+        *
+        * Outputs a javascript library addClass event
+        *
+        * @access      public
+        * @param       string  - element
+        * @param       string  - Class to add
+        * @return      string
+        */
+       function addClass($element = 'this', $class = '')
+       {
+               return $this->js->_addClass($element, $class);
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Animate
+        *
+        * Outputs a javascript library animate event
+        *
+        * @access      public
+        * @param       string  - element
+        * @param       string  - One of 'slow', 'normal', 'fast', or time in milliseconds
+        * @param       string  - Javascript callback function
+        * @return      string
+        */
+       function animate($element = 'this', $params = array(), $speed = '', $extra = '')
+       {
+               return $this->js->_animate($element, $params, $speed, $extra);
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Fade In
+        *
+        * Outputs a javascript library hide event
+        *
+        * @access      public
+        * @param       string  - element
+        * @param       string  - One of 'slow', 'normal', 'fast', or time in milliseconds
+        * @param       string  - Javascript callback function
+        * @return      string
+        */
+       function fadeIn($element = 'this', $speed = '', $callback = '')
+       {
+               return $this->js->_fadeIn($element, $speed, $callback);
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Fade Out
+        *
+        * Outputs a javascript library hide event
+        *
+        * @access      public
+        * @param       string  - element
+        * @param       string  - One of 'slow', 'normal', 'fast', or time in milliseconds
+        * @param       string  - Javascript callback function
+        * @return      string
+        */
+       function fadeOut($element = 'this', $speed = '', $callback = '')
+       {
+               return $this->js->_fadeOut($element, $speed, $callback);
+       }
+       // --------------------------------------------------------------------
+
+       /**
+        * Slide Up
+        *
+        * Outputs a javascript library slideUp event
+        *
+        * @access      public
+        * @param       string  - element
+        * @param       string  - One of 'slow', 'normal', 'fast', or time in milliseconds
+        * @param       string  - Javascript callback function
+        * @return      string
+        */
+       function slideUp($element = 'this', $speed = '', $callback = '')
+       {
+               return $this->js->_slideUp($element, $speed, $callback);
+
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Remove Class
+        *
+        * Outputs a javascript library removeClass event
+        *
+        * @access      public
+        * @param       string  - element
+        * @param       string  - Class to add
+        * @return      string
+        */
+       function removeClass($element = 'this', $class = '')
+       {
+               return $this->js->_removeClass($element, $class);
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Slide Down
+        *
+        * Outputs a javascript library slideDown event
+        *
+        * @access      public
+        * @param       string  - element
+        * @param       string  - One of 'slow', 'normal', 'fast', or time in milliseconds
+        * @param       string  - Javascript callback function
+        * @return      string
+        */
+       function slideDown($element = 'this', $speed = '', $callback = '')
+       {
+               return $this->js->_slideDown($element, $speed, $callback);
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Slide Toggle
+        *
+        * Outputs a javascript library slideToggle event
+        *
+        * @access      public
+        * @param       string  - element
+        * @param       string  - One of 'slow', 'normal', 'fast', or time in milliseconds
+        * @param       string  - Javascript callback function
+        * @return      string
+        */
+       function slideToggle($element = 'this', $speed = '', $callback = '')
+       {
+               return $this->js->_slideToggle($element, $speed, $callback);
+
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Hide
+        *
+        * Outputs a javascript library hide action
+        *
+        * @access      public
+        * @param       string  - element
+        * @param       string  - One of 'slow', 'normal', 'fast', or time in milliseconds
+        * @param       string  - Javascript callback function
+        * @return      string
+        */
+       function hide($element = 'this', $speed = '', $callback = '')
+       {
+               return $this->js->_hide($element, $speed, $callback);
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Toggle
+        *
+        * Outputs a javascript library toggle event
+        *
+        * @access      public
+        * @param       string  - element
+        * @return      string
+        */
+       function toggle($element = 'this')
+       {
+               return $this->js->_toggle($element);
+
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Toggle Class
+        *
+        * Outputs a javascript library toggle class event
+        *
+        * @access      public
+        * @param       string  - element
+        * @return      string
+        */
+       function toggleClass($element = 'this', $class='')
+       {
+               return $this->js->_toggleClass($element, $class);
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Show
+        *
+        * Outputs a javascript library show event
+        *
+        * @access      public
+        * @param       string  - element
+        * @param       string  - One of 'slow', 'normal', 'fast', or time in milliseconds
+        * @param       string  - Javascript callback function
+        * @return      string
+        */
+       function show($element = 'this', $speed = '', $callback = '')
+       {
+               return $this->js->_show($element, $speed, $callback);
+       }
+
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Compile
+        *
+        * gather together all script needing to be output
+        *
+        * @access      public
+        * @param       string  The element to attach the event to
+        * @return      string
+        */
+       function compile($view_var = 'script_foot', $script_tags = TRUE)
+       {
+               $this->js->_compile($view_var, $script_tags);
+       }
+
+       /**
+        * Clear Compile
+        *
+        * Clears any previous javascript collected for output
+        *
+        * @access      public
+        * @return      void
+        */
+       function clear_compile()
+       {
+               $this->js->_clear_compile();
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * External
+        *
+        * Outputs a <script> tag with the source as an external js file
+        *
+        * @access      public
+        * @param       string  The element to attach the event to
+        * @return      string
+        */
+       function external($external_file = '', $relative = FALSE)
+       {
+               if ($external_file !== '')
+               {
+                       $this->_javascript_location = $external_file;
+               }
+               else
+               {
+                       if ($this->CI->config->item('javascript_location') != '')
+                       {
+                               $this->_javascript_location = $this->CI->config->item('javascript_location');
+                       }
+               }
+
+               if ($relative === TRUE OR strncmp($external_file, 'http://', 7) == 0 OR strncmp($external_file, 'https://', 8) == 0)
+               {
+                       $str = $this->_open_script($external_file);
+               }
+               elseif (strpos($this->_javascript_location, 'http://') !== FALSE)
+               {
+                       $str = $this->_open_script($this->_javascript_location.$external_file);
+               }
+               else
+               {
+                       $str = $this->_open_script($this->CI->config->slash_item('base_url').$this->_javascript_location.$external_file);
+               }
+
+               $str .= $this->_close_script();
+               return $str;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Inline
+        *
+        * Outputs a <script> tag
+        *
+        * @access      public
+        * @param       string  The element to attach the event to
+        * @param       boolean If a CDATA section should be added
+        * @return      string
+        */
+       function inline($script, $cdata = TRUE)
+       {
+               $str = $this->_open_script();
+               $str .= ($cdata) ? "\n// <![CDATA[\n{$script}\n// ]]>\n" : "\n{$script}\n";
+               $str .= $this->_close_script();
+
+               return $str;
+       }
+       
+       // --------------------------------------------------------------------
+
+       /**
+        * Open Script
+        *
+        * Outputs an opening <script>
+        *
+        * @access      private
+        * @param       string
+        * @return      string
+        */
+       function _open_script($src = '')
+       {
+               $str = '<script type="text/javascript" charset="'.strtolower($this->CI->config->item('charset')).'"';
+               $str .= ($src == '') ? '>' : ' src="'.$src.'">';
+               return $str;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Close Script
+        *
+        * Outputs an closing </script>
+        *
+        * @access      private
+        * @param       string
+        * @return      string
+        */
+       function _close_script($extra = "\n")
+       {
+               return "</script>$extra";
+       }
+
+
+       // --------------------------------------------------------------------
+       // --------------------------------------------------------------------
+       // AJAX-Y STUFF - still a testbed
+       // --------------------------------------------------------------------
+       // --------------------------------------------------------------------
+
+       /**
+        * Update
+        *
+        * Outputs a javascript library slideDown event
+        *
+        * @access      public
+        * @param       string  - element
+        * @param       string  - One of 'slow', 'normal', 'fast', or time in milliseconds
+        * @param       string  - Javascript callback function
+        * @return      string
+        */
+       function update($element = 'this', $speed = '', $callback = '')
+       {
+               return $this->js->_updater($element, $speed, $callback);
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Generate JSON
+        *
+        * Can be passed a database result or associative array and returns a JSON formatted string
+        *
+        * @param       mixed   result set or array
+        * @param       bool    match array types (defaults to objects)
+        * @return      string  a json formatted string
+        */
+       function generate_json($result = NULL, $match_array_type = FALSE)
+       {
+               // JSON data can optionally be passed to this function
+               // either as a database result object or an array, or a user supplied array
+               if ( ! is_null($result))
+               {
+                       if (is_object($result))
+                       {
+                               $json_result = $result->result_array();
+                       }
+                       elseif (is_array($result))
+                       {
+                               $json_result = $result;
+                       }
+                       else
+                       {
+                               return $this->_prep_args($result);
+                       }
+               }
+               else
+               {
+                       return 'null';
+               }
+
+               $json = array();
+               $_is_assoc = TRUE;
+
+               if ( ! is_array($json_result) AND empty($json_result))
+               {
+                       show_error("Generate JSON Failed - Illegal key, value pair.");
+               }
+               elseif ($match_array_type)
+               {
+                       $_is_assoc = $this->_is_associative_array($json_result);
+               }
+
+               foreach ($json_result as $k => $v)
+               {
+                       if ($_is_assoc)
+                       {
+                               $json[] = $this->_prep_args($k, TRUE).':'.$this->generate_json($v, $match_array_type);
+                       }
+                       else
+                       {
+                               $json[] = $this->generate_json($v, $match_array_type);
+                       }
+               }
+
+               $json = implode(',', $json);
+
+               return $_is_assoc ? "{".$json."}" : "[".$json."]";
+
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Is associative array
+        *
+        * Checks for an associative array
+        *
+        * @access      public
+        * @param       type
+        * @return      type
+        */
+       function _is_associative_array($arr)
+       {
+               foreach (array_keys($arr) as $key => $val)
+               {
+                       if ($key !== $val)
+                       {
+                               return TRUE;
+                       }
+               }
+
+               return FALSE;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Prep Args
+        *
+        * Ensures a standard json value and escapes values
+        *
+        * @access      public
+        * @param       type
+        * @return      type
+        */
+       function _prep_args($result, $is_key = FALSE)
+       {
+               if (is_null($result))
+               {
+                       return 'null';
+               }
+               elseif (is_bool($result))
+               {
+                       return ($result === TRUE) ? 'true' : 'false';
+               }
+               elseif (is_string($result) OR $is_key)
+               {
+                       return '"'.str_replace(array('\\', "\t", "\n", "\r", '"', '/'), array('\\\\', '\\t', '\\n', "\\r", '\"', '\/'), $result).'"';                   
+               }
+               elseif (is_scalar($result))
+               {
+                       return $result;
+               }
+       }
+
+       // --------------------------------------------------------------------
+}
+// END Javascript Class
+
+/* End of file Javascript.php */
+/* Location: ./system/libraries/Javascript.php */
\ No newline at end of file
diff --git a/system/libraries/Log.php b/system/libraries/Log.php
new file mode 100755 (executable)
index 0000000..fb2c5a4
--- /dev/null
@@ -0,0 +1,114 @@
+<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+/**
+ * CodeIgniter
+ *
+ * An open source application development framework for PHP 5.1.6 or newer
+ *
+ * @package            CodeIgniter
+ * @author             ExpressionEngine Dev Team
+ * @copyright  Copyright (c) 2008 - 2011, EllisLab, Inc.
+ * @license            http://codeigniter.com/user_guide/license.html
+ * @link               http://codeigniter.com
+ * @since              Version 1.0
+ * @filesource
+ */
+
+// ------------------------------------------------------------------------
+
+/**
+ * Logging Class
+ *
+ * @package            CodeIgniter
+ * @subpackage Libraries
+ * @category   Logging
+ * @author             ExpressionEngine Dev Team
+ * @link               http://codeigniter.com/user_guide/general/errors.html
+ */
+class CI_Log {
+
+       protected $_log_path;
+       protected $_threshold   = 1;
+       protected $_date_fmt    = 'Y-m-d H:i:s';
+       protected $_enabled     = TRUE;
+       protected $_levels      = array('ERROR' => '1', 'DEBUG' => '2',  'INFO' => '3', 'ALL' => '4');
+
+       /**
+        * Constructor
+        */
+       public function __construct()
+       {
+               $config =& get_config();
+
+               $this->_log_path = ($config['log_path'] != '') ? $config['log_path'] : APPPATH.'logs/';
+
+               if ( ! is_dir($this->_log_path) OR ! is_really_writable($this->_log_path))
+               {
+                       $this->_enabled = FALSE;
+               }
+
+               if (is_numeric($config['log_threshold']))
+               {
+                       $this->_threshold = $config['log_threshold'];
+               }
+
+               if ($config['log_date_format'] != '')
+               {
+                       $this->_date_fmt = $config['log_date_format'];
+               }
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Write Log File
+        *
+        * Generally this function will be called using the global log_message() function
+        *
+        * @param       string  the error level
+        * @param       string  the error message
+        * @param       bool    whether the error is a native PHP error
+        * @return      bool
+        */
+       public function write_log($level = 'error', $msg, $php_error = FALSE)
+       {
+               if ($this->_enabled === FALSE)
+               {
+                       return FALSE;
+               }
+
+               $level = strtoupper($level);
+
+               if ( ! isset($this->_levels[$level]) OR ($this->_levels[$level] > $this->_threshold))
+               {
+                       return FALSE;
+               }
+
+               $filepath = $this->_log_path.'log-'.date('Y-m-d').EXT;
+               $message  = '';
+
+               if ( ! file_exists($filepath))
+               {
+                       $message .= "<"."?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed'); ?".">\n\n";
+               }
+
+               if ( ! $fp = @fopen($filepath, FOPEN_WRITE_CREATE))
+               {
+                       return FALSE;
+               }
+
+               $message .= $level.' '.(($level == 'INFO') ? ' -' : '-').' '.date($this->_date_fmt). ' --> '.$msg."\n";
+
+               flock($fp, LOCK_EX);
+               fwrite($fp, $message);
+               flock($fp, LOCK_UN);
+               fclose($fp);
+
+               @chmod($filepath, FILE_WRITE_MODE);
+               return TRUE;
+       }
+
+}
+// END Log Class
+
+/* End of file Log.php */
+/* Location: ./system/libraries/Log.php */
\ No newline at end of file
diff --git a/system/libraries/Pagination.php b/system/libraries/Pagination.php
new file mode 100755 (executable)
index 0000000..1113f86
--- /dev/null
@@ -0,0 +1,279 @@
+<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+/**
+ * CodeIgniter
+ *
+ * An open source application development framework for PHP 5.1.6 or newer
+ *
+ * @package            CodeIgniter
+ * @author             ExpressionEngine Dev Team
+ * @copyright  Copyright (c) 2008 - 2011, EllisLab, Inc.
+ * @license            http://codeigniter.com/user_guide/license.html
+ * @link               http://codeigniter.com
+ * @since              Version 1.0
+ * @filesource
+ */
+
+// ------------------------------------------------------------------------
+
+/**
+ * Pagination Class
+ *
+ * @package            CodeIgniter
+ * @subpackage Libraries
+ * @category   Pagination
+ * @author             ExpressionEngine Dev Team
+ * @link               http://codeigniter.com/user_guide/libraries/pagination.html
+ */
+class CI_Pagination {
+
+       var $base_url                   = ''; // The page we are linking to
+       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 $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
+       var $first_link                 = '&lsaquo; First';
+       var $next_link                  = '&gt;';
+       var $prev_link                  = '&lt;';
+       var $last_link                  = 'Last &rsaquo;';
+       var $uri_segment                = 3;
+       var $full_tag_open              = '';
+       var $full_tag_close             = '';
+       var $first_tag_open             = '';
+       var $first_tag_close    = '&nbsp;';
+       var $last_tag_open              = '&nbsp;';
+       var $last_tag_close             = '';
+       var $first_url                  = ''; // Alternative URL for the First Page.
+       var $cur_tag_open               = '&nbsp;<strong>';
+       var $cur_tag_close              = '</strong>';
+       var $next_tag_open              = '&nbsp;';
+       var $next_tag_close             = '&nbsp;';
+       var $prev_tag_open              = '&nbsp;';
+       var $prev_tag_close             = '';
+       var $num_tag_open               = '&nbsp;';
+       var $num_tag_close              = '';
+       var $page_query_string  = FALSE;
+       var $query_string_segment = 'per_page';
+       var $display_pages              = TRUE;
+       var $anchor_class               = '';
+
+       /**
+        * Constructor
+        *
+        * @access      public
+        * @param       array   initialization parameters
+        */
+       public function __construct($params = array())
+       {
+               if (count($params) > 0)
+               {
+                       $this->initialize($params);
+               }
+
+               if ($this->anchor_class != '')
+               {
+                       $this->anchor_class = 'class="'.$this->anchor_class.'" ';
+               }
+
+               log_message('debug', "Pagination Class Initialized");
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Initialize Preferences
+        *
+        * @access      public
+        * @param       array   initialization parameters
+        * @return      void
+        */
+       function initialize($params = array())
+       {
+               if (count($params) > 0)
+               {
+                       foreach ($params as $key => $val)
+                       {
+                               if (isset($this->$key))
+                               {
+                                       $this->$key = $val;
+                               }
+                       }
+               }
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Generate the pagination links
+        *
+        * @access      public
+        * @return      string
+        */
+       function create_links()
+       {
+               // If our item count or per-page total is zero there is no need to continue.
+               if ($this->total_rows == 0 OR $this->per_page == 0)
+               {
+                       return '';
+               }
+
+               // Calculate the total number of pages
+               $num_pages = ceil($this->total_rows / $this->per_page);
+
+               // Is there only one page? Hm... nothing more to do here then.
+               if ($num_pages == 1)
+               {
+                       return '';
+               }
+
+               // Determine the current page number.
+               $CI =& get_instance();
+
+               if ($CI->config->item('enable_query_strings') === TRUE OR $this->page_query_string === TRUE)
+               {
+                       if ($CI->input->get($this->query_string_segment) != 0)
+                       {
+                               $this->cur_page = $CI->input->get($this->query_string_segment);
+
+                               // Prep the current page - no funny business!
+                               $this->cur_page = (int) $this->cur_page;
+                       }
+               }
+               else
+               {
+                       if ($CI->uri->segment($this->uri_segment) != 0)
+                       {
+                               $this->cur_page = $CI->uri->segment($this->uri_segment);
+
+                               // Prep the current page - no funny business!
+                               $this->cur_page = (int) $this->cur_page;
+                       }
+               }
+
+               $this->num_links = (int)$this->num_links;
+
+               if ($this->num_links < 1)
+               {
+                       show_error('Your number of links must be a positive number.');
+               }
+
+               if ( ! is_numeric($this->cur_page))
+               {
+                       $this->cur_page = 0;
+               }
+
+               // Is the page number beyond the result range?
+               // If so we show the last page
+               if ($this->cur_page > $this->total_rows)
+               {
+                       $this->cur_page = ($num_pages - 1) * $this->per_page;
+               }
+
+               $uri_page_number = $this->cur_page;
+               $this->cur_page = floor(($this->cur_page/$this->per_page) + 1);
+
+               // Calculate the start and end numbers. These determine
+               // which number to start and end the digit links with
+               $start = (($this->cur_page - $this->num_links) > 0) ? $this->cur_page - ($this->num_links - 1) : 1;
+               $end   = (($this->cur_page + $this->num_links) < $num_pages) ? $this->cur_page + $this->num_links : $num_pages;
+
+               // Is pagination being used over GET or POST?  If get, add a per_page query
+               // string. If post, add a trailing slash to the base URL if needed
+               if ($CI->config->item('enable_query_strings') === TRUE OR $this->page_query_string === TRUE)
+               {
+                       $this->base_url = rtrim($this->base_url).'&amp;'.$this->query_string_segment.'=';
+               }
+               else
+               {
+                       $this->base_url = rtrim($this->base_url, '/') .'/';
+               }
+
+               // And here we go...
+               $output = '';
+
+               // Render the "First" link
+               if  ($this->first_link !== FALSE AND $this->cur_page > ($this->num_links + 1))
+               {
+                       $first_url = ($this->first_url == '') ? $this->base_url : $this->first_url;
+                       $output .= $this->first_tag_open.'<a '.$this->anchor_class.'href="'.$first_url.'">'.$this->first_link.'</a>'.$this->first_tag_close;
+               }
+
+               // Render the "previous" link
+               if  ($this->prev_link !== FALSE AND $this->cur_page != 1)
+               {
+                       $i = $uri_page_number - $this->per_page;
+
+                       if ($i == 0 && $this->first_url != '')
+                       {
+                               $output .= $this->prev_tag_open.'<a '.$this->anchor_class.'href="'.$this->first_url.'">'.$this->prev_link.'</a>'.$this->prev_tag_close;
+                       }
+                       else
+                       {
+                               $i = ($i == 0) ? '' : $this->prefix.$i.$this->suffix;
+                               $output .= $this->prev_tag_open.'<a '.$this->anchor_class.'href="'.$this->base_url.$i.'">'.$this->prev_link.'</a>'.$this->prev_tag_close;
+                       }
+
+               }
+
+               // Render the pages
+               if ($this->display_pages !== FALSE)
+               {
+                       // Write the digit links
+                       for ($loop = $start -1; $loop <= $end; $loop++)
+                       {
+                               $i = ($loop * $this->per_page) - $this->per_page;
+
+                               if ($i >= 0)
+                               {
+                                       if ($this->cur_page == $loop)
+                                       {
+                                               $output .= $this->cur_tag_open.$loop.$this->cur_tag_close; // Current page
+                                       }
+                                       else
+                                       {
+                                               $n = ($i == 0) ? '' : $i;
+
+                                               if ($n == '' && $this->first_url != '')
+                                               {
+                                                       $output .= $this->num_tag_open.'<a '.$this->anchor_class.'href="'.$this->first_url.'">'.$loop.'</a>'.$this->num_tag_close;
+                                               }
+                                               else
+                                               {
+                                                       $n = ($n == '') ? '' : $this->prefix.$n.$this->suffix;
+
+                                                       $output .= $this->num_tag_open.'<a '.$this->anchor_class.'href="'.$this->base_url.$n.'">'.$loop.'</a>'.$this->num_tag_close;
+                                               }
+                                       }
+                               }
+                       }
+               }
+
+               // Render the "next" link
+               if ($this->next_link !== FALSE AND $this->cur_page < $num_pages)
+               {
+                       $output .= $this->next_tag_open.'<a '.$this->anchor_class.'href="'.$this->base_url.$this->prefix.($this->cur_page * $this->per_page).$this->suffix.'">'.$this->next_link.'</a>'.$this->next_tag_close;
+               }
+
+               // Render the "Last" link
+               if ($this->last_link !== FALSE AND ($this->cur_page + $this->num_links) < $num_pages)
+               {
+                       $i = (($num_pages * $this->per_page) - $this->per_page);
+                       $output .= $this->last_tag_open.'<a '.$this->anchor_class.'href="'.$this->base_url.$this->prefix.$i.$this->suffix.'">'.$this->last_link.'</a>'.$this->last_tag_close;
+               }
+
+               // Kill double slashes.  Note: Sometimes we can end up with a double slash
+               // in the penultimate link so we'll kill all double slashes.
+               $output = preg_replace("#([^:])//+#", "\\1/", $output);
+
+               // Add the wrapper HTML if exists
+               $output = $this->full_tag_open.$output.$this->full_tag_close;
+
+               return $output;
+       }
+}
+// END Pagination Class
+
+/* End of file Pagination.php */
+/* Location: ./system/libraries/Pagination.php */
\ No newline at end of file
diff --git a/system/libraries/Parser.php b/system/libraries/Parser.php
new file mode 100755 (executable)
index 0000000..d223da0
--- /dev/null
@@ -0,0 +1,212 @@
+<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+/**
+ * CodeIgniter
+ *
+ * An open source application development framework for PHP 5.1.6 or newer
+ *
+ * @package            CodeIgniter
+ * @author             ExpressionEngine Dev Team
+ * @copyright  Copyright (c) 2008 - 2011, EllisLab, Inc.
+ * @license            http://codeigniter.com/user_guide/license.html
+ * @link               http://codeigniter.com
+ * @since              Version 1.0
+ * @filesource
+ */
+
+// ------------------------------------------------------------------------
+
+/**
+ * Parser Class
+ *
+ * @package            CodeIgniter
+ * @subpackage Libraries
+ * @category   Parser
+ * @author             ExpressionEngine Dev Team
+ * @link               http://codeigniter.com/user_guide/libraries/parser.html
+ */
+class CI_Parser {
+
+       var $l_delim = '{';
+       var $r_delim = '}';
+       var $object;
+
+       /**
+        *  Parse a template
+        *
+        * Parses pseudo-variables contained in the specified template view,
+        * replacing them with the data in the second param
+        *
+        * @access      public
+        * @param       string
+        * @param       array
+        * @param       bool
+        * @return      string
+        */
+       public function parse($template, $data, $return = FALSE)
+       {
+               $CI =& get_instance();
+               $template = $CI->load->view($template, $data, TRUE);
+
+               return $this->_parse($template, $data, $return);
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        *  Parse a String
+        *
+        * Parses pseudo-variables contained in the specified string,
+        * replacing them with the data in the second param
+        *
+        * @access      public
+        * @param       string
+        * @param       array
+        * @param       bool
+        * @return      string
+        */
+       function parse_string($template, $data, $return = FALSE)
+       {
+               return $this->_parse($template, $data, $return);
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        *  Parse a template
+        *
+        * Parses pseudo-variables contained in the specified template,
+        * replacing them with the data in the second param
+        *
+        * @access      public
+        * @param       string
+        * @param       array
+        * @param       bool
+        * @return      string
+        */
+       function _parse($template, $data, $return = FALSE)
+       {
+               if ($template == '')
+               {
+                       return FALSE;
+               }
+
+               foreach ($data as $key => $val)
+               {
+                       if (is_array($val))
+                       {
+                               $template = $this->_parse_pair($key, $val, $template);
+                       }
+                       else
+                       {
+                               $template = $this->_parse_single($key, (string)$val, $template);
+                       }
+               }
+
+               if ($return == FALSE)
+               {
+                       $CI =& get_instance();
+                       $CI->output->append_output($template);
+               }
+
+               return $template;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        *  Set the left/right variable delimiters
+        *
+        * @access      public
+        * @param       string
+        * @param       string
+        * @return      void
+        */
+       function set_delimiters($l = '{', $r = '}')
+       {
+               $this->l_delim = $l;
+               $this->r_delim = $r;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        *  Parse a single key/value
+        *
+        * @access      private
+        * @param       string
+        * @param       string
+        * @param       string
+        * @return      string
+        */
+       function _parse_single($key, $val, $string)
+       {
+               return str_replace($this->l_delim.$key.$this->r_delim, $val, $string);
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        *  Parse a tag pair
+        *
+        * Parses tag pairs:  {some_tag} string... {/some_tag}
+        *
+        * @access      private
+        * @param       string
+        * @param       array
+        * @param       string
+        * @return      string
+        */
+       function _parse_pair($variable, $data, $string)
+       {
+               if (FALSE === ($match = $this->_match_pair($string, $variable)))
+               {
+                       return $string;
+               }
+
+               $str = '';
+               foreach ($data as $row)
+               {
+                       $temp = $match['1'];
+                       foreach ($row as $key => $val)
+                       {
+                               if ( ! is_array($val))
+                               {
+                                       $temp = $this->_parse_single($key, $val, $temp);
+                               }
+                               else
+                               {
+                                       $temp = $this->_parse_pair($key, $val, $temp);
+                               }
+                       }
+
+                       $str .= $temp;
+               }
+
+               return str_replace($match['0'], $str, $string);
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        *  Matches a variable pair
+        *
+        * @access      private
+        * @param       string
+        * @param       string
+        * @return      mixed
+        */
+       function _match_pair($string, $variable)
+       {
+               if ( ! preg_match("|" . preg_quote($this->l_delim) . $variable . preg_quote($this->r_delim) . "(.+?)". preg_quote($this->l_delim) . '/' . $variable . preg_quote($this->r_delim) . "|s", $string, $match))
+               {
+                       return FALSE;
+               }
+
+               return $match;
+       }
+
+}
+// END Parser Class
+
+/* End of file Parser.php */
+/* Location: ./system/libraries/Parser.php */
diff --git a/system/libraries/Profiler.php b/system/libraries/Profiler.php
new file mode 100755 (executable)
index 0000000..8a1f18c
--- /dev/null
@@ -0,0 +1,502 @@
+<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+/**
+ * CodeIgniter
+ *
+ * An open source application development framework for PHP 5.1.6 or newer
+ *
+ * @package            CodeIgniter
+ * @author             ExpressionEngine Dev Team
+ * @copyright  Copyright (c) 2008 - 2011, EllisLab, Inc.
+ * @license            http://codeigniter.com/user_guide/license.html
+ * @link               http://codeigniter.com
+ * @since              Version 1.0
+ * @filesource
+ */
+
+// ------------------------------------------------------------------------
+
+/**
+ * CodeIgniter Profiler Class
+ *
+ * This class enables you to display benchmark, query, and other data
+ * in order to help with debugging and optimization.
+ *
+ * Note: At some point it would be good to move all the HTML in this class
+ * into a set of template files in order to allow customization.
+ *
+ * @package            CodeIgniter
+ * @subpackage Libraries
+ * @category   Libraries
+ * @author             ExpressionEngine Dev Team
+ * @link               http://codeigniter.com/user_guide/general/profiling.html
+ */
+class CI_Profiler {
+
+       var $CI;
+
+       protected $_available_sections = array(
+                                                                               'benchmarks',
+                                                                               'get',
+                                                                               'memory_usage',
+                                                                               'post',
+                                                                               'uri_string',
+                                                                               'controller_info',
+                                                                               'queries',
+                                                                               'http_headers',
+                                                                               'config'
+                                                                               );
+
+       public function __construct($config = array())
+       {
+               $this->CI =& get_instance();
+               $this->CI->load->language('profiler');
+
+               // default all sections to display
+               foreach ($this->_available_sections as $section)
+               {
+                       if ( ! isset($config[$section]))
+                       {
+                               $this->_compile_{$section} = TRUE;
+                       }
+               }
+
+               $this->set_sections($config);
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Set Sections
+        *
+        * Sets the private _compile_* properties to enable/disable Profiler sections
+        *
+        * @param       mixed
+        * @return      void
+        */
+       public function set_sections($config)
+       {
+               foreach ($config as $method => $enable)
+               {
+                       if (in_array($method, $this->_available_sections))
+                       {
+                               $this->_compile_{$method} = ($enable !== FALSE) ? TRUE : FALSE;
+                       }
+               }
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Auto Profiler
+        *
+        * This function cycles through the entire array of mark points and
+        * matches any two points that are named identically (ending in "_start"
+        * and "_end" respectively).  It then compiles the execution times for
+        * all points and returns it as an array
+        *
+        * @return      array
+        */
+       protected function _compile_benchmarks()
+       {
+               $profile = array();
+               foreach ($this->CI->benchmark->marker as $key => $val)
+               {
+                       // We match the "end" marker so that the list ends
+                       // up in the order that it was defined
+                       if (preg_match("/(.+?)_end/i", $key, $match))
+                       {
+                               if (isset($this->CI->benchmark->marker[$match[1].'_end']) AND isset($this->CI->benchmark->marker[$match[1].'_start']))
+                               {
+                                       $profile[$match[1]] = $this->CI->benchmark->elapsed_time($match[1].'_start', $key);
+                               }
+                       }
+               }
+
+               // Build a table containing the profile data.
+               // Note: At some point we should turn this into a template that can
+               // be modified.  We also might want to make this data available to be logged
+
+               $output  = "\n\n";
+               $output .= '<fieldset id="ci_profiler_benchmarks" style="border:1px solid #900;padding:6px 10px 10px 10px;margin:20px 0 20px 0;background-color:#eee">';
+               $output .= "\n";
+               $output .= '<legend style="color:#900;">&nbsp;&nbsp;'.$this->CI->lang->line('profiler_benchmarks').'&nbsp;&nbsp;</legend>';
+               $output .= "\n";
+               $output .= "\n\n<table style='width:100%'>\n";
+
+               foreach ($profile as $key => $val)
+               {
+                       $key = ucwords(str_replace(array('_', '-'), ' ', $key));
+                       $output .= "<tr><td style='padding:5px;width:50%;color:#000;font-weight:bold;background-color:#ddd;'>".$key."&nbsp;&nbsp;</td><td style='padding:5px;width:50%;color:#900;font-weight:normal;background-color:#ddd;'>".$val."</td></tr>\n";
+               }
+
+               $output .= "</table>\n";
+               $output .= "</fieldset>";
+
+               return $output;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Compile Queries
+        *
+        * @return      string
+        */
+       protected function _compile_queries()
+       {
+               $dbs = array();
+
+               // Let's determine which databases are currently connected to
+               foreach (get_object_vars($this->CI) as $CI_object)
+               {
+                       if (is_object($CI_object) && is_subclass_of(get_class($CI_object), 'CI_DB') )
+                       {
+                               $dbs[] = $CI_object;
+                       }
+               }
+
+               if (count($dbs) == 0)
+               {
+                       $output  = "\n\n";
+                       $output .= '<fieldset id="ci_profiler_queries" style="border:1px solid #0000FF;padding:6px 10px 10px 10px;margin:20px 0 20px 0;background-color:#eee">';
+                       $output .= "\n";
+                       $output .= '<legend style="color:#0000FF;">&nbsp;&nbsp;'.$this->CI->lang->line('profiler_queries').'&nbsp;&nbsp;</legend>';
+                       $output .= "\n";
+                       $output .= "\n\n<table style='border:none; width:100%'>\n";
+                       $output .="<tr><td style='width:100%;color:#0000FF;font-weight:normal;background-color:#eee;padding:5px'>".$this->CI->lang->line('profiler_no_db')."</td></tr>\n";
+                       $output .= "</table>\n";
+                       $output .= "</fieldset>";
+
+                       return $output;
+               }
+
+               // Load the text helper so we can highlight the SQL
+               $this->CI->load->helper('text');
+
+               // Key words we want bolded
+               $highlight = array('SELECT', 'DISTINCT', 'FROM', 'WHERE', 'AND', 'LEFT&nbsp;JOIN', 'ORDER&nbsp;BY', 'GROUP&nbsp;BY', 'LIMIT', 'INSERT', 'INTO', 'VALUES', 'UPDATE', 'OR&nbsp;', 'HAVING', 'OFFSET', 'NOT&nbsp;IN', 'IN', 'LIKE', 'NOT&nbsp;LIKE', 'COUNT', 'MAX', 'MIN', 'ON', 'AS', 'AVG', 'SUM', '(', ')');
+
+               $output  = "\n\n";
+
+               foreach ($dbs as $db)
+               {
+                       $output .= '<fieldset style="border:1px solid #0000FF;padding:6px 10px 10px 10px;margin:20px 0 20px 0;background-color:#eee">';
+                       $output .= "\n";
+                       $output .= '<legend style="color:#0000FF;">&nbsp;&nbsp;'.$this->CI->lang->line('profiler_database').':&nbsp; '.$db->database.'&nbsp;&nbsp;&nbsp;'.$this->CI->lang->line('profiler_queries').': '.count($db->queries).'&nbsp;&nbsp;&nbsp;</legend>';
+                       $output .= "\n";
+                       $output .= "\n\n<table style='width:100%;'>\n";
+
+                       if (count($db->queries) == 0)
+                       {
+                               $output .= "<tr><td style='width:100%;color:#0000FF;font-weight:normal;background-color:#eee;padding:5px;'>".$this->CI->lang->line('profiler_no_queries')."</td></tr>\n";
+                       }
+                       else
+                       {
+                               foreach ($db->queries as $key => $val)
+                               {
+                                       $time = number_format($db->query_times[$key], 4);
+
+                                       $val = highlight_code($val, ENT_QUOTES);
+
+                                       foreach ($highlight as $bold)
+                                       {
+                                               $val = str_replace($bold, '<strong>'.$bold.'</strong>', $val);
+                                       }
+
+                                       $output .= "<tr><td style='padding:5px; vertical-align: top;width:1%;color:#900;font-weight:normal;background-color:#ddd;'>".$time."&nbsp;&nbsp;</td><td style='padding:5px; color:#000;font-weight:normal;background-color:#ddd;'>".$val."</td></tr>\n";
+                               }
+                       }
+
+                       $output .= "</table>\n";
+                       $output .= "</fieldset>";
+
+               }
+
+               return $output;
+       }
+
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Compile $_GET Data
+        *
+        * @return      string
+        */
+       protected function _compile_get()
+       {
+               $output  = "\n\n";
+               $output .= '<fieldset id="ci_profiler_get" style="border:1px solid #cd6e00;padding:6px 10px 10px 10px;margin:20px 0 20px 0;background-color:#eee">';
+               $output .= "\n";
+               $output .= '<legend style="color:#cd6e00;">&nbsp;&nbsp;'.$this->CI->lang->line('profiler_get_data').'&nbsp;&nbsp;</legend>';
+               $output .= "\n";
+
+               if (count($_GET) == 0)
+               {
+                       $output .= "<div style='color:#cd6e00;font-weight:normal;padding:4px 0 4px 0'>".$this->CI->lang->line('profiler_no_get')."</div>";
+               }
+               else
+               {
+                       $output .= "\n\n<table style='width:100%; border:none'>\n";
+
+                       foreach ($_GET as $key => $val)
+                       {
+                               if ( ! is_numeric($key))
+                               {
+                                       $key = "'".$key."'";
+                               }
+
+                               $output .= "<tr><td style='width:50%;color:#000;background-color:#ddd;padding:5px'>&#36;_GET[".$key."]&nbsp;&nbsp; </td><td style='width:50%;padding:5px;color:#cd6e00;font-weight:normal;background-color:#ddd;'>";
+                               if (is_array($val))
+                               {
+                                       $output .= "<pre>" . htmlspecialchars(stripslashes(print_r($val, true))) . "</pre>";
+                               }
+                               else
+                               {
+                                       $output .= htmlspecialchars(stripslashes($val));
+                               }
+                               $output .= "</td></tr>\n";
+                       }
+
+                       $output .= "</table>\n";
+               }
+               $output .= "</fieldset>";
+
+               return $output;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Compile $_POST Data
+        *
+        * @return      string
+        */
+       protected function _compile_post()
+       {
+               $output  = "\n\n";
+               $output .= '<fieldset id="ci_profiler_post" style="border:1px solid #009900;padding:6px 10px 10px 10px;margin:20px 0 20px 0;background-color:#eee">';
+               $output .= "\n";
+               $output .= '<legend style="color:#009900;">&nbsp;&nbsp;'.$this->CI->lang->line('profiler_post_data').'&nbsp;&nbsp;</legend>';
+               $output .= "\n";
+
+               if (count($_POST) == 0)
+               {
+                       $output .= "<div style='color:#009900;font-weight:normal;padding:4px 0 4px 0'>".$this->CI->lang->line('profiler_no_post')."</div>";
+               }
+               else
+               {
+                       $output .= "\n\n<table style='width:100%'>\n";
+
+                       foreach ($_POST as $key => $val)
+                       {
+                               if ( ! is_numeric($key))
+                               {
+                                       $key = "'".$key."'";
+                               }
+
+                               $output .= "<tr><td style='width:50%;padding:5px;color:#000;background-color:#ddd;'>&#36;_POST[".$key."]&nbsp;&nbsp; </td><td style='width:50%;padding:5px;color:#009900;font-weight:normal;background-color:#ddd;'>";
+                               if (is_array($val))
+                               {
+                                       $output .= "<pre>" . htmlspecialchars(stripslashes(print_r($val, TRUE))) . "</pre>";
+                               }
+                               else
+                               {
+                                       $output .= htmlspecialchars(stripslashes($val));
+                               }
+                               $output .= "</td></tr>\n";
+                       }
+
+                       $output .= "</table>\n";
+               }
+               $output .= "</fieldset>";
+
+               return $output;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Show query string
+        *
+        * @return      string
+        */
+       protected function _compile_uri_string()
+       {
+               $output  = "\n\n";
+               $output .= '<fieldset id="ci_profiler_uri_string" style="border:1px solid #000;padding:6px 10px 10px 10px;margin:20px 0 20px 0;background-color:#eee">';
+               $output .= "\n";
+               $output .= '<legend style="color:#000;">&nbsp;&nbsp;'.$this->CI->lang->line('profiler_uri_string').'&nbsp;&nbsp;</legend>';
+               $output .= "\n";
+
+               if ($this->CI->uri->uri_string == '')
+               {
+                       $output .= "<div style='color:#000;font-weight:normal;padding:4px 0 4px 0'>".$this->CI->lang->line('profiler_no_uri')."</div>";
+               }
+               else
+               {
+                       $output .= "<div style='color:#000;font-weight:normal;padding:4px 0 4px 0'>".$this->CI->uri->uri_string."</div>";
+               }
+
+               $output .= "</fieldset>";
+
+               return $output;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Show the controller and function that were called
+        *
+        * @return      string
+        */
+       protected function _compile_controller_info()
+       {
+               $output  = "\n\n";
+               $output .= '<fieldset id="ci_profiler_controller_info" style="border:1px solid #995300;padding:6px 10px 10px 10px;margin:20px 0 20px 0;background-color:#eee">';
+               $output .= "\n";
+               $output .= '<legend style="color:#995300;">&nbsp;&nbsp;'.$this->CI->lang->line('profiler_controller_info').'&nbsp;&nbsp;</legend>';
+               $output .= "\n";
+
+               $output .= "<div style='color:#995300;font-weight:normal;padding:4px 0 4px 0'>".$this->CI->router->fetch_class()."/".$this->CI->router->fetch_method()."</div>";
+
+               $output .= "</fieldset>";
+
+               return $output;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Compile memory usage
+        *
+        * Display total used memory
+        *
+        * @return      string
+        */
+       protected function _compile_memory_usage()
+       {
+               $output  = "\n\n";
+               $output .= '<fieldset id="ci_profiler_memory_usage" style="border:1px solid #5a0099;padding:6px 10px 10px 10px;margin:20px 0 20px 0;background-color:#eee">';
+               $output .= "\n";
+               $output .= '<legend style="color:#5a0099;">&nbsp;&nbsp;'.$this->CI->lang->line('profiler_memory_usage').'&nbsp;&nbsp;</legend>';
+               $output .= "\n";
+
+               if (function_exists('memory_get_usage') && ($usage = memory_get_usage()) != '')
+               {
+                       $output .= "<div style='color:#5a0099;font-weight:normal;padding:4px 0 4px 0'>".number_format($usage).' bytes</div>';
+               }
+               else
+               {
+                       $output .= "<div style='color:#5a0099;font-weight:normal;padding:4px 0 4px 0'>".$this->CI->lang->line('profiler_no_memory_usage')."</div>";
+               }
+
+               $output .= "</fieldset>";
+
+               return $output;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Compile header information
+        *
+        * Lists HTTP headers
+        *
+        * @return      string
+        */
+       protected function _compile_http_headers()
+       {
+               $output  = "\n\n";
+               $output .= '<fieldset id="ci_profiler_http_headers" style="border:1px solid #000;padding:6px 10px 10px 10px;margin:20px 0 20px 0;background-color:#eee">';
+               $output .= "\n";
+               $output .= '<legend style="color:#000;">&nbsp;&nbsp;'.$this->CI->lang->line('profiler_headers').'&nbsp;&nbsp;</legend>';
+               $output .= "\n";
+
+               $output .= "\n\n<table style='width:100%'>\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)
+               {
+                       $val = (isset($_SERVER[$header])) ? $_SERVER[$header] : '';
+                       $output .= "<tr><td style='vertical-align: top;width:50%;padding:5px;color:#900;background-color:#ddd;'>".$header."&nbsp;&nbsp;</td><td style='width:50%;padding:5px;color:#000;background-color:#ddd;'>".$val."</td></tr>\n";
+               }
+
+               $output .= "</table>\n";
+               $output .= "</fieldset>";
+
+               return $output;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Compile config information
+        *
+        * Lists developer config variables
+        *
+        * @return      string
+        */
+       protected function _compile_config()
+       {
+               $output  = "\n\n";
+               $output .= '<fieldset id="ci_profiler_config" style="border:1px solid #000;padding:6px 10px 10px 10px;margin:20px 0 20px 0;background-color:#eee">';
+               $output .= "\n";
+               $output .= '<legend style="color:#000;">&nbsp;&nbsp;'.$this->CI->lang->line('profiler_config').'&nbsp;&nbsp;</legend>';
+               $output .= "\n";
+
+               $output .= "\n\n<table style='width:100%'>\n";
+
+               foreach ($this->CI->config->config as $config=>$val)
+               {
+                       if (is_array($val))
+                       {
+                               $val = print_r($val, TRUE);
+                       }
+
+                       $output .= "<tr><td style='padding:5px; vertical-align: top;color:#900;background-color:#ddd;'>".$config."&nbsp;&nbsp;</td><td style='padding:5px; color:#000;background-color:#ddd;'>".htmlspecialchars($val)."</td></tr>\n";
+               }
+
+               $output .= "</table>\n";
+               $output .= "</fieldset>";
+
+               return $output;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Run the Profiler
+        *
+        * @return      string
+        */
+       public function run()
+       {
+               $output = "<div id='codeigniter_profiler' style='clear:both;background-color:#fff;padding:10px;'>";
+               $fields_displayed = 0;
+
+               foreach ($this->_available_sections as $section)
+               {
+                       if ($this->_compile_{$section} !== FALSE)
+                       {
+                               $func = "_compile_{$section}";
+                               $output .= $this->{$func}();
+                               $fields_displayed++;
+                       }
+               }
+
+               if ($fields_displayed == 0)
+               {
+                       $output .= '<p style="border:1px solid #5a0099;padding:10px;margin:20px 0;background-color:#eee">'.$this->CI->lang->line('profiler_no_profiles').'</p>';
+               }
+
+               $output .= '</div>';
+
+               return $output;
+       }
+
+}
+
+// END CI_Profiler class
+
+/* End of file Profiler.php */
+/* Location: ./system/libraries/Profiler.php */
\ No newline at end of file
diff --git a/system/libraries/Session.php b/system/libraries/Session.php
new file mode 100755 (executable)
index 0000000..1822940
--- /dev/null
@@ -0,0 +1,776 @@
+<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+/**
+ * CodeIgniter
+ *
+ * An open source application development framework for PHP 5.1.6 or newer
+ *
+ * @package            CodeIgniter
+ * @author             ExpressionEngine Dev Team
+ * @copyright  Copyright (c) 2008 - 2011, EllisLab, Inc.
+ * @license            http://codeigniter.com/user_guide/license.html
+ * @link               http://codeigniter.com
+ * @since              Version 1.0
+ * @filesource
+ */
+
+// ------------------------------------------------------------------------
+
+/**
+ * Session Class
+ *
+ * @package            CodeIgniter
+ * @subpackage Libraries
+ * @category   Sessions
+ * @author             ExpressionEngine Dev Team
+ * @link               http://codeigniter.com/user_guide/libraries/sessions.html
+ */
+class CI_Session {
+
+       var $sess_encrypt_cookie                = FALSE;
+       var $sess_use_database                  = FALSE;
+       var $sess_table_name                    = '';
+       var $sess_expiration                    = 7200;
+       var $sess_expire_on_close               = FALSE;
+       var $sess_match_ip                              = FALSE;
+       var $sess_match_useragent               = TRUE;
+       var $sess_cookie_name                   = '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';
+       var $time_reference                             = 'time';
+       var $gc_probability                             = 5;
+       var $userdata                                   = array();
+       var $CI;
+       var $now;
+
+       /**
+        * Session Constructor
+        *
+        * The constructor runs the session routines automatically
+        * whenever the class is instantiated.
+        */
+       public function __construct($params = array())
+       {
+               log_message('debug', "Session Class Initialized");
+
+               // Set the super object to a local variable for use throughout the class
+               $this->CI =& get_instance();
+
+               // 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', '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);
+               }
+
+               if ($this->encryption_key == '')
+               {
+                       show_error('In order to use the Session class you are required to set an encryption key in your config file.');
+               }
+
+               // Load the string helper so we can use the strip_slashes() function
+               $this->CI->load->helper('string');
+
+               // Do we need encryption? If so, load the encryption class
+               if ($this->sess_encrypt_cookie == TRUE)
+               {
+                       $this->CI->load->library('encrypt');
+               }
+
+               // Are we using a database?  If so, load it
+               if ($this->sess_use_database === TRUE AND $this->sess_table_name != '')
+               {
+                       $this->CI->load->database();
+               }
+
+               // Set the "now" time.  Can either be GMT or server time, based on the
+               // config prefs.  We use this to set the "last activity" time
+               $this->now = $this->_get_time();
+
+               // Set the session length. If the session expiration is
+               // set to zero we'll set the expiration two years from now.
+               if ($this->sess_expiration == 0)
+               {
+                       $this->sess_expiration = (60*60*24*365*2);
+               }
+               
+               // Set the cookie name
+               $this->sess_cookie_name = $this->cookie_prefix.$this->sess_cookie_name;
+
+               // Run the Session routine. If a session doesn't exist we'll
+               // create a new one.  If it does, we'll update it.
+               if ( ! $this->sess_read())
+               {
+                       $this->sess_create();
+               }
+               else
+               {
+                       $this->sess_update();
+               }
+
+               // Delete 'old' flashdata (from last request)
+               $this->_flashdata_sweep();
+
+               // Mark all new flashdata as old (data will be deleted before next request)
+               $this->_flashdata_mark();
+
+               // Delete expired sessions if necessary
+               $this->_sess_gc();
+
+               log_message('debug', "Session routines successfully run");
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Fetch the current session data if it exists
+        *
+        * @access      public
+        * @return      bool
+        */
+       function sess_read()
+       {
+               // Fetch the cookie
+               $session = $this->CI->input->cookie($this->sess_cookie_name);
+
+               // No cookie?  Goodbye cruel world!...
+               if ($session === FALSE)
+               {
+                       log_message('debug', 'A session cookie was not found.');
+                       return FALSE;
+               }
+
+               // Decrypt the cookie data
+               if ($this->sess_encrypt_cookie == TRUE)
+               {
+                       $session = $this->CI->encrypt->decode($session);
+               }
+               else
+               {
+                       // encryption was not used, so we need to check the md5 hash
+                       $hash    = substr($session, strlen($session)-32); // get last 32 chars
+                       $session = substr($session, 0, strlen($session)-32);
+
+                       // Does the md5 hash match?  This is to prevent manipulation of session data in userspace
+                       if ($hash !==  md5($session.$this->encryption_key))
+                       {
+                               log_message('error', 'The session cookie data did not match what was expected. This could be a possible hacking attempt.');
+                               $this->sess_destroy();
+                               return FALSE;
+                       }
+               }
+
+               // Unserialize the session array
+               $session = $this->_unserialize($session);
+
+               // Is the session data we unserialized an array with the correct format?
+               if ( ! is_array($session) OR ! isset($session['session_id']) OR ! isset($session['ip_address']) OR ! isset($session['user_agent']) OR ! isset($session['last_activity']))
+               {
+                       $this->sess_destroy();
+                       return FALSE;
+               }
+
+               // Is the session current?
+               if (($session['last_activity'] + $this->sess_expiration) < $this->now)
+               {
+                       $this->sess_destroy();
+                       return FALSE;
+               }
+
+               // Does the IP Match?
+               if ($this->sess_match_ip == TRUE AND $session['ip_address'] != $this->CI->input->ip_address())
+               {
+                       $this->sess_destroy();
+                       return FALSE;
+               }
+
+               // 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)))
+               {
+                       $this->sess_destroy();
+                       return FALSE;
+               }
+
+               // Is there a corresponding session in the DB?
+               if ($this->sess_use_database === TRUE)
+               {
+                       $this->CI->db->where('session_id', $session['session_id']);
+
+                       if ($this->sess_match_ip == TRUE)
+                       {
+                               $this->CI->db->where('ip_address', $session['ip_address']);
+                       }
+
+                       if ($this->sess_match_useragent == TRUE)
+                       {
+                               $this->CI->db->where('user_agent', $session['user_agent']);
+                       }
+
+                       $query = $this->CI->db->get($this->sess_table_name);
+
+                       // No result?  Kill it!
+                       if ($query->num_rows() == 0)
+                       {
+                               $this->sess_destroy();
+                               return FALSE;
+                       }
+
+                       // Is there custom data?  If so, add it to the main session array
+                       $row = $query->row();
+                       if (isset($row->user_data) AND $row->user_data != '')
+                       {
+                               $custom_data = $this->_unserialize($row->user_data);
+
+                               if (is_array($custom_data))
+                               {
+                                       foreach ($custom_data as $key => $val)
+                                       {
+                                               $session[$key] = $val;
+                                       }
+                               }
+                       }
+               }
+
+               // Session is valid!
+               $this->userdata = $session;
+               unset($session);
+
+               return TRUE;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Write the session data
+        *
+        * @access      public
+        * @return      void
+        */
+       function sess_write()
+       {
+               // Are we saving custom data to the DB?  If not, all we do is update the cookie
+               if ($this->sess_use_database === FALSE)
+               {
+                       $this->_set_cookie();
+                       return;
+               }
+
+               // set the custom userdata, the session data we will set in a second
+               $custom_userdata = $this->userdata;
+               $cookie_userdata = array();
+
+               // Before continuing, we need to determine if there is any custom data to deal with.
+               // Let's determine this by removing the default indexes to see if there's anything left in the array
+               // and set the session data while we're at it
+               foreach (array('session_id','ip_address','user_agent','last_activity') as $val)
+               {
+                       unset($custom_userdata[$val]);
+                       $cookie_userdata[$val] = $this->userdata[$val];
+               }
+
+               // Did we find any custom data?  If not, we turn the empty array into a string
+               // since there's no reason to serialize and store an empty array in the DB
+               if (count($custom_userdata) === 0)
+               {
+                       $custom_userdata = '';
+               }
+               else
+               {
+                       // Serialize the custom data array so we can store it
+                       $custom_userdata = $this->_serialize($custom_userdata);
+               }
+
+               // Run the update query
+               $this->CI->db->where('session_id', $this->userdata['session_id']);
+               $this->CI->db->update($this->sess_table_name, array('last_activity' => $this->userdata['last_activity'], 'user_data' => $custom_userdata));
+
+               // Write the cookie.  Notice that we manually pass the cookie data array to the
+               // _set_cookie() function. Normally that function will store $this->userdata, but
+               // in this case that array contains custom data, which we do not want in the cookie.
+               $this->_set_cookie($cookie_userdata);
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Create a new session
+        *
+        * @access      public
+        * @return      void
+        */
+       function sess_create()
+       {
+               $sessid = '';
+               while (strlen($sessid) < 32)
+               {
+                       $sessid .= mt_rand(0, mt_getrandmax());
+               }
+
+               // To make the session ID even more secure we'll combine it with the user's IP
+               $sessid .= $this->CI->input->ip_address();
+
+               $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),
+                                                       'last_activity' => $this->now
+                                                       );
+
+
+               // Save the data to the DB if needed
+               if ($this->sess_use_database === TRUE)
+               {
+                       $this->CI->db->query($this->CI->db->insert_string($this->sess_table_name, $this->userdata));
+               }
+
+               // Write the cookie
+               $this->_set_cookie();
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Update an existing session
+        *
+        * @access      public
+        * @return      void
+        */
+       function sess_update()
+       {
+               // We only update the session every five minutes by default
+               if (($this->userdata['last_activity'] + $this->sess_time_to_update) >= $this->now)
+               {
+                       return;
+               }
+
+               // Save the old session id so we know which record to
+               // update in the database if we need it
+               $old_sessid = $this->userdata['session_id'];
+               $new_sessid = '';
+               while (strlen($new_sessid) < 32)
+               {
+                       $new_sessid .= mt_rand(0, mt_getrandmax());
+               }
+
+               // To make the session ID even more secure we'll combine it with the user's IP
+               $new_sessid .= $this->CI->input->ip_address();
+
+               // Turn it into a hash
+               $new_sessid = md5(uniqid($new_sessid, TRUE));
+
+               // Update the session data in the session data array
+               $this->userdata['session_id'] = $new_sessid;
+               $this->userdata['last_activity'] = $this->now;
+
+               // _set_cookie() will handle this for us if we aren't using database sessions
+               // by pushing all userdata to the cookie.
+               $cookie_data = NULL;
+
+               // Update the session ID and last_activity field in the DB if needed
+               if ($this->sess_use_database === TRUE)
+               {
+                       // set cookie explicitly to only have our session data
+                       $cookie_data = array();
+                       foreach (array('session_id','ip_address','user_agent','last_activity') as $val)
+                       {
+                               $cookie_data[$val] = $this->userdata[$val];
+                       }
+
+                       $this->CI->db->query($this->CI->db->update_string($this->sess_table_name, array('last_activity' => $this->now, 'session_id' => $new_sessid), array('session_id' => $old_sessid)));
+               }
+
+               // Write the cookie
+               $this->_set_cookie($cookie_data);
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Destroy the current session
+        *
+        * @access      public
+        * @return      void
+        */
+       function sess_destroy()
+       {
+               // Kill the session DB row
+               if ($this->sess_use_database === TRUE AND isset($this->userdata['session_id']))
+               {
+                       $this->CI->db->where('session_id', $this->userdata['session_id']);
+                       $this->CI->db->delete($this->sess_table_name);
+               }
+
+               // Kill the cookie
+               setcookie(
+                                       $this->sess_cookie_name,
+                                       addslashes(serialize(array())),
+                                       ($this->now - 31500000),
+                                       $this->cookie_path,
+                                       $this->cookie_domain,
+                                       0
+                               );
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Fetch a specific item from the session array
+        *
+        * @access      public
+        * @param       string
+        * @return      string
+        */
+       function userdata($item)
+       {
+               return ( ! isset($this->userdata[$item])) ? FALSE : $this->userdata[$item];
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Fetch all session data
+        *
+        * @access      public
+        * @return      mixed
+        */
+       function all_userdata()
+       {
+               return ( ! isset($this->userdata)) ? FALSE : $this->userdata;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Add or change data in the "userdata" array
+        *
+        * @access      public
+        * @param       mixed
+        * @param       string
+        * @return      void
+        */
+       function set_userdata($newdata = array(), $newval = '')
+       {
+               if (is_string($newdata))
+               {
+                       $newdata = array($newdata => $newval);
+               }
+
+               if (count($newdata) > 0)
+               {
+                       foreach ($newdata as $key => $val)
+                       {
+                               $this->userdata[$key] = $val;
+                       }
+               }
+
+               $this->sess_write();
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Delete a session variable from the "userdata" array
+        *
+        * @access      array
+        * @return      void
+        */
+       function unset_userdata($newdata = array())
+       {
+               if (is_string($newdata))
+               {
+                       $newdata = array($newdata => '');
+               }
+
+               if (count($newdata) > 0)
+               {
+                       foreach ($newdata as $key => $val)
+                       {
+                               unset($this->userdata[$key]);
+                       }
+               }
+
+               $this->sess_write();
+       }
+
+       // ------------------------------------------------------------------------
+
+       /**
+        * Add or change flashdata, only available
+        * until the next request
+        *
+        * @access      public
+        * @param       mixed
+        * @param       string
+        * @return      void
+        */
+       function set_flashdata($newdata = array(), $newval = '')
+       {
+               if (is_string($newdata))
+               {
+                       $newdata = array($newdata => $newval);
+               }
+
+               if (count($newdata) > 0)
+               {
+                       foreach ($newdata as $key => $val)
+                       {
+                               $flashdata_key = $this->flashdata_key.':new:'.$key;
+                               $this->set_userdata($flashdata_key, $val);
+                       }
+               }
+       }
+
+       // ------------------------------------------------------------------------
+
+       /**
+        * Keeps existing flashdata available to next request.
+        *
+        * @access      public
+        * @param       string
+        * @return      void
+        */
+       function keep_flashdata($key)
+       {
+               // 'old' flashdata gets removed.  Here we mark all
+               // flashdata as 'new' to preserve it from _flashdata_sweep()
+               // Note the function will return FALSE if the $key
+               // provided cannot be found
+               $old_flashdata_key = $this->flashdata_key.':old:'.$key;
+               $value = $this->userdata($old_flashdata_key);
+
+               $new_flashdata_key = $this->flashdata_key.':new:'.$key;
+               $this->set_userdata($new_flashdata_key, $value);
+       }
+
+       // ------------------------------------------------------------------------
+
+       /**
+        * Fetch a specific flashdata item from the session array
+        *
+        * @access      public
+        * @param       string
+        * @return      string
+        */
+       function flashdata($key)
+       {
+               $flashdata_key = $this->flashdata_key.':old:'.$key;
+               return $this->userdata($flashdata_key);
+       }
+
+       // ------------------------------------------------------------------------
+
+       /**
+        * Identifies flashdata as 'old' for removal
+        * when _flashdata_sweep() runs.
+        *
+        * @access      private
+        * @return      void
+        */
+       function _flashdata_mark()
+       {
+               $userdata = $this->all_userdata();
+               foreach ($userdata as $name => $value)
+               {
+                       $parts = explode(':new:', $name);
+                       if (is_array($parts) && count($parts) === 2)
+                       {
+                               $new_name = $this->flashdata_key.':old:'.$parts[1];
+                               $this->set_userdata($new_name, $value);
+                               $this->unset_userdata($name);
+                       }
+               }
+       }
+
+       // ------------------------------------------------------------------------
+
+       /**
+        * Removes all flashdata marked as 'old'
+        *
+        * @access      private
+        * @return      void
+        */
+
+       function _flashdata_sweep()
+       {
+               $userdata = $this->all_userdata();
+               foreach ($userdata as $key => $value)
+               {
+                       if (strpos($key, ':old:'))
+                       {
+                               $this->unset_userdata($key);
+                       }
+               }
+
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Get the "now" time
+        *
+        * @access      private
+        * @return      string
+        */
+       function _get_time()
+       {
+               if (strtolower($this->time_reference) == 'gmt')
+               {
+                       $now = time();
+                       $time = mktime(gmdate("H", $now), gmdate("i", $now), gmdate("s", $now), gmdate("m", $now), gmdate("d", $now), gmdate("Y", $now));
+               }
+               else
+               {
+                       $time = time();
+               }
+
+               return $time;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Write the session cookie
+        *
+        * @access      public
+        * @return      void
+        */
+       function _set_cookie($cookie_data = NULL)
+       {
+               if (is_null($cookie_data))
+               {
+                       $cookie_data = $this->userdata;
+               }
+
+               // Serialize the userdata for the cookie
+               $cookie_data = $this->_serialize($cookie_data);
+
+               if ($this->sess_encrypt_cookie == TRUE)
+               {
+                       $cookie_data = $this->CI->encrypt->encode($cookie_data);
+               }
+               else
+               {
+                       // if encryption is not used, we provide an md5 hash to prevent userside tampering
+                       $cookie_data = $cookie_data.md5($cookie_data.$this->encryption_key);
+               }
+
+               $expire = ($this->sess_expire_on_close === TRUE) ? 0 : $this->sess_expiration + time();
+
+               // Set the cookie
+               setcookie(
+                                       $this->sess_cookie_name,
+                                       $cookie_data,
+                                       $expire,
+                                       $this->cookie_path,
+                                       $this->cookie_domain,
+                                       $this->cookie_secure
+                               );
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Serialize an array
+        *
+        * This function first converts any slashes found in the array to a temporary
+        * marker, so when it gets unserialized the slashes will be preserved
+        *
+        * @access      private
+        * @param       array
+        * @return      string
+        */
+       function _serialize($data)
+       {
+               if (is_array($data))
+               {
+                       foreach ($data as $key => $val)
+                       {
+                               if (is_string($val))
+                               {
+                                       $data[$key] = str_replace('\\', '{{slash}}', $val);
+                               }
+                       }
+               }
+               else
+               {
+                       if (is_string($data))
+                       {
+                               $data = str_replace('\\', '{{slash}}', $data);
+                       }
+               }
+
+               return serialize($data);
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Unserialize
+        *
+        * This function unserializes a data string, then converts any
+        * temporary slash markers back to actual slashes
+        *
+        * @access      private
+        * @param       array
+        * @return      string
+        */
+       function _unserialize($data)
+       {
+               $data = @unserialize(strip_slashes($data));
+
+               if (is_array($data))
+               {
+                       foreach ($data as $key => $val)
+                       {
+                               if (is_string($val))
+                               {
+                                       $data[$key] = str_replace('{{slash}}', '\\', $val);
+                               }
+                       }
+
+                       return $data;
+               }
+
+               return (is_string($data)) ? str_replace('{{slash}}', '\\', $data) : $data;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Garbage collection
+        *
+        * This deletes expired session rows from database
+        * if the probability percentage is met
+        *
+        * @access      public
+        * @return      void
+        */
+       function _sess_gc()
+       {
+               if ($this->sess_use_database != TRUE)
+               {
+                       return;
+               }
+
+               srand(time());
+               if ((rand() % 100) < $this->gc_probability)
+               {
+                       $expire = $this->now - $this->sess_expiration;
+
+                       $this->CI->db->where("last_activity < {$expire}");
+                       $this->CI->db->delete($this->sess_table_name);
+
+                       log_message('debug', 'Session garbage collection performed.');
+               }
+       }
+
+
+}
+// END Session Class
+
+/* End of file Session.php */
+/* Location: ./system/libraries/Session.php */
\ No newline at end of file
diff --git a/system/libraries/Sha1.php b/system/libraries/Sha1.php
new file mode 100755 (executable)
index 0000000..1a65757
--- /dev/null
@@ -0,0 +1,251 @@
+<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+/**
+ * CodeIgniter
+ *
+ * An open source application development framework for PHP 5.1.6 or newer
+ *
+ * @package            CodeIgniter
+ * @author             ExpressionEngine Dev Team
+ * @copyright  Copyright (c) 2008 - 2011, EllisLab, Inc.
+ * @license            http://codeigniter.com/user_guide/license.html
+ * @link               http://codeigniter.com
+ * @since              Version 1.0
+ * @filesource
+ */
+
+// ------------------------------------------------------------------------
+
+/**
+ * SHA1 Encoding Class
+ *
+ * Purpose: Provides 160 bit hashing using The Secure Hash Algorithm
+ * developed at the National Institute of Standards and Technology. The 40
+ * character SHA1 message hash is computationally infeasible to crack.
+ *
+ * This class is a fallback for servers that are not running PHP greater than
+ * 4.3, or do not have the MHASH library.
+ *
+ * This class is based on two scripts:
+ *
+ * Marcus Campbell's PHP implementation (GNU license)
+ * http://www.tecknik.net/sha-1/
+ *
+ * ...which is based on Paul Johnston's JavaScript version
+ * (BSD license). http://pajhome.org.uk/
+ *
+ * I encapsulated the functions and wrote one additional method to fix
+ * a hex conversion bug. - Rick Ellis
+ *
+ * @package            CodeIgniter
+ * @subpackage Libraries
+ * @category   Encryption
+ * @author             ExpressionEngine Dev Team
+ * @link               http://codeigniter.com/user_guide/general/encryption.html
+ */
+class CI_SHA1 {
+
+       public function __construct()
+       {
+               log_message('debug', "SHA1 Class Initialized");
+       }
+
+       /**
+        * Generate the Hash
+        *
+        * @access      public
+        * @param       string
+        * @return      string
+        */
+       function generate($str)
+       {
+               $n = ((strlen($str) + 8) >> 6) + 1;
+
+               for ($i = 0; $i < $n * 16; $i++)
+               {
+                       $x[$i] = 0;
+               }
+
+               for ($i = 0; $i < strlen($str); $i++)
+               {
+                       $x[$i >> 2] |= ord(substr($str, $i, 1)) << (24 - ($i % 4) * 8);
+               }
+
+               $x[$i >> 2] |= 0x80 << (24 - ($i % 4) * 8);
+
+               $x[$n * 16 - 1] = strlen($str) * 8;
+
+               $a =  1732584193;
+               $b = -271733879;
+               $c = -1732584194;
+               $d =  271733878;
+               $e = -1009589776;
+
+               for ($i = 0; $i < count($x); $i += 16)
+               {
+                       $olda = $a;
+                       $oldb = $b;
+                       $oldc = $c;
+                       $oldd = $d;
+                       $olde = $e;
+
+                       for ($j = 0; $j < 80; $j++)
+                       {
+                               if ($j < 16)
+                               {
+                                       $w[$j] = $x[$i + $j];
+                               }
+                               else
+                               {
+                                       $w[$j] = $this->_rol($w[$j - 3] ^ $w[$j - 8] ^ $w[$j - 14] ^ $w[$j - 16], 1);
+                               }
+
+                               $t = $this->_safe_add($this->_safe_add($this->_rol($a, 5), $this->_ft($j, $b, $c, $d)), $this->_safe_add($this->_safe_add($e, $w[$j]), $this->_kt($j)));
+
+                               $e = $d;
+                               $d = $c;
+                               $c = $this->_rol($b, 30);
+                               $b = $a;
+                               $a = $t;
+                       }
+
+                       $a = $this->_safe_add($a, $olda);
+                       $b = $this->_safe_add($b, $oldb);
+                       $c = $this->_safe_add($c, $oldc);
+                       $d = $this->_safe_add($d, $oldd);
+                       $e = $this->_safe_add($e, $olde);
+               }
+
+               return $this->_hex($a).$this->_hex($b).$this->_hex($c).$this->_hex($d).$this->_hex($e);
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Convert a decimal to hex
+        *
+        * @access      private
+        * @param       string
+        * @return      string
+        */
+       function _hex($str)
+       {
+               $str = dechex($str);
+
+               if (strlen($str) == 7)
+               {
+                       $str = '0'.$str;
+               }
+
+               return $str;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        *  Return result based on iteration
+        *
+        * @access      private
+        * @return      string
+        */
+       function _ft($t, $b, $c, $d)
+       {
+               if ($t < 20)
+                       return ($b & $c) | ((~$b) & $d);
+               if ($t < 40)
+                       return $b ^ $c ^ $d;
+               if ($t < 60)
+                       return ($b & $c) | ($b & $d) | ($c & $d);
+
+               return $b ^ $c ^ $d;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Determine the additive constant
+        *
+        * @access      private
+        * @return      string
+        */
+       function _kt($t)
+       {
+               if ($t < 20)
+               {
+                       return 1518500249;
+               }
+               else if ($t < 40)
+               {
+                       return 1859775393;
+               }
+               else if ($t < 60)
+               {
+                       return -1894007588;
+               }
+               else
+               {
+                       return -899497514;
+               }
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Add integers, wrapping at 2^32
+        *
+        * @access      private
+        * @return      string
+        */
+       function _safe_add($x, $y)
+       {
+               $lsw = ($x & 0xFFFF) + ($y & 0xFFFF);
+               $msw = ($x >> 16) + ($y >> 16) + ($lsw >> 16);
+
+               return ($msw << 16) | ($lsw & 0xFFFF);
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Bitwise rotate a 32-bit number
+        *
+        * @access      private
+        * @return      integer
+        */
+       function _rol($num, $cnt)
+       {
+               return ($num << $cnt) | $this->_zero_fill($num, 32 - $cnt);
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Pad string with zero
+        *
+        * @access      private
+        * @return      string
+        */
+       function _zero_fill($a, $b)
+       {
+               $bin = decbin($a);
+
+               if (strlen($bin) < $b)
+               {
+                       $bin = 0;
+               }
+               else
+               {
+                       $bin = substr($bin, 0, strlen($bin) - $b);
+               }
+
+               for ($i=0; $i < $b; $i++)
+               {
+                       $bin = "0".$bin;
+               }
+
+               return bindec($bin);
+       }
+}
+// END CI_SHA
+
+/* End of file Sha1.php */
+/* Location: ./system/libraries/Sha1.php */
\ No newline at end of file
diff --git a/system/libraries/Table.php b/system/libraries/Table.php
new file mode 100755 (executable)
index 0000000..def6967
--- /dev/null
@@ -0,0 +1,531 @@
+<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+/**
+ * CodeIgniter
+ *
+ * An open source application development framework for PHP 5.1.6 or newer
+ *
+ * @package            CodeIgniter
+ * @author             ExpressionEngine Dev Team
+ * @copyright  Copyright (c) 2008 - 2011, EllisLab, Inc.
+ * @license            http://codeigniter.com/user_guide/license.html
+ * @link               http://codeigniter.com
+ * @since              Version 1.3.1
+ * @filesource
+ */
+
+// ------------------------------------------------------------------------
+
+/**
+ * HTML Table Generating Class
+ *
+ * Lets you create tables manually or from database result objects, or arrays.
+ *
+ * @package            CodeIgniter
+ * @subpackage Libraries
+ * @category   HTML Tables
+ * @author             ExpressionEngine Dev Team
+ * @link               http://codeigniter.com/user_guide/libraries/uri.html
+ */
+class CI_Table {
+
+       var $rows                               = array();
+       var $heading                    = array();
+       var $auto_heading               = TRUE;
+       var $caption                    = NULL;
+       var $template                   = NULL;
+       var $newline                    = "\n";
+       var $empty_cells                = "";
+       var     $function                       = FALSE;
+
+       public function __construct()
+       {
+               log_message('debug', "Table Class Initialized");
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Set the template
+        *
+        * @access      public
+        * @param       array
+        * @return      void
+        */
+       function set_template($template)
+       {
+               if ( ! is_array($template))
+               {
+                       return FALSE;
+               }
+
+               $this->template = $template;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Set the table heading
+        *
+        * Can be passed as an array or discreet params
+        *
+        * @access      public
+        * @param       mixed
+        * @return      void
+        */
+       function set_heading()
+       {
+               $args = func_get_args();
+               $this->heading = $this->_prep_args($args);
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Set columns.  Takes a one-dimensional array as input and creates
+        * a multi-dimensional array with a depth equal to the number of
+        * columns.  This allows a single array with many elements to  be
+        * displayed in a table that has a fixed column count.
+        *
+        * @access      public
+        * @param       array
+        * @param       int
+        * @return      void
+        */
+       function make_columns($array = array(), $col_limit = 0)
+       {
+               if ( ! is_array($array) OR count($array) == 0)
+               {
+                       return FALSE;
+               }
+
+               // Turn off the auto-heading feature since it's doubtful we
+               // will want headings from a one-dimensional array
+               $this->auto_heading = FALSE;
+
+               if ($col_limit == 0)
+               {
+                       return $array;
+               }
+
+               $new = array();
+               while (count($array) > 0)
+               {
+                       $temp = array_splice($array, 0, $col_limit);
+
+                       if (count($temp) < $col_limit)
+                       {
+                               for ($i = count($temp); $i < $col_limit; $i++)
+                               {
+                                       $temp[] = '&nbsp;';
+                               }
+                       }
+
+                       $new[] = $temp;
+               }
+
+               return $new;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Set "empty" cells
+        *
+        * Can be passed as an array or discreet params
+        *
+        * @access      public
+        * @param       mixed
+        * @return      void
+        */
+       function set_empty($value)
+       {
+               $this->empty_cells = $value;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Add a table row
+        *
+        * Can be passed as an array or discreet params
+        *
+        * @access      public
+        * @param       mixed
+        * @return      void
+        */
+       function add_row()
+       {
+               $args = func_get_args();
+               $this->rows[] = $this->_prep_args($args);
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Prep Args
+        *
+        * Ensures a standard associative array format for all cell data
+        *
+        * @access      public
+        * @param       type
+        * @return      type
+        */
+       function _prep_args($args)
+       {
+               // If there is no $args[0], skip this and treat as an associative array
+               // This can happen if there is only a single key, for example this is passed to table->generate
+               // array(array('foo'=>'bar'))
+               if (isset($args[0]) AND (count($args) == 1 && is_array($args[0])))
+               {
+                       // args sent as indexed array
+                       if ( ! isset($args[0]['data']))
+                       {
+                               foreach ($args[0] as $key => $val)
+                               {
+                                       if (is_array($val) && isset($val['data']))
+                                       {
+                                               $args[$key] = $val;
+                                       }
+                                       else
+                                       {
+                                               $args[$key] = array('data' => $val);
+                                       }
+                               }
+                       }
+               }
+               else
+               {
+                       foreach ($args as $key => $val)
+                       {
+                               if ( ! is_array($val))
+                               {
+                                       $args[$key] = array('data' => $val);
+                               }
+                       }
+               }
+
+               return $args;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Add a table caption
+        *
+        * @access      public
+        * @param       string
+        * @return      void
+        */
+       function set_caption($caption)
+       {
+               $this->caption = $caption;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Generate the table
+        *
+        * @access      public
+        * @param       mixed
+        * @return      string
+        */
+       function generate($table_data = NULL)
+       {
+               // The table data can optionally be passed to this function
+               // either as a database result object or an array
+               if ( ! is_null($table_data))
+               {
+                       if (is_object($table_data))
+                       {
+                               $this->_set_from_object($table_data);
+                       }
+                       elseif (is_array($table_data))
+                       {
+                               $set_heading = (count($this->heading) == 0 AND $this->auto_heading == FALSE) ? FALSE : TRUE;
+                               $this->_set_from_array($table_data, $set_heading);
+                       }
+               }
+
+               // Is there anything to display?  No?  Smite them!
+               if (count($this->heading) == 0 AND count($this->rows) == 0)
+               {
+                       return 'Undefined table data';
+               }
+
+               // Compile and validate the template date
+               $this->_compile_template();
+
+               // set a custom cell manipulation function to a locally scoped variable so its callable
+               $function = $this->function;
+
+               // Build the table!
+
+               $out = $this->template['table_open'];
+               $out .= $this->newline;
+
+               // Add any caption here
+               if ($this->caption)
+               {
+                       $out .= $this->newline;
+                       $out .= '<caption>' . $this->caption . '</caption>';
+                       $out .= $this->newline;
+               }
+
+               // Is there a table heading to display?
+               if (count($this->heading) > 0)
+               {
+                       $out .= $this->template['thead_open'];
+                       $out .= $this->newline;
+                       $out .= $this->template['heading_row_start'];
+                       $out .= $this->newline;
+
+                       foreach ($this->heading as $heading)
+                       {
+                               $temp = $this->template['heading_cell_start'];
+
+                               foreach ($heading as $key => $val)
+                               {
+                                       if ($key != 'data')
+                                       {
+                                               $temp = str_replace('<th', "<th $key='$val'", $temp);
+                                       }
+                               }
+
+                               $out .= $temp;
+                               $out .= isset($heading['data']) ? $heading['data'] : '';
+                               $out .= $this->template['heading_cell_end'];
+                       }
+
+                       $out .= $this->template['heading_row_end'];
+                       $out .= $this->newline;
+                       $out .= $this->template['thead_close'];
+                       $out .= $this->newline;
+               }
+
+               // Build the table rows
+               if (count($this->rows) > 0)
+               {
+                       $out .= $this->template['tbody_open'];
+                       $out .= $this->newline;
+
+                       $i = 1;
+                       foreach ($this->rows as $row)
+                       {
+                               if ( ! is_array($row))
+                               {
+                                       break;
+                               }
+
+                               // We use modulus to alternate the row colors
+                               $name = (fmod($i++, 2)) ? '' : 'alt_';
+
+                               $out .= $this->template['row_'.$name.'start'];
+                               $out .= $this->newline;
+
+                               foreach ($row as $cell)
+                               {
+                                       $temp = $this->template['cell_'.$name.'start'];
+
+                                       foreach ($cell as $key => $val)
+                                       {
+                                               if ($key != 'data')
+                                               {
+                                                       $temp = str_replace('<td', "<td $key='$val'", $temp);
+                                               }
+                                       }
+
+                                       $cell = isset($cell['data']) ? $cell['data'] : '';
+                                       $out .= $temp;
+
+                                       if ($cell === "" OR $cell === NULL)
+                                       {
+                                               $out .= $this->empty_cells;
+                                       }
+                                       else
+                                       {
+                                               if ($function !== FALSE && is_callable($function))
+                                               {
+                                                       $out .= call_user_func($function, $cell);
+                                               }
+                                               else
+                                               {
+                                                       $out .= $cell;
+                                               }
+                                       }
+
+                                       $out .= $this->template['cell_'.$name.'end'];
+                               }
+
+                               $out .= $this->template['row_'.$name.'end'];
+                               $out .= $this->newline;
+                       }
+
+                       $out .= $this->template['tbody_close'];
+                       $out .= $this->newline;
+               }
+
+               $out .= $this->template['table_close'];
+
+               // Clear table class properties before generating the table
+               $this->clear();
+
+               return $out;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Clears the table arrays.  Useful if multiple tables are being generated
+        *
+        * @access      public
+        * @return      void
+        */
+       function clear()
+       {
+               $this->rows                             = array();
+               $this->heading                  = array();
+               $this->auto_heading             = TRUE;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Set table data from a database result object
+        *
+        * @access      public
+        * @param       object
+        * @return      void
+        */
+       function _set_from_object($query)
+       {
+               if ( ! is_object($query))
+               {
+                       return FALSE;
+               }
+
+               // First generate the headings from the table column names
+               if (count($this->heading) == 0)
+               {
+                       if ( ! method_exists($query, 'list_fields'))
+                       {
+                               return FALSE;
+                       }
+
+                       $this->heading = $this->_prep_args($query->list_fields());
+               }
+
+               // Next blast through the result array and build out the rows
+
+               if ($query->num_rows() > 0)
+               {
+                       foreach ($query->result_array() as $row)
+                       {
+                               $this->rows[] = $this->_prep_args($row);
+                       }
+               }
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Set table data from an array
+        *
+        * @access      public
+        * @param       array
+        * @return      void
+        */
+       function _set_from_array($data, $set_heading = TRUE)
+       {
+               if ( ! is_array($data) OR count($data) == 0)
+               {
+                       return FALSE;
+               }
+
+               $i = 0;
+               foreach ($data as $row)
+               {
+                       // If a heading hasn't already been set we'll use the first row of the array as the heading
+                       if ($i == 0 AND count($data) > 1 AND count($this->heading) == 0 AND $set_heading == TRUE)
+                       {
+                               $this->heading = $this->_prep_args($row);
+                       }
+                       else
+                       {
+                               $this->rows[] = $this->_prep_args($row);
+                       }
+
+                       $i++;
+               }
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Compile Template
+        *
+        * @access      private
+        * @return      void
+        */
+       function _compile_template()
+       {
+               if ($this->template == NULL)
+               {
+                       $this->template = $this->_default_template();
+                       return;
+               }
+
+               $this->temp = $this->_default_template();
+               foreach (array('table_open', 'thead_open', 'thead_close', 'heading_row_start', 'heading_row_end', 'heading_cell_start', 'heading_cell_end', 'tbody_open', 'tbody_close', 'row_start', 'row_end', 'cell_start', 'cell_end', 'row_alt_start', 'row_alt_end', 'cell_alt_start', 'cell_alt_end', 'table_close') as $val)
+               {
+                       if ( ! isset($this->template[$val]))
+                       {
+                               $this->template[$val] = $this->temp[$val];
+                       }
+               }
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Default Template
+        *
+        * @access      private
+        * @return      void
+        */
+       function _default_template()
+       {
+               return  array (
+                                               'table_open'                    => '<table border="0" cellpadding="4" cellspacing="0">',
+
+                                               'thead_open'                    => '<thead>',
+                                               'thead_close'                   => '</thead>',
+
+                                               'heading_row_start'             => '<tr>',
+                                               'heading_row_end'               => '</tr>',
+                                               'heading_cell_start'    => '<th>',
+                                               'heading_cell_end'              => '</th>',
+
+                                               'tbody_open'                    => '<tbody>',
+                                               'tbody_close'                   => '</tbody>',
+
+                                               'row_start'                             => '<tr>',
+                                               'row_end'                               => '</tr>',
+                                               'cell_start'                    => '<td>',
+                                               'cell_end'                              => '</td>',
+
+                                               'row_alt_start'         => '<tr>',
+                                               'row_alt_end'                   => '</tr>',
+                                               'cell_alt_start'                => '<td>',
+                                               'cell_alt_end'                  => '</td>',
+
+                                               'table_close'                   => '</table>'
+                                       );
+       }
+
+
+}
+
+
+/* End of file Table.php */
+/* Location: ./system/libraries/Table.php */
\ No newline at end of file
diff --git a/system/libraries/Trackback.php b/system/libraries/Trackback.php
new file mode 100755 (executable)
index 0000000..b0a7678
--- /dev/null
@@ -0,0 +1,548 @@
+<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+/**
+ * CodeIgniter
+ *
+ * An open source application development framework for PHP 5.1.6 or newer
+ *
+ * @package            CodeIgniter
+ * @author             ExpressionEngine Dev Team
+ * @copyright  Copyright (c) 2008 - 2011, EllisLab, Inc.
+ * @license            http://codeigniter.com/user_guide/license.html
+ * @link               http://codeigniter.com
+ * @since              Version 1.0
+ * @filesource
+ */
+
+// ------------------------------------------------------------------------
+
+/**
+ * Trackback Class
+ *
+ * Trackback Sending/Receiving Class
+ *
+ * @package            CodeIgniter
+ * @subpackage Libraries
+ * @category   Trackbacks
+ * @author             ExpressionEngine Dev Team
+ * @link               http://codeigniter.com/user_guide/libraries/trackback.html
+ */
+class CI_Trackback {
+
+       var $time_format        = 'local';
+       var $charset            = 'UTF-8';
+       var $data                       = array('url' => '', 'title' => '', 'excerpt' => '', 'blog_name' => '', 'charset' => '');
+       var $convert_ascii      = TRUE;
+       var $response           = '';
+       var $error_msg          = array();
+
+       /**
+        * Constructor
+        *
+        * @access      public
+        */
+       public function __construct()
+       {
+               log_message('debug', "Trackback Class Initialized");
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Send Trackback
+        *
+        * @access      public
+        * @param       array
+        * @return      bool
+        */
+       function send($tb_data)
+       {
+               if ( ! is_array($tb_data))
+               {
+                       $this->set_error('The send() method must be passed an array');
+                       return FALSE;
+               }
+
+               // Pre-process the Trackback Data
+               foreach (array('url', 'title', 'excerpt', 'blog_name', 'ping_url') as $item)
+               {
+                       if ( ! isset($tb_data[$item]))
+                       {
+                               $this->set_error('Required item missing: '.$item);
+                               return FALSE;
+                       }
+
+                       switch ($item)
+                       {
+                               case 'ping_url' : $$item = $this->extract_urls($tb_data[$item]);
+                                       break;
+                               case 'excerpt'  : $$item = $this->limit_characters($this->convert_xml(strip_tags(stripslashes($tb_data[$item]))));
+                                       break;
+                               case 'url'              : $$item = str_replace('&#45;', '-', $this->convert_xml(strip_tags(stripslashes($tb_data[$item]))));
+                                       break;
+                               default                 : $$item = $this->convert_xml(strip_tags(stripslashes($tb_data[$item])));
+                                       break;
+                       }
+
+                       // Convert High ASCII Characters
+                       if ($this->convert_ascii == TRUE)
+                       {
+                               if ($item == 'excerpt')
+                               {
+                                       $$item = $this->convert_ascii($$item);
+                               }
+                               elseif ($item == 'title')
+                               {
+                                       $$item = $this->convert_ascii($$item);
+                               }
+                               elseif ($item == 'blog_name')
+                               {
+                                       $$item = $this->convert_ascii($$item);
+                               }
+                       }
+               }
+
+               // Build the Trackback data string
+               $charset = ( ! isset($tb_data['charset'])) ? $this->charset : $tb_data['charset'];
+
+               $data = "url=".rawurlencode($url)."&title=".rawurlencode($title)."&blog_name=".rawurlencode($blog_name)."&excerpt=".rawurlencode($excerpt)."&charset=".rawurlencode($charset);
+
+               // Send Trackback(s)
+               $return = TRUE;
+               if (count($ping_url) > 0)
+               {
+                       foreach ($ping_url as $url)
+                       {
+                               if ($this->process($url, $data) == FALSE)
+                               {
+                                       $return = FALSE;
+                               }
+                       }
+               }
+
+               return $return;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Receive Trackback  Data
+        *
+        * This function simply validates the incoming TB data.
+        * It returns FALSE on failure and TRUE on success.
+        * If the data is valid it is set to the $this->data array
+        * so that it can be inserted into a database.
+        *
+        * @access      public
+        * @return      bool
+        */
+       function receive()
+       {
+               foreach (array('url', 'title', 'blog_name', 'excerpt') as $val)
+               {
+                       if ( ! isset($_POST[$val]) OR $_POST[$val] == '')
+                       {
+                               $this->set_error('The following required POST variable is missing: '.$val);
+                               return FALSE;
+                       }
+
+                       $this->data['charset'] = ( ! isset($_POST['charset'])) ? 'auto' : strtoupper(trim($_POST['charset']));
+
+                       if ($val != 'url' && function_exists('mb_convert_encoding'))
+                       {
+                               $_POST[$val] = mb_convert_encoding($_POST[$val], $this->charset, $this->data['charset']);
+                       }
+
+                       $_POST[$val] = ($val != 'url') ? $this->convert_xml(strip_tags($_POST[$val])) : strip_tags($_POST[$val]);
+
+                       if ($val == 'excerpt')
+                       {
+                               $_POST['excerpt'] = $this->limit_characters($_POST['excerpt']);
+                       }
+
+                       $this->data[$val] = $_POST[$val];
+               }
+
+               return TRUE;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Send Trackback Error Message
+        *
+        * Allows custom errors to be set.  By default it
+        * sends the "incomplete information" error, as that's
+        * the most common one.
+        *
+        * @access      public
+        * @param       string
+        * @return      void
+        */
+       function send_error($message = 'Incomplete Information')
+       {
+               echo "<?xml version=\"1.0\" encoding=\"utf-8\"?".">\n<response>\n<error>1</error>\n<message>".$message."</message>\n</response>";
+               exit;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Send Trackback Success Message
+        *
+        * This should be called when a trackback has been
+        * successfully received and inserted.
+        *
+        * @access      public
+        * @return      void
+        */
+       function send_success()
+       {
+               echo "<?xml version=\"1.0\" encoding=\"utf-8\"?".">\n<response>\n<error>0</error>\n</response>";
+               exit;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Fetch a particular item
+        *
+        * @access      public
+        * @param       string
+        * @return      string
+        */
+       function data($item)
+       {
+               return ( ! isset($this->data[$item])) ? '' : $this->data[$item];
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Process Trackback
+        *
+        * Opens a socket connection and passes the data to
+        * the server.  Returns TRUE on success, FALSE on failure
+        *
+        * @access      public
+        * @param       string
+        * @param       string
+        * @return      bool
+        */
+       function process($url, $data)
+       {
+               $target = parse_url($url);
+
+               // Open the socket
+               if ( ! $fp = @fsockopen($target['host'], 80))
+               {
+                       $this->set_error('Invalid Connection: '.$url);
+                       return FALSE;
+               }
+
+               // Build the path
+               $ppath = ( ! isset($target['path'])) ? $url : $target['path'];
+
+               $path = (isset($target['query']) && $target['query'] != "") ? $ppath.'?'.$target['query'] : $ppath;
+
+               // Add the Trackback ID to the data string
+               if ($id = $this->get_id($url))
+               {
+                       $data = "tb_id=".$id."&".$data;
+               }
+
+               // Transfer the data
+               fputs ($fp, "POST " . $path . " HTTP/1.0\r\n" );
+               fputs ($fp, "Host: " . $target['host'] . "\r\n" );
+               fputs ($fp, "Content-type: application/x-www-form-urlencoded\r\n" );
+               fputs ($fp, "Content-length: " . strlen($data) . "\r\n" );
+               fputs ($fp, "Connection: close\r\n\r\n" );
+               fputs ($fp, $data);
+
+               // Was it successful?
+               $this->response = "";
+
+               while ( ! feof($fp))
+               {
+                       $this->response .= fgets($fp, 128);
+               }
+               @fclose($fp);
+
+
+               if (stristr($this->response, '<error>0</error>') === FALSE)
+               {
+                       $message = 'An unknown error was encountered';
+
+                       if (preg_match("/<message>(.*?)<\/message>/is", $this->response, $match))
+                       {
+                               $message = trim($match['1']);
+                       }
+
+                       $this->set_error($message);
+                       return FALSE;
+               }
+
+               return TRUE;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Extract Trackback URLs
+        *
+        * This function lets multiple trackbacks be sent.
+        * It takes a string of URLs (separated by comma or
+        * space) and puts each URL into an array
+        *
+        * @access      public
+        * @param       string
+        * @return      string
+        */
+       function extract_urls($urls)
+       {
+               // Remove the pesky white space and replace with a comma.
+               $urls = preg_replace("/\s*(\S+)\s*/", "\\1,", $urls);
+
+               // If they use commas get rid of the doubles.
+               $urls = str_replace(",,", ",", $urls);
+
+               // Remove any comma that might be at the end
+               if (substr($urls, -1) == ",")
+               {
+                       $urls = substr($urls, 0, -1);
+               }
+
+               // Break into an array via commas
+               $urls = preg_split('/[,]/', $urls);
+
+               // Removes duplicates
+               $urls = array_unique($urls);
+
+               array_walk($urls, array($this, 'validate_url'));
+
+               return $urls;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Validate URL
+        *
+        * Simply adds "http://" if missing
+        *
+        * @access      public
+        * @param       string
+        * @return      string
+        */
+       function validate_url($url)
+       {
+               $url = trim($url);
+
+               if (substr($url, 0, 4) != "http")
+               {
+                       $url = "http://".$url;
+               }
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Find the Trackback URL's ID
+        *
+        * @access      public
+        * @param       string
+        * @return      string
+        */
+       function get_id($url)
+       {
+               $tb_id = "";
+
+               if (strpos($url, '?') !== FALSE)
+               {
+                       $tb_array = explode('/', $url);
+                       $tb_end   = $tb_array[count($tb_array)-1];
+
+                       if ( ! is_numeric($tb_end))
+                       {
+                               $tb_end  = $tb_array[count($tb_array)-2];
+                       }
+
+                       $tb_array = explode('=', $tb_end);
+                       $tb_id  = $tb_array[count($tb_array)-1];
+               }
+               else
+               {
+                       $url = rtrim($url, '/');
+
+                       $tb_array = explode('/', $url);
+                       $tb_id  = $tb_array[count($tb_array)-1];
+
+                       if ( ! is_numeric($tb_id))
+                       {
+                               $tb_id  = $tb_array[count($tb_array)-2];
+                       }
+               }
+
+               if ( ! preg_match ("/^([0-9]+)$/", $tb_id))
+               {
+                       return FALSE;
+               }
+               else
+               {
+                       return $tb_id;
+               }
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Convert Reserved XML characters to Entities
+        *
+        * @access      public
+        * @param       string
+        * @return      string
+        */
+       function convert_xml($str)
+       {
+               $temp = '__TEMP_AMPERSANDS__';
+
+               $str = preg_replace("/&#(\d+);/", "$temp\\1;", $str);
+               $str = preg_replace("/&(\w+);/",  "$temp\\1;", $str);
+
+               $str = str_replace(array("&","<",">","\"", "'", "-"),
+                                                       array("&amp;", "&lt;", "&gt;", "&quot;", "&#39;", "&#45;"),
+                                                       $str);
+
+               $str = preg_replace("/$temp(\d+);/","&#\\1;",$str);
+               $str = preg_replace("/$temp(\w+);/","&\\1;", $str);
+
+               return $str;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Character limiter
+        *
+        * Limits the string based on the character count. Will preserve complete words.
+        *
+        * @access      public
+        * @param       string
+        * @param       integer
+        * @param       string
+        * @return      string
+        */
+       function limit_characters($str, $n = 500, $end_char = '&#8230;')
+       {
+               if (strlen($str) < $n)
+               {
+                       return $str;
+               }
+
+               $str = preg_replace("/\s+/", ' ', str_replace(array("\r\n", "\r", "\n"), ' ', $str));
+
+               if (strlen($str) <= $n)
+               {
+                       return $str;
+               }
+
+               $out = "";
+               foreach (explode(' ', trim($str)) as $val)
+               {
+                       $out .= $val.' ';
+                       if (strlen($out) >= $n)
+                       {
+                               return trim($out).$end_char;
+                       }
+               }
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * High ASCII to Entities
+        *
+        * Converts Hight ascii text and MS Word special chars
+        * to character entities
+        *
+        * @access      public
+        * @param       string
+        * @return      string
+        */
+       function convert_ascii($str)
+       {
+               $count  = 1;
+               $out    = '';
+               $temp   = array();
+
+               for ($i = 0, $s = strlen($str); $i < $s; $i++)
+               {
+                       $ordinal = ord($str[$i]);
+
+                       if ($ordinal < 128)
+                       {
+                               $out .= $str[$i];
+                       }
+                       else
+                       {
+                               if (count($temp) == 0)
+                               {
+                                       $count = ($ordinal < 224) ? 2 : 3;
+                               }
+
+                               $temp[] = $ordinal;
+
+                               if (count($temp) == $count)
+                               {
+                                       $number = ($count == 3) ? (($temp['0'] % 16) * 4096) + (($temp['1'] % 64) * 64) + ($temp['2'] % 64) : (($temp['0'] % 32) * 64) + ($temp['1'] % 64);
+
+                                       $out .= '&#'.$number.';';
+                                       $count = 1;
+                                       $temp = array();
+                               }
+                       }
+               }
+
+               return $out;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Set error message
+        *
+        * @access      public
+        * @param       string
+        * @return      void
+        */
+       function set_error($msg)
+       {
+               log_message('error', $msg);
+               $this->error_msg[] = $msg;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Show error messages
+        *
+        * @access      public
+        * @param       string
+        * @param       string
+        * @return      string
+        */
+       function display_errors($open = '<p>', $close = '</p>')
+       {
+               $str = '';
+               foreach ($this->error_msg as $val)
+               {
+                       $str .= $open.$val.$close;
+               }
+
+               return $str;
+       }
+
+}
+// END Trackback Class
+
+/* End of file Trackback.php */
+/* Location: ./system/libraries/Trackback.php */
\ No newline at end of file
diff --git a/system/libraries/Typography.php b/system/libraries/Typography.php
new file mode 100755 (executable)
index 0000000..734cec1
--- /dev/null
@@ -0,0 +1,410 @@
+<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+/**
+ * CodeIgniter
+ *
+ * An open source application development framework for PHP 5.1.6 or newer
+ *
+ * @package            CodeIgniter
+ * @author             ExpressionEngine Dev Team
+ * @copyright  Copyright (c) 2008 - 2011, EllisLab, Inc.
+ * @license            http://codeigniter.com/user_guide/license.html
+ * @link               http://codeigniter.com
+ * @since              Version 1.0
+ * @filesource
+ */
+
+// ------------------------------------------------------------------------
+
+/**
+ * Typography Class
+ *
+ *
+ * @access             private
+ * @category   Helpers
+ * @author             ExpressionEngine Dev Team
+ * @link               http://codeigniter.com/user_guide/helpers/
+ */
+class CI_Typography {
+
+       // Block level elements that should not be wrapped inside <p> tags
+       var $block_elements = 'address|blockquote|div|dl|fieldset|form|h\d|hr|noscript|object|ol|p|pre|script|table|ul';
+
+       // Elements that should not have <p> and <br /> tags within them.
+       var $skip_elements      = 'p|pre|ol|ul|dl|object|table|h\d';
+
+       // Tags we want the parser to completely ignore when splitting the string.
+       var $inline_elements = 'a|abbr|acronym|b|bdo|big|br|button|cite|code|del|dfn|em|i|img|ins|input|label|map|kbd|q|samp|select|small|span|strong|sub|sup|textarea|tt|var';
+
+       // array of block level elements that require inner content to be within another block level element
+       var $inner_block_required = array('blockquote');
+
+       // the last block element parsed
+       var $last_block_element = '';
+
+       // whether or not to protect quotes within { curly braces }
+       var $protect_braced_quotes = FALSE;
+
+       /**
+        * Auto Typography
+        *
+        * This function converts text, making it typographically correct:
+        *      - Converts double spaces into paragraphs.
+        *      - Converts single line breaks into <br /> tags
+        *      - Converts single and double quotes into correctly facing curly quote entities.
+        *      - Converts three dots into ellipsis.
+        *      - Converts double dashes into em-dashes.
+        *  - Converts two spaces into entities
+        *
+        * @access      public
+        * @param       string
+        * @param       bool    whether to reduce more then two consecutive newlines to two
+        * @return      string
+        */
+       function auto_typography($str, $reduce_linebreaks = FALSE)
+       {
+               if ($str == '')
+               {
+                       return '';
+               }
+
+               // Standardize Newlines to make matching easier
+               if (strpos($str, "\r") !== FALSE)
+               {
+                       $str = str_replace(array("\r\n", "\r"), "\n", $str);
+               }
+
+               // Reduce line breaks.  If there are more than two consecutive linebreaks
+               // we'll compress them down to a maximum of two since there's no benefit to more.
+               if ($reduce_linebreaks === TRUE)
+               {
+                       $str = preg_replace("/\n\n+/", "\n\n", $str);
+               }
+
+               // HTML comment tags don't conform to patterns of normal tags, so pull them out separately, only if needed
+               $html_comments = array();
+               if (strpos($str, '<!--') !== FALSE)
+               {
+                       if (preg_match_all("#(<!\-\-.*?\-\->)#s", $str, $matches))
+                       {
+                               for ($i = 0, $total = count($matches[0]); $i < $total; $i++)
+                               {
+                                       $html_comments[] = $matches[0][$i];
+                                       $str = str_replace($matches[0][$i], '{@HC'.$i.'}', $str);
+                               }
+                       }
+               }
+
+               // match and yank <pre> tags if they exist.  It's cheaper to do this separately since most content will
+               // not contain <pre> tags, and it keeps the PCRE patterns below simpler and faster
+               if (strpos($str, '<pre') !== FALSE)
+               {
+                       $str = preg_replace_callback("#<pre.*?>.*?</pre>#si", array($this, '_protect_characters'), $str);
+               }
+
+               // Convert quotes within tags to temporary markers.
+               $str = preg_replace_callback("#<.+?>#si", array($this, '_protect_characters'), $str);
+
+               // Do the same with braces if necessary
+               if ($this->protect_braced_quotes === TRUE)
+               {
+                       $str = preg_replace_callback("#\{.+?\}#si", array($this, '_protect_characters'), $str);
+               }
+
+               // Convert "ignore" tags to temporary marker.  The parser splits out the string at every tag
+               // it encounters.  Certain inline tags, like image tags, links, span tags, etc. will be
+               // adversely affected if they are split out so we'll convert the opening bracket < temporarily to: {@TAG}
+               $str = preg_replace("#<(/*)(".$this->inline_elements.")([ >])#i", "{@TAG}\\1\\2\\3", $str);
+
+               // Split the string at every tag.  This expression creates an array with this prototype:
+               //
+               //      [array]
+               //      {
+               //              [0] = <opening tag>
+               //              [1] = Content...
+               //              [2] = <closing tag>
+               //              Etc...
+               //      }
+               $chunks = preg_split('/(<(?:[^<>]+(?:"[^"]*"|\'[^\']*\')?)+>)/', $str, -1, PREG_SPLIT_DELIM_CAPTURE|PREG_SPLIT_NO_EMPTY);
+
+               // Build our finalized string.  We cycle through the array, skipping tags, and processing the contained text
+               $str = '';
+               $process = TRUE;
+               $paragraph = FALSE;
+               $current_chunk = 0;
+               $total_chunks = count($chunks);
+
+               foreach ($chunks as $chunk)
+               {
+                       $current_chunk++;
+
+                       // Are we dealing with a tag? If so, we'll skip the processing for this cycle.
+                       // Well also set the "process" flag which allows us to skip <pre> tags and a few other things.
+                       if (preg_match("#<(/*)(".$this->block_elements.").*?>#", $chunk, $match))
+                       {
+                               if (preg_match("#".$this->skip_elements."#", $match[2]))
+                               {
+                                       $process =  ($match[1] == '/') ? TRUE : FALSE;
+                               }
+
+                               if ($match[1] == '')
+                               {
+                                       $this->last_block_element = $match[2];
+                               }
+
+                               $str .= $chunk;
+                               continue;
+                       }
+
+                       if ($process == FALSE)
+                       {
+                               $str .= $chunk;
+                               continue;
+                       }
+
+                       //  Force a newline to make sure end tags get processed by _format_newlines()
+                       if ($current_chunk == $total_chunks)
+                       {
+                               $chunk .= "\n";
+                       }
+
+                       //  Convert Newlines into <p> and <br /> tags
+                       $str .= $this->_format_newlines($chunk);
+               }
+
+               // No opening block level tag?  Add it if needed.
+               if ( ! preg_match("/^\s*<(?:".$this->block_elements.")/i", $str))
+               {
+                       $str = preg_replace("/^(.*?)<(".$this->block_elements.")/i", '<p>$1</p><$2', $str);
+               }
+
+               // Convert quotes, elipsis, em-dashes, non-breaking spaces, and ampersands
+               $str = $this->format_characters($str);
+
+               // restore HTML comments
+               for ($i = 0, $total = count($html_comments); $i < $total; $i++)
+               {
+                       // remove surrounding paragraph tags, but only if there's an opening paragraph tag
+                       // otherwise HTML comments at the ends of paragraphs will have the closing tag removed
+                       // if '<p>{@HC1}' then replace <p>{@HC1}</p> with the comment, else replace only {@HC1} with the comment
+                       $str = preg_replace('#(?(?=<p>\{@HC'.$i.'\})<p>\{@HC'.$i.'\}(\s*</p>)|\{@HC'.$i.'\})#s', $html_comments[$i], $str);
+               }
+
+               // Final clean up
+               $table = array(
+
+                                               // If the user submitted their own paragraph tags within the text
+                                               // we will retain them instead of using our tags.
+                                               '/(<p[^>*?]>)<p>/'      => '$1', // <?php BBEdit syntax coloring bug fix
+
+                                               // Reduce multiple instances of opening/closing paragraph tags to a single one
+                                               '#(</p>)+#'                     => '</p>',
+                                               '/(<p>\W*<p>)+/'        => '<p>',
+
+                                               // Clean up stray paragraph tags that appear before block level elements
+                                               '#<p></p><('.$this->block_elements.')#' => '<$1',
+
+                                               // Clean up stray non-breaking spaces preceeding block elements
+                                               '#(&nbsp;\s*)+<('.$this->block_elements.')#'    => '  <$2',
+
+                                               // Replace the temporary markers we added earlier
+                                               '/\{@TAG\}/'            => '<',
+                                               '/\{@DQ\}/'                     => '"',
+                                               '/\{@SQ\}/'                     => "'",
+                                               '/\{@DD\}/'                     => '--',
+                                               '/\{@NBS\}/'            => '  ',
+
+                                               // An unintended consequence of the _format_newlines function is that
+                                               // some of the newlines get truncated, resulting in <p> tags
+                                               // starting immediately after <block> tags on the same line.
+                                               // This forces a newline after such occurrences, which looks much nicer.
+                                               "/><p>\n/"                      => ">\n<p>",
+
+                                               // Similarly, there might be cases where a closing </block> will follow
+                                               // a closing </p> tag, so we'll correct it by adding a newline in between
+                                               "#</p></#"                      => "</p>\n</"
+                                               );
+
+               // Do we need to reduce empty lines?
+               if ($reduce_linebreaks === TRUE)
+               {
+                       $table['#<p>\n*</p>#'] = '';
+               }
+               else
+               {
+                       // If we have empty paragraph tags we add a non-breaking space
+                       // otherwise most browsers won't treat them as true paragraphs
+                       $table['#<p></p>#'] = '<p>&nbsp;</p>';
+               }
+
+               return preg_replace(array_keys($table), $table, $str);
+
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Format Characters
+        *
+        * This function mainly converts double and single quotes
+        * to curly entities, but it also converts em-dashes,
+        * double spaces, and ampersands
+        *
+        * @access      public
+        * @param       string
+        * @return      string
+        */
+       function format_characters($str)
+       {
+               static $table;
+
+               if ( ! isset($table))
+               {
+                       $table = array(
+                                                       // nested smart quotes, opening and closing
+                                                       // note that rules for grammar (English) allow only for two levels deep
+                                                       // and that single quotes are _supposed_ to always be on the outside
+                                                       // but we'll accommodate both
+                                                       // Note that in all cases, whitespace is the primary determining factor
+                                                       // on which direction to curl, with non-word characters like punctuation
+                                                       // being a secondary factor only after whitespace is addressed.
+                                                       '/\'"(\s|$)/'                                   => '&#8217;&#8221;$1',
+                                                       '/(^|\s|<p>)\'"/'                               => '$1&#8216;&#8220;',
+                                                       '/\'"(\W)/'                                             => '&#8217;&#8221;$1',
+                                                       '/(\W)\'"/'                                             => '$1&#8216;&#8220;',
+                                                       '/"\'(\s|$)/'                                   => '&#8221;&#8217;$1',
+                                                       '/(^|\s|<p>)"\'/'                               => '$1&#8220;&#8216;',
+                                                       '/"\'(\W)/'                                             => '&#8221;&#8217;$1',
+                                                       '/(\W)"\'/'                                             => '$1&#8220;&#8216;',
+
+                                                       // single quote smart quotes
+                                                       '/\'(\s|$)/'                                    => '&#8217;$1',
+                                                       '/(^|\s|<p>)\'/'                                => '$1&#8216;',
+                                                       '/\'(\W)/'                                              => '&#8217;$1',
+                                                       '/(\W)\'/'                                              => '$1&#8216;',
+
+                                                       // double quote smart quotes
+                                                       '/"(\s|$)/'                                             => '&#8221;$1',
+                                                       '/(^|\s|<p>)"/'                                 => '$1&#8220;',
+                                                       '/"(\W)/'                                               => '&#8221;$1',
+                                                       '/(\W)"/'                                               => '$1&#8220;',
+
+                                                       // apostrophes
+                                                       "/(\w)'(\w)/"                                   => '$1&#8217;$2',
+
+                                                       // Em dash and ellipses dots
+                                                       '/\s?\-\-\s?/'                                  => '&#8212;',
+                                                       '/(\w)\.{3}/'                                   => '$1&#8230;',
+
+                                                       // double space after sentences
+                                                       '/(\W)  /'                                              => '$1&nbsp; ',
+
+                                                       // ampersands, if not a character entity
+                                                       '/&(?!#?[a-zA-Z0-9]{2,};)/'             => '&amp;'
+                                               );
+               }
+
+               return preg_replace(array_keys($table), $table, $str);
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Format Newlines
+        *
+        * Converts newline characters into either <p> tags or <br />
+        *
+        * @access      public
+        * @param       string
+        * @return      string
+        */
+       function _format_newlines($str)
+       {
+               if ($str == '')
+               {
+                       return $str;
+               }
+
+               if (strpos($str, "\n") === FALSE  && ! in_array($this->last_block_element, $this->inner_block_required))
+               {
+                       return $str;
+               }
+
+               // Convert two consecutive newlines to paragraphs
+               $str = str_replace("\n\n", "</p>\n\n<p>", $str);
+
+               // Convert single spaces to <br /> tags
+               $str = preg_replace("/([^\n])(\n)([^\n])/", "\\1<br />\\2\\3", $str);
+
+               // Wrap the whole enchilada in enclosing paragraphs
+               if ($str != "\n")
+               {
+                       // We trim off the right-side new line so that the closing </p> tag
+                       // will be positioned immediately following the string, matching
+                       // the behavior of the opening <p> tag
+                       $str =  '<p>'.rtrim($str).'</p>';
+               }
+
+               // Remove empty paragraphs if they are on the first line, as this
+               // is a potential unintended consequence of the previous code
+               $str = preg_replace("/<p><\/p>(.*)/", "\\1", $str, 1);
+
+               return $str;
+       }
+
+       // ------------------------------------------------------------------------
+
+       /**
+        * Protect Characters
+        *
+        * Protects special characters from being formatted later
+        * We don't want quotes converted within tags so we'll temporarily convert them to {@DQ} and {@SQ}
+        * and we don't want double dashes converted to emdash entities, so they are marked with {@DD}
+        * likewise double spaces are converted to {@NBS} to prevent entity conversion
+        *
+        * @access      public
+        * @param       array
+        * @return      string
+        */
+       function _protect_characters($match)
+       {
+               return str_replace(array("'",'"','--','  '), array('{@SQ}', '{@DQ}', '{@DD}', '{@NBS}'), $match[0]);
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Convert newlines to HTML line breaks except within PRE tags
+        *
+        * @access      public
+        * @param       string
+        * @return      string
+        */
+       function nl2br_except_pre($str)
+       {
+               $ex = explode("pre>",$str);
+               $ct = count($ex);
+
+               $newstr = "";
+               for ($i = 0; $i < $ct; $i++)
+               {
+                       if (($i % 2) == 0)
+                       {
+                               $newstr .= nl2br($ex[$i]);
+                       }
+                       else
+                       {
+                               $newstr .= $ex[$i];
+                       }
+
+                       if ($ct - 1 != $i)
+                               $newstr .= "pre>";
+               }
+
+               return $newstr;
+       }
+
+}
+// END Typography Class
+
+/* End of file Typography.php */
+/* Location: ./system/libraries/Typography.php */
\ No newline at end of file
diff --git a/system/libraries/Unit_test.php b/system/libraries/Unit_test.php
new file mode 100755 (executable)
index 0000000..5bd7e80
--- /dev/null
@@ -0,0 +1,383 @@
+<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+/**
+ * CodeIgniter
+ *
+ * An open source application development framework for PHP 5.1.6 or newer
+ *
+ * @package            CodeIgniter
+ * @author             ExpressionEngine Dev Team
+ * @copyright  Copyright (c) 2008 - 2011, EllisLab, Inc.
+ * @license            http://codeigniter.com/user_guide/license.html
+ * @link               http://codeigniter.com
+ * @since              Version 1.3.1
+ * @filesource
+ */
+
+// ------------------------------------------------------------------------
+
+/**
+ * Unit Testing Class
+ *
+ * Simple testing class
+ *
+ * @package            CodeIgniter
+ * @subpackage Libraries
+ * @category   UnitTesting
+ * @author             ExpressionEngine Dev Team
+ * @link               http://codeigniter.com/user_guide/libraries/uri.html
+ */
+class CI_Unit_test {
+
+       var $active                                     = TRUE;
+       var $results                            = array();
+       var $strict                                     = FALSE;
+       var $_template                          = NULL;
+       var $_template_rows                     = NULL;
+       var $_test_items_visible        = array();
+
+       public function __construct()
+       {
+               // These are the default items visible when a test is run.
+               $this->_test_items_visible = array (
+                                                       'test_name',
+                                                       'test_datatype',
+                                                       'res_datatype',
+                                                       'result',
+                                                       'file',
+                                                       'line',
+                                                       'notes'
+                                               );
+
+               log_message('debug', "Unit Testing Class Initialized");
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Run the tests
+        *
+        * Runs the supplied tests
+        *
+        * @access      public
+        * @param       array
+        * @return      void
+        */
+       function set_test_items($items = array())
+       {
+               if ( ! empty($items) AND is_array($items))
+               {
+                       $this->_test_items_visible = $items;
+               }
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Run the tests
+        *
+        * Runs the supplied tests
+        *
+        * @access      public
+        * @param       mixed
+        * @param       mixed
+        * @param       string
+        * @return      string
+        */
+       function run($test, $expected = TRUE, $test_name = 'undefined', $notes = '')
+       {
+               if ($this->active == FALSE)
+               {
+                       return FALSE;
+               }
+
+               if (in_array($expected, array('is_object', 'is_string', 'is_bool', 'is_true', 'is_false', 'is_int', 'is_numeric', 'is_float', 'is_double', 'is_array', 'is_null'), TRUE))
+               {
+                       $expected = str_replace('is_float', 'is_double', $expected);
+                       $result = ($expected($test)) ? TRUE : FALSE;
+                       $extype = str_replace(array('true', 'false'), 'bool', str_replace('is_', '', $expected));
+               }
+               else
+               {
+                       if ($this->strict == TRUE)
+                               $result = ($test === $expected) ? TRUE : FALSE;
+                       else
+                               $result = ($test == $expected) ? TRUE : FALSE;
+
+                       $extype = gettype($expected);
+               }
+
+               $back = $this->_backtrace();
+
+               $report[] = array (
+                                                       'test_name'                     => $test_name,
+                                                       'test_datatype'         => gettype($test),
+                                                       'res_datatype'          => $extype,
+                                                       'result'                        => ($result === TRUE) ? 'passed' : 'failed',
+                                                       'file'                          => $back['file'],
+                                                       'line'                          => $back['line'],
+                                                       'notes'                         => $notes
+                                               );
+
+               $this->results[] = $report;
+
+               return($this->report($this->result($report)));
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Generate a report
+        *
+        * Displays a table with the test data
+        *
+        * @access      public
+        * @return      string
+        */
+       function report($result = array())
+       {
+               if (count($result) == 0)
+               {
+                       $result = $this->result();
+               }
+
+               $CI =& get_instance();
+               $CI->load->language('unit_test');
+
+               $this->_parse_template();
+
+               $r = '';
+               foreach ($result as $res)
+               {
+                       $table = '';
+
+                       foreach ($res as $key => $val)
+                       {
+                               if ($key == $CI->lang->line('ut_result'))
+                               {
+                                       if ($val == $CI->lang->line('ut_passed'))
+                                       {
+                                               $val = '<span style="color: #0C0;">'.$val.'</span>';
+                                       }
+                                       elseif ($val == $CI->lang->line('ut_failed'))
+                                       {
+                                               $val = '<span style="color: #C00;">'.$val.'</span>';
+                                       }
+                               }
+
+                               $temp = $this->_template_rows;
+                               $temp = str_replace('{item}', $key, $temp);
+                               $temp = str_replace('{result}', $val, $temp);
+                               $table .= $temp;
+                       }
+
+                       $r .= str_replace('{rows}', $table, $this->_template);
+               }
+
+               return $r;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Use strict comparison
+        *
+        * Causes the evaluation to use === rather than ==
+        *
+        * @access      public
+        * @param       bool
+        * @return      null
+        */
+       function use_strict($state = TRUE)
+       {
+               $this->strict = ($state == FALSE) ? FALSE : TRUE;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Make Unit testing active
+        *
+        * Enables/disables unit testing
+        *
+        * @access      public
+        * @param       bool
+        * @return      null
+        */
+       function active($state = TRUE)
+       {
+               $this->active = ($state == FALSE) ? FALSE : TRUE;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Result Array
+        *
+        * Returns the raw result data
+        *
+        * @access      public
+        * @return      array
+        */
+       function result($results = array())
+       {
+               $CI =& get_instance();
+               $CI->load->language('unit_test');
+
+               if (count($results) == 0)
+               {
+                       $results = $this->results;
+               }
+
+               $retval = array();
+               foreach ($results as $result)
+               {
+                       $temp = array();
+                       foreach ($result as $key => $val)
+                       {
+                               if ( ! in_array($key, $this->_test_items_visible))
+                               {
+                                       continue;
+                               }
+
+                               if (is_array($val))
+                               {
+                                       foreach ($val as $k => $v)
+                                       {
+                                               if (FALSE !== ($line = $CI->lang->line(strtolower('ut_'.$v))))
+                                               {
+                                                       $v = $line;
+                                               }
+                                               $temp[$CI->lang->line('ut_'.$k)] = $v;
+                                       }
+                               }
+                               else
+                               {
+                                       if (FALSE !== ($line = $CI->lang->line(strtolower('ut_'.$val))))
+                                       {
+                                               $val = $line;
+                                       }
+                                       $temp[$CI->lang->line('ut_'.$key)] = $val;
+                               }
+                       }
+
+                       $retval[] = $temp;
+               }
+
+               return $retval;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Set the template
+        *
+        * This lets us set the template to be used to display results
+        *
+        * @access      public
+        * @param       string
+        * @return      void
+        */
+       function set_template($template)
+       {
+               $this->_template = $template;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Generate a backtrace
+        *
+        * This lets us show file names and line numbers
+        *
+        * @access      private
+        * @return      array
+        */
+       function _backtrace()
+       {
+               if (function_exists('debug_backtrace'))
+               {
+                       $back = debug_backtrace();
+
+                       $file = ( ! isset($back['1']['file'])) ? '' : $back['1']['file'];
+                       $line = ( ! isset($back['1']['line'])) ? '' : $back['1']['line'];
+
+                       return array('file' => $file, 'line' => $line);
+               }
+               return array('file' => 'Unknown', 'line' => 'Unknown');
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Get Default Template
+        *
+        * @access      private
+        * @return      string
+        */
+       function _default_template()
+       {
+               $this->_template = "\n".'<table style="width:100%; font-size:small; margin:10px 0; border-collapse:collapse; border:1px solid #CCC;">';
+               $this->_template .= '{rows}';
+               $this->_template .= "\n".'</table>';
+
+               $this->_template_rows = "\n\t".'<tr>';
+               $this->_template_rows .= "\n\t\t".'<th style="text-align: left; border-bottom:1px solid #CCC;">{item}</th>';
+               $this->_template_rows .= "\n\t\t".'<td style="border-bottom:1px solid #CCC;">{result}</td>';
+               $this->_template_rows .= "\n\t".'</tr>';
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Parse Template
+        *
+        * Harvests the data within the template {pseudo-variables}
+        *
+        * @access      private
+        * @return      void
+        */
+       function _parse_template()
+       {
+               if ( ! is_null($this->_template_rows))
+               {
+                       return;
+               }
+
+               if (is_null($this->_template))
+               {
+                       $this->_default_template();
+                       return;
+               }
+
+               if ( ! preg_match("/\{rows\}(.*?)\{\/rows\}/si", $this->_template, $match))
+               {
+                       $this->_default_template();
+                       return;
+               }
+
+               $this->_template_rows = $match['1'];
+               $this->_template = str_replace($match['0'], '{rows}', $this->_template);
+       }
+
+}
+// END Unit_test Class
+
+/**
+ * Helper functions to test boolean true/false
+ *
+ *
+ * @access     private
+ * @return     bool
+ */
+function is_true($test)
+{
+       return (is_bool($test) AND $test === TRUE) ? TRUE : FALSE;
+}
+function is_false($test)
+{
+       return (is_bool($test) AND $test === FALSE) ? TRUE : FALSE;
+}
+
+
+/* End of file Unit_test.php */
+/* Location: ./system/libraries/Unit_test.php */
\ No newline at end of file
diff --git a/system/libraries/Upload.php b/system/libraries/Upload.php
new file mode 100755 (executable)
index 0000000..e80049f
--- /dev/null
@@ -0,0 +1,1013 @@
+<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+/**
+ * CodeIgniter
+ *
+ * An open source application development framework for PHP 5.1.6 or newer
+ *
+ * @package            CodeIgniter
+ * @author             ExpressionEngine Dev Team
+ * @copyright  Copyright (c) 2008 - 2011, EllisLab, Inc.
+ * @license            http://codeigniter.com/user_guide/license.html
+ * @link               http://codeigniter.com
+ * @since              Version 1.0
+ * @filesource
+ */
+
+// ------------------------------------------------------------------------
+
+/**
+ * File Uploading Class
+ *
+ * @package            CodeIgniter
+ * @subpackage Libraries
+ * @category   Uploads
+ * @author             ExpressionEngine Dev Team
+ * @link               http://codeigniter.com/user_guide/libraries/file_uploading.html
+ */
+class CI_Upload {
+
+       public $max_size                                = 0;
+       public $max_width                               = 0;
+       public $max_height                              = 0;
+       public $max_filename                    = 0;
+       public $allowed_types                   = "";
+       public $file_temp                               = "";
+       public $file_name                               = "";
+       public $orig_name                               = "";
+       public $file_type                               = "";
+       public $file_size                               = "";
+       public $file_ext                                = "";
+       public $upload_path                             = "";
+       public $overwrite                               = FALSE;
+       public $encrypt_name                    = FALSE;
+       public $is_image                                = FALSE;
+       public $image_width                             = '';
+       public $image_height                    = '';
+       public $image_type                              = '';
+       public $image_size_str                  = '';
+       public $error_msg                               = array();
+       public $mimes                                   = array();
+       public $remove_spaces                   = TRUE;
+       public $xss_clean                               = FALSE;
+       public $temp_prefix                             = "temp_file_";
+       public $client_name                             = '';
+
+       protected $_file_name_override  = '';
+
+       /**
+        * Constructor
+        *
+        * @access      public
+        */
+       public function __construct($props = array())
+       {
+               if (count($props) > 0)
+               {
+                       $this->initialize($props);
+               }
+
+               log_message('debug', "Upload Class Initialized");
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Initialize preferences
+        *
+        * @param       array
+        * @return      void
+        */
+       public function initialize($config = array())
+       {
+               $defaults = array(
+                                                       'max_size'                      => 0,
+                                                       'max_width'                     => 0,
+                                                       'max_height'            => 0,
+                                                       'max_filename'          => 0,
+                                                       'allowed_types'         => "",
+                                                       'file_temp'                     => "",
+                                                       'file_name'                     => "",
+                                                       'orig_name'                     => "",
+                                                       'file_type'                     => "",
+                                                       'file_size'                     => "",
+                                                       'file_ext'                      => "",
+                                                       'upload_path'           => "",
+                                                       'overwrite'                     => FALSE,
+                                                       'encrypt_name'          => FALSE,
+                                                       'is_image'                      => FALSE,
+                                                       'image_width'           => '',
+                                                       'image_height'          => '',
+                                                       'image_type'            => '',
+                                                       'image_size_str'        => '',
+                                                       'error_msg'                     => array(),
+                                                       'mimes'                         => array(),
+                                                       'remove_spaces'         => TRUE,
+                                                       'xss_clean'                     => FALSE,
+                                                       'temp_prefix'           => "temp_file_",
+                                                       'client_name'           => ''
+                                               );
+
+
+               foreach ($defaults as $key => $val)
+               {
+                       if (isset($config[$key]))
+                       {
+                               $method = 'set_'.$key;
+                               if (method_exists($this, $method))
+                               {
+                                       $this->$method($config[$key]);
+                               }
+                               else
+                               {
+                                       $this->$key = $config[$key];
+                               }
+                       }
+                       else
+                       {
+                               $this->$key = $val;
+                       }
+               }
+
+               // if a file_name was provided in the config, use it instead of the user input
+               // supplied file name for all uploads until initialized again
+               $this->_file_name_override = $this->file_name;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Perform the file upload
+        *
+        * @return      bool
+        */
+       public function do_upload($field = 'userfile')
+       {
+
+       // Is $_FILES[$field] set? If not, no reason to continue.
+               if ( ! isset($_FILES[$field]))
+               {
+                       $this->set_error('upload_no_file_selected');
+                       return FALSE;
+               }
+
+               // Is the upload path valid?
+               if ( ! $this->validate_upload_path())
+               {
+                       // errors will already be set by validate_upload_path() so just return FALSE
+                       return FALSE;
+               }
+
+               // Was the file able to be uploaded? If not, determine the reason why.
+               if ( ! is_uploaded_file($_FILES[$field]['tmp_name']))
+               {
+                       $error = ( ! isset($_FILES[$field]['error'])) ? 4 : $_FILES[$field]['error'];
+
+                       switch($error)
+                       {
+                               case 1: // UPLOAD_ERR_INI_SIZE
+                                       $this->set_error('upload_file_exceeds_limit');
+                                       break;
+                               case 2: // UPLOAD_ERR_FORM_SIZE
+                                       $this->set_error('upload_file_exceeds_form_limit');
+                                       break;
+                               case 3: // UPLOAD_ERR_PARTIAL
+                                       $this->set_error('upload_file_partial');
+                                       break;
+                               case 4: // UPLOAD_ERR_NO_FILE
+                                       $this->set_error('upload_no_file_selected');
+                                       break;
+                               case 6: // UPLOAD_ERR_NO_TMP_DIR
+                                       $this->set_error('upload_no_temp_directory');
+                                       break;
+                               case 7: // UPLOAD_ERR_CANT_WRITE
+                                       $this->set_error('upload_unable_to_write_file');
+                                       break;
+                               case 8: // UPLOAD_ERR_EXTENSION
+                                       $this->set_error('upload_stopped_by_extension');
+                                       break;
+                               default :   $this->set_error('upload_no_file_selected');
+                                       break;
+                       }
+
+                       return FALSE;
+               }
+
+
+               // Set the uploaded data as class variables
+               $this->file_temp = $_FILES[$field]['tmp_name'];
+               $this->file_size = $_FILES[$field]['size'];
+               $this->file_type = preg_replace("/^(.+?);.*$/", "\\1", $_FILES[$field]['type']);
+               $this->file_type = strtolower(trim(stripslashes($this->file_type), '"'));
+               $this->file_name = $this->_prep_filename($_FILES[$field]['name']);
+               $this->file_ext  = $this->get_extension($this->file_name);
+               $this->client_name = $this->file_name;
+
+               // Is the file type allowed to be uploaded?
+               if ( ! $this->is_allowed_filetype())
+               {
+                       $this->set_error('upload_invalid_filetype');
+                       return FALSE;
+               }
+
+               // if we're overriding, let's now make sure the new name and type is allowed
+               if ($this->_file_name_override != '')
+               {
+                       $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)
+                       {
+                               $this->file_name .= $this->file_ext;
+                       }
+
+                       // An extension was provided, lets have it!
+                       else
+                       {
+                               $this->file_ext  = $this->get_extension($this->_file_name_override);
+                       }
+
+                       if ( ! $this->is_allowed_filetype(TRUE))
+                       {
+                               $this->set_error('upload_invalid_filetype');
+                               return FALSE;
+                       }
+               }
+
+               // Convert the file size to kilobytes
+               if ($this->file_size > 0)
+               {
+                       $this->file_size = round($this->file_size/1024, 2);
+               }
+
+               // Is the file size within the allowed maximum?
+               if ( ! $this->is_allowed_filesize())
+               {
+                       $this->set_error('upload_invalid_filesize');
+                       return FALSE;
+               }
+
+               // Are the image dimensions within the allowed size?
+               // Note: This can fail if the server has an open_basdir restriction.
+               if ( ! $this->is_allowed_dimensions())
+               {
+                       $this->set_error('upload_invalid_dimensions');
+                       return FALSE;
+               }
+
+               // Sanitize the file name for security
+               $this->file_name = $this->clean_file_name($this->file_name);
+
+               // Truncate the file name if it's too long
+               if ($this->max_filename > 0)
+               {
+                       $this->file_name = $this->limit_filename_length($this->file_name, $this->max_filename);
+               }
+
+               // Remove white spaces in the name
+               if ($this->remove_spaces == TRUE)
+               {
+                       $this->file_name = preg_replace("/\s+/", "_", $this->file_name);
+               }
+
+               /*
+                * Validate the file name
+                * This function appends an number onto the end of
+                * the file if one with the same name already exists.
+                * If it returns false there was a problem.
+                */
+               $this->orig_name = $this->file_name;
+
+               if ($this->overwrite == FALSE)
+               {
+                       $this->file_name = $this->set_filename($this->upload_path, $this->file_name);
+
+                       if ($this->file_name === FALSE)
+                       {
+                               return FALSE;
+                       }
+               }
+
+               /*
+                * Run the file through the XSS hacking filter
+                * This helps prevent malicious code from being
+                * embedded within a file.  Scripts can easily
+                * be disguised as images or other file types.
+                */
+               if ($this->xss_clean)
+               {
+                       if ($this->do_xss_clean() === FALSE)
+                       {
+                               $this->set_error('upload_unable_to_write_file');
+                               return FALSE;
+                       }
+               }
+
+               /*
+                * Move the file to the final destination
+                * To deal with different server configurations
+                * we'll attempt to use copy() first.  If that fails
+                * we'll use move_uploaded_file().  One of the two should
+                * reliably work in most environments
+                */
+               if ( ! @copy($this->file_temp, $this->upload_path.$this->file_name))
+               {
+                       if ( ! @move_uploaded_file($this->file_temp, $this->upload_path.$this->file_name))
+                       {
+                               $this->set_error('upload_destination_error');
+                               return FALSE;
+                       }
+               }
+
+               /*
+                * Set the finalized image dimensions
+                * This sets the image width/height (assuming the
+                * file was an image).  We use this information
+                * in the "data" function.
+                */
+               $this->set_image_properties($this->upload_path.$this->file_name);
+
+               return TRUE;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Finalized Data Array
+        *
+        * Returns an associative array containing all of the information
+        * related to the upload, allowing the developer easy access in one array.
+        *
+        * @return      array
+        */
+       public function data()
+       {
+               return array (
+                                               'file_name'                     => $this->file_name,
+                                               'file_type'                     => $this->file_type,
+                                               'file_path'                     => $this->upload_path,
+                                               'full_path'                     => $this->upload_path.$this->file_name,
+                                               'raw_name'                      => str_replace($this->file_ext, '', $this->file_name),
+                                               'orig_name'                     => $this->orig_name,
+                                               'client_name'           => $this->client_name,
+                                               'file_ext'                      => $this->file_ext,
+                                               'file_size'                     => $this->file_size,
+                                               'is_image'                      => $this->is_image(),
+                                               'image_width'           => $this->image_width,
+                                               'image_height'          => $this->image_height,
+                                               'image_type'            => $this->image_type,
+                                               'image_size_str'        => $this->image_size_str,
+                                       );
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Set Upload Path
+        *
+        * @param       string
+        * @return      void
+        */
+       public function set_upload_path($path)
+       {
+               // Make sure it has a trailing slash
+               $this->upload_path = rtrim($path, '/').'/';
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Set the file name
+        *
+        * This function takes a filename/path as input and looks for the
+        * existence of a file with the same name. If found, it will append a
+        * number to the end of the filename to avoid overwriting a pre-existing file.
+        *
+        * @param       string
+        * @param       string
+        * @return      string
+        */
+       public function set_filename($path, $filename)
+       {
+               if ($this->encrypt_name == TRUE)
+               {
+                       mt_srand();
+                       $filename = md5(uniqid(mt_rand())).$this->file_ext;
+               }
+
+               if ( ! file_exists($path.$filename))
+               {
+                       return $filename;
+               }
+
+               $filename = str_replace($this->file_ext, '', $filename);
+
+               $new_filename = '';
+               for ($i = 1; $i < 100; $i++)
+               {
+                       if ( ! file_exists($path.$filename.$i.$this->file_ext))
+                       {
+                               $new_filename = $filename.$i.$this->file_ext;
+                               break;
+                       }
+               }
+
+               if ($new_filename == '')
+               {
+                       $this->set_error('upload_bad_filename');
+                       return FALSE;
+               }
+               else
+               {
+                       return $new_filename;
+               }
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Set Maximum File Size
+        *
+        * @param       integer
+        * @return      void
+        */
+       public function set_max_filesize($n)
+       {
+               $this->max_size = ((int) $n < 0) ? 0: (int) $n;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Set Maximum File Name Length
+        *
+        * @param       integer
+        * @return      void
+        */
+       public function set_max_filename($n)
+       {
+               $this->max_filename = ((int) $n < 0) ? 0: (int) $n;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Set Maximum Image Width
+        *
+        * @param       integer
+        * @return      void
+        */
+       public function set_max_width($n)
+       {
+               $this->max_width = ((int) $n < 0) ? 0: (int) $n;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Set Maximum Image Height
+        *
+        * @param       integer
+        * @return      void
+        */
+       public function set_max_height($n)
+       {
+               $this->max_height = ((int) $n < 0) ? 0: (int) $n;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Set Allowed File Types
+        *
+        * @param       string
+        * @return      void
+        */
+       public function set_allowed_types($types)
+       {
+               if ( ! is_array($types) && $types == '*')
+               {
+                       $this->allowed_types = '*';
+                       return;
+               }
+               $this->allowed_types = explode('|', $types);
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Set Image Properties
+        *
+        * Uses GD to determine the width/height/type of image
+        *
+        * @param       string
+        * @return      void
+        */
+       public function set_image_properties($path = '')
+       {
+               if ( ! $this->is_image())
+               {
+                       return;
+               }
+
+               if (function_exists('getimagesize'))
+               {
+                       if (FALSE !== ($D = @getimagesize($path)))
+                       {
+                               $types = array(1 => 'gif', 2 => 'jpeg', 3 => 'png');
+
+                               $this->image_width              = $D['0'];
+                               $this->image_height             = $D['1'];
+                               $this->image_type               = ( ! isset($types[$D['2']])) ? 'unknown' : $types[$D['2']];
+                               $this->image_size_str   = $D['3'];  // string containing height and width
+                       }
+               }
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Set XSS Clean
+        *
+        * Enables the XSS flag so that the file that was uploaded
+        * will be run through the XSS filter.
+        *
+        * @param       bool
+        * @return      void
+        */
+       public function set_xss_clean($flag = FALSE)
+       {
+               $this->xss_clean = ($flag == TRUE) ? TRUE : FALSE;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Validate the image
+        *
+        * @return      bool
+        */
+       public function is_image()
+       {
+               // IE will sometimes return odd mime-types during upload, so here we just standardize all
+               // jpegs or pngs to the same file type.
+
+               $png_mimes  = array('image/x-png');
+               $jpeg_mimes = array('image/jpg', 'image/jpe', 'image/jpeg', 'image/pjpeg');
+
+               if (in_array($this->file_type, $png_mimes))
+               {
+                       $this->file_type = 'image/png';
+               }
+
+               if (in_array($this->file_type, $jpeg_mimes))
+               {
+                       $this->file_type = 'image/jpeg';
+               }
+
+               $img_mimes = array(
+                                                       'image/gif',
+                                                       'image/jpeg',
+                                                       'image/png',
+                                               );
+
+               return (in_array($this->file_type, $img_mimes, TRUE)) ? TRUE : FALSE;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Verify that the filetype is allowed
+        *
+        * @return      bool
+        */
+       public function is_allowed_filetype($ignore_mime = FALSE)
+       {
+               if ($this->allowed_types == '*')
+               {
+                       return TRUE;
+               }
+
+               if (count($this->allowed_types) == 0 OR ! is_array($this->allowed_types))
+               {
+                       $this->set_error('upload_no_file_types');
+                       return FALSE;
+               }
+
+               $ext = strtolower(ltrim($this->file_ext, '.'));
+
+               if ( ! in_array($ext, $this->allowed_types))
+               {
+                       return FALSE;
+               }
+
+               // Images get some additional checks
+               $image_types = array('gif', 'jpg', 'jpeg', 'png', 'jpe');
+
+               if (in_array($ext, $image_types))
+               {
+                       if (getimagesize($this->file_temp) === FALSE)
+                       {
+                               return FALSE;
+                       }
+               }
+
+               if ($ignore_mime === TRUE)
+               {
+                       return TRUE;
+               }
+
+               $mime = $this->mimes_types($ext);
+
+               if (is_array($mime))
+               {
+                       if (in_array($this->file_type, $mime, TRUE))
+                       {
+                               return TRUE;
+                       }
+               }
+               elseif ($mime == $this->file_type)
+               {
+                               return TRUE;
+               }
+
+               return FALSE;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Verify that the file is within the allowed size
+        *
+        * @return      bool
+        */
+       public function is_allowed_filesize()
+       {
+               if ($this->max_size != 0  AND  $this->file_size > $this->max_size)
+               {
+                       return FALSE;
+               }
+               else
+               {
+                       return TRUE;
+               }
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Verify that the image is within the allowed width/height
+        *
+        * @return      bool
+        */
+       public function is_allowed_dimensions()
+       {
+               if ( ! $this->is_image())
+               {
+                       return TRUE;
+               }
+
+               if (function_exists('getimagesize'))
+               {
+                       $D = @getimagesize($this->file_temp);
+
+                       if ($this->max_width > 0 AND $D['0'] > $this->max_width)
+                       {
+                               return FALSE;
+                       }
+
+                       if ($this->max_height > 0 AND $D['1'] > $this->max_height)
+                       {
+                               return FALSE;
+                       }
+
+                       return TRUE;
+               }
+
+               return TRUE;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Validate Upload Path
+        *
+        * Verifies that it is a valid upload path with proper permissions.
+        *
+        *
+        * @return      bool
+        */
+       public function validate_upload_path()
+       {
+               if ($this->upload_path == '')
+               {
+                       $this->set_error('upload_no_filepath');
+                       return FALSE;
+               }
+
+               if (function_exists('realpath') AND @realpath($this->upload_path) !== FALSE)
+               {
+                       $this->upload_path = str_replace("\\", "/", realpath($this->upload_path));
+               }
+
+               if ( ! @is_dir($this->upload_path))
+               {
+                       $this->set_error('upload_no_filepath');
+                       return FALSE;
+               }
+
+               if ( ! is_really_writable($this->upload_path))
+               {
+                       $this->set_error('upload_not_writable');
+                       return FALSE;
+               }
+
+               $this->upload_path = preg_replace("/(.+?)\/*$/", "\\1/",  $this->upload_path);
+               return TRUE;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Extract the file extension
+        *
+        * @param       string
+        * @return      string
+        */
+       public function get_extension($filename)
+       {
+               $x = explode('.', $filename);
+               return '.'.end($x);
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Clean the file name for security
+        *
+        * @param       string
+        * @return      string
+        */
+       public function clean_file_name($filename)
+       {
+               $bad = array(
+                                               "<!--",
+                                               "-->",
+                                               "'",
+                                               "<",
+                                               ">",
+                                               '"',
+                                               '&',
+                                               '$',
+                                               '=',
+                                               ';',
+                                               '?',
+                                               '/',
+                                               "%20",
+                                               "%22",
+                                               "%3c",          // <
+                                               "%253c",        // <
+                                               "%3e",          // >
+                                               "%0e",          // >
+                                               "%28",          // (
+                                               "%29",          // )
+                                               "%2528",        // (
+                                               "%26",          // &
+                                               "%24",          // $
+                                               "%3f",          // ?
+                                               "%3b",          // ;
+                                               "%3d"           // =
+                                       );
+
+               $filename = str_replace($bad, '', $filename);
+
+               return stripslashes($filename);
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Limit the File Name Length
+        *
+        * @param       string
+        * @return      string
+        */
+       public function limit_filename_length($filename, $length)
+       {
+               if (strlen($filename) < $length)
+               {
+                       return $filename;
+               }
+
+               $ext = '';
+               if (strpos($filename, '.') !== FALSE)
+               {
+                       $parts          = explode('.', $filename);
+                       $ext            = '.'.array_pop($parts);
+                       $filename       = implode('.', $parts);
+               }
+
+               return substr($filename, 0, ($length - strlen($ext))).$ext;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Runs the file through the XSS clean function
+        *
+        * This prevents people from embedding malicious code in their files.
+        * I'm not sure that it won't negatively affect certain files in unexpected ways,
+        * but so far I haven't found that it causes trouble.
+        *
+        * @return      void
+        */
+       public function do_xss_clean()
+       {
+               $file = $this->file_temp;
+
+               if (filesize($file) == 0)
+               {
+                       return FALSE;
+               }
+
+               if (function_exists('memory_get_usage') && memory_get_usage() && ini_get('memory_limit') != '')
+               {
+                       $current = ini_get('memory_limit') * 1024 * 1024;
+
+                       // There was a bug/behavioural change in PHP 5.2, where numbers over one million get output
+                       // into scientific notation.  number_format() ensures this number is an integer
+                       // http://bugs.php.net/bug.php?id=43053
+
+                       $new_memory = number_format(ceil(filesize($file) + $current), 0, '.', '');
+
+                       ini_set('memory_limit', $new_memory); // When an integer is used, the value is measured in bytes. - PHP.net
+               }
+
+               // If the file being uploaded is an image, then we should have no problem with XSS attacks (in theory), but
+               // IE can be fooled into mime-type detecting a malformed image as an html file, thus executing an XSS attack on anyone
+               // using IE who looks at the image.  It does this by inspecting the first 255 bytes of an image.  To get around this
+               // CI will itself look at the first 255 bytes of an image to determine its relative safety.  This can save a lot of
+               // processor power and time if it is actually a clean image, as it will be in nearly all instances _except_ an
+               // attempted XSS attack.
+
+               if (function_exists('getimagesize') && @getimagesize($file) !== FALSE)
+               {
+                       if (($file = @fopen($file, 'rb')) === FALSE) // "b" to force binary
+                       {
+                               return FALSE; // Couldn't open the file, return FALSE
+                       }
+
+                       $opening_bytes = fread($file, 256);
+                       fclose($file);
+
+                       // These are known to throw IE into mime-type detection chaos
+                       // <a, <body, <head, <html, <img, <plaintext, <pre, <script, <table, <title
+                       // title is basically just in SVG, but we filter it anyhow
+
+                       if ( ! preg_match('/<(a|body|head|html|img|plaintext|pre|script|table|title)[\s>]/i', $opening_bytes))
+                       {
+                               return TRUE; // its an image, no "triggers" detected in the first 256 bytes, we're good
+                       }
+               }
+
+               if (($data = @file_get_contents($file)) === FALSE)
+               {
+                       return FALSE;
+               }
+
+               $CI =& get_instance();
+               return $CI->security->xss_clean($data, TRUE);
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Set an error message
+        *
+        * @param       string
+        * @return      void
+        */
+       public function set_error($msg)
+       {
+               $CI =& get_instance();
+               $CI->lang->load('upload');
+
+               if (is_array($msg))
+               {
+                       foreach ($msg as $val)
+                       {
+                               $msg = ($CI->lang->line($val) == FALSE) ? $val : $CI->lang->line($val);
+                               $this->error_msg[] = $msg;
+                               log_message('error', $msg);
+                       }
+               }
+               else
+               {
+                       $msg = ($CI->lang->line($msg) == FALSE) ? $msg : $CI->lang->line($msg);
+                       $this->error_msg[] = $msg;
+                       log_message('error', $msg);
+               }
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Display the error message
+        *
+        * @param       string
+        * @param       string
+        * @return      string
+        */
+       public function display_errors($open = '<p>', $close = '</p>')
+       {
+               $str = '';
+               foreach ($this->error_msg as $val)
+               {
+                       $str .= $open.$val.$close;
+               }
+
+               return $str;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * List of Mime Types
+        *
+        * This is a list of mime types.  We use it to validate
+        * the "allowed types" set by the developer
+        *
+        * @param       string
+        * @return      string
+        */
+       public function mimes_types($mime)
+       {
+               global $mimes;
+
+               if (count($this->mimes) == 0)
+               {
+                       if (defined('ENVIRONMENT') AND is_file(APPPATH.'config/'.ENVIRONMENT.'/mimes'.EXT))
+                       {
+                               include(APPPATH.'config/'.ENVIRONMENT.'/mimes'.EXT);
+                       }
+                       elseif (is_file(APPPATH.'config/mimes'.EXT))
+                       {
+                               include(APPPATH.'config//mimes'.EXT);
+                       }
+                       else
+                       {
+                               return FALSE;
+                       }
+
+                       $this->mimes = $mimes;
+                       unset($mimes);
+               }
+
+               return ( ! isset($this->mimes[$mime])) ? FALSE : $this->mimes[$mime];
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Prep Filename
+        *
+        * Prevents possible script execution from Apache's handling of files multiple extensions
+        * http://httpd.apache.org/docs/1.3/mod/mod_mime.html#multipleext
+        *
+        * @param       string
+        * @return      string
+        */
+       protected function _prep_filename($filename)
+       {
+               if (strpos($filename, '.') === FALSE OR $this->allowed_types == '*')
+               {
+                       return $filename;
+               }
+
+               $parts          = explode('.', $filename);
+               $ext            = array_pop($parts);
+               $filename       = array_shift($parts);
+
+               foreach ($parts as $part)
+               {
+                       if ( ! in_array(strtolower($part), $this->allowed_types) OR $this->mimes_types(strtolower($part)) === FALSE)
+                       {
+                               $filename .= '.'.$part.'_';
+                       }
+                       else
+                       {
+                               $filename .= '.'.$part;
+                       }
+               }
+
+               $filename .= '.'.$ext;
+
+               return $filename;
+       }
+
+       // --------------------------------------------------------------------
+
+}
+// END Upload Class
+
+/* End of file Upload.php */
+/* Location: ./system/libraries/Upload.php */
\ No newline at end of file
diff --git a/system/libraries/User_agent.php b/system/libraries/User_agent.php
new file mode 100755 (executable)
index 0000000..04cda73
--- /dev/null
@@ -0,0 +1,549 @@
+<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+/**
+ * CodeIgniter
+ *
+ * An open source application development framework for PHP 5.1.6 or newer
+ *
+ * @package            CodeIgniter
+ * @author             ExpressionEngine Dev Team
+ * @copyright  Copyright (c) 2008 - 2011, EllisLab, Inc.
+ * @license            http://codeigniter.com/user_guide/license.html
+ * @link               http://codeigniter.com
+ * @since              Version 1.0
+ * @filesource
+ */
+
+// ------------------------------------------------------------------------
+
+/**
+ * User Agent Class
+ *
+ * Identifies the platform, browser, robot, or mobile devise of the browsing agent
+ *
+ * @package            CodeIgniter
+ * @subpackage Libraries
+ * @category   User Agent
+ * @author             ExpressionEngine Dev Team
+ * @link               http://codeigniter.com/user_guide/libraries/user_agent.html
+ */
+class CI_User_agent {
+
+       var $agent              = NULL;
+
+       var $is_browser = FALSE;
+       var $is_robot   = FALSE;
+       var $is_mobile  = FALSE;
+
+       var $languages  = array();
+       var $charsets   = array();
+
+       var $platforms  = array();
+       var $browsers   = array();
+       var $mobiles    = array();
+       var $robots             = array();
+
+       var $platform   = '';
+       var $browser    = '';
+       var $version    = '';
+       var $mobile             = '';
+       var $robot              = '';
+
+       /**
+        * Constructor
+        *
+        * Sets the User Agent and runs the compilation routine
+        *
+        * @access      public
+        * @return      void
+        */
+       public function __construct()
+       {
+               if (isset($_SERVER['HTTP_USER_AGENT']))
+               {
+                       $this->agent = trim($_SERVER['HTTP_USER_AGENT']);
+               }
+
+               if ( ! is_null($this->agent))
+               {
+                       if ($this->_load_agent_file())
+                       {
+                               $this->_compile_data();
+                       }
+               }
+
+               log_message('debug', "User Agent Class Initialized");
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Compile the User Agent Data
+        *
+        * @access      private
+        * @return      bool
+        */
+       private function _load_agent_file()
+       {
+               if (defined('ENVIRONMENT') AND is_file(APPPATH.'config/'.ENVIRONMENT.'/user_agents'.EXT))
+               {
+                       include(APPPATH.'config/'.ENVIRONMENT.'/user_agents'.EXT);
+               }
+               elseif (is_file(APPPATH.'config/user_agents'.EXT))
+               {
+                       include(APPPATH.'config/user_agents'.EXT);
+               }
+               else
+               {
+                       return FALSE;
+               }
+
+               $return = FALSE;
+
+               if (isset($platforms))
+               {
+                       $this->platforms = $platforms;
+                       unset($platforms);
+                       $return = TRUE;
+               }
+
+               if (isset($browsers))
+               {
+                       $this->browsers = $browsers;
+                       unset($browsers);
+                       $return = TRUE;
+               }
+
+               if (isset($mobiles))
+               {
+                       $this->mobiles = $mobiles;
+                       unset($mobiles);
+                       $return = TRUE;
+               }
+
+               if (isset($robots))
+               {
+                       $this->robots = $robots;
+                       unset($robots);
+                       $return = TRUE;
+               }
+
+               return $return;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Compile the User Agent Data
+        *
+        * @access      private
+        * @return      bool
+        */
+       private function _compile_data()
+       {
+               $this->_set_platform();
+
+               foreach (array('_set_browser', '_set_robot', '_set_mobile') as $function)
+               {
+                       if ($this->$function() === TRUE)
+                       {
+                               break;
+                       }
+               }
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Set the Platform
+        *
+        * @access      private
+        * @return      mixed
+        */
+       private function _set_platform()
+       {
+               if (is_array($this->platforms) AND count($this->platforms) > 0)
+               {
+                       foreach ($this->platforms as $key => $val)
+                       {
+                               if (preg_match("|".preg_quote($key)."|i", $this->agent))
+                               {
+                                       $this->platform = $val;
+                                       return TRUE;
+                               }
+                       }
+               }
+               $this->platform = 'Unknown Platform';
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Set the Browser
+        *
+        * @access      private
+        * @return      bool
+        */
+       private function _set_browser()
+       {
+               if (is_array($this->browsers) AND count($this->browsers) > 0)
+               {
+                       foreach ($this->browsers as $key => $val)
+                       {
+                               if (preg_match("|".preg_quote($key).".*?([0-9\.]+)|i", $this->agent, $match))
+                               {
+                                       $this->is_browser = TRUE;
+                                       $this->version = $match[1];
+                                       $this->browser = $val;
+                                       $this->_set_mobile();
+                                       return TRUE;
+                               }
+                       }
+               }
+               return FALSE;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Set the Robot
+        *
+        * @access      private
+        * @return      bool
+        */
+       private function _set_robot()
+       {
+               if (is_array($this->robots) AND count($this->robots) > 0)
+               {
+                       foreach ($this->robots as $key => $val)
+                       {
+                               if (preg_match("|".preg_quote($key)."|i", $this->agent))
+                               {
+                                       $this->is_robot = TRUE;
+                                       $this->robot = $val;
+                                       return TRUE;
+                               }
+                       }
+               }
+               return FALSE;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Set the Mobile Device
+        *
+        * @access      private
+        * @return      bool
+        */
+       private function _set_mobile()
+       {
+               if (is_array($this->mobiles) AND count($this->mobiles) > 0)
+               {
+                       foreach ($this->mobiles as $key => $val)
+                       {
+                               if (FALSE !== (strpos(strtolower($this->agent), $key)))
+                               {
+                                       $this->is_mobile = TRUE;
+                                       $this->mobile = $val;
+                                       return TRUE;
+                               }
+                       }
+               }
+               return FALSE;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Set the accepted languages
+        *
+        * @access      private
+        * @return      void
+        */
+       private function _set_languages()
+       {
+               if ((count($this->languages) == 0) AND isset($_SERVER['HTTP_ACCEPT_LANGUAGE']) AND $_SERVER['HTTP_ACCEPT_LANGUAGE'] != '')
+               {
+                       $languages = preg_replace('/(;q=[0-9\.]+)/i', '', strtolower(trim($_SERVER['HTTP_ACCEPT_LANGUAGE'])));
+
+                       $this->languages = explode(',', $languages);
+               }
+
+               if (count($this->languages) == 0)
+               {
+                       $this->languages = array('Undefined');
+               }
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Set the accepted character sets
+        *
+        * @access      private
+        * @return      void
+        */
+       private function _set_charsets()
+       {
+               if ((count($this->charsets) == 0) AND isset($_SERVER['HTTP_ACCEPT_CHARSET']) AND $_SERVER['HTTP_ACCEPT_CHARSET'] != '')
+               {
+                       $charsets = preg_replace('/(;q=.+)/i', '', strtolower(trim($_SERVER['HTTP_ACCEPT_CHARSET'])));
+
+                       $this->charsets = explode(',', $charsets);
+               }
+
+               if (count($this->charsets) == 0)
+               {
+                       $this->charsets = array('Undefined');
+               }
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Is Browser
+        *
+        * @access      public
+        * @return      bool
+        */
+       public function is_browser($key = NULL)
+       {
+               if ( ! $this->is_browser)
+               {
+                       return FALSE;
+               }
+
+               // No need to be specific, it's a browser
+               if ($key === NULL)
+               {
+                       return TRUE;
+               }
+
+               // Check for a specific browser
+               return array_key_exists($key, $this->browsers) AND $this->browser === $this->browsers[$key];
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Is Robot
+        *
+        * @access      public
+        * @return      bool
+        */
+       public function is_robot($key = NULL)
+       {
+               if ( ! $this->is_robot)
+               {
+                       return FALSE;
+               }
+
+               // No need to be specific, it's a robot
+               if ($key === NULL)
+               {
+                       return TRUE;
+               }
+
+               // Check for a specific robot
+               return array_key_exists($key, $this->robots) AND $this->robot === $this->robots[$key];
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Is Mobile
+        *
+        * @access      public
+        * @return      bool
+        */
+       public function is_mobile($key = NULL)
+       {
+               if ( ! $this->is_mobile)
+               {
+                       return FALSE;
+               }
+
+               // No need to be specific, it's a mobile
+               if ($key === NULL)
+               {
+                       return TRUE;
+               }
+
+               // Check for a specific robot
+               return array_key_exists($key, $this->mobiles) AND $this->mobile === $this->mobiles[$key];
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Is this a referral from another site?
+        *
+        * @access      public
+        * @return      bool
+        */
+       public function is_referral()
+       {
+               if ( ! isset($_SERVER['HTTP_REFERER']) OR $_SERVER['HTTP_REFERER'] == '')
+               {
+                       return FALSE;
+               }
+               return TRUE;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Agent String
+        *
+        * @access      public
+        * @return      string
+        */
+       public function agent_string()
+       {
+               return $this->agent;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Get Platform
+        *
+        * @access      public
+        * @return      string
+        */
+       public function platform()
+       {
+               return $this->platform;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Get Browser Name
+        *
+        * @access      public
+        * @return      string
+        */
+       public function browser()
+       {
+               return $this->browser;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Get the Browser Version
+        *
+        * @access      public
+        * @return      string
+        */
+       public function version()
+       {
+               return $this->version;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Get The Robot Name
+        *
+        * @access      public
+        * @return      string
+        */
+       public function robot()
+       {
+               return $this->robot;
+       }
+       // --------------------------------------------------------------------
+
+       /**
+        * Get the Mobile Device
+        *
+        * @access      public
+        * @return      string
+        */
+       public function mobile()
+       {
+               return $this->mobile;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Get the referrer
+        *
+        * @access      public
+        * @return      bool
+        */
+       public function referrer()
+       {
+               return ( ! isset($_SERVER['HTTP_REFERER']) OR $_SERVER['HTTP_REFERER'] == '') ? '' : trim($_SERVER['HTTP_REFERER']);
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Get the accepted languages
+        *
+        * @access      public
+        * @return      array
+        */
+       public function languages()
+       {
+               if (count($this->languages) == 0)
+               {
+                       $this->_set_languages();
+               }
+
+               return $this->languages;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Get the accepted Character Sets
+        *
+        * @access      public
+        * @return      array
+        */
+       public function charsets()
+       {
+               if (count($this->charsets) == 0)
+               {
+                       $this->_set_charsets();
+               }
+
+               return $this->charsets;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Test for a particular language
+        *
+        * @access      public
+        * @return      bool
+        */
+       public function accept_lang($lang = 'en')
+       {
+               return (in_array(strtolower($lang), $this->languages(), TRUE));
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Test for a particular character set
+        *
+        * @access      public
+        * @return      bool
+        */
+       public function accept_charset($charset = 'utf-8')
+       {
+               return (in_array(strtolower($charset), $this->charsets(), TRUE));
+       }
+
+}
+
+
+/* End of file User_agent.php */
+/* Location: ./system/libraries/User_agent.php */
\ No newline at end of file
diff --git a/system/libraries/Xmlrpc.php b/system/libraries/Xmlrpc.php
new file mode 100755 (executable)
index 0000000..5da6ea6
--- /dev/null
@@ -0,0 +1,1423 @@
+<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+/**
+ * CodeIgniter
+ *
+ * An open source application development framework for PHP 5.1.6 or newer
+ *
+ * @package            CodeIgniter
+ * @author             ExpressionEngine Dev Team
+ * @copyright  Copyright (c) 2008 - 2011, EllisLab, Inc.
+ * @license            http://codeigniter.com/user_guide/license.html
+ * @link               http://codeigniter.com
+ * @since              Version 1.0
+ * @filesource
+ */
+
+if ( ! function_exists('xml_parser_create'))
+{
+       show_error('Your PHP installation does not support XML');
+}
+
+
+// ------------------------------------------------------------------------
+
+/**
+ * XML-RPC request handler class
+ *
+ * @package            CodeIgniter
+ * @subpackage Libraries
+ * @category   XML-RPC
+ * @author             ExpressionEngine Dev Team
+ * @link               http://codeigniter.com/user_guide/libraries/xmlrpc.html
+ */
+class CI_Xmlrpc {
+
+       var $debug                      = FALSE;        // Debugging on or off
+       var $xmlrpcI4           = 'i4';
+       var $xmlrpcInt          = 'int';
+       var $xmlrpcBoolean      = 'boolean';
+       var $xmlrpcDouble       = 'double';
+       var $xmlrpcString       = 'string';
+       var $xmlrpcDateTime     = 'dateTime.iso8601';
+       var $xmlrpcBase64       = 'base64';
+       var $xmlrpcArray        = 'array';
+       var $xmlrpcStruct       = 'struct';
+
+       var $xmlrpcTypes        = array();
+       var $valid_parents      = array();
+       var $xmlrpcerr          = array();      // Response numbers
+       var $xmlrpcstr          = array();  // Response strings
+
+       var $xmlrpc_defencoding = 'UTF-8';
+       var $xmlrpcName                 = 'XML-RPC for CodeIgniter';
+       var $xmlrpcVersion              = '1.1';
+       var $xmlrpcerruser              = 800; // Start of user errors
+       var $xmlrpcerrxml               = 100; // Start of XML Parse errors
+       var $xmlrpc_backslash   = ''; // formulate backslashes for escaping regexp
+
+       var $client;
+       var $method;
+       var $data;
+       var $message                    = '';
+       var $error                              = '';           // Error string for request
+       var $result;
+       var $response                   = array();  // Response from remote server
+
+       var $xss_clean                  = TRUE;
+
+       //-------------------------------------
+       //  VALUES THAT MULTIPLE CLASSES NEED
+       //-------------------------------------
+
+       public function __construct($config = array())
+       {
+               $this->xmlrpcName               = $this->xmlrpcName;
+               $this->xmlrpc_backslash = chr(92).chr(92);
+
+               // Types for info sent back and forth
+               $this->xmlrpcTypes = array(
+                       $this->xmlrpcI4                 => '1',
+                       $this->xmlrpcInt                => '1',
+                       $this->xmlrpcBoolean    => '1',
+                       $this->xmlrpcString             => '1',
+                       $this->xmlrpcDouble             => '1',
+                       $this->xmlrpcDateTime   => '1',
+                       $this->xmlrpcBase64             => '1',
+                       $this->xmlrpcArray              => '2',
+                       $this->xmlrpcStruct             => '3'
+                       );
+
+               // Array of Valid Parents for Various XML-RPC elements
+               $this->valid_parents = array('BOOLEAN'                  => array('VALUE'),
+                                                                        'I4'                           => array('VALUE'),
+                                                                        'INT'                          => array('VALUE'),
+                                                                        'STRING'                       => array('VALUE'),
+                                                                        'DOUBLE'                       => array('VALUE'),
+                                                                        'DATETIME.ISO8601'     => array('VALUE'),
+                                                                        'BASE64'                       => array('VALUE'),
+                                                                        'ARRAY'                        => array('VALUE'),
+                                                                        'STRUCT'                       => array('VALUE'),
+                                                                        'PARAM'                        => array('PARAMS'),
+                                                                        'METHODNAME'           => array('METHODCALL'),
+                                                                        'PARAMS'                       => array('METHODCALL', 'METHODRESPONSE'),
+                                                                        'MEMBER'                       => array('STRUCT'),
+                                                                        'NAME'                         => array('MEMBER'),
+                                                                        'DATA'                         => array('ARRAY'),
+                                                                        'FAULT'                        => array('METHODRESPONSE'),
+                                                                        'VALUE'                        => array('MEMBER', 'DATA', 'PARAM', 'FAULT')
+                                                                        );
+
+
+               // XML-RPC Responses
+               $this->xmlrpcerr['unknown_method'] = '1';
+               $this->xmlrpcstr['unknown_method'] = 'This is not a known method for this XML-RPC Server';
+               $this->xmlrpcerr['invalid_return'] = '2';
+               $this->xmlrpcstr['invalid_return'] = 'The XML data received was either invalid or not in the correct form for XML-RPC.  Turn on debugging to examine the XML data further.';
+               $this->xmlrpcerr['incorrect_params'] = '3';
+               $this->xmlrpcstr['incorrect_params'] = 'Incorrect parameters were passed to method';
+               $this->xmlrpcerr['introspect_unknown'] = '4';
+               $this->xmlrpcstr['introspect_unknown'] = "Cannot inspect signature for request: method unknown";
+               $this->xmlrpcerr['http_error'] = '5';
+               $this->xmlrpcstr['http_error'] = "Did not receive a '200 OK' response from remote server.";
+               $this->xmlrpcerr['no_data'] = '6';
+               $this->xmlrpcstr['no_data'] ='No data received from server.';
+
+               $this->initialize($config);
+
+               log_message('debug', "XML-RPC Class Initialized");
+       }
+
+
+       //-------------------------------------
+       //  Initialize Prefs
+       //-------------------------------------
+
+       function initialize($config = array())
+       {
+               if (count($config) > 0)
+               {
+                       foreach ($config as $key => $val)
+                       {
+                               if (isset($this->$key))
+                               {
+                                       $this->$key = $val;
+                               }
+                       }
+               }
+       }
+       // END
+
+       //-------------------------------------
+       //  Take URL and parse it
+       //-------------------------------------
+
+       function server($url, $port=80)
+       {
+               if (substr($url, 0, 4) != "http")
+               {
+                       $url = "http://".$url;
+               }
+
+               $parts = parse_url($url);
+
+               $path = ( ! isset($parts['path'])) ? '/' : $parts['path'];
+
+               if (isset($parts['query']) && $parts['query'] != '')
+               {
+                       $path .= '?'.$parts['query'];
+               }
+
+               $this->client = new XML_RPC_Client($path, $parts['host'], $port);
+       }
+       // END
+
+       //-------------------------------------
+       //  Set Timeout
+       //-------------------------------------
+
+       function timeout($seconds=5)
+       {
+               if ( ! is_null($this->client) && is_int($seconds))
+               {
+                       $this->client->timeout = $seconds;
+               }
+       }
+       // END
+
+       //-------------------------------------
+       //  Set Methods
+       //-------------------------------------
+
+       function method($function)
+       {
+               $this->method = $function;
+       }
+       // END
+
+       //-------------------------------------
+       //  Take Array of Data and Create Objects
+       //-------------------------------------
+
+       function request($incoming)
+       {
+               if ( ! is_array($incoming))
+               {
+                       // Send Error
+               }
+
+               $this->data = array();
+
+               foreach ($incoming as $key => $value)
+               {
+                       $this->data[$key] = $this->values_parsing($value);
+               }
+       }
+       // END
+
+
+       //-------------------------------------
+       //  Set Debug
+       //-------------------------------------
+
+       function set_debug($flag = TRUE)
+       {
+               $this->debug = ($flag == TRUE) ? TRUE : FALSE;
+       }
+
+       //-------------------------------------
+       //  Values Parsing
+       //-------------------------------------
+
+       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 (is_array($value[0]))
+                               {
+                                       $temp = new XML_RPC_Values($value['0'], 'array');
+                               }
+                               else
+                               {
+                                       $temp = new XML_RPC_Values($value['0'], 'string');
+                               }
+                       }
+                       elseif (is_array($value['0']) && ($value['1'] == 'struct' OR $value['1'] == 'array'))
+                       {
+                               while (list($k) = each($value['0']))
+                               {
+                                       $value['0'][$k] = $this->values_parsing($value['0'][$k], TRUE);
+                               }
+
+                               $temp = new XML_RPC_Values($value['0'], $value['1']);
+                       }
+                       else
+                       {
+                               $temp = new XML_RPC_Values($value['0'], $value['1']);
+                       }
+               }
+               else
+               {
+                       $temp = new XML_RPC_Values($value, 'string');
+               }
+
+               return $temp;
+       }
+       // END
+
+
+       //-------------------------------------
+       //  Sends XML-RPC Request
+       //-------------------------------------
+
+       function send_request()
+       {
+               $this->message = new XML_RPC_Message($this->method,$this->data);
+               $this->message->debug = $this->debug;
+
+               if ( ! $this->result = $this->client->send($this->message))
+               {
+                       $this->error = $this->result->errstr;
+                       return FALSE;
+               }
+               elseif ( ! is_object($this->result->val))
+               {
+                       $this->error = $this->result->errstr;
+                       return FALSE;
+               }
+
+               $this->response = $this->result->decode();
+
+               return TRUE;
+       }
+       // END
+
+       //-------------------------------------
+       //  Returns Error
+       //-------------------------------------
+
+       function display_error()
+       {
+               return $this->error;
+       }
+       // END
+
+       //-------------------------------------
+       //  Returns Remote Server Response
+       //-------------------------------------
+
+       function display_response()
+       {
+               return $this->response;
+       }
+       // END
+
+       //-------------------------------------
+       //  Sends an Error Message for Server Request
+       //-------------------------------------
+
+       function send_error_message($number, $message)
+       {
+               return new XML_RPC_Response('0',$number, $message);
+       }
+       // END
+
+
+       //-------------------------------------
+       //  Send Response for Server Request
+       //-------------------------------------
+
+       function send_response($response)
+       {
+               // $response should be array of values, which will be parsed
+               // based on their data and type into a valid group of XML-RPC values
+
+               $response = $this->values_parsing($response);
+
+               return new XML_RPC_Response($response);
+       }
+       // END
+
+} // END XML_RPC Class
+
+
+
+/**
+ * XML-RPC Client class
+ *
+ * @category   XML-RPC
+ * @author             ExpressionEngine Dev Team
+ * @link               http://codeigniter.com/user_guide/libraries/xmlrpc.html
+ */
+class XML_RPC_Client extends CI_Xmlrpc
+{
+       var $path                       = '';
+       var $server                     = '';
+       var $port                       = 80;
+       var $errno                      = '';
+       var $errstring          = '';
+       var $timeout            = 5;
+       var $no_multicall       = FALSE;
+
+       public function __construct($path, $server, $port=80)
+       {
+               parent::__construct();
+
+               $this->port = $port;
+               $this->server = $server;
+               $this->path = $path;
+       }
+
+       function send($msg)
+       {
+               if (is_array($msg))
+               {
+                       // Multi-call disabled
+                       $r = new XML_RPC_Response(0, $this->xmlrpcerr['multicall_recursion'],$this->xmlrpcstr['multicall_recursion']);
+                       return $r;
+               }
+
+               return $this->sendPayload($msg);
+       }
+
+       function sendPayload($msg)
+       {
+               $fp = @fsockopen($this->server, $this->port,$this->errno, $this->errstr, $this->timeout);
+
+               if ( ! is_resource($fp))
+               {
+                       error_log($this->xmlrpcstr['http_error']);
+                       $r = new XML_RPC_Response(0, $this->xmlrpcerr['http_error'],$this->xmlrpcstr['http_error']);
+                       return $r;
+               }
+
+               if (empty($msg->payload))
+               {
+                       // $msg = XML_RPC_Messages
+                       $msg->createPayload();
+               }
+
+               $r = "\r\n";
+               $op  = "POST {$this->path} HTTP/1.0$r";
+               $op .= "Host: {$this->server}$r";
+               $op .= "Content-Type: text/xml$r";
+               $op .= "User-Agent: {$this->xmlrpcName}$r";
+               $op .= "Content-Length: ".strlen($msg->payload). "$r$r";
+               $op .= $msg->payload;
+
+
+               if ( ! fputs($fp, $op, strlen($op)))
+               {
+                       error_log($this->xmlrpcstr['http_error']);
+                       $r = new XML_RPC_Response(0, $this->xmlrpcerr['http_error'], $this->xmlrpcstr['http_error']);
+                       return $r;
+               }
+               $resp = $msg->parseResponse($fp);
+               fclose($fp);
+               return $resp;
+       }
+
+} // end class XML_RPC_Client
+
+
+/**
+ * XML-RPC Response class
+ *
+ * @category   XML-RPC
+ * @author             ExpressionEngine Dev Team
+ * @link               http://codeigniter.com/user_guide/libraries/xmlrpc.html
+ */
+class XML_RPC_Response
+{
+       var $val = 0;
+       var $errno = 0;
+       var $errstr = '';
+       var $headers = array();
+       var $xss_clean = TRUE;
+
+       public function __construct($val, $code = 0, $fstr = '')
+       {
+               if ($code != 0)
+               {
+                       // error
+                       $this->errno = $code;
+                       $this->errstr = htmlentities($fstr);
+               }
+               else if ( ! is_object($val))
+               {
+                       // programmer error, not an object
+                       error_log("Invalid type '" . gettype($val) . "' (value: $val) passed to XML_RPC_Response.  Defaulting to empty value.");
+                       $this->val = new XML_RPC_Values();
+               }
+               else
+               {
+                       $this->val = $val;
+               }
+       }
+
+       function faultCode()
+       {
+               return $this->errno;
+       }
+
+       function faultString()
+       {
+               return $this->errstr;
+       }
+
+       function value()
+       {
+               return $this->val;
+       }
+
+       function prepare_response()
+       {
+               $result = "<methodResponse>\n";
+               if ($this->errno)
+               {
+                       $result .= '<fault>
+       <value>
+               <struct>
+                       <member>
+                               <name>faultCode</name>
+                               <value><int>' . $this->errno . '</int></value>
+                       </member>
+                       <member>
+                               <name>faultString</name>
+                               <value><string>' . $this->errstr . '</string></value>
+                       </member>
+               </struct>
+       </value>
+</fault>';
+               }
+               else
+               {
+                       $result .= "<params>\n<param>\n" .
+                                       $this->val->serialize_class() .
+                                       "</param>\n</params>";
+               }
+               $result .= "\n</methodResponse>";
+               return $result;
+       }
+
+       function decode($array=FALSE)
+       {
+               $CI =& get_instance();
+               
+               if ($array !== FALSE && is_array($array))
+               {
+                       while (list($key) = each($array))
+                       {
+                               if (is_array($array[$key]))
+                               {
+                                       $array[$key] = $this->decode($array[$key]);
+                               }
+                               else
+                               {
+                                       $array[$key] = ($this->xss_clean) ? $CI->security->xss_clean($array[$key]) : $array[$key];
+                               }
+                       }
+
+                       $result = $array;
+               }
+               else
+               {
+                       $result = $this->xmlrpc_decoder($this->val);
+
+                       if (is_array($result))
+                       {
+                               $result = $this->decode($result);
+                       }
+                       else
+                       {
+                               $result = ($this->xss_clean) ? $CI->security->xss_clean($result) : $result;
+                       }
+               }
+
+               return $result;
+       }
+
+
+
+       //-------------------------------------
+       //  XML-RPC Object to PHP Types
+       //-------------------------------------
+
+       function xmlrpc_decoder($xmlrpc_val)
+       {
+               $kind = $xmlrpc_val->kindOf();
+
+               if ($kind == 'scalar')
+               {
+                       return $xmlrpc_val->scalarval();
+               }
+               elseif ($kind == 'array')
+               {
+                       reset($xmlrpc_val->me);
+                       list($a,$b) = each($xmlrpc_val->me);
+                       $size = count($b);
+
+                       $arr = array();
+
+                       for ($i = 0; $i < $size; $i++)
+                       {
+                               $arr[] = $this->xmlrpc_decoder($xmlrpc_val->me['array'][$i]);
+                       }
+                       return $arr;
+               }
+               elseif ($kind == 'struct')
+               {
+                       reset($xmlrpc_val->me['struct']);
+                       $arr = array();
+
+                       while (list($key,$value) = each($xmlrpc_val->me['struct']))
+                       {
+                               $arr[$key] = $this->xmlrpc_decoder($value);
+                       }
+                       return $arr;
+               }
+       }
+
+
+       //-------------------------------------
+       //  ISO-8601 time to server or UTC time
+       //-------------------------------------
+
+       function iso8601_decode($time, $utc=0)
+       {
+               // return a timet in the localtime, or UTC
+               $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))
+               {
+                       $fnc = ($utc == 1) ? 'gmmktime' : 'mktime';
+                       $t = $fnc($regs[4], $regs[5], $regs[6], $regs[2], $regs[3], $regs[1]);
+               }
+               return $t;
+       }
+
+} // End Response Class
+
+
+
+/**
+ * XML-RPC Message class
+ *
+ * @category   XML-RPC
+ * @author             ExpressionEngine Dev Team
+ * @link               http://codeigniter.com/user_guide/libraries/xmlrpc.html
+ */
+class XML_RPC_Message extends CI_Xmlrpc
+{
+       var $payload;
+       var $method_name;
+       var $params                     = array();
+       var $xh                         = array();
+
+       public function __construct($method, $pars=0)
+       {
+               parent::__construct();
+
+               $this->method_name = $method;
+               if (is_array($pars) && count($pars) > 0)
+               {
+                       for ($i=0; $i<count($pars); $i++)
+                       {
+                               // $pars[$i] = XML_RPC_Values
+                               $this->params[] = $pars[$i];
+                       }
+               }
+       }
+
+       //-------------------------------------
+       //  Create Payload to Send
+       //-------------------------------------
+
+       function createPayload()
+       {
+               $this->payload = "<?xml version=\"1.0\"?".">\r\n<methodCall>\r\n";
+               $this->payload .= '<methodName>' . $this->method_name . "</methodName>\r\n";
+               $this->payload .= "<params>\r\n";
+
+               for ($i=0; $i<count($this->params); $i++)
+               {
+                       // $p = XML_RPC_Values
+                       $p = $this->params[$i];
+                       $this->payload .= "<param>\r\n".$p->serialize_class()."</param>\r\n";
+               }
+
+               $this->payload .= "</params>\r\n</methodCall>\r\n";
+       }
+
+       //-------------------------------------
+       //  Parse External XML-RPC Server's Response
+       //-------------------------------------
+
+       function parseResponse($fp)
+       {
+               $data = '';
+
+               while ($datum = fread($fp, 4096))
+               {
+                       $data .= $datum;
+               }
+
+               //-------------------------------------
+               //  DISPLAY HTTP CONTENT for DEBUGGING
+               //-------------------------------------
+
+               if ($this->debug === TRUE)
+               {
+                       echo "<pre>";
+                       echo "---DATA---\n" . htmlspecialchars($data) . "\n---END DATA---\n\n";
+                       echo "</pre>";
+               }
+
+               //-------------------------------------
+               //  Check for data
+               //-------------------------------------
+
+               if ($data == "")
+               {
+                       error_log($this->xmlrpcstr['no_data']);
+                       $r = new XML_RPC_Response(0, $this->xmlrpcerr['no_data'], $this->xmlrpcstr['no_data']);
+                       return $r;
+               }
+
+
+               //-------------------------------------
+               //  Check for HTTP 200 Response
+               //-------------------------------------
+
+               if (strncmp($data, 'HTTP', 4) == 0 && ! preg_match('/^HTTP\/[0-9\.]+ 200 /', $data))
+               {
+                       $errstr= substr($data, 0, strpos($data, "\n")-1);
+                       $r = new XML_RPC_Response(0, $this->xmlrpcerr['http_error'], $this->xmlrpcstr['http_error']. ' (' . $errstr . ')');
+                       return $r;
+               }
+
+               //-------------------------------------
+               //  Create and Set Up XML Parser
+               //-------------------------------------
+
+               $parser = xml_parser_create($this->xmlrpc_defencoding);
+
+               $this->xh[$parser]                                      = array();
+               $this->xh[$parser]['isf']                       = 0;
+               $this->xh[$parser]['ac']                        = '';
+               $this->xh[$parser]['headers']           = array();
+               $this->xh[$parser]['stack']                     = array();
+               $this->xh[$parser]['valuestack']        = array();
+               $this->xh[$parser]['isf_reason']        = 0;
+
+               xml_set_object($parser, $this);
+               xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, true);
+               xml_set_element_handler($parser, 'open_tag', 'closing_tag');
+               xml_set_character_data_handler($parser, 'character_data');
+               //xml_set_default_handler($parser, 'default_handler');
+
+
+               //-------------------------------------
+               //  GET HEADERS
+               //-------------------------------------
+
+               $lines = explode("\r\n", $data);
+               while (($line = array_shift($lines)))
+               {
+                       if (strlen($line) < 1)
+                       {
+                               break;
+                       }
+                       $this->xh[$parser]['headers'][] = $line;
+               }
+               $data = implode("\r\n", $lines);
+
+
+               //-------------------------------------
+               //  PARSE XML DATA
+               //-------------------------------------
+
+               if ( ! xml_parse($parser, $data, count($data)))
+               {
+                       $errstr = sprintf('XML error: %s at line %d',
+                                       xml_error_string(xml_get_error_code($parser)),
+                                       xml_get_current_line_number($parser));
+                       //error_log($errstr);
+                       $r = new XML_RPC_Response(0, $this->xmlrpcerr['invalid_return'], $this->xmlrpcstr['invalid_return']);
+                       xml_parser_free($parser);
+                       return $r;
+               }
+               xml_parser_free($parser);
+
+               // ---------------------------------------
+               //  Got Ourselves Some Badness, It Seems
+               // ---------------------------------------
+
+               if ($this->xh[$parser]['isf'] > 1)
+               {
+                       if ($this->debug === TRUE)
+                       {
+                               echo "---Invalid Return---\n";
+                               echo $this->xh[$parser]['isf_reason'];
+                               echo "---Invalid Return---\n\n";
+                       }
+
+                       $r = new XML_RPC_Response(0, $this->xmlrpcerr['invalid_return'],$this->xmlrpcstr['invalid_return'].' '.$this->xh[$parser]['isf_reason']);
+                       return $r;
+               }
+               elseif ( ! is_object($this->xh[$parser]['value']))
+               {
+                       $r = new XML_RPC_Response(0, $this->xmlrpcerr['invalid_return'],$this->xmlrpcstr['invalid_return'].' '.$this->xh[$parser]['isf_reason']);
+                       return $r;
+               }
+
+               //-------------------------------------
+               //  DISPLAY XML CONTENT for DEBUGGING
+               //-------------------------------------
+
+               if ($this->debug === TRUE)
+               {
+                       echo "<pre>";
+
+                       if (count($this->xh[$parser]['headers'] > 0))
+                       {
+                               echo "---HEADERS---\n";
+                               foreach ($this->xh[$parser]['headers'] as $header)
+                               {
+                                       echo "$header\n";
+                               }
+                               echo "---END HEADERS---\n\n";
+                       }
+
+                       echo "---DATA---\n" . htmlspecialchars($data) . "\n---END DATA---\n\n";
+
+                       echo "---PARSED---\n" ;
+                       var_dump($this->xh[$parser]['value']);
+                       echo "\n---END PARSED---</pre>";
+               }
+
+               //-------------------------------------
+               //  SEND RESPONSE
+               //-------------------------------------
+
+               $v = $this->xh[$parser]['value'];
+
+               if ($this->xh[$parser]['isf'])
+               {
+                       $errno_v = $v->me['struct']['faultCode'];
+                       $errstr_v = $v->me['struct']['faultString'];
+                       $errno = $errno_v->scalarval();
+
+                       if ($errno == 0)
+                       {
+                               // FAULT returned, errno needs to reflect that
+                               $errno = -1;
+                       }
+
+                       $r = new XML_RPC_Response($v, $errno, $errstr_v->scalarval());
+               }
+               else
+               {
+                       $r = new XML_RPC_Response($v);
+               }
+
+               $r->headers = $this->xh[$parser]['headers'];
+               return $r;
+       }
+
+       // ------------------------------------
+       //  Begin Return Message Parsing section
+       // ------------------------------------
+
+       // quick explanation of components:
+       //   ac - used to accumulate values
+       //   isf - used to indicate a fault
+       //   lv - used to indicate "looking for a value": implements
+       //              the logic to allow values with no types to be strings
+       //   params - used to store parameters in method calls
+       //   method - used to store method name
+       //       stack - array with parent tree of the xml element,
+       //                       used to validate the nesting of elements
+
+       //-------------------------------------
+       //  Start Element Handler
+       //-------------------------------------
+
+       function open_tag($the_parser, $name, $attrs)
+       {
+               // If invalid nesting, then return
+               if ($this->xh[$the_parser]['isf'] > 1) return;
+
+               // Evaluate and check for correct nesting of XML elements
+
+               if (count($this->xh[$the_parser]['stack']) == 0)
+               {
+                       if ($name != 'METHODRESPONSE' && $name != 'METHODCALL')
+                       {
+                               $this->xh[$the_parser]['isf'] = 2;
+                               $this->xh[$the_parser]['isf_reason'] = 'Top level XML-RPC element is missing';
+                               return;
+                       }
+               }
+               else
+               {
+                       // not top level element: see if parent is OK
+                       if ( ! in_array($this->xh[$the_parser]['stack'][0], $this->valid_parents[$name], TRUE))
+                       {
+                               $this->xh[$the_parser]['isf'] = 2;
+                               $this->xh[$the_parser]['isf_reason'] = "XML-RPC element $name cannot be child of ".$this->xh[$the_parser]['stack'][0];
+                               return;
+                       }
+               }
+
+               switch($name)
+               {
+                       case 'STRUCT':
+                       case 'ARRAY':
+                               // Creates array for child elements
+
+                               $cur_val = array('value' => array(),
+                                                                'type'  => $name);
+
+                               array_unshift($this->xh[$the_parser]['valuestack'], $cur_val);
+                       break;
+                       case 'METHODNAME':
+                       case 'NAME':
+                               $this->xh[$the_parser]['ac'] = '';
+                       break;
+                       case 'FAULT':
+                               $this->xh[$the_parser]['isf'] = 1;
+                       break;
+                       case 'PARAM':
+                               $this->xh[$the_parser]['value'] = NULL;
+                       break;
+                       case 'VALUE':
+                               $this->xh[$the_parser]['vt'] = 'value';
+                               $this->xh[$the_parser]['ac'] = '';
+                               $this->xh[$the_parser]['lv'] = 1;
+                       break;
+                       case 'I4':
+                       case 'INT':
+                       case 'STRING':
+                       case 'BOOLEAN':
+                       case 'DOUBLE':
+                       case 'DATETIME.ISO8601':
+                       case 'BASE64':
+                               if ($this->xh[$the_parser]['vt'] != 'value')
+                               {
+                                       //two data elements inside a value: an error occurred!
+                                       $this->xh[$the_parser]['isf'] = 2;
+                                       $this->xh[$the_parser]['isf_reason'] = "'Twas a $name element following a ".$this->xh[$the_parser]['vt']." element inside a single value";
+                                       return;
+                               }
+
+                               $this->xh[$the_parser]['ac'] = '';
+                       break;
+                       case 'MEMBER':
+                               // Set name of <member> to nothing to prevent errors later if no <name> is found
+                               $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;
+                       break;
+                       case 'DATA':
+                       case 'METHODCALL':
+                       case 'METHODRESPONSE':
+                       case 'PARAMS':
+                               // valid elements that add little to processing
+                       break;
+                       default:
+                               /// An Invalid Element is Found, so we have trouble
+                               $this->xh[$the_parser]['isf'] = 2;
+                               $this->xh[$the_parser]['isf_reason'] = "Invalid XML-RPC element found: $name";
+                       break;
+               }
+
+               // Add current element name to stack, to allow validation of nesting
+               array_unshift($this->xh[$the_parser]['stack'], $name);
+
+               if ($name != 'VALUE') $this->xh[$the_parser]['lv'] = 0;
+       }
+       // END
+
+
+       //-------------------------------------
+       //  End Element Handler
+       //-------------------------------------
+
+       function closing_tag($the_parser, $name)
+       {
+               if ($this->xh[$the_parser]['isf'] > 1) return;
+
+               // Remove current element from stack and set variable
+               // NOTE: If the XML validates, then we do not have to worry about
+               // the opening and closing of elements.  Nesting is checked on the opening
+               // tag so we be safe there as well.
+
+               $curr_elem = array_shift($this->xh[$the_parser]['stack']);
+
+               switch($name)
+               {
+                       case 'STRUCT':
+                       case 'ARRAY':
+                               $cur_val = array_shift($this->xh[$the_parser]['valuestack']);
+                               $this->xh[$the_parser]['value'] = ( ! isset($cur_val['values'])) ? array() : $cur_val['values'];
+                               $this->xh[$the_parser]['vt']    = strtolower($name);
+                       break;
+                       case 'NAME':
+                               $this->xh[$the_parser]['valuestack'][0]['name'] = $this->xh[$the_parser]['ac'];
+                       break;
+                       case 'BOOLEAN':
+                       case 'I4':
+                       case 'INT':
+                       case 'STRING':
+                       case 'DOUBLE':
+                       case 'DATETIME.ISO8601':
+                       case 'BASE64':
+                               $this->xh[$the_parser]['vt'] = strtolower($name);
+
+                               if ($name == 'STRING')
+                               {
+                                       $this->xh[$the_parser]['value'] = $this->xh[$the_parser]['ac'];
+                               }
+                               elseif ($name=='DATETIME.ISO8601')
+                               {
+                                       $this->xh[$the_parser]['vt']    = $this->xmlrpcDateTime;
+                                       $this->xh[$the_parser]['value'] = $this->xh[$the_parser]['ac'];
+                               }
+                               elseif ($name=='BASE64')
+                               {
+                                       $this->xh[$the_parser]['value'] = base64_decode($this->xh[$the_parser]['ac']);
+                               }
+                               elseif ($name=='BOOLEAN')
+                               {
+                                       // Translated BOOLEAN values to TRUE AND FALSE
+                                       if ($this->xh[$the_parser]['ac'] == '1')
+                                       {
+                                               $this->xh[$the_parser]['value'] = TRUE;
+                                       }
+                                       else
+                                       {
+                                               $this->xh[$the_parser]['value'] = FALSE;
+                                       }
+                               }
+                               elseif ($name=='DOUBLE')
+                               {
+                                       // we have a DOUBLE
+                                       // we must check that only 0123456789-.<space> are characters here
+                                       if ( ! preg_match('/^[+-]?[eE0-9\t \.]+$/', $this->xh[$the_parser]['ac']))
+                                       {
+                                               $this->xh[$the_parser]['value'] = 'ERROR_NON_NUMERIC_FOUND';
+                                       }
+                                       else
+                                       {
+                                               $this->xh[$the_parser]['value'] = (double)$this->xh[$the_parser]['ac'];
+                                       }
+                               }
+                               else
+                               {
+                                       // we have an I4/INT
+                                       // we must check that only 0123456789-<space> are characters here
+                                       if ( ! preg_match('/^[+-]?[0-9\t ]+$/', $this->xh[$the_parser]['ac']))
+                                       {
+                                               $this->xh[$the_parser]['value'] = 'ERROR_NON_NUMERIC_FOUND';
+                                       }
+                                       else
+                                       {
+                                               $this->xh[$the_parser]['value'] = (int)$this->xh[$the_parser]['ac'];
+                                       }
+                               }
+                               $this->xh[$the_parser]['ac'] = '';
+                               $this->xh[$the_parser]['lv'] = 3; // indicate we've found a value
+                       break;
+                       case 'VALUE':
+                               // This if() detects if no scalar was inside <VALUE></VALUE>
+                               if ($this->xh[$the_parser]['vt']=='value')
+                               {
+                                       $this->xh[$the_parser]['value'] = $this->xh[$the_parser]['ac'];
+                                       $this->xh[$the_parser]['vt']    = $this->xmlrpcString;
+                               }
+
+                               // build the XML-RPC value out of the data received, and substitute it
+                               $temp = new XML_RPC_Values($this->xh[$the_parser]['value'], $this->xh[$the_parser]['vt']);
+
+                               if (count($this->xh[$the_parser]['valuestack']) && $this->xh[$the_parser]['valuestack'][0]['type'] == 'ARRAY')
+                               {
+                                       // Array
+                                       $this->xh[$the_parser]['valuestack'][0]['values'][] = $temp;
+                               }
+                               else
+                               {
+                                       // Struct
+                                       $this->xh[$the_parser]['value'] = $temp;
+                               }
+                       break;
+                       case 'MEMBER':
+                               $this->xh[$the_parser]['ac']='';
+
+                               // If value add to array in the stack for the last element built
+                               if ($this->xh[$the_parser]['value'])
+                               {
+                                       $this->xh[$the_parser]['valuestack'][0]['values'][$this->xh[$the_parser]['valuestack'][0]['name']] = $this->xh[$the_parser]['value'];
+                               }
+                       break;
+                       case 'DATA':
+                               $this->xh[$the_parser]['ac']='';
+                       break;
+                       case 'PARAM':
+                               if ($this->xh[$the_parser]['value'])
+                               {
+                                       $this->xh[$the_parser]['params'][] = $this->xh[$the_parser]['value'];
+                               }
+                       break;
+                       case 'METHODNAME':
+                               $this->xh[$the_parser]['method'] = ltrim($this->xh[$the_parser]['ac']);
+                       break;
+                       case 'PARAMS':
+                       case 'FAULT':
+                       case 'METHODCALL':
+                       case 'METHORESPONSE':
+                               // We're all good kids with nuthin' to do
+                       break;
+                       default:
+                               // End of an Invalid Element.  Taken care of during the opening tag though
+                       break;
+               }
+       }
+
+       //-------------------------------------
+       //  Parses Character Data
+       //-------------------------------------
+
+       function character_data($the_parser, $data)
+       {
+               if ($this->xh[$the_parser]['isf'] > 1) return; // XML Fault found already
+
+               // If a value has not been found
+               if ($this->xh[$the_parser]['lv'] != 3)
+               {
+                       if ($this->xh[$the_parser]['lv'] == 1)
+                       {
+                               $this->xh[$the_parser]['lv'] = 2; // Found a value
+                       }
+
+                       if ( ! @isset($this->xh[$the_parser]['ac']))
+                       {
+                               $this->xh[$the_parser]['ac'] = '';
+                       }
+
+                       $this->xh[$the_parser]['ac'] .= $data;
+               }
+       }
+
+
+       function addParam($par) { $this->params[]=$par; }
+
+       function output_parameters($array=FALSE)
+       {
+               $CI =& get_instance();
+               
+               if ($array !== FALSE && is_array($array))
+               {
+                       while (list($key) = each($array))
+                       {
+                               if (is_array($array[$key]))
+                               {
+                                       $array[$key] = $this->output_parameters($array[$key]);
+                               }
+                               else
+                               {
+                                       // 'bits' is for the MetaWeblog API image bits
+                                       // @todo - this needs to be made more general purpose
+                                       $array[$key] = ($key == 'bits' OR $this->xss_clean == FALSE) ? $array[$key] : $CI->security->xss_clean($array[$key]);
+                               }
+                       }
+
+                       $parameters = $array;
+               }
+               else
+               {
+                       $parameters = array();
+
+                       for ($i = 0; $i < count($this->params); $i++)
+                       {
+                               $a_param = $this->decode_message($this->params[$i]);
+
+                               if (is_array($a_param))
+                               {
+                                       $parameters[] = $this->output_parameters($a_param);
+                               }
+                               else
+                               {
+                                       $parameters[] = ($this->xss_clean) ? $CI->security->xss_clean($a_param) : $a_param;
+                               }
+                       }
+               }
+
+               return $parameters;
+       }
+
+
+       function decode_message($param)
+       {
+               $kind = $param->kindOf();
+
+               if ($kind == 'scalar')
+               {
+                       return $param->scalarval();
+               }
+               elseif ($kind == 'array')
+               {
+                       reset($param->me);
+                       list($a,$b) = each($param->me);
+
+                       $arr = array();
+
+                       for($i = 0; $i < count($b); $i++)
+                       {
+                               $arr[] = $this->decode_message($param->me['array'][$i]);
+                       }
+
+                       return $arr;
+               }
+               elseif ($kind == 'struct')
+               {
+                       reset($param->me['struct']);
+
+                       $arr = array();
+
+                       while (list($key,$value) = each($param->me['struct']))
+                       {
+                               $arr[$key] = $this->decode_message($value);
+                       }
+
+                       return $arr;
+               }
+       }
+
+} // End XML_RPC_Messages class
+
+
+
+/**
+ * XML-RPC Values class
+ *
+ * @category   XML-RPC
+ * @author             ExpressionEngine Dev Team
+ * @link               http://codeigniter.com/user_guide/libraries/xmlrpc.html
+ */
+class XML_RPC_Values extends CI_Xmlrpc
+{
+       var $me         = array();
+       var $mytype     = 0;
+
+       public function __construct($val=-1, $type='')
+       {
+               parent::__construct();
+
+               if ($val != -1 OR $type != '')
+               {
+                       $type = $type == '' ? 'string' : $type;
+
+                       if ($this->xmlrpcTypes[$type] == 1)
+                       {
+                               $this->addScalar($val,$type);
+                       }
+                       elseif ($this->xmlrpcTypes[$type] == 2)
+                       {
+                               $this->addArray($val);
+                       }
+                       elseif ($this->xmlrpcTypes[$type] == 3)
+                       {
+                               $this->addStruct($val);
+                       }
+               }
+       }
+
+       function addScalar($val, $type='string')
+       {
+               $typeof = $this->xmlrpcTypes[$type];
+
+               if ($this->mytype==1)
+               {
+                       echo '<strong>XML_RPC_Values</strong>: scalar can have only one value<br />';
+                       return 0;
+               }
+
+               if ($typeof != 1)
+               {
+                       echo '<strong>XML_RPC_Values</strong>: not a scalar type (${typeof})<br />';
+                       return 0;
+               }
+
+               if ($type == $this->xmlrpcBoolean)
+               {
+                       if (strcasecmp($val,'true')==0 OR $val==1 OR ($val==true && strcasecmp($val,'false')))
+                       {
+                               $val = 1;
+                       }
+                       else
+                       {
+                               $val=0;
+                       }
+               }
+
+               if ($this->mytype == 2)
+               {
+                       // adding to an array here
+                       $ar = $this->me['array'];
+                       $ar[] = new XML_RPC_Values($val, $type);
+                       $this->me['array'] = $ar;
+               }
+               else
+               {
+                       // a scalar, so set the value and remember we're scalar
+                       $this->me[$type] = $val;
+                       $this->mytype = $typeof;
+               }
+               return 1;
+       }
+
+       function addArray($vals)
+       {
+               if ($this->mytype != 0)
+               {
+                       echo '<strong>XML_RPC_Values</strong>: already initialized as a [' . $this->kindOf() . ']<br />';
+                       return 0;
+               }
+
+               $this->mytype = $this->xmlrpcTypes['array'];
+               $this->me['array'] = $vals;
+               return 1;
+       }
+
+       function addStruct($vals)
+       {
+               if ($this->mytype != 0)
+               {
+                       echo '<strong>XML_RPC_Values</strong>: already initialized as a [' . $this->kindOf() . ']<br />';
+                       return 0;
+               }
+               $this->mytype = $this->xmlrpcTypes['struct'];
+               $this->me['struct'] = $vals;
+               return 1;
+       }
+
+       function kindOf()
+       {
+               switch($this->mytype)
+               {
+                       case 3:
+                               return 'struct';
+                               break;
+                       case 2:
+                               return 'array';
+                               break;
+                       case 1:
+                               return 'scalar';
+                               break;
+                       default:
+                               return 'undef';
+               }
+       }
+
+       function serializedata($typ, $val)
+       {
+               $rs = '';
+
+               switch($this->xmlrpcTypes[$typ])
+               {
+                       case 3:
+                               // struct
+                               $rs .= "<struct>\n";
+                               reset($val);
+                               while (list($key2, $val2) = each($val))
+                               {
+                                       $rs .= "<member>\n<name>{$key2}</name>\n";
+                                       $rs .= $this->serializeval($val2);
+                                       $rs .= "</member>\n";
+                               }
+                               $rs .= '</struct>';
+                       break;
+                       case 2:
+                               // array
+                               $rs .= "<array>\n<data>\n";
+                               for($i=0; $i < count($val); $i++)
+                               {
+                                       $rs .= $this->serializeval($val[$i]);
+                               }
+                               $rs.="</data>\n</array>\n";
+                               break;
+                       case 1:
+                               // others
+                               switch ($typ)
+                               {
+                                       case $this->xmlrpcBase64:
+                                               $rs .= "<{$typ}>" . base64_encode((string)$val) . "</{$typ}>\n";
+                                       break;
+                                       case $this->xmlrpcBoolean:
+                                               $rs .= "<{$typ}>" . ((bool)$val ? '1' : '0') . "</{$typ}>\n";
+                                       break;
+                                       case $this->xmlrpcString:
+                                               $rs .= "<{$typ}>" . htmlspecialchars((string)$val). "</{$typ}>\n";
+                                       break;
+                                       default:
+                                               $rs .= "<{$typ}>{$val}</{$typ}>\n";
+                                       break;
+                               }
+                       default:
+                       break;
+               }
+               return $rs;
+       }
+
+       function serialize_class()
+       {
+               return $this->serializeval($this);
+       }
+
+       function serializeval($o)
+       {
+               $ar = $o->me;
+               reset($ar);
+
+               list($typ, $val) = each($ar);
+               $rs = "<value>\n".$this->serializedata($typ, $val)."</value>\n";
+               return $rs;
+       }
+
+       function scalarval()
+       {
+               reset($this->me);
+               list($a,$b) = each($this->me);
+               return $b;
+       }
+
+
+       //-------------------------------------
+       // Encode time in ISO-8601 form.
+       //-------------------------------------
+
+       // Useful for sending time in XML-RPC
+
+       function iso8601_encode($time, $utc=0)
+       {
+               if ($utc == 1)
+               {
+                       $t = strftime("%Y%m%dT%H:%M:%S", $time);
+               }
+               else
+               {
+                       if (function_exists('gmstrftime'))
+                               $t = gmstrftime("%Y%m%dT%H:%M:%S", $time);
+                       else
+                               $t = strftime("%Y%m%dT%H:%M:%S", $time - date('Z'));
+               }
+               return $t;
+       }
+
+}
+// END XML_RPC_Values Class
+
+/* End of file Xmlrpc.php */
+/* Location: ./system/libraries/Xmlrpc.php */
\ No newline at end of file
diff --git a/system/libraries/Xmlrpcs.php b/system/libraries/Xmlrpcs.php
new file mode 100755 (executable)
index 0000000..9cd3321
--- /dev/null
@@ -0,0 +1,612 @@
+<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+/**
+ * CodeIgniter
+ *
+ * An open source application development framework for PHP 5.1.6 or newer
+ *
+ * @package            CodeIgniter
+ * @author             ExpressionEngine Dev Team
+ * @copyright  Copyright (c) 2008 - 2011, EllisLab, Inc.
+ * @license            http://codeigniter.com/user_guide/license.html
+ * @link               http://codeigniter.com
+ * @since              Version 1.0
+ * @filesource
+ */
+
+if ( ! function_exists('xml_parser_create'))
+{
+       show_error('Your PHP installation does not support XML');
+}
+
+if ( ! class_exists('CI_Xmlrpc'))
+{
+       show_error('You must load the Xmlrpc class before loading the Xmlrpcs class in order to create a server.');
+}
+
+// ------------------------------------------------------------------------
+
+/**
+ * XML-RPC server class
+ *
+ * @package            CodeIgniter
+ * @subpackage Libraries
+ * @category   XML-RPC
+ * @author             ExpressionEngine Dev Team
+ * @link               http://codeigniter.com/user_guide/libraries/xmlrpc.html
+ */
+class CI_Xmlrpcs extends CI_Xmlrpc
+{
+       var $methods            = array();      //array of methods mapped to function names and signatures
+       var $debug_msg          = '';           // Debug Message
+       var $system_methods = array();  // XML RPC Server methods
+       var $controller_obj;
+
+       var $object                     = FALSE;
+
+       /**
+        * Constructor
+        */
+       public function __construct($config=array())
+       {
+               parent::__construct();
+               $this->set_system_methods();
+
+               if (isset($config['functions']) && is_array($config['functions']))
+               {
+                       $this->methods = array_merge($this->methods, $config['functions']);
+               }
+
+               log_message('debug', "XML-RPC Server Class Initialized");
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Initialize Prefs and Serve
+        *
+        * @access      public
+        * @param       mixed
+        * @return      void
+        */
+       function initialize($config=array())
+       {
+               if (isset($config['functions']) && is_array($config['functions']))
+               {
+                       $this->methods = array_merge($this->methods, $config['functions']);
+               }
+
+               if (isset($config['debug']))
+               {
+                       $this->debug = $config['debug'];
+               }
+
+               if (isset($config['object']) && is_object($config['object']))
+               {
+                       $this->object = $config['object'];
+               }
+
+               if (isset($config['xss_clean']))
+               {
+                       $this->xss_clean = $config['xss_clean'];
+               }
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Setting of System Methods
+        *
+        * @access      public
+        * @return      void
+        */
+       function set_system_methods()
+       {
+               $this->methods = array(
+                                       'system.listMethods'     => array(
+                                                                                                       'function' => 'this.listMethods',
+                                                                                                       'signature' => array(array($this->xmlrpcArray, $this->xmlrpcString), array($this->xmlrpcArray)),
+                                                                                                       'docstring' => 'Returns an array of available methods on this server'),
+                                       'system.methodHelp'              => array(
+                                                                                                       'function' => 'this.methodHelp',
+                                                                                                       'signature' => array(array($this->xmlrpcString, $this->xmlrpcString)),
+                                                                                                       'docstring' => 'Returns a documentation string for the specified method'),
+                                       'system.methodSignature' => array(
+                                                                                                       'function' => 'this.methodSignature',
+                                                                                                       'signature' => array(array($this->xmlrpcArray, $this->xmlrpcString)),
+                                                                                                       'docstring' => 'Returns an array describing the return type and required parameters of a method'),
+                                       'system.multicall'               => array(
+                                                                                               'function' => 'this.multicall',
+                                                                                               'signature' => array(array($this->xmlrpcArray, $this->xmlrpcArray)),
+                                                                                               'docstring' => 'Combine multiple RPC calls in one request. See http://www.xmlrpc.com/discuss/msgReader$1208 for details')
+                                       );
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Main Server Function
+        *
+        * @access      public
+        * @return      void
+        */
+       function serve()
+       {
+               $r = $this->parseRequest();
+               $payload  = '<?xml version="1.0" encoding="'.$this->xmlrpc_defencoding.'"?'.'>'."\n";
+               $payload .= $this->debug_msg;
+               $payload .= $r->prepare_response();
+
+               header("Content-Type: text/xml");
+               header("Content-Length: ".strlen($payload));
+               exit($payload);
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * 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,
+                       'signature' => $sig,
+                       'docstring' => $doc
+               );
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Parse Server Request
+        *
+        * @access      public
+        * @param       string  data
+        * @return      object  xmlrpc response
+        */
+       function parseRequest($data='')
+       {
+               global $HTTP_RAW_POST_DATA;
+
+               //-------------------------------------
+               //  Get Data
+               //-------------------------------------
+
+               if ($data == '')
+               {
+                       $data = $HTTP_RAW_POST_DATA;
+               }
+
+               //-------------------------------------
+               //  Set up XML Parser
+               //-------------------------------------
+
+               $parser = xml_parser_create($this->xmlrpc_defencoding);
+               $parser_object = new XML_RPC_Message("filler");
+
+               $parser_object->xh[$parser]                                     = array();
+               $parser_object->xh[$parser]['isf']                      = 0;
+               $parser_object->xh[$parser]['isf_reason']       = '';
+               $parser_object->xh[$parser]['params']           = array();
+               $parser_object->xh[$parser]['stack']            = array();
+               $parser_object->xh[$parser]['valuestack']       = array();
+               $parser_object->xh[$parser]['method']           = '';
+
+               xml_set_object($parser, $parser_object);
+               xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, true);
+               xml_set_element_handler($parser, 'open_tag', 'closing_tag');
+               xml_set_character_data_handler($parser, 'character_data');
+               //xml_set_default_handler($parser, 'default_handler');
+
+
+               //-------------------------------------
+               //  PARSE + PROCESS XML DATA
+               //-------------------------------------
+
+               if ( ! xml_parse($parser, $data, 1))
+               {
+                       // return XML error as a faultCode
+                       $r = new XML_RPC_Response(0,
+                       $this->xmlrpcerrxml + xml_get_error_code($parser),
+                       sprintf('XML error: %s at line %d',
+                               xml_error_string(xml_get_error_code($parser)),
+                               xml_get_current_line_number($parser)));
+                       xml_parser_free($parser);
+               }
+               elseif ($parser_object->xh[$parser]['isf'])
+               {
+                       return new XML_RPC_Response(0, $this->xmlrpcerr['invalid_return'], $this->xmlrpcstr['invalid_return']);
+               }
+               else
+               {
+                       xml_parser_free($parser);
+
+                       $m = new XML_RPC_Message($parser_object->xh[$parser]['method']);
+                       $plist='';
+
+                       for ($i=0; $i < count($parser_object->xh[$parser]['params']); $i++)
+                       {
+                               if ($this->debug === TRUE)
+                               {
+                                       $plist .= "$i - " .  print_r(get_object_vars($parser_object->xh[$parser]['params'][$i]), TRUE). ";\n";
+                               }
+
+                               $m->addParam($parser_object->xh[$parser]['params'][$i]);
+                       }
+
+                       if ($this->debug === TRUE)
+                       {
+                               echo "<pre>";
+                               echo "---PLIST---\n" . $plist . "\n---PLIST END---\n\n";
+                               echo "</pre>";
+                       }
+
+                       $r = $this->_execute($m);
+               }
+
+               //-------------------------------------
+               //  SET DEBUGGING MESSAGE
+               //-------------------------------------
+
+               if ($this->debug === TRUE)
+               {
+                       $this->debug_msg = "<!-- DEBUG INFO:\n\n".$plist."\n END DEBUG-->\n";
+               }
+
+               return $r;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Executes the Method
+        *
+        * @access      protected
+        * @param       object
+        * @return      mixed
+        */
+       function _execute($m)
+       {
+               $methName = $m->method_name;
+
+               // Check to see if it is a system call
+               $system_call = (strncmp($methName, 'system', 5) == 0) ? TRUE : FALSE;
+
+               if ($this->xss_clean == FALSE)
+               {
+                       $m->xss_clean = FALSE;
+               }
+
+               //-------------------------------------
+               //  Valid Method
+               //-------------------------------------
+
+               if ( ! isset($this->methods[$methName]['function']))
+               {
+                       return new XML_RPC_Response(0, $this->xmlrpcerr['unknown_method'], $this->xmlrpcstr['unknown_method']);
+               }
+
+               //-------------------------------------
+               //  Check for Method (and Object)
+               //-------------------------------------
+
+               $method_parts = explode(".", $this->methods[$methName]['function']);
+               $objectCall = (isset($method_parts['1']) && $method_parts['1'] != "") ? TRUE : FALSE;
+
+               if ($system_call === TRUE)
+               {
+                       if ( ! is_callable(array($this,$method_parts['1'])))
+                       {
+                               return new XML_RPC_Response(0, $this->xmlrpcerr['unknown_method'], $this->xmlrpcstr['unknown_method']);
+                       }
+               }
+               else
+               {
+                       if ($objectCall && ! is_callable(array($method_parts['0'],$method_parts['1'])))
+                       {
+                               return new XML_RPC_Response(0, $this->xmlrpcerr['unknown_method'], $this->xmlrpcstr['unknown_method']);
+                       }
+                       elseif ( ! $objectCall && ! is_callable($this->methods[$methName]['function']))
+                       {
+                               return new XML_RPC_Response(0, $this->xmlrpcerr['unknown_method'], $this->xmlrpcstr['unknown_method']);
+                       }
+               }
+
+               //-------------------------------------
+               //  Checking Methods Signature
+               //-------------------------------------
+
+               if (isset($this->methods[$methName]['signature']))
+               {
+                       $sig = $this->methods[$methName]['signature'];
+                       for ($i=0; $i<count($sig); $i++)
+                       {
+                               $current_sig = $sig[$i];
+
+                               if (count($current_sig) == count($m->params)+1)
+                               {
+                                       for ($n=0; $n < count($m->params); $n++)
+                                       {
+                                               $p = $m->params[$n];
+                                               $pt = ($p->kindOf() == 'scalar') ? $p->scalarval() : $p->kindOf();
+
+                                               if ($pt != $current_sig[$n+1])
+                                               {
+                                                       $pno = $n+1;
+                                                       $wanted = $current_sig[$n+1];
+
+                                                       return new XML_RPC_Response(0,
+                                                               $this->xmlrpcerr['incorrect_params'],
+                                                               $this->xmlrpcstr['incorrect_params'] .
+                                                               ": Wanted {$wanted}, got {$pt} at param {$pno})");
+                                               }
+                                       }
+                               }
+                       }
+               }
+
+               //-------------------------------------
+               //  Calls the Function
+               //-------------------------------------
+
+               if ($objectCall === TRUE)
+               {
+                       if ($method_parts[0] == "this" && $system_call == TRUE)
+                       {
+                               return call_user_func(array($this, $method_parts[1]), $m);
+                       }
+                       else
+                       {
+                               if ($this->object === FALSE)
+                               {
+                                       $CI =& get_instance();
+                                       return $CI->$method_parts['1']($m);
+                               }
+                               else
+                               {
+                                       return $this->object->$method_parts['1']($m);
+                                       //return call_user_func(array(&$method_parts['0'],$method_parts['1']), $m);
+                               }
+                       }
+               }
+               else
+               {
+                       return call_user_func($this->methods[$methName]['function'], $m);
+               }
+       }
+       
+       // --------------------------------------------------------------------
+
+       /**
+        * 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)
+               {
+                       $output[] = new XML_RPC_Values($key, 'string');
+               }
+
+               foreach ($this->system_methods as $key => $value)
+               {
+                       $output[]= new XML_RPC_Values($key, 'string');
+               }
+
+               $v->addArray($output);
+               return new XML_RPC_Response($v);
+       }
+       
+       // --------------------------------------------------------------------
+
+       /**
+        * Server Function:  Return Signature for Method
+        *
+        * @access      public
+        * @param       mixed
+        * @return      object
+        */
+       function methodSignature($m)
+       {
+               $parameters = $m->output_parameters();
+               $method_name = $parameters[0];
+
+               if (isset($this->methods[$method_name]))
+               {
+                       if ($this->methods[$method_name]['signature'])
+                       {
+                               $sigs = array();
+                               $signature = $this->methods[$method_name]['signature'];
+
+                               for ($i=0; $i < count($signature); $i++)
+                               {
+                                       $cursig = array();
+                                       $inSig = $signature[$i];
+                                       for ($j=0; $j<count($inSig); $j++)
+                                       {
+                                               $cursig[]= new XML_RPC_Values($inSig[$j], 'string');
+                                       }
+                                       $sigs[]= new XML_RPC_Values($cursig, 'array');
+                               }
+                               $r = new XML_RPC_Response(new XML_RPC_Values($sigs, 'array'));
+                       }
+                       else
+                       {
+                               $r = new XML_RPC_Response(new XML_RPC_Values('undef', 'string'));
+                       }
+               }
+               else
+               {
+                       $r = new XML_RPC_Response(0,$this->xmlrpcerr['introspect_unknown'], $this->xmlrpcstr['introspect_unknown']);
+               }
+               return $r;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Server Function:  Doc String for Method
+        *
+        * @access      public
+        * @param       mixed
+        * @return      object
+        */
+       function methodHelp($m)
+       {
+               $parameters = $m->output_parameters();
+               $method_name = $parameters[0];
+
+               if (isset($this->methods[$method_name]))
+               {
+                       $docstring = isset($this->methods[$method_name]['docstring']) ? $this->methods[$method_name]['docstring'] : '';
+
+                       return new XML_RPC_Response(new XML_RPC_Values($docstring, 'string'));
+               }
+               else
+               {
+                       return new XML_RPC_Response(0, $this->xmlrpcerr['introspect_unknown'], $this->xmlrpcstr['introspect_unknown']);
+               }
+       }
+       
+       // --------------------------------------------------------------------
+
+       /**
+        * Server Function:  Multi-call
+        *
+        * @access      public
+        * @param       mixed
+        * @return      object
+        */
+       function multicall($m)
+       {
+               // Disabled
+               return new XML_RPC_Response(0, $this->xmlrpcerr['unknown_method'], $this->xmlrpcstr['unknown_method']);
+
+               $parameters = $m->output_parameters();
+               $calls = $parameters[0];
+
+               $result = array();
+
+               foreach ($calls as $value)
+               {
+                       //$attempt = $this->_execute(new XML_RPC_Message($value[0], $value[1]));
+
+                       $m = new XML_RPC_Message($value[0]);
+                       $plist='';
+
+                       for ($i=0; $i < count($value[1]); $i++)
+                       {
+                               $m->addParam(new XML_RPC_Values($value[1][$i], 'string'));
+                       }
+
+                       $attempt = $this->_execute($m);
+
+                       if ($attempt->faultCode() != 0)
+                       {
+                               return $attempt;
+                       }
+
+                       $result[] = new XML_RPC_Values(array($attempt->value()), 'array');
+               }
+
+               return new XML_RPC_Response(new XML_RPC_Values($result, 'array'));
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        *  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();
+               $code = is_string($err) ? $this->xmlrpcerr["multicall_${err}"] : $err->faultCode();
+
+               $struct['faultCode'] = new XML_RPC_Values($code, 'int');
+               $struct['faultString'] = new XML_RPC_Values($str, 'string');
+
+               return new XML_RPC_Values($struct, 'struct');
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        *  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);
+
+               $msg = new XML_RPC_Message($scalar_value);
+               for ($i = 0; $i < $numParams; $i++)
+               {
+                       $msg->params[] = $params->me['array'][$i];
+               }
+
+               $result = $this->_execute($msg);
+
+               if ($result->faultCode() != 0)
+               {
+                       return $this->multicall_error($result);
+               }
+
+               return new XML_RPC_Values(array($result->value()), 'array');
+       }
+
+}
+// END XML_RPC_Server class
+
+
+/* End of file Xmlrpcs.php */
+/* Location: ./system/libraries/Xmlrpcs.php */
\ No newline at end of file
diff --git a/system/libraries/Zip.php b/system/libraries/Zip.php
new file mode 100755 (executable)
index 0000000..666327d
--- /dev/null
@@ -0,0 +1,423 @@
+<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+/**
+ * CodeIgniter
+ *
+ * An open source application development framework for PHP 5.1.6 or newer
+ *
+ * @package            CodeIgniter
+ * @author             ExpressionEngine Dev Team
+ * @copyright  Copyright (c) 2008 - 2011, EllisLab, Inc.
+ * @license            http://codeigniter.com/user_guide/license.html
+ * @link               http://codeigniter.com
+ * @since              Version 1.0
+ * @filesource
+ */
+
+// ------------------------------------------------------------------------
+
+/**
+ * Zip Compression Class
+ *
+ * This class is based on a library I found at Zend:
+ * http://www.zend.com/codex.php?id=696&single=1
+ *
+ * The original library is a little rough around the edges so I
+ * refactored it and added several additional methods -- Rick Ellis
+ *
+ * @package            CodeIgniter
+ * @subpackage Libraries
+ * @category   Encryption
+ * @author             ExpressionEngine Dev Team
+ * @link               http://codeigniter.com/user_guide/libraries/zip.html
+ */
+class CI_Zip  {
+
+       var $zipdata    = '';
+       var $directory  = '';
+       var $entries    = 0;
+       var $file_num   = 0;
+       var $offset             = 0;
+       var $now;
+
+       /**
+        * Constructor
+        */
+       public function __construct()
+       {
+               log_message('debug', "Zip Compression Class Initialized");
+
+               $this->now = time();
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Add Directory
+        *
+        * Lets you add a virtual directory into which you can place files.
+        *
+        * @access      public
+        * @param       mixed   the directory name. Can be string or array
+        * @return      void
+        */
+       function add_dir($directory)
+       {
+               foreach ((array)$directory as $dir)
+               {
+                       if ( ! preg_match("|.+/$|", $dir))
+                       {
+                               $dir .= '/';
+                       }
+
+                       $dir_time = $this->_get_mod_time($dir);
+
+                       $this->_add_dir($dir, $dir_time['file_mtime'], $dir_time['file_mdate']);
+               }
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        *      Get file/directory modification time
+        *
+        *      If this is a newly created file/dir, we will set the time to 'now'
+        *
+        *      @param string   path to file
+        *      @return array   filemtime/filemdate
+        */
+       function _get_mod_time($dir)
+       {
+               // filemtime() will return false, but it does raise an error.
+               $date = (@filemtime($dir)) ? filemtime($dir) : getdate($this->now);
+
+               $time['file_mtime'] = ($date['hours'] << 11) + ($date['minutes'] << 5) + $date['seconds'] / 2;
+               $time['file_mdate'] = (($date['year'] - 1980) << 9) + ($date['mon'] << 5) + $date['mday'];
+
+               return $time;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Add Directory
+        *
+        * @access      private
+        * @param       string  the directory name
+        * @return      void
+        */
+       function _add_dir($dir, $file_mtime, $file_mdate)
+       {
+               $dir = str_replace("\\", "/", $dir);
+
+               $this->zipdata .=
+                       "\x50\x4b\x03\x04\x0a\x00\x00\x00\x00\x00"
+                       .pack('v', $file_mtime)
+                       .pack('v', $file_mdate)
+                       .pack('V', 0) // crc32
+                       .pack('V', 0) // compressed filesize
+                       .pack('V', 0) // uncompressed filesize
+                       .pack('v', strlen($dir)) // length of pathname
+                       .pack('v', 0) // extra field length
+                       .$dir
+                       // below is "data descriptor" segment
+                       .pack('V', 0) // crc32
+                       .pack('V', 0) // compressed filesize
+                       .pack('V', 0); // uncompressed filesize
+
+               $this->directory .=
+                       "\x50\x4b\x01\x02\x00\x00\x0a\x00\x00\x00\x00\x00"
+                       .pack('v', $file_mtime)
+                       .pack('v', $file_mdate)
+                       .pack('V',0) // crc32
+                       .pack('V',0) // compressed filesize
+                       .pack('V',0) // uncompressed filesize
+                       .pack('v', strlen($dir)) // length of pathname
+                       .pack('v', 0) // extra field length
+                       .pack('v', 0) // file comment length
+                       .pack('v', 0) // disk number start
+                       .pack('v', 0) // internal file attributes
+                       .pack('V', 16) // external file attributes - 'directory' bit set
+                       .pack('V', $this->offset) // relative offset of local header
+                       .$dir;
+
+               $this->offset = strlen($this->zipdata);
+               $this->entries++;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Add Data to Zip
+        *
+        * Lets you add files to the archive. If the path is included
+        * in the filename it will be placed within a directory.  Make
+        * sure you use add_dir() first to create the folder.
+        *
+        * @access      public
+        * @param       mixed
+        * @param       string
+        * @return      void
+        */
+       function add_data($filepath, $data = NULL)
+       {
+               if (is_array($filepath))
+               {
+                       foreach ($filepath as $path => $data)
+                       {
+                               $file_data = $this->_get_mod_time($path);
+
+                               $this->_add_data($path, $data, $file_data['file_mtime'], $file_data['file_mdate']);
+                       }
+               }
+               else
+               {
+                       $file_data = $this->_get_mod_time($filepath);
+
+                       $this->_add_data($filepath, $data, $file_data['file_mtime'], $file_data['file_mdate']);
+               }
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Add Data to Zip
+        *
+        * @access      private
+        * @param       string  the file name/path
+        * @param       string  the data to be encoded
+        * @return      void
+        */
+       function _add_data($filepath, $data, $file_mtime, $file_mdate)
+       {
+               $filepath = str_replace("\\", "/", $filepath);
+
+               $uncompressed_size = strlen($data);
+               $crc32  = crc32($data);
+
+               $gzdata = gzcompress($data);
+               $gzdata = substr($gzdata, 2, -4);
+               $compressed_size = strlen($gzdata);
+
+               $this->zipdata .=
+                       "\x50\x4b\x03\x04\x14\x00\x00\x00\x08\x00"
+                       .pack('v', $file_mtime)
+                       .pack('v', $file_mdate)
+                       .pack('V', $crc32)
+                       .pack('V', $compressed_size)
+                       .pack('V', $uncompressed_size)
+                       .pack('v', strlen($filepath)) // length of filename
+                       .pack('v', 0) // extra field length
+                       .$filepath
+                       .$gzdata; // "file data" segment
+
+               $this->directory .=
+                       "\x50\x4b\x01\x02\x00\x00\x14\x00\x00\x00\x08\x00"
+                       .pack('v', $file_mtime)
+                       .pack('v', $file_mdate)
+                       .pack('V', $crc32)
+                       .pack('V', $compressed_size)
+                       .pack('V', $uncompressed_size)
+                       .pack('v', strlen($filepath)) // length of filename
+                       .pack('v', 0) // extra field length
+                       .pack('v', 0) // file comment length
+                       .pack('v', 0) // disk number start
+                       .pack('v', 0) // internal file attributes
+                       .pack('V', 32) // external file attributes - 'archive' bit set
+                       .pack('V', $this->offset) // relative offset of local header
+                       .$filepath;
+
+               $this->offset = strlen($this->zipdata);
+               $this->entries++;
+               $this->file_num++;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Read the contents of a file and add it to the zip
+        *
+        * @access      public
+        * @return      bool
+        */
+       function read_file($path, $preserve_filepath = FALSE)
+       {
+               if ( ! file_exists($path))
+               {
+                       return FALSE;
+               }
+
+               if (FALSE !== ($data = file_get_contents($path)))
+               {
+                       $name = str_replace("\\", "/", $path);
+
+                       if ($preserve_filepath === FALSE)
+                       {
+                               $name = preg_replace("|.*/(.+)|", "\\1", $name);
+                       }
+
+                       $this->add_data($name, $data);
+                       return TRUE;
+               }
+               return FALSE;
+       }
+
+       // ------------------------------------------------------------------------
+
+       /**
+        * Read a directory and add it to the zip.
+        *
+        * This function recursively reads a folder and everything it contains (including
+        * sub-folders) and creates a zip based on it.  Whatever directory structure
+        * is in the original file path will be recreated in the zip file.
+        *
+        * @access      public
+        * @param       string  path to source
+        * @return      bool
+        */
+       function read_dir($path, $preserve_filepath = TRUE, $root_path = NULL)
+       {
+               if ( ! $fp = @opendir($path))
+               {
+                       return FALSE;
+               }
+
+               // Set the original directory root for child dir's to use as relative
+               if ($root_path === NULL)
+               {
+                       $root_path = dirname($path).'/';
+               }
+
+               while (FALSE !== ($file = readdir($fp)))
+               {
+                       if (substr($file, 0, 1) == '.')
+                       {
+                               continue;
+                       }
+
+                       if (@is_dir($path.$file))
+                       {
+                               $this->read_dir($path.$file."/", $preserve_filepath, $root_path);
+                       }
+                       else
+                       {
+                               if (FALSE !== ($data = file_get_contents($path.$file)))
+                               {
+                                       $name = str_replace("\\", "/", $path);
+
+                                       if ($preserve_filepath === FALSE)
+                                       {
+                                               $name = str_replace($root_path, '', $name);
+                                       }
+
+                                       $this->add_data($name.$file, $data);
+                               }
+                       }
+               }
+
+               return TRUE;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Get the Zip file
+        *
+        * @access      public
+        * @return      binary string
+        */
+       function get_zip()
+       {
+               // Is there any data to return?
+               if ($this->entries == 0)
+               {
+                       return FALSE;
+               }
+
+               $zip_data = $this->zipdata;
+               $zip_data .= $this->directory."\x50\x4b\x05\x06\x00\x00\x00\x00";
+               $zip_data .= pack('v', $this->entries); // total # of entries "on this disk"
+               $zip_data .= pack('v', $this->entries); // total # of entries overall
+               $zip_data .= pack('V', strlen($this->directory)); // size of central dir
+               $zip_data .= pack('V', strlen($this->zipdata)); // offset to start of central dir
+               $zip_data .= "\x00\x00"; // .zip file comment length
+
+               return $zip_data;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Write File to the specified directory
+        *
+        * Lets you write a file
+        *
+        * @access      public
+        * @param       string  the file name
+        * @return      bool
+        */
+       function archive($filepath)
+       {
+               if ( ! ($fp = @fopen($filepath, FOPEN_WRITE_CREATE_DESTRUCTIVE)))
+               {
+                       return FALSE;
+               }
+
+               flock($fp, LOCK_EX);
+               fwrite($fp, $this->get_zip());
+               flock($fp, LOCK_UN);
+               fclose($fp);
+
+               return TRUE;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Download
+        *
+        * @access      public
+        * @param       string  the file name
+        * @param       string  the data to be encoded
+        * @return      bool
+        */
+       function download($filename = 'backup.zip')
+       {
+               if ( ! preg_match("|.+?\.zip$|", $filename))
+               {
+                       $filename .= '.zip';
+               }
+
+               $CI =& get_instance();
+               $CI->load->helper('download');
+
+               $get_zip = $this->get_zip();
+
+               $zip_content =& $get_zip;
+
+               force_download($filename, $zip_content);
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Initialize Data
+        *
+        * Lets you clear current zip data.  Useful if you need to create
+        * multiple zips with different data.
+        *
+        * @access      public
+        * @return      void
+        */
+       function clear_data()
+       {
+               $this->zipdata          = '';
+               $this->directory        = '';
+               $this->entries          = 0;
+               $this->file_num         = 0;
+               $this->offset           = 0;
+       }
+
+}
+
+/* End of file Zip.php */
+/* Location: ./system/libraries/Zip.php */
\ No newline at end of file
diff --git a/system/libraries/index.html b/system/libraries/index.html
new file mode 100755 (executable)
index 0000000..c942a79
--- /dev/null
@@ -0,0 +1,10 @@
+<html>
+<head>
+       <title>403 Forbidden</title>
+</head>
+<body>
+
+<p>Directory access is forbidden.</p>
+
+</body>
+</html>
\ No newline at end of file
diff --git a/system/libraries/javascript/Jquery.php b/system/libraries/javascript/Jquery.php
new file mode 100755 (executable)
index 0000000..baab83d
--- /dev/null
@@ -0,0 +1,1071 @@
+<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+
+/**
+ * CodeIgniter
+ *
+ * An open source application development framework for PHP 4.3.2 or newer
+ *
+ * @package            CodeIgniter
+ * @author             ExpressionEngine Dev Team
+ * @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
+ * @filesource
+ */
+
+/**
+ * Jquery Class
+ *
+ * @package            CodeIgniter
+ * @subpackage Libraries
+ * @author             ExpressionEngine Dev Team
+ * @category   Loader
+ * @link               http://www.codeigniter.com/user_guide/libraries/javascript.html
+ */
+class CI_Jquery extends CI_Javascript {
+
+       var $_javascript_folder = 'js';
+       var $jquery_code_for_load = array();
+       var $jquery_code_for_compile = array();
+       var $jquery_corner_active = FALSE;
+       var $jquery_table_sorter_active = FALSE;
+       var $jquery_table_sorter_pager_active = FALSE;
+       var $jquery_ajax_img = '';
+
+       public function __construct($params)
+       {
+               $this->CI =& get_instance();    
+               extract($params);
+
+               if ($autoload === TRUE)
+               {
+                       $this->script();                        
+               }
+               
+               log_message('debug', "Jquery Class Initialized");
+       }
+       
+       // --------------------------------------------------------------------  
+       // Event Code
+       // -------------------------------------------------------------------- 
+
+       /**
+        * Blur
+        *
+        * Outputs a jQuery blur event
+        *
+        * @access      private
+        * @param       string  The element to attach the event to
+        * @param       string  The code to execute
+        * @return      string
+        */
+       function _blur($element = 'this', $js = '')
+       {
+               return $this->_add_event($element, $js, 'blur');
+       }
+       
+       // --------------------------------------------------------------------
+       
+       /**
+        * Change
+        *
+        * Outputs a jQuery change event
+        *
+        * @access      private
+        * @param       string  The element to attach the event to
+        * @param       string  The code to execute
+        * @return      string
+        */
+       function _change($element = 'this', $js = '')
+       {
+               return $this->_add_event($element, $js, 'change');
+       }
+       
+       // --------------------------------------------------------------------
+       
+       /**
+        * Click
+        *
+        * Outputs a jQuery click event
+        *
+        * @access      private
+        * @param       string  The element to attach the event to
+        * @param       string  The code to execute
+        * @param       boolean whether or not to return false
+        * @return      string
+        */
+       function _click($element = 'this', $js = '', $ret_false = TRUE)
+       {
+               if ( ! is_array($js))
+               {
+                       $js = array($js);
+               }
+
+               if ($ret_false)
+               {
+                       $js[] = "return false;";
+               }
+
+               return $this->_add_event($element, $js, 'click');
+       }
+
+       // --------------------------------------------------------------------
+       
+       /**
+        * Double Click
+        *
+        * Outputs a jQuery dblclick event
+        *
+        * @access      private
+        * @param       string  The element to attach the event to
+        * @param       string  The code to execute
+        * @return      string
+        */
+       function _dblclick($element = 'this', $js = '')
+       {
+               return $this->_add_event($element, $js, 'dblclick');
+       }
+
+       // --------------------------------------------------------------------
+       
+       /**
+        * Error
+        *
+        * Outputs a jQuery error event
+        *
+        * @access      private
+        * @param       string  The element to attach the event to
+        * @param       string  The code to execute
+        * @return      string
+        */
+       function _error($element = 'this', $js = '')
+       {
+               return $this->_add_event($element, $js, 'error');
+       }
+
+       // --------------------------------------------------------------------
+       
+       /**
+        * Focus
+        *
+        * Outputs a jQuery focus event
+        *
+        * @access      private
+        * @param       string  The element to attach the event to
+        * @param       string  The code to execute
+        * @return      string
+        */
+       function _focus($element = 'this', $js = '')
+       {
+               return $this->_add_event($element, $js, 'focus');
+       }
+
+       // --------------------------------------------------------------------
+       
+       /**
+        * Hover
+        *
+        * Outputs a jQuery hover event
+        *
+        * @access      private
+        * @param       string  - element
+        * @param       string  - Javascript code for mouse over
+        * @param       string  - Javascript code for mouse out
+        * @return      string
+        */
+       function _hover($element = 'this', $over, $out)
+       {
+               $event = "\n\t$(" . $this->_prep_element($element) . ").hover(\n\t\tfunction()\n\t\t{\n\t\t\t{$over}\n\t\t}, \n\t\tfunction()\n\t\t{\n\t\t\t{$out}\n\t\t});\n";
+
+               $this->jquery_code_for_compile[] = $event;
+
+               return $event;
+       }
+
+       // --------------------------------------------------------------------
+       
+       /**
+        * Keydown
+        *
+        * Outputs a jQuery keydown event
+        *
+        * @access      private
+        * @param       string  The element to attach the event to
+        * @param       string  The code to execute
+        * @return      string
+        */
+       function _keydown($element = 'this', $js = '')
+       {
+               return $this->_add_event($element, $js, 'keydown');
+       }
+
+       // --------------------------------------------------------------------
+       
+       /**
+        * Keyup
+        *
+        * Outputs a jQuery keydown event
+        *
+        * @access      private
+        * @param       string  The element to attach the event to
+        * @param       string  The code to execute
+        * @return      string
+        */
+       function _keyup($element = 'this', $js = '')
+       {
+               return $this->_add_event($element, $js, 'keyup');
+       }       
+
+       // --------------------------------------------------------------------
+       
+       /**
+        * Load
+        *
+        * Outputs a jQuery load event
+        *
+        * @access      private
+        * @param       string  The element to attach the event to
+        * @param       string  The code to execute
+        * @return      string
+        */
+       function _load($element = 'this', $js = '')
+       {
+               return $this->_add_event($element, $js, 'load');
+       }       
+       
+       // --------------------------------------------------------------------
+       
+       /**
+        * Mousedown
+        *
+        * Outputs a jQuery mousedown event
+        *
+        * @access      private
+        * @param       string  The element to attach the event to
+        * @param       string  The code to execute
+        * @return      string
+        */
+       function _mousedown($element = 'this', $js = '')
+       {
+               return $this->_add_event($element, $js, 'mousedown');
+       }
+
+       // --------------------------------------------------------------------
+       
+       /**
+        * Mouse Out
+        *
+        * Outputs a jQuery mouseout event
+        *
+        * @access      private
+        * @param       string  The element to attach the event to
+        * @param       string  The code to execute
+        * @return      string
+        */
+       function _mouseout($element = 'this', $js = '')
+       {
+               return $this->_add_event($element, $js, 'mouseout');
+       }
+
+       // --------------------------------------------------------------------
+       
+       /**
+        * Mouse Over
+        *
+        * Outputs a jQuery mouseover event
+        *
+        * @access      private
+        * @param       string  The element to attach the event to
+        * @param       string  The code to execute
+        * @return      string
+        */
+       function _mouseover($element = 'this', $js = '')
+       {
+               return $this->_add_event($element, $js, 'mouseover');
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Mouseup
+        *
+        * Outputs a jQuery mouseup event
+        *
+        * @access      private
+        * @param       string  The element to attach the event to
+        * @param       string  The code to execute
+        * @return      string
+        */
+       function _mouseup($element = 'this', $js = '')
+       {
+               return $this->_add_event($element, $js, 'mouseup');
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Output
+        *
+        * Outputs script directly
+        *
+        * @access      private
+        * @param       string  The element to attach the event to
+        * @param       string  The code to execute
+        * @return      string
+        */
+       function _output($array_js = '')
+       {
+               if ( ! is_array($array_js))
+               {
+                       $array_js = array($array_js);
+               }
+               
+               foreach ($array_js as $js)
+               {
+                       $this->jquery_code_for_compile[] = "\t$js\n";
+               }
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Resize
+        *
+        * Outputs a jQuery resize event
+        *
+        * @access      private
+        * @param       string  The element to attach the event to
+        * @param       string  The code to execute
+        * @return      string
+        */
+       function _resize($element = 'this', $js = '')
+       {
+               return $this->_add_event($element, $js, 'resize');
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Scroll
+        *
+        * Outputs a jQuery scroll event
+        *
+        * @access      private
+        * @param       string  The element to attach the event to
+        * @param       string  The code to execute
+        * @return      string
+        */
+       function _scroll($element = 'this', $js = '')
+       {
+               return $this->_add_event($element, $js, 'scroll');
+       }
+       
+       // --------------------------------------------------------------------
+
+       /**
+        * Unload
+        *
+        * Outputs a jQuery unload event
+        *
+        * @access      private
+        * @param       string  The element to attach the event to
+        * @param       string  The code to execute
+        * @return      string
+        */
+       function _unload($element = 'this', $js = '')
+       {
+               return $this->_add_event($element, $js, 'unload');
+       }
+
+       // --------------------------------------------------------------------  
+       // Effects
+       // -------------------------------------------------------------------- 
+       
+       /**
+        * Add Class
+        *
+        * Outputs a jQuery addClass event
+        *
+        * @access      private
+        * @param       string  - element
+        * @return      string
+        */
+       function _addClass($element = 'this', $class='')
+       {
+               $element = $this->_prep_element($element);
+               $str  = "$({$element}).addClass(\"$class\");";
+               return $str;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Animate
+        *
+        * Outputs a jQuery animate event
+        *
+        * @access      private
+        * @param       string  - element
+        * @param       string  - One of 'slow', 'normal', 'fast', or time in milliseconds
+        * @param       string  - Javascript callback function
+        * @return      string
+        */
+       function _animate($element = 'this', $params = array(), $speed = '', $extra = '')
+       {
+               $element = $this->_prep_element($element);
+               $speed = $this->_validate_speed($speed);
+               
+               $animations = "\t\t\t";
+               
+               foreach ($params as $param=>$value)
+               {
+                       $animations .= $param.': \''.$value.'\', ';
+               }
+
+               $animations = substr($animations, 0, -2); // remove the last ", "
+
+               if ($speed != '')
+               {
+                       $speed = ', '.$speed;
+               }
+               
+               if ($extra != '')
+               {
+                       $extra = ', '.$extra;
+               }
+               
+               $str  = "$({$element}).animate({\n$animations\n\t\t}".$speed.$extra.");";
+               
+               return $str;
+       }
+
+       // --------------------------------------------------------------------
+               
+       /**
+        * Fade In
+        *
+        * Outputs a jQuery hide event
+        *
+        * @access      private
+        * @param       string  - element
+        * @param       string  - One of 'slow', 'normal', 'fast', or time in milliseconds
+        * @param       string  - Javascript callback function
+        * @return      string
+        */
+       function _fadeIn($element = 'this', $speed = '', $callback = '')
+       {
+               $element = $this->_prep_element($element);      
+               $speed = $this->_validate_speed($speed);
+               
+               if ($callback != '')
+               {
+                       $callback = ", function(){\n{$callback}\n}";
+               }
+               
+               $str  = "$({$element}).fadeIn({$speed}{$callback});";
+               
+               return $str;
+       }
+               
+       // --------------------------------------------------------------------
+       
+       /**
+        * Fade Out
+        *
+        * Outputs a jQuery hide event
+        *
+        * @access      private
+        * @param       string  - element
+        * @param       string  - One of 'slow', 'normal', 'fast', or time in milliseconds
+        * @param       string  - Javascript callback function
+        * @return      string
+        */
+       function _fadeOut($element = 'this', $speed = '', $callback = '')
+       {
+               $element = $this->_prep_element($element);
+               $speed = $this->_validate_speed($speed);
+               
+               if ($callback != '')
+               {
+                       $callback = ", function(){\n{$callback}\n}";
+               }
+               
+               $str  = "$({$element}).fadeOut({$speed}{$callback});";
+               
+               return $str;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Hide
+        *
+        * Outputs a jQuery hide action
+        *
+        * @access      private
+        * @param       string  - element
+        * @param       string  - One of 'slow', 'normal', 'fast', or time in milliseconds
+        * @param       string  - Javascript callback function
+        * @return      string
+        */
+       function _hide($element = 'this', $speed = '', $callback = '')
+       {
+               $element = $this->_prep_element($element);      
+               $speed = $this->_validate_speed($speed);
+               
+               if ($callback != '')
+               {
+                       $callback = ", function(){\n{$callback}\n}";
+               }
+               
+               $str  = "$({$element}).hide({$speed}{$callback});";
+
+               return $str;
+       }
+       
+       // --------------------------------------------------------------------
+
+       /**
+        * Remove Class
+        *
+        * Outputs a jQuery remove class event
+        *
+        * @access      private
+        * @param       string  - element
+        * @return      string
+        */
+       function _removeClass($element = 'this', $class='')
+       {
+               $element = $this->_prep_element($element);
+               $str  = "$({$element}).removeClass(\"$class\");";
+               return $str;
+       }
+
+       // --------------------------------------------------------------------
+                       
+       /**
+        * Slide Up
+        *
+        * Outputs a jQuery slideUp event
+        *
+        * @access      private
+        * @param       string  - element
+        * @param       string  - One of 'slow', 'normal', 'fast', or time in milliseconds
+        * @param       string  - Javascript callback function
+        * @return      string
+        */
+       function _slideUp($element = 'this', $speed = '', $callback = '')
+       {
+               $element = $this->_prep_element($element);      
+               $speed = $this->_validate_speed($speed);
+               
+               if ($callback != '')
+               {
+                       $callback = ", function(){\n{$callback}\n}";
+               }
+               
+               $str  = "$({$element}).slideUp({$speed}{$callback});";
+               
+               return $str;
+       }
+               
+       // --------------------------------------------------------------------
+       
+       /**
+        * Slide Down
+        *
+        * Outputs a jQuery slideDown event
+        *
+        * @access      private
+        * @param       string  - element
+        * @param       string  - One of 'slow', 'normal', 'fast', or time in milliseconds
+        * @param       string  - Javascript callback function
+        * @return      string
+        */
+       function _slideDown($element = 'this', $speed = '', $callback = '')
+       {
+               $element = $this->_prep_element($element);
+               $speed = $this->_validate_speed($speed);
+               
+               if ($callback != '')
+               {
+                       $callback = ", function(){\n{$callback}\n}";
+               }
+               
+               $str  = "$({$element}).slideDown({$speed}{$callback});";
+               
+               return $str;
+       }
+
+       // --------------------------------------------------------------------
+       
+       /**
+        * Slide Toggle
+        *
+        * Outputs a jQuery slideToggle event
+        *
+        * @access      public
+        * @param       string  - element
+        * @param       string  - One of 'slow', 'normal', 'fast', or time in milliseconds
+        * @param       string  - Javascript callback function
+        * @return      string
+        */
+       function _slideToggle($element = 'this', $speed = '', $callback = '')
+       {
+               $element = $this->_prep_element($element);
+               $speed = $this->_validate_speed($speed);
+               
+               if ($callback != '')
+               {
+                       $callback = ", function(){\n{$callback}\n}";
+               }
+               
+               $str  = "$({$element}).slideToggle({$speed}{$callback});";
+               
+               return $str;
+       }
+               
+       // --------------------------------------------------------------------
+       
+       /**
+        * Toggle
+        *
+        * Outputs a jQuery toggle event
+        *
+        * @access      private
+        * @param       string  - element
+        * @return      string
+        */
+       function _toggle($element = 'this')
+       {
+               $element = $this->_prep_element($element);
+               $str  = "$({$element}).toggle();";
+               return $str;
+       }
+       
+       // --------------------------------------------------------------------
+       
+       /**
+        * Toggle Class
+        *
+        * Outputs a jQuery toggle class event
+        *
+        * @access      private
+        * @param       string  - element
+        * @return      string
+        */
+       function _toggleClass($element = 'this', $class='')
+       {
+               $element = $this->_prep_element($element);
+               $str  = "$({$element}).toggleClass(\"$class\");";
+               return $str;
+       }
+       
+       // --------------------------------------------------------------------
+       
+       /**
+        * Show
+        *
+        * Outputs a jQuery show event
+        *
+        * @access      private
+        * @param       string  - element
+        * @param       string  - One of 'slow', 'normal', 'fast', or time in milliseconds
+        * @param       string  - Javascript callback function
+        * @return      string
+        */
+       function _show($element = 'this', $speed = '', $callback = '')
+       {
+               $element = $this->_prep_element($element);      
+               $speed = $this->_validate_speed($speed);
+               
+               if ($callback != '')
+               {
+                       $callback = ", function(){\n{$callback}\n}";
+               }
+               
+               $str  = "$({$element}).show({$speed}{$callback});";
+               
+               return $str;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Updater
+        *
+        * An Ajax call that populates the designated DOM node with 
+        * returned content
+        *
+        * @access      private
+        * @param       string  The element to attach the event to
+        * @param       string  the controller to run the call against
+        * @param       string  optional parameters
+        * @return      string
+        */
+       
+       function _updater($container = 'this', $controller, $options = '')
+       {       
+               $container = $this->_prep_element($container);
+               
+               $controller = (strpos('://', $controller) === FALSE) ? $controller : $this->CI->config->site_url($controller);
+               
+               // ajaxStart and ajaxStop are better choices here... but this is a stop gap
+               if ($this->CI->config->item('javascript_ajax_img') == '')
+               {
+                       $loading_notifier = "Loading...";
+               }
+               else
+               {
+                       $loading_notifier = '<img src=\'' . $this->CI->config->slash_item('base_url') . $this->CI->config->item('javascript_ajax_img') . '\' alt=\'Loading\' />';
+               }
+               
+               $updater = "$($container).empty();\n"; // anything that was in... get it out
+               $updater .= "\t\t$($container).prepend(\"$loading_notifier\");\n"; // to replace with an image
+
+               $request_options = '';
+               if ($options != '')
+               {
+                       $request_options .= ", {";
+                       $request_options .= (is_array($options)) ? "'".implode("', '", $options)."'" : "'".str_replace(":", "':'", $options)."'";
+                       $request_options .= "}";
+               }
+
+               $updater .= "\t\t$($container).load('$controller'$request_options);";
+               return $updater;
+       }
+
+
+       // --------------------------------------------------------------------
+       // Pre-written handy stuff
+       // --------------------------------------------------------------------
+        
+       /**
+        * Zebra tables
+        *
+        * @access      private
+        * @param       string  table name
+        * @param       string  plugin location
+        * @return      string
+        */
+       function _zebraTables($class = '', $odd = 'odd', $hover = '')
+       {
+               $class = ($class != '') ? '.'.$class : '';
+               
+               $zebra  = "\t\$(\"table{$class} tbody tr:nth-child(even)\").addClass(\"{$odd}\");";
+
+               $this->jquery_code_for_compile[] = $zebra;
+
+               if ($hover != '')
+               {
+                       $hover = $this->hover("table{$class} tbody tr", "$(this).addClass('hover');", "$(this).removeClass('hover');");
+               }
+
+               return $zebra;
+       }
+
+
+
+       // --------------------------------------------------------------------
+       // Plugins
+       // --------------------------------------------------------------------
+       
+       /**
+        * Corner Plugin
+        *
+        * http://www.malsup.com/jquery/corner/
+        *
+        * @access      public
+        * @param       string  target
+        * @return      string
+        */
+       function corner($element = '', $corner_style = '')
+       {
+               // may want to make this configurable down the road
+               $corner_location = '/plugins/jquery.corner.js';
+
+               if ($corner_style != '')
+               {
+                       $corner_style = '"'.$corner_style.'"';
+               }
+
+               return "$(" . $this->_prep_element($element) . ").corner(".$corner_style.");";
+       }
+       
+       // --------------------------------------------------------------------
+
+       /**
+        * modal window
+        *
+        * Load a thickbox modal window
+        *
+        * @access      public
+        * @return      void
+        */
+       function modal($src, $relative = FALSE)
+       {       
+               $this->jquery_code_for_load[] = $this->external($src, $relative);
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Effect
+        *
+        * Load an Effect library
+        *
+        * @access      public
+        * @return      void
+        */
+       function effect($src, $relative = FALSE)
+       {
+               $this->jquery_code_for_load[] = $this->external($src, $relative);
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Plugin
+        *
+        * Load a plugin library
+        *
+        * @access      public
+        * @return      void
+        */
+       function plugin($src, $relative = FALSE)
+       {
+               $this->jquery_code_for_load[] = $this->external($src, $relative);
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * UI
+        *
+        * Load a user interface library
+        *
+        * @access      public
+        * @return      void
+        */
+       function ui($src, $relative = FALSE)
+       {
+               $this->jquery_code_for_load[] = $this->external($src, $relative);
+       }
+       // --------------------------------------------------------------------
+
+       /**
+        * Sortable
+        *
+        * Creates a jQuery sortable
+        *
+        * @access      public
+        * @return      void
+        */
+       function sortable($element, $options = array())
+       {
+
+               if (count($options) > 0)
+               {
+                       $sort_options = array();
+                       foreach ($options as $k=>$v)
+                       {
+                               $sort_options[] = "\n\t\t".$k.': '.$v."";
+                       }
+                       $sort_options = implode(",", $sort_options);
+               }
+               else
+               {
+                       $sort_options = '';
+               }
+
+               return "$(" . $this->_prep_element($element) . ").sortable({".$sort_options."\n\t});";
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Table Sorter Plugin
+        *
+        * @access      public
+        * @param       string  table name
+        * @param       string  plugin location
+        * @return      string
+        */
+       function tablesorter($table = '', $options = '')
+       {
+               $this->jquery_code_for_compile[] = "\t$(" . $this->_prep_element($table) . ").tablesorter($options);\n";
+       }
+       
+       // --------------------------------------------------------------------
+       // Class functions
+       // --------------------------------------------------------------------
+
+       /**
+        * Add Event
+        *
+        * Constructs the syntax for an event, and adds to into the array for compilation
+        *
+        * @access      private
+        * @param       string  The element to attach the event to
+        * @param       string  The code to execute
+        * @param       string  The event to pass
+        * @return      string
+        */     
+       function _add_event($element, $js, $event)
+       {
+               if (is_array($js))
+               {
+                       $js = implode("\n\t\t", $js);
+
+               }
+
+               $event = "\n\t$(" . $this->_prep_element($element) . ").{$event}(function(){\n\t\t{$js}\n\t});\n";
+               $this->jquery_code_for_compile[] = $event;
+               return $event;
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Compile
+        *
+        * As events are specified, they are stored in an array
+        * This funciton compiles them all for output on a page
+        *
+        * @access      private
+        * @return      string
+        */
+       function _compile($view_var = 'script_foot', $script_tags = TRUE)
+       {
+               // External references
+               $external_scripts = implode('', $this->jquery_code_for_load);
+               $this->CI->load->vars(array('library_src' => $external_scripts));
+
+               if (count($this->jquery_code_for_compile) == 0 )
+               {
+                       // no inline references, let's just return
+                       return;
+               }
+
+               // Inline references
+               $script = '$(document).ready(function() {' . "\n";
+               $script .= implode('', $this->jquery_code_for_compile);
+               $script .= '});';
+               
+               $output = ($script_tags === FALSE) ? $script : $this->inline($script);
+
+               $this->CI->load->vars(array($view_var => $output));
+
+       }
+       
+       // --------------------------------------------------------------------
+       
+       /**
+        * Clear Compile
+        *
+        * Clears the array of script events collected for output
+        *
+        * @access      public
+        * @return      void
+        */
+       function _clear_compile()
+       {
+               $this->jquery_code_for_compile = array();
+       }
+
+       // --------------------------------------------------------------------
+       
+       /**
+        * Document Ready
+        *
+        * A wrapper for writing document.ready()
+        *
+        * @access      private
+        * @return      string
+        */
+       function _document_ready($js)
+       {
+               if ( ! is_array($js))
+               {
+                       $js = array ($js);
+
+               }
+               
+               foreach ($js as $script)
+               {
+                       $this->jquery_code_for_compile[] = $script;
+               }
+       }
+
+       // --------------------------------------------------------------------
+
+       /**
+        * Script Tag
+        *
+        * Outputs the script tag that loads the jquery.js file into an HTML document
+        *
+        * @access      public
+        * @param       string
+        * @return      string
+        */
+       function script($library_src = '', $relative = FALSE)
+       {
+               $library_src = $this->external($library_src, $relative);
+               $this->jquery_code_for_load[] = $library_src;
+               return $library_src;
+       }
+       
+       // --------------------------------------------------------------------
+
+       /**
+        * Prep Element
+        *
+        * Puts HTML element in quotes for use in jQuery code
+        * unless the supplied element is the Javascript 'this'
+        * object, in which case no quotes are added
+        *
+        * @access      public
+        * @param       string
+        * @return      string
+        */
+       function _prep_element($element)
+       {
+               if ($element != 'this')
+               {
+                       $element = '"'.$element.'"';
+               }
+               
+               return $element;
+       }
+       
+       // --------------------------------------------------------------------
+
+       /**
+        * Validate Speed
+        *
+        * Ensures the speed parameter is valid for jQuery
+        *
+        * @access      private
+        * @param       string
+        * @return      string
+        */     
+       function _validate_speed($speed)
+       {
+               if (in_array($speed, array('slow', 'normal', 'fast')))
+               {
+                       $speed = '"'.$speed.'"';
+               }
+               elseif (preg_match("/[^0-9]/", $speed))
+               {
+                       $speed = '';
+               }
+       
+               return $speed;
+       }
+
+}
+
+/* End of file Jquery.php */
+/* Location: ./system/libraries/Jquery.php */
\ No newline at end of file
diff --git a/user_guide/changelog.html b/user_guide/changelog.html
new file mode 100755 (executable)
index 0000000..f24d811
--- /dev/null
@@ -0,0 +1,1314 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head>
+
+<style type='text/css' media='all'>@import url('userguide.css');</style>
+<link rel='stylesheet' type='text/css' media='all' href='userguide.css' />
+
+<script type="text/javascript" src="./nav/nav.js"></script>
+<script type="text/javascript" src="./nav/prototype.lite.js"></script>
+<script type="text/javascript" src="./nav/moo.fx.js"></script>
+<script type="text/javascript" src="./nav/user_guide_menu.js"></script>
+
+<meta http-equiv='expires' content='-1' />
+<meta http-equiv= 'pragma' content='no-cache' />
+<meta name='robots' content='all' />
+<meta name='author' content='ExpressionEngine Dev Team' />
+<meta name='description' content='CodeIgniter User Guide' />
+
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+<title>Change Log : CodeIgniter User Guide</title>
+
+</head>
+<body>
+
+<!-- START NAVIGATION -->
+<div id="nav"><div id="nav_inner"><script type="text/javascript">create_menu('./');</script></div></div>
+<div id="nav2"><a name="top"></a><a href="javascript:void(0);" onclick="myHeight.toggle();"><img src="./images/nav_toggle_darker.jpg" width="154" height="43" border="0" title="Toggle Table of Contents" alt="Toggle Table of Contents" /></a></div>
+<div id="masthead">
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td><h1>CodeIgniter User Guide Version 2.0.2</h1></td>
+<td id="breadcrumb_right"><a href="./toc.html">Table of Contents Page</a></td>
+</tr>
+</table>
+</div>
+<!-- END NAVIGATION -->
+
+
+<!-- START BREADCRUMB -->
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td id="breadcrumb">
+<a href="http://codeigniter.com/">CodeIgniter Home</a> &nbsp;&#8250;&nbsp;
+<a href="index.html">User Guide Home</a> &nbsp;&#8250;&nbsp;
+Change Log
+</td>
+<td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="codeigniter.com/user_guide/" />Search User Guide&nbsp; <input type="text" class="input" style="width:200px;" name="q" id="q" size="31" maxlength="255" value="" />&nbsp;<input type="submit" class="submit" name="sa" value="Go" /></form></td>
+</tr>
+</table>
+<!-- END BREADCRUMB -->
+
+<br clear="all" />
+
+
+<!-- START CONTENT -->
+<div id="content">
+
+<h1>Change Log</h1>
+
+<p>The <img src="images/reactor-bullet.png" width="16" height="16" alt="Reactor Marker" /> indicates items that were contributed to CodeIgniter via CodeIgniter Reactor.</p>
+
+<h2>Version 2.0.2</h2>
+<p>Release Date: April 7, 2011<br />
+Hg Tag: v2.0.2</p>
+
+<ul>
+       <li>General changes
+               <ul>
+                       <li>The <a href="./libraries/security.html">Security library</a> was moved to the core and is now loaded automatically. Please remove your loading calls.</li>
+                       <li>The CI_SHA class is now deprecated. All supported versions of PHP provide a <kbd>sha1()</kbd> function.</li>
+                       <li class="reactor"><kbd>constants.php</kbd> will now be loaded from the environment folder if available.</li>
+                       <li class="reactor">Added language key error logging</li>
+                       <li class="reactor">Made Environment Support optional. Comment out or delete the constant to stop environment checks.</li>
+                       <li class="reactor">Added Environment Support for Hooks.</li>
+                       <li class="reactor">Added CI_ Prefix to the <a href="libraries/caching.html">Cache driver</a>.</li>
+                       <li class="reactor">Added <a href="./general/cli.html">CLI usage</a> documentation.</li>
+               </ul>
+       </li>
+       <li>Helpers
+               <ul>
+                       <li>Removed the previously deprecated <kbd>dohash()</kbd> from the <a href="./helpers/security_helper.html">Security helper</a>; use <kbd>do_hash()</kbd> instead.</li>
+                       <li class="reactor">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.</li>
+               </ul>
+       </li>
+       <li>Database
+               <ul>
+                       <li class="reactor"><kbd>$this->db->count_all_results()</kbd> will now return an integer instead of a string.</li>
+               </ul>
+       </li>
+</ul>
+
+<h3>Bug fixes for 2.0.2</h3>
+<ul>
+       <li class="reactor">Fixed a bug (Reactor #145) where the Output Library had parse_exec_vars set to protected.</li>
+       <li class="reactor">Fixed a bug (Reactor #80) where is_really_writable would create an empty file when on Windows or with safe_mode enabled.</li>
+       <li class="reactor">Fixed various bugs with User Guide.</li>
+       <li class="reactor">Added is_cli_request() method to documentation for <a href="libraries/input.html">Input class</a>.</li>
+       <li class="reactor">Added form_validation_lang entries for <kbd>decimal</kbd>, <kbd>less_than</kbd> and <kbd>greater_than</kbd>.</li>
+       <li class="reactor"><a href="https://bitbucket.org/ellislab/codeigniter-reactor/issue/153/escape-str-bug-in-mssql-driver">Fixed issue #153</a> Escape Str Bug in MSSQL driver.</li>
+       <li class="reactor"><a href="https://bitbucket.org/ellislab/codeigniter-reactor/issue/172/bug-in-chrome-and-form_open-in-201">Fixed issue #172</a> Google Chrome 11 posts incorrectly when action is empty.</li>
+
+</ul>
+
+<h2>Version 2.0.1</h2>
+<p>Release Date: March 15, 2011<br />
+Hg Tag: v2.0.1</p>
+
+<ul>
+       <li>General changes
+               <ul>
+                       <li>Added <kbd>$config['cookie_secure']</kbd> to the config file to allow requiring a secure (HTTPS) in order to set cookies.</li>
+                       <li class="reactor">Added the constant <kbd>CI_CORE</kbd> to help differentiate between Core: TRUE and Reactor: FALSE.</li>
+                       <li class="reactor">Added an <kbd>ENVIRONMENT</kbd> constant in index.php, which affects PHP error reporting settings, and optionally,
+                which configuration files are loaded (see below). Read more on the <a href="general/environments.html">Handling Environments</a> page.</li>
+                       <li class="reactor">Added support for <a href="libraries/config.html#environments">environment-specific</a> configuration files.</li>
+               </ul>
+       </li>
+       <li>Libraries
+               <ul>
+                       <li class="reactor">Added <kbd>decimal</kbd>, <kbd>less_than</kbd> and <kbd>greater_than</kbd> rules to the <a href="libraries/form_validation.html">Form validation Class</a>.</li>
+                       <li class="reactor"><a href="libraries/input.html">Input Class</a> methods <kbd>post()</kbd> and <kbd>get()</kbd> will now return a full array if the first argument is not provided.</li>
+                       <li class="reactor">Secure cookies can now be made with the <kbd>set_cookie()</kbd> helper and <a href="libraries/input.html">Input Class</a> method.</li>
+                       <li class="reactor">Added <kbd>set_content_type()</kbd> to <a href="libraries/output.html">Output Class</a> to set the output <kbd>Content-Type</kbd> HTTP header based on a MIME Type or a config/mimes.php array key.</li>
+                       <li class="reactor"><a href="libraries/output.html">Output Class</a> will now support method chaining.</li>
+               </ul>
+       </li>
+       <li>Helpers
+               <ul>
+                       <li class="reactor">Changed the logic for <kbd>form_open()</kbd> in <a href="helpers/form_helper.html">Form helper</a>. If no value is passed it will submit to the current URL.</li>
+               </ul>
+       </li>
+</ul>
+
+<h3>Bug fixes for 2.0.1</h3>
+<ul>
+       <li class="reactor">CLI requests can now be run from any folder, not just when CD'ed next to index.php.</li>
+       <li class="reactor">Fixed issue #41: Added audio/mp3 mime type to mp3.</li>
+       <li class="reactor">Fixed a bug (Core #329) where the file caching driver referenced the incorrect cache directory.</li>
+       <li class="reactor">Fixed a bug (Reactor #69) where the SHA1 library was named incorrectly.</li>
+</ul>
+
+<h2>Version 2.0.0</h2>
+<p>Release Date: January 28, 2011<br />
+Hg Tag: v2.0.0</p>
+
+<ul>
+       <li>General changes
+               <ul>
+                       <li>PHP 4 support is removed. CodeIgniter now requires PHP 5.1.6.</li>
+                       <li>Scaffolding, having been deprecated for a number of versions, has been removed.</li>
+                       <li>Plugins have been removed, in favor of Helpers.  The CAPTCHA plugin has been converted to a Helper and <a href="./helpers/captcha_helper.html">documented</a>.  The JavaScript calendar plugin was removed due to the ready availability of great JavaScript calendars, particularly with jQuery.</li>
+                       <li>Added new special Library type: <a href="./general/drivers.html">Drivers</a>.</li>
+                       <li class="reactor">Added full query-string support.  See the config file for details.</li>
+                       <li>Moved the application folder outside of the system folder.</li>
+                       <li>Moved system/cache and system/logs directories to the application directory.</li>
+                       <li>Added routing overrides to the main index.php file, enabling the normal routing to be overridden on a per "index" file basis.</li>
+                       <li>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.</li>
+                       <li>Added <kbd>$config['directory_trigger']</kbd> to the config file so that a controller sub-directory can be specified when running _GET strings instead of URI segments.</li>
+                       <li>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 <a href="libraries/loader.html">Loader class</a> documentation for more details.</li>
+                       <li>In-development code is now hosted at <a href="http://bitbucket.org/ellislab/codeigniter-reactor/">BitBucket</a>.</li>
+                       <li>Removed the deprecated Validation Class.</li>
+                       <li>Added CI_ Prefix to all core classes.</li>
+                       <li class="reactor">Package paths can now be set in application/config/autoload.php.</li>
+                       <li class="reactor"><a href="libraries/file_uploading.html">Upload library</a> file_name can now be set without an extension, the extension will be taken from the uploaded file instead of the given name.</li>
+                       <li class="reactor">In <a href="database/forge.html">Database Forge</a> the name can be omitted from $this->dbforge->modify_column()'s 2nd param if you aren't changing the name.</li>
+                       <li class="reactor"><kbd>$config['base_url']</kbd> is now empty by default and will guess what it should be.</li>
+                       <li class="reactor">Enabled full Command Line Interface compatibility with <kbd>config['uri_protocol'] = 'CLI';</kbd>.</li>
+               </ul>
+       <li>Libraries
+               <ul>
+                       <li class="reactor">Added a <a href="libraries/caching.html">Cache driver</a> with APC, memcached, and file-based support.</li>
+                       <li>Added <var>$prefix</var>, <var>$suffix</var> and <var>$first_url</var> properties to <a href="./libraries/pagination.html">Pagination library</a>.</li>
+                       <li>Added the ability to suppress first, previous, next, last, and page links by setting their values to FALSE in the <a href="./libraries/pagination.html">Pagination library</a>.</li>
+                       <li>Added <a href="./libraries/security.html">Security library</a>, which now contains the <dfn>xss_clean</dfn> function, <dfn>filename_security</dfn> function and other security related functions.</li>
+                       <li>Added CSRF (Cross-site Reference Forgery) protection to the <a href="./libraries/security.html">Security library</a>.</li>
+                       <li>Added <var>$parse_exec_vars</var> property to Output library.</li>
+                       <li>Added ability to enable / disable individual sections of the <a href="general/profiling.html">Profiler</a></li>
+                       <li>Added a wildcard option <kbd>$config['allowed_types'] = '*'</kbd> to the <a href="./libraries/file_uploading.html">File Uploading Class</a>.</li>
+                       <li>Added an 'object' config variable to the XML-RPC Server library so that one can specify the object to look for requested methods, instead of assuming it is in the $CI superobject.</li>
+                       <li>Added "is_object" into the list of unit tests capable of being run.</li>
+                       <li>Table library will generate an empty cell with a blank string, or NULL value.</li>
+                       <li>Added ability to set tag attributes for individual cells in the Table library</li>
+                       <li>Added a <kbd>parse_string()</kbd> method to the <a href="libraries/parser.html">Parser Class</a>.</li>
+                       <li>Added HTTP headers and Config information to the <a href="general/profiling.html">Profiler</a> output.</li>
+                       <li>Added Chrome and Flock to the list of detectable browsers by <kbd>browser()</kbd> in the <a href="libraries/user_agent.html">User Agent Class</a>.</li>
+                       <li>The <a href="libraries/unit_testing.html">Unit Test Class</a> now has an optional "notes" field available to it, and allows for discrete display of test result items using <kbd>$this->unit->set_test_items()</kbd>.</li>
+                       <li>Added a <kbd>$xss_clean</kbd> class variable to the XMLRPC library, enabling control over the use of the Security library's <kbd>xss_clean()</kbd> method.</li>
+                       <li>Added a <kbd>download()</kbd> method to the <a href="libraries/ftp.html">FTP library</a></li>
+                       <li>Changed <kbd>do_xss_clean()</kbd> to return FALSE if the uploaded file fails XSS checks.</li>
+                       <li>Added stripslashes() and trim()ing of double quotes from $_FILES type value to standardize input in Upload library.</li>
+                       <li>Added a second parameter (boolean) to <kbd>$this->zip->read_dir('/path/to/directory', FALSE)</kbd> to remove the preceding trail of empty folders when creating a Zip archive. This example would contain a zip with "directory" and all of its contents.</li>
+                       <li>Added ability in the Image Library to handle PNG transparency for resize operations when using the GD lib.</li>
+                       <li>Modified the Session class to prevent use if no encryption key is set in the config file.</li>
+                       <li>Added a new config item to the Session class <kbd>sess_expire_on_close</kbd> to allow sessions to auto-expire when the browser window is closed.</li>
+                       <li>Improved performance of the Encryption library on servers where Mcrypt is available.</li>
+                       <li>Changed the default encryption mode in the Encryption library to CBC.</li>
+                       <li>Added an <kbd>encode_from_legacy()</kbd> method to provide a way to transition encrypted data from CodeIgniter 1.x to CodeIgniter 2.x.
+                               Please see the <a href="./installation/upgrade_200.html">upgrade instructions</a> for details.</li>
+                       <li>Altered Form_Validation library to allow for method chaining on <kbd>set_rules()</kbd>, <kbd>set_message()</kbd> and <kbd>set_error_delimiters()</kbd> functions.</li>
+                       <li>Altered Email Library to allow for method chaining.</li>
+                       <li>Added <kbd>request_headers()</kbd>, <kbd>get_request_header()</kbd> and <kbd>is_ajax_request()</kbd> to the input class.</li>
+                       <li class="reactor">Altered <a href="libraries/user_agent.html">User agent library</a> so that <kbd>is_browser()</kbd>, <kbd>is_mobile()</kbd> and <kbd>is_robot()</kbd> can optionally check for a specific browser or mobile device.</li>
+                       <li class="reactor">Altered <a href="libraries/input.html">Input library</a> so that <kbd>post()</kbd> and <kbd>get()</kbd> will return all POST and GET items (respectively) if there are no parameters passed in.</li>
+               </ul>
+       </li>
+       <li>Database
+               <ul>
+                       <li><a href="./database/configuration.html">database configuration</a>.</li>
+                       <li>Added <kbd>autoinit</kbd> value to <a href="./database/configuration.html">database configuration</a>.</li>
+                       <li>Added <kbd>stricton</kbd> value to <a href="./database/configuration.html">database configuration</a>.</li>
+                       <li>Added <kbd>database_exists()</kbd> to the <a href="database/utilities.html">Database Utilities Class</a>.</li>
+                       <li>Semantic change to db->version() function to allow a list of exceptions for databases with functions to return version string instead of specially formed SQL queries. Currently this list only includes Oracle and SQLite.</li>
+                       <li>Fixed a bug where driver specific table identifier protection could lead to malformed queries in the <kbd>field_data()</kbd> functions.</li>
+                       <li>Fixed a bug where an undefined class variable was referenced in database drivers.</li>
+                       <li>Modified the database errors to show the filename and line number of the problematic query.</li>
+                       <li>Removed the following deprecated functions: orwhere, orlike, groupby, orhaving, orderby, getwhere.</li>
+                       <li>Removed deprecated _drop_database() and _create_database() functions from the db utility drivers.</li>
+                       <li>Improved dbforge create_table() function for the Postgres driver.</li>
+               </ul>
+       </li>
+       <li>Helpers
+               <ul>
+                       <li>Added <kbd>convert_accented_characters()</kbd> function to <a href="./helpers/text_helper.html">text helper</a>.</li>
+                       <li>Added accept-charset to the list of inserted attributes of <kbd>form_open()</kbd> in the <a href="helpers/form_helper.html">Form Helper</a>.</li>
+                       <li>Deprecated the <kbd>dohash()</kbd> function in favour of <kbd>do_hash()</kbd> for naming consistency.</li>
+                       <li>Non-backwards compatible change made to <kbd>get_dir_file_info()</kbd> in the <a href="helpers/file_helper.html">File Helper</a>.  No longer recurses
+                               by default so as to encourage responsible use (this function can cause server performance issues when used without caution).</li>
+                       <li>Modified the second parameter of <kbd>directory_map()</kbd> in the <a href="helpers/directory_helper.html">Directory Helper</a> to accept an integer to specify recursion depth.</li>
+                       <li>Modified <kbd>delete_files()</kbd> in the <a href="helpers/file_helper.html">File Helper</a> to return FALSE on failure.</li>
+                       <li>Added an optional second parameter to <kbd>byte_format()</kbd> in the <a href="helpers/number_helper.html">Number Helper</a> to allow for decimal precision.</li>
+                       <li>Added alpha, and sha1 string types to <kbd>random_string()</kbd> in the <a href="helpers/string_helper.html">String Helper</a>.</li>
+                       <li>Modified <kbd>prep_url()</kbd> so as to not prepend http:// if the supplied string already has a scheme.</li>
+                       <li>Modified <kbd>get_file_info</kbd> in the file helper, changing filectime() to filemtime() for dates.</li>
+                       <li>Modified <kbd>smiley_js()</kbd> to add optional third parameter to return only the javascript with no script tags.</li>
+                       <li>The <kbd>img()</kbd> function of the <a href="./helpers/html_helper.html">HTML helper</a> will now generate an empty string as an alt attribute if one is not provided.</li>
+                       <li>If CSRF is enabled in the application config file, <kbd>form_open()</kbd> will automatically insert it as a hidden field.</li>
+                       <li>Added <kbd>sanitize_filename()</kbd> into the <a href="./helpers/security_helper.html">Security helper</a>.</li>
+                       <li>Added <kbd>ellipsize()</kbd> to the <a href="./helpers/text_helper.html">Text Helper</a></li>
+                       <li>Added <kbd>elements()</kbd> to the <a href="./helpers/array_helper.html">Array Helper</a></li>
+               </ul>
+       </li>
+       <li>Other Changes
+               <ul>
+                       <li>Added an optional second parameter to <kbd>show_404()</kbd> to disable logging.</li>
+                       <li>Updated loader to automatically apply the sub-class prefix as an option when loading classes.  Class names can be prefixed with the standard "CI_" or the same prefix as the subclass prefix, or no prefix at all.</li>
+                       <li>Increased randomness with <kbd>is_really_writable()</kbd> to avoid file collisions when hundreds or thousands of requests occur at once.</li>
+                       <li>Switched some DIR_WRITE_MODE constant uses to FILE_WRITE_MODE where files and not directories are being operated on.</li>
+                       <li><kbd>get_mime_by_extension()</kbd> is now case insensitive.</li>
+                       <li>Added "default" to the list <a href="general/reserved_names.html">Reserved Names</a>.</li>
+                       <li>Added 'application/x-msdownload' for .exe files and ''application/x-gzip-compressed' for .tgz files to config/mimes.php.</li>
+                       <li>Updated the output library to no longer compress output or send content-length headers if the server runs with zlib.output_compression enabled.</li>
+                       <li>Eliminated a call to is_really_writable() on each request unless it is really needed (Output caching)</li>
+                       <li>Documented <kbd>append_output()</kbd> in the <a href="libraries/output.html">Output Class</a>.</li>
+                       <li>Documented a second argument in the <kbd>decode()</kbd> function for the <a href="libraries/encryption.html">Encryption Class</a>.</li>
+                       <li>Documented db->close().</li>
+                       <li>Updated the router to support a default route with any number of segments.</li>
+                       <li>Moved _remove_invisible_characters() function from the <a href="libraries/security.html">Security Library</a> to <a href="general/common_functions.html">common functions.</a></li>
+                       <li>Added audio/mpeg3 as a valid mime type for MP3.</li>
+               </ul>
+       </li>
+</ul>
+
+<h3>Bug fixes for 2.0.0</h3>
+<ul>
+       <li class="reactor">Fixed a bug where you could not change the User-Agent when sending email.</li>
+       <li>Fixed a bug where the Output class would send incorrect cached output for controllers implementing their own <dfn>_output()</dfn> method.</li>
+       <li>Fixed a bug where a failed query would not have a saved query execution time causing errors in the Profiler</li>
+       <li>Fixed a bug that was writing log entries when multiple identical helpers and plugins were loaded.</li>
+       <li>Fixed assorted user guide typos or examples (#10693, #8951, #7825, #8660, #7883, #6771, #10656).</li>
+       <li>Fixed a language key in the profiler: "profiler_no_memory_usage" to "profiler_no_memory".</li>
+       <li>Fixed an error in the Zip library that didn't allow downloading on PHP 4 servers.</li>
+       <li>Fixed a bug in the Form Validation library where fields passed as rule parameters were not being translated (#9132)</li>
+       <li>Modified inflector helper to properly pluralize words that end in 'ch' or 'sh'</li>
+       <li>Fixed a bug in xss_clean() that was not allowing hyphens in query strings of submitted URLs.</li>
+       <li>Fixed bugs in get_dir_file_info() and get_file_info() in the File Helper with recursion, and file paths on Windows.</li>
+       <li>Fixed a bug where Active Record override parameter would not let you disable Active Record if it was enabled in your database config file.</li>
+       <li>Fixed a bug in reduce_double_slashes() in the String Helper to properly remove duplicate leading slashes (#7585)</li>
+       <li>Fixed a bug in values_parsing() of the XML-RPC library which prevented NULL variables typed as 'string' from being handled properly.</li>
+       <li>Fixed a bug were form_open_multipart() didn't accept string attribute arguments (#10930).</li>
+       <li>Fixed a bug (#10470) where <kdb>get_mime_by_extension()</kbd> was case sensitive.</li>
+       <li>Fixed a bug where some error messages for the SQLite and Oracle drivers would not display.</li>
+       <li>Fixed a bug where files created with the Zip Library would result in file creation dates of 1980.</li>
+       <li>Fixed a bug in the Session library that would result in PHP error when attempting to store values with objects.</li>
+       <li>Fixed a bug where extending the Controller class would result in a fatal PHP error.</li>
+       <li>Fixed a PHP Strict Standards Error in the index.php file.</li>
+       <li>Fixed a bug where getimagesize() was being needlessly checked on non-image files in is_allowed_type().</li>
+       <li>Fixed a bug in the Encryption library where an empty key was not triggering an error.</li>
+       <li>Fixed a bug in the Email library where CC and BCC recipients were not reset when using the clear() method (#109).</li>
+       <li>Fixed a bug in the URL Helper where prep_url() could cause a PHP error on PHP versions &lt; 5.1.2.</li>
+       <li>Added a log message in core/output if the cache directory config value was not found.</li>
+       <li>Fixed a bug where multiple libraries could not be loaded by passing an array to load-&gt;library()</li>
+       <li>Fixed a bug in the html helper where too much white space was rendered between the src and alt tags in the img() function.</li>
+       <li>Fixed a bug in the profilers _compile_queries() function.</li>
+       <li>Fixed a bug in the date helper where the DATE_ISO8601 variable was returning an incorrectly formatted date string.</li>
+</ul>
+
+<h2>Version 1.7.2</h2>
+<p>Release Date: September 11, 2009<br />
+Hg Tag: v1.7.2</p>
+
+<ul>
+       <li>Libraries
+               <ul>
+                       <li>Added a new <a href="libraries/cart.html">Cart Class</a>.</li>
+                       <li>Added the ability to pass $config['file_name'] for the <a href="libraries/file_uploading.html">File Uploading Class</a> and rename the uploaded file.</li>
+                       <li>Changed order of listed user-agents so Safari would more accurately report itself. (#6844)</li>
+               </ul>
+       </li>
+       <li>Database
+               <ul>
+                       <li>Switched from using gettype() in escape() to is_* methods, since future PHP versions might change its output.</li>
+                       <li>Updated all database drivers to handle arrays in escape_str()</li>
+                       <li>Added escape_like_str() method for escaping strings to be used in LIKE conditions</li>
+                       <li>Updated Active Record to utilize the new LIKE escaping mechanism.</li>
+                       <li>Added reconnect() method to DB drivers to try to keep alive / reestablish a connection after a long idle.</li>
+                       <li>Modified MSSQL driver to use mssql_get_last_message() for error messages.</li>
+               </ul>
+       </li>
+       <li>Helpers
+               <ul>
+                       <li>Added <kbd>form_multiselect()</kbd> to the <a href="helpers/form_helper.html">Form helper</a>.</li>
+                       <li>Modified <kbd>form_hidden()</kbd> in the <a href="helpers/form_helper.html">Form helper</a> to accept multi-dimensional arrays.</li>
+                       <li>Modified <kbd>form_prep()</kbd> in the <a href="helpers/form_helper.html">Form helper</a> to keep track of prepped fields to avoid multiple prep/mutation from subsequent calls which can occur when using Form Validation
+                               and form helper functions to output form fields.</li>
+                       <li>Modified <kbd>directory_map()</kbd> in the <a href="helpers/directory_helper.html">Directory helper</a> to allow the inclusion of hidden files, and to return FALSE on failure to read directory.</li>
+                       <li>Modified the <a href="helpers/smiley_helper.html">Smiley helper</a> to work with multiple fields and insert the smiley at the last known cursor position.</li>
+               </ul>
+       </li>
+       <li>General
+               <ul>
+                       <li>Compatible with PHP 5.3.0</li>
+                       <li>Modified <a href="general/errors.html">show_error()</a> to allow sending of HTTP server response codes.</li>
+                       <li>Modified <a href="general/errors.html">show_404()</a> to send 404 status code, removing non-CGI compatible header() statement from error_404.php template.</li>
+                       <li>Added set_status_header() to the <a href="general/common_functions.html">Common functions<a> to allow use when the Output class is unavailable.</li>
+                       <li>Added is_php() to <a href="general/common_functions.html">Common functions</a> to facilitate PHP version comparisons.</p>
+                       <li>Added 2 CodeIgniter "cheatsheets" (thanks to DesignFellow.com for this contribution).</li>
+               </ul>
+       </li>
+</ul>
+
+<h3>Bug fixes for 1.7.2</h3>
+<ul>
+       <li>Fixed assorted user guide typos or examples (#6743, #7214, #7516, #7287, #7852, #8224, #8324, #8349).</li>
+       <li>Fixed a bug in the Form Validation library where multiple callbacks weren't working (#6110)</li>
+       <li>doctype helper default value was missing a "1".</li>
+       <li>Fixed a bug in the language class when outputting an error for an unfound file.</li>
+       <li>Fixed a bug in the Calendar library where the shortname was output for "May".</li>
+       <li>Fixed a bug with ORIG_PATH_INFO that was allowing URIs of just a slash through.</li>
+       <li>Fixed a fatal error in the Oracle and ODBC drivers (#6752)</li>
+       <li>Fixed a bug where xml_from_result() was checking for a nonexistent method.</li>
+       <li>Fixed a bug where Database Forge's add_column and modify_column were not looping through when sent multiple fields.</li>
+       <li>Fixed a bug where the File Helper was using '/' instead of the DIRECTORY_SEPARATOR constant.</li>
+       <li>Fixed a bug to prevent PHP errors when attempting to use sendmail on servers that have manually disabled the PHP popen() function.</li>
+       <li>Fixed a bug that would cause PHP errors in XML-RPC data if the PHP data type did not match the specified XML-RPC type.</li>
+       <li>Fixed a bug in the XML-RPC class with parsing dateTime.iso8601 data types.</li>
+       <li>Fixed a case sensitive string replacement in xss_clean()</li>
+       <li>Fixed a bug in form_textarea() where form data was not prepped correctly.</li>
+       <li>Fixed a bug in form_prep() causing it to not preserve entities in the user's original input when called back into a form element</li>
+       <li>Fixed a bug in _protect_identifiers() where the swap prefix ($swap_pre) was not being observed.</li>
+       <li>Fixed a bug where the 400 status header sent with the 'disallowed URI characters' was not compatible with CGI environments.</li>
+       <li>Fixed a bug in the typography class where heading tags could have paragraph tags inserted when using auto_typography().</li>
+</ul>
+
+<h2>Version 1.7.1</h2>
+<p>Release Date: February 10, 2009<br />
+Hg Tag: 1.7.1</p>
+
+<ul>
+       <li>Libraries
+               <ul>
+                       <li>Fixed an arbitrary script execution security flaw (#6068) in the Form Validation library (thanks to hkk)</li>
+                       <li>Changed default current page indicator in the Pagination library to use &lt;strong&gt; instead of &lt;b&gt;</li>
+                       <li>A "HTTP/1.1 400 Bad Request" header is now sent when disallowed characters are encountered.</li>
+                       <li>Added &lt;big&gt;, &lt;small&gt;, &lt;q&gt;, and &lt;tt&gt; to the Typography parser's inline elements.</li>
+                       <li>Added more accurate error reporting for the Email library when using sendmail.</li>
+                       <li>Removed a strict type check from the <kbd>rotate()</kbd> function of the <a href="libraries/image_lib.html">Image Manipulation Class</a>.</li>
+                       <li>Added enhanced error checking in file saving in the Image library when using the GD lib.</li>
+                       <li>Added an additional newline between multipart email headers and the MIME message text for better compatibility with a variety of MUAs.</li>
+                       <li>Made modest improvements to efficiency and accuracy of explode_name() in the Image lib.</li>
+               </ul>
+       </li>
+       <li>Database
+               <ul>
+                       <li>Added where_in to the list of expected arguments received by <kbd>delete()</kbd>.</li>
+               </ul>
+       </li>
+       <li>Helpers
+               <ul>
+                       <li>Added the ability to have optgroups in <kbd>form_dropdown()</kbd> within the <a href="helpers/form_helper.html">form helper</a>.</li>
+                       <li>Added a doctype() function to the <a href="helpers/html_helper.html">HTML helper</a>.</li>
+                       <li>Added ability to force lowercase for <kbd>url_title()</kbd> in the <a href="helpers/url_helper.html">URL helper</a>.</li>
+                       <li>Changed the default "type" of <kbd>form_button()</kbd> to "button" from "submit" in the <a href="helpers/form_helper.html">form helper</a>.</li>
+                       <li>Changed redirect() in the URL helper to allow redirections to URLs outside of the CI site.</li>
+                       <li>Updated get_cookie() to try to fetch the cookie using the global cookie prefix if the requested cookie name doesn't exist.</li>
+               </ul>
+       </li>
+       <li>Other Changes
+               <ul>
+                       <li>Improved security in <kbd>xss_clean()</kbd> to help prevent attacks targeting Internet Explorer.</li>
+                       <li>Added 'application/msexcel' to config/mimes.php for .xls files.</li>
+                       <li>Added 'proxy_ips' config item to whitelist reverse proxy servers from which to trust the HTTP_X_FORWARDED_FOR header to
+                               to determine the visitor's IP address.</li>
+                       <li>Improved accuracy of Upload::is_allowed_filetype() for images (#6715)</li>
+               </ul>
+       </li>
+</ul>
+
+<h3>Bug fixes for 1.7.1</h3>
+<ul>
+       <li>Database
+               <ul>
+                       <li>Fixed a bug when doing 'random' on order_by() (#5706).</li>
+                       <li>Fixed a bug where adding a primary key through Forge could fail (#5731).</li>
+                       <li>Fixed a bug when using DB cache on multiple databases (#5737).</li>
+                       <li>Fixed a bug where TRUNCATE was not considered a "write" query (#6619).</li>
+                       <li>Fixed a bug where csv_from_result() was checking for a nonexistent method.</li>
+                       <li>Fixed a bug _protect_identifiers() where it was improperly removing all pipe symbols from items</li>
+               </ul>
+       </li>
+       <li>Fixed assorted user guide typos or examples (#5998, #6093, #6259, #6339, #6432, #6521).</li>
+       <li>Fixed a bug in the MySQLi driver when no port is specified</li>
+       <li>Fixed a bug (#5702), in which the field label was not being fetched properly, when "matching" one field to another.</li>
+       <li>Fixed a bug in which identifers were not being escaped properly when reserved characters were used.</li>
+       <li>Fixed a bug with the regular expression used to protect submitted paragraph tags in auto typography.</li>
+       <li>Fixed a bug where double dashes within tag attributes were being converted to em dash entities.</li>
+       <li>Fixed a bug where double spaces within tag attributes were being converted to non-breaking space entities.</li>
+       <li>Fixed some accuracy issues with curly quotes in Typography::format_characters()</li>
+       <li>Changed a few docblock comments to reflect actual return values.</li>
+       <li>Fixed a bug with high ascii characters in subject and from email headers.</li>
+       <li>Fixed a bug in xss_clean() where whitespace following a validated character entity would not be preserved.</li>
+       <li>Fixed a bug where HTML comments and &lt;pre&gt; tags were being parsed in Typography::auto_typography().</li>
+       <li>Fixed a bug with non-breaking space cleanup in Typography::auto_typography().</li>
+       <li>Fixed a bug in database escaping where a compound statement (ie: SUM()) wasn't handled correctly with database prefixes.</li>
+       <li>Fixed a bug when an opening quote is preceded by a paragraph tag and immediately followed by another tag.</li>
+       <li>Fixed a bug in the Text Helper affecting some locales where word_censor() would not work on words beginning or ending with an accented character.</li>
+       <li>Fixed a bug in the Text Helper character limiter where the provided limit intersects the last word of the string.</li>
+       <li>Fixed a bug (#6342) with plural() in the Inflection helper with words ending in "y".</li>
+       <li>Fixed bug (#6517) where Routed URI segments returned by URI::rsegment() method were incorrect for the default controller.</li>
+       <li>Fixed a bug (#6706) in the Security Helper where xss_clean() was using a deprecated second argument.</li>
+       <li>Fixed a bug in the URL helper url_title() function where trailing periods were allowed at the end of a URL.</li>
+       <li>Fixed a bug (#6669) in the Email class when CRLF's are used for the newline character with headers when used with the "mail" protocol.</li>
+       <li>Fixed a bug (#6500) where URI::A_filter_uri() was exit()ing an error instead of using show_error().</li>
+       <li>Fixed a bug (#6592) in the File Helper where get_dir_file_info() where recursion was not occurring properly.</li>
+       <li>Tweaked Typography::auto_typography() for some edge-cases.</li>
+</ul>
+
+
+<h2>Version 1.7</h2>
+<p>Release Date: October 23, 2008<br />
+Hg Tag: 1.7.0</p>
+
+<ul>
+       <li>Libraries
+               <ul>
+                       <li>Added a new <a href="libraries/form_validation.html">Form Validation Class</a>.  It simplifies setting rules and field names, supports arrays as field names, allows groups of validation rules to be saved in a config file, and adds some helper functions for use in view files.  <strong>Please note that the old Validation class is now deprecated</strong>. We will leave it in the library folder for some time so that existing applications that use it will not break, but you are encouraged to migrate to the new version.</li>
+                       <li>Updated the <a href="libraries/sessions.html">Sessions class</a> so that any custom data being saved gets stored to a database rather than the session cookie (assuming you are using a database to store session data), permitting much more data to be saved.</li>
+                       <li>Added the ability to store libraries in subdirectories within either the main "libraries" or the local application "libraries" folder. Please see the <a href="libraries/loader.html">Loader class</a> for more info.</li>
+                       <li>Added the ability to assign library objects to your own variable names when you use <kbd>$this->load->library()</kbd>. Please see the <a href="libraries/loader.html">Loader class</a> for more info.</li>
+                       <li>Added controller class/method info to <a href="general/profiling.html">Profiler class</a> and support for multiple database connections.</li>
+                       <li>Improved the "auto typography" feature and moved it out of the helper into its own <a href="libraries/typography.html">Typography Class</a>.</li>
+                       <li>Improved performance and accuracy of <kbd>xss_clean()</kbd>, including reduction of false positives on image/file tests.</li>
+                       <li>Improved <a href="./libraries/parser.html">Parser class</a> to allow multiple calls to the parse() function.  The output of each is appended in the output.</li>
+                       <li>Added <dfn>max_filename</dfn> option to set a file name length limit in the  <a href="libraries/file_uploading.html">File Upload Class</a>.</li>
+                       <li>Added <dfn>set_status_header()</dfn> function to <a href="libraries/output.html">Output class</a>.</li>
+                       <li>Modified <a href="libraries/pagination.html">Pagination</a> class to only output the "First" link when the link for page one would not be shown.</li>
+                       <li>Added support for mb_strlen in the <a href="libraries/form_validation.html">Form Validation</a> class so that multi-byte languages will calculate string lengths properly.</li>
+               </ul>
+       </li>
+       <li>Database
+               <ul>
+                       <li>Improved Active Record class to allow full path column and table names:  hostname.database.table.column.  Also improved the alias handling.</li>
+                       <li>Improved how table and column names are escaped and prefixed.  It now honors full path names when adding prefixes and escaping.</li>
+                       <li>Added Active Record caching feature to "update" and "delete" functions.</li>
+                       <li>Added removal of non-printing control characters in <kbd>escape_str()</kbd> of DB drivers that do not have native PHP escaping mechanisms (mssql, oci8, odbc), to avoid potential SQL errors, and possible sources of SQL injection.</li>
+                       <li>Added port support to MySQL, MySQLi, and MS SQL database drivers.</li>
+                       <li>Added driver name variable in each DB driver, based on bug report #4436.</li>
+               </ul>
+       </li>
+       <li>Helpers
+               <ul>
+                       <li>Added several new "setting" functions to the <a href="helpers/form_helper.html">Form helper</a> that allow POST data to be retrieved and set into forms.  These are intended to be used on their own, or with the new <a href="libraries/form_validation.html">Form Validation Class</a>.</li>
+                       <li>Added <kbd>current_url()</kbd> and uri_segments() to  <a href="helpers/url_helper.html">URL helper</a>.</li>
+                       <li>Altered <kbd>auto_link()</kbd> in the <a href="helpers/url_helper.html">URL helper</a> so that email addresses with "+" included will be linked.</li>
+                       <li>Added <kbd>meta()</kbd> function to  <a href="helpers/html_helper.html">HTML helper</a>.</li>
+                       <li>Improved accuracy of calculations in <a href="helpers/number_helper.html">Number helper</a>.</li>
+                       <li>Removed added newlines ("\n") from most form and html helper functions.</li>
+                       <li>Tightened up validation in the <a href="helpers/date_helper.html">Date helper</a> function <kbd>human_to_unix()</kbd>, and eliminated the POSIX regex.</li>
+                       <li>Updated <a href="helpers/date_helper.html">Date helper</a> to match the world's current time zones and offsets.</li>
+                       <li>Modified url_title() in the <a href="helpers/url_helper.html">URL helper</a> to remove characters and digits that are part of
+                               character entities, to allow dashes, underscores, and periods regardless of the $separator, and to allow uppercase characters.</li>
+                       <li>Added support for arbitrary attributes in anchor_popup() of the <a href="helpers/url_helper.html">URL helper</a>.</li>
+               </ul>
+       </li>
+       <li>Other Changes
+               <ul>
+                       <li>Added <a href="./general/styleguide.html">PHP Style Guide</a> to docs.</li>
+                       <li>Added sanitization in <kbd>xss_clean()</kbd> for a deprecated HTML tag that could be abused in user input in Internet Explorer.</li>
+                       <li>Added a few openxml document mime types, and an additional mobile agent to mimes.php and user_agents.php respectively.</li>
+                       <li>Added a file lock check during caching, before trying to write to the file.</li>
+                       <li>Modified Cookie key cleaning to unset a few troublesome key names that can be present in certain environments, preventing CI from halting execution.</li>
+                       <li>Changed the output of the profiler to use style attribute rather than clear, and added the id "codeigniter_profiler" to the container div.</li>
+               </ul>
+       </li>
+</ul>
+
+<h3>Bug fixes for 1.7.0</h3>
+<ul>
+       <li>Fixed bug in <kbd>xss_clean()</kbd> that could remove some desirable tag attributes.</li>
+       <li>Fixed assorted user guide typos or examples (#4807, #4812, #4840, #4862, #4864, #4899, #4930, #5006, #5071, #5158, #5229, #5254, #5351).</li>
+       <li>Fixed an edit from 1.6.3 that made the $robots array in user_agents.php go poof.</li>
+       <li>Fixed a bug in the <a href="libraries/email.html">Email library</a> with quoted-printable encoding improperly encoding space and tab characters.</li>
+       <li>Modified XSS sanitization to no longer add semicolons after &amp;[single letter], such as in M&amp;M's, B&amp;B, etc.</li>
+       <li>Modified XSS sanitization to no longer strip XHTML image tags of closing slashes.</li>
+       <li>Fixed a bug in the Session class when database sessions are used where upon session update all userdata would be errantly written to the session cookie.</li>
+       <li>Fixed a bug (#4536) in backups with the MySQL driver where some legacy code was causing certain characters to be double escaped.</li>
+       <li>Fixed a routing bug (#4661) that occurred when the default route pointed to a subfolder.</li>
+       <li>Fixed the spelling of "Dhaka" in the <kbd>timezone_menu()</kbd> function of the <a href="helpers/date_helper.html">Date helper.</a></li>
+       <li>Fixed the spelling of "raspberry" in config/smileys.php.</li>
+       <li>Fixed incorrect parenthesis in <kbd>form_open()</kbd> function (#5135).</li>
+       <li>Fixed a bug that was ignoring case when comparing controller methods (#4560).</li>
+       <li>Fixed a bug (#4615) that was not setting SMTP authorization settings when using the initialize function.</li>
+       <li>Fixed a bug in <kbd>highlight_code()</kbd> in the <a href="helpers/text_helper.html">Text helper</a> that would leave a stray &lt;/span&gt; in certain cases.</li>
+       <li>Fixed Oracle bug (#3306) that was preventing multiple queries in one action.</li>
+       <li>Fixed ODBC bug that was ignoring connection params due to its use of a constructor.</li>
+       <li>Fixed a DB driver bug with num_rows() that would cause an error with the Oracle driver.</li>
+       <li>Fixed MS SQL bug (#4915).  Added brackets around database name in MS SQL driver when selecting the database, in the event that reserved characters are used in the name.</li>
+       <li>Fixed a DB caching bug (4718) in which the path was incorrect when no URI segments were present.</li>
+       <li>Fixed Image_lib class bug #4562.  A path was not defined for NetPBM.</li>
+       <li>Fixed Image_lib class bug #4532.  When cropping an image with identical height/width settings on output, a copy is made.</li>
+       <li>Fixed DB_driver bug (4900), in which a database error was not being logged correctly.</li>
+       <li>Fixed DB backup bug in which field names were not being escaped.</li>
+       <li>Fixed a DB Active Record caching bug in which multiple calls to cached data were not being honored.</li>
+       <li>Fixed a bug in the Session class that was disallowing slashes in the serialized array.</li>
+       <li>Fixed a Form Validation bug in which the "isset" error message was being trigged by the "required" rule.</li>
+       <li>Fixed a spelling error in a Loader error message.</li>
+       <li>Fixed a bug (5050) with IP validation with empty segments.</li>
+       <li>Fixed a bug in which the parser was being greedy if multiple identical sets of tags were encountered.</li>
+</ul>
+
+<h2>Version 1.6.3</h2>
+<p>Release Date: June 26, 2008<br />
+Hg Tag: v1.6.3</p>
+
+<p>Version 1.6.3 is a security and maintenance release and is recommended for all users.</p>
+<ul>
+       <li>Database
+               <ul>
+                       <li>Modified MySQL/MySQLi Forge class to give explicit names to keys</li>
+                       <li>Added ability to set multiple column non-primary keys to the <a href="database/forge.html">Forge class</a></li>
+                       <li>Added ability to set additional database config values in <a href="database/connecting.html">DSN connections</a> via the query string.</li>
+                       </ul>
+       </li>
+       <li>Libraries
+               <ul>
+                       <li>Set the mime type check in the <a href="libraries/file_uploading.html">Upload class</a> to reference the global mimes variable.</li>
+                       <li>Added support for query strings to the <a href="libraries/pagination.html">Pagination class</a>, automatically detected or explicitly declared.</li>
+                       <li>Added <kbd>get_post()</kbd> to the <a href="libraries/input.html">Input class</a>.</li>
+                       <li>Documented <kbd>get()</kbd> in the <a href="libraries/input.html">Input class</a>.</li>
+                       <li>Added the ability to automatically output language items as form labels in the <a href="libraries/language.html">Language class</a>.</li>
+               </ul>
+       </li>
+       <li>Helpers
+               <ul>
+                       <li>Added a <a href="helpers/language_helper.html">Language helper</a>.</li>
+                       <li>Added a <a href="helpers/number_helper.html">Number helper</a>.</li>
+                       <li><a href="helpers/form_helper.html">Form helper</a> refactored to allow <kbd>form_open()</kbd> and <kbd>form_fieldset()</kbd> to accept arrays or strings as arguments.</li>
+               </ul>
+       </li>
+       <li>Other changes
+               <ul>
+                       <li>Improved security in <kbd>xss_clean()</kbd>.</li>
+                       <li>Removed an unused Router reference in <kbd>_display_cache()</kbd>.</li>
+                       <li>Added ability to <a href="libraries/input.html">use xss_clean() to test images</a> for XSS, useful for upload security.</li>
+                       <li>Considerably expanded list of mobile user-agents in config/user_agents.php.</li>
+                       <li>Charset information in the userguide has been moved above title for internationalization purposes (#4614).</li>
+                       <li>Added &quot;Using Associative Arrays In a Request Parameter&quot; example to the <a href="libraries/xmlrpc.html">XMLRPC userguide page</a>.</li>
+                       <li>Removed maxlength and size as automatically added attributes of form_input() in the <a href="helpers/form_helper.html">form helper</a>.</li>
+                       <li>Documented the language file use of <kbd>byte_format()</kbd> in the <a href="helpers/number_helper.html">number helper</a>.</li>
+               </ul>
+       </li>
+</ul>
+
+
+<h3>Bug fixes for 1.6.3</h3>
+
+<ul>
+       <li>Added a language key for valid_emails in validation_lang.php.</li>
+       <li>Amended fixes for bug (#3419) with parsing DSN database connections.</li>
+       <li>Moved the <kbd>_has_operators()</kbd> function (#4535) into DB_driver from DB_active_rec.</li>
+       <li>Fixed a syntax error in upload_lang.php.</li>
+       <li>Fixed a bug (#4542) with a regular expression in the Image library.</li>
+       <li>Fixed a bug (#4561) where <kbd>orhaving()</kbd> wasn't properly passing values.</li>
+       <li>Removed some unused variables from the code (#4563).</li>
+       <li>Fixed a bug where <kbd>having()</kbd> was not adding an = into the statement (#4568).</li>
+       <li>Fixed assorted user guide typos or examples (#4574, #4706).</li>
+       <li>Added quoted-printable headers to Email class when the multi-part override is used.</li>
+       <li>Fixed a double opening &lt;p&gt; tag in the index pages of each system directory.</li>
+</ul>
+
+<h2>Version 1.6.2</h2>
+<p>Release Date: May 13, 2008<br />
+Hg Tag: 1.6.2</p>
+<ul>
+       <li>Active Record
+               <ul>
+                       <li>Added the ability to prevent escaping in <kbd>having()</kbd> clauses.</li>
+                       <li>Added <kbd>rename_table()</kbd> into <a href="./database/forge.html">DBForge</a>.</li>
+                       <li>Fixed a bug that wasn't allowing escaping to be turned off if the value of a query was NULL.</li>
+                       <li>DB Forge is now assigned to any models that exist after loading (#3457).</li>
+                       </ul>
+       </li>
+       <li>Database
+               <ul>
+                       <li>Added <a href="./database/transactions.html">Strict Mode</a> to database transactions.</li>
+                       <li>Escape behaviour in where() clauses has changed; values in those with the &quot;FALSE&quot; argument are no longer escaped (ie: quoted).</li>
+               </ul>
+       </li>
+       <li>Config
+               <ul>
+                       <li>Added 'application/vnd.ms-powerpoint' to list of mime types.</li>
+                       <li>Added 'audio/mpg' to list of mime types.</li>
+                       <li>Added new user-modifiable file constants.php containing file mode and fopen constants.</li>
+                       <li>Added the ability to set CRLF settings via config in the <a href="libraries/email.html">Email</a> class.</li>
+               </ul>
+       </li>
+       <li>Libraries
+               <ul>
+                       <li>Added increased security for filename handling in the Upload library.</li>
+                       <li>Added increased security for sessions for client-side data tampering.</li>
+                       <li>The MySQLi forge class is now in sync with MySQL forge. </li>
+                       <li>Added the ability to set CRLF settings via config in the <a href="libraries/email.html">Email</a> class.</li>
+                       <li><a href="libraries/unit_testing.html">Unit Testing</a> results are now colour coded, and a change was made to the default template of results.</li>
+                       <li>Added a valid_emails rule to the Validation class.</li>
+                       <li>The <a href="libraries/zip.html">Zip class</a> now exits within <kbd>download()</kbd>.</li>
+                       <li>The <a href="libraries/zip.html">Zip class</a> has undergone a substantial re-write for speed and clarity (thanks stanleyxu for the hard work and code contribution in bug report #3425!)</li>
+               </ul>
+       </li>
+       <li>Helpers
+               <ul>
+                       <li>Added a <a href="helpers/compatibility_helper.html">Compatibility Helper</a> for using some common PHP 5 functions safely in applications that might run on PHP 4 servers (thanks Seppo for the hard work and code contribution!)</li>
+                       <li>Added <kbd>form_button()</kbd> in the <a href="helpers/form_helper.html">Form helper</a>.</li>
+                       <li>Changed the <kbd>radio()</kbd> and <kbd>checkbox()</kbd> functions to default to not checked by default.</li>
+                       <li>Added the ability to include an optional HTTP Response Code in the <kbd>redirect()</kbd> function of the <a href="helpers/url_helper.html">URL Helper</a>.</li>
+                       <li>Modified <kbd>img()</kbd> in the <a href="helpers/html_helper.html">HTML Helper</a> to remove an unneeded space (#4208).</li>
+                       <li>Modified <kbd>anchor()</kbd> in the <a href="helpers/url_helper.html">URL helper</a> to no longer add a default title= attribute (#4209).</li>
+                       <li>The <a href="helpers/download_helper.html">Download helper</a> now exits within <kbd>force_download()</kbd>.</li>
+                       <li>Added <kbd>get_dir_file_info()</kbd>, <kbd>get_file_info()</kbd>, and <kbd>get_mime_by_extension()</kbd> to the <a href="helpers/file_helper.html">File Helper</a>.</li>
+                       <li>Added <kbd>symbolic_permissions()</kbd> and <kbd>octal_permissions()</kbd> to the <a href='helpers/file_helper.html'>File helper</a>.</li>
+               </ul>
+       </li>
+       <li>Plugins
+               <ul>
+                       <li>Modified captcha generation to first look for the function imagecreatetruecolor, and fallback to imagecreate if it isn't available (#4226).</li>
+               </ul>
+       </li>
+       <li>Other
+               Changes
+               <ul>
+                       <li>Added ability for <a href="libraries/input.html">xss_clean()</a> to accept arrays.</li>
+                       <li>Removed closing PHP tags from all PHP files to avoid accidental output and potential 'cannot modify headers' errors.</li>
+                       <li>Removed &quot;scripts&quot; from the auto-load search path. Scripts were deprecated
+                               in Version 1.4.1 (September 21, 2006). If you still need to use them for legacy reasons, they must now be manually loaded in each Controller.</li>
+                       <li>Added a <a href="general/reserved_names.html">Reserved Names</a> page to the userguide, and migrated reserved controller names into it.</li>
+                       <li>Added a <a href="general/common_functions.html">Common Functions</a> page to the userguide for globally available functions.</li>
+                       <li>Improved security and performance of xss_clean().</li>
+               </ul>
+       </li>
+       </ul>
+
+<h3>Bugfixes for 1.6.2</h3>
+<ul>
+       <li>Fixed a bug where SET queries were not being handled as "write" queries.</li>
+       <li>Fixed a bug (#3191) with ORIG_PATH_INFO URI parsing.</li>
+       <li>Fixed a bug in DB Forge, when inserting an id field (#3456).</li>
+       <li>Fixed a bug in the table library that could cause identically constructed rows to be dropped (#3459).</li>
+       <li>Fixed DB Driver and MySQLi result driver checking for resources instead of objects (#3461).</li>
+       <li>Fixed an AR_caching error where it wasn't tracking table aliases (#3463).</li>
+       <li>Fixed a bug in AR compiling, where select statements with arguments got incorrectly escaped (#3478).</li>
+       <li>Fixed an incorrect documentation of $this-&gt;load-&gt;language (#3520).</li>
+       <li>Fixed bugs (#3523, #4350) in get_filenames() with recursion and problems with Windows when $include_path is used.</li>
+       <li>Fixed a bug (#4153) in the XML-RPC class preventing dateTime.iso8601 from being used.</li>
+       <li>Fixed an AR bug with or_where_not_in() (#4171).</li>
+       <li>Fixed a bug with <a href="libraries/input.html">xss_clean()</a> that would add semicolons to GET URI variable strings.</li>
+       <li>Fixed a bug (#4206) in the Directory Helper where the directory resource was not being closed, and minor improvements.</li>
+       <li>Fixed a bug in the FTP library where delete_dir() was not working recursively (#4215).</li>
+       <li>Fixed a Validation bug when set_rules() is used with a non-array field name and rule (#4220).</li>
+       <li>Fixed a bug (#4223) where DB caching would not work for returned DB objects or multiple DB connections.</li>
+       <li>Fixed a bug in the Upload library that might output the same error twice (#4390).</li>
+       <li>Fixed an AR bug when joining with a table alias and table prefix (#4400).</li>
+       <li>Fixed a bug in the DB class testing the $params argument.</li>
+       <li>Fixed a bug in the Table library where the integer 0 in cell data would be displayed as a blank cell.</li>
+       <li>Fixed a bug in <kbd>link_tag()</kbd> of the <a href="helpers/url_helper.html">URL helper</a> where a key was passed instead of a value.</li>
+       <li>Fixed a bug in DB_result::row() that prevented it from returning individual fields with MySQL NULL values.</li>
+       <li>Fixed a bug where SMTP emails were not having dot transformation performed on lines that begin with a dot.</li>
+       <li>Fixed a bug in display_error() in the DB driver that was instantiating new Language and Exception objects, and not using the error heading.</li>
+       <li>Fixed a bug (#4413) where a URI containing slashes only e.g. 'http://example.com/index.php?//' would result in PHP errors</li>
+       <li>Fixed an array to string conversion error in the Validation library (#4425)</li>
+       <li>Fixed bug (#4451, #4299, #4339) where failed transactions will not rollback when debug mode is enabled.</li>
+       <li>Fixed a bug (#4506) with overlay_watermark() in the Image library preventing support for PNG-24s with alpha transparency</li>
+       <li>Fixed assorted user guide typos (#3453, #4364, #4379, #4399, #4408, #4412, #4448, #4488).</li>
+       </ul>
+
+<h2>Version 1.6.1</h2>
+<p>Release Date: February 12, 2008<br />
+Hg Tag: 1.6.1</p>
+<ul>
+       <li>Active Record
+               <ul>
+                       <li>Added <a href="./database/active_record.html#caching">Active Record Caching</a>.</li>
+                       <li>Made Active Record fully database-prefix aware.</li>
+               </ul>
+       </li>
+       <li>Database drivers
+               <ul>
+                       <li>Added support for setting client character set and collation for MySQLi.</li>
+               </ul>
+       </li>
+       <li>Core Changes
+               <ul>
+                       <li>Modified <kbd>xss_clean()</kbd> to be more intelligent with its handling of URL encoded strings.</li>
+                       <li>Added $_SERVER, $_FILES, $_ENV, and $_SESSION to sanitization of globals.</li>
+                       <li>Added a <a href="./helpers/path_helper.html">Path Helper</a>.</li>
+                       <li>Simplified <kbd>_reindex_segments()</kbd> in the URI class.</li>
+                       <li>Escaped the '-' in the default 'permitted_uri_chars' config item, to prevent errors if developers just try to add additional characters to the end of the default expression.</li>
+                       <li>Modified method calling to controllers to show a 404 when a private or protected method is accessed via a URL.</li>
+                       <li>Modified framework initiated 404s to log the controller and method for invalid requests.</li>
+               </ul>
+       </li>
+       <li>Helpers
+               <ul>
+                       <li>Modified <kbd>get_filenames()</kbd> in the File Helper to return FALSE if the $source_dir is not readable.</li>
+               </ul>
+       </li>
+</ul>
+
+
+<h3>Bugfixes for 1.6.1</h3>
+<ul>
+       <li>Deprecated is_numeric as a validation rule. Use of numeric and integer are preferred.</li>
+       <li>Fixed bug (#3379) in DBForge with SQLite for table creation.</li>
+       <li>Made Active Record fully database prefix aware (#3384).</li>
+       <li>Fixed a bug where DBForge was outputting invalid SQL in Postgres by adding brackets around the tables in FROM.</li>
+       <li>Changed the behaviour of Active Record's update() to make the WHERE clause optional (#3395).</li>
+       <li>Fixed a bug (#3396) where certain POST variables would cause a PHP warning.</li>
+       <li>Fixed a bug in query binding (#3402).</li>
+       <li>Changed order of SQL keywords in the Profiler $highlight array so OR would not be highlighted before ORDER BY.</li>
+       <li>Fixed a bug (#3404) where the MySQLi driver was testing if $this->conn_id was a resource instead of an object.</li>
+       <li>Fixed a bug (#3419) connecting to a database via a DSN string.</li>
+       <li>Fixed a bug (#3445) where the routed segment array was not re-indexed to begin with 1 when the default controller is used.</li>
+       <li>Fixed assorted user guide typos.</li>
+</ul>
+
+
+
+<h2>Version 1.6.0</h2>
+<p>Release Date: January 30, 2008 </p>
+<ul>
+       <li>DBForge
+               <ul>
+                       <li>Added <a href="./database/forge.html">DBForge</a> to the database tools.</li>
+                       <li>Moved <kbd>create_database()</kbd> and <kbd>drop_database()</kbd> into <a href="./database/forge.html">DBForge</a>.</li>
+                       <li>Added <kbd>add_field()</kbd>, <kbd>add_key()</kbd>, <kbd>create_table()</kbd>, <kbd>drop_table()</kbd>, <kbd>add_column()</kbd>, <kbd>drop_column()</kbd>, <kbd>modify_column()</kbd> into <a href="./database/forge.html">DBForge</a>.</li>
+               </ul>
+       </li>
+
+       <li>Active Record
+               <ul>
+                       <li>Added <kbd>protect_identifiers()</kbd> in <a href="./database/active_record.html">Active Record</a>.</li>
+                       <li>All AR queries are backticked if appropriate to the database.</li>
+                       <li>Added <kbd>where_in()</kbd>, <kbd>or_where_in()</kbd>, <kbd>where_not_in()</kbd>,  <kbd>or_where_not_in()</kbd>, <kbd>not_like()</kbd> and <kbd>or_not_like()</kbd> to <a href="./database/active_record.html">Active Record</a>.</li>
+                       <li>Added support for <kbd>limit()</kbd>  into <kbd>update()</kbd> and <kbd>delete()</kbd> statements in  <a href="./database/active_record.html">Active Record</a>.</li>
+                       <li>Added <kbd>empty_table()</kbd> and <kbd>truncate_table()</kbd> to <a href="./database/active_record.html">Active Record</a>.</li>
+                       <li>Added the ability to pass an array of tables to the <kbd>delete()</kbd> statement in <a href="./database/active_record.html">Active Record</a>.</li>
+                       <li>Added <kbd>count_all_results()</kbd> function to <a href="./database/active_record.html">Active Record</a>.</li>
+                       <li>Added <kbd>select_max()</kbd>, <kbd>select_min()</kbd>, <kbd>select_avg()</kbd> and <kbd>select_sum()</kbd> to <a href="./database/active_record.html">Active Record</a>.</li>
+                       <li>Added the ability to use aliases with joins in <a href="./database/active_record.html">Active Record</a>.</li>
+                       <li>Added a third parameter to Active Record's <kbd>like()</kbd> clause to control where the wildcard goes. </li>
+                       <li>Added a third parameter to <kbd>set()</kbd> in <a href="./database/active_record.html">Active Record</a> that withholds escaping data.</li>
+                       <li>Changed the behaviour of variables submitted to the where() clause with no values to auto set &quot;IS NULL&quot;</li>
+               </ul>
+       </li>
+
+       <li>Other Database Related
+               <ul>
+                       <li>MySQL driver now requires MySQL 4.1+</li>
+                       <li>Added $this->DB->save_queries variable to DB driver, enabling queries to get saved or not. Previously they were always saved.</li>
+                       <li>Added $this->db->dbprefix() to manually add database prefixes.</li>
+                       <li>Added 'random' as an <kbd>order_by()</kbd> option , and removed &quot;rand()&quot; as a listed option as it was MySQL only.</li>
+                       <li>Added a check for NULL fields in the MySQL database backup utility.</li>
+                       <li>Added &quot;constrain_by_prefix&quot; parameter to db-&gt;list_table() function.  If set to TRUE it will limit the result to only table names with the current prefix.</li>
+                       <li>Deprecated from Active Record; <kbd>getwhere()</kbd> for <kbd>get_where()</kbd>; <kbd>groupby()</kbd> for <kbd>group_by()</kbd>; <kbd>havingor()</kbd> for <kbd>having_or()</kbd>; <kbd>orderby()</kbd> for <kbd>order_by</kbd>; <kbd>orwhere()</kbd> for <kbd>or_where()</kbd>; and <kbd>orlike()</kbd> for <kbd>or_like()</kbd>.</li>
+                       <li>Modified <kbd>csv_from_result()</kbd> to output CSV data more in the spirit of basic rules of RFC 4180.</li>
+                       <li>Added 'char_set' and 'dbcollat' database configuration settings, to explicitly set the client communication properly.</li>
+                       <li>Removed 'active_r' configuration setting and replaced with a global $active_record setting, which is more
+                               in harmony with the global nature of the behavior (#1834).</li>
+               </ul>
+       </li>
+
+       <li>Core changes
+               <ul>
+                       <li>Added ability to load multiple views, whose content will be appended to the output in the order loaded.</li>
+                       <li>Added the ability to <a href="./general/autoloader.html">auto-load</a> <a href="./general/models.html">Models</a>.</li>
+                       <li>Reorganized the URI and Routes classes for better clarity.</li>
+                       <li>Added Compat.php to allow function overrides for older versions of PHP or PHP environments missing certain extensions / libraries</li>
+                       <li>Added memory usage, GET, URI string data, and individual query execution time to Profiler output.</li>
+                       <li>Deprecated Scaffolding.</li>
+                       <li>Added is_really_writable() to Common.php to provide a cross-platform reliable method of testing file/folder writability.</li>
+               </ul>
+       </li>
+
+       <li>Libraries
+               <ul>
+                       <li>Changed the load protocol of Models to allow for extension.</li>
+                       <li>Strengthened the Encryption library to help protect against man in the middle attacks when MCRYPT_MODE_CBC mode is used.</li>
+                       <li>Added Flashdata variables, session_id regeneration and configurable session update times to the <a href="./libraries/sessions.html">Session class.</a></li>
+                       <li>Removed 'last_visit' from the Session class.</li>
+                       <li>Added a language entry for valid_ip validation error.</li>
+                       <li>Modified prep_for_form() in the Validation class to accept arrays, adding support for POST array validation (via callbacks only)</li>
+                       <li>Added an &quot;integer&quot; rule into the Validation library.</li>
+                       <li>Added valid_base64() to the Validation library.</li>
+                       <li>Documented clear() in the <a href="../libraries/image_lib.html">Image Processing</a> library.</li>
+                       <li>Changed the behaviour of custom callbacks so that they no longer trigger the &quot;required&quot; rule. </li>
+                       <li>Modified Upload class $_FILES error messages to be more precise.</li>
+                       <li>Moved the safe mode and auth checks for the Email library into the constructor. </li>
+                       <li>Modified variable names in _ci_load() method of Loader class to avoid conflicts with view variables.</li>
+                       <li>Added a few additional mime type variations for CSV.</li>
+                       <li>Enabled the 'system' methods for the XML-RPC Server library, except for 'system.multicall' which is still disabled.</li>
+               </ul>
+       </li>
+
+       <li>Helpers &amp; Plugins
+               <ul>
+                       <li>Added link_tag() to the <a href="./helpers/html_helper.html">HTML helper.</a></li>
+                       <li>Added img() to the <a href="./helpers/html_helper.html">HTML helper.</a></li>
+                       <li>Added ability to <a href="./general/helpers.html">"extend" Helpers</a>.</li>
+                       <li>Added an <a href="./helpers/email_helper.html">email helper</a> into core helpers.</li>
+                       <li>Added <kbd>strip_quotes()</kbd> function to <a href="./helpers/string_helper.html">string helper</a>.</li>
+                       <li>Added <kbd>reduce_multiples()</kbd> function to <a href="./helpers/string_helper.html">string helper</a>.</li>
+                       <li>Added <kbd>quotes_to_entities()</kbd> function to <a href="./helpers/string_helper.html">string helper</a>.</li>
+                       <li>Added <kbd>form_fieldset()</kbd>, <kbd>form_fieldset_close()</kbd>, <kbd>form_label()</kbd>, and <kbd>form_reset()</kbd> function to <a href="./helpers/form_helper.html">form helper</a>.</li>
+                       <li>Added support for external urls in <kbd>form_open()</kbd>.</li>
+                       <li>Removed support for db_backup in MySQLi due to incompatible functions.</li>
+                       <li>Javascript Calendar plugin now uses the months and days from the calendar language file, instead of hard-coded values, internationalizing it.</li>
+               </ul>
+       </li>
+
+
+       <li>Documentation Changes
+               <ul>
+                       <li>Added <a href="./doc_style/index.html">Writing Documentation</a> section for the community to use in writing their own documentation.</li>
+                       <li>Added titles to all user manual pages.</li>
+                       <li>Added attributes into &lt;html&gt; of userguide for valid html.</li>
+                       <li>Added <a href="http://codeigniter.com/user_guide/libraries/zip.html">Zip Encoding Class</a> to the table of contents of the userguide.</li>
+                       <li>Moved part of the userguide menu javascript to an external file.</li>
+                       <li>Documented <kbd>distinct()</kbd> in <a href="./database/active_record.html">Active Record</a>. </li>
+                       <li>Documented the <kbd>timezones()</kbd> function in the <a href="./helpers/date_helper.html">Date Helper</a>.</li>
+                       <li>Documented unset_userdata in the <a href="./libraries/sessions.html">Session class</a>.</li>
+                       <li>Documented 2 config options to the <a href="./database/configuration.html">Database configuration</a> page.</li>
+               </ul>
+       </li>
+</ul>
+
+<h3>Bug fixes for Version 1.6.0</h3>
+
+<ul>
+       <li>Fixed a bug (#1813) preventing using $CI->db in the same application with returned database objects.</li>
+       <li>Fixed a bug (#1842) where the $this->uri->rsegments array would not include the 'index' method if routed to the controller without an implicit method.</li>
+       <li>Fixed a bug (#1872) where word_limiter() was not retaining whitespace.</li>
+       <li>Fixed a bug (#1890) in csv_from_result() where content that included the delimiter would break the file.</li>
+       <li>Fixed a bug (#2542)in the clean_email() method of the Email class to allow for non-numeric / non-sequential array keys.</li>
+       <li>Fixed a bug (#2545) in <kbd>_html_entity_decode_callback()</kbd> when 'global_xss_filtering' is enabled.</li>
+       <li>Fixed a bug (#2668) in the <a href="./libraries/parser.html">parser class</a> where numeric data was ignored.</li>
+       <li>Fixed a bug (#2679) where the &quot;previous&quot; pagination link would get drawn on the first page.</li>
+       <li>Fixed a bug (#2702) in _object_to_array that broke some types of inserts and updates.</li>
+       <li>Fixed a bug (#2732) in the SQLite driver for PHP 4.</li>
+       <li>Fixed a bug (#2754) in Pagination to scan for non-positive num_links.</li>
+       <li>Fixed a bug (#2762) in the <a href="./libraries/sessions.html">Session library</a> where user agent matching would fail on user agents ending with a space. </li>
+       <li>Fixed a bug (#2784) $field_names[] vs $Ffield_names[] in postgres and sqlite drivers.</li>
+       <li>Fixed a bug (#2810) in the typography helper causing extraneous paragraph tags when string contains tags.</li>
+       <li>Fixed a bug (#2849) where arguments passed to a subfolder controller method would be incorrectly shifted, dropping the 3rd segment value.</li>
+       <li>Fixed a bug (#2858) which referenced a wrong variable in the Image class.</li>
+       <li>Fixed a bug (#2875)when loading plugin files as _plugin. and not _pi.</li>
+       <li>Fixed a bug (#2912) in <kbd>get_filenames()</kbd> in the <a href="./helpers/file_helper.html">File Helper </a>where the array wasn't cleared after each call.</li>
+       <li>Fixed a bug (#2974) in <kbd>highlight_phrase()</kbd> that caused an error with slashes.</li>
+       <li>Fixed a bug (#3003) in the Encryption Library to support modes other than MCRYPT_MODE_ECB</li>
+       <li>Fixed a bug (#3015) in the <a href="./libraries/user_agent.html">User Agent library</a> where more then 2 languages where not reported with languages().</li>
+       <li>Fixed a bug (#3017) in the <a href="./libraries/email.html">Email</a> library where some timezones were calculated incorrectly. </li>
+       <li>Fixed a bug (#3024) in which master_dim wasn't getting reset by clear() in the Image library.</li>
+       <li>Fixed a bug (#3156) in Text Helper highlight_code() causing PHP tags to be handled incorrectly.</li>
+       <li>Fixed a bug (#3166) that prevented num_rows from working in Oracle.</li>
+       <li>Fixed a bug (#3175) preventing certain libraries from working properly when autoloaded in PHP 4.</li>
+       <li>Fixed a bug (#3267) in the Typography Helper where unordered list was listed &quot;un.</li>
+       <li>Fixed a bug (#3268) where the Router could leave '/' as the path.</li>
+       <li>Fixed a bug (#3279) where the Email class was sending the wrong Content-Transfer-Encoding for some character sets.</li>
+       <li>Fixed a bug (#3284) where the rsegment array would not be set properly if the requested URI contained more segments than the routed URI.</li>
+       <li>Removed extraneous load of $CFG in _display_cache() of the Output class (#3285).</li>
+       <li>Removed an extraneous call to loading models (#3286).</li>
+       <li>Fixed a bug (#3310) with sanitization of globals in the Input class that could unset CI's global variables.</li>
+       <li>Fixed a bug (#3314) which would cause the top level path to be deleted in delete_files() of the File helper.</li>
+       <li>Fixed a bug (#3328) where the smiley helper might return an undefined variable.</li>
+       <li>Fixed a bug (#3330) in the FTP class where a comparison wasn't getting made.</li>
+       <li>Removed an unused parameter from Profiler (#3332).</li>
+       <li>Fixed a bug in database driver where num_rows property wasn't getting updated.</li>
+       <li>Fixed a bug in the <a href="./libraries/file_uploading.html">upload library</a> when allowed_files wasn't defined.</li>
+       <li>Fixed a bug in <kbd>word_wrap()</kbd> of the Text Helper that incorrectly referenced an object. </li>
+       <li>Fixed a bug in Validation where <kbd>valid_ip()</kbd> wasn't called properly.</li>
+       <li>Fixed a bug in Validation where individual error messages for checkboxes wasn't supported.</li>
+       <li>Fixed a bug in captcha calling an invalid PHP function.</li>
+       <li>Fixed a bug in the cookie helper "set_cookie" function.  It was not honoring the config settings.</li>
+       <li>Fixed a bug that was making validation callbacks required even when not set as such.</li>
+       <li>Fixed a bug in the XML-RPC library so if a type is specified, a more intelligent decision is made as to the default type.</li>
+       <li>Fixed an example of comma-separated emails in the email library documentation.</li>
+       <li>Fixed an example in the Calendar library for Showing Next/Previous Month Links.</li>
+       <li>Fixed a typo in the database language file.</li>
+       <li>Fixed a typo in the image language file &quot;suppor&quot; to &quot;support&quot;.</li>
+       <li>Fixed an example for XML RPC.</li>
+       <li>Fixed an example of <kbd>accept_charset()</kbd> in the <a href="./libraries/user_agent.html">User Agent Library</a>.</li>
+       <li>Fixed a typo in the docblock comments that had CodeIgniter spelled CodeIgnitor.</li>
+       <li>Fixed a typo in the <a href="./helpers/string_helper.html">String Helper</a> (uniquid changed to uniqid).</li>
+       <li>Fixed typos in the email Language class (email_attachment_unredable, email_filed_smtp_login), and FTP Class (ftp_unable_to_remame).</li>
+       <li>Added a stripslashes()  into the Upload Library.</li>
+       <li>Fixed a series of grammatical and spelling errors in the language files.</li>
+       <li>Fixed assorted user guide typos.</li>
+</ul>
+<h2>Version 1.5.4</h2>
+<p>Release Date: July 12, 2007 </p>
+<ul>
+       <li>Added <a href="./libraries/language.html">custom Language files</a> to the <a href="./general/autoloader.html">autoload</a> options. </li>
+       <li>Added stripslashes() to the _clean_input_data() function in the <a href="./libraries/input.html">Input class</a> when magic quotes is on so that data will always be un-slashed within the framework.</li>
+       <li>Added array to string into the <a href="general/profiling.html">profiler</a>.</li>
+       <li>Added some additional mime types in application/config/mimes.php.</li>
+       <li>Added filename_security() method to <a href="./libraries/input.html">Input library</a>.</li>
+       <li>Added some additional arguments to the <a href="./helpers/inflector_helper.html">Inflection helper</a> singular() to compensate for words ending in "s".  Also added a force parameter to pluralize().</li>
+       <li>Added $config['charset'] to the config file.  Default value is 'UTF-8', used in some string handling functions.</li>
+       <li>Fixed MSSQL insert_id().</li>
+       <li>Fixed a logic error in the DB trans_status() function.  It was incorrectly returning TRUE on failure and FALSE on success.</li>
+       <li>Fixed a bug that was allowing multiple load attempts on extended classes.</li>
+       <li>Fixed a bug in the bootstrap file that was incorrectly attempting to discern the full server path even when it was explicity set by the user.</li>
+       <li>Fixed a bug in the escape_str() function in the MySQL driver.</li>
+       <li>Fixed a typo in the <a href="./libraries/calendar.html">Calendar library </a> </li>
+       <li>Fixed a typo in rpcs.php library</li>
+       <li>Fixed a bug in the <a href="./libraries/zip.html">Zip library</a>, providing PC Zip file compatibility with Mac OS X</li>
+       <li>Fixed a bug in router that was ignoring the scaffolding route for optimization </li>
+       <li>Fixed an IP validation bug.</li>
+       <li>Fixed a bug in display of POST keys in the <a href="./general/profiling.html">Profiler</a> output</li>
+       <li>Fixed a bug in display of queries with characters that would be interpreted as HTML in the <a href="./general/profiling.html">Profiler</a> output</li>
+       <li>Fixed a bug in display of Email class print debugger with characters that would be interpreted as HTML in the debugging output</li>
+       <li>Fixed a bug in the Content-Transfer-Encoding of HTML emails with the quoted-printable MIME type</li>
+       <li>Fixed a bug where one could unset certain PHP superglobals by setting them via GET or POST data</li>
+       <li>Fixed an undefined function error in the insert_id() function of the PostgreSQL driver</li>
+       <li>Fixed various doc typos. </li>
+       <li>Documented two functions from the <a href="./helpers/string_helper.html">String helper </a> that were missing from the user guide:  trim_slashes() and reduce_double_slashes().</li>
+       <li>Docs now validate to XHTML 1 transitional</li>
+       <li>Updated the XSS Filtering to take into account the IE expression() ability and improved certain deletions to prevent possible exploits</li>
+       <li>Modified the Router so that when Query Strings are Enabled, the controller trigger and function trigger values are sanitized for filename include security.</li>
+       <li>Modified the is_image() method in the Upload library to take into account Windows IE 6/7 eccentricities when dealing with MIMEs</li>
+       <li>Modified XSS Cleaning routine to be more performance friendly and compatible with PHP 5.2's new PCRE backtrack and recursion limits.</li>
+       <li>Modified the <a href="./helpers/url_helper.html">URL Helper</a> to type cast the $title as a string in case a numeric value is supplied</li>
+       <li>Modified Form Helper form_dropdown() to type cast the keys and values of the options array as strings, allowing numeric values to be properly set as 'selected'</li>
+       <li>Deprecated the use if <kbd>is_numeric()</kbd> in various places since it allows periods.  Due to compatibility problems with <kbd>ctype_digit()</kbd>, making it unreliable in some installations, the following regular expression was used instead:  <kbd>preg_match("/[^0-9]/", $n)</kbd></li>
+       <li>Deprecated: APPVER has been deprecated and replaced with CI_VERSION for clarity. </li>
+</ul>
+<h2>Version 1.5.3</h2>
+<p>Release Date: April 15, 2007 </p>
+<ul>
+       <li>Added array to string into the profiler </li>
+       <li>Code Igniter references updated to CodeIgniter </li>
+       <li>pMachine references updated to EllisLab </li>
+       <li>Fixed a bug in the repeater function of <a href="./helpers/string_helper.html">string helper</a>. </li>
+       <li>Fixed a bug in ODBC driver </li>
+       <li>Fixed a bug in result_array() that was returning an empty array when no result is produced.</li>
+       <li>Fixed a bug in the redirect function of the <a href="./helpers/url_helper.html">url helper</a>. </li>
+       <li>Fixed an undefined variable in Loader </li>
+       <li>Fixed a version bug in the Postgres driver </li>
+       <li>Fixed a bug in the textarea function of the form helper for use with strings</li>
+       <li>Fixed doc typos. </li>
+</ul>
+<h2>Version 1.5.2</h2>
+<p>Release Date: February 13, 2007 </p>
+<ul>
+       <li>Added <a href="./installation/downloads.html#svn">subversion information</a> to the <a href="./installation/downloads.html">downloads</a> page. </li>
+       <li>Added support for captions in the <a href="./libraries/table.html">Table Library</a> </li>
+       <li>Fixed a bug in the <a href="./helpers/download_helper.html">download_helper</a> that was causing Internet Explorer to load rather than download </li>
+       <li>Fixed a bug in the Active Record Join function that was not taking table prefixes into consideration.</li>
+       <li>Removed unescaped variables in error messages of Input and Router classes</li>
+       <li>Fixed a bug in the Loader that was causing errors on Libraries loaded twice. A debug message is now silently made in the log.  </li>
+       <li>Fixed a bug in the <a href="./helpers/form_helper.html">form helper</a> that gave textarea a value attribute </li>
+       <li>Fixed a bug in the <a href="./libraries/image_lib.php">Image Library</a> that was ignoring resizing the same size image </li>
+       <li>Fixed some doc typos.</li>
+</ul>
+
+
+<h2>Version 1.5.1</h2>
+<p>Release Date: November 23, 2006</p>
+<ul>
+       <li>Added support for submitting arrays of libraries in the $this-&gt;load-&gt;library function.</li>
+       <li>Added support for naming custom library files in lower or uppercase.</li>
+       <li>Fixed a bug related to output buffering.</li>
+       <li>Fixed a bug in the active record class that was not resetting query data after a completed query.</li>
+       <li>Fixed a bug that was suppressing errors in controllers.</li>
+       <li>Fixed a problem that can cause a loop to occur when the config file is missing.</li>
+       <li>Fixed a bug that occurred when multiple models were loaded with the third parameter set to TRUE.</li>
+       <li>Fixed an oversight that was not unsetting globals properly in the input sanitize function.</li>
+       <li>Fixed some bugs in the Oracle DB driver.</li>
+       <li>Fixed an incorrectly named variable in the MySQLi result driver.</li>
+       <li>Fixed some doc typos.</li>
+</ul>
+<h2>Version 1.5.0.1</h2>
+<p>Release Date: October 31, 2006</p>
+<ul>
+<li>Fixed a problem in which duplicate attempts to load helpers and classes were not being stopped.</li>
+<li>Fixed a bug in the word_wrap() helper function.</li>
+<li>Fixed an invalid color Hex number in the Profiler class.</li>
+<li>Fixed a corrupted image in the user guide.</li>
+</ul>
+
+
+
+<h2>Version 1.5.0</h2>
+<p>Release Date: October 30, 2006</p>
+
+<ul>
+<li>Added <a href="./database/utilities.html">DB utility class</a>, permitting DB backups, CVS or XML files from DB results, and various other functions.</li>
+<li>Added <a href="./database/caching.html">Database Caching Class</a>.</li>
+<li>Added <a href="./database/transactions.html">transaction support</a> to the database classes.</li>
+<li>Added <a href="./general/profiling.html">Profiler Class</a> which generates a report of Benchmark execution times, queries, and POST data at the bottom of your pages.</li>
+<li>Added <a href="./libraries/user_agent.html">User Agent Library</a> which allows browsers, robots, and mobile devises to be identified.</li>
+<li>Added <a href="./libraries/table.html">HTML Table Class</a> , enabling tables to be generated from arrays or database results.</li>
+<li>Added <a href="./libraries/zip.html">Zip Encoding Library</a>.</li>
+<li>Added <a href="./libraries/ftp.html">FTP Library</a>.</li>
+<li>Added the ability to <a href="./general/creating_libraries.html">extend libraries</a> and <a href="./general/core_classes.html">extend core classes</a>, in addition to being able to replace them.</li>
+<li>Added support for storing <a href="./general/models.html">models within sub-folders</a>.</li>
+<li>Added <a href="./helpers/download_helper.html">Download Helper</a>.</li>
+<li>Added <a href="./database/queries.html">simple_query()</a> function to the database classes</li>
+<li>Added <a href="./helpers/date_helper.html">standard_date()</a> function to the Date Helper.</li>
+<li>Added <a href="./database/results.html">$query->free_result()</a> to database class.</li>
+<li>Added <a href="./database/fields.html">$query->list_fields()</a> function to database class</li>
+<li>Added <a href="./database/helpers.html">$this->db->platform()</a> function</li>
+<li>Added new <a href="./helpers/file_helper.html">File Helper</a>:  get_filenames()</li>
+<li>Added new helper:  <a href="./helpers/smiley_helper.html">Smiley Helper</a></li>
+<li>Added support for &lt;ul> and &lt;ol> lists in the  <a href="./helpers/html_helper.html">HTML Helper</a></li>
+<li>Added the ability to rewrite <a href="./general/alternative_php.html">short tags</a> on-the-fly, converting them to standard PHP statements, for those servers that do not support short tags.  This allows the cleaner syntax to be used regardless of whether it's supported by the server.</li>
+<li>Added the ability to <a href="./general/managing_apps.html">rename or relocate the "application" folder</a>.</li>
+<li>Added more thorough initialization in the upload class so that all class variables are reset.</li>
+<li>Added "is_numeric" to validation, which uses the native PHP is_numeric function.</li>
+<li>Improved the URI handler to make it more reliable when the $config['uri_protocol'] item is set to AUTO.</li>
+<li>Moved most of the functions in the Controller class into the Loader class, allowing fewer reserved function names for controllers when running under PHP 5.</li>
+<li>Updated the DB Result class to return an empty array when $query->result() doesn't produce a result.</li>
+<li>Updated the <dfn>input->cookie()</dfn> and <dfn>input->post()</dfn> functions in <a href="./libraries/input.html">Input Class</a> to permit arrays contained cookies that are arrays to be run through the XSS filter.</li>
+<li>Documented three functions from the <a href="./libraries/validation.html">Validation class</a> that were missing from the user guide:  set_select(), set_radio(), and set_checkbox().</li>
+<li>Fixed a bug in the Email class related to SMTP Helo data.</li>
+<li>Fixed a bug in the word wrapping helper and function in the email class.</li>
+<li>Fixed a bug in the validation class.</li>
+<li>Fixed a bug in the typography helper that was incorrectly wrapping block level elements in paragraph tags.</li>
+<li>Fixed a problem in the form_prep() function that was double encoding entities.</li>
+<li>Fixed a bug that affects some versions of PHP when output buffering is nested.</li>
+<li>Fixed a bug that caused CI to stop working when the PHP magic __get() or __set() functions were used within models or controllers.</li>
+<li>Fixed a pagination bug that was permitting negative values in the URL.</li>
+<li>Fixed an oversight in which the Loader class was not allowed to be extended.</li>
+<li>Changed <dfn>_get_config()</dfn> to <dfn>get_config()</dfn> since the function is not a private one.</li>
+<li><strong>Deprecated "init" folder</strong>.  Initialization happens automatically now.  <a href="./general/creating_libraries.html">Please see documentation</a>.</li>
+<li><strong>Deprecated</strong> $this->db->field_names()  USE  $this->db->list_fields()</li>
+<li><strong>Deprecated</strong> the <dfn>$config['log_errors']</dfn> item from the config.php file.  Instead, <dfn>$config['log_threshold']</dfn> can be set to "0" to turn it off.</li>
+</ul>
+
+
+
+
+<h2>Version 1.4.1</h2>
+<p>Release Date: September 21, 2006</p>
+
+<ul>
+<li>Added a new feature that passes URI segments directly to your function calls as parameters. See the <a href="./general/controllers.html">Controllers</a> page for more info.</li>
+<li>Added support for a function named <dfn>_output()</dfn>, which when used in your controllers will received the final rendered output from the output class.  More info in the <a href="controllers.html">Controllers</a> page.</li>
+<li>Added several new functions in the <a href="./libraries/uri.html">URI Class</a> to let you retrieve and manipulate URI segments that have been re-routed using the <a href="routing.html">URI Routing</a> feature. Previously, the URI class did not permit you to access any re-routed URI segments, but now it does.</li>
+<li>Added <a href="./libraries/output.html">$this->output->set_header()</a> function, which allows you to set server headers.</li>
+<li>Updated plugins, helpers, and language classes to allow your <dfn>application</dfn> folder to contain its own plugins, helpers, and language folders.  Previously they were always treated as global for your entire installation.  If your application folder contains any of these resources they will be used <em>instead</em> the global ones.</li>
+<li>Added <a href="./helpers/inflector_helper.html">Inflector helper</a>.</li>
+<li>Added <dfn>element()</dfn> function in the <a href="./helpers/array_helper.html">array helper</a>.</li>
+<li>Added <dfn>RAND()</dfn> to active record <dfn>orderby()</dfn> function.</li>
+<li>Added <dfn>delete_cookie()</dfn> and <dfn>get_cookie()</dfn> to <a href="./helpers/cookie_helper.html">Cookie helper</a>, even though the input class has a cookie fetching function.</li>
+<li>Added Oracle database driver (still undergoing testing so it might have some bugs).</li>
+<li>Added the ability to combine pseudo-variables and php variables in the template parser class.</li>
+<li>Added output compression option to the config file.</li>
+<li>Removed the is_numeric test from the db->escape() function.</li>
+<li>Fixed a MySQLi bug that was causing error messages not to contain proper error data.</li>
+<li>Fixed a bug in the email class which was causing it to ignore explicitly set alternative headers.</li>
+<li>Fixed a bug that was causing a PHP error when the Exceptions class was called within the get_config() function since it was causing problems.</li>
+<li>Fixed an oversight in the cookie helper in which the config file cookie settings were not being honored.</li>
+<li>Fixed an oversight in the upload class. An item mentioned in the 1.4 changelog was missing.</li>
+<li>Added some code to allow email attachments to be reset when sending batches of email.</li>
+<li>Deprecated the <dfn>application/scripts</dfn> folder. It will continue to work for legacy users, but it is recommended that you create your own
+<a href="./general/libraries.html">libraries</a> or <a href="./general/models.html">models</a> instead.  It was originally added before CI had user libraries or models, but it's not needed anymore.</li>
+<li>Deprecated the <dfn>$autoload['core']</dfn> item from the <kbd>autoload.php</kbd> file.  Instead, please now use: <kbd>$autoload['libraries']</kbd></li>
+<li>Deprecated the following database functions: $this->db->smart_escape_str() and $this->db->fields().</li>
+</ul>
+
+
+
+<h2>Version 1.4.0</h2>
+<p>Release Date: September 17, 2006</p>
+
+<ul>
+<li>Added <a href="./general/hooks.html">Hooks</a> feature, enabling you to tap into and modify the inner workings of the framework without hacking the core files.</li>
+<li>Added the ability to organize controller files <a href="./general/controllers.html">into sub-folders</a>.  Kudos to Marco for <a href="http://codeigniter.com/forums/viewthread/627/">suggesting</a> this (and the next two) feature.</li>
+<li>Added regular expressions support for <a href="./general/routing.html">routing rules</a>.</li>
+<li>Added the ability to <a href="./general/controllers.html">remap function calls</a> within your controllers.</li>
+<li>Added the ability to <a href="./general/core_classes.html">replace core system classes</a> with your own classes.</li>
+<li>Added support for % character in URL.</li>
+<li>Added the ability to supply full URLs using the <a href="./helpers/url_helper.html">anchor()</a> helper function.</li>
+<li>Added mode parameter to <a href="./helpers/file_helper.html">file_write()</a> helper.</li>
+<li>Added support for changing the port number in the <a href="./database/configuration.html">Postgres driver</a>.</li>
+<li>Moved the list of "allowed URI characters" out of the Router class and into the config file.</li>
+<li>Moved the MIME type array out of the Upload class and into its own file in the applications/config/ folder.</li>
+<li>Updated the Upload class to allow the upload field name to be set when calling <a href="./libraries/file_uploading.html">do_upload()</a>.</li>
+<li>Updated the <a href="./libraries/config.html">Config Library</a> to be able to load config files silently, and to be able to assign config files to their own index (to avoid collisions if you use multiple config files).</li>
+<li>Updated the URI Protocol code to allow more options so that URLs will work more reliably in different environments.</li>
+<li>Updated the <dfn>form_open()</dfn> helper to allow the GET method to be used.</li>
+<li>Updated the MySQLi <dfn>execute()</dfn> function with some code to help prevent lost connection errors.</li>
+<li>Updated the SQLite Driver to check for object support before attempting to return results as objects.  If unsupported it returns an array.</li>
+<li>Updated the Models loader function to allow multiple loads of the same model.</li>
+<li>Updated the MS SQL driver so that single quotes are escaped.</li>
+<li>Updated the Postgres and ODBC drivers for better compatibility.</li>
+<li>Removed a strtolower() call that was changing URL segments to lower case.</li>
+<li>Removed some references that were interfering with PHP 4.4.1 compatibility.</li>
+<li>Removed backticks from Postgres class since these are not needed.</li>
+<li>Renamed <dfn>display()</dfn> to <dfn>_display()</dfn> in the Output class to make it clear that it's a private function.</li>
+<li>Deprecated the hash() function due to a naming conflict with a native PHP function with the same name.  Please use <kbd>dohash()</kbd> instead.</li>
+<li>Fixed an bug that was preventing the input class from unsetting GET variables.</li>
+<li>Fixed a router bug that was making it too greedy when matching end segments.</li>
+<li>Fixed a bug that was preventing multiple discrete database calls.</li>
+<li>Fixed a bug in which loading a language file was producing a "file contains no data" message.</li>
+<li>Fixed a session bug caused by the XSS Filtering feature inadvertently changing the case of certain words.</li>
+<li>Fixed some missing prefixes when using the database prefix feature.</li>
+<li>Fixed a typo in the Calendar class (cal_november).</li>
+<li>Fixed a bug in the <dfn>form_checkbox()</dfn> helper.</li>
+<li>Fixed a bug that was allowing the second segment of the URI to be identical to the class name.</li>
+<li>Fixed an evaluation bug in the database initialization function.</li>
+<li>Fixed a minor bug in one of the error messages in the language class.</li>
+<li>Fixed a bug in the date helper <dfn>timespan</dfn> function.</li>
+<li>Fixed an undefined variable in the DB Driver class.</li>
+<li>Fixed a bug in which dollar signs used as binding replacement values in the DB class would be treated as RegEx back-references.</li>
+<li>Fixed a bug in the <dfn>set_hash()</dfn> function which was preventing MD5 from being used.</li>
+<li>Fixed a couple bugs in the Unit Testing class.</li>
+<li>Fixed an incorrectly named variable in the Validation class.</li>
+<li>Fixed an incorrectly named variable in the URI class.</li>
+<li>Fixed a bug in the config class that was preventing the base URL from being called properly.</li>
+<li>Fixed a bug in the validation class that was not permitting callbacks if the form field was empty.</li>
+<li>Fixed a problem that was preventing scaffolding from working properly with MySQLi.</li>
+<li>Fixed some MS SQL bugs.</li>
+<li>Fixed some doc typos.</li>
+</ul>
+
+
+
+<h2>Version 1.3.3</h2>
+<p>Release Date: June 1, 2006</p>
+
+<ul>
+
+<li>Models do <strong>not</strong> connect automatically to the database as of this version. <a href="./general/models.html">More info here</a>.</li>
+<li>Updated the Sessions class to utilize the active record class when running session related queries.  Previously the queries assumed MySQL syntax.</li>
+<li>Updated alternator() function to re-initialize when called with no arguments, allowing multiple calls.</li>
+<li>Fixed a bug in the active record "having" function.</li>
+<li>Fixed a problem in the validation class which was making checkboxes be ignored when required.</li>
+<li>Fixed a bug in the word_limiter() helper function.  It was cutting off the fist word.</li>
+<li>Fixed a bug in the xss_clean function due to a PHP bug that affects some versions of html_entity_decode.</li>
+<li>Fixed a validation bug that was preventing rules from being set twice in one controller.</li>
+<li>Fixed a calendar bug that was not letting it use dynamically loaded languages.</li>
+<li>Fixed a bug in the active record class when using WHERE clauses with LIKE</li>
+<li>Fixed a bug in the hash() security helper.</li>
+<li>Fixed some typos.</li>
+</ul>
+
+
+
+
+<h2>Version 1.3.2</h2>
+<p>Release Date: April 17, 2006</p>
+
+<ul>
+<li>Changed the behavior of the validation class such that if a "required" rule is NOT explicitly stated for a field then all other tests get ignored.</li>
+<li>Fixed a bug in the Controller class that was causing it to look in the local "init" folder instead of the main system one.</li>
+<li>Fixed a bug in the init_pagination file.  The $config item was not being set correctly.</li>
+<li>Fixed a bug in the auto typography helper that was causing inconsistent behavior.</li>
+<li>Fixed a couple bugs in the Model class.</li>
+<li>Fixed some documentation typos and errata.</li>
+</ul>
+
+
+
+<h2>Version 1.3.1</h2>
+<p>Release Date: April 11, 2006</p>
+
+<ul>
+<li>Added a <a href="./libraries/unit_testing.html">Unit Testing Library</a>.</li>
+<li>Added the ability to pass objects to the <strong>insert()</strong> and <strong>update()</strong>  database functions.
+This feature enables you to (among other things) use your  <a href="./general/models.html">Model class</a> variables to run queries with. See the Models page for details.</li>
+<li>Added the ability to pass objects to the <a href="./general/views.html">view loading function</a>: $this->load->view('my_view', <var>$object</var>);</li>
+<li>Added <kbd>getwhere</kbd> function to <a href="./database/active_record.html">Active Record class</a>.</li>
+<li>Added <kbd>count_all</kbd> function to <a href="./database/active_record.html">Active Record class</a>.</li>
+<li>Added language file for scaffolding and fixed a scaffolding bug that occurs when there are no rows in the specified table.</li>
+<li>Added <a href="./database/queries.html">$this->db->last_query()</a>, which allows you to view your last query that was run.</li>
+<li>Added a new mime type to the upload class for better compatibility.</li>
+<li>Changed how cache files are read to prevent PHP errors if the cache file contains an XML tag, which PHP wants to interpret as a short tag.</li>
+<li>Fixed a bug in a couple of the active record functions (where and orderby).</li>
+<li>Fixed a bug in the image library when realpath() returns false.</li>
+<li>Fixed a bug in the Models that was preventing libraries from being used within them.</li>
+<li>Fixed a bug in the "exact_length" function of the validation class.</li>
+<li>Fixed some typos in the user guide</li>
+</ul>
+
+
+<h2>Version 1.3</h2>
+<p>Release Date: April 3, 2006</p>
+
+<ul>
+<li>Added support for <a href="models.html">Models</a>.</li>
+<li>Redesigned the database libraries to support additional RDBMs (Postgres, MySQLi, etc.).</li>
+<li>Redesigned the <a href="./database/active_record.html">Active Record class</a> to enable more varied types of queries with simpler syntax, and advanced features like JOINs.</li>
+<li>Added a feature to the database class that lets you run <a href="./database/call_function.html">custom function calls</a>.</li>
+<li>Added support for <a href="controllers.html">private functions</a> in your controllers.  Any controller function name that starts with an underscore will not be served by a URI request.</li>
+<li>Added the ability to pass your own initialization parameters to your <a href="creating_libraries.html">custom core libraries</a> when using $this->load->library()</li>
+<li>Added support for running standard <a href="urls.html">query string URLs</a>.  These can be optionally enabled in your config file.</li>
+<li>Added the ability to  <a href="urls.html">specify a "suffix"</a>, which will be appended to your URLs.  For example, you could add .html to your URLs, making them appear static. This feature is enabled in your config file.</li>
+<li>Added a new error template for use with native PHP errors.</li>
+<li>Added "alternator" function in the <a href="./helpers/string_helper.html">string helpers</a>.</li>
+<li>Removed slashing from the input class. After much debate we decided to kill this feature.</li>
+<li>Change the commenting style in the scripts to the PEAR standard so that IDEs and tools like phpDocumenter can harvest the comments.</li>
+<li>Added better class and function name-spacing to avoid collisions with user developed classes. All CodeIgniter classes are now prefixed with <dfn>CI_</dfn> and
+all controller methods are prefixed with <dfn>_ci</dfn> to avoid controller collisions. A list of reserved function names can be <a href="controllers.html">found here</a>.</li>
+<li>Redesigned how the "CI" super object is referenced, depending on whether PHP 4 or 5 is being run, since PHP 5 allows a more graceful way to manage objects that utilizes a bit less resources.</li>
+<li>Deprecated: <var>$this->db->use_table()</var> has been deprecated. Please read the <a href="./database/active_record.html">Active Record</a> page for information.</li>
+<li>Deprecated: <var>$this->db->smart_escape_str()</var> has been deprecated. Please use this instead: <var>$this->db->escape()</var></li>
+<li>Fixed a bug in the exception handler which was preventing some PHP errors from showing up.</li>
+<li>Fixed a typo in the URI class.  $this->total_segment() should be plural: $this->total_segments()</li>
+<li>Fixed some typos in the default calendar template</li>
+<li>Fixed some typos in the user guide</li>
+</ul>
+
+
+
+
+
+
+
+
+<h2>Version 1.2</h2>
+<p>Release Date: March 21, 2006</p>
+
+<ul>
+<li>Redesigned some internal aspects of the framework to resolve scoping problems that surfaced during the beta tests. The problem was most notable when instantiating classes in your constructors, particularly if those classes in turn did work in their constructors.</li>
+<li>Added a global function named <a href="ancillary_classes.html">get_instance()</a> allowing the main CodeIgniter object to be accessible throughout your own classes.</li>
+<li>Added new <a href="./helpers/file_helper.html">File Helper</a>:  delete_files()</li>
+<li>Added new <a href="./helpers/url_helper.html">URL Helpers</a>:  base_url(), index_page()</li>
+<li>Added the ability to create your own <a href="creating_libraries.html">core libraries</a> and store them in your local application directory.</li>
+<li>Added an <kbd>overwrite</kbd> option to the <a href="./libraries/file_uploading.html">Upload class</a>, enabling files to be overwritten rather than having the file name appended.</li>
+<li>Added Javascript Calendar plugin.</li>
+<li>Added search feature to user guide.  Note: This is done using Google, which at the time of this writing has not crawled all the pages of the docs.</li>
+<li>Updated the parser class so that it allows tag pars within other tag pairs.</li>
+<li>Fixed a bug in the DB "where" function.</li>
+<li>Fixed a bug that was preventing custom config files to be auto-loaded.</li>
+<li>Fixed a bug in the mysql class bind feature that prevented question marks in the replacement data.</li>
+<li>Fixed some bugs in the xss_clean function</li>
+</ul>
+
+
+
+
+
+<h2>Version Beta 1.1</h2>
+<p>Release Date: March 10, 2006</p>
+
+<ul>
+<li>Added a <a href="./libraries/calendar.html">Calendaring class</a>.</li>
+<li>Added support for running <a href="managing_apps.html">multiple applications</a> that share a common CodeIgniter backend.</li>
+<li>Moved the "uri protocol" variable from the index.php file into the config.php file</li>
+<li>Fixed a problem that was preventing certain function calls from working within constructors.</li>
+<li>Fixed a problem that was preventing the $this->load->library function from working in constructors.</li>
+<li>Fixed a bug that occurred when the session class was loaded using the auto-load routine.</li>
+<li>Fixed a bug that can happen with PHP versions that do not support the E_STRICT constant</li>
+<li>Fixed a data type error in the form_radio function (form helper)</li>
+<li>Fixed a bug that was preventing the xss_clean function from being called from the validation class.</li>
+<li>Fixed the cookie related config names, which were incorrectly specified as $conf rather than $config</li>
+<li>Fixed a pagination problem in the scaffolding.</li>
+<li>Fixed a bug in the mysql class "where" function.</li>
+<li>Fixed a regex problem in some code that trimmed duplicate slashes.</li>
+<li>Fixed a bug in the br() function in the HTML helper</li>
+<li>Fixed a syntax mistake in the form_dropdown function in the Form Helper.</li>
+<li>Removed the "style" attributes form the form helpers.</li>
+<li>Updated the documentation. Added "next/previous" links to each page and fixed various typos.</li>
+</ul>
+
+<h2>Version Beta 1.0 </h2>
+<p>Release Date: February 28, 2006</p>
+<p>First publicly released version.</p>
+
+</div>
+<!-- END CONTENT -->
+
+
+<div id="footer">
+<p>
+Previous Topic:&nbsp;&nbsp;<a href="license.html">License Agreement</a>
+&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+<a href="#top">Top of Page</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+<a href="index.html">User Guide Home</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+Next Topic:&nbsp;&nbsp;<a href="./general/credits.html">Credits</a>
+</p>
+<p><a href="http://codeigniter.com">CodeIgniter</a> &nbsp;&middot;&nbsp; Copyright &#169; 2006 - 2011 &nbsp;&middot;&nbsp; <a href="http://ellislab.com/">EllisLab, Inc.</a></p>
+</div>
+
+</body>
+</html>
diff --git a/user_guide/database/active_record.html b/user_guide/database/active_record.html
new file mode 100755 (executable)
index 0000000..faa13b3
--- /dev/null
@@ -0,0 +1,806 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head>
+
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+<title>Active Record : CodeIgniter User Guide</title>
+
+<style type='text/css' media='all'>@import url('../userguide.css');</style>
+<link rel='stylesheet' type='text/css' media='all' href='../userguide.css' />
+
+<script type="text/javascript" src="../nav/nav.js"></script>
+<script type="text/javascript" src="../nav/prototype.lite.js"></script>
+<script type="text/javascript" src="../nav/moo.fx.js"></script>
+<script type="text/javascript" src="../nav/user_guide_menu.js"></script>
+
+<meta http-equiv='expires' content='-1' />
+<meta http-equiv= 'pragma' content='no-cache' />
+<meta name='robots' content='all' />
+<meta name='author' content='ExpressionEngine Dev Team' />
+<meta name='description' content='CodeIgniter User Guide' />
+</head>
+<body>
+
+<!-- START NAVIGATION -->
+<div id="nav"><div id="nav_inner"><script type="text/javascript">create_menu('../');</script></div></div>
+<div id="nav2"><a name="top"></a><a href="javascript:void(0);" onclick="myHeight.toggle();"><img src="../images/nav_toggle_darker.jpg" width="154" height="43" border="0" title="Toggle Table of Contents" alt="Toggle Table of Contents" /></a></div>
+<div id="masthead">
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td><h1>CodeIgniter User Guide Version 2.0.2</h1></td>
+<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
+</tr>
+</table>
+</div>
+<!-- END NAVIGATION -->
+
+
+<!-- START BREADCRUMB -->
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td id="breadcrumb">
+<a href="http://codeigniter.com/">CodeIgniter Home</a> &nbsp;&#8250;&nbsp;
+<a href="../index.html">User Guide Home</a> &nbsp;&#8250;&nbsp;
+<a href="index.html">Database Library</a> &nbsp;&#8250;&nbsp;
+Active Record
+</td>
+<td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="codeigniter.com/user_guide/" />Search User Guide&nbsp; <input type="text" class="input" style="width:200px;" name="q" id="q" size="31" maxlength="255" value="" />&nbsp;<input type="submit" class="submit" name="sa" value="Go" /></form></td>
+</tr>
+</table>
+<!-- END BREADCRUMB -->
+
+<br clear="all" />
+
+<!-- START CONTENT -->
+<div id="content">
+
+<h1>Active Record Class</h1>
+
+<p>CodeIgniter uses a modified version of the Active Record Database Pattern.
+This pattern allows information to be retrieved, inserted, and updated in your database with minimal scripting.
+In some cases only one or two lines of code are necessary to perform a database action.
+CodeIgniter does not require that each database table be its own class file.  It instead provides a more simplified interface.</p>
+
+<p>Beyond simplicity, a major benefit to using the Active Record features is that it allows you to create database independent applications, since the query syntax
+is generated by each database adapter.  It also allows for safer queries, since the values are escaped automatically by the system.</p>
+
+<p class="important"><strong>Note:</strong>  If you intend to write your own queries you can disable this class in your database config file, allowing the core database library and adapter to utilize fewer resources.<br /></p>
+
+<ul>
+<li><a href="#select">Selecting Data</a></li>
+<li><a href="#insert">Inserting Data</a></li>
+<li><a href="#update">Updating Data</a></li>
+<li><a href="#delete">Deleting Data</a></li>
+<li><a href="#chaining">Method Chaining</a></li>
+<li><a href="#caching">Active Record Caching</a></li>
+</ul>
+
+<h1><a name="select">&nbsp;</a>Selecting Data</h1>
+
+<p>The following functions allow you to build SQL <strong>SELECT</strong> statements.</p>
+
+<p><strong>Note: If you are using PHP 5 you can use method chaining for more compact syntax. This is described at the end of the page.</strong></p>
+
+
+<h2>$this->db->get();</h2>
+
+<p>Runs the selection query and returns the result.  Can be used by itself to retrieve all records from a table:</p>
+
+<code>$query = $this->db->get('mytable');<br />
+<br />
+// Produces: SELECT * FROM mytable</code>
+
+<p>The second and third parameters enable you to set a limit and offset clause:</p>
+
+<code>$query = $this->db->get('mytable', 10, 20);<br />
+<br />
+// Produces: SELECT * FROM mytable LIMIT 20, 10 (in MySQL. Other databases have slightly different syntax)</code>
+
+<p>You'll notice that the above function is assigned to a variable named <kbd>$query</kbd>, which can be used to show the results:</p>
+
+<code>$query = $this->db->get('mytable');<br />
+<br />
+foreach ($query->result() as $row)<br />
+{<br />
+&nbsp;&nbsp;&nbsp;&nbsp;echo $row->title;<br />
+}</code>
+
+<p>Please visit the <a href="results.html">result functions</a> page for a full discussion regarding result generation.</p>
+
+
+<h2>$this->db->get_where();</h2>
+
+<p>Identical to the above function except that it permits you to add a "where" clause in the second parameter,
+instead of using the db->where() function:</p>
+
+<code>$query = $this->db->get_where('mytable', array('id' => $id), $limit, $offset);</code>
+
+<p>Please read the about the where function below for more information.</p>
+<p class="important">Note: get_where() was formerly known as getwhere(), which has been removed</p>
+
+<h2>$this->db->select();</h2>
+<p>Permits you to write the SELECT portion of your query:</p>
+<p><code>
+$this->db->select('title, content, date');<br />
+<br />
+$query = $this->db->get('mytable');<br />
+<br />
+// Produces: SELECT title, content, date FROM mytable</code></p>
+<p class="important"><strong>Note:</strong> If you are selecting all (*) from a table you do not need to use this function.  When omitted, CodeIgniter assumes you wish to SELECT *</p>
+
+<p>$this-&gt;db-&gt;select() accepts an optional second parameter. If you set it to FALSE, CodeIgniter will not try to protect your field or table names with backticks. This is useful if you need a compound select statement.</p>
+<p><code>$this-&gt;db-&gt;select('(SELECT SUM(payments.amount) FROM payments WHERE payments.invoice_id=4') AS amount_paid', FALSE); <br />
+$query = $this-&gt;db-&gt;get('mytable');<br />
+</code></p>
+<h2>$this->db->select_max();</h2>
+<p>Writes a "SELECT MAX(field)" portion for your query. You can optionally include a second parameter to rename the resulting field.</p>
+<p><code>
+$this->db->select_max('age');<br />
+$query = $this->db->get('members');<br />
+
+// Produces: SELECT MAX(age) as age FROM members<br />
+<br />
+$this-&gt;db-&gt;select_max('age', 'member_age');<br />
+$query = $this-&gt;db-&gt;get('members');<br />
+// Produces: SELECT MAX(age) as member_age FROM members</code></p>
+
+<h2>$this->db->select_min();</h2>
+<p>Writes a "SELECT MIN(field)" portion for your query. As with <dfn>select_max()</dfn>, You can optionally include a second parameter to rename the resulting field.</p>
+<p><code>
+$this->db->select_min('age');<br />
+$query = $this->db->get('members');<br />
+// Produces: SELECT MIN(age) as age FROM members</code></p>
+
+<h2>$this->db->select_avg();</h2>
+<p>Writes a "SELECT AVG(field)" portion for your query. As with <dfn>select_max()</dfn>, You can optionally include a second parameter to rename the resulting field.</p>
+<p><code>
+$this->db->select_avg('age');<br />
+$query = $this->db->get('members');<br />
+// Produces: SELECT AVG(age) as age FROM members</code></p>
+
+<h2>$this->db->select_sum();</h2>
+<p>Writes a "SELECT SUM(field)" portion for your query. As with <dfn>select_max()</dfn>, You can optionally include a second parameter to rename the resulting field.</p>
+<p><code>
+$this->db->select_sum('age');<br />
+$query = $this->db->get('members');<br />
+// Produces: SELECT SUM(age) as age FROM members</code></p>
+
+<h2>$this->db->from();</h2>
+
+<p>Permits you to write the FROM portion of your query:</p>
+
+<code>
+$this->db->select('title, content, date');<br />
+$this->db->from('mytable');<br />
+<br />
+$query = $this->db->get();<br />
+<br />
+// Produces: SELECT title, content, date FROM mytable</code>
+
+<p class="important">Note: As shown earlier, the FROM portion of your query can be specified in the <dfn>$this->db->get()</dfn> function, so use whichever method
+you prefer.</p>
+
+<h2>$this->db->join();</h2>
+
+<p>Permits you to write the JOIN portion of your query:</p>
+
+<code>
+$this->db->select('*');<br />
+$this->db->from('blogs');<br />
+$this->db->join('comments', 'comments.id = blogs.id');<br />
+<br />
+$query = $this->db->get();<br />
+<br />
+// Produces: <br />
+// SELECT * FROM blogs<br />
+// JOIN comments ON comments.id = blogs.id<br />
+</code>
+
+<p>Multiple function calls can be made if you need several joins in one query.</p>
+
+<p>If you need a specific type of JOIN you can specify it via the third parameter of the function.
+Options are: left, right, outer, inner, left outer, and right outer.</p>
+
+<code>
+$this->db->join('comments', 'comments.id = blogs.id', <strong>'left'</strong>);<br />
+<br />
+// Produces: LEFT JOIN comments ON comments.id = blogs.id</code>
+
+
+
+
+
+<h2>$this->db->where();</h2>
+<p>This function enables you to set <strong>WHERE</strong> clauses using one of four methods:</p>
+
+<p class="important"><strong>Note:</strong> All values passed to this function are escaped automatically, producing safer queries.</p>
+
+<ol>
+       <li><strong>Simple key/value method:</strong>
+
+       <code>$this->db->where('name', $name);
+       <br /><br />// Produces: WHERE name = 'Joe'     </code>
+
+       <p>Notice that the equal sign is added for you.</p>
+
+       <p>If you use multiple function calls they will be chained together with <var>AND</var> between them:</p>
+
+       <code>$this->db->where('name', $name);<br />
+       $this->db->where('title', $title);<br />
+       $this->db->where('status', $status);
+       <br /><br />// WHERE name = 'Joe' AND title = 'boss' AND status = 'active'      </code> </li>
+
+       <li><strong>Custom key/value method:</strong>
+
+       <p>You can include an operator in the first parameter in order to control the comparison:</p>
+
+       <code>$this->db->where('name !=', $name);<br />
+       $this->db->where('id <', $id);
+       <br /><br />// Produces: WHERE name != 'Joe' AND id < 45        </code> </li>
+       <li><strong>Associative array method:</strong>
+
+
+       <code>
+       $array = array('name' => $name, 'title' => $title, 'status' => $status);<br /><br />
+
+       $this->db->where($array);
+       <br /><br />// Produces: WHERE name = 'Joe' AND title = 'boss' AND status = 'active'    </code>
+
+       <p>You can include your own operators using this method as well:</p>
+
+       <code>
+       $array = array('name !=' => $name, 'id <' => $id, 'date >' => $date);<br /><br />
+
+       $this->db->where($array);</code>        </li>
+               <li><strong>Custom string:</strong>
+
+               <p>You can write your own clauses manually:</p>
+
+               <code>
+               $where = "name='Joe' AND status='boss' OR status='active'";<br /><br />
+               $this->db->where($where);</code></li>
+       </ol>
+
+
+<p>$this-&gt;db-&gt;where() accepts an optional third parameter. If you set it to FALSE, CodeIgniter will not try to protect your field or table names with backticks.</p>
+<p><code>              $this-&gt;db-&gt;where('MATCH (field) AGAINST (&quot;value&quot;)', NULL, FALSE);<br />
+</code></p>
+<h2>$this->db->or_where();</h2>
+<p>This function is identical to the one above, except that multiple instances are joined by OR:</p>
+
+<code>
+$this->db->where('name !=', $name);<br />
+$this->db->or_where('id >', $id);
+<br />
+<br />// Produces: WHERE name != 'Joe' OR id > 50</code>
+
+<p class="important">Note: or_where() was formerly known as orwhere(), which has been removed.</p>
+
+
+<h2>$this->db->where_in();</h2>
+<p>Generates a WHERE field IN ('item', 'item') SQL query joined with  AND if appropriate</p>
+<p><code>
+       $names = array('Frank', 'Todd', 'James');<br />
+       $this->db->where_in('username', $names);<br />
+       // Produces: WHERE username IN ('Frank', 'Todd', 'James')</code></p>
+
+<h2>$this->db->or_where_in();</h2>
+<p>Generates a WHERE field IN ('item', 'item') SQL query joined with OR if appropriate</p>
+<p><code>
+       $names = array('Frank', 'Todd', 'James');<br />
+       $this->db->or_where_in('username', $names);<br />
+       // Produces: OR username IN ('Frank', 'Todd', 'James')</code></p>
+
+<h2>$this->db->where_not_in();</h2>
+<p>Generates a WHERE field NOT IN ('item', 'item') SQL query joined with AND if appropriate</p>
+<p><code>
+       $names = array('Frank', 'Todd', 'James');<br />
+       $this->db->where_not_in('username', $names);<br />
+       // Produces: WHERE username NOT IN ('Frank', 'Todd', 'James')</code></p>
+
+<h2>$this->db->or_where_not_in();</h2>
+<p>Generates a WHERE field NOT IN ('item', 'item') SQL query joined with OR if appropriate</p>
+<p><code>
+       $names = array('Frank', 'Todd', 'James');<br />
+       $this->db->or_where_not_in('username', $names);<br />
+       // Produces: OR username NOT IN ('Frank', 'Todd', 'James')</code></p>
+
+<h2>$this->db->like();</h2>
+<p>This function enables you to generate <strong>LIKE</strong> clauses, useful for doing searches.</p>
+
+<p class="important"><strong>Note:</strong> All values passed to this function are escaped automatically.</p>
+
+
+<ol>
+       <li><strong>Simple key/value method:</strong>
+
+       <code>$this->db->like('title', 'match');
+       <br /><br />// Produces: WHERE title LIKE '%match%'     </code>
+
+       <p>If you use multiple function calls they will be chained together with <var>AND</var> between them:</p>
+
+       <code>$this->db->like('title', 'match');<br />
+       $this->db->like('body', 'match');
+       <br /><br />
+       // WHERE title LIKE '%match%' AND  body LIKE '%match%</code>
+       If you want to control where the wildcard (%) is placed, you can use an optional third argument. Your options are 'before', 'after' and 'both' (which is the default).
+       <code>$this->db->like('title', 'match', 'before');
+       <br />
+               // Produces: WHERE title LIKE '%match'  <br />
+               <br />
+       $this-&gt;db-&gt;like('title', 'match', 'after'); <br />
+// Produces: WHERE title LIKE 'match%' <br />
+<br />
+       $this-&gt;db-&gt;like('title', 'match', 'both'); <br />
+// Produces: WHERE title LIKE '%match%' </code>        </li>
+
+       <li><strong>Associative array method:</strong>
+
+       <code>
+       $array = array('title' => $match, 'page1' => $match, 'page2' => $match);<br /><br />
+
+       $this->db->like($array);
+       <br /><br />// WHERE title LIKE '%match%' AND  page1 LIKE '%match%' AND  page2 LIKE '%match%'</code></li>
+       </ol>
+
+
+<h2>$this->db->or_like();</h2>
+<p>This function is identical to the one above, except that multiple instances are joined by OR:</p>
+
+<code>
+$this->db->like('title', 'match');<br />
+$this->db->or_like('body', $match);
+<br />
+<br />// WHERE title LIKE '%match%' OR  body LIKE '%match%'</code>
+
+
+
+
+<p class="important">Note: or_like() was formerly known as orlike(), which has been removed.</p>
+<h2>$this-&gt;db-&gt;not_like();</h2>
+<p>This function is identical to <strong>like()</strong>, except that it generates NOT LIKE statements:</p>
+<code> $this-&gt;db-&gt;not_like('title', 'match');<br />
+<br />
+// WHERE title NOT LIKE '%match%</code>
+<h2>$this-&gt;db-&gt;or_not_like();</h2>
+<p>This function is identical to <strong>not_like()</strong>, except that multiple instances are joined by OR:</p>
+<code> $this-&gt;db-&gt;like('title', 'match');<br />
+$this-&gt;db-&gt;or_not_like('body', 'match'); <br />
+<br />
+// WHERE title  LIKE '%match% OR body NOT LIKE '%match%'</code>
+<h2>$this->db->group_by();</h2>
+<p>Permits you to write the GROUP BY portion of your query:</p>
+
+<code>$this->db->group_by("title");
+<br /><br />// Produces: GROUP BY title
+</code>
+
+<p>You can also pass an array of multiple values as well:</p>
+
+<code>$this->db->group_by(array("title", "date"));
+<br />
+<br />// Produces: GROUP BY title, date</code>
+
+<p class="important">Note: group_by() was formerly known as groupby(), which has been removed. </p>
+
+<h2> $this-&gt;db-&gt;distinct();<br />
+</h2>
+<p>Adds the &quot;DISTINCT&quot; keyword to  a query</p>
+<p><code>$this-&gt;db-&gt;distinct();<br />
+       $this-&gt;db-&gt;get('table');<br />
+               <br />
+       // Produces: SELECT DISTINCT * FROM table</code></p>
+<h2>$this->db->having();</h2>
+<p>Permits you to write the HAVING portion of your query. There are 2 possible syntaxes, 1 argument or 2:</p>
+
+<code>$this->db->having('user_id = 45');
+<br />
+// Produces: HAVING user_id = 45<br />
+<br />
+$this-&gt;db-&gt;having('user_id',  45); <br />
+// Produces: HAVING user_id = 45<br />
+<br />
+</code>
+
+<p>You can also pass an array of multiple values as well:</p>
+
+
+<p><code>$this->db->having(array('title =' => 'My Title', 'id <' => $id)); <br />
+               <br />
+       // Produces: HAVING title = 'My Title', id < 45</code></p>
+<p>If you are using a database that CodeIgniter escapes queries for, you can prevent escaping content by passing an optional third argument, and setting it to FALSE.</p>
+<p><code>$this-&gt;db-&gt;having('user_id',  45); <br />
+// Produces: HAVING `user_id` = 45 in some databases such as MySQL
+               <br />
+               $this-&gt;db-&gt;having('user_id',  45, FALSE); <br />
+// Produces: HAVING user_id = 45</code></p>
+<h2>$this-&gt;db-&gt;or_having();</h2>
+<p>Identical to having(), only separates multiple clauses with &quot;OR&quot;.</p>
+<h2>$this->db->order_by();</h2>
+<p>Lets you set an ORDER BY clause. The first parameter contains the name of the column you would like to order by.
+The second parameter lets you set the direction of the result.  Options are <kbd>asc</kbd> or <kbd>desc</kbd>, or <kbd>random</kbd>. </p>
+
+<code>$this->db->order_by("title", "desc");
+<br />
+<br />// Produces: ORDER BY title DESC
+</code>
+
+<p>You can also pass your own string in the first parameter:</p>
+
+<code>$this->db->order_by('title desc, name asc');
+<br />
+<br />// Produces: ORDER BY title DESC, name ASC
+</code>
+
+<p>Or multiple function calls can be made if you need multiple fields.</p>
+
+<p><code>$this->db->order_by("title", "desc");<br />
+       $this->db->order_by("name", "asc"); <br />
+       <br />
+       // Produces: ORDER BY title DESC, name ASC
+       </code></p>
+<p class="important">Note: order_by() was formerly known as orderby(), which has been removed.</p>
+<p class="important">Note: random ordering is not currently supported in Oracle or MSSQL drivers. These will default to 'ASC'.</p>
+<h2>$this->db->limit();</h2>
+<p>Lets you limit the number of rows you would like returned by the query:</p>
+
+<code>
+$this->db->limit(10);<br />
+<br />
+// Produces: LIMIT 10</code>
+
+
+<p>The second parameter lets you set a result offset.</p>
+
+<code>
+$this->db->limit(10, 20);<br />
+<br />
+// Produces: LIMIT 20, 10 (in MySQL.  Other databases have slightly different syntax)</code>
+
+
+<h2>$this->db->count_all_results();</h2>
+
+<p>Permits you to determine the number of rows in a particular Active Record query. Queries will accept Active Record restrictors such as where(),  or_where(), like(), or_like(), etc. Example:</p>
+<code>echo $this->db->count_all_results('<var>my_table</var>');<br />
+
+// Produces an integer, like 25<br />
+<br />
+$this-&gt;db-&gt;like('title', 'match');<br />
+$this-&gt;db-&gt;from('<var>my_table</var>');<br />
+echo $this-&gt;db-&gt;count_all_results();<br />
+// Produces an integer, like 17 </code>
+
+<h2>$this->db->count_all();</h2>
+
+<p>Permits you to determine the number of rows in a particular table.  Submit the table name in the first parameter. Example:</p>
+
+<code>echo $this->db->count_all('<var>my_table</var>');<br />
+<br />
+// Produces an integer, like 25</code>
+
+
+
+<a name="insert">&nbsp;</a>
+<h1>Inserting Data</h1>
+
+<h2>$this->db->insert();</h2>
+<p>Generates an insert string based on the data you supply, and runs the query. You can either pass an
+<strong>array</strong> or an <strong>object</strong> to the function.  Here is an example using an array:</p>
+
+<code>
+$data = array(<br />
+&nbsp;&nbsp;&nbsp;'title' => 'My title' ,<br />
+&nbsp;&nbsp;&nbsp;'name' => 'My Name' ,<br />
+&nbsp;&nbsp;&nbsp;'date' => 'My date'<br />
+);<br />
+<br />
+$this->db->insert('mytable', $data);
+<br /><br />
+// Produces: INSERT INTO mytable (title, name, date) VALUES ('My title', 'My name', 'My date')</code>
+
+<p>The first parameter will contain the table name, the second is an associative array of values.</p>
+
+<p>Here is an example using an object:</p>
+
+<code>
+/*<br />
+&nbsp;&nbsp;&nbsp;&nbsp;class Myclass {<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;var  $title = 'My Title';<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;var  $content = 'My Content';<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;var  $date = 'My Date';<br />
+&nbsp;&nbsp;&nbsp;&nbsp;}<br />
+*/<br />
+<br />
+$object = new Myclass;<br />
+<br />
+$this->db->insert('mytable', $object);
+<br /><br />
+// Produces: INSERT INTO mytable (title, content, date) VALUES ('My Title', 'My Content', 'My Date')</code>
+
+<p>The first parameter will contain the table name, the second is an object.</p>
+
+<p class="important"><strong>Note:</strong> All values are escaped automatically producing safer queries.</p>
+
+<h2>$this->db->insert_batch();</h2>
+<p>Generates an insert string based on the data you supply, and runs the query. You can either pass an
+<strong>array</strong> or an <strong>object</strong> to the function.  Here is an example using an array:</p>
+
+<code>
+$data = array(<br/>
+&nbsp;&nbsp;&nbsp;array(<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'title' => 'My title' ,<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'name' => 'My Name' ,<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'date' => 'My date'<br />
+&nbsp;&nbsp;&nbsp;),<br />
+&nbsp;&nbsp;&nbsp;array(<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'title' => 'Another title' ,<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'name' => 'Another Name' ,<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'date' => 'Another date'<br />
+&nbsp;&nbsp;&nbsp;)<br/>
+);<br />
+<br />
+$this->db->insert_batch('mytable', $data);
+<br /><br />
+// Produces: INSERT INTO mytable (title, name, date) VALUES ('My title', 'My name', 'My date'),  ('Another title', 'Another name', 'Another date')</code>
+
+<p>The first parameter will contain the table name, the second is an associative array of values.</p>
+
+<h2>$this->db->insert_batch();</h2>
+<p>Generates an insert string based on the data you supply, and runs the query. You can either pass an
+<strong>array</strong> or an <strong>object</strong> to the function.  Here is an example using an array:</p>
+
+<code>
+$data = array(<br/>
+&nbsp;&nbsp;&nbsp;array(<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'title' => 'My title' ,<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'name' => 'My Name' ,<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'date' => 'My date'<br />
+&nbsp;&nbsp;&nbsp;),<br />
+&nbsp;&nbsp;&nbsp;array(<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'title' => 'Another title' ,<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'name' => 'Another Name' ,<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'date' => 'Another date'<br />
+&nbsp;&nbsp;&nbsp;)<br/>
+);<br />
+<br />
+$this->db->update_batch('mytable', $data);
+<br /><br />
+// Produces: INSERT INTO mytable (title, name, date) VALUES ('My title', 'My name', 'My date'),  ('Another title', 'Another name', 'Another date')</code>
+
+<p>The first parameter will contain the table name, the second is an associative array of values.</p>
+
+<p class="important"><strong>Note:</strong> All values are escaped automatically producing safer queries.</p>
+
+
+
+<h2>$this->db->set();</h2>
+<p>This function enables you to set values for <dfn>inserts</dfn> or <dfn>updates</dfn>.</p>
+
+<p><strong>It can be used instead of passing a data array directly to the insert or update functions:</strong> </p>
+
+<code>$this->db->set('name', $name);
+<br />
+$this->db->insert('mytable');
+<br /><br />
+// Produces: INSERT INTO mytable (name) VALUES ('{$name}')</code>
+
+<p>If you use multiple function called they will be assembled properly based on whether you are doing an insert or an update:</p>
+
+<code>$this-&gt;db-&gt;set('name', $name);<br />
+$this-&gt;db-&gt;set('title', $title);<br />
+$this-&gt;db-&gt;set('status', $status);<br />
+$this-&gt;db-&gt;insert('mytable'); </code>
+<p><strong>set()</strong> will also accept an optional third parameter ($escape), that will prevent data from being escaped if set to FALSE. To illustrate the difference, here is set() used both with and without the escape parameter.</p>
+<p><code>$this-&gt;db-&gt;set('field', 'field+1', FALSE);<br />
+       $this-&gt;db-&gt;insert('mytable'); <br />
+       // gives INSERT INTO mytable (field) VALUES (field+1)<br />
+       <br />
+       $this-&gt;db-&gt;set('field', 'field+1');<br />
+       $this-&gt;db-&gt;insert('mytable'); <br />
+       // gives INSERT INTO mytable (field) VALUES ('field+1')</code></p>
+<p>You can also pass an associative array to this function:</p>
+<code>
+$array = array('name' => $name, 'title' => $title, 'status' => $status);<br /><br />
+
+$this->db->set($array);<br />
+$this->db->insert('mytable');
+</code>
+
+<p>Or an object:</p>
+
+
+<code>
+/*<br />
+&nbsp;&nbsp;&nbsp;&nbsp;class Myclass {<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;var  $title = 'My Title';<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;var  $content = 'My Content';<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;var  $date = 'My Date';<br />
+&nbsp;&nbsp;&nbsp;&nbsp;}<br />
+*/<br />
+<br />
+$object = new Myclass;<br />
+<br />
+$this->db->set($object);<br />
+$this->db->insert('mytable');
+</code>
+
+
+
+<a name="update">&nbsp;</a>
+<h1>Updating Data</h1>
+
+<h2>$this->db->update();</h2>
+<p>Generates an update string and runs the query based on the data you supply.  You can pass an
+<strong>array</strong> or an <strong>object</strong> to the function. Here is an example using
+an array:</p>
+
+<code>
+$data = array(<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'title' => $title,<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'name' => $name,<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'date' => $date<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;);<br />
+<br />
+$this->db->where('id', $id);<br />
+$this->db->update('mytable', $data);
+<br /><br />
+// Produces:<br />
+// UPDATE mytable <br />
+// SET title = '{$title}', name = '{$name}', date = '{$date}'<br />
+// WHERE id = $id</code>
+
+<p>Or you can supply an object:</p>
+
+<code>
+/*<br />
+&nbsp;&nbsp;&nbsp;&nbsp;class Myclass {<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;var  $title = 'My Title';<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;var  $content = 'My Content';<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;var  $date = 'My Date';<br />
+&nbsp;&nbsp;&nbsp;&nbsp;}<br />
+*/<br />
+<br />
+$object = new Myclass;<br />
+<br />
+$this->db->where('id', $id);<br />
+$this->db->update('mytable', $object);
+<br />
+<br />
+// Produces:<br />
+// UPDATE mytable <br />
+// SET title = '{$title}', name = '{$name}', date = '{$date}'<br />
+// WHERE id = $id</code>
+
+
+
+<p class="important"><strong>Note:</strong> All values are escaped automatically producing safer queries.</p>
+
+<p>You'll notice the use of the <dfn>$this->db->where()</dfn> function, enabling you to set the WHERE clause.
+You can optionally pass this information directly into the update function as a string:</p>
+
+<code>$this->db->update('mytable', $data, "id = 4");</code>
+
+<p>Or as an array:</p>
+
+<code>$this->db->update('mytable', $data, array('id' => $id));</code>
+
+<p>You may also use the <dfn>$this->db->set()</dfn> function described above when performing updates.</p>
+
+
+<a name="delete">&nbsp;</a>
+<h1>Deleting Data</h1>
+
+
+
+<h2>$this->db->delete();</h2>
+<p>Generates a delete SQL string and runs the query.</p>
+
+<code>
+$this->db->delete('mytable', array('id' => $id));
+<br /><br />
+// Produces:<br />
+// DELETE FROM mytable <br />
+// WHERE id = $id</code>
+
+<p>The first parameter is the table name, the second is the where clause. You can also use the <dfn>where()</dfn> or <dfn>or_where()</dfn> functions instead of passing
+the data to the second parameter of the function:</p>
+
+<p><code> $this->db->where('id', $id);<br />
+       $this->db->delete('mytable'); <br />
+       <br />
+       // Produces:<br />
+       // DELETE FROM mytable <br />
+       // WHERE id = $id</code></p>
+<p>An array of table names can be passed into delete() if you would like to delete data from more than 1 table.</p>
+<p><code>$tables = array('table1', 'table2', 'table3');<br />
+$this-&gt;db-&gt;where('id', '5');<br />
+$this-&gt;db-&gt;delete($tables);</code></p>
+<p>If you want to delete all data from a table, you can use the <dfn>truncate()</dfn> function, or <dfn>empty_table()</dfn>.</p>
+<h2>$this-&gt;db-&gt;empty_table();</h2>
+<p>Generates a delete SQL string and runs the query.<code>     $this-&gt;db-&gt;empty_table('mytable'); <br />
+       <br />
+// Produces<br />
+// DELETE FROM mytable</code></p>
+<h2>$this-&gt;db-&gt;truncate();</h2>
+<p>Generates a truncate SQL string and runs the query.</p>
+<code> $this-&gt;db-&gt;from('mytable'); <br />
+$this-&gt;db-&gt;truncate(); <br />
+// or <br />
+$this-&gt;db-&gt;truncate('mytable'); <br />
+<br />
+// Produce:<br />
+// TRUNCATE mytable <br />
+</code>
+<p class="important"><strong>Note:</strong> If the TRUNCATE command isn't available, truncate() will execute as &quot;DELETE FROM table&quot;.</p>
+
+<h1><a name="chaining">&nbsp;</a>Method Chaining</h1>
+
+<p>Method chaining allows you to simplify your syntax by connecting multiple functions.  Consider this example:</p>
+
+<code>
+<dfn>$this->db</dfn><kbd>-></kbd><var>select</var>('title')<kbd>-></kbd><var>from</var>('mytable')<kbd>-></kbd><var>where</var>('id', $id)<kbd>-></kbd><var>limit</var>(10, 20);<br />
+<br />
+$query = $this->db->get();</code>
+
+<p class="important"><strong>Note:</strong> Method chaining only works with PHP 5.</p>
+
+<p>&nbsp;</p>
+
+<h1><a name="caching">&nbsp;</a>Active Record Caching</h1>
+
+<p>While not &quot;true&quot; caching, Active Record enables you to save (or &quot;cache&quot;) certain parts of your queries for reuse at a later point in your script's execution. Normally, when an Active Record call is completed, all stored information is reset for the next call. With caching, you can prevent this reset, and reuse information easily.</p>
+
+<p>Cached calls are cumulative. If you make 2 cached select() calls, and then 2 uncached select() calls, this will result in 4 select() calls. There are three Caching functions available:</p>
+
+<h2>$this-&gt;db-&gt;start_cache()</h2>
+
+<p>This function must be called to begin caching. All Active Record queries of the correct type (see below for supported queries) are stored for later use.</p>
+
+<h2>$this-&gt;db-&gt;stop_cache()</h2>
+
+<p>This function can be called to stop caching.</p>
+
+<h2>$this-&gt;db-&gt;flush_cache()</h2>
+
+<p>This function deletes all items from the Active Record cache.</p>
+
+<p>Here's a usage example:</p>
+
+<p><code>$this-&gt;db-&gt;start_cache();<br />
+$this-&gt;db-&gt;select('field1');<br />
+$this-&gt;db-&gt;stop_cache();<br /><br />
+$this-&gt;db-&gt;get('tablename');<br />
+<br />
+//Generates: SELECT `field1` FROM (`tablename`)<br />
+<br />
+$this-&gt;db-&gt;select('field2');<br />
+$this-&gt;db-&gt;get('tablename');<br />
+<br />
+//Generates:  SELECT `field1`, `field2` FROM (`tablename`)<br />
+<br />
+$this-&gt;db-&gt;flush_cache();<br />
+<br />
+$this-&gt;db-&gt;select('field2');<br />
+$this-&gt;db-&gt;get('tablename');<br />
+<br />
+//Generates:  SELECT `field2` FROM (`tablename`)</code></p>
+
+<p class="important"> <strong>Note:</strong> The following statements can be cached: select, from, join, where, like, group_by, having, order_by, set</p>
+<p>&nbsp;</p>
+</div>
+<!-- END CONTENT -->
+
+
+<div id="footer">
+<p>
+Previous Topic:&nbsp;&nbsp;<a href="helpers.html">Query Helper Functions</a>
+&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+<a href="#top">Top of Page</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+<a href="../index.html">User Guide Home</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+Next Topic:&nbsp;&nbsp;<a href="transactions.html">Transactions</a>
+</p>
+<p><a href="http://codeigniter.com">CodeIgniter</a> &nbsp;&middot;&nbsp; Copyright &#169; 2006 - 2011 &nbsp;&middot;&nbsp; <a href="http://ellislab.com/">EllisLab, Inc.</a></p>
+</div>
+
+</body>
+</html>
\ No newline at end of file
diff --git a/user_guide/database/caching.html b/user_guide/database/caching.html
new file mode 100755 (executable)
index 0000000..3f4ef2b
--- /dev/null
@@ -0,0 +1,220 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head>
+
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+<title>Database Caching Class : CodeIgniter User Guide</title>
+
+<style type='text/css' media='all'>@import url('../userguide.css');</style>
+<link rel='stylesheet' type='text/css' media='all' href='../userguide.css' />
+
+<script type="text/javascript" src="../nav/nav.js"></script>
+<script type="text/javascript" src="../nav/prototype.lite.js"></script>
+<script type="text/javascript" src="../nav/moo.fx.js"></script>
+<script type="text/javascript" src="../nav/user_guide_menu.js"></script>
+
+<meta http-equiv='expires' content='-1' />
+<meta http-equiv= 'pragma' content='no-cache' />
+<meta name='robots' content='all' />
+<meta name='author' content='ExpressionEngine Dev Team' />
+<meta name='description' content='CodeIgniter User Guide' />
+
+</head>
+<body>
+
+<!-- START NAVIGATION -->
+<div id="nav"><div id="nav_inner"><script type="text/javascript">create_menu('../');</script></div></div>
+<div id="nav2"><a name="top"></a><a href="javascript:void(0);" onclick="myHeight.toggle();"><img src="../images/nav_toggle_darker.jpg" width="154" height="43" border="0" title="Toggle Table of Contents" alt="Toggle Table of Contents" /></a></div>
+<div id="masthead">
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td><h1>CodeIgniter User Guide Version 2.0.2</h1></td>
+<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
+</tr>
+</table>
+</div>
+<!-- END NAVIGATION -->
+
+
+<!-- START BREADCRUMB -->
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td id="breadcrumb">
+<a href="http://codeigniter.com/">CodeIgniter Home</a> &nbsp;&#8250;&nbsp;
+<a href="../index.html">User Guide Home</a> &nbsp;&#8250;&nbsp;
+<a href="index.html">Database Library</a> &nbsp;&#8250;&nbsp;
+Database Caching Class
+</td>
+<td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="codeigniter.com/user_guide/" />Search User Guide&nbsp; <input type="text" class="input" style="width:200px;" name="q" id="q" size="31" maxlength="255" value="" />&nbsp;<input type="submit" class="submit" name="sa" value="Go" /></form></td>
+</tr>
+</table>
+<!-- END BREADCRUMB -->
+
+
+<br clear="all" />
+
+
+<!-- START CONTENT -->
+<div id="content">
+
+<h1>Database Caching Class</h1>
+
+<p>The Database Caching Class permits you to cache your queries as text files for reduced database load.</p>
+
+<p class="important"><strong>Important:</strong>&nbsp; This class is initialized automatically by the database driver
+when caching is enabled.  Do NOT load this class manually.<br /><br />
+
+<strong>Also note:</strong>&nbsp; Not all query result functions are available when you use caching. Please read this page carefully.</p>
+
+<h2>Enabling Caching</h2>
+
+<p>Caching is enabled in three steps:</p>
+
+<ul>
+<li>Create a writable directory on your server where the cache files can be stored.</li>
+<li>Set the path to your cache folder in your <dfn>application/config/database.php</dfn> file.</li>
+<li>Enable the caching feature, either globally by setting the preference in your <dfn>application/config/database.php</dfn> file, or manually as described below.</li>
+</ul>
+
+<p>Once enabled, caching will happen automatically whenever a page is loaded that contains database queries.</p>
+
+
+<h2>How Does Caching Work?</h2>
+
+<p>CodeIgniter's query caching system happens dynamically when your pages are viewed.
+When caching is enabled, the first time a web page is loaded, the query result object will
+be serialized and stored in a text file on your server. The next time the page is loaded the cache file will be used instead of
+accessing your database.  Your database usage can effectively be reduced to zero for any pages that have been cached.</p>
+
+<p>Only <dfn>read-type</dfn> (SELECT) queries can be cached, since these are the only type of queries that produce a result.
+<dfn>Write-type</dfn> (INSERT, UPDATE, etc.) queries, since they don't generate a result, will not be cached by the system.</p>
+
+<p>Cache files DO NOT expire.  Any queries that have been cached will remain cached until you delete them.  The caching system
+permits you clear caches associated with individual pages, or you can delete the entire collection of cache files.
+Typically you'll want to use the housekeeping functions described below to delete cache files after certain
+events take place, like when you've added new information to your database.</p>
+
+<h2>Will Caching Improve Your Site's Performance?</h2>
+
+<p>Getting a performance gain as a result of caching depends on many factors.
+If you have a highly optimized database under very little load, you probably won't see a performance boost.
+If your database is under heavy use you probably will see an improved response, assuming your file-system is not
+overly taxed.  Remember that caching simply changes how your information is retrieved, shifting it from being a database
+operation to a file-system one.</p>
+
+<p>In some clustered server environments, for example, caching may be detrimental since file-system operations are so intense.
+On single servers in shared environments, caching will probably be beneficial. Unfortunately there is no
+single answer to the question of whether you should cache your database.  It really depends on your situation.</p>
+
+<h2>How are Cache Files Stored?</h2>
+
+<p>CodeIgniter places the result of EACH query into its own cache file.  Sets of cache files are further organized into
+sub-folders corresponding to your controller functions.  To be precise, the sub-folders are named identically to the
+first two segments of your URI (the controller class name and function name).</p>
+
+<p>For example, let's say you have a controller called <dfn>blog</dfn> with a function called <dfn>comments</dfn> that
+contains three queries.  The caching system will create a cache folder
+called <kbd>blog+comments</kbd>, into which it will write three cache files.</p>
+
+<p>If you use dynamic queries that change based on information in your URI (when using pagination, for example), each instance of
+the query will produce its own cache file.  It's possible, therefore, to end up with many times more cache files than you have
+queries.</p>
+
+
+<h2>Managing your Cache Files</h2>
+
+<p>Since cache files do not expire, you'll need to build deletion routines into your application.  For example, let's say you have a blog
+that allows user commenting.  Whenever a new comment is submitted you'll want to delete the cache files associated with the
+controller function that serves up your comments.  You'll find two delete functions described below that help you
+clear data.</p>
+
+
+<h2>Not All Database Functions Work with Caching</h2>
+
+<p>Lastly, we need to point out that the result object that is cached is a simplified version of the full result object. For that reason,
+some of the query result functions are not available for use.</p>
+
+<p>The following functions <kbd>ARE NOT</kbd> available when using a cached result object:</p>
+
+<ul>
+<li>num_fields()</li>
+<li>field_names()</li>
+<li>field_data()</li>
+<li>free_result()</li>
+</ul>
+
+<p>Also, the two database resources (result_id and conn_id) are not available when caching, since result resources only
+pertain to run-time operations.</p>
+
+
+<br />
+
+<h1>Function Reference</h1>
+
+
+
+<h2>$this->db->cache_on()&nbsp; / &nbsp; $this->db->cache_off()</h2>
+
+<p>Manually enables/disables caching.  This can be useful if you want to
+keep certain queries from being cached.  Example:</p>
+
+<code>
+// Turn caching on<br />
+$this->db->cache_on();<br />
+$query = $this->db->query("SELECT * FROM mytable");<br />
+<br />
+// Turn caching off for this one query<br />
+$this->db->cache_off();<br />
+$query = $this->db->query("SELECT * FROM members WHERE member_id = '$current_user'");<br />
+<br />
+// Turn caching back on<br />
+$this->db->cache_on();<br />
+$query = $this->db->query("SELECT * FROM another_table");
+</code>
+
+
+<h2>$this->db->cache_delete()</h2>
+
+<p>Deletes the cache files associated with a particular page. This is useful if you need to clear caching after you update your database.</p>
+
+<p>The caching system saves your cache files to folders that correspond to the URI of the page you are viewing.  For example, if you are viewing
+a page at <dfn>example.com/index.php/blog/comments</dfn>, the caching system will put all cache files associated with it in a folder
+called <dfn>blog+comments</dfn>.  To delete those particular cache files you will use:</p>
+
+<code>$this->db->cache_delete('blog', 'comments');</code>
+
+<p>If you do not use any parameters the current URI will be used when determining what should be cleared.</p>
+
+
+<h2>$this->db->cache_delete_all()</h2>
+
+<p>Clears all existing cache files.  Example:</p>
+
+<code>$this->db->cache_delete_all();</code>
+
+
+
+
+
+
+
+
+
+
+</div>
+<!-- END CONTENT -->
+
+
+<div id="footer">
+<p>
+Previous Topic:&nbsp;&nbsp;<a href="call_function.html">Custom Function Calls</a>
+&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+<a href="#top">Top of Page</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+<a href="../index.html">User Guide Home</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+Next Topic:&nbsp;&nbsp;<a href="forge.html">Database manipulation with Database Forge</a>
+</p>
+<p><a href="http://codeigniter.com">CodeIgniter</a> &nbsp;&middot;&nbsp; Copyright &#169; 2006 - 2011 &nbsp;&middot;&nbsp; <a href="http://ellislab.com/">EllisLab, Inc.</a></p>
+</div>
+
+</body>
+</html>
\ No newline at end of file
diff --git a/user_guide/database/call_function.html b/user_guide/database/call_function.html
new file mode 100755 (executable)
index 0000000..3e0c78d
--- /dev/null
@@ -0,0 +1,118 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head>
+
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+<title>Custom Function Calls : CodeIgniter User Guide</title>
+
+<style type='text/css' media='all'>@import url('../userguide.css');</style>
+<link rel='stylesheet' type='text/css' media='all' href='../userguide.css' />
+
+<script type="text/javascript" src="../nav/nav.js"></script>
+<script type="text/javascript" src="../nav/prototype.lite.js"></script>
+<script type="text/javascript" src="../nav/moo.fx.js"></script>
+<script type="text/javascript" src="../nav/user_guide_menu.js"></script>
+
+<meta http-equiv='expires' content='-1' />
+<meta http-equiv= 'pragma' content='no-cache' />
+<meta name='robots' content='all' />
+<meta name='author' content='ExpressionEngine Dev Team' />
+<meta name='description' content='CodeIgniter User Guide' />
+
+</head>
+<body>
+
+<!-- START NAVIGATION -->
+<div id="nav"><div id="nav_inner"><script type="text/javascript">create_menu('../');</script></div></div>
+<div id="nav2"><a name="top"></a><a href="javascript:void(0);" onclick="myHeight.toggle();"><img src="../images/nav_toggle_darker.jpg" width="154" height="43" border="0" title="Toggle Table of Contents" alt="Toggle Table of Contents" /></a></div>
+<div id="masthead">
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td><h1>CodeIgniter User Guide Version 2.0.2</h1></td>
+<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
+</tr>
+</table>
+</div>
+<!-- END NAVIGATION -->
+
+
+<!-- START BREADCRUMB -->
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td id="breadcrumb">
+<a href="http://codeigniter.com/">CodeIgniter Home</a> &nbsp;&#8250;&nbsp;
+<a href="../index.html">User Guide Home</a> &nbsp;&#8250;&nbsp;
+<a href="index.html">Database Library</a> &nbsp;&#8250;&nbsp;
+Custom Function Calls
+</td>
+<td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="codeigniter.com/user_guide/" />Search User Guide&nbsp; <input type="text" class="input" style="width:200px;" name="q" id="q" size="31" maxlength="255" value="" />&nbsp;<input type="submit" class="submit" name="sa" value="Go" /></form></td>
+</tr>
+</table>
+<!-- END BREADCRUMB -->
+
+
+<br clear="all" />
+
+
+<!-- START CONTENT -->
+<div id="content">
+
+<h1>Custom Function Calls</h1>
+
+<h2>$this->db->call_function();</h2>
+
+<p>This function enables you to call PHP database functions that are not natively included in CodeIgniter, in a platform independent manner.
+For example, lets say you want to call the <dfn>mysql_get_client_info()</dfn> function, which is <strong>not</strong> natively supported
+by CodeIgniter.  You could do so like this:
+</p>
+
+<code>$this->db->call_function('<var>get_client_info</var>');</code>
+
+<p>You must supply the name of the function, <strong>without</strong> the <var>mysql_</var> prefix, in the first parameter.  The prefix is added
+automatically based on which database driver is currently being used.  This permits you to run the same function on different database platforms.
+Obviously not all function calls are identical between platforms, so there are limits to how useful this function can be in terms of portability.</p>
+
+<p>Any parameters needed by the function you are calling will be added to the second parameter.</p>
+
+<code>$this->db->call_function('<var>some_function</var>', $param1, $param2, etc..);</code>
+
+
+<p>Often, you will either need to supply a database connection ID or a database result ID.  The connection ID can be accessed using:</p>
+
+<code>$this->db->conn_id;</code>
+
+<p>The result ID can be accessed from within your result object, like this:</p>
+
+<code>$query = $this->db->query("SOME QUERY");<br />
+<br />
+<var>$query->result_id;</var></code>
+
+
+
+
+
+
+
+
+
+
+
+
+
+</div>
+<!-- END CONTENT -->
+
+
+<div id="footer">
+<p>
+Previous Topic:&nbsp;&nbsp;<a href="fields.html">Field MetaData</a>
+&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+<a href="#top">Top of Page</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+<a href="../index.html">User Guide Home</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+Next Topic:&nbsp;&nbsp;<a href="caching.html">Query Caching</a>
+</p>
+<p><a href="http://codeigniter.com">CodeIgniter</a> &nbsp;&middot;&nbsp; Copyright &#169; 2006 - 2011 &nbsp;&middot;&nbsp; <a href="http://ellislab.com/">EllisLab, Inc.</a></p>
+</div>
+
+</body>
+</html>
\ No newline at end of file
diff --git a/user_guide/database/configuration.html b/user_guide/database/configuration.html
new file mode 100755 (executable)
index 0000000..fdeae0e
--- /dev/null
@@ -0,0 +1,164 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head>
+
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+<title>Database Configuration : CodeIgniter User Guide</title>
+
+<style type='text/css' media='all'>@import url('../userguide.css');</style>
+<link rel='stylesheet' type='text/css' media='all' href='../userguide.css' />
+
+<script type="text/javascript" src="../nav/nav.js"></script>
+<script type="text/javascript" src="../nav/prototype.lite.js"></script>
+<script type="text/javascript" src="../nav/moo.fx.js"></script>
+<script type="text/javascript" src="../nav/user_guide_menu.js"></script>
+
+<meta http-equiv='expires' content='-1' />
+<meta http-equiv= 'pragma' content='no-cache' />
+<meta name='robots' content='all' />
+<meta name='author' content='ExpressionEngine Dev Team' />
+<meta name='description' content='CodeIgniter User Guide' />
+
+</head>
+<body>
+
+<!-- START NAVIGATION -->
+<div id="nav"><div id="nav_inner"><script type="text/javascript">create_menu('../');</script></div></div>
+<div id="nav2"><a name="top"></a><a href="javascript:void(0);" onclick="myHeight.toggle();"><img src="../images/nav_toggle_darker.jpg" width="154" height="43" border="0" title="Toggle Table of Contents" alt="Toggle Table of Contents" /></a></div>
+<div id="masthead">
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td><h1>CodeIgniter User Guide Version 2.0.2</h1></td>
+<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
+</tr>
+</table>
+</div>
+<!-- END NAVIGATION -->
+
+
+<!-- START BREADCRUMB -->
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td id="breadcrumb">
+<a href="http://codeigniter.com/">CodeIgniter Home</a> &nbsp;&#8250;&nbsp;
+<a href="../index.html">User Guide Home</a> &nbsp;&#8250;&nbsp;
+<a href="index.html">Database Library</a> &nbsp;&#8250;&nbsp;
+Configuration
+</td>
+<td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="codeigniter.com/user_guide/" />Search User Guide&nbsp; <input type="text" class="input" style="width:200px;" name="q" id="q" size="31" maxlength="255" value="" />&nbsp;<input type="submit" class="submit" name="sa" value="Go" /></form></td>
+</tr>
+</table>
+<!-- END BREADCRUMB -->
+
+
+<br clear="all" />
+
+
+<!-- START CONTENT -->
+<div id="content">
+
+
+<h1>Database Configuration</h1>
+
+<p>CodeIgniter has a config file that lets you store your database connection values (username, password, database name, etc.).
+The config file is located at <samp>application/config/database.php</samp>. You can also set database connection values for specific <a href="../libraries/config.html">environments</a> by placing <strong>database.php</strong> it the respective environment config folder.</p>
+
+<p>The config settings are stored in a multi-dimensional array with this prototype:</p>
+
+<code>$db['default']['hostname'] = "localhost";<br />
+$db['default']['username'] = "root";<br />
+$db['default']['password'] = "";<br />
+$db['default']['database'] = "database_name";<br />
+$db['default']['dbdriver'] = "mysql";<br />
+$db['default']['dbprefix'] = "";<br />
+$db['default']['pconnect'] = TRUE;<br />
+$db['default']['db_debug'] = FALSE;<br />
+$db['default']['cache_on'] = FALSE;<br />
+$db['default']['cachedir'] =  &quot;&quot;;<br />
+$db['default']['char_set'] = "utf8";<br />
+$db['default']['dbcollat'] = "utf8_general_ci";<br />
+$db['default']['swap_pre'] = "";<br />
+$db['default']['autoinit'] = TRUE;<br />
+$db['default']['stricton'] = FALSE;</code>
+
+<p>The reason we use a multi-dimensional array rather than a more simple one is to permit you to optionally store
+multiple sets of connection values.  If, for example,  you run multiple environments (development, production, test, etc.)
+under a single installation, you can set up a connection group for each, then switch between groups as needed.
+For example, to set up a "test" environment you would do this:</p>
+
+<code>$db['test']['hostname'] = "localhost";<br />
+$db['test']['username'] = "root";<br />
+$db['test']['password'] = "";<br />
+$db['test']['database'] = "database_name";<br />
+$db['test']['dbdriver'] = "mysql";<br />
+$db['test']['dbprefix'] = "";<br />
+$db['test']['pconnect'] = TRUE;<br />
+$db['test']['db_debug'] = FALSE;<br />
+$db['test']['cache_on'] = FALSE;<br />
+$db['test']['cachedir'] =  &quot;&quot;;<br />
+$db['test']['char_set'] = "utf8";<br />
+$db['test']['dbcollat'] = "utf8_general_ci";<br />
+$db['test']['swap_pre'] = "";<br />
+$db['test']['autoinit'] = TRUE;<br />
+$db['test']['stricton'] = FALSE;</code>
+
+
+<p>Then, to globally tell the system to use that group you would set this variable located in the config file:</p>
+
+<code>$active_group = "test";</code>
+
+<p>Note: The name "test" is arbitrary.  It can be anything you want. By default we've used the word "default"
+for the primary connection, but it too can be renamed to something more relevant to your project.</p>
+
+<h3>Active Record</h3>
+
+<p>The <a href="active_record.html">Active Record Class</a> is globally enabled or disabled by setting the $active_record variable in the database configuration file to TRUE/FALSE (boolean). If you are not using the active record class, setting it to FALSE will utilize fewer resources when the database classes are initialized.</p>
+
+<code>$active_record = TRUE;</code>
+
+<p class="important"><strong>Note:</strong> that some CodeIgniter classes such as Sessions require Active Records be enabled to access certain functionality.</p>
+
+<h3>Explanation of Values:</h3>
+
+<ul>
+<li><strong>hostname</strong> - The hostname of your database server. Often this is "localhost".</li>
+<li><strong>username</strong> - The username used to connect to the database.</li>
+<li><strong>password</strong> - The password used to connect to the database.</li>
+<li><strong>database</strong> - The name of the database you want to connect to.</li>
+<li><strong>dbdriver</strong> - The database type. ie: mysql, postgres, odbc, etc. Must be specified in lower case.</li>
+<li><strong>dbprefix</strong> - An optional table prefix which will added to the table name when running <a href="active_record.html">Active Record</a> queries.  This permits multiple CodeIgniter installations to share one database.</li>
+<li><strong>pconnect</strong> - TRUE/FALSE (boolean) - Whether to use a persistent connection.</li>
+<li><strong>db_debug</strong> - TRUE/FALSE (boolean) - Whether database errors should be displayed.</li>
+<li><strong>cache_on</strong> - TRUE/FALSE (boolean) - Whether database query caching is enabled, see also <a href="caching.html">Database Caching Class</a>.</li>
+<li><strong>cachedir</strong> - The absolute server path to your database query cache directory.</li>
+<li><strong>char_set</strong> - The character set used in communicating with the database.</li>
+<li><strong>dbcollat</strong> - The character collation used in communicating with the database.</li>
+<li><strong>swap_pre</strong> - A default table prefix that should be swapped with <var>dbprefix</var>.  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.</li>
+<li><strong>autoinit</strong> - 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.</li>
+<li><strong>stricton</strong> - TRUE/FALSE (boolean) - Whether to force "Strict Mode" connections, good for ensuring strict SQL while developing an application.</li>
+<li><strong>port</strong> - The database port number.  To use this value you have to add a line to the database config array.<code>$db['default']['port'] =  5432;</code>
+</ul>
+
+<p class="important"><strong>Note:</strong> Depending on what database platform you are using (MySQL, Postgres, etc.)
+not all values will be needed.  For example, when using SQLite you will not need to supply a username or password, and
+the database name will be the path to your database file. The information above assumes you are using MySQL.</p>
+
+
+
+</div>
+<!-- END CONTENT -->
+
+
+<div id="footer">
+<p>
+Previous Topic:&nbsp;&nbsp;<a href="examples.html">Quick Start: Usage Examples</a>
+&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+<a href="#top">Top of Page</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+<a href="../index.html">User Guide Home</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+Next Topic:&nbsp;&nbsp;<a href="connecting.html">Connecting to your Database</a>
+</p>
+<p><a href="http://codeigniter.com">CodeIgniter</a> &nbsp;&middot;&nbsp; Copyright &#169; 2006 - 2011 &nbsp;&middot;&nbsp; <a href="http://ellislab.com/">EllisLab, Inc.</a></p>
+</div>
+
+</body>
+</html>
\ No newline at end of file
diff --git a/user_guide/database/connecting.html b/user_guide/database/connecting.html
new file mode 100755 (executable)
index 0000000..bb1b401
--- /dev/null
@@ -0,0 +1,188 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head>
+
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+<title>Connecting to your Database : CodeIgniter User Guide</title>
+
+<style type='text/css' media='all'>@import url('../userguide.css');</style>
+<link rel='stylesheet' type='text/css' media='all' href='../userguide.css' />
+
+<script type="text/javascript" src="../nav/nav.js"></script>
+<script type="text/javascript" src="../nav/prototype.lite.js"></script>
+<script type="text/javascript" src="../nav/moo.fx.js"></script>
+<script type="text/javascript" src="../nav/user_guide_menu.js"></script>
+
+<meta http-equiv='expires' content='-1' />
+<meta http-equiv= 'pragma' content='no-cache' />
+<meta name='robots' content='all' />
+<meta name='author' content='ExpressionEngine Dev Team' />
+<meta name='description' content='CodeIgniter User Guide' />
+
+</head>
+<body>
+
+<!-- START NAVIGATION -->
+<div id="nav"><div id="nav_inner"><script type="text/javascript">create_menu('../');</script></div></div>
+<div id="nav2"><a name="top"></a><a href="javascript:void(0);" onclick="myHeight.toggle();"><img src="../images/nav_toggle_darker.jpg" width="154" height="43" border="0" title="Toggle Table of Contents" alt="Toggle Table of Contents" /></a></div>
+<div id="masthead">
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td><h1>CodeIgniter User Guide Version 2.0.2</h1></td>
+<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
+</tr>
+</table>
+</div>
+<!-- END NAVIGATION -->
+
+
+<!-- START BREADCRUMB -->
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td id="breadcrumb">
+<a href="http://codeigniter.com/">CodeIgniter Home</a> &nbsp;&#8250;&nbsp;
+<a href="../index.html">User Guide Home</a> &nbsp;&#8250;&nbsp;
+<a href="index.html">Database Library</a> &nbsp;&#8250;&nbsp;
+Connecting
+</td>
+<td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="codeigniter.com/user_guide/" />Search User Guide&nbsp; <input type="text" class="input" style="width:200px;" name="q" id="q" size="31" maxlength="255" value="" />&nbsp;<input type="submit" class="submit" name="sa" value="Go" /></form></td>
+</tr>
+</table>
+<!-- END BREADCRUMB -->
+
+
+<br clear="all" />
+
+
+<!-- START CONTENT -->
+<div id="content">
+
+
+<h1>Connecting to your Database</h1>
+
+<p>There are two ways to connect to a database:</p>
+
+<h2>Automatically Connecting</h2>
+
+<p>The "auto connect" feature will load and instantiate the database class with every page load.
+To enable "auto connecting", add the word <var>database</var> to the library array, as indicated in the following file:</p>
+
+<p><kbd>application/config/autoload.php</kbd></p>
+
+<h2>Manually Connecting</h2>
+
+<p>If only some of your pages require database connectivity you can manually connect to your database by adding this
+line of code in any function where it is needed, or in your class constructor to make the database
+available globally in that class.</p>
+
+<code>$this->load->database();</code>
+
+<p class="important">If the above function does <strong>not</strong> contain any information in the first parameter it will connect
+to the group specified in your database config file. For most people, this is the preferred method of use.</p>
+
+<h3>Available Parameters</h3>
+
+<ol>
+       <li>The database connection values, passed either as an array or a DSN string.</li>
+       <li>TRUE/FALSE (boolean).  Whether to return the connection ID (see Connecting to Multiple Databases below).</li>
+       <li>TRUE/FALSE (boolean).  Whether to enable the Active Record class.  Set to TRUE by default.</li>
+</ol>
+
+
+<h3>Manually Connecting to a Database</h3>
+
+<p>The first parameter of this function can <strong>optionally</strong> be used to specify a particular database group
+from your config file, or you can even submit connection values for a database that is not specified in your config file.
+Examples:</p>
+
+<p>To choose a specific group from your config file you can do this:</p>
+
+<code>$this->load->database('<samp>group_name</samp>');</code>
+
+<p>Where <samp>group_name</samp> is the name of the connection group from your config file.</p>
+
+
+<p>To connect manually to a desired database you can pass an array of values:</p>
+
+<code>$config['hostname'] = "localhost";<br />
+$config['username'] = "myusername";<br />
+$config['password'] = "mypassword";<br />
+$config['database'] = "mydatabase";<br />
+$config['dbdriver'] = "mysql";<br />
+$config['dbprefix'] = "";<br />
+$config['pconnect'] = FALSE;<br />
+$config['db_debug'] = TRUE;<br />
+$config['cache_on'] = FALSE;<br />
+$config['cachedir'] = "";<br />
+$config['char_set'] = "utf8";<br />
+$config['dbcollat'] = "utf8_general_ci";<br />
+<br />
+$this->load->database(<samp>$config</samp>);</code>
+
+<p>For information on each of these values please see the <a href="configuration.html">configuration page</a>.</p>
+
+<p>Or you can submit your database values as a Data Source Name. DSNs must have this prototype:</p>
+
+<code>$dsn = 'dbdriver://username:password@hostname/database';<br />
+<br />
+$this->load->database(<samp>$dsn</samp>);</code>
+
+<p>To override default config values when connecting with a DSN string, add the config variables as a query string.</p>
+
+<code>$dsn = 'dbdriver://username:password@hostname/database?char_set=utf8&amp;dbcollat=utf8_general_ci&amp;cache_on=true&amp;cachedir=/path/to/cache';<br />
+<br />
+$this->load->database(<samp>$dsn</samp>);</code>
+
+<h2>Connecting to Multiple Databases</h2>
+
+<p>If you need to connect to more than one database simultaneously you can do so as follows:</p>
+
+
+<code>$DB1 = $this->load->database('group_one', TRUE);<br />
+$DB2 = $this->load->database('group_two', TRUE);
+</code>
+
+<p>Note: Change the words "group_one" and "group_two" to the specific group names you are connecting to (or
+you can pass the connection values as indicated above).</p>
+
+<p>By setting the second parameter to TRUE (boolean) the function will return the database object.</p>
+
+<div class="important">
+<p>When you connect this way, you will use your object name to issue commands rather than the syntax used throughout this guide.  In other words, rather than issuing commands with:</p>
+
+<p>$this->db->query();<br />$this->db->result();<br /> etc...</p>
+
+<p>You will instead use:</p>
+
+<p>$DB1->query();<br />$DB1->result();<br /> etc...</p>
+
+</div>
+
+<h2>Reconnecting / Keeping the Connection Alive</h2>
+
+<p>If the database server's idle timeout is exceeded while you're doing some heavy PHP lifting (processing an image, for instance), you should consider pinging the server by using the <dfn>reconnect()</dfn> method before sending further queries, which can gracefully keep the connection alive or re-establish it.</p>
+
+<code>$this->db->reconnect();</code>
+
+<h2>Manually closing the Connection</h2>
+
+<p>While CodeIgniter intelligently takes care of closing your database connections, you can explicitly close the connection.</p>
+
+<code>$this->db->close();</code>
+</div>
+<!-- END CONTENT -->
+
+
+<div id="footer">
+<p>
+Previous Topic:&nbsp;&nbsp;<a href="configuration.html">Database Configuration</a>
+&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+<a href="#top">Top of Page</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+<a href="../index.html">User Guide Home</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+Next Topic:&nbsp;&nbsp;<a href="queries.html">Queries</a>
+</p>
+<p><a href="http://codeigniter.com">CodeIgniter</a> &nbsp;&middot;&nbsp; Copyright &#169; 2006 - 2011 &nbsp;&middot;&nbsp; <a href="http://ellislab.com/">EllisLab, Inc.</a></p>
+</div>
+
+</body>
+</html>
\ No newline at end of file
diff --git a/user_guide/database/examples.html b/user_guide/database/examples.html
new file mode 100755 (executable)
index 0000000..535fa31
--- /dev/null
@@ -0,0 +1,217 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head>
+
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+<title>Database Quick Start : CodeIgniter User Guide</title>
+
+<style type='text/css' media='all'>@import url('../userguide.css');</style>
+<link rel='stylesheet' type='text/css' media='all' href='../userguide.css' />
+
+<script type="text/javascript" src="../nav/nav.js"></script>
+<script type="text/javascript" src="../nav/prototype.lite.js"></script>
+<script type="text/javascript" src="../nav/moo.fx.js"></script>
+<script type="text/javascript" src="../nav/user_guide_menu.js"></script>
+
+<meta http-equiv='expires' content='-1' />
+<meta http-equiv= 'pragma' content='no-cache' />
+<meta name='robots' content='all' />
+<meta name='author' content='ExpressionEngine Dev Team' />
+<meta name='description' content='CodeIgniter User Guide' />
+
+</head>
+<body>
+
+<!-- START NAVIGATION -->
+<div id="nav"><div id="nav_inner"><script type="text/javascript">create_menu('../');</script></div></div>
+<div id="nav2"><a name="top"></a><a href="javascript:void(0);" onclick="myHeight.toggle();"><img src="../images/nav_toggle_darker.jpg" width="154" height="43" border="0" title="Toggle Table of Contents" alt="Toggle Table of Contents" /></a></div>
+<div id="masthead">
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td><h1>CodeIgniter User Guide Version 2.0.2</h1></td>
+<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
+</tr>
+</table>
+</div>
+<!-- END NAVIGATION -->
+
+
+
+<!-- START BREADCRUMB -->
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td id="breadcrumb">
+<a href="http://codeigniter.com/">CodeIgniter Home</a> &nbsp;&#8250;&nbsp;
+<a href="../index.html">User Guide Home</a> &nbsp;&#8250;&nbsp;
+<a href="index.html">Database Library</a> &nbsp;&#8250;&nbsp;
+Database Example Code
+</td>
+<td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="codeigniter.com/user_guide/" />Search User Guide&nbsp; <input type="text" class="input" style="width:200px;" name="q" id="q" size="31" maxlength="255" value="" />&nbsp;<input type="submit" class="submit" name="sa" value="Go" /></form></td>
+</tr>
+</table>
+<!-- END BREADCRUMB -->
+
+
+<br clear="all" />
+
+
+<!-- START CONTENT -->
+<div id="content">
+
+
+<h1>Database Quick Start: Example Code</h1>
+
+<p>The following page contains example code showing how the database class is used.  For complete details please
+read the individual pages describing each function.</p>
+
+
+<h2>Initializing the Database Class</h2>
+
+<p>The following code loads and initializes the database class based on your <a href="configuration.html">configuration</a> settings:</p>
+
+<code>$this->load->database();</code>
+
+<p>Once loaded the class is ready to be used as described below.</p>
+
+<p>Note: If all your pages require database access you can connect automatically.  See the <a href="connecting.html">connecting</a> page for details.</p>
+
+
+<h2>Standard Query With Multiple Results (Object Version)</h2>
+
+<code>$query = $this->db->query('SELECT name, title, email FROM my_table');<br />
+<br />
+foreach ($query->result() as $row)<br />
+{<br />
+&nbsp;&nbsp;&nbsp;&nbsp;echo $row->title;<br />
+&nbsp;&nbsp;&nbsp;&nbsp;echo $row->name;<br />
+&nbsp;&nbsp;&nbsp;&nbsp;echo $row->email;<br />
+}<br />
+<br />
+echo 'Total Results: ' . $query->num_rows();
+</code>
+
+<p>The above <dfn>result()</dfn> function returns an array of <strong>objects</strong>.  Example:  $row->title</p>
+
+
+<h2>Standard Query With Multiple Results (Array Version)</h2>
+
+<code>$query = $this->db->query('SELECT name, title, email FROM my_table');<br />
+<br />
+foreach ($query->result_array() as $row)<br />
+{<br />
+&nbsp;&nbsp;&nbsp;&nbsp;echo $row['title'];<br />
+&nbsp;&nbsp;&nbsp;&nbsp;echo $row['name'];<br />
+&nbsp;&nbsp;&nbsp;&nbsp;echo $row['email'];<br />
+}</code>
+
+<p>The above <dfn>result_array()</dfn> function returns an array of standard array indexes.  Example:  $row['title']</p>
+
+
+<h2>Testing for Results</h2>
+
+<p>If you run queries that might <strong>not</strong> produce a result, you are encouraged to test for a result first
+using the <dfn>num_rows()</dfn> function:</p>
+
+<code>
+$query = $this->db->query("YOUR QUERY");<br />
+<br />
+if ($query->num_rows() > 0)<br />
+{<br />
+&nbsp;&nbsp;&nbsp;foreach ($query->result() as $row)<br />
+&nbsp;&nbsp;&nbsp;{<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;echo $row->title;<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;echo $row->name;<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;echo $row->body;<br />
+&nbsp;&nbsp;&nbsp;}<br />
+}
+</code>
+
+
+
+
+<h2>Standard Query With Single Result</h2>
+
+<code>$query = $this->db->query('SELECT name FROM my_table LIMIT 1');<br />
+<br />
+$row = $query->row();<br />
+echo $row->name;<br />
+</code>
+
+<p>The above <dfn>row()</dfn> function returns an <strong>object</strong>.  Example:  $row->name</p>
+
+
+<h2>Standard Query With Single Result (Array version)</h2>
+
+<code>$query = $this->db->query('SELECT name FROM my_table LIMIT 1');<br />
+<br />
+$row = $query->row_array();<br />
+echo $row['name'];<br />
+</code>
+
+<p>The above <dfn>row_array()</dfn> function returns an <strong>array</strong>.  Example:  $row['name']</p>
+
+
+<h2>Standard Insert</h2>
+
+<code>
+$sql = "INSERT INTO mytable (title, name) <br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;VALUES (".$this->db->escape($title).", ".$this->db->escape($name).")";<br />
+<br />
+$this->db->query($sql);<br />
+<br />
+echo $this->db->affected_rows();
+</code>
+
+
+
+
+<h2>Active Record Query</h2>
+
+<p>The <a href="active_record.html">Active Record Pattern</a> gives you a simplified means of retrieving data:</p>
+
+<code>
+$query = $this->db->get('table_name');<br />
+<br />
+foreach ($query->result() as $row)<br />
+{<br />
+&nbsp;&nbsp;&nbsp;&nbsp;echo $row->title;<br />
+}</code>
+
+<p>The above <dfn>get()</dfn> function retrieves all the results from the supplied table.
+The <a href="active_record.html">Active Record</a> class contains a full compliment of functions
+for working with data.</p>
+
+
+<h2>Active Record Insert</h2>
+
+<code>
+$data = array(<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'title' => $title,<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'name' => $name,<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'date' => $date<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;);<br />
+<br />
+$this->db->insert('mytable', $data);
+<br /><br />
+// Produces: INSERT INTO mytable (title, name, date) VALUES ('{$title}', '{$name}', '{$date}')</code>
+
+
+
+
+</div>
+<!-- END CONTENT -->
+
+
+<div id="footer">
+<p>
+Previous Topic:&nbsp;&nbsp;<a href="index.html">Database Class</a>
+&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+<a href="#top">Top of Page</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+<a href="../index.html">User Guide Home</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+Next Topic:&nbsp;&nbsp;<a href="configuration.html">Database Configuration</a>
+</p>
+<p><a href="http://codeigniter.com">CodeIgniter</a> &nbsp;&middot;&nbsp; Copyright &#169; 2006 - 2011 &nbsp;&middot;&nbsp; <a href="http://ellislab.com/">EllisLab, Inc.</a></p>
+</div>
+
+</body>
+</html>
\ No newline at end of file
diff --git a/user_guide/database/fields.html b/user_guide/database/fields.html
new file mode 100755 (executable)
index 0000000..04d8b80
--- /dev/null
@@ -0,0 +1,163 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head>
+
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+<title>Field Data : CodeIgniter User Guide</title>
+
+<style type='text/css' media='all'>@import url('../userguide.css');</style>
+<link rel='stylesheet' type='text/css' media='all' href='../userguide.css' />
+
+<script type="text/javascript" src="../nav/nav.js"></script>
+<script type="text/javascript" src="../nav/prototype.lite.js"></script>
+<script type="text/javascript" src="../nav/moo.fx.js"></script>
+<script type="text/javascript" src="../nav/user_guide_menu.js"></script>
+
+<meta http-equiv='expires' content='-1' />
+<meta http-equiv= 'pragma' content='no-cache' />
+<meta name='robots' content='all' />
+<meta name='author' content='ExpressionEngine Dev Team' />
+<meta name='description' content='CodeIgniter User Guide' />
+
+</head>
+<body>
+
+<!-- START NAVIGATION -->
+<div id="nav"><div id="nav_inner"><script type="text/javascript">create_menu('../');</script></div></div>
+<div id="nav2"><a name="top"></a><a href="javascript:void(0);" onclick="myHeight.toggle();"><img src="../images/nav_toggle_darker.jpg" width="154" height="43" border="0" title="Toggle Table of Contents" alt="Toggle Table of Contents" /></a></div>
+<div id="masthead">
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td><h1>CodeIgniter User Guide Version 2.0.2</h1></td>
+<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
+</tr>
+</table>
+</div>
+<!-- END NAVIGATION -->
+
+<!-- START BREADCRUMB -->
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td id="breadcrumb">
+<a href="http://codeigniter.com/">CodeIgniter Home</a> &nbsp;&#8250;&nbsp;
+<a href="../index.html">User Guide Home</a> &nbsp;&#8250;&nbsp;
+<a href="index.html">Database Library</a> &nbsp;&#8250;&nbsp;
+Field Names
+</td>
+<td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="codeigniter.com/user_guide/" />Search User Guide&nbsp; <input type="text" class="input" style="width:200px;" name="q" id="q" size="31" maxlength="255" value="" />&nbsp;<input type="submit" class="submit" name="sa" value="Go" /></form></td>
+</tr>
+</table>
+<!-- END BREADCRUMB -->
+
+
+<br clear="all" />
+
+
+<!-- START CONTENT -->
+<div id="content">
+
+
+<h1>Field Data</h1>
+
+
+<h2>$this->db->list_fields()</h2>
+<p>Returns an array containing the field names. This query can be called two ways:</p>
+
+
+<p>1. You can supply the table name and call it from the <dfn>$this->db-></dfn> object:</p>
+
+<code>
+$fields = $this->db->list_fields('table_name');<br /><br />
+
+foreach ($fields as $field)<br />
+{<br />
+&nbsp;&nbsp;&nbsp;echo $field;<br />
+}
+</code>
+
+<p>2. You can gather the field names associated with any query you run by calling the function
+from your query result object:</p>
+
+<code>
+$query = $this->db->query('SELECT * FROM some_table');
+<br /><br />
+
+foreach ($query->list_fields() as $field)<br />
+{<br />
+&nbsp;&nbsp;&nbsp;echo $field;<br />
+}
+</code>
+
+
+<h2>$this->db->field_exists()</h2>
+
+<p>Sometimes it's helpful to know whether a particular field exists before performing an action.
+Returns a boolean TRUE/FALSE.  Usage example:</p>
+
+<code>
+if ($this->db->field_exists('field_name', 'table_name'))<br />
+{<br />
+&nbsp;&nbsp; // some code...<br />
+}
+</code>
+
+<p>Note:  Replace <em>field_name</em> with the name of the column you are looking for, and replace
+<em>table_name</em> with the name of the table you are looking for.</p>
+
+
+<h2>$this->db->field_data()</h2>
+<p>Returns an array of objects containing field information.</p>
+<p>Sometimes it's helpful to gather the field names or other metadata, like the column type, max length, etc.</p>
+
+
+<p class="important">Note: Not all databases provide meta-data.</p>
+
+<p>Usage example:</p>
+
+<code>
+$fields = $this->db->field_data('table_name');<br /><br />
+
+foreach ($fields as $field)<br />
+{<br />
+&nbsp;&nbsp;&nbsp;echo $field->name;<br />
+&nbsp;&nbsp;&nbsp;echo $field->type;<br />
+&nbsp;&nbsp;&nbsp;echo $field->max_length;<br />
+&nbsp;&nbsp;&nbsp;echo $field->primary_key;<br />
+}
+</code>
+
+<p>If you have run a query already you can use the result object instead of supplying the table name:</p>
+
+<code>
+$query = $this->db->query("YOUR QUERY");<br />
+$fields = $query->field_data();
+</code>
+
+
+<p>The following data is available from this function if supported by your database:</p>
+
+<ul>
+<li>name - column name</li>
+<li>max_length - maximum length of the column</li>
+<li>primary_key - 1 if the column is a primary key</li>
+<li>type - the type of the column</li>
+</ul>
+
+
+</div>
+<!-- END CONTENT -->
+
+
+<div id="footer">
+<p>
+Previous Topic:&nbsp;&nbsp;<a href="table_data.html"> Table Data</a>
+&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+<a href="#top">Top of Page</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+<a href="../index.html">User Guide Home</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+Next Topic:&nbsp;&nbsp;<a href="call_function.html">Custom Function Calls</a>
+</p>
+<p><a href="http://codeigniter.com">CodeIgniter</a> &nbsp;&middot;&nbsp; Copyright &#169; 2006 - 2011 &nbsp;&middot;&nbsp; <a href="http://ellislab.com/">EllisLab, Inc.</a></p>
+</div>
+
+</body>
+</html>
\ No newline at end of file
diff --git a/user_guide/database/forge.html b/user_guide/database/forge.html
new file mode 100755 (executable)
index 0000000..cad2cf2
--- /dev/null
@@ -0,0 +1,234 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head>
+
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+<title>Database Forge Class : CodeIgniter User Guide</title>
+
+<style type='text/css' media='all'>@import url('../userguide.css');</style>
+<link rel='stylesheet' type='text/css' media='all' href='../userguide.css' />
+
+<script type="text/javascript" src="../nav/nav.js"></script>
+<script type="text/javascript" src="../nav/prototype.lite.js"></script>
+<script type="text/javascript" src="../nav/moo.fx.js"></script>
+<script type="text/javascript" src="../nav/user_guide_menu.js"></script>
+
+<meta http-equiv='expires' content='-1' />
+<meta http-equiv= 'pragma' content='no-cache' />
+<meta name='robots' content='all' />
+<meta name='author' content='ExpressionEngine Dev Team' />
+<meta name='description' content='CodeIgniter User Guide' />
+
+</head>
+<body>
+
+<!-- START NAVIGATION -->
+<div id="nav"><div id="nav_inner"><script type="text/javascript">create_menu('../');</script></div></div>
+<div id="nav2"><a name="top"></a><a href="javascript:void(0);" onclick="myHeight.toggle();"><img src="../images/nav_toggle_darker.jpg" width="154" height="43" border="0" title="Toggle Table of Contents" alt="Toggle Table of Contents" /></a></div>
+<div id="masthead">
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td><h1>CodeIgniter User Guide Version 2.0.2</h1></td>
+<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
+</tr>
+</table>
+</div>
+<!-- END NAVIGATION -->
+
+
+<!-- START BREADCRUMB -->
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td id="breadcrumb">
+<a href="http://codeigniter.com/">CodeIgniter Home</a> &nbsp;&#8250;&nbsp;
+<a href="../index.html">User Guide Home</a> &nbsp;&#8250;&nbsp;
+<a href="index.html">Database Library</a> &nbsp;&#8250;&nbsp;
+Database Forge Class
+</td>
+<td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="codeigniter.com/user_guide/" />Search User Guide&nbsp; <input type="text" class="input" style="width:200px;" name="q" id="q" size="31" maxlength="255" value="" />&nbsp;<input type="submit" class="submit" name="sa" value="Go" /></form></td>
+</tr>
+</table>
+<!-- END BREADCRUMB -->
+
+
+<br clear="all" />
+
+
+<!-- START CONTENT -->
+<div id="content">
+
+<h1>Database Forge Class</h1>
+
+<p>The Database Forge Class contains functions that help you manage your database.</p>
+
+<h3>Table of Contents</h3>
+
+<ul>
+<li><a href="#init">Initializing the Forge Class</a></li>
+<li><a href="#create">Creating a Database</a></li>
+<li><a href="#drop">Dropping a Database</a></li>
+<li><a href="#add_field">Adding Fields</a></li>
+<li><a href="#add_key">Adding Keys</a></li>
+<li><a href="#create_table">Creating a Table</a></li>
+<li><a href="#drop_table">Dropping a Table</a></li>
+<li><a href="#rename_table">Renaming a Table</a></li>
+<li><a href="#modifying_tables">Modifying a Table</a></li>
+</ul>
+
+
+<h2><a name="init"></a>Initializing the Forge Class</h2>
+
+<p class="important"><strong>Important:</strong>&nbsp; In order to initialize the Forge class, your database driver must
+already be running, since the forge class relies on it.</p>
+
+<p>Load the Forge Class as follows:</p>
+
+<code>$this->load->dbforge()</code>
+
+<p>Once initialized you will access the functions using the <dfn>$this->dbforge</dfn> object:</p>
+
+<code>$this->dbforge->some_function()</code>
+<h2><a name="create"></a>$this->dbforge->create_database('db_name')</h2>
+
+<p>Permits you to create the database specified in the first parameter. Returns TRUE/FALSE based on success or failure:</p>
+
+<code>if ($this->dbforge->create_database('my_db'))<br />
+{<br />
+&nbsp;&nbsp;&nbsp; echo 'Database created!';<br />
+}</code>
+
+
+
+
+<h2><a name="drop"></a>$this->dbforge->drop_database('db_name')</h2>
+
+<p>Permits you to drop the database specified in the first parameter. Returns TRUE/FALSE based on success or failure:</p>
+
+<code>if ($this->dbforge->drop_database('my_db'))<br />
+{<br />
+&nbsp;&nbsp;&nbsp; echo 'Database deleted!';<br />
+}</code>
+
+
+<h1>Creating and Dropping Tables</h1>
+<p>There are several things you may wish to do when creating tables. Add fields, add keys to the table, alter columns. CodeIgniter provides a mechanism for this.</p>
+<h2><a name="add_field" id="add_field"></a>Adding fields</h2>
+<p>Fields are created via an associative array. Within the array you must include a 'type' key that relates to the datatype of the field. For example, INT, VARCHAR, TEXT, etc. Many datatypes (for example VARCHAR) also require a 'constraint' key.</p>
+<p><code>$fields = array(<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'users' =&gt; array(<br />
+       &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'type' =&gt; 'VARCHAR',<br />
+       &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'constraint' =&gt; '100',<br />
+       &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;),<br />
+       &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;);<br />
+       <br />
+// will translate to &quot;users VARCHAR(100)&quot; when the field is added.</code></p>
+<p>Additionally, the following key/values can be used:</p>
+<ul>
+       <li>unsigned/true : to generate &quot;UNSIGNED&quot; in the field definition.</li>
+       <li>default/value : to generate a default value in the field definition.</li>
+       <li>null/true : to generate &quot;NULL&quot; in the field definition. Without this, the field will default to &quot;NOT NULL&quot;.</li>
+       <li>auto_increment/true : generates an auto_increment flag on the field. Note that the field type must be a type that supports this, such as integer.</li>
+       </ul>
+<p><code>$fields = array(<br />
+       &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'blog_id' =&gt; array(<br />
+       &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'type' =&gt; 'INT',<br />
+       &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'constraint' =&gt; 5, <br />
+       &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'unsigned' =&gt; TRUE,<br />
+       &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'auto_increment' =&gt; TRUE<br />
+       &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;),<br />
+       &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'blog_title' =&gt; array(<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'type' =&gt; 'VARCHAR',<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'constraint' =&gt; '100',<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;),<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'blog_author' =&gt; array(<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'type' =&gt;'VARCHAR',<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'constraint' =&gt; '100',<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'default' =&gt; 'King of Town',<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;),<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'blog_description' =&gt; array(<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'type' =&gt; 'TEXT',<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'null' =&gt; TRUE,<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;),<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;);<br />
+</code></p>
+<p>After the fields have been defined, they can  be added  using <dfn>$this-&gt;dbforge-&gt;add_field($fields);</dfn> followed by a call to the <dfn>create_table()</dfn> function.</p>
+<h3>$this-&gt;dbforge-&gt;add_field()</h3>
+<p>The add fields function will accept the above array.</p>
+<h3>Passing strings as fields</h3>
+<p>If you know exactly how you want a field to be created, you can pass the string into the field definitions with add_field()</p>
+<p><code>$this-&gt;dbforge-&gt;add_field(&quot;label varchar(100) NOT NULL DEFAULT 'default label'&quot;);</code></p>
+<p class="important">Note: Multiple calls to <dfn>add_field()</dfn> are cumulative.</p>
+<h3>Creating an id field</h3>
+<p>There is a special exception for creating id fields. A field with type id will automatically be assinged as an INT(9) auto_incrementing Primary Key.</p>
+<p><code>$this-&gt;dbforge-&gt;add_field('id');<br />
+       // gives id INT(9) NOT NULL AUTO_INCREMENT</code></p>
+<h2><a name="add_key" id="add_key"></a>Adding Keys</h2>
+<p>Generally speaking, you'll want your table to have Keys. This is accomplished with <dfn>$this-&gt;dbforge-&gt;add_key('field')</dfn>. An optional second parameter set to TRUE will make it a primary key. Note that <dfn>add_key()</dfn> must be followed by a call to <dfn>create_table()</dfn>.</p>
+<p>Multiple column non-primary keys must be sent as an array.  Sample output below is for MySQL.</p>
+<p><code>$this-&gt;dbforge-&gt;add_key('blog_id', TRUE);<br />
+       // gives PRIMARY KEY `blog_id` (`blog_id`)<br />
+       <br />
+       $this-&gt;dbforge-&gt;add_key('blog_id', TRUE);<br />
+       $this-&gt;dbforge-&gt;add_key('site_id', TRUE);<br />
+       // gives PRIMARY KEY `blog_id_site_id` (`blog_id`, `site_id`)<br />
+       <br />
+       $this-&gt;dbforge-&gt;add_key('blog_name');<br />
+       // gives KEY `blog_name` (`blog_name`)<br />
+       <br />
+       $this-&gt;dbforge-&gt;add_key(array('blog_name', 'blog_label'));<br />
+       // gives KEY `blog_name_blog_label` (`blog_name`, `blog_label`)</code></p>
+<h2><a name="create_table" id="create_table"></a>Creating a table</h2>
+<p>After fields and keys have been declared, you can create a new table with</p>
+<p><code>$this-&gt;dbforge-&gt;create_table('table_name');<br />
+// gives CREATE TABLE table_name</code></p>
+<p>An optional second parameter set to TRUE adds an &quot;IF NOT EXISTS&quot; clause into the definition</p>
+<p><code>$this-&gt;dbforge-&gt;create_table('table_name', TRUE);<br />
+// gives CREATE TABLE IF NOT EXISTS table_name</code></p>
+<h2><a name="drop_table" id="drop_table"></a>Dropping a table</h2>
+<p>Executes a DROP TABLE sql</p>
+<p><code>$this-&gt;dbforge-&gt;drop_table('table_name');<br />
+       // gives DROP TABLE IF EXISTS  table_name</code></p>
+<h2><a name="rename_table" id="rename_table"></a>Renaming a table</h2>
+<p>Executes a TABLE rename</p>
+<p><code>$this-&gt;dbforge-&gt;rename_table('old_table_name', 'new_table_name');<br />
+       // gives ALTER TABLE old_table_name RENAME TO new_table_name</code></p>
+<h1><a name="modifying_tables" id="modifying_tables"></a>Modifying Tables</h1>
+<h2>$this-&gt;dbforge-&gt;add_column()</h2>
+<p>The add_column() function is used to modify an existing table. It accepts the same field array as above, and can be used for an unlimited number of additional fields.</p>
+<p><code>$fields = array(<br />
+       &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'preferences' =&gt; array('type' =&gt; 'TEXT')<br />
+);<br />
+$this-&gt;dbforge-&gt;add_column('table_name', $fields);<br />
+<br />
+// gives ALTER TABLE table_name ADD    preferences TEXT</code></p>
+<h2>$this-&gt;dbforge-&gt;drop_column()</h2>
+<p>Used to remove a column from a table. </p>
+<p><code>$this-&gt;dbforge-&gt;drop_column('table_name', 'column_to_drop');</code></p>
+<h2>$this-&gt;dbforge-&gt;modify_column()</h2>
+<p>The usage of this function is identical to add_column(), except it alters an existing column rather than adding a new one. In order to change the name you can add a &quot;name&quot; key into the field defining array.</p>
+<p><code>$fields = array(<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'old_name' =&gt; array(<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'name' =&gt; 'new_name',<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'type' =&gt; 'TEXT',<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;),<br />
+);<br />
+$this-&gt;dbforge-&gt;modify_column('table_name', $fields);<br />
+       <br />
+       // gives ALTER TABLE table_name CHANGE          old_name new_name TEXT </code></p>
+<p>&nbsp;</p>
+</div>
+<!-- END CONTENT -->
+
+
+<div id="footer">
+<p>
+Previous Topic:&nbsp;&nbsp;<a href="caching.html">DB Caching Class</a>
+&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+<a href="#top">Top of Page</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+<a href="../index.html">User Guide Home</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+Next Topic:&nbsp;&nbsp;<a href="utilities.html">Database Utilities Class</a><a href="../libraries/email.html"></a></p>
+<p><a href="http://codeigniter.com">CodeIgniter</a> &nbsp;&middot;&nbsp; Copyright &#169; 2006 - 2011 &nbsp;&middot;&nbsp; <a href="http://ellislab.com/">EllisLab, Inc.</a></p>
+</div>
+
+</body>
+</html>
\ No newline at end of file
diff --git a/user_guide/database/helpers.html b/user_guide/database/helpers.html
new file mode 100755 (executable)
index 0000000..107d2ed
--- /dev/null
@@ -0,0 +1,151 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head>
+
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+<title>Query Helper Functions : CodeIgniter User Guide</title>
+
+<style type='text/css' media='all'>@import url('../userguide.css');</style>
+<link rel='stylesheet' type='text/css' media='all' href='../userguide.css' />
+
+<script type="text/javascript" src="../nav/nav.js"></script>
+<script type="text/javascript" src="../nav/prototype.lite.js"></script>
+<script type="text/javascript" src="../nav/moo.fx.js"></script>
+<script type="text/javascript" src="../nav/user_guide_menu.js"></script>
+
+<meta http-equiv='expires' content='-1' />
+<meta http-equiv= 'pragma' content='no-cache' />
+<meta name='robots' content='all' />
+<meta name='author' content='ExpressionEngine Dev Team' />
+<meta name='description' content='CodeIgniter User Guide' />
+
+</head>
+<body>
+
+<!-- START NAVIGATION -->
+<div id="nav"><div id="nav_inner"><script type="text/javascript">create_menu('../');</script></div></div>
+<div id="nav2"><a name="top"></a><a href="javascript:void(0);" onclick="myHeight.toggle();"><img src="../images/nav_toggle_darker.jpg" width="154" height="43" border="0" title="Toggle Table of Contents" alt="Toggle Table of Contents" /></a></div>
+<div id="masthead">
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td><h1>CodeIgniter User Guide Version 2.0.2</h1></td>
+<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
+</tr>
+</table>
+</div>
+<!-- END NAVIGATION -->
+
+
+<!-- START BREADCRUMB -->
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td id="breadcrumb">
+<a href="http://codeigniter.com/">CodeIgniter Home</a> &nbsp;&#8250;&nbsp;
+<a href="../index.html">User Guide Home</a> &nbsp;&#8250;&nbsp;
+<a href="index.html">Database Library</a> &nbsp;&#8250;&nbsp;
+Query Helpers
+</td>
+<td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="codeigniter.com/user_guide/" />Search User Guide&nbsp; <input type="text" class="input" style="width:200px;" name="q" id="q" size="31" maxlength="255" value="" />&nbsp;<input type="submit" class="submit" name="sa" value="Go" /></form></td>
+</tr>
+</table>
+<!-- END BREADCRUMB -->
+
+
+
+<br clear="all" />
+
+
+<!-- START CONTENT -->
+<div id="content">
+
+
+<h1>Query Helper Functions</h1>
+
+
+<h2>$this->db->insert_id()</h2>
+<p>The insert ID number when performing database inserts.</p>
+
+<h2>$this->db->affected_rows()</h2>
+<p>Displays the number of affected rows, when doing "write" type queries (insert, update, etc.).</p>
+<p>Note:  In MySQL "DELETE FROM TABLE" returns 0 affected rows. The database class has a small hack that allows it to return the
+correct number of affected rows.  By default this hack is enabled but it can be turned off in the database driver file.</p>
+
+
+<h2>$this->db->count_all();</h2>
+<p>Permits you to determine the number of rows in a particular table.  Submit the table name in the first parameter. Example:</p>
+<code>echo $this->db->count_all('<var>my_table</var>');<br />
+<br />
+// Produces an integer, like 25
+</code>
+
+
+<h2>$this->db->platform()</h2>
+<p>Outputs the database platform you are running (MySQL, MS SQL, Postgres, etc...):</p>
+<code>echo $this->db->platform();</code>
+
+
+<h2>$this->db->version()</h2>
+<p>Outputs the database version you are running:</p>
+<code>echo $this->db->version();</code>
+
+
+<h2>$this->db->last_query();</h2>
+<p>Returns the last query that was run (the query string, not the result).  Example:</p>
+
+<code>$str = $this->db->last_query();<br />
+<br />
+// Produces:  SELECT * FROM sometable....
+</code>
+
+
+<p>The following two functions help simplify the process of writing database INSERTs and UPDATEs.</p>
+
+
+<h2>$this->db->insert_string(); </h2>
+<p>This function simplifies the process of writing database inserts. It returns a correctly formatted SQL insert string. Example:</p>
+
+<code>$data = array('name' => $name, 'email' => $email, 'url' => $url);<br />
+<br />
+$str = $this->db->insert_string('table_name', $data);
+</code>
+
+<p>The first parameter is the table name, the second is an associative array with the data to be inserted.  The above example produces:</p>
+<code>INSERT INTO table_name (name, email, url) VALUES ('Rick', 'rick@example.com', 'example.com')</code>
+
+<p class="important">Note: Values are automatically escaped, producing safer queries.</p>
+
+
+
+<h2>$this->db->update_string(); </h2>
+<p>This function simplifies the process of writing database updates. It returns a correctly formatted SQL update string. Example:</p>
+
+<code>$data = array('name' => $name, 'email' => $email, 'url' => $url);<br />
+<br />
+$where = "author_id = 1 AND status = 'active'";
+<br /><br />
+$str = $this->db->update_string('table_name', $data, $where);
+</code>
+
+<p>The first parameter is the table name, the second is an associative array with the data to be updated, and the third parameter is the "where" clause. The above example produces:</p>
+<code> UPDATE table_name SET name = 'Rick', email = 'rick@example.com', url = 'example.com' WHERE author_id = 1 AND status = 'active'</code>
+
+<p class="important">Note: Values are automatically escaped, producing safer queries.</p>
+
+
+</div>
+<!-- END CONTENT -->
+
+
+<div id="footer">
+<p>
+Previous Topic:&nbsp;&nbsp;<a href="results.html">Query Results</a>
+&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+<a href="#top">Top of Page</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+<a href="../index.html">User Guide Home</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+Next Topic:&nbsp;&nbsp;<a href="active_record.html">Active Record Pattern</a>
+</p>
+<p><a href="http://codeigniter.com">CodeIgniter</a> &nbsp;&middot;&nbsp; Copyright &#169; 2006 - 2011 &nbsp;&middot;&nbsp; <a href="http://ellislab.com/">EllisLab, Inc.</a></p>
+</div>
+
+</body>
+</html>
\ No newline at end of file
diff --git a/user_guide/database/index.html b/user_guide/database/index.html
new file mode 100755 (executable)
index 0000000..fa3548c
--- /dev/null
@@ -0,0 +1,99 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head>
+
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+<title>The Database Class : CodeIgniter User Guide</title>
+
+<style type='text/css' media='all'>@import url('../userguide.css');</style>
+<link rel='stylesheet' type='text/css' media='all' href='../userguide.css' />
+
+<script type="text/javascript" src="../nav/nav.js"></script>
+<script type="text/javascript" src="../nav/prototype.lite.js"></script>
+<script type="text/javascript" src="../nav/moo.fx.js"></script>
+<script type="text/javascript" src="../nav/user_guide_menu.js"></script>
+
+<meta http-equiv='expires' content='-1' />
+<meta http-equiv= 'pragma' content='no-cache' />
+<meta name='robots' content='all' />
+<meta name='author' content='ExpressionEngine Dev Team' />
+<meta name='description' content='CodeIgniter User Guide' />
+
+</head>
+<body>
+
+<!-- START NAVIGATION -->
+<div id="nav"><div id="nav_inner"><script type="text/javascript">create_menu('../');</script></div></div>
+<div id="nav2"><a name="top"></a><a href="javascript:void(0);" onclick="myHeight.toggle();"><img src="../images/nav_toggle_darker.jpg" width="154" height="43" border="0" title="Toggle Table of Contents" alt="Toggle Table of Contents" /></a></div>
+<div id="masthead">
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td><h1>CodeIgniter User Guide Version 2.0.2</h1></td>
+<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
+</tr>
+</table>
+</div>
+<!-- END NAVIGATION -->
+
+
+<!-- START BREADCRUMB -->
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td id="breadcrumb">
+<a href="http://codeigniter.com/">CodeIgniter Home</a> &nbsp;&#8250;&nbsp;
+<a href="../index.html">User Guide Home</a> &nbsp;&#8250;&nbsp;
+Database Library
+</td>
+<td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="codeigniter.com/user_guide/" />Search User Guide&nbsp; <input type="text" class="input" style="width:200px;" name="q" id="q" size="31" maxlength="255" value="" />&nbsp;<input type="submit" class="submit" name="sa" value="Go" /></form></td>
+</tr>
+</table>
+<!-- END BREADCRUMB -->
+
+
+<br clear="all" />
+
+
+<!-- START CONTENT -->
+<div id="content">
+
+
+<h1>The Database Class</h1>
+
+<p>CodeIgniter comes with a full-featured and very fast abstracted database class that supports both traditional
+structures and Active Record patterns. The database functions offer clear, simple syntax.</p>
+
+       <ul>
+               <li><a href="examples.html">Quick Start:  Usage Examples</a></li>
+               <li><a href="configuration.html">Database Configuration</a></li>
+               <li><a href="connecting.html">Connecting to a Database</a></li>
+               <li><a href="queries.html">Running Queries</a></li>
+               <li><a href="results.html">Generating Query Results</a></li>
+               <li><a href="helpers.html">Query Helper Functions</a></li>
+               <li><a href="active_record.html">Active Record Class</a></li>
+               <li><a href="transactions.html">Transactions</a></li>
+               <li><a href="table_data.html">Table MetaData</a></li>
+               <li><a href="fields.html">Field MetaData</a></li>
+               <li><a href="call_function.html">Custom Function Calls</a></li>
+               <li><a href="caching.html">Query Caching</a></li>
+               <li><a href="forge.html">Database manipulation with Database Forge</a></li>
+               <li><a href="utilities.html">Database Utilities Class</a></li>
+       </ul>
+
+
+</div>
+<!-- END CONTENT -->
+
+
+<div id="footer">
+<p>
+Previous Topic:&nbsp;&nbsp;<a href="../libraries/config.html">Config Class</a>
+&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+<a href="#top">Top of Page</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+<a href="../index.html">User Guide Home</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+Next Topic:&nbsp;&nbsp;<a href="examples.html">Quick Start: Usage Examples</a>
+</p>
+<p><a href="http://codeigniter.com">CodeIgniter</a> &nbsp;&middot;&nbsp; Copyright &#169; 2006 - 2011 &nbsp;&middot;&nbsp; <a href="http://ellislab.com/">EllisLab, Inc.</a></p>
+</div>
+
+</body>
+</html>
\ No newline at end of file
diff --git a/user_guide/database/queries.html b/user_guide/database/queries.html
new file mode 100755 (executable)
index 0000000..f9f9680
--- /dev/null
@@ -0,0 +1,153 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head>
+
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+<title>Queries : CodeIgniter User Guide</title>
+
+<style type='text/css' media='all'>@import url('../userguide.css');</style>
+<link rel='stylesheet' type='text/css' media='all' href='../userguide.css' />
+
+<script type="text/javascript" src="../nav/nav.js"></script>
+<script type="text/javascript" src="../nav/prototype.lite.js"></script>
+<script type="text/javascript" src="../nav/moo.fx.js"></script>
+<script type="text/javascript" src="../nav/user_guide_menu.js"></script>
+
+<meta http-equiv='expires' content='-1' />
+<meta http-equiv= 'pragma' content='no-cache' />
+<meta name='robots' content='all' />
+<meta name='author' content='ExpressionEngine Dev Team' />
+<meta name='description' content='CodeIgniter User Guide' />
+
+</head>
+<body>
+
+<!-- START NAVIGATION -->
+<div id="nav"><div id="nav_inner"><script type="text/javascript">create_menu('../');</script></div></div>
+<div id="nav2"><a name="top"></a><a href="javascript:void(0);" onclick="myHeight.toggle();"><img src="../images/nav_toggle_darker.jpg" width="154" height="43" border="0" title="Toggle Table of Contents" alt="Toggle Table of Contents" /></a></div>
+<div id="masthead">
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td><h1>CodeIgniter User Guide Version 2.0.2</h1></td>
+<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
+</tr>
+</table>
+</div>
+<!-- END NAVIGATION -->
+
+
+<!-- START BREADCRUMB -->
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td id="breadcrumb">
+<a href="http://codeigniter.com/">CodeIgniter Home</a> &nbsp;&#8250;&nbsp;
+<a href="../index.html">User Guide Home</a> &nbsp;&#8250;&nbsp;
+<a href="index.html">Database Library</a> &nbsp;&#8250;&nbsp;
+Queries
+</td>
+<td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="codeigniter.com/user_guide/" />Search User Guide&nbsp; <input type="text" class="input" style="width:200px;" name="q" id="q" size="31" maxlength="255" value="" />&nbsp;<input type="submit" class="submit" name="sa" value="Go" /></form></td>
+</tr>
+</table>
+<!-- END BREADCRUMB -->
+
+
+
+<br clear="all" />
+
+
+<!-- START CONTENT -->
+<div id="content">
+
+
+<h1>Queries</h1>
+
+<h2>$this->db->query();</h2>
+
+<p>To submit a query, use the following function:</p>
+
+<code>$this->db->query('YOUR QUERY HERE');</code>
+
+<p>The <dfn>query()</dfn> function returns a database result <strong>object</strong> when "read" type queries are run,
+which you can use to <a href="results.html">show your results</a>.  When "write" type queries are run it simply returns TRUE or FALSE
+depending on success or failure.  When retrieving data you will typically assign the query to your own variable, like this:</p>
+
+<code><var>$query</var> = $this->db->query('YOUR QUERY HERE');</code>
+
+<h2>$this->db->simple_query();</h2>
+
+<p>This is a simplified version of the <dfn>$this->db->query()</dfn> function.  It ONLY returns TRUE/FALSE on success or failure.
+It DOES NOT return a database result set, nor does it set the query timer, or compile bind data, or store your query for debugging.
+It simply lets you submit a query. Most users will rarely use this function.</p>
+
+
+<h1>Adding Database prefixes manually</h1>
+<p>If you have configured a database prefix and would like to add it in manually for, you can use the following.</p>
+<p><code>$this-&gt;db-&gt;dbprefix('tablename');<br />
+// outputs prefix_tablename</code></p>
+
+
+<h1>Protecting identifiers</h1>
+<p>In many databases it is advisable to protect table and field names - for example with backticks in MySQL. <strong>Active Record queries are automatically protected</strong>, however if you need to manually protect an identifier you can use:</p>
+<p><code>$this-&gt;db-&gt;protect_identifiers('table_name');</code></p>
+
+<p>This function will also add a table prefix to your table, assuming you have a prefix specified in your database config file. To enable the prefixing set <kbd>TRUE</kbd> (boolen) via the second parameter:</p>
+<p><code>$this-&gt;db-&gt;protect_identifiers('table_name', <kbd>TRUE</kbd>);</code></p>
+
+
+<h1>Escaping Queries</h1>
+<p>It's a very good security practice to escape your data before submitting it into your database.
+CodeIgniter has three methods that help you do this:</p>
+
+<ol>
+<li><strong>$this->db->escape()</strong> This function determines the data type so that it
+can escape only string data.  It also automatically adds single quotes around the data so you don't have to:
+
+<code>$sql = "INSERT INTO table (title) VALUES(".$this->db->escape($title).")";</code></li>
+
+<li><strong>$this->db->escape_str()</strong>  This function escapes the data passed to it, regardless of type.
+Most of the time you'll use the above function rather than this one. Use the function like this:
+
+<code>$sql = "INSERT INTO table (title) VALUES('".$this->db->escape_str($title)."')";</code></li>
+
+<li><strong>$this->db->escape_like_str()</strong>  This method should be used when strings are to be used in LIKE
+conditions so that LIKE wildcards ('%', '_') in the string are also properly escaped.
+
+<code>$search = '20% raise';<br />
+$sql = "SELECT id FROM table WHERE column LIKE '%".$this->db->escape_like_str($search)."%'";</code></li>
+
+</ol>
+
+
+<h1>Query Bindings</h1>
+
+
+<p>Bindings enable you to simplify your query syntax by letting the system put the queries together for you. Consider the following example:</p>
+
+<code>
+$sql = "SELECT * FROM some_table WHERE id = <var>?</var> AND status = <var>?</var> AND author = <var>?</var>";
+<br /><br />
+$this->db->query($sql, array(3, 'live', 'Rick'));
+</code>
+
+<p>The question marks in the query are automatically replaced with the values in the array in the second parameter of the query function.</p>
+<p class="important">The secondary benefit of using binds is that the values are automatically escaped, producing safer queries.  You don't have to remember to manually escape data; the engine does it automatically for you.</p>
+
+
+
+</div>
+<!-- END CONTENT -->
+
+
+<div id="footer">
+<p>
+Previous Topic:&nbsp;&nbsp;<a href="connecting.html">Connecting to your Database</a>
+&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+<a href="#top">Top of Page</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+<a href="../index.html">User Guide Home</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+Next Topic:&nbsp;&nbsp;<a href="results.html">Query Results</a>
+</p>
+<p><a href="http://codeigniter.com">CodeIgniter</a> &nbsp;&middot;&nbsp; Copyright &#169; 2006 - 2011 &nbsp;&middot;&nbsp; <a href="http://ellislab.com/">EllisLab, Inc.</a></p>
+</div>
+
+</body>
+</html>
\ No newline at end of file
diff --git a/user_guide/database/results.html b/user_guide/database/results.html
new file mode 100755 (executable)
index 0000000..8ad6a19
--- /dev/null
@@ -0,0 +1,259 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head>
+
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+<title>Generating Query Results : CodeIgniter User Guide</title>
+
+<style type='text/css' media='all'>@import url('../userguide.css');</style>
+<link rel='stylesheet' type='text/css' media='all' href='../userguide.css' />
+
+<script type="text/javascript" src="../nav/nav.js"></script>
+<script type="text/javascript" src="../nav/prototype.lite.js"></script>
+<script type="text/javascript" src="../nav/moo.fx.js"></script>
+<script type="text/javascript" src="../nav/user_guide_menu.js"></script>
+
+<meta http-equiv='expires' content='-1' />
+<meta http-equiv= 'pragma' content='no-cache' />
+<meta name='robots' content='all' />
+<meta name='author' content='ExpressionEngine Dev Team' />
+<meta name='description' content='CodeIgniter User Guide' />
+
+</head>
+<body>
+
+<!-- START NAVIGATION -->
+<div id="nav"><div id="nav_inner"><script type="text/javascript">create_menu('../');</script></div></div>
+<div id="nav2"><a name="top"></a><a href="javascript:void(0);" onclick="myHeight.toggle();"><img src="../images/nav_toggle_darker.jpg" width="154" height="43" border="0" title="Toggle Table of Contents" alt="Toggle Table of Contents" /></a></div>
+<div id="masthead">
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td><h1>CodeIgniter User Guide Version 2.0.2</h1></td>
+<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
+</tr>
+</table>
+</div>
+<!-- END NAVIGATION -->
+
+
+<!-- START BREADCRUMB -->
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td id="breadcrumb">
+<a href="http://codeigniter.com/">CodeIgniter Home</a> &nbsp;&#8250;&nbsp;
+<a href="../index.html">User Guide Home</a> &nbsp;&#8250;&nbsp;
+<a href="index.html">Database Library</a> &nbsp;&#8250;&nbsp;
+Query Results
+</td>
+<td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="codeigniter.com/user_guide/" />Search User Guide&nbsp; <input type="text" class="input" style="width:200px;" name="q" id="q" size="31" maxlength="255" value="" />&nbsp;<input type="submit" class="submit" name="sa" value="Go" /></form></td>
+</tr>
+</table>
+<!-- END BREADCRUMB -->
+
+
+<br clear="all" />
+
+
+<!-- START CONTENT -->
+<div id="content">
+
+
+
+<h1>Generating Query Results</h1>
+
+
+<p>There are several ways to generate query results:</p>
+
+       <h2>result()</h2>
+
+       <p>This function returns the query result as an array of <strong>objects</strong>, or <strong>an empty array</strong> on failure.
+
+       Typically you'll use this in a foreach loop, like this:</p>
+
+       <code>
+       $query = $this->db->query("YOUR QUERY");<br />
+       <br />
+       foreach ($query->result() as $row)<br />
+       {<br />
+       &nbsp;&nbsp;&nbsp;echo $row->title;<br />
+       &nbsp;&nbsp;&nbsp;echo $row->name;<br />
+       &nbsp;&nbsp;&nbsp;echo $row->body;<br />
+       }</code>
+
+       <p>The above <dfn>function</dfn> is an alias of <dfn>result_object()</dfn>.</p>
+
+       <p>If you run queries that might <strong>not</strong> produce a result, you are encouraged to test the result first:</p>
+
+       <code>
+       $query = $this->db->query("YOUR QUERY");<br />
+       <br />
+       if ($query->num_rows() > 0)<br />
+       {<br />
+       &nbsp;&nbsp;&nbsp;foreach ($query->result() as $row)<br />
+       &nbsp;&nbsp;&nbsp;{<br />
+       &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;echo $row->title;<br />
+       &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;echo $row->name;<br />
+       &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;echo $row->body;<br />
+       &nbsp;&nbsp;&nbsp;}<br />
+       }
+       </code>
+
+       <p>You can also pass a string to result() which represents a class to instantiate for each result object (note: this class must be loaded)</p>
+
+       <code>
+       $query = $this->db->query("SELECT * FROM users;");<br />
+       <br />
+       foreach ($query->result('User') as $user)<br />
+       {<br />
+       &nbsp;&nbsp;&nbsp;echo $row->name; // call attributes<br />
+       &nbsp;&nbsp;&nbsp;echo $row->reverse_name(); // or methods defined on the 'User' class<br />
+       }
+       </code>
+
+       <h2>result_array()</h2>
+
+       <p>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:</p>
+       <code>
+       $query = $this->db->query("YOUR QUERY");<br />
+       <br />
+       foreach ($query->result_array() as $row)<br />
+       {<br />
+       &nbsp;&nbsp;&nbsp;echo $row['title'];<br />
+       &nbsp;&nbsp;&nbsp;echo $row['name'];<br />
+       &nbsp;&nbsp;&nbsp;echo $row['body'];<br />
+       }</code>
+
+
+       <h2>row()</h2>
+
+       <p>This function returns a single result row.  If your query has more than one row, it returns only the first row.
+       The result is returned as an <strong>object</strong>.  Here's a usage example:</p>
+       <code>
+       $query = $this->db->query("YOUR QUERY");<br />
+       <br />
+       if ($query->num_rows() > 0)<br />
+       {<br />
+       &nbsp;&nbsp;&nbsp;$row = $query->row();
+       <br /><br />
+       &nbsp;&nbsp;&nbsp;echo $row->title;<br />
+       &nbsp;&nbsp;&nbsp;echo $row->name;<br />
+       &nbsp;&nbsp;&nbsp;echo $row->body;<br />
+       }
+       </code>
+
+       <p>If you want a specific row returned you can submit the row number as a digit in the first parameter:</p>
+
+       <code>$row = $query->row(<dfn>5</dfn>);</code>
+
+       <p>You can also add a second String parameter, which is the name of a class to instantiate the row with:</p>
+
+       <code>
+       $query = $this->db->query("SELECT * FROM users LIMIT 1;");<br />
+       <br />
+       $query->row(0, 'User')<br />
+       echo $row->name; // call attributes<br />
+       echo $row->reverse_name(); // or methods defined on the 'User' class<br />
+       </code>
+
+       <h2>row_array()</h2>
+
+       <p>Identical to the above <var>row()</var> function, except it returns an array.  Example:</p>
+
+       <code>
+       $query = $this->db->query("YOUR QUERY");<br />
+       <br />
+       if ($query->num_rows() > 0)<br />
+       {<br />
+       &nbsp;&nbsp;&nbsp;$row = $query->row_array();
+       <br /><br />
+       &nbsp;&nbsp;&nbsp;echo $row['title'];<br />
+       &nbsp;&nbsp;&nbsp;echo $row['name'];<br />
+       &nbsp;&nbsp;&nbsp;echo $row['body'];<br />
+       }
+       </code>
+
+
+       <p>If you want a specific row returned you can submit the row number as a digit in the first parameter:</p>
+
+       <code>$row = $query->row_array(<dfn>5</dfn>);</code>
+
+
+       <p>In addition, you can walk forward/backwards/first/last through your results using these variations:</p>
+
+<p>
+       <strong>$row = $query->first_row()</strong><br />
+       <strong>$row = $query->last_row()</strong><br />
+       <strong>$row = $query->next_row()</strong><br />
+       <strong>$row = $query->previous_row()</strong>
+</p>
+
+<p>By default they return an object unless you put the word "array" in the parameter:</p>
+
+<p>
+       <strong>$row = $query->first_row('array')</strong><br />
+       <strong>$row = $query->last_row('array')</strong><br />
+       <strong>$row = $query->next_row('array')</strong><br />
+       <strong>$row = $query->previous_row('array')</strong>
+</p>
+
+
+
+<h1>Result Helper Functions</h1>
+
+
+<h2>$query->num_rows()</h2>
+<p>The number of rows returned by the query. Note: In this example, <dfn>$query</dfn> is the variable that the query result object is assigned to:</p>
+
+<code>$query = $this->db->query('SELECT * FROM my_table');<br /><br />
+echo $query->num_rows();
+</code>
+
+<h2>$query->num_fields()</h2>
+<p>The number of FIELDS (columns) returned by the query.  Make sure to call the function using your query result object:</p>
+
+<code>$query = $this->db->query('SELECT * FROM my_table');<br /><br />
+echo $query->num_fields();
+</code>
+
+
+
+<h2>$query->free_result()</h2>
+<p>It frees the memory associated with the result and deletes the result resource ID.  Normally PHP frees its memory automatically at the end of script
+execution.  However, if you are running a lot of queries in a particular script you might want to free the result after each query result has been
+generated in order to cut down on memory consumptions.  Example:
+</p>
+
+<code>$query = $this->db->query('SELECT title FROM my_table');<br /><br />
+foreach ($query->result() as $row)<br />
+{<br />
+&nbsp;&nbsp;&nbsp;echo $row->title;<br />
+}<br />
+$query->free_result();  // The $query result object will no longer be available<br />
+<br />
+$query2 = $this->db->query('SELECT name FROM some_table');<br /><br />
+$row = $query2->row();<br />
+echo $row->name;<br />
+$query2->free_result();  // The $query2 result object will no longer be available
+</code>
+
+
+
+
+
+</div>
+<!-- END CONTENT -->
+
+
+<div id="footer">
+<p>
+Previous Topic:&nbsp;&nbsp;<a href="queries.html">Queries</a>
+&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+<a href="#top">Top of Page</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+<a href="../index.html">User Guide Home</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+Next Topic:&nbsp;&nbsp;<a href="helpers.html">Query Helper Functions</a>
+</p>
+<p><a href="http://codeigniter.com">CodeIgniter</a> &nbsp;&middot;&nbsp; Copyright &#169; 2006 - 2011 &nbsp;&middot;&nbsp; <a href="http://ellislab.com/">EllisLab, Inc.</a></p>
+</div>
+
+</body>
+</html>
diff --git a/user_guide/database/table_data.html b/user_guide/database/table_data.html
new file mode 100755 (executable)
index 0000000..a2aaa99
--- /dev/null
@@ -0,0 +1,113 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head>
+
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+<title>Table Data : CodeIgniter User Guide</title>
+
+<style type='text/css' media='all'>@import url('../userguide.css');</style>
+<link rel='stylesheet' type='text/css' media='all' href='../userguide.css' />
+
+<script type="text/javascript" src="../nav/nav.js"></script>
+<script type="text/javascript" src="../nav/prototype.lite.js"></script>
+<script type="text/javascript" src="../nav/moo.fx.js"></script>
+<script type="text/javascript" src="../nav/user_guide_menu.js"></script>
+
+<meta http-equiv='expires' content='-1' />
+<meta http-equiv= 'pragma' content='no-cache' />
+<meta name='robots' content='all' />
+<meta name='author' content='ExpressionEngine Dev Team' />
+<meta name='description' content='CodeIgniter User Guide' />
+
+</head>
+<body>
+
+<!-- START NAVIGATION -->
+<div id="nav"><div id="nav_inner"><script type="text/javascript">create_menu('../');</script></div></div>
+<div id="nav2"><a name="top"></a><a href="javascript:void(0);" onclick="myHeight.toggle();"><img src="../images/nav_toggle_darker.jpg" width="154" height="43" border="0" title="Toggle Table of Contents" alt="Toggle Table of Contents" /></a></div>
+<div id="masthead">
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td><h1>CodeIgniter User Guide Version 2.0.2</h1></td>
+<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
+</tr>
+</table>
+</div>
+<!-- END NAVIGATION -->
+
+
+<!-- START BREADCRUMB -->
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td id="breadcrumb">
+<a href="http://codeigniter.com/">CodeIgniter Home</a> &nbsp;&#8250;&nbsp;
+<a href="../index.html">User Guide Home</a> &nbsp;&#8250;&nbsp;
+<a href="index.html">Database Library</a> &nbsp;&#8250;&nbsp;
+Table Data
+</td>
+<td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="codeigniter.com/user_guide/" />Search User Guide&nbsp; <input type="text" class="input" style="width:200px;" name="q" id="q" size="31" maxlength="255" value="" />&nbsp;<input type="submit" class="submit" name="sa" value="Go" /></form></td>
+</tr>
+</table>
+<!-- END BREADCRUMB -->
+
+
+<br clear="all" />
+
+
+<!-- START CONTENT -->
+<div id="content">
+
+
+
+<h1>Table Data</h1>
+
+<p>These functions let you fetch table information.</p>
+
+<h2>$this->db->list_tables();</h2>
+
+<p>Returns an array containing the names of all the tables in the database you are currently connected to.  Example:</p>
+
+<code>$tables = $this->db->list_tables();<br />
+<br />
+foreach ($tables as $table)<br />
+{<br />
+&nbsp;&nbsp; echo $table;<br />
+}
+</code>
+
+
+<h2>$this->db->table_exists();</h2>
+
+<p>Sometimes it's helpful to know whether a particular table exists before running an operation on it.
+Returns a boolean TRUE/FALSE.  Usage example:</p>
+
+<code>
+if ($this->db->table_exists('table_name'))<br />
+{<br />
+&nbsp;&nbsp; // some code...<br />
+}
+</code>
+
+<p>Note:  Replace <em>table_name</em> with the name of the table you are looking for.</p>
+
+
+
+
+
+</div>
+<!-- END CONTENT -->
+
+
+<div id="footer">
+<p>
+Previous Topic:&nbsp;&nbsp;<a href="transactions.html"> Transactions</a>
+&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+<a href="#top">Top of Page</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+<a href="../index.html">User Guide Home</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+Next Topic:&nbsp;&nbsp;<a href="fields.html"> Field Metadata</a>
+</p>
+<p><a href="http://codeigniter.com">CodeIgniter</a> &nbsp;&middot;&nbsp; Copyright &#169; 2006 - 2011 &nbsp;&middot;&nbsp; <a href="http://ellislab.com/">EllisLab, Inc.</a></p>
+</div>
+
+</body>
+</html>
\ No newline at end of file
diff --git a/user_guide/database/transactions.html b/user_guide/database/transactions.html
new file mode 100755 (executable)
index 0000000..74945d4
--- /dev/null
@@ -0,0 +1,200 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head>
+
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+<title>Transactions : CodeIgniter User Guide</title>
+
+<style type='text/css' media='all'>@import url('../userguide.css');</style>
+<link rel='stylesheet' type='text/css' media='all' href='../userguide.css' />
+
+<script type="text/javascript" src="../nav/nav.js"></script>
+<script type="text/javascript" src="../nav/prototype.lite.js"></script>
+<script type="text/javascript" src="../nav/moo.fx.js"></script>
+<script type="text/javascript" src="../nav/user_guide_menu.js"></script>
+
+<meta http-equiv='expires' content='-1' />
+<meta http-equiv= 'pragma' content='no-cache' />
+<meta name='robots' content='all' />
+<meta name='author' content='ExpressionEngine Dev Team' />
+<meta name='description' content='CodeIgniter User Guide' />
+
+</head>
+<body>
+
+<!-- START NAVIGATION -->
+<div id="nav"><div id="nav_inner"><script type="text/javascript">create_menu('../');</script></div></div>
+<div id="nav2"><a name="top"></a><a href="javascript:void(0);" onclick="myHeight.toggle();"><img src="../images/nav_toggle_darker.jpg" width="154" height="43" border="0" title="Toggle Table of Contents" alt="Toggle Table of Contents" /></a></div>
+<div id="masthead">
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td><h1>CodeIgniter User Guide Version 2.0.2</h1></td>
+<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
+</tr>
+</table>
+</div>
+<!-- END NAVIGATION -->
+
+
+
+<!-- START BREADCRUMB -->
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td id="breadcrumb">
+<a href="http://codeigniter.com/">CodeIgniter Home</a> &nbsp;&#8250;&nbsp;
+<a href="../index.html">User Guide Home</a> &nbsp;&#8250;&nbsp;
+<a href="index.html">Database Library</a> &nbsp;&#8250;&nbsp;
+Transactions
+</td>
+<td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="codeigniter.com/user_guide/" />Search User Guide&nbsp; <input type="text" class="input" style="width:200px;" name="q" id="q" size="31" maxlength="255" value="" />&nbsp;<input type="submit" class="submit" name="sa" value="Go" /></form></td>
+</tr>
+</table>
+<!-- END BREADCRUMB -->
+
+
+<br clear="all" />
+
+
+<!-- START CONTENT -->
+<div id="content">
+
+
+<h1>Transactions</h1>
+
+<p>CodeIgniter's database abstraction allows you to use <dfn>transactions</dfn> with databases that support transaction-safe table types.  In MySQL, you'll need
+to be running InnoDB or BDB table types rather than the more common MyISAM.  Most other database platforms support transactions natively.</p>
+
+<p>If you are not familiar with
+transactions we recommend you find a good online resource to learn about them for your particular database.  The information below assumes you
+have a basic understanding of transactions.
+</p>
+
+<h2>CodeIgniter's Approach to Transactions</h2>
+
+<p>CodeIgniter utilizes an approach to transactions that is very similar to the process used by the popular database class ADODB.  We've chosen that approach
+because it greatly simplifies the process of running transactions.  In most cases all that is required are two lines of code.</p>
+
+<p>Traditionally, transactions have required a fair amount of work to implement since they demand that you to keep track of your queries
+and determine whether to <dfn>commit</dfn> or <dfn>rollback</dfn> based on the success or failure of your queries. This is particularly cumbersome with
+nested queries. In contrast,
+we've implemented a smart transaction system that does all this for you automatically (you can also manage your transactions manually if you choose to,
+but there's really no benefit).</p>
+
+<h2>Running Transactions</h2>
+
+<p>To run your queries using transactions you will use the <dfn>$this->db->trans_start()</dfn> and <dfn>$this->db->trans_complete()</dfn> functions as follows:</p>
+
+<code>
+<kbd>$this->db->trans_start();</kbd><br />
+$this->db->query('AN SQL QUERY...');<br />
+$this->db->query('ANOTHER QUERY...');<br />
+$this->db->query('AND YET ANOTHER QUERY...');<br />
+<kbd>$this->db->trans_complete();</kbd>
+</code>
+
+<p>You can run as many queries as you want between the start/complete functions and they will all be committed or rolled back based on success or failure
+of any given query.</p>
+
+
+<h2>Strict Mode</h2>
+
+<p>By default CodeIgniter runs all transactions in <dfn>Strict Mode</dfn>.  When strict mode is enabled, if you are running multiple groups of
+transactions, if one group fails all groups will be rolled back. If strict mode is disabled, each group is treated independently, meaning
+a failure of one group will not affect any others.</p>
+
+<p>Strict Mode can be disabled as follows:</p>
+
+<code>$this->db->trans_strict(FALSE);</code>
+
+
+<h2>Managing Errors</h2>
+
+<p>If you have error reporting enabled in your <dfn>config/database.php</dfn> file you'll see a standard error message if the commit was unsuccessful. If debugging is turned off, you can
+manage your own errors like this:</p>
+
+<code>
+$this->db->trans_start();<br />
+$this->db->query('AN SQL QUERY...');<br />
+$this->db->query('ANOTHER QUERY...');<br />
+$this->db->trans_complete();<br />
+<br />
+if (<kbd>$this->db->trans_status()</kbd> === FALSE)<br />
+{<br />
+&nbsp;&nbsp;&nbsp;&nbsp;// generate an error... or use the log_message() function to log your error<br />
+}
+</code>
+
+
+<h2>Enabling Transactions</h2>
+
+<p>Transactions are enabled automatically the moment you use <dfn>$this->db->trans_start()</dfn>.  If you would like to disable transactions you
+can do so using <dfn>$this->db->trans_off()</dfn>:</p>
+
+<code>
+<kbd>$this->db->trans_off()</kbd><br /><br />
+
+$this->db->trans_start();<br />
+$this->db->query('AN SQL QUERY...');<br />
+$this->db->trans_complete();
+</code>
+
+<p class="important">When transactions are disabled, your queries will be auto-commited, just as they are when running queries without transactions.</p>
+
+
+<h2>Test Mode</h2>
+
+<p>You can optionally put the transaction system into "test mode", which will cause your queries to be rolled back -- even if the queries produce a valid result.
+To use test mode simply set the first parameter in the <dfn>$this->db->trans_start()</dfn> function to <samp>TRUE</samp>:</p>
+
+<code>
+$this->db->trans_start(<samp>TRUE</samp>); // Query will be rolled back<br />
+$this->db->query('AN SQL QUERY...');<br />
+$this->db->trans_complete();
+</code>
+
+
+<h2>Running Transactions Manually</h2>
+
+<p>If you would like to run transactions manually you can do so as follows:</p>
+
+<code>
+$this->db->trans_begin();<br /><br />
+
+$this->db->query('AN SQL QUERY...');<br />
+$this->db->query('ANOTHER QUERY...');<br />
+$this->db->query('AND YET ANOTHER QUERY...');<br />
+
+<br />
+
+if ($this->db->trans_status() === FALSE)<br />
+{<br />
+&nbsp;&nbsp;&nbsp;&nbsp;$this->db->trans_rollback();<br />
+}<br />
+else<br />
+{<br />
+&nbsp;&nbsp;&nbsp;&nbsp;$this->db->trans_commit();<br />
+}<br />
+</code>
+
+<p class="important"><strong>Note:</strong> Make sure to use <kbd>$this->db->trans_begin()</kbd> when running manual transactions, <strong>NOT</strong>
+<dfn>$this->db->trans_start()</dfn>.</p>
+
+
+
+
+</div>
+<!-- END CONTENT -->
+
+
+<div id="footer">
+<p>
+Previous Topic:&nbsp;&nbsp; <a href="fields.html">Field MetaData</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+<a href="#top">Top of Page</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+<a href="../index.html">User Guide Home</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+Next Topic:&nbsp;&nbsp;<a href="table_data.html">Table Metadata</a>
+</p>
+<p><a href="http://codeigniter.com">CodeIgniter</a> &nbsp;&middot;&nbsp; Copyright &#169; 2006 - 2011 &nbsp;&middot;&nbsp; <a href="http://ellislab.com/">EllisLab, Inc.</a></p>
+</div>
+
+</body>
+</html>
\ No newline at end of file
diff --git a/user_guide/database/utilities.html b/user_guide/database/utilities.html
new file mode 100755 (executable)
index 0000000..c488180
--- /dev/null
@@ -0,0 +1,314 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head>
+
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+<title>Database Utility Class : CodeIgniter User Guide</title>
+
+<style type='text/css' media='all'>@import url('../userguide.css');</style>
+<link rel='stylesheet' type='text/css' media='all' href='../userguide.css' />
+
+<script type="text/javascript" src="../nav/nav.js"></script>
+<script type="text/javascript" src="../nav/prototype.lite.js"></script>
+<script type="text/javascript" src="../nav/moo.fx.js"></script>
+<script type="text/javascript" src="../nav/user_guide_menu.js"></script>
+
+<meta http-equiv='expires' content='-1' />
+<meta http-equiv= 'pragma' content='no-cache' />
+<meta name='robots' content='all' />
+<meta name='author' content='ExpressionEngine Dev Team' />
+<meta name='description' content='CodeIgniter User Guide' />
+
+</head>
+<body>
+
+<!-- START NAVIGATION -->
+<div id="nav"><div id="nav_inner"><script type="text/javascript">create_menu('../');</script></div></div>
+<div id="nav2"><a name="top"></a><a href="javascript:void(0);" onclick="myHeight.toggle();"><img src="../images/nav_toggle_darker.jpg" width="154" height="43" border="0" title="Toggle Table of Contents" alt="Toggle Table of Contents" /></a></div>
+<div id="masthead">
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td><h1>CodeIgniter User Guide Version 2.0.2</h1></td>
+<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
+</tr>
+</table>
+</div>
+<!-- END NAVIGATION -->
+
+
+<!-- START BREADCRUMB -->
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td id="breadcrumb">
+<a href="http://codeigniter.com/">CodeIgniter Home</a> &nbsp;&#8250;&nbsp;
+<a href="../index.html">User Guide Home</a> &nbsp;&#8250;&nbsp;
+<a href="index.html">Database Library</a> &nbsp;&#8250;&nbsp;
+Database Utility Class
+</td>
+<td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="codeigniter.com/user_guide/" />Search User Guide&nbsp; <input type="text" class="input" style="width:200px;" name="q" id="q" size="31" maxlength="255" value="" />&nbsp;<input type="submit" class="submit" name="sa" value="Go" /></form></td>
+</tr>
+</table>
+<!-- END BREADCRUMB -->
+
+
+<br clear="all" />
+
+
+<!-- START CONTENT -->
+<div id="content">
+
+<h1>Database Utility Class</h1>
+
+<p>The Database Utility Class contains functions that help you manage your database.</p>
+
+<h3>Table of Contents</h3>
+
+<ul>
+<li><a href="#init">Initializing the Utility Class</a></li>
+<li><a href="#list">Listing your Databases</a></li>
+<li><a href="#exists">Checking for a specific Database</a></li>
+<li><a href="#opttb">Optimizing your Tables</a></li>
+<li><a href="#repair">Repairing your Databases</a></li>
+<li><a href="#optdb">Optimizing your Database</a></li>
+<li><a href="#csv">CSV Files from a Database Result</a></li>
+<li><a href="#xml">XML Files from a Database Result</a></li>
+<li><a href="#backup">Backing up your Database</a></li>
+</ul>
+
+
+
+<h2><a name="init"></a>Initializing the Utility Class</h2>
+
+<p class="important"><strong>Important:</strong>&nbsp; In order to initialize the Utility class, your database driver must
+already be running, since the utilities class relies on it.</p>
+
+<p>Load the Utility Class as follows:</p>
+
+<code>$this->load->dbutil()</code>
+
+<p>Once initialized you will access the functions using the <dfn>$this->dbutil</dfn> object:</p>
+
+<code>$this->dbutil->some_function()</code>
+
+<h2><a name="list"></a>$this->dbutil->list_databases()</h2>
+<p>Returns an array of database names:</p>
+
+<code>
+$dbs = $this->dbutil->list_databases();<br />
+<br />
+foreach ($dbs as $db)<br />
+{<br />
+&nbsp;&nbsp;&nbsp; echo $db;<br />
+}</code>
+
+
+<h2><a name="exists"></a>$this->dbutil->database_exists();</h2>
+
+<p>Sometimes it's helpful to know whether a particular database exists.
+Returns a boolean TRUE/FALSE.  Usage example:</p>
+
+<code>
+if ($this->dbutil->database_exists('database_name'))<br />
+{<br />
+&nbsp;&nbsp; // some code...<br />
+}
+</code>
+
+<p>Note:  Replace <em>database_name</em> with the name of the table you are looking for. This function is case sensitive.</p>
+
+
+
+<h2><a name="opttb"></a>$this->dbutil->optimize_table('table_name');</h2>
+
+<p class="important"><strong>Note:</strong>&nbsp; This features is only available for MySQL/MySQLi databases.</p>
+
+
+<p>Permits you to optimize a table using the table name specified in the first parameter. Returns TRUE/FALSE based on success or failure:</p>
+
+<code>
+if ($this->dbutil->optimize_table('table_name'))<br />
+{<br />
+&nbsp;&nbsp;&nbsp; echo 'Success!';<br />
+}
+</code>
+
+<p><strong>Note:</strong> Not all database platforms support table optimization.</p>
+
+
+<h2><a name="repair"></a>$this->dbutil->repair_table('table_name');</h2>
+
+<p class="important"><strong>Note:</strong>&nbsp; This features is only available for MySQL/MySQLi databases.</p>
+
+
+<p>Permits you to repair a table using the table name specified in the first parameter. Returns TRUE/FALSE based on success or failure:</p>
+
+<code>
+if ($this->dbutil->repair_table('table_name'))<br />
+{<br />
+&nbsp;&nbsp;&nbsp; echo 'Success!';<br />
+}
+</code>
+
+<p><strong>Note:</strong> Not all database platforms support table repairs.</p>
+
+
+<h2><a name="optdb"></a>$this->dbutil->optimize_database();</h2>
+
+<p class="important"><strong>Note:</strong>&nbsp; This features is only available for MySQL/MySQLi databases.</p>
+
+<p>Permits you to optimize the database your DB class is currently connected to. Returns an array containing the DB status messages or FALSE on failure.</p>
+
+<code>
+$result = $this->dbutil->optimize_database();<br />
+<br />
+if ($result !== FALSE)<br />
+{<br />
+&nbsp;&nbsp;&nbsp; print_r($result);<br />
+}
+</code>
+
+<p><strong>Note:</strong> Not all database platforms support table optimization.</p>
+
+
+<h2><a name="csv"></a>$this->dbutil->csv_from_result($db_result)</h2>
+
+<p>Permits you to generate a CSV file from a query result. The first parameter of the function must contain the result object from your query.
+Example:</p>
+
+<code>
+$this->load->dbutil();<br />
+<br />
+$query = $this->db->query("SELECT * FROM mytable");<br />
+<br />
+echo $this->dbutil->csv_from_result($query);
+</code>
+
+<p>The second and third parameters allows you to
+set the delimiter and newline character.  By default tabs are used as the delimiter and "\n" is used as a new line.  Example:</p>
+
+<code>
+$delimiter = ",";<br />
+$newline = "\r\n";<br />
+<br />
+echo $this->dbutil->csv_from_result($query, $delimiter, $newline);
+</code>
+
+<p><strong>Important:</strong>&nbsp; This function will NOT write the CSV file for you.  It simply creates the CSV layout.
+If you need to write the file use the <a href="../helpers/file_helper.html">File Helper</a>.</p>
+
+
+<h2><a name="xml"></a>$this->dbutil->xml_from_result($db_result)</h2>
+
+<p>Permits you to generate an XML file from a query result. The first parameter expects a query result object, the second
+may contain an optional array of config parameters.  Example:</p>
+
+<code>
+$this->load->dbutil();<br />
+<br />
+$query = $this->db->query("SELECT * FROM mytable");<br />
+<br />
+$config = array (<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'root'&nbsp;&nbsp;&nbsp; => 'root',<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'element' => 'element', <br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'newline' => "\n", <br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'tab'&nbsp;&nbsp;&nbsp;&nbsp;=> "\t"<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;);<br />
+<br />
+echo $this->dbutil->xml_from_result($query, $config);
+</code>
+
+<p><strong>Important:</strong>&nbsp; This function will NOT write the XML file for you.  It simply creates the XML layout.
+If you need to write the file use the <a href="../helpers/file_helper.html">File Helper</a>.</p>
+
+
+<h2><a name="backup"></a>$this->dbutil->backup()</h2>
+
+<p>Permits you to backup your full database or individual tables.  The backup data can be compressed in either Zip or Gzip format.</p>
+
+<p class="important"><strong>Note:</strong>&nbsp; This features is only available for MySQL databases.</p>
+
+<p>Note: Due to the limited execution time and memory available to PHP, backing up very large
+databases may not be possible.  If your database is very large you might need to backup directly from your SQL server
+via the command line, or have your server admin do it for you if you do not have root privileges.</p>
+
+<h3>Usage Example</h3>
+
+<code>
+<dfn>// Load the DB utility class</dfn><br />
+$this->load->dbutil();<br /><br />
+
+<dfn>// Backup your entire database and assign it to a variable</dfn><br />
+$backup =& $this->dbutil->backup();
+
+<br /><br />
+<dfn>// Load the file helper and write the file to your server</dfn><br />
+$this->load->helper('file');<br />
+write_file('/path/to/mybackup.gz', $backup);
+
+<br /><br />
+<dfn>// Load the download helper and send the file to your desktop</dfn><br />
+$this->load->helper('download');<br />
+force_download('mybackup.gz', $backup);
+</code>
+
+<h3>Setting Backup Preferences</h3>
+
+<p>Backup preferences are set by submitting an array of values to the first parameter of the backup function. Example:</p>
+
+<code>$prefs = array(<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'tables'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=> array('table1', 'table2'),&nbsp;&nbsp;// Array of tables to backup.<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'ignore'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=> array(),&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// List of tables to omit from the backup<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'format'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=> 'txt',&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// gzip, zip, txt<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'filename'&nbsp;&nbsp;&nbsp;&nbsp;=> 'mybackup.sql',&nbsp;&nbsp;&nbsp;&nbsp;// File name - NEEDED ONLY WITH ZIP FILES<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'add_drop'&nbsp;&nbsp;&nbsp;&nbsp;=> TRUE,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// Whether to add DROP TABLE statements to backup file<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'add_insert'&nbsp;&nbsp;=> TRUE,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// Whether to add INSERT data to backup file<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'newline'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=> "\n"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// Newline character used in backup file<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;);<br />
+<br />
+$this->dbutil->backup($prefs);
+</code>
+
+
+<h3>Description of Backup Preferences</h3>
+
+<table cellpadding="0" cellspacing="1" border="0" style="width:100%" class="tableborder">
+<tr>
+<th>Preference</th>
+<th>Default&nbsp;Value</th>
+<th>Options</th>
+<th>Description</th>
+</tr><tr>
+<td class="td"><strong>tables</strong></td><td class="td">empty array</td><td class="td">None</td><td class="td">An array of tables you want backed up.  If left blank all tables will be exported.</td>
+</tr><tr>
+<td class="td"><strong>ignore</strong></td><td class="td">empty array</td><td class="td">None</td><td class="td">An array of tables you want the backup routine to ignore.</td>
+</tr><tr>
+<td class="td"><strong>format</strong></td><td class="td">gzip</td><td class="td">gzip, zip, txt</td><td class="td">The file format of the export file.</td>
+</tr><tr>
+<td class="td"><strong>filename</strong></td><td class="td">the current date/time</td><td class="td">None</td><td class="td">The name of the backed-up file. The name is needed only if you are using zip compression.</td>
+</tr><tr>
+<td class="td"><strong>add_drop</strong></td><td class="td">TRUE</td><td class="td">TRUE/FALSE</td><td class="td">Whether to include DROP TABLE statements in your SQL export file.</td>
+</tr><tr>
+<td class="td"><strong>add_insert</strong></td><td class="td">TRUE</td><td class="td">TRUE/FALSE</td><td class="td">Whether to include INSERT statements in your SQL export file.</td>
+</tr><tr>
+<td class="td"><strong>newline</strong></td><td class="td">"\n"</td><td class="td">"\n", "\r", "\r\n"</td><td class="td">Type of newline to use in your SQL export file.</td>
+
+</tr>
+</table>
+
+
+</div>
+<!-- END CONTENT -->
+
+
+<div id="footer">
+<p>
+Previous Topic:&nbsp;&nbsp;<a href="forge.html">DB Forge Class</a>
+&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+<a href="#top">Top of Page</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+<a href="../index.html">User Guide Home</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+Next Topic:&nbsp;&nbsp;<a href="../libraries/email.html"> Email Class</a></p>
+<p><a href="http://codeigniter.com">CodeIgniter</a> &nbsp;&middot;&nbsp; Copyright &#169; 2006 - 2011 &nbsp;&middot;&nbsp; <a href="http://ellislab.com/">EllisLab, Inc.</a></p>
+</div>
+
+</body>
+</html>
\ No newline at end of file
diff --git a/user_guide/doc_style/index.html b/user_guide/doc_style/index.html
new file mode 100755 (executable)
index 0000000..f69846f
--- /dev/null
@@ -0,0 +1,87 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head>
+
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+<title>Writing Documentation : CodeIgniter User Guide</title>
+
+<style type='text/css' media='all'>@import url('../userguide.css');</style>
+<link rel='stylesheet' type='text/css' media='all' href='../userguide.css' />
+
+<script type="text/javascript" src="../nav/nav.js"></script>
+<script type="text/javascript" src="../nav/prototype.lite.js"></script>
+<script type="text/javascript" src="../nav/moo.fx.js"></script>
+<script type="text/javascript" src="../nav/user_guide_menu.js"></script>
+
+<meta http-equiv='expires' content='-1' />
+<meta http-equiv= 'pragma' content='no-cache' />
+<meta name='robots' content='all' />
+<meta name='author' content='ExpressionEngine Dev Team' />
+<meta name='description' content='CodeIgniter User Guide' />
+
+</head>
+<body>
+
+<!-- START NAVIGATION -->
+<div id="nav"><div id="nav_inner"><script type="text/javascript">create_menu('../');</script></div></div>
+<div id="nav2"><a name="top"></a><a href="javascript:void(0);" onclick="myHeight.toggle();"><img src="../images/nav_toggle_darker.jpg" width="154" height="43" border="0" title="Toggle Table of Contents" alt="Toggle Table of Contents" /></a></div>
+<div id="masthead">
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td><h1>CodeIgniter User Guide Version 2.0.2</h1></td>
+<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
+</tr>
+</table>
+</div>
+<!-- END NAVIGATION -->
+
+
+<!-- START BREADCRUMB -->
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td id="breadcrumb">
+<a href="http://codeigniter.com/">CodeIgniter Home</a> &nbsp;&#8250;&nbsp;
+<a href="../index.html">User Guide Home</a> &nbsp;&#8250;&nbsp;
+Writing Documentation
+</td>
+<td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="codeigniter.com/user_guide/" />Search User Guide&nbsp; <input type="text" class="input" style="width:200px;" name="q" id="q" size="31" maxlength="255" value="" />&nbsp;<input type="submit" class="submit" name="sa" value="Go" /></form></td>
+</tr>
+</table>
+<!-- END BREADCRUMB -->
+
+<br clear="all" />
+
+
+<!-- START CONTENT -->
+<div id="content">
+
+<h1>Writing Documentation</h1>
+
+<p>To help facilitate a consistent, easy-to-read documentation style for CodeIgniter projects, EllisLab is making the markup and CSS from the CodeIgniter user guide freely available to the community for their use. For your convenience, a template file has been created that includes the primary blocks of markup used with brief samples.</p>
+
+<h2>Files</h2>
+
+<ul>
+       <li><a href="../userguide.css">Stylesheet</a></li>
+       <li><a href="./template.html">Page Template</a></li>
+</ul>
+
+
+</div>
+<!-- END CONTENT -->
+
+
+
+<div id="footer">
+<p>
+Previous Topic:&nbsp;&nbsp;<a href="../general/styleguide.html">PHP Style Guide</a>
+&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+<a href="#top">Top of Page</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+<a href="../index.html">User Guide Home</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+Next Topic:&nbsp;&nbsp;<a href="../libraries/benchmark.html">Benchmarking Class</a>
+</p>
+<p><a href="http://codeigniter.com">CodeIgniter</a> &nbsp;&middot;&nbsp; Copyright &#169; 2006 - 2011 &nbsp;&middot;&nbsp; <a href="http://ellislab.com/">EllisLab, Inc.</a></p>
+</div>
+
+</body>
+</html>
\ No newline at end of file
diff --git a/user_guide/doc_style/template.html b/user_guide/doc_style/template.html
new file mode 100755 (executable)
index 0000000..d59d5e4
--- /dev/null
@@ -0,0 +1,128 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head>
+
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+<title>CodeIgniter Project Documentation Template</title>
+
+<style type='text/css' media='all'>@import url('./userguide.css');</style>
+<link rel='stylesheet' type='text/css' media='all' href='../userguide.css' />
+
+<meta http-equiv='expires' content='-1' />
+<meta http-equiv= 'pragma' content='no-cache' />
+<meta name='robots' content='all' />
+
+</head>
+<body>
+
+<!-- START NAVIGATION -->
+<div id="nav"><div id="nav_inner"></div></div>
+<div id="nav2"><a name="top">&nbsp;</a></div>
+<div id="masthead">
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td><h1>Project Title</h1></td>
+<td id="breadcrumb_right"><a href="#">Right Breadcrumb</a></td>
+</tr>
+</table>
+</div>
+<!-- END NAVIGATION -->
+
+
+<!-- START BREADCRUMB -->
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td id="breadcrumb">
+<a href="http://example.com/">Project Home</a> &nbsp;&#8250;&nbsp;
+<a href="#">User Guide Home</a> &nbsp;&#8250;&nbsp;
+Foo Class
+</td>
+<td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="example.com/user_guide/" />Search Project User Guide&nbsp; <input type="text" class="input" style="width:200px;" name="q" id="q" size="31" maxlength="255" value="" />&nbsp;<input type="submit" class="submit" name="sa" value="Go" /></form></td>
+</tr>
+</table>
+<!-- END BREADCRUMB -->
+
+<br clear="all" />
+
+
+<!-- START CONTENT -->
+<div id="content">
+
+
+<h1>Foo Class</h1>
+
+<p>Brief description of Foo Class.  If it extends a native CodeIgniter class, please link to the class in the CodeIgniter documents here.</p>
+
+<p class="important"><strong>Important:</strong>&nbsp; This is an important note with <kbd>EMPHASIS</kbd>.</p>
+
+<p>Features:</p>
+
+<ul>
+       <li>Foo</li>
+       <li>Bar</li>
+</ul>
+
+<h2>Usage Heading</h2>
+
+<p>Within a text string, <var>highlight variables</var> using <var>&lt;var&gt;&lt;/var&gt;</var> tags, and <dfn>highlight code</dfn> using the <dfn>&lt;dfn&gt;&lt;/dfn&gt;</dfn> tags.</p>
+
+<h3>Sub-heading</h3>
+
+<p>Put code examples within <dfn>&lt;code&gt;&lt;/code&gt;</dfn> tags:</p>
+
+<code>
+       $this->load->library('foo');<br />
+       <br />
+       $this->foo->bar('bat');
+</code>
+
+
+<h2>Table Preferences</h2>
+
+<p>Use tables where appropriate for long lists of preferences.</p>
+
+
+<table cellpadding="0" cellspacing="1" border="0" style="width:100%" class="tableborder">
+<tr>
+       <th>Preference</th>
+       <th>Default&nbsp;Value</th>
+       <th>Options</th>
+       <th>Description</th>
+</tr>
+<tr>
+       <td class="td"><strong>foo</strong></td>
+       <td class="td">Foo</td>
+       <td class="td">None</td>
+       <td class="td">Description of foo.</td>
+</tr>
+<tr>
+       <td class="td"><strong>bar</strong></td>
+       <td class="td">Bar</td>
+       <td class="td">bat, bag, or bak</td>
+       <td class="td">Description of bar.</td>
+</tr>
+</table>
+
+<h2>Foo Function Reference</h2>
+
+<h3>$this->foo->bar()</h3>
+<p>Description</p>
+<code>$this->foo->bar('<var>baz</var>')</code>
+
+</div>
+<!-- END CONTENT -->
+
+
+<div id="footer">
+<p>
+Previous Topic:&nbsp;&nbsp;<a href="#">Previous Class</a>
+&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+<a href="#top">Top of Page</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+<a href="#">User Guide Home</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+Next Topic:&nbsp;&nbsp;<a href="#">Next Class</a>
+</p>
+<p><a href="http://codeigniter.com">CodeIgniter</a> &nbsp;&middot;&nbsp; Copyright &#169; 2006 - 2011 &nbsp;&middot;&nbsp; <a href="http://ellislab.com/">EllisLab, Inc.</a></p>
+</div>
+
+</body>
+</html>
\ No newline at end of file
diff --git a/user_guide/general/alternative_php.html b/user_guide/general/alternative_php.html
new file mode 100755 (executable)
index 0000000..abd5845
--- /dev/null
@@ -0,0 +1,147 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head>
+
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+<title>Alternate PHP Syntax for View Files : CodeIgniter User Guide</title>
+
+<style type='text/css' media='all'>@import url('../userguide.css');</style>
+<link rel='stylesheet' type='text/css' media='all' href='../userguide.css' />
+
+<script type="text/javascript" src="../nav/nav.js"></script>
+<script type="text/javascript" src="../nav/prototype.lite.js"></script>
+<script type="text/javascript" src="../nav/moo.fx.js"></script>
+<script type="text/javascript" src="../nav/user_guide_menu.js"></script>
+
+<meta http-equiv='expires' content='-1' />
+<meta http-equiv= 'pragma' content='no-cache' />
+<meta name='robots' content='all' />
+<meta name='author' content='ExpressionEngine Dev Team' />
+<meta name='description' content='CodeIgniter User Guide' />
+
+</head>
+<body>
+
+<!-- START NAVIGATION -->
+<div id="nav"><div id="nav_inner"><script type="text/javascript">create_menu('../');</script></div></div>
+<div id="nav2"><a name="top"></a><a href="javascript:void(0);" onclick="myHeight.toggle();"><img src="../images/nav_toggle_darker.jpg" width="154" height="43" border="0" title="Toggle Table of Contents" alt="Toggle Table of Contents" /></a></div>
+<div id="masthead">
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td><h1>CodeIgniter User Guide Version 2.0.2</h1></td>
+<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
+</tr>
+</table>
+</div>
+<!-- END NAVIGATION -->
+
+
+<!-- START BREADCRUMB -->
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td id="breadcrumb">
+<a href="http://codeigniter.com/">CodeIgniter Home</a> &nbsp;&#8250;&nbsp;
+<a href="../index.html">User Guide Home</a> &nbsp;&#8250;&nbsp;
+Alternate PHP Syntax
+</td>
+<td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="codeigniter.com/user_guide/" />Search User Guide&nbsp; <input type="text" class="input" style="width:200px;" name="q" id="q" size="31" maxlength="255" value="" />&nbsp;<input type="submit" class="submit" name="sa" value="Go" /></form></td>
+</tr>
+</table>
+<!-- END BREADCRUMB -->
+
+<br clear="all" />
+
+
+<!-- START CONTENT -->
+<div id="content">
+
+<h1>Alternate PHP Syntax for View Files</h1>
+
+<p>If you do not utilize CodeIgniter's <a href="../libraries/parser.html">template engine</a>, you'll be using pure PHP
+in your View files.  To minimize the PHP code in these files, and to make it easier to identify the code blocks it is recommended that you use
+PHPs alternative syntax for control structures and short tag echo statements.  If you are not familiar with this syntax, it allows you to eliminate the braces from your code,
+and eliminate "echo" statements.</p>
+
+<h2>Automatic Short Tag Support</h2>
+
+<p><strong>Note:</strong> If you find that the syntax described in this page does not work on your server it might
+be that "short tags" are disabled in your PHP ini file. CodeIgniter will optionally rewrite short tags on-the-fly,
+allowing you to use that syntax even if your server doesn't support it.  This feature can be enabled in your
+<dfn>config/config.php</dfn> file.</p>
+
+<p class="important">Please note that if you do use this feature, if PHP errors are encountered
+in your <strong>view files</strong>, the error message and line number will not be accurately shown.  Instead, all errors
+will be shown as <kbd>eval()</kbd> errors.</p>
+
+
+<h2>Alternative Echos</h2>
+
+<p>Normally to echo, or print out a variable you would do this:</p>
+
+<code>&lt;?php echo $variable; ?></code>
+
+<p>With the alternative syntax you can instead do it this way:</p>
+
+<code>&lt;?=$variable?></code>
+
+
+
+<h2>Alternative Control Structures</h2>
+
+<p>Controls structures, like <var>if</var>, <var>for</var>, <var>foreach</var>, and <var>while</var> can be
+written in a simplified format as well.  Here is an example using foreach:</p>
+
+<code>
+&lt;ul><br />
+<br />
+<var>&lt;?php foreach ($todo as $item): ?></var><br />
+<br />
+&lt;li><var>&lt;?=$item?></var>&lt;/li><br />
+<br />
+<var>&lt;?php endforeach; ?></var><br />
+<br />
+&lt;/ul></code>
+
+<p>Notice that there are no braces.  Instead, the end brace is replaced with <var>endforeach</var>.
+Each of the control structures listed above has a similar closing syntax:
+<var>endif</var>, <var>endfor</var>, <var>endforeach</var>, and <var>endwhile</var></p>
+
+<p>Also notice that instead of using a semicolon after each structure (except the last one), there is a colon.  This is
+important!</p>
+
+<p>Here is another example, using if/elseif/else.  Notice the colons:</p>
+
+
+<code><var>&lt;?php if ($username == 'sally'): ?></var><br />
+<br />
+&nbsp;&nbsp;&nbsp;&lt;h3>Hi Sally&lt;/h3><br />
+<br />
+<var>&lt;?php elseif ($username == 'joe'): ?></var><br />
+<br />
+&nbsp;&nbsp;&nbsp;&lt;h3>Hi Joe&lt;/h3><br />
+<br />
+<var>&lt;?php else: ?></var><br />
+<br />
+&nbsp;&nbsp;&nbsp;&lt;h3>Hi unknown user&lt;/h3><br />
+<br />
+<var>&lt;?php endif; ?></var></code>
+
+
+
+</div>
+<!-- END CONTENT -->
+
+
+<div id="footer">
+<p>
+Previous Topic:&nbsp;&nbsp;<a href="managing_apps.html">Managing Applications</a>
+&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+<a href="#top">Top of Page</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+<a href="../index.html">User Guide Home</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+Next Topic:&nbsp;&nbsp;<a href="security.html">Security</a>
+</p>
+<p><a href="http://codeigniter.com">CodeIgniter</a> &nbsp;&middot;&nbsp; Copyright &#169; 2006 - 2011 &nbsp;&middot;&nbsp; <a href="http://ellislab.com/">EllisLab, Inc.</a></p>
+</div>
+
+</body>
+</html>
\ No newline at end of file
diff --git a/user_guide/general/ancillary_classes.html b/user_guide/general/ancillary_classes.html
new file mode 100755 (executable)
index 0000000..a7365e7
--- /dev/null
@@ -0,0 +1,117 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head>
+
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+<title>Creating Ancillary Classes : CodeIgniter User Guide</title>
+
+<style type='text/css' media='all'>@import url('../userguide.css');</style>
+<link rel='stylesheet' type='text/css' media='all' href='../userguide.css' />
+
+<script type="text/javascript" src="../nav/nav.js"></script>
+<script type="text/javascript" src="../nav/prototype.lite.js"></script>
+<script type="text/javascript" src="../nav/moo.fx.js"></script>
+<script type="text/javascript" src="../nav/user_guide_menu.js"></script>
+
+<meta http-equiv='expires' content='-1' />
+<meta http-equiv= 'pragma' content='no-cache' />
+<meta name='robots' content='all' />
+<meta name='author' content='ExpressionEngine Dev Team' />
+<meta name='description' content='CodeIgniter User Guide' />
+
+</head>
+<body>
+
+<!-- START NAVIGATION -->
+<div id="nav"><div id="nav_inner"><script type="text/javascript">create_menu('../');</script></div></div>
+<div id="nav2"><a name="top"></a><a href="javascript:void(0);" onclick="myHeight.toggle();"><img src="../images/nav_toggle_darker.jpg" width="154" height="43" border="0" title="Toggle Table of Contents" alt="Toggle Table of Contents" /></a></div>
+<div id="masthead">
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td><h1>CodeIgniter User Guide Version 2.0.2</h1></td>
+<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
+</tr>
+</table>
+</div>
+<!-- END NAVIGATION -->
+
+
+<!-- START BREADCRUMB -->
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td id="breadcrumb">
+<a href="http://codeigniter.com/">CodeIgniter Home</a> &nbsp;&#8250;&nbsp;
+<a href="../index.html">User Guide Home</a> &nbsp;&#8250;&nbsp;
+Creating Ancillary Classes
+</td>
+<td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="codeigniter.com/user_guide/" />Search User Guide&nbsp; <input type="text" class="input" style="width:200px;" name="q" id="q" size="31" maxlength="255" value="" />&nbsp;<input type="submit" class="submit" name="sa" value="Go" /></form></td>
+</tr>
+</table>
+<!-- END BREADCRUMB -->
+
+<br clear="all" />
+
+
+<!-- START CONTENT -->
+<div id="content">
+
+<h1>Creating Ancillary Classes</h1>
+
+<p>In some cases you may want to develop classes that exist apart from your controllers but have the ability to
+utilize all of CodeIgniter's resources. This is easily possible as you'll see.</p>
+
+<h2>get_instance()</h2>
+
+
+<p><strong>Any class that you instantiate within your controller functions can access CodeIgniter's native resources</strong> simply by using the <kbd>get_instance()</kbd> function.
+This function returns the main CodeIgniter object.</p>
+
+<p>Normally, to call any of the available CodeIgniter functions requires you to use the <kbd>$this</kbd> construct:</p>
+
+<code>
+<strong>$this</strong>->load->helper('url');<br />
+<strong>$this</strong>->load->library('session');<br />
+<strong>$this</strong>->config->item('base_url');<br />
+etc.
+</code>
+
+<p><kbd>$this</kbd>, however, only works within your controllers, your models, or your views.
+If you would like to use CodeIgniter's classes from within your own custom classes you can do so as follows:</p>
+
+
+<p>First, assign the CodeIgniter object to a variable:</p>
+
+<code>$CI =& get_instance();</code>
+
+<p>Once you've assigned the object to a variable, you'll use that variable <em>instead</em> of <kbd>$this</kbd>:</p>
+
+<code>
+$CI =& get_instance();<br /><br />
+$CI->load->helper('url');<br />
+$CI->load->library('session');<br />
+$CI->config->item('base_url');<br />
+etc.
+</code>
+
+<p class="important"><strong>Note:</strong> You'll notice that the above get_instance() function is being passed by reference:
+<br /><br />
+<var>$CI =& get_instance();</var>
+<br /><br />
+This is very important. Assigning by reference allows you to use the original CodeIgniter object rather than creating a copy of it.</p>
+</div>
+<!-- END CONTENT -->
+
+
+<div id="footer">
+<p>
+Previous Topic:&nbsp;&nbsp;<a href="creating_libraries.html">Creating Core Libraries</a>
+&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+<a href="#top">Top of Page</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+<a href="../index.html">User Guide Home</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+Next Topic:&nbsp;&nbsp;<a href="autoloader.html">Auto-loading Resources</a>
+</p>
+<p><a href="http://codeigniter.com">CodeIgniter</a> &nbsp;&middot;&nbsp; Copyright &#169; 2006 - 2011 &nbsp;&middot;&nbsp; <a href="http://ellislab.com/">EllisLab, Inc.</a></p>
+</div>
+
+</body>
+</html>
\ No newline at end of file
diff --git a/user_guide/general/autoloader.html b/user_guide/general/autoloader.html
new file mode 100755 (executable)
index 0000000..fae0b5f
--- /dev/null
@@ -0,0 +1,100 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head>
+
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+<title>Auto-loading Resources : CodeIgniter User Guide</title>
+
+<style type='text/css' media='all'>@import url('../userguide.css');</style>
+<link rel='stylesheet' type='text/css' media='all' href='../userguide.css' />
+
+<script type="text/javascript" src="../nav/nav.js"></script>
+<script type="text/javascript" src="../nav/prototype.lite.js"></script>
+<script type="text/javascript" src="../nav/moo.fx.js"></script>
+<script type="text/javascript" src="../nav/user_guide_menu.js"></script>
+
+<meta http-equiv='expires' content='-1' />
+<meta http-equiv= 'pragma' content='no-cache' />
+<meta name='robots' content='all' />
+<meta name='author' content='ExpressionEngine Dev Team' />
+<meta name='description' content='CodeIgniter User Guide' />
+
+</head>
+<body>
+
+<!-- START NAVIGATION -->
+<div id="nav"><div id="nav_inner"><script type="text/javascript">create_menu('../');</script></div></div>
+<div id="nav2"><a name="top"></a><a href="javascript:void(0);" onclick="myHeight.toggle();"><img src="../images/nav_toggle_darker.jpg" width="154" height="43" border="0" title="Toggle Table of Contents" alt="Toggle Table of Contents" /></a></div>
+<div id="masthead">
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td><h1>CodeIgniter User Guide Version 2.0.2</h1></td>
+<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
+</tr>
+</table>
+</div>
+<!-- END NAVIGATION -->
+
+
+<!-- START BREADCRUMB -->
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td id="breadcrumb">
+<a href="http://codeigniter.com/">CodeIgniter Home</a> &nbsp;&#8250;&nbsp;
+<a href="../index.html">User Guide Home</a> &nbsp;&#8250;&nbsp;
+Auto-loading Resources
+</td>
+<td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="codeigniter.com/user_guide/" />Search User Guide&nbsp; <input type="text" class="input" style="width:200px;" name="q" id="q" size="31" maxlength="255" value="" />&nbsp;<input type="submit" class="submit" name="sa" value="Go" /></form></td>
+</tr>
+</table>
+<!-- END BREADCRUMB -->
+
+<br clear="all" />
+
+
+<!-- START CONTENT -->
+<div id="content">
+
+<h1>Auto-loading Resources</h1>
+
+<p>CodeIgniter comes with an "Auto-load" feature that permits libraries, helpers, and models to be initialized
+automatically every time the system runs. If you need certain resources globally throughout your application you should
+consider auto-loading them for convenience.</p>
+
+<p>The following items can be loaded automatically:</p>
+
+<ul>
+<li>Core classes found in the "libraries" folder</li>
+<li>Helper files found in the "helpers" folder</li>
+<li>Custom config files found in the "config" folder</li>
+<li>Language files found in the "system/language" folder </li>
+<li>Models found in the &quot;models&quot; folder</li>
+</ul>
+
+<p>To autoload resources, open the <var>application/config/autoload.php</var> file and add the item you want
+loaded to the <samp>autoload</samp> array. You'll find instructions in that file corresponding to each
+type of item.</p>
+
+<p class="important"><strong>Note:</strong>  Do not include the file extension (.php) when adding items to the autoload array.</p>
+
+
+
+
+
+
+</div>
+<!-- END CONTENT -->
+
+
+<div id="footer">
+<p>
+Previous Topic:&nbsp;&nbsp;<a href="hooks.html">Hooks - Extending the Core</a>
+&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+<a href="#top">Top of Page</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+<a href="../index.html">User Guide Home</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+Next Topic:&nbsp;&nbsp;<a href="common_functions.html">Common Functions</a></p>
+<p><a href="http://codeigniter.com">CodeIgniter</a> &nbsp;&middot;&nbsp; Copyright &#169; 2006 - 2011 &nbsp;&middot;&nbsp; <a href="http://ellislab.com/">EllisLab, Inc.</a></p>
+</div>
+
+</body>
+</html>
\ No newline at end of file
diff --git a/user_guide/general/caching.html b/user_guide/general/caching.html
new file mode 100755 (executable)
index 0000000..c77f9a1
--- /dev/null
@@ -0,0 +1,115 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head>
+
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+<title>Web Page Caching : CodeIgniter User Guide</title>
+
+<style type='text/css' media='all'>@import url('../userguide.css');</style>
+<link rel='stylesheet' type='text/css' media='all' href='../userguide.css' />
+
+<script type="text/javascript" src="../nav/nav.js"></script>
+<script type="text/javascript" src="../nav/prototype.lite.js"></script>
+<script type="text/javascript" src="../nav/moo.fx.js"></script>
+<script type="text/javascript" src="../nav/user_guide_menu.js"></script>
+
+<meta http-equiv='expires' content='-1' />
+<meta http-equiv= 'pragma' content='no-cache' />
+<meta name='robots' content='all' />
+<meta name='author' content='ExpressionEngine Dev Team' />
+<meta name='description' content='CodeIgniter User Guide' />
+
+</head>
+<body>
+
+<!-- START NAVIGATION -->
+<div id="nav"><div id="nav_inner"><script type="text/javascript">create_menu('../');</script></div></div>
+<div id="nav2"><a name="top"></a><a href="javascript:void(0);" onclick="myHeight.toggle();"><img src="../images/nav_toggle_darker.jpg" width="154" height="43" border="0" title="Toggle Table of Contents" alt="Toggle Table of Contents" /></a></div>
+<div id="masthead">
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td><h1>CodeIgniter User Guide Version 2.0.2</h1></td>
+<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
+</tr>
+</table>
+</div>
+<!-- END NAVIGATION -->
+
+
+<!-- START BREADCRUMB -->
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td id="breadcrumb">
+<a href="http://codeigniter.com/">CodeIgniter Home</a> &nbsp;&#8250;&nbsp;
+<a href="../index.html">User Guide Home</a> &nbsp;&#8250;&nbsp;
+Page Caching
+</td>
+<td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="codeigniter.com/user_guide/" />Search User Guide&nbsp; <input type="text" class="input" style="width:200px;" name="q" id="q" size="31" maxlength="255" value="" />&nbsp;<input type="submit" class="submit" name="sa" value="Go" /></form></td>
+</tr>
+</table>
+<!-- END BREADCRUMB -->
+
+<br clear="all" />
+
+
+<!-- START CONTENT -->
+<div id="content">
+
+
+<h1>Web Page Caching</h1>
+
+<p>CodeIgniter lets you cache your pages in order to achieve maximum performance.</p>
+
+<p>Although CodeIgniter is quite fast, the amount of dynamic information you display in your pages will correlate directly to the
+server resources, memory, and processing cycles utilized, which affect your page load speeds.
+By caching your pages, since they are saved in their fully rendered state, you can achieve performance that nears that of static web pages.</p>
+
+
+<h2>How Does Caching Work?</h2>
+
+<p>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 <dfn>application/cache</dfn> 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.</p>
+
+<p>Note: The Benchmark tag is not cached so you can still view your page load speed when caching is enabled.</p>
+
+<h2>Enabling Caching</h2>
+
+<p>To enable caching, put the following tag in any of your controller functions:</p>
+
+<code>$this->output->cache(<var>n</var>);</code>
+
+<p>Where <var>n</var> is the number of <strong>minutes</strong> you wish the page to remain cached between refreshes.</p>
+
+<p>The above tag can go anywhere within a function. It is not affected by the order that it appears, so place it wherever it seems
+most logical to you. Once the tag is in place, your pages will begin being cached.</p>
+
+<p class="important"><strong>Warning:</strong> Because of the way CodeIgniter stores content for output, caching will only work if you are generating display for your controller with a <a href="./views.html">view</a>.</p>
+<p class="important"><strong>Note:</strong> Before the cache files can be written you must set the file permissions on your
+<dfn>application/cache</dfn> folder such that it is writable.</p>
+
+<h2>Deleting Caches</h2>
+
+<p>If you no longer wish to cache a file you can remove the caching tag and it will no longer be refreshed when it expires.  Note:
+Removing the tag will not delete the cache immediately.  It will have to expire normally.  If you need to remove it earlier you
+will need to manually delete it from your cache folder.</p>
+
+
+
+</div>
+<!-- END CONTENT -->
+
+
+<div id="footer">
+<p>
+Previous Topic:&nbsp;&nbsp;<a href="errors.html">Error Handling</a>
+&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+<a href="#top">Top of Page</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+<a href="../index.html">User Guide Home</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+Next Topic:&nbsp;&nbsp;<a href="profiling.html">Profiling Your Application</a>
+</p>
+<p><a href="http://codeigniter.com">CodeIgniter</a> &nbsp;&middot;&nbsp; Copyright &#169; 2006 - 2011 &nbsp;&middot;&nbsp; <a href="http://ellislab.com/">EllisLab, Inc.</a></p>
+</div>
+
+</body>
+</html>
\ No newline at end of file
diff --git a/user_guide/general/cli.html b/user_guide/general/cli.html
new file mode 100755 (executable)
index 0000000..962954b
--- /dev/null
@@ -0,0 +1,150 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head>
+
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+<title>Running via the CLI : CodeIgniter User Guide</title>
+
+<style type='text/css' media='all'>@import url('../userguide.css');</style>
+<link rel='stylesheet' type='text/css' media='all' href='../userguide.css' />
+
+<script type="text/javascript" src="../nav/nav.js"></script>
+<script type="text/javascript" src="../nav/prototype.lite.js"></script>
+<script type="text/javascript" src="../nav/moo.fx.js"></script>
+<script type="text/javascript" src="../nav/user_guide_menu.js"></script>
+
+<meta http-equiv='expires' content='-1' />
+<meta http-equiv= 'pragma' content='no-cache' />
+<meta name='robots' content='all' />
+<meta name='author' content='ExpressionEngine Dev Team' />
+<meta name='description' content='CodeIgniter User Guide' />
+
+</head>
+<body>
+
+<!-- START NAVIGATION -->
+<div id="nav"><div id="nav_inner"><script type="text/javascript">create_menu('../');</script></div></div>
+<div id="nav2"><a name="top"></a><a href="javascript:void(0);" onclick="myHeight.toggle();"><img src="../images/nav_toggle_darker.jpg" width="154" height="43" border="0" title="Toggle Table of Contents" alt="Toggle Table of Contents" /></a></div>
+<div id="masthead">
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td><h1>CodeIgniter User Guide Version 2.0.2</h1></td>
+<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
+</tr>
+</table>
+</div>
+<!-- END NAVIGATION -->
+
+
+<!-- START BREADCRUMB -->
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td id="breadcrumb">
+<a href="http://codeigniter.com/">CodeIgniter Home</a> &nbsp;&#8250;&nbsp;
+<a href="../index.html">User Guide Home</a> &nbsp;&#8250;&nbsp;
+Running via the CLI
+</td>
+<td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="codeigniter.com/user_guide/" />Search User Guide&nbsp; <input type="text" class="input" style="width:200px;" name="q" id="q" size="31" maxlength="255" value="" />&nbsp;<input type="submit" class="submit" name="sa" value="Go" /></form></td>
+</tr>
+</table>
+<!-- END BREADCRUMB -->
+
+<br clear="all" />
+
+
+<!-- START CONTENT -->
+<div id="content">
+
+<h1>Running via the CLI</h1>
+
+<p>
+       As well as calling an applications <a href="./controllers.html">Controllers</a> via the URL in a browser they can also be loaded via the command-line interface (CLI).
+</p>
+
+
+<ul>
+<li><a href="#what">What is the CLI?</a></li>
+<li><a href="#why">Why use this method?</a></li>
+<li><a href="#how">How does it work?</a></li>
+</ul>
+
+
+<a name="what"></a>
+<h2>What is the CLI?</h2>
+
+<p><dfn>The command-line interface is a text-based method of interacting with computers that looks like what most people remember as DOS.</dfn></p>
+
+<a name="why"></a>
+
+<h2>Why run via the command-line?</h2>
+
+<p>
+       There are many reasons for running CodeIgniter from the command-line, but they are not always obvious.</p>
+
+<ul>
+       <li>Run your cron-jobs without needing to use wget or curl</li>
+       <li>Make your cron-jobs inaccessible from being loaded in the URL by checking for <kbd>IS_CLI</kbd></li>
+       <li>Make interactive "tasks" that can do things like set permissions, prune cache folders, run backups, etc.</li>
+       <li>Integrate with other applications in other languages. For example, a random C++ script could call one command and run code in your models!</li>
+</ul>
+
+<a name="how"></a>
+<h2>Let's try it:&nbsp; Hello World!</h2>
+
+<p>Let's create a simple controller so you can see it in action. Using your text editor, create a file called <dfn>tools.php</dfn>, and put the following code in it:</p>
+
+<textarea class="textarea" style="width:100%" cols="50" rows="10">
+&lt;?php
+class Tools extends CI_Controller {
+
+       public function message($to = 'World')
+       {
+               echo "Hello {$to}!".PHP_EOL;
+       }
+}
+?&gt;
+</textarea>
+
+<p>Then save the file to your <dfn>application/controllers/</dfn> folder.</p>
+
+<p>Now normally you would visit the your site using a URL similar to this:</p>
+
+<code>example.com/index.php/<var>tools</var>/<var>message</var>/<var>to</var></code>
+
+<p>Instead, we are going to open Terminal in Mac/Lunix or go to Run > "cmd" in Windows and navigate to our CodeIgniter project.</p>
+
+<blockquote>
+       $ cd /path/to/project;<br/>
+       $ php index.php tools message
+</blockquote>
+
+<p>If you did it right, you should see <samp>Hello World!</samp>.</p>
+
+<blockquote>
+       $ php index.php tools message "John Smith"
+</blockquote>
+
+<p>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: <samp>Hello John Smith!</samp>.</p>
+
+<h2>That's it!</h2>
+
+<p>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.</p>
+
+
+
+</div>
+<!-- END CONTENT -->
+
+
+<div id="footer">
+<p>
+Previous Topic:&nbsp;&nbsp;<a href="urls.html">CodeIgniter URLs</a>
+&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+<a href="#top">Top of Page</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+<a href="../index.html">User Guide Home</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+Next Topic:&nbsp;&nbsp;<a href="reserved_names.html">Reserved Names</a></p>
+<p><a href="http://codeigniter.com">CodeIgniter</a> &nbsp;&middot;&nbsp; Copyright &#169; 2006 - 2011 &nbsp;&middot;&nbsp; <a href="http://ellislab.com/">EllisLab, Inc.</a></p>
+</div>
+
+</body>
+</html>
\ No newline at end of file
diff --git a/user_guide/general/common_functions.html b/user_guide/general/common_functions.html
new file mode 100755 (executable)
index 0000000..bfac326
--- /dev/null
@@ -0,0 +1,125 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head>
+
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+<title>Common Functions : CodeIgniter User Guide</title>
+
+<style type='text/css' media='all'>@import url('../userguide.css');</style>
+<link rel='stylesheet' type='text/css' media='all' href='../userguide.css' />
+
+<script type="text/javascript" src="../nav/nav.js"></script>
+<script type="text/javascript" src="../nav/prototype.lite.js"></script>
+<script type="text/javascript" src="../nav/moo.fx.js"></script>
+<script type="text/javascript" src="../nav/user_guide_menu.js"></script>
+
+<meta http-equiv='expires' content='-1' />
+<meta http-equiv= 'pragma' content='no-cache' />
+<meta name='robots' content='all' />
+<meta name='author' content='ExpressionEngine Dev Team' />
+<meta name='description' content='CodeIgniter User Guide' />
+
+</head>
+<body>
+
+<!-- START NAVIGATION -->
+<div id="nav"><div id="nav_inner"><script type="text/javascript">create_menu('../');</script></div></div>
+<div id="nav2"><a name="top"></a><a href="javascript:void(0);" onclick="myHeight.toggle();"><img src="../images/nav_toggle_darker.jpg" width="154" height="43" border="0" title="Toggle Table of Contents" alt="Toggle Table of Contents" /></a></div>
+<div id="masthead">
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td><h1>CodeIgniter User Guide Version 2.0.2</h1></td>
+<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
+</tr>
+</table>
+</div>
+<!-- END NAVIGATION -->
+
+
+<!-- START BREADCRUMB -->
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td id="breadcrumb">
+<a href="http://codeigniter.com/">CodeIgniter Home</a> &nbsp;&#8250;&nbsp;
+<a href="../index.html">User Guide Home</a> &nbsp;&#8250;&nbsp;
+Auto-loading Resources
+</td>
+<td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="codeigniter.com/user_guide/" />Search User Guide&nbsp; <input type="text" class="input" style="width:200px;" name="q" id="q" size="31" maxlength="255" value="" />&nbsp;<input type="submit" class="submit" name="sa" value="Go" /></form></td>
+</tr>
+</table>
+<!-- END BREADCRUMB -->
+
+<br clear="all" />
+
+
+<!-- START CONTENT -->
+<div id="content">
+
+<h1>Common Functions</h1>
+
+<p>CodeIgniter uses a few functions for its operation that are globally defined, and are available to you at any point. These do not require loading any libraries or helpers.</p>
+
+<h2>is_php('<var>version_number</var>')</h2>
+
+<p>is_php() determines of the PHP version being used is greater than the supplied <var>version_number</var>.</p>
+
+<code>if (is_php('5.3.0'))<br />
+{<br />
+&nbsp;&nbsp;&nbsp;&nbsp;$str = quoted_printable_encode($str);<br />
+}</code>
+
+<p>Returns boolean <kbd>TRUE</kbd> if the installed version of PHP is equal to or greater than the supplied version number.  Returns  <kbd>FALSE</kbd> if the installed version of PHP is lower than the supplied version number.</p>
+
+
+<h2>is_really_writable('<var>path/to/file</var>')</h2>
+
+<p>is_writable() returns TRUE on Windows servers when you really can't write to the file as the OS reports to PHP as FALSE only if the read-only attribute is marked. This function determines if a file is actually writable by attempting to write to it first. Generally only recommended on platforms where this information may be unreliable.</p>
+
+<code>if (is_really_writable('file.txt'))<br />
+{<br />
+&nbsp;&nbsp;&nbsp;&nbsp;echo &quot;I could write to this if I wanted to&quot;;<br />
+}<br />
+else<br />
+{<br />
+&nbsp;&nbsp;&nbsp;&nbsp;echo &quot;File is not writable&quot;;<br />
+}</code>
+
+<h2>config_item('<var>item_key</var>')</h2>
+<p>The <a href="../libraries/config.html">Config library</a> is the preferred way of accessing configuration information, however config_item() can be used to retrieve single keys. See Config library documentation for more information.</p>
+
+<h2>show_error('<var>message</var>'), show_404('<var>page</var>'), log_message('<var>level</var>', '<samp>message</samp>')</h2>
+<p>These are each outlined on the <a href="errors.html">Error Handling</a> page.</p>
+
+<h2>set_status_header(<var>code</var>, '<var>text</var>');</h2>
+
+<p>Permits you to manually set a server status header.  Example:</p>
+
+<code>set_status_header(401);<br />
+// Sets the header as:  Unauthorized</code>
+
+<p><a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html">See here</a> for a full list of headers.</p>
+
+
+<h2>remove_invisible_characters(<var>$str</var>)</h2>
+<p>This function prevents inserting null characters between ascii characters, like Java\0script.</p>
+
+
+
+</div>
+
+
+<!-- END CONTENT -->
+
+
+<div id="footer">
+<p>
+Previous Topic:&nbsp;&nbsp;<a href="autoloader.html">Auto-loading Resources</a><a href="hooks.html"></a>
+&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+<a href="#top">Top of Page</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+<a href="../index.html">User Guide Home</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+Next Topic:&nbsp;&nbsp;<a href="routing.html">URI Routing</a></p>
+<p><a href="http://codeigniter.com">CodeIgniter</a> &nbsp;&middot;&nbsp; Copyright &#169; 2006 - 2011 &nbsp;&middot;&nbsp; <a href="http://ellislab.com/">EllisLab, Inc.</a></p>
+</div>
+
+</body>
+</html>
\ No newline at end of file
diff --git a/user_guide/general/controllers.html b/user_guide/general/controllers.html
new file mode 100755 (executable)
index 0000000..c909164
--- /dev/null
@@ -0,0 +1,388 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head>
+
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+<title>Controllers : CodeIgniter User Guide</title>
+
+<style type='text/css' media='all'>@import url('../userguide.css');</style>
+<link rel='stylesheet' type='text/css' media='all' href='../userguide.css' />
+
+<script type="text/javascript" src="../nav/nav.js"></script>
+<script type="text/javascript" src="../nav/prototype.lite.js"></script>
+<script type="text/javascript" src="../nav/moo.fx.js"></script>
+<script type="text/javascript" src="../nav/user_guide_menu.js"></script>
+
+<meta http-equiv='expires' content='-1' />
+<meta http-equiv= 'pragma' content='no-cache' />
+<meta name='robots' content='all' />
+<meta name='author' content='ExpressionEngine Dev Team' />
+<meta name='description' content='CodeIgniter User Guide' />
+
+</head>
+<body>
+
+<!-- START NAVIGATION -->
+<div id="nav"><div id="nav_inner"><script type="text/javascript">create_menu('../');</script></div></div>
+<div id="nav2"><a name="top"></a><a href="javascript:void(0);" onclick="myHeight.toggle();"><img src="../images/nav_toggle_darker.jpg" width="154" height="43" border="0" title="Toggle Table of Contents" alt="Toggle Table of Contents" /></a></div>
+<div id="masthead">
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td><h1>CodeIgniter User Guide Version 2.0.2</h1></td>
+<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
+</tr>
+</table>
+</div>
+<!-- END NAVIGATION -->
+
+
+<!-- START BREADCRUMB -->
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td id="breadcrumb">
+<a href="http://codeigniter.com/">CodeIgniter Home</a> &nbsp;&#8250;&nbsp;
+<a href="../index.html">User Guide Home</a> &nbsp;&#8250;&nbsp;
+Controllers
+</td>
+<td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="codeigniter.com/user_guide/" />Search User Guide&nbsp; <input type="text" class="input" style="width:200px;" name="q" id="q" size="31" maxlength="255" value="" />&nbsp;<input type="submit" class="submit" name="sa" value="Go" /></form></td>
+</tr>
+</table>
+<!-- END BREADCRUMB -->
+
+<br clear="all" />
+
+
+<!-- START CONTENT -->
+<div id="content">
+
+<h1>Controllers</h1>
+
+<p>Controllers are the heart of your application, as they determine how HTTP requests should be handled.</p>
+
+
+<ul>
+<li><a href="#what">What is a Controller?</a></li>
+<li><a href="#hello">Hello World</a></li>
+<li><a href="#functions">Functions</a></li>
+<li><a href="#passinguri">Passing URI Segments to Your Functions</a></li>
+<li><a href="#default">Defining a Default Controller</a></li>
+<li><a href="#remapping">Remapping Function Calls</a></li>
+<li><a href="#output">Controlling Output Data</a></li>
+<li><a href="#private">Private Functions</a></li>
+<li><a href="#subfolders">Organizing Controllers into Sub-folders</a></li>
+<li><a href="#constructors">Class Constructors</a></li>
+<li><a href="#reserved">Reserved Function Names</a></li>
+</ul>
+
+
+<a name="what"></a>
+<h2>What is a Controller?</h2>
+
+<p><dfn>A Controller is simply a class file that is named in a way that can be associated with a URI.</dfn></p>
+
+<p>Consider this URI:</p>
+
+<code>example.com/index.php/<var>blog</var>/</code>
+
+<p>In the above example, CodeIgniter would attempt to find a controller named <dfn>blog.php</dfn> and load it.</p>
+
+<p><strong>When a controller's name matches the first segment of a URI, it will be loaded.</strong></p>
+
+<a name="hello"></a>
+<h2>Let's try it:&nbsp; Hello World!</h2>
+
+<p>Let's create a simple controller so you can see it in action.  Using your text editor, create a file called <dfn>blog.php</dfn>, and put the following code in it:</p>
+
+
+<textarea class="textarea" style="width:100%" cols="50" rows="10">
+&lt;?php
+class Blog extends CI_Controller {
+
+       public function index()
+       {
+               echo 'Hello World!';
+       }
+}
+?&gt;
+</textarea>
+
+
+
+<p>Then save the file to your <dfn>application/controllers/</dfn> folder.</p>
+
+<p>Now visit the your site using a URL similar to this:</p>
+
+<code>example.com/index.php/<var>blog</var>/</code>
+
+<p>If you did it right, you should see <samp>Hello World!</samp>.</p>
+
+<p>Note: Class names must start with an uppercase letter.  In other words, this is valid:</p>
+
+<code>&lt;?php<br />
+class <var>Blog</var> extends CI_Controller {<br />
+<br />
+}<br />
+?&gt;</code>
+
+<p>This is <strong>not</strong> valid:</p>
+
+<code>&lt;?php<br />
+class <var>blog</var> extends CI_Controller {<br />
+<br />
+}<br />
+?&gt;</code>
+
+<p>Also, always make sure your controller <dfn>extends</dfn> the parent controller class so that it can inherit all its functions.</p>
+
+
+
+<a name="functions"></a>
+<h2>Functions</h2>
+
+<p>In the above example the function name is <dfn>index()</dfn>.  The "index" function is always loaded by default if the
+<strong>second segment</strong> of the URI is empty.  Another way to show your "Hello World" message would be this:</p>
+
+<code>example.com/index.php/<var>blog</var>/<samp>index</samp>/</code>
+
+<p><strong>The second segment of the URI determines which function in the controller gets called.</strong></p>
+
+<p>Let's try it.  Add a new function to your controller:</p>
+
+
+<textarea class="textarea" style="width:100%" cols="50" rows="15">
+&lt;?php
+class Blog extends CI_Controller {
+
+       public function index()
+       {
+               echo 'Hello World!';
+       }
+
+       public function comments()
+       {
+               echo 'Look at this!';
+       }
+}
+?&gt;
+</textarea>
+
+<p>Now load the following URL to see the <dfn>comment</dfn> function:</p>
+
+<code>example.com/index.php/<var>blog</var>/<samp>comments</samp>/</code>
+
+<p>You should see your new message.</p>
+
+<a name="passinguri"></a>
+<h2>Passing URI Segments to your Functions</h2>
+
+<p>If your URI contains more then two segments they will be passed to your function as parameters.</p>
+
+<p>For example, lets say you have a URI like this:</p>
+
+<code>example.com/index.php/<var>products</var>/<samp>shoes</samp>/<kbd>sandals</kbd>/<dfn>123</dfn></code>
+
+<p>Your function will be passed URI segments 3 and 4 ("sandals" and "123"):</p>
+
+<code>
+&lt;?php<br />
+class Products extends CI_Controller {<br />
+<br />
+&nbsp;&nbsp;&nbsp;&nbsp;public function shoes($sandals, $id)<br />
+&nbsp;&nbsp;&nbsp;&nbsp;{<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;echo $sandals;<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;echo $id;<br />
+&nbsp;&nbsp;&nbsp;&nbsp;}<br />
+}<br />
+?&gt;
+</code>
+
+<p class="important"><strong>Important:</strong>&nbsp; If you are using the <a href="routing.html">URI Routing</a> feature, the segments
+passed to your function will be the re-routed ones.</p>
+
+
+<a name="default"></a>
+<h2>Defining a Default Controller</h2>
+
+<p>CodeIgniter can be told to load a default controller when a URI is not present,
+as will be the case when only your site root URL is requested.  To specify a default controller, open
+your <dfn>application/config/routes.php</dfn> file and set this variable:</p>
+
+<code>$route['default_controller'] = '<var>Blog</var>';</code>
+
+<p>Where <var>Blog</var> is the name of the controller class you want used. If you now load your main index.php file without
+specifying any URI segments you'll see your Hello World message by default.</p>
+
+
+
+<a name="remapping"></a>
+<h2>Remapping Function Calls</h2>
+
+<p>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 <kbd>_remap()</kbd> function:</p>
+
+<code>public function _remap()<br />
+{<br />
+&nbsp;&nbsp;&nbsp;&nbsp;// Some code here...<br />
+}</code>
+
+<p class="important"><strong>Important:</strong>&nbsp; If your controller contains a function named <kbd>_remap()</kbd>, it will <strong>always</strong>
+get called regardless of what your URI contains.  It overrides the normal behavior in which the URI determines which function is called,
+allowing you to define your own function routing rules.</p>
+
+<p>The overridden function call (typically the second segment of the URI) will be passed as a parameter to the <kbd>_remap()</kbd> function:</p>
+
+<code>public function _remap(<var>$method</var>)<br />
+{<br />
+&nbsp;&nbsp;&nbsp;&nbsp;if ($method == 'some_method')<br />
+&nbsp;&nbsp;&nbsp;&nbsp;{<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$this->$method();<br />
+&nbsp;&nbsp;&nbsp;&nbsp;}<br />
+&nbsp;&nbsp;&nbsp;&nbsp;else<br />
+&nbsp;&nbsp;&nbsp;&nbsp;{<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$this->default_method();<br />
+&nbsp;&nbsp;&nbsp;&nbsp;}<br />
+}</code>
+
+<p>Any extra segments after the method name are passed into <kbd>_remap()</kbd> as an optional second parameter. This array can be used in combination with PHP's <a href="http://php.net/call_user_func_array">call_user_func_array</a> to emulate CodeIgniter's default behavior.</p>
+
+<code>public function _remap($method, $params = array())<br />
+{<br />
+&nbsp;&nbsp;&nbsp;&nbsp;$method = 'process_'.$method;<br />
+&nbsp;&nbsp;&nbsp;&nbsp;if (method_exists($this, $method))<br />
+&nbsp;&nbsp;&nbsp;&nbsp;{<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return call_user_func_array(array($this, $method), $params);<br />
+&nbsp;&nbsp;&nbsp;&nbsp;}<br />
+&nbsp;&nbsp;&nbsp;&nbsp;show_404();<br />
+}</code>
+
+
+<a name="output"></a>
+<h2>Processing Output</h2>
+
+<p>CodeIgniter has an output class that takes care of sending your final rendered data to the web browser automatically.  More information on this can be found in the
+<a href="views.html">Views</a> and <a href="../libraries/output.html">Output class</a> pages.  In some cases, however, you might want to
+post-process the finalized data in some way and send it to the browser yourself.  CodeIgniter permits you to
+add a function named <dfn>_output()</dfn> to your controller that will receive the finalized output data.</p>
+
+<p><strong>Important:</strong>&nbsp; If your controller contains a function named <kbd>_output()</kbd>, it will <strong>always</strong>
+be called by the output class instead of echoing the finalized data directly. The first parameter of the function will contain the finalized output.</p>
+
+<p>Here is an example:</p>
+
+<code>
+public function _output($output)<br />
+{<br />
+&nbsp;&nbsp;&nbsp;&nbsp;echo $output;<br />
+}</code>
+
+<p class="important">Please note that your <dfn>_output()</dfn> function will receive the data in its finalized state.  Benchmark and memory usage data will be rendered,
+cache files written (if you have caching enabled), and headers will be sent (if you use that <a href="../libraries/output.html">feature</a>)
+before it is handed off to the _output() function.<br />
+<br />
+To have your controller's output cached properly, its <dfn>_output()</dfn> method can use:<br />
+
+<code>if ($this-&gt;output-&gt;cache_expiration &gt; 0)<br />
+{<br />
+&nbsp;&nbsp;&nbsp;&nbsp;$this-&gt;output-&gt;_write_cache($output);<br />
+}</code>
+
+If you are using this feature the page execution timer and memory usage stats might not be perfectly accurate
+since they will not take into acccount any further processing you do.  For an alternate way to control output <em>before</em> any of the final processing is done, please see
+the available methods in the <a href="../libraries/output.html">Output Class</a>.</p>
+
+<a name="private"></a>
+<h2>Private Functions</h2>
+
+
+<p>In some cases you may want certain functions hidden from public access.  To make a function private, simply add an
+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:</p>
+
+<code>
+private function _utility()<br />
+{<br />
+&nbsp;&nbsp;// some code<br />
+}</code>
+
+<p>Trying to access it via the URL, like this, will not work:</p>
+
+<code>example.com/index.php/<var>blog</var>/<samp>_utility</samp>/</code>
+
+
+
+<a name="subfolders"></a>
+<h2>Organizing Your Controllers into Sub-folders</h2>
+
+<p>If you are building a large application you might find it convenient to organize your controllers into sub-folders.  CodeIgniter permits you to do this.</p>
+
+<p>Simply create folders within your <dfn>application/controllers</dfn> directory and place your controller classes within them.</p>
+
+<p><strong>Note:</strong>&nbsp; When using this feature the first segment of your URI must specify the folder.  For example, lets say you have a controller
+located here:</p>
+
+<code>application/controllers/<kbd>products</kbd>/shoes.php</code>
+
+<p>To call the above controller your URI will look something like this:</p>
+
+<code>example.com/index.php/products/shoes/show/123</code>
+
+<p>Each of your sub-folders may contain a default controller which will be
+called if the URL contains only the sub-folder.  Simply name your default controller as specified in your
+<dfn>application/config/routes.php</dfn> file</p>
+
+
+<p>CodeIgniter also permits you to remap your URIs using its <a href="routing.html">URI Routing</a> feature.</p>
+
+
+<h2><a name="constructors"></a>Class Constructors</h2>
+
+
+<p>If you intend to use a constructor in any of your Controllers, you <strong>MUST</strong> place the following line of code in it:</p>
+
+<code>parent::__construct();</code>
+
+<p>The reason this line is necessary is because your local constructor will be overriding the one in the parent controller class so we need to manually call it.</p>
+
+<code>
+&lt;?php<br />
+class <kbd>Blog</kbd> extends CI_Controller {<br />
+<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;public function <kbd>__construct()</kbd><br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<var>parent::__construct();</var><br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// Your own constructor code<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br />
+}<br />
+?&gt;</code>
+
+<p>Constructors are useful if you need to set some default values, or run a default process when your class is instantiated.
+Constructors can't return a value, but they can do some default work.</p>
+
+<a name="reserved"></a>
+<h2>Reserved Function Names</h2>
+
+<p>Since your controller classes will extend the main application controller you
+must be careful not to name your functions identically to the ones used by that class, otherwise your local functions
+will override them. See <a href="reserved_names.html">Reserved Names</a> for a full list.</p>
+
+<h2>That's it!</h2>
+
+<p>That, in a nutshell, is all there is to know about controllers.</p>
+
+
+
+</div>
+<!-- END CONTENT -->
+
+
+<div id="footer">
+<p>
+Previous Topic:&nbsp;&nbsp;<a href="urls.html">CodeIgniter URLs</a>
+&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+<a href="#top">Top of Page</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+<a href="../index.html">User Guide Home</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+Next Topic:&nbsp;&nbsp;<a href="reserved_names.html">Reserved Names</a></p>
+<p><a href="http://codeigniter.com">CodeIgniter</a> &nbsp;&middot;&nbsp; Copyright &#169; 2006 - 2011 &nbsp;&middot;&nbsp; <a href="http://ellislab.com/">EllisLab, Inc.</a></p>
+</div>
+
+</body>
+</html>
\ No newline at end of file
diff --git a/user_guide/general/core_classes.html b/user_guide/general/core_classes.html
new file mode 100755 (executable)
index 0000000..51c2c74
--- /dev/null
@@ -0,0 +1,186 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head>
+
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+<title>Creating Core System Classes : CodeIgniter User Guide</title>
+
+<style type='text/css' media='all'>@import url('../userguide.css');</style>
+<link rel='stylesheet' type='text/css' media='all' href='../userguide.css' />
+
+<script type="text/javascript" src="../nav/nav.js"></script>
+<script type="text/javascript" src="../nav/prototype.lite.js"></script>
+<script type="text/javascript" src="../nav/moo.fx.js"></script>
+<script type="text/javascript" src="../nav/user_guide_menu.js"></script>
+
+<meta http-equiv='expires' content='-1' />
+<meta http-equiv= 'pragma' content='no-cache' />
+<meta name='robots' content='all' />
+<meta name='author' content='ExpressionEngine Dev Team' />
+<meta name='description' content='CodeIgniter User Guide' />
+
+</head>
+<body>
+
+<!-- START NAVIGATION -->
+<div id="nav"><div id="nav_inner"><script type="text/javascript">create_menu('../');</script></div></div>
+<div id="nav2"><a name="top"></a><a href="javascript:void(0);" onclick="myHeight.toggle();"><img src="../images/nav_toggle_darker.jpg" width="154" height="43" border="0" title="Toggle Table of Contents" alt="Toggle Table of Contents" /></a></div>
+<div id="masthead">
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td><h1>CodeIgniter User Guide Version 2.0.2</h1></td>
+<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
+</tr>
+</table>
+</div>
+<!-- END NAVIGATION -->
+
+
+<!-- START BREADCRUMB -->
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td id="breadcrumb">
+<a href="http://codeigniter.com/">CodeIgniter Home</a> &nbsp;&#8250;&nbsp;
+<a href="../index.html">User Guide Home</a> &nbsp;&#8250;&nbsp;
+Creating Core System Classes
+</td>
+<td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="codeigniter.com/user_guide/" />Search User Guide&nbsp; <input type="text" class="input" style="width:200px;" name="q" id="q" size="31" maxlength="255" value="" />&nbsp;<input type="submit" class="submit" name="sa" value="Go" /></form></td>
+</tr>
+</table>
+<!-- END BREADCRUMB -->
+
+<br clear="all" />
+
+
+<!-- START CONTENT -->
+<div id="content">
+
+<h1>Creating Core System Classes</h1>
+
+<p>Every time CodeIgniter runs there are several base classes that are initialized automatically as part of the core framework.
+It is possible, however, to swap any of the core system classes with your own versions or even extend the core versions.</p>
+
+<p><strong>Most users will never have any need to do this,
+but the option to replace or extend them does exist for those who would like to significantly alter the CodeIgniter core.</strong>
+</p>
+
+<p class="important"><strong>Note:</strong>&nbsp; Messing with a core system class has a lot of implications, so make sure you
+know what you are doing before attempting it.</p>
+
+
+<h2>System Class List</h2>
+
+<p>The following is a list of the core system files that are invoked every time CodeIgniter runs:</p>
+
+<ul>
+<li>Benchmark</li>
+<li>Config</li>
+<li>Controller</li>
+<li>Exceptions</li>
+<li>Hooks</li>
+<li>Input</li>
+<li>Language</li>
+<li>Loader</li>
+<li>Log</li>
+<li>Output</li>
+<li>Router</li>
+<li>URI</li>
+<li>Utf8</li>
+</ul>
+
+<h2>Replacing Core Classes</h2>
+
+<p>To use one of your own system classes instead of a default one simply place your version inside your local <dfn>application/core</dfn> directory:</p>
+
+<code>application/core/<dfn>some-class.php</dfn></code>
+
+<p>If this directory does not exist you can create it.</p>
+
+<p>Any file named identically to one from the list above will be used instead of the one normally used.</p>
+
+<p>Please note that your class must use <kbd>CI</kbd> as a prefix. For example, if your file is named <kbd>Input.php</kbd> the class will be named:</p>
+
+<code>
+class CI_Input {<br /><br />
+
+}
+</code>
+
+
+
+<h2>Extending Core Class</h2>
+
+<p>If all you need to do is add some functionality to an existing library - perhaps add a function or two - then
+it's overkill to replace the entire library with your version.  In this case it's better to simply extend the class.
+Extending a class is nearly identical to replacing a class with a couple exceptions:</p>
+
+<ul>
+<li>The class declaration must extend the parent class.</li>
+<li>Your new class name and filename must be prefixed with <kbd>MY_</kbd> (this item is configurable.  See below.).</li>
+</ul>
+
+<p>For example, to extend the native <kbd>Input</kbd> class you'll create a file named <dfn>application/core/</dfn><kbd>MY_Input.php</kbd>, and declare your class with:</p>
+
+<code>
+class MY_Input extends CI_Input {<br /><br />
+
+}</code>
+
+<p>Note: If you need to use a constructor in your class make sure you extend the parent constructor:</p>
+
+<code>
+class MY_Input extends CI_Input {<br />
+<br />
+&nbsp;&nbsp;&nbsp;&nbsp;function __construct()<br />
+&nbsp;&nbsp;&nbsp;&nbsp;{<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;parent::__construct();<br />
+&nbsp;&nbsp;&nbsp;&nbsp;}<br />
+}</code>
+
+<p class="important"><strong>Tip:</strong>&nbsp; Any functions in your class that are named identically to the functions in the parent class will be used instead of the native ones
+(this is known as "method overriding").
+This allows you to substantially alter the CodeIgniter core.</p>
+
+<p>If you are extending the Controller core class, then be sure to extend your new class in your application controller's constructors.</p>
+
+<code>class Welcome extends MY_Controller {<br />
+<br />
+&nbsp;&nbsp;&nbsp;&nbsp;function __construct()<br />
+&nbsp;&nbsp;&nbsp;&nbsp;{<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;parent::__construct();<br />
+&nbsp;&nbsp;&nbsp;&nbsp;}<br />
+<br />
+&nbsp;&nbsp;&nbsp;&nbsp;function index()<br />
+&nbsp;&nbsp;&nbsp;&nbsp;{<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$this->load->view('welcome_message');<br />
+&nbsp;&nbsp;&nbsp;&nbsp;}<br />
+}</code>
+
+<h3>Setting Your Own Prefix</h3>
+
+<p>To set your own sub-class prefix, open your <dfn>application/config/config.php</dfn> file and look for this item:</p>
+
+<code>$config['subclass_prefix'] = 'MY_';</code>
+
+<p>Please note that all native CodeIgniter libraries are prefixed with <kbd>CI_</kbd> so DO NOT use that as your prefix.</p>
+
+
+
+
+</div>
+<!-- END CONTENT -->
+
+
+<div id="footer">
+<p>
+Previous Topic:&nbsp;&nbsp;<a href="creating_libraries.html">Creating Your Own Libraries</a>
+&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+<a href="#top">Top of Page</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+<a href="../index.html">User Guide Home</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+Next Topic:&nbsp;&nbsp;<a href="hooks.html">Hooks - Extending the Core</a>
+</p>
+<p><a href="http://codeigniter.com">CodeIgniter</a> &nbsp;&middot;&nbsp; Copyright &#169; 2006 - 2011 &nbsp;&middot;&nbsp; <a href="http://ellislab.com/">EllisLab, Inc.</a></p>
+</div>
+
+</body>
+</html>
\ No newline at end of file
diff --git a/user_guide/general/creating_drivers.html b/user_guide/general/creating_drivers.html
new file mode 100755 (executable)
index 0000000..a759405
--- /dev/null
@@ -0,0 +1,100 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head>
+
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+<title>Creating Drivers : CodeIgniter User Guide</title>
+
+<style type='text/css' media='all'>@import url('../userguide.css');</style>
+<link rel='stylesheet' type='text/css' media='all' href='../userguide.css' />
+
+<script type="text/javascript" src="../nav/nav.js"></script>
+<script type="text/javascript" src="../nav/prototype.lite.js"></script>
+<script type="text/javascript" src="../nav/moo.fx.js"></script>
+<script type="text/javascript" src="../nav/user_guide_menu.js"></script>
+
+<meta http-equiv='expires' content='-1' />
+<meta http-equiv= 'pragma' content='no-cache' />
+<meta name='robots' content='all' />
+<meta name='author' content='ExpressionEngine Dev Team' />
+<meta name='description' content='CodeIgniter User Guide' />
+
+</head>
+<body>
+
+<!-- START NAVIGATION -->
+<div id="nav"><div id="nav_inner"><script type="text/javascript">create_menu('../');</script></div></div>
+<div id="nav2"><a name="top"></a><a href="javascript:void(0);" onclick="myHeight.toggle();"><img src="../images/nav_toggle_darker.jpg" width="154" height="43" border="0" title="Toggle Table of Contents" alt="Toggle Table of Contents" /></a></div>
+<div id="masthead">
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td><h1>CodeIgniter User Guide Version 2.0.2</h1></td>
+<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
+</tr>
+</table>
+</div>
+<!-- END NAVIGATION -->
+
+
+<!-- START BREADCRUMB -->
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td id="breadcrumb">
+<a href="http://codeigniter.com/">CodeIgniter Home</a> &nbsp;&#8250;&nbsp;
+<a href="../index.html">User Guide Home</a> &nbsp;&#8250;&nbsp;
+Creating Drivers
+</td>
+<td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="codeigniter.com/user_guide/" />Search User Guide&nbsp; <input type="text" class="input" style="width:200px;" name="q" id="q" size="31" maxlength="255" value="" />&nbsp;<input type="submit" class="submit" name="sa" value="Go" /></form></td>
+</tr>
+</table>
+<!-- END BREADCRUMB -->
+
+<br clear="all" />
+
+
+<!-- START CONTENT -->
+<div id="content">
+
+<h1>Creating Drivers</h1>
+
+<h2>Driver Directory and File Structure</h2>
+
+<p>Sample driver directory and file structure layout:</p>
+
+<ul>
+       <li>/application/libraries/Driver_name
+               <ul>
+                       <li>Driver_name.php</li>
+                       <li>drivers
+                               <ul>
+                                       <li>Driver_name_subclass_1.php</li>
+                                       <li>Driver_name_subclass_2.php</li>
+                                       <li>Driver_name_subclass_3.php</li>
+                               </ul>
+                       </li>
+               </ul>
+       </li>
+</ul>
+
+<p class="important"><strong>NOTE:</strong> In order to maintain compatibility on case-sensitive file systems, the <samp>Driver_name</samp> directory must be <var>ucfirst()</var></p>
+
+<!-- @todo write this! -->
+
+
+</div>
+<!-- END CONTENT -->
+
+
+<div id="footer">
+<p>
+Previous Topic:&nbsp;&nbsp;<a href="drivers.html">Using CodeIgniter Drivers</a>
+&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+<a href="#top">Top of Page</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+<a href="../index.html">User Guide Home</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+Next Topic:&nbsp;&nbsp;<a href="core_classes.html">Creating Core System Classes</a>
+</p>
+<p><a href="http://codeigniter.com">CodeIgniter</a> &nbsp;&middot;&nbsp; Copyright &#169; 2006 - 2011 &nbsp;&middot;&nbsp; <a href="http://ellislab.com/">EllisLab, Inc.</a></p>
+</div>
+
+</body>
+</html>
\ No newline at end of file
diff --git a/user_guide/general/creating_libraries.html b/user_guide/general/creating_libraries.html
new file mode 100755 (executable)
index 0000000..8198c18
--- /dev/null
@@ -0,0 +1,293 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head>
+
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+<title>Creating Libraries : CodeIgniter User Guide</title>
+
+<style type='text/css' media='all'>@import url('../userguide.css');</style>
+<link rel='stylesheet' type='text/css' media='all' href='../userguide.css' />
+
+<script type="text/javascript" src="../nav/nav.js"></script>
+<script type="text/javascript" src="../nav/prototype.lite.js"></script>
+<script type="text/javascript" src="../nav/moo.fx.js"></script>
+<script type="text/javascript" src="../nav/user_guide_menu.js"></script>
+
+<meta http-equiv='expires' content='-1' />
+<meta http-equiv= 'pragma' content='no-cache' />
+<meta name='robots' content='all' />
+<meta name='author' content='ExpressionEngine Dev Team' />
+<meta name='description' content='CodeIgniter User Guide' />
+
+</head>
+<body>
+
+<!-- START NAVIGATION -->
+<div id="nav"><div id="nav_inner"><script type="text/javascript">create_menu('../');</script></div></div>
+<div id="nav2"><a name="top"></a><a href="javascript:void(0);" onclick="myHeight.toggle();"><img src="../images/nav_toggle_darker.jpg" width="154" height="43" border="0" title="Toggle Table of Contents" alt="Toggle Table of Contents" /></a></div>
+<div id="masthead">
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td><h1>CodeIgniter User Guide Version 2.0.2</h1></td>
+<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
+</tr>
+</table>
+</div>
+<!-- END NAVIGATION -->
+
+
+<!-- START BREADCRUMB -->
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td id="breadcrumb">
+<a href="http://codeigniter.com/">CodeIgniter Home</a> &nbsp;&#8250;&nbsp;
+<a href="../index.html">User Guide Home</a> &nbsp;&#8250;&nbsp;
+Creating Libraries
+</td>
+<td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="codeigniter.com/user_guide/" />Search User Guide&nbsp; <input type="text" class="input" style="width:200px;" name="q" id="q" size="31" maxlength="255" value="" />&nbsp;<input type="submit" class="submit" name="sa" value="Go" /></form></td>
+</tr>
+</table>
+<!-- END BREADCRUMB -->
+
+<br clear="all" />
+
+
+<!-- START CONTENT -->
+<div id="content">
+
+<h1>Creating Libraries</h1>
+
+<p>When we use the term "Libraries" we are normally referring to the classes that are located in the <kbd>libraries</kbd>
+directory and described in the Class Reference of this user guide.  In this case, however, we will instead describe how you can create
+your own libraries within your <dfn>application/libraries</dfn> directory in order to maintain separation between your local resources
+and the global framework resources.</p>
+
+<p>As an added bonus, CodeIgniter permits your libraries to <kbd>extend</kbd> native classes if you simply need to add some functionality
+to an existing library. Or you can even replace native libraries just by placing identically named versions in your <dfn>application/libraries</dfn> folder.</p>
+
+<p>In summary:</p>
+
+<ul>
+<li>You can create entirely new libraries.</li>
+<li>You can extend native libraries.</li>
+<li>You can replace native libraries.</li>
+</ul>
+
+<p>The page below explains these three concepts in detail.</p>
+
+<p class="important"><strong>Note:</strong> The Database classes can not be extended or replaced with your own classes.  All other classes are able to be replaced/extended.</p>
+
+
+<h2>Storage</h2>
+
+<p>Your library classes should be placed within your <dfn>application/libraries</dfn> folder, as this is where CodeIgniter will look for them when
+they are initialized.</p>
+
+
+<h2>Naming Conventions</h2>
+
+<ul>
+<li>File names must be capitalized. For example:&nbsp; <dfn>Myclass.php</dfn></li>
+<li>Class declarations must be capitalized. For example:&nbsp;  <kbd>class Myclass</kbd></li>
+<li>Class names and file names must match.</li>
+</ul>
+
+
+<h2>The Class File</h2>
+
+<p>Classes should have this basic prototype (Note:  We are using the name <kbd>Someclass</kbd> purely as an example):</p>
+
+<code>&lt;?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+<br /><br />
+class Someclass {<br />
+<br />
+&nbsp;&nbsp;&nbsp;&nbsp;public function some_function()<br />
+&nbsp;&nbsp;&nbsp;&nbsp;{<br />
+&nbsp;&nbsp;&nbsp;&nbsp;}<br />
+}<br /><br />
+/* End of file Someclass.php */</code>
+
+
+<h2>Using Your Class</h2>
+
+<p>From within any of your <a href="controllers.html">Controller</a> functions you can initialize your class using the standard:</p>
+
+<code>$this->load->library('<kbd>someclass</kbd>');</code>
+
+<p>Where <em>someclass</em> is the file name, without the ".php" file extension. You can submit the file name capitalized or lower case.
+CodeIgniter doesn't care.</p>
+
+<p>Once loaded you can access your class using the <kbd>lower case</kbd> version:</p>
+
+<code>$this-><kbd>someclass</kbd>->some_function();&nbsp; // Object instances will always be lower case
+</code>
+
+
+
+<h2>Passing Parameters When Initializing Your Class</h2>
+
+<p>In the library loading function you can dynamically pass data as an array via the second parameter and it will be passed to your class
+constructor:</p>
+
+<code>
+$params = array('type' => 'large', 'color' => 'red');<br />
+<br />
+$this->load->library('Someclass', <kbd>$params</kbd>);</code>
+
+<p>If you use this feature you must set up your class constructor to expect data:</p>
+
+<code>&lt;?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');<br />
+<br />
+class Someclass {<br />
+<br />
+&nbsp;&nbsp;&nbsp;&nbsp;public function __construct($params)<br />
+&nbsp;&nbsp;&nbsp;&nbsp;{<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// Do something with $params<br />
+&nbsp;&nbsp;&nbsp;&nbsp;}<br />
+}<br /><br />
+?&gt;</code>
+
+<p class="important">You can also pass parameters stored in a config file.  Simply create a config file named identically to the class <kbd>file name</kbd>
+and store it in your <dfn>application/config/</dfn> folder.  Note that if you dynamically pass parameters as described above,
+the config file option will not be available.</p>
+
+
+
+
+
+
+
+<h2>Utilizing CodeIgniter Resources within Your Library</h2>
+
+
+<p>To access CodeIgniter's native resources within your library use the <kbd>get_instance()</kbd> function.
+This function returns the CodeIgniter super object.</p>
+
+<p>Normally from within your controller functions you will call any of the available CodeIgniter functions using the <kbd>$this</kbd> construct:</p>
+
+<code>
+<strong>$this</strong>->load->helper('url');<br />
+<strong>$this</strong>->load->library('session');<br />
+<strong>$this</strong>->config->item('base_url');<br />
+etc.
+</code>
+
+<p><kbd>$this</kbd>, however, only works directly within your controllers, your models, or your views.
+If you would like to use CodeIgniter's classes from within your own custom classes you can do so as follows:</p>
+
+
+<p>First, assign the CodeIgniter object to a variable:</p>
+
+<code>$CI =&amp; get_instance();</code>
+
+<p>Once you've assigned the object to a variable, you'll use that variable <em>instead</em> of <kbd>$this</kbd>:</p>
+
+<code>
+$CI =&amp; get_instance();<br />
+<br />
+$CI->load->helper('url');<br />
+$CI->load->library('session');<br />
+$CI->config->item('base_url');<br />
+etc.
+</code>
+
+<p class="important"><strong>Note:</strong> You'll notice that the above get_instance() function is being passed by reference:
+<br /><br />
+<var>$CI =&amp; get_instance();</var>
+<br />
+<br />
+<kbd>This is very important.</kbd> Assigning by reference allows you to use the original CodeIgniter object rather than creating a copy of it.</p>
+
+
+<h2>Replacing Native Libraries with Your Versions</h2>
+
+<p>Simply by naming your class files identically to a native library will cause CodeIgniter to use it instead of the native one. To use this
+feature you must name the file and the class declaration exactly the same as the native library.  For example, to replace the native <kbd>Email</kbd> library
+you'll create a file named <dfn>application/libraries/Email.php</dfn>, and declare your class with:</p>
+
+<code>
+class CI_Email {<br /><br />
+
+}</code>
+
+<p>Note that most native classes are prefixed with <kbd>CI_</kbd>.</p>
+
+<p>To load your library you'll see the standard loading function:</p>
+
+<code>$this->load->library('<kbd>email</kbd>');</code>
+
+<p class="important"><strong>Note:</strong> At this time the Database classes can not be replaced with your own versions.</p>
+
+
+<h2>Extending Native Libraries</h2>
+
+<p>If all you need to do is add some functionality to an existing library - perhaps add a function or two - then
+it's overkill to replace the entire library with your version.  In this case it's better to simply extend the class.
+Extending a class is nearly identical to replacing a class with a couple exceptions:</p>
+
+<ul>
+<li>The class declaration must extend the parent class.</li>
+<li>Your new class name and filename must be prefixed with <kbd>MY_</kbd> (this item is configurable.  See below.).</li>
+</ul>
+
+<p>For example, to extend the native <kbd>Email</kbd> class you'll create a file named <dfn>application/libraries/</dfn><kbd>MY_Email.php</kbd>, and declare your class with:</p>
+
+<code>
+class MY_Email extends CI_Email {<br /><br />
+
+}</code>
+
+<p>Note: If you need to use a constructor in your class make sure you extend the parent constructor:</p>
+
+
+<code>
+class MY_Email extends CI_Email {<br />
+<br />
+&nbsp;&nbsp;&nbsp;&nbsp;public function __construct()<br />
+&nbsp;&nbsp;&nbsp;&nbsp;{<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;parent::__construct();<br />
+&nbsp;&nbsp;&nbsp;&nbsp;}<br />
+}</code>
+
+
+<h3>Loading Your Sub-class</h3>
+
+<p>To load your sub-class you'll use the standard syntax normally used.  DO NOT include your prefix.  For example,
+to load the example above, which extends the Email class, you will use:</p>
+
+<code>$this->load->library('<kbd>email</kbd>');</code>
+
+<p>Once loaded you will use the class variable as you normally would for the class you are extending.  In the case of
+the email class all calls will use:</p>
+
+
+<code>$this-><kbd>email</kbd>->some_function();</code>
+
+
+<h3>Setting Your Own Prefix</h3>
+
+<p>To set your own sub-class prefix, open your <dfn>application/config/config.php</dfn> file and look for this item:</p>
+
+<code>$config['subclass_prefix'] = 'MY_';</code>
+
+<p>Please note that all native CodeIgniter libraries are prefixed with <kbd>CI_</kbd> so DO NOT use that as your prefix.</p>
+
+
+
+</div>
+<!-- END CONTENT -->
+
+
+<div id="footer">
+<p>
+Previous Topic:&nbsp;&nbsp;<a href="libraries.html">Using CodeIgniter Libraries</a>
+&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+<a href="#top">Top of Page</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+<a href="../index.html">User Guide Home</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+Next Topic:&nbsp;&nbsp;<a href="drivers.html">Using CodeIgniter Drivers</a>
+</p>
+<p><a href="http://codeigniter.com">CodeIgniter</a> &nbsp;&middot;&nbsp; Copyright &#169; 2006 - 2011 &nbsp;&middot;&nbsp; <a href="http://ellislab.com/">EllisLab, Inc.</a></p>
+</div>
+
+</body>
+</html>
\ No newline at end of file
diff --git a/user_guide/general/credits.html b/user_guide/general/credits.html
new file mode 100755 (executable)
index 0000000..9e0fbac
--- /dev/null
@@ -0,0 +1,87 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head>
+
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+<title>Credits : CodeIgniter User Guide</title>
+
+<style type='text/css' media='all'>@import url('../userguide.css');</style>
+<link rel='stylesheet' type='text/css' media='all' href='../userguide.css' />
+
+<script type="text/javascript" src="../nav/nav.js"></script>
+<script type="text/javascript" src="../nav/prototype.lite.js"></script>
+<script type="text/javascript" src="../nav/moo.fx.js"></script>
+<script type="text/javascript" src="../nav/user_guide_menu.js"></script>
+
+<meta http-equiv='expires' content='-1' />
+<meta http-equiv= 'pragma' content='no-cache' />
+<meta name='robots' content='all' />
+<meta name='author' content='ExpressionEngine Dev Team' />
+<meta name='description' content='CodeIgniter User Guide' />
+
+</head>
+<body>
+
+<!-- START NAVIGATION -->
+<div id="nav"><div id="nav_inner"><script type="text/javascript">create_menu('../');</script></div></div>
+<div id="nav2"><a name="top"></a><a href="javascript:void(0);" onclick="myHeight.toggle();"><img src="../images/nav_toggle_darker.jpg" width="154" height="43" border="0" title="Toggle Table of Contents" alt="Toggle Table of Contents" /></a></div>
+<div id="masthead">
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td><h1>CodeIgniter User Guide Version 2.0.2</h1></td>
+<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
+</tr>
+</table>
+</div>
+<!-- END NAVIGATION -->
+
+
+<!-- START BREADCRUMB -->
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td id="breadcrumb">
+<a href="http://codeigniter.com/">CodeIgniter Home</a> &nbsp;&#8250;&nbsp;
+<a href="../index.html">User Guide Home</a> &nbsp;&#8250;&nbsp;
+Credits
+</td>
+<td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="codeigniter.com/user_guide/" />Search User Guide&nbsp; <input type="text" class="input" style="width:200px;" name="q" id="q" size="31" maxlength="255" value="" />&nbsp;<input type="submit" class="submit" name="sa" value="Go" /></form></td>
+</tr>
+</table>
+<!-- END BREADCRUMB -->
+
+<br clear="all" />
+
+
+<!-- START CONTENT -->
+<div id="content">
+
+<h1>Credits</h1>
+
+<p>CodeIgniter was originally developed by <a href="http://www.ellislab.com/">Rick Ellis</a> (CEO of
+<a href="http://ellislab.com/">EllisLab, Inc.</a>).  The framework was written for performance in the real
+world, with many of the class libraries, helpers, and sub-systems borrowed from the code-base of
+<a href="http://www.expressionengine.com/">ExpressionEngine</a>.</p>
+
+<p>It is currently developed and maintained by the ExpressionEngine Development Team.<br />
+Bleeding edge development is spearheaded by the handpicked contributors of the Reactor Team.</p>
+
+<p>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.</p>
+
+</div>
+<!-- END CONTENT -->
+
+
+<div id="footer">
+<p>
+Previous Topic:&nbsp;&nbsp;<a href="../changelog.html">Change Log</a>
+&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+<a href="#top">Top of Page</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+<a href="../index.html">User Guide Home</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+Next Topic:&nbsp;&nbsp;<a href="../installation/downloads.html">Downloading CodeIgniter</a>
+</p>
+<p><a href="http://codeigniter.com">CodeIgniter</a> &nbsp;&middot;&nbsp; Copyright &#169; 2006 - 2011 &nbsp;&middot;&nbsp; <a href="http://ellislab.com/">EllisLab, Inc.</a></p>
+</div>
+
+</body>
+</html>
\ No newline at end of file
diff --git a/user_guide/general/drivers.html b/user_guide/general/drivers.html
new file mode 100755 (executable)
index 0000000..8dbeb93
--- /dev/null
@@ -0,0 +1,104 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head>
+
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+<title>Using CodeIgniter Drivers : CodeIgniter User Guide</title>
+
+<style type='text/css' media='all'>@import url('../userguide.css');</style>
+<link rel='stylesheet' type='text/css' media='all' href='../userguide.css' />
+
+<script type="text/javascript" src="../nav/nav.js"></script>
+<script type="text/javascript" src="../nav/prototype.lite.js"></script>
+<script type="text/javascript" src="../nav/moo.fx.js"></script>
+<script type="text/javascript" src="../nav/user_guide_menu.js"></script>
+
+<meta http-equiv='expires' content='-1' />
+<meta http-equiv= 'pragma' content='no-cache' />
+<meta name='robots' content='all' />
+<meta name='author' content='ExpressionEngine Dev Team' />
+<meta name='description' content='CodeIgniter User Guide' />
+
+</head>
+<body>
+
+<!-- START NAVIGATION -->
+<div id="nav"><div id="nav_inner"><script type="text/javascript">create_menu('../');</script></div></div>
+<div id="nav2"><a name="top"></a><a href="javascript:void(0);" onclick="myHeight.toggle();"><img src="../images/nav_toggle_darker.jpg" width="154" height="43" border="0" title="Toggle Table of Contents" alt="Toggle Table of Contents" /></a></div>
+<div id="masthead">
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td><h1>CodeIgniter User Guide Version 2.0.2</h1></td>
+<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
+</tr>
+</table>
+</div>
+<!-- END NAVIGATION -->
+
+
+<!-- START BREADCRUMB -->
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td id="breadcrumb">
+<a href="http://codeigniter.com/">CodeIgniter Home</a> &nbsp;&#8250;&nbsp;
+<a href="../index.html">User Guide Home</a> &nbsp;&#8250;&nbsp;
+Using CodeIgniter Drivers
+</td>
+<td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="codeigniter.com/user_guide/" />Search User Guide&nbsp; <input type="text" class="input" style="width:200px;" name="q" id="q" size="31" maxlength="255" value="" />&nbsp;<input type="submit" class="submit" name="sa" value="Go" /></form></td>
+</tr>
+</table>
+<!-- END BREADCRUMB -->
+
+<br clear="all" />
+
+
+<!-- START CONTENT -->
+<div id="content">
+
+<h1>Using CodeIgniter Drivers</h1>
+
+
+<p>Drivers are a special type of Library that has a parent class and any number of potential child classes.  Child classes have access to the parent class, but not their siblings.  Drivers provide an elegant syntax  in your <a href="controllers.html">controllers</a> for libraries that benefit from or require being broken down into discrete classes.</p>
+
+<p>Drivers are found in the <dfn>system/libraries</dfn> folder, in their own folder which is identically named to the parent library class.  Also inside that folder is a subfolder named <kbd>drivers</kbd>, which contains all of the possible child class files.</p>
+
+<p>To use a driver you will initialize it within a controller using the following initialization function:</p>
+
+<code>$this->load->driver('<var>class name</var>'); </code>
+
+<p>Where <var>class name</var> is the name of the driver class you want to invoke.  For example, to load a driver named "Some Parent" you would do this:</p>
+
+<code>$this->load->driver('<var>some_parent</var>');</code>
+
+<p>Methods of that class can then be invoked with:</p>
+
+<code>$this->some_parent->some_method();</code>
+
+<p>The child classes, the drivers themselves, can then be called directly through the parent class, without initializing them:</p>
+
+<code>$this->some_parent->child_one->some_method();<br />
+$this->some_parent->child_two->another_method();</code>
+
+<h2>Creating Your Own Drivers</h2>
+
+<p>Please read the section of the user guide that discusses how to <a href="creating_drivers.html">create your own drivers</a>.</p>
+
+
+
+</div>
+<!-- END CONTENT -->
+
+
+<div id="footer">
+<p>
+Previous Topic:&nbsp;&nbsp;<a href="creating_libraries.html">Creating Libraries</a>
+&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+<a href="#top">Top of Page</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+<a href="../index.html">User Guide Home</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+Next Topic:&nbsp;&nbsp;<a href="creating_drivers.html">Creating Drivers</a>
+</p>
+<p><a href="http://codeigniter.com">CodeIgniter</a> &nbsp;&middot;&nbsp; Copyright &#169; 2006 - 2011 &nbsp;&middot;&nbsp; <a href="http://ellislab.com/">EllisLab, Inc.</a></p>
+</div>
+
+</body>
+</html>
\ No newline at end of file
diff --git a/user_guide/general/environments.html b/user_guide/general/environments.html
new file mode 100755 (executable)
index 0000000..175a153
--- /dev/null
@@ -0,0 +1,126 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head>
+
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+<title>Handling Multiple Environments : CodeIgniter User Guide</title>
+
+<style type='text/css' media='all'>@import url('../userguide.css');</style>
+<link rel='stylesheet' type='text/css' media='all' href='../userguide.css' />
+
+<script type="text/javascript" src="../nav/nav.js"></script>
+<script type="text/javascript" src="../nav/prototype.lite.js"></script>
+<script type="text/javascript" src="../nav/moo.fx.js"></script>
+<script type="text/javascript" src="../nav/user_guide_menu.js"></script>
+
+<meta http-equiv='expires' content='-1' />
+<meta http-equiv= 'pragma' content='no-cache' />
+<meta name='robots' content='all' />
+<meta name='author' content='ExpressionEngine Dev Team' />
+<meta name='description' content='CodeIgniter User Guide' />
+
+</head>
+<body>
+
+<!-- START NAVIGATION -->
+<div id="nav"><div id="nav_inner"><script type="text/javascript">create_menu('../');</script></div></div>
+<div id="nav2"><a name="top"></a><a href="javascript:void(0);" onclick="myHeight.toggle();"><img src="../images/nav_toggle_darker.jpg" width="154" height="43" border="0" title="Toggle Table of Contents" alt="Toggle Table of Contents" /></a></div>
+<div id="masthead">
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td><h1>CodeIgniter User Guide Version 2.0.2</h1></td>
+<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
+</tr>
+</table>
+</div>
+<!-- END NAVIGATION -->
+
+
+<!-- START BREADCRUMB -->
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td id="breadcrumb">
+<a href="http://codeigniter.com/">CodeIgniter Home</a> &nbsp;&#8250;&nbsp;
+<a href="../index.html">User Guide Home</a> &nbsp;&#8250;&nbsp;
+Handling Multiple Environments
+</td>
+<td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="codeigniter.com/user_guide/" />Search User Guide&nbsp; <input type="text" class="input" style="width:200px;" name="q" id="q" size="31" maxlength="255" value="" />&nbsp;<input type="submit" class="submit" name="sa" value="Go" /></form></td>
+</tr>
+</table>
+<!-- END BREADCRUMB -->
+
+<br clear="all" />
+
+
+<!-- START CONTENT -->
+<div id="content">
+
+<h1>Handling Multiple Environments</h1>
+
+<p>
+    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".
+</p>
+
+<h2>The ENVIRONMENT Constant</h2>
+
+<p>
+    By default, CodeIgniter comes with the environment constant set to
+    '<kbd>development</kbd>'. At the top of index.php, you will see:
+</p>
+
+<code>
+define('<var>ENVIRONMENT</var>', '<var>development</var>');
+</code>
+
+<p>
+    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.
+</p>
+
+<h2>Effects On Default Framework Behavior</h2>
+
+<p>
+    There are some places in the CodeIgniter system where the <kbd>ENVIRONMENT</kbd>
+    constant is used. This section describes how default framework behavior is
+    affected.
+</p>
+
+<h3>Error Reporting</h3>
+
+<p>
+    Setting the <kbd>ENVIRONMENT</kbd> constant to a value of '<kbd>development</kbd>' will
+    cause all PHP errors to be rendered to the browser when they occur. Conversely,
+    setting the constant to '<kbd>production</kbd>' will disable all error output. Disabling
+    error reporting in production is a <a href="security.html">good security practice</a>.
+</p>
+
+<h3>Configuration Files</h3>
+
+<p>
+    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 <a href="../libraries/config.html#environments">Config Class</a> documentation.
+</p>
+
+</div>
+<!-- END CONTENT -->
+
+
+<div id="footer">
+<p>
+Previous Topic:&nbsp;&nbsp;<a href="managing_apps.html">Managing Applications</a>
+&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+<a href="#top">Top of Page</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+<a href="../index.html">User Guide Home</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+Next Topic:&nbsp;&nbsp;<a href="alternative_php.html">Alternative PHP Syntax</a>
+</p>
+<p><a href="http://codeigniter.com">CodeIgniter</a> &nbsp;&middot;&nbsp; Copyright &#169; 2006 - 2011 &nbsp;&middot;&nbsp; <a href="http://ellislab.com/">EllisLab, Inc.</a></p>
+</div>
+
+</body>
+</html>
\ No newline at end of file
diff --git a/user_guide/general/errors.html b/user_guide/general/errors.html
new file mode 100755 (executable)
index 0000000..58eff65
--- /dev/null
@@ -0,0 +1,140 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head>
+
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+<title>Error Handling : CodeIgniter User Guide</title>
+
+<style type='text/css' media='all'>@import url('../userguide.css');</style>
+<link rel='stylesheet' type='text/css' media='all' href='../userguide.css' />
+
+<script type="text/javascript" src="../nav/nav.js"></script>
+<script type="text/javascript" src="../nav/prototype.lite.js"></script>
+<script type="text/javascript" src="../nav/moo.fx.js"></script>
+<script type="text/javascript" src="../nav/user_guide_menu.js"></script>
+
+<meta http-equiv='expires' content='-1' />
+<meta http-equiv= 'pragma' content='no-cache' />
+<meta name='robots' content='all' />
+<meta name='author' content='ExpressionEngine Dev Team' />
+<meta name='description' content='CodeIgniter User Guide' />
+
+</head>
+<body>
+
+<!-- START NAVIGATION -->
+<div id="nav"><div id="nav_inner"><script type="text/javascript">create_menu('../');</script></div></div>
+<div id="nav2"><a name="top"></a><a href="javascript:void(0);" onclick="myHeight.toggle();"><img src="../images/nav_toggle_darker.jpg" width="154" height="43" border="0" title="Toggle Table of Contents" alt="Toggle Table of Contents" /></a></div>
+<div id="masthead">
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td><h1>CodeIgniter User Guide Version 2.0.2</h1></td>
+<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
+</tr>
+</table>
+</div>
+<!-- END NAVIGATION -->
+
+
+<!-- START BREADCRUMB -->
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td id="breadcrumb">
+<a href="http://codeigniter.com/">CodeIgniter Home</a> &nbsp;&#8250;&nbsp;
+<a href="../index.html">User Guide Home</a> &nbsp;&#8250;&nbsp;
+Error Handling
+</td>
+<td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="codeigniter.com/user_guide/" />Search User Guide&nbsp; <input type="text" class="input" style="width:200px;" name="q" id="q" size="31" maxlength="255" value="" />&nbsp;<input type="submit" class="submit" name="sa" value="Go" /></form></td>
+</tr>
+</table>
+<!-- END BREADCRUMB -->
+
+<br clear="all" />
+
+
+<!-- START CONTENT -->
+<div id="content">
+
+<h1>Error Handling</h1>
+
+<p>CodeIgniter lets you build error reporting into your applications using the functions described below.
+In addition, it has an error logging class that permits error and debugging messages to be saved as text files.</p>
+
+<p class="important"><strong>Note:</strong> By default, CodeIgniter displays all PHP errors.  You might
+wish to change this behavior once your development is complete.  You'll find the <dfn>error_reporting()</dfn>
+function located at the top of your main index.php file. Disabling error reporting will NOT prevent log files
+from being written if there are errors.</p>
+
+<p>Unlike most systems in CodeIgniter, the error functions are simple procedural interfaces that are available
+globally throughout the application.  This approach permits error messages to get triggered without having to worry
+about class/function scoping.</p>
+
+<p>The following functions let you generate errors:</p>
+
+<h2>show_error('<var>message</var>' [, int <var>$status_code</var>= 500 ] )</h2>
+<p>This function will display the error message supplied to it using the following error template:</p>
+<p><dfn>application/errors/</dfn><kbd>error_general.php</kbd></p>
+<p>The optional parameter $status_code determines what HTTP status code should be sent with the error.</p>
+
+<h2>show_404('<var>page</var>' [, '<var>log_error</var>'])</h2>
+<p>This function will display the 404 error message supplied to it using the following error template:</p>
+<p><dfn>application/errors/</dfn><kbd>error_404.php</kbd></p>
+
+<p>The function expects the string passed to it to be the file path to the page that isn't found.
+Note that CodeIgniter automatically shows 404 messages if controllers are not found.</p>
+
+<p>CodeIgniter automatically logs any show_404() calls. Setting the optional second parameter to FALSE will skip logging.</p>
+
+
+<h2>log_message('<var>level</var>', '<samp>message</samp>')</h2>
+
+<p>This function lets you write messages to your log files.  You must supply one of three "levels"
+in the first parameter, indicating what type of message it is (debug, error, info), with the message
+itself in the second parameter.  Example:</p>
+
+<code>
+if ($some_var == "")<br />
+{<br />
+&nbsp;&nbsp;&nbsp;&nbsp;log_message('error', 'Some variable did not contain a value.');<br />
+}<br />
+else<br />
+{<br />
+&nbsp;&nbsp;&nbsp;&nbsp;log_message('debug', 'Some variable was correctly set');<br />
+}<br />
+<br />
+log_message('info', 'The purpose of some variable is to provide some value.');<br />
+</code>
+
+<p>There are three message types:</p>
+
+<ol>
+<li>Error Messages.  These are actual errors, such as PHP errors or user errors.</li>
+<li>Debug Messages.  These are messages that assist in debugging. For example, if a class has been initialized, you could log this as debugging info.</li>
+<li>Informational Messages.  These are the lowest priority messages, simply giving information regarding some process.  CodeIgniter doesn't natively generate any info messages but you may want to in your application.</li>
+</ol>
+
+
+<p class="important"><strong>Note:</strong> 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 in <dfn>application/config/config.php</dfn>.
+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.</p>
+
+
+
+</div>
+<!-- END CONTENT -->
+
+
+<div id="footer">
+<p>
+Previous Topic:&nbsp;&nbsp;<a href="routing.html">URI Routing</a>
+&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+<a href="#top">Top of Page</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+<a href="../index.html">User Guide Home</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+Next Topic:&nbsp;&nbsp;<a href="caching.html">Page Caching</a>
+</p>
+<p><a href="http://codeigniter.com">CodeIgniter</a> &nbsp;&middot;&nbsp; Copyright &#169; 2006 - 2011 &nbsp;&middot;&nbsp; <a href="http://ellislab.com/">EllisLab, Inc.</a></p>
+</div>
+
+</body>
+</html>
\ No newline at end of file
diff --git a/user_guide/general/helpers.html b/user_guide/general/helpers.html
new file mode 100755 (executable)
index 0000000..339a0df
--- /dev/null
@@ -0,0 +1,185 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head>
+
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+<title>Helper Functions : CodeIgniter User Guide</title>
+
+<style type='text/css' media='all'>@import url('../userguide.css');</style>
+<link rel='stylesheet' type='text/css' media='all' href='../userguide.css' />
+
+<script type="text/javascript" src="../nav/nav.js"></script>
+<script type="text/javascript" src="../nav/prototype.lite.js"></script>
+<script type="text/javascript" src="../nav/moo.fx.js"></script>
+<script type="text/javascript" src="../nav/user_guide_menu.js"></script>
+
+<meta http-equiv='expires' content='-1' />
+<meta http-equiv= 'pragma' content='no-cache' />
+<meta name='robots' content='all' />
+<meta name='author' content='ExpressionEngine Dev Team' />
+<meta name='description' content='CodeIgniter User Guide' />
+
+</head>
+<body>
+
+<!-- START NAVIGATION -->
+<div id="nav"><div id="nav_inner"><script type="text/javascript">create_menu('../');</script></div></div>
+<div id="nav2"><a name="top"></a><a href="javascript:void(0);" onclick="myHeight.toggle();"><img src="../images/nav_toggle_darker.jpg" width="154" height="43" border="0" title="Toggle Table of Contents" alt="Toggle Table of Contents" /></a></div>
+<div id="masthead">
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td><h1>CodeIgniter User Guide Version 2.0.2</h1></td>
+<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
+</tr>
+</table>
+</div>
+<!-- END NAVIGATION -->
+
+
+<!-- START BREADCRUMB -->
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td id="breadcrumb">
+<a href="http://codeigniter.com/">CodeIgniter Home</a> &nbsp;&#8250;&nbsp;
+<a href="../index.html">User Guide Home</a> &nbsp;&#8250;&nbsp;
+Helper Functions
+</td>
+<td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="codeigniter.com/user_guide/" />Search User Guide&nbsp; <input type="text" class="input" style="width:200px;" name="q" id="q" size="31" maxlength="255" value="" />&nbsp;<input type="submit" class="submit" name="sa" value="Go" /></form></td>
+</tr>
+</table>
+<!-- END BREADCRUMB -->
+
+<br clear="all" />
+
+
+<!-- START CONTENT -->
+<div id="content">
+
+<h1>Helper Functions</h1>
+
+<p>Helpers, as the name suggests, help you with tasks.  Each helper file is simply a collection of functions in a particular
+category.  There are <dfn>URL Helpers</dfn>, that assist in creating links, there are <dfn>Form Helpers</dfn>
+that help you create form elements, <dfn>Text Helpers</dfn> perform various text formatting routines,
+<dfn>Cookie Helpers</dfn> set and read cookies, <dfn>File Helpers</dfn> help you deal with files, etc.
+</p>
+
+<p>Unlike most other systems in CodeIgniter, Helpers are not written in an Object Oriented format.  They are simple, procedural functions.
+Each helper function performs one specific task, with no dependence on other functions.</p>
+
+<p>CodeIgniter does not load Helper Files by default, so the first step in using
+a Helper is to load it.  Once loaded, it becomes globally available in your <a href="../general/controllers.html">controller</a> and <a href="../general/views.html">views</a>.</p>
+
+<p>Helpers are typically stored in your <dfn>system/helpers</dfn>, or <dfn>application/helpers </dfn>directory.        CodeIgniter will look first in your <dfn>application/helpers</dfn>
+directory.  If the directory does not exist or the specified helper is not located there CI will instead look in your global
+<dfn>system/helpers</dfn> folder.</p>
+
+
+<h2>Loading a Helper</h2>
+
+<p>Loading a helper file is quite simple using the following function:</p>
+
+<code>$this->load->helper('<var>name</var>');</code>
+
+<p>Where <var>name</var> is the file name of the helper, without the .php file extension or the "helper" part.</p>
+
+<p>For example, to load the <dfn>URL Helper</dfn> file, which is named <var>url_helper.php</var>, you would do this:</p>
+
+<code>$this->load->helper('<var>url</var>');</code>
+
+<p>A helper can be loaded anywhere within your controller functions (or even within your View files, although that's not a good practice),
+as long as you load it before you use it.  You can load your helpers in your controller constructor so that they become available
+automatically in any function, or you can load a helper in a specific function that needs it.</p>
+
+<p class="important">Note: The Helper loading function above does not return a value, so don't try to assign it to a variable.  Just use it as shown.</p>
+
+
+<h2>Loading Multiple Helpers</h2>
+
+<p>If you need to load more than one helper you can specify them in an array, like this:</p>
+
+<code>$this->load->helper( <samp>array(</samp>'<var>helper1</var>', '<var>helper2</var>', '<var>helper3</var>'<samp>)</samp> );</code>
+
+<h2>Auto-loading Helpers</h2>
+
+<p>If you find that you need a particular helper globally throughout your application, you can tell CodeIgniter to auto-load it during system initialization.
+This is done by opening the <var>application/config/autoload.php</var> file and adding the helper to the autoload array.</p>
+
+
+<h2>Using a Helper</h2>
+
+<p>Once you've loaded the Helper File containing the function you intend to use, you'll call it the way you would a standard PHP function.</p>
+
+<p>For example, to create a link using the <dfn>anchor()</dfn> function in one of your view files you would do this:</p>
+
+<code>&lt;?php echo anchor('blog/comments', 'Click Here');?&gt;</code>
+
+<p>Where "Click Here" is the name of the link, and "blog/comments" is the URI to the controller/function you wish to link to.</p>
+
+<h2>"Extending" Helpers</h2>
+
+<p>To "extend" Helpers, create a file in your <dfn>application/helpers/</dfn> folder with an identical name to the existing Helper, but prefixed with <kbd>MY_</kbd> (this item is configurable.  See below.).</p>
+
+<p>If all you need to do is add some functionality to an existing helper - perhaps add a function or two, or change how a particular
+       helper function operates - then it's overkill to replace the entire helper with your version.  In this case it's better to simply
+       "extend" the Helper.  The term "extend" is used loosely since Helper functions are procedural and discrete and cannot be extended
+       in the traditional programmatic sense.  Under the hood, this gives you the ability to add to the functions a Helper provides,
+       or to modify how the native Helper functions operate.</p>
+
+<p>For example, to extend the native <kbd>Array Helper</kbd> you'll create a file named <dfn>application/helpers/</dfn><kbd>MY_array_helper.php</kbd>, and add or override functions:</p>
+
+<code>
+// any_in_array() is not in the Array Helper, so it defines a new function<br />
+function any_in_array($needle, $haystack)<br />
+{<br />
+&nbsp;&nbsp;&nbsp;&nbsp;$needle = (is_array($needle)) ? $needle : array($needle);<br />
+       <br />
+&nbsp;&nbsp;&nbsp;&nbsp;foreach ($needle as $item)<br />
+&nbsp;&nbsp;&nbsp;&nbsp;{<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if (in_array($item, $haystack))<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return TRUE;<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br />
+       <br />
+&nbsp;&nbsp;&nbsp;&nbsp;return FALSE;<br />
+}<br />
+<br />
+// random_element() is included in Array Helper, so it overrides the native function<br />
+function random_element($array)<br />
+{<br />
+&nbsp;&nbsp;&nbsp;&nbsp;shuffle($array);<br />
+&nbsp;&nbsp;&nbsp;&nbsp;return array_pop($array);<br />
+}<br />
+</code>
+
+<h3>Setting Your Own Prefix</h3>
+
+<p>The filename prefix for "extending" Helpers is the same used to extend libraries and Core classes.  To set your own prefix, open your <dfn>application/config/config.php</dfn> file and look for this item:</p>
+
+<code>$config['subclass_prefix'] = 'MY_';</code>
+
+<p>Please note that all native CodeIgniter libraries are prefixed with <kbd>CI_</kbd> so DO NOT use that as your prefix.</p>
+
+
+<h2>Now What?</h2>
+
+<p>In the Table of Contents you'll find a list of all the available Helper Files.  Browse each one to see what they do.</p>
+
+
+</div>
+<!-- END CONTENT -->
+
+
+<div id="footer">
+<p>
+Previous Topic:&nbsp;&nbsp;<a href="models.html">Models</a>
+&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+<a href="#top">Top of Page</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+<a href="../index.html">User Guide Home</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+Next Topic:&nbsp;&nbsp;<a href="libraries.html">Using Libraries</a>
+</p>
+<p><a href="http://codeigniter.com">CodeIgniter</a> &nbsp;&middot;&nbsp; Copyright &#169; 2006 - 2011 &nbsp;&middot;&nbsp; <a href="http://ellislab.com/">EllisLab, Inc.</a></p>
+</div>
+
+</body>
+</html>
\ No newline at end of file
diff --git a/user_guide/general/hooks.html b/user_guide/general/hooks.html
new file mode 100755 (executable)
index 0000000..11de409
--- /dev/null
@@ -0,0 +1,165 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head>
+
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+<title>Hooks : CodeIgniter User Guide</title>
+
+<style type='text/css' media='all'>@import url('../userguide.css');</style>
+<link rel='stylesheet' type='text/css' media='all' href='../userguide.css' />
+
+<script type="text/javascript" src="../nav/nav.js"></script>
+<script type="text/javascript" src="../nav/prototype.lite.js"></script>
+<script type="text/javascript" src="../nav/moo.fx.js"></script>
+<script type="text/javascript" src="../nav/user_guide_menu.js"></script>
+
+<meta http-equiv='expires' content='-1' />
+<meta http-equiv= 'pragma' content='no-cache' />
+<meta name='robots' content='all' />
+<meta name='author' content='ExpressionEngine Dev Team' />
+<meta name='description' content='CodeIgniter User Guide' />
+
+</head>
+<body>
+
+<!-- START NAVIGATION -->
+<div id="nav"><div id="nav_inner"><script type="text/javascript">create_menu('../');</script></div></div>
+<div id="nav2"><a name="top"></a><a href="javascript:void(0);" onclick="myHeight.toggle();"><img src="../images/nav_toggle_darker.jpg" width="154" height="43" border="0" title="Toggle Table of Contents" alt="Toggle Table of Contents" /></a></div>
+<div id="masthead">
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td><h1>CodeIgniter User Guide Version 2.0.2</h1></td>
+<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
+</tr>
+</table>
+</div>
+<!-- END NAVIGATION -->
+
+
+<!-- START BREADCRUMB -->
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td id="breadcrumb">
+<a href="http://codeigniter.com/">CodeIgniter Home</a> &nbsp;&#8250;&nbsp;
+<a href="../index.html">User Guide Home</a> &nbsp;&#8250;&nbsp;
+Hooks - Extending the Framework Core
+</td>
+<td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="codeigniter.com/user_guide/" />Search User Guide&nbsp; <input type="text" class="input" style="width:200px;" name="q" id="q" size="31" maxlength="255" value="" />&nbsp;<input type="submit" class="submit" name="sa" value="Go" /></form></td>
+</tr>
+</table>
+<!-- END BREADCRUMB -->
+
+<br clear="all" />
+
+
+<!-- START CONTENT -->
+<div id="content">
+
+<h1>Hooks - Extending the Framework Core</h1>
+
+<p>CodeIgniter's Hooks feature provides a means to tap into and modify the inner workings of the framework without hacking the core files.
+When CodeIgniter runs it follows a specific execution process, diagramed in the <a href="../overview/appflow.html">Application Flow</a> page.
+There may be instances, however, where you'd like to cause some action to take place at a particular stage in the execution process.
+For example, you might want to run a script right before your controllers get loaded, or right after, or you might want to trigger one of
+your own scripts in some other location.
+</p>
+
+<h2>Enabling Hooks</h2>
+
+<p>The hooks feature can be globally enabled/disabled by setting the following item in the <kbd>application/config/config.php</kbd> file:</p>
+
+<code>$config['enable_hooks'] = TRUE;</code>
+
+
+<h2>Defining a Hook</h2>
+
+<p>Hooks are defined in <dfn>application/config/hooks.php</dfn> file.  Each hook is specified as an array with this prototype:</p>
+
+<code>
+$hook['pre_controller'] = array(<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'class'&nbsp;&nbsp;&nbsp;&nbsp;=> 'MyClass',<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'function' => 'Myfunction',<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'filename' => 'Myclass.php',<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'filepath' => 'hooks',<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'params'&nbsp;&nbsp;&nbsp;=> array('beer', 'wine', 'snacks')<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;);</code>
+
+<p><strong>Notes:</strong><br />The array index correlates to the name of the particular hook point you want to
+use.  In the above example the hook point is <kbd>pre_controller</kbd>. A list of hook points is found below.
+The following items should be defined in your associative hook array:</p>
+
+<ul>
+<li><strong>class</strong>&nbsp; The name of the class you wish to invoke. If you prefer to use a procedural function instead of a class, leave this item blank.</li>
+<li><strong>function</strong>&nbsp; The function name you wish to call.</li>
+<li><strong>filename</strong>&nbsp; The file name containing your class/function.</li>
+<li><strong>filepath</strong>&nbsp; The name of the directory containing your script.  Note: Your script must be located in a directory INSIDE your <kbd>application</kbd> folder, so the file path is relative to that folder.  For example, if your script is located in <dfn>application/hooks</dfn>, you will simply use <samp>hooks</samp> as your filepath.  If your script is located in <dfn>application/hooks/utilities</dfn> you will use <samp>hooks/utilities</samp> as your filepath. No trailing slash.</li>
+<li><strong>params</strong>&nbsp; Any parameters you wish to pass to your script. This item is optional.</li>
+</ul>
+
+
+<h2>Multiple Calls to the Same Hook</h2>
+
+<p>If want to use the same hook point with more then one script, simply make your array declaration multi-dimensional, like this:</p>
+
+<code>
+$hook['pre_controller']<kbd>[]</kbd> = array(<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'class'&nbsp;&nbsp;&nbsp;&nbsp;=> 'MyClass',<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'function' => 'Myfunction',<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'filename' => 'Myclass.php',<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'filepath' => 'hooks',<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'params'&nbsp;&nbsp;&nbsp;=> array('beer', 'wine', 'snacks')<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;);<br />
+<br />
+$hook['pre_controller']<kbd>[]</kbd> = array(<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'class'&nbsp;&nbsp;&nbsp;&nbsp;=> 'MyOtherClass',<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'function' => 'MyOtherfunction',<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'filename' => 'Myotherclass.php',<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'filepath' => 'hooks',<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'params'&nbsp;&nbsp;&nbsp;=> array('red', 'yellow', 'blue')<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;);</code>
+
+<p>Notice the brackets after each array index:</p>
+
+<code>$hook['pre_controller']<kbd>[]</kbd></code>
+
+<p>This permits you to have the same hook point with multiple scripts.  The order you define your array will be the execution order.</p>
+
+
+<h2>Hook Points</h2>
+
+<p>The following is a list of available hook points.</p>
+
+<ul>
+               <li><strong>pre_system</strong><br />
+                       Called very early during system execution.  Only the benchmark and hooks class have been loaded at this point. No routing or other processes have happened.</li>
+               <li><strong>pre_controller</strong><br />
+                       Called immediately prior to any of your controllers being called. All base classes, routing, and security checks have been done.</li>
+               <li><strong>post_controller_constructor</strong><br />
+                       Called immediately after your controller is instantiated, but prior to any method calls happening.</li>
+               <li><strong>post_controller</strong><br />
+                       Called immediately after your controller is fully executed.</li>
+               <li><strong>display_override</strong><br />
+                       Overrides the <dfn>_display()</dfn> function, used to send the finalized page to the web browser at the end of system execution.  This permits you to
+                       use your own display methodology.  Note that you will need to reference the CI superobject with <dfn>$this->CI =&amp; get_instance()</dfn> and then the finalized data will be available by calling <dfn>$this->CI->output->get_output()</dfn></li>
+               <li><strong>cache_override</strong><br />
+                       Enables you to call your own function instead of the <dfn>_display_cache()</dfn> function in the output class.  This permits you to use your own cache display mechanism.</li>
+               <li><strong>post_system</strong><br />
+                       Called after the final rendered page is sent to the browser, at the end of system execution after the finalized data is sent to the browser.</li>
+       </ul>
+</div>
+<!-- END CONTENT -->
+
+
+<div id="footer">
+<p>
+Previous Topic:&nbsp;&nbsp;<a href="core_classes.html">Creating Core Classes</a>
+&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+<a href="#top">Top of Page</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+<a href="../index.html">User Guide Home</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+Next Topic:&nbsp;&nbsp;<a href="autoloader.html">Auto-loading Resources</a>
+</p>
+<p><a href="http://codeigniter.com">CodeIgniter</a> &nbsp;&middot;&nbsp; Copyright &#169; 2006 - 2011 &nbsp;&middot;&nbsp; <a href="http://ellislab.com/">EllisLab, Inc.</a></p>
+</div>
+
+</body>
+</html>
\ No newline at end of file
diff --git a/user_guide/general/libraries.html b/user_guide/general/libraries.html
new file mode 100755 (executable)
index 0000000..ce367cd
--- /dev/null
@@ -0,0 +1,98 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head>
+
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+<title>Using CodeIgniter Libraries : CodeIgniter User Guide</title>
+
+<style type='text/css' media='all'>@import url('../userguide.css');</style>
+<link rel='stylesheet' type='text/css' media='all' href='../userguide.css' />
+
+<script type="text/javascript" src="../nav/nav.js"></script>
+<script type="text/javascript" src="../nav/prototype.lite.js"></script>
+<script type="text/javascript" src="../nav/moo.fx.js"></script>
+<script type="text/javascript" src="../nav/user_guide_menu.js"></script>
+
+<meta http-equiv='expires' content='-1' />
+<meta http-equiv= 'pragma' content='no-cache' />
+<meta name='robots' content='all' />
+<meta name='author' content='ExpressionEngine Dev Team' />
+<meta name='description' content='CodeIgniter User Guide' />
+
+</head>
+<body>
+
+<!-- START NAVIGATION -->
+<div id="nav"><div id="nav_inner"><script type="text/javascript">create_menu('../');</script></div></div>
+<div id="nav2"><a name="top"></a><a href="javascript:void(0);" onclick="myHeight.toggle();"><img src="../images/nav_toggle_darker.jpg" width="154" height="43" border="0" title="Toggle Table of Contents" alt="Toggle Table of Contents" /></a></div>
+<div id="masthead">
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td><h1>CodeIgniter User Guide Version 2.0.2</h1></td>
+<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
+</tr>
+</table>
+</div>
+<!-- END NAVIGATION -->
+
+
+<!-- START BREADCRUMB -->
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td id="breadcrumb">
+<a href="http://codeigniter.com/">CodeIgniter Home</a> &nbsp;&#8250;&nbsp;
+<a href="../index.html">User Guide Home</a> &nbsp;&#8250;&nbsp;
+Using CodeIgniter Libraries
+</td>
+<td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="codeigniter.com/user_guide/" />Search User Guide&nbsp; <input type="text" class="input" style="width:200px;" name="q" id="q" size="31" maxlength="255" value="" />&nbsp;<input type="submit" class="submit" name="sa" value="Go" /></form></td>
+</tr>
+</table>
+<!-- END BREADCRUMB -->
+
+<br clear="all" />
+
+
+<!-- START CONTENT -->
+<div id="content">
+
+<h1>Using CodeIgniter Libraries</h1>
+
+
+<p>All of the available libraries are located in your <dfn>system/libraries</dfn> folder.
+In most cases, to use one of these classes involves initializing it within a <a href="controllers.html">controller</a> using the following initialization function:</p>
+
+<code>$this->load->library('<var>class name</var>'); </code>
+
+<p>Where <var>class name</var> is the name of the class you want to invoke.  For example, to load the form validation class you would do this:</p>
+
+<code>$this->load->library('<var>form_validation</var>'); </code>
+
+<p>Once initialized you can use it as indicated in the user guide page corresponding to that class.</p>
+
+<p>Additionally, multiple libraries can be loaded at the same time by passing an array of libraries to the load function.</p>
+
+<code>$this->load->library(array('<var>email</var>', '<var>table</var>'));</code>
+
+<h2>Creating Your Own Libraries</h2>
+
+<p>Please read the section of the user guide that discusses how to <a href="creating_libraries.html">create your own libraries</a></p>
+
+
+
+</div>
+<!-- END CONTENT -->
+
+
+<div id="footer">
+<p>
+Previous Topic:&nbsp;&nbsp;<a href="helpers.html">Helpers</a>
+&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+<a href="#top">Top of Page</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+<a href="../index.html">User Guide Home</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+Next Topic:&nbsp;&nbsp;<a href="creating_libraries.html">Creating Libraries</a>
+</p>
+<p><a href="http://codeigniter.com">CodeIgniter</a> &nbsp;&middot;&nbsp; Copyright &#169; 2006 - 2011 &nbsp;&middot;&nbsp; <a href="http://ellislab.com/">EllisLab, Inc.</a></p>
+</div>
+
+</body>
+</html>
\ No newline at end of file
diff --git a/user_guide/general/managing_apps.html b/user_guide/general/managing_apps.html
new file mode 100755 (executable)
index 0000000..ea886d9
--- /dev/null
@@ -0,0 +1,133 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head>
+
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+<title>Managing your Applications : CodeIgniter User Guide</title>
+
+<style type='text/css' media='all'>@import url('../userguide.css');</style>
+<link rel='stylesheet' type='text/css' media='all' href='../userguide.css' />
+
+<script type="text/javascript" src="../nav/nav.js"></script>
+<script type="text/javascript" src="../nav/prototype.lite.js"></script>
+<script type="text/javascript" src="../nav/moo.fx.js"></script>
+<script type="text/javascript" src="../nav/user_guide_menu.js"></script>
+
+<meta http-equiv='expires' content='-1' />
+<meta http-equiv= 'pragma' content='no-cache' />
+<meta name='robots' content='all' />
+<meta name='author' content='ExpressionEngine Dev Team' />
+<meta name='description' content='CodeIgniter User Guide' />
+
+</head>
+<body>
+
+<!-- START NAVIGATION -->
+<div id="nav"><div id="nav_inner"><script type="text/javascript">create_menu('../');</script></div></div>
+<div id="nav2"><a name="top"></a><a href="javascript:void(0);" onclick="myHeight.toggle();"><img src="../images/nav_toggle_darker.jpg" width="154" height="43" border="0" title="Toggle Table of Contents" alt="Toggle Table of Contents" /></a></div>
+<div id="masthead">
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td><h1>CodeIgniter User Guide Version 2.0.2</h1></td>
+<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
+</tr>
+</table>
+</div>
+<!-- END NAVIGATION -->
+
+
+<!-- START BREADCRUMB -->
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td id="breadcrumb">
+<a href="http://codeigniter.com/">CodeIgniter Home</a> &nbsp;&#8250;&nbsp;
+<a href="../index.html">User Guide Home</a> &nbsp;&#8250;&nbsp;
+Managing your Applications
+</td>
+<td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="codeigniter.com/user_guide/" />Search User Guide&nbsp; <input type="text" class="input" style="width:200px;" name="q" id="q" size="31" maxlength="255" value="" />&nbsp;<input type="submit" class="submit" name="sa" value="Go" /></form></td>
+</tr>
+</table>
+<!-- END BREADCRUMB -->
+
+<br clear="all" />
+
+
+<!-- START CONTENT -->
+<div id="content">
+
+<h1>Managing your Applications</h1>
+
+<p>By default it is assumed that you only intend to use CodeIgniter to manage one application, which you will build in your
+<dfn>application/</dfn> directory.  It is possible, however, to have multiple sets of applications that share a single
+CodeIgniter installation, or even to rename or relocate your <dfn>application</dfn> folder.</p>
+
+<h2>Renaming the Application Folder</h2>
+
+<p>If you would like to rename your <dfn>application</dfn> folder you may do so as long as you open your main <kbd>index.php</kbd>
+file and set its name using the <samp>$application_folder</samp> variable:</p>
+
+<code>$application_folder = "application";</code>
+
+<h2>Relocating your Application Folder</h2>
+
+<p>It is possible to move your <dfn>application</dfn> folder to a different location on your server than your <kbd>system</kbd> folder.
+To do so open your main <kbd>index.php</kbd> and set a <em>full server path</em> in the <samp>$application_folder</samp> variable.</p>
+
+
+<code>$application_folder = "/Path/to/your/application";</code>
+
+
+<h2>Running Multiple Applications with one CodeIgniter Installation</h2>
+
+<p>If you would like to share a common CodeIgniter installation to manage several different applications simply
+put all of the directories located inside your <kbd>application</kbd> folder into their
+own sub-folder.</p>
+
+<p>For example, let's say you want to create two applications, "foo" and "bar".  You could structure your
+application folders like this:</p>
+
+<code>applications/<var>foo</var>/<br />
+applications/<var>foo</var>/config/<br />
+applications/<var>foo</var>/controllers/<br />
+applications/<var>foo</var>/errors/<br />
+applications/<var>foo</var>/libraries/<br />
+applications/<var>foo</var>/models/<br />
+applications/<var>foo</var>/views/<br />
+applications/<samp>bar</samp>/<br />
+applications/<samp>bar</samp>/config/<br />
+applications/<samp>bar</samp>/controllers/<br />
+applications/<samp>bar</samp>/errors/<br />
+applications/<samp>bar</samp>/libraries/<br />
+applications/<samp>bar</samp>/models/<br />
+applications/<samp>bar</samp>/views/</code>
+
+
+<p>To select a particular application for use requires that you open your main <kbd>index.php</kbd> file and set the <dfn>$application_folder</dfn>
+variable.  For example, to select the "foo" application for use you would do this:</p>
+
+<code>$application_folder = "applications/foo";</code>
+
+<p class="important"><strong>Note:</strong>&nbsp; Each of your applications will need its own <dfn>index.php</dfn> file which
+calls the desired application.  The index.php file can be named anything you want.</p>
+
+
+
+
+
+</div>
+<!-- END CONTENT -->
+
+
+<div id="footer">
+<p>
+Previous Topic:&nbsp;&nbsp;<a href="profiling.html">Profiling Your Application</a>
+&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+<a href="#top">Top of Page</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+<a href="../index.html">User Guide Home</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+Next Topic:&nbsp;&nbsp;<a href="alternative_php.html">Alternative PHP Syntax</a>
+</p>
+<p><a href="http://codeigniter.com">CodeIgniter</a> &nbsp;&middot;&nbsp; Copyright &#169; 2006 - 2011 &nbsp;&middot;&nbsp; <a href="http://ellislab.com/">EllisLab, Inc.</a></p>
+</div>
+
+</body>
+</html>
\ No newline at end of file
diff --git a/user_guide/general/models.html b/user_guide/general/models.html
new file mode 100755 (executable)
index 0000000..117c810
--- /dev/null
@@ -0,0 +1,251 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head>
+
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+<title>Models : CodeIgniter User Guide</title>
+
+<style type='text/css' media='all'>@import url('../userguide.css');</style>
+<link rel='stylesheet' type='text/css' media='all' href='../userguide.css' />
+
+<script type="text/javascript" src="../nav/nav.js"></script>
+<script type="text/javascript" src="../nav/prototype.lite.js"></script>
+<script type="text/javascript" src="../nav/moo.fx.js"></script>
+<script type="text/javascript" src="../nav/user_guide_menu.js"></script>
+
+<meta http-equiv='expires' content='-1' />
+<meta http-equiv= 'pragma' content='no-cache' />
+<meta name='robots' content='all' />
+<meta name='author' content='ExpressionEngine Dev Team' />
+<meta name='description' content='CodeIgniter User Guide' />
+</head>
+<body>
+
+<!-- START NAVIGATION -->
+<div id="nav"><div id="nav_inner"><script type="text/javascript">create_menu('../');</script></div></div>
+<div id="nav2"><a name="top"></a><a href="javascript:void(0);" onclick="myHeight.toggle();"><img src="../images/nav_toggle_darker.jpg" width="154" height="43" border="0" title="Toggle Table of Contents" alt="Toggle Table of Contents" /></a></div>
+<div id="masthead">
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td><h1>CodeIgniter User Guide Version 2.0.2</h1></td>
+<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
+</tr>
+</table>
+</div>
+<!-- END NAVIGATION -->
+
+
+<!-- START BREADCRUMB -->
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td id="breadcrumb">
+<a href="http://codeigniter.com/">CodeIgniter Home</a> &nbsp;&#8250;&nbsp;
+<a href="../index.html">User Guide Home</a> &nbsp;&#8250;&nbsp;
+Models
+</td>
+<td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="codeigniter.com/user_guide/" />Search User Guide&nbsp; <input type="text" class="input" style="width:200px;" name="q" id="q" size="31" maxlength="255" value="" />&nbsp;<input type="submit" class="submit" name="sa" value="Go" /></form></td>
+</tr>
+</table>
+<!-- END BREADCRUMB -->
+
+<br clear="all" />
+
+
+<!-- START CONTENT -->
+<div id="content">
+
+<h1>Models</h1>
+
+<p>Models are <strong>optionally</strong> available for those who want to use a more traditional MVC approach.</p>
+
+
+
+<ul>
+<li><a href="#what">What is a Model?</a></li>
+<li><a href="#anatomy">Anatomy of a Model</a></li>
+<li><a href="#loading">Loading a Model</a></li>
+<li><a href="#auto_load_model">Auto-Loading a Model</a> </li>
+<li><a href="#conn">Connecting to your Database</a></li>
+</ul>
+
+
+
+<h2><a name="what"></a>What is a Model?</h2>
+
+<p>Models are PHP classes that are designed to work with information in your database.  For example, let's say
+you use CodeIgniter to manage a blog.  You might have a model class that contains functions to insert, update, and
+retrieve your blog data. Here is an example of what such a model class might look like:</p>
+
+<code>
+class&nbsp;Blogmodel&nbsp;extends&nbsp;CI_Model&nbsp;{<br />
+<br />
+&nbsp;&nbsp;&nbsp;&nbsp;var $title&nbsp;&nbsp; = '';<br />
+&nbsp;&nbsp;&nbsp;&nbsp;var $content = '';<br />
+&nbsp;&nbsp;&nbsp;&nbsp;var $date&nbsp;&nbsp;&nbsp; = '';<br />
+<br />
+&nbsp;&nbsp;&nbsp;&nbsp;function&nbsp;__construct()<br />
+&nbsp;&nbsp;&nbsp;&nbsp;{<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// Call the Model constructor<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;parent::__construct();<br />
+&nbsp;&nbsp;&nbsp;&nbsp;}<br />
+&nbsp;&nbsp;&nbsp;&nbsp;<br />
+&nbsp;&nbsp;&nbsp;&nbsp;function&nbsp;get_last_ten_entries()<br />
+&nbsp;&nbsp;&nbsp;&nbsp;{<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$query = $this->db->get('entries', 10);<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return $query->result();<br />
+&nbsp;&nbsp;&nbsp;&nbsp;}<br />
+<br />
+&nbsp;&nbsp;&nbsp;&nbsp;function&nbsp;insert_entry()<br />
+&nbsp;&nbsp;&nbsp;&nbsp;{<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$this->title&nbsp;&nbsp; = $_POST['title']; // please read the below note<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$this->content = $_POST['content'];<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$this->date&nbsp;&nbsp;&nbsp; = time();<br />
+<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$this->db->insert('entries',&nbsp;$this);<br />
+&nbsp;&nbsp;&nbsp;&nbsp;}<br />
+<br />
+&nbsp;&nbsp;&nbsp;&nbsp;function&nbsp;update_entry()<br />
+&nbsp;&nbsp;&nbsp;&nbsp;{<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$this->title&nbsp;&nbsp; = $_POST['title'];<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$this->content = $_POST['content'];<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$this->date&nbsp;&nbsp;&nbsp; = time();<br />
+<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$this->db->update('entries',&nbsp;$this, array('id' => $_POST['id']));<br />
+&nbsp;&nbsp;&nbsp;&nbsp;}<br />
+<br />
+}</code>
+
+<p>Note: The functions in the above example use the <a href="../database/active_record.html">Active Record</a> database functions.</p>
+<p class="important"><strong>Note:</strong> For the sake of simplicity in this example we're using $_POST directly.  This is generally bad practice, and a more common approach would be to use the <a href="../libraries/input.html">Input Class</a> $this-&gt;input-&gt;post('title')</p>
+<h2><a name="anatomy"></a>Anatomy of a Model</h2>
+
+<p>Model classes are stored in your <dfn>application/models/</dfn> folder.  They can be nested within sub-folders if you
+want this type of organization.</p>
+
+<p>The basic prototype for a model class is this:</p>
+
+
+<code>
+class&nbsp;<var>Model_name</var>&nbsp;extends&nbsp;CI_Model&nbsp;{<br />
+<br />
+&nbsp;&nbsp;&nbsp;&nbsp;function&nbsp;<var>__construct</var>()<br />
+&nbsp;&nbsp;&nbsp;&nbsp;{<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;parent::__construct();<br />
+&nbsp;&nbsp;&nbsp;&nbsp;}<br />
+}</code>
+
+<p>Where <var>Model_name</var> is the name of your class.  Class names <strong>must</strong> have the first letter capitalized with the rest of the name lowercase.
+Make sure your class extends the base Model class.</p>
+
+<p>The file name will be a lower case version of your class name.  For example, if your class is this:</p>
+
+<code>
+class&nbsp;<var>User_model</var>&nbsp;extends&nbsp;CI_Model&nbsp;{<br />
+<br />
+&nbsp;&nbsp;&nbsp;&nbsp;function&nbsp;<var>__construct</var>()<br />
+&nbsp;&nbsp;&nbsp;&nbsp;{<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;parent::__construct();<br />
+&nbsp;&nbsp;&nbsp;&nbsp;}<br />
+}</code>
+
+<p>Your file will be this:</p>
+
+<code>application/models/<var>user_model.php</var></code>
+
+
+
+<h2><a name="loading"></a>Loading a Model</h2>
+
+<p>Your models will typically be loaded and called from within your <a href="controllers.html">controller</a> functions.
+To load a model you will use the following function:</p>
+
+<code>$this->load->model('<var>Model_name</var>');</code>
+
+<p>If your model is located in a sub-folder, include the relative path from your models folder.  For example, if
+you have a model located at <dfn>application/models/blog/queries.php</dfn> you'll load it using:</p>
+
+<code>$this->load->model('<var>blog/queries</var>');</code>
+
+
+<p>Once loaded, you will access your model functions using an object with the same name as your class:</p>
+
+<code>
+$this->load->model('<var>Model_name</var>');<br />
+<br />
+$this-><var>Model_name</var>->function();
+</code>
+
+<p>If you would like your model assigned to a different object name you can specify it via the second parameter of the loading
+function:</p>
+
+
+<code>
+$this->load->model('<var>Model_name</var>', '<kbd>fubar</kbd>');<br />
+<br />
+$this-><kbd>fubar</kbd>->function();
+</code>
+
+<p>Here is an example of a controller, that loads a model, then serves a view:</p>
+
+<code>
+class&nbsp;Blog_controller&nbsp;extends&nbsp;CI_Controller&nbsp;{<br />
+<br />
+&nbsp;&nbsp;&nbsp;&nbsp;function&nbsp;blog()<br />
+&nbsp;&nbsp;&nbsp;&nbsp;{<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$this->load->model('Blog');<br />
+<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$data['query'] = $this->Blog->get_last_ten_entries();<br /><br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$this->load->view('blog', $data);<br />
+&nbsp;&nbsp;&nbsp;&nbsp;}<br />
+}</code>
+
+<h2><a name="auto_load_model" id="auto_load_model"></a>Auto-loading Models</h2>
+<p>If you find that you need a particular model globally throughout your  application, you can tell CodeIgniter to auto-load it during system  initialization.  This is done by opening the application/config/autoload.php file and adding the model to the autoload array.</p>
+
+
+<h2><a name="conn"></a>Connecting to your Database</h2>
+
+<p>When a model is loaded it does <strong>NOT</strong> connect automatically to your database.  The following options for connecting are available to you:</p>
+
+<ul>
+<li>You can connect using the standard database methods <a href="../database/connecting.html">described here</a>, either from within your Controller class or your Model class.</li>
+<li>You can tell the model loading function to auto-connect by passing <kbd>TRUE</kbd> (boolean) via the third parameter,
+and connectivity settings, as defined in your database config file will be used:
+
+       <code>$this->load->model('<var>Model_name</var>', '', <kbd>TRUE</kbd>);</code>
+       </li>
+
+
+<li>You can manually pass database connectivity settings via the third parameter:
+
+
+               <code>$config['hostname'] = "localhost";<br />
+               $config['username'] = "myusername";<br />
+               $config['password'] = "mypassword";<br />
+               $config['database'] = "mydatabase";<br />
+               $config['dbdriver'] = "mysql";<br />
+               $config['dbprefix'] = "";<br />
+               $config['pconnect'] = FALSE;<br />
+               $config['db_debug'] = TRUE;<br />
+               <br />
+               $this->load->model('<var>Model_name</var>', '', <kbd>$config</kbd>);</code></li>
+</ul>
+
+
+</div>
+<!-- END CONTENT -->
+
+
+<div id="footer">
+<p>
+Previous Topic:&nbsp;&nbsp;<a href="views.html">Views</a>
+&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+<a href="#top">Top of Page</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+<a href="../index.html">User Guide Home</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+Next Topic:&nbsp;&nbsp;<a href="helpers.html">Helpers</a>
+</p>
+<p><a href="http://codeigniter.com">CodeIgniter</a> &nbsp;&middot;&nbsp; Copyright &#169; 2006 - 2011 &nbsp;&middot;&nbsp; <a href="http://ellislab.com/">EllisLab, Inc.</a></p>
+</div>
+
+</body>
+</html>
\ No newline at end of file
diff --git a/user_guide/general/profiling.html b/user_guide/general/profiling.html
new file mode 100755 (executable)
index 0000000..f3ea0c6
--- /dev/null
@@ -0,0 +1,176 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head>
+
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+<title>Profiling Your Application : CodeIgniter User Guide</title>
+
+<style type='text/css' media='all'>@import url('../userguide.css');</style>
+<link rel='stylesheet' type='text/css' media='all' href='../userguide.css' />
+
+<script type="text/javascript" src="../nav/nav.js"></script>
+<script type="text/javascript" src="../nav/prototype.lite.js"></script>
+<script type="text/javascript" src="../nav/moo.fx.js"></script>
+<script type="text/javascript" src="../nav/user_guide_menu.js"></script>
+
+<meta http-equiv='expires' content='-1' />
+<meta http-equiv= 'pragma' content='no-cache' />
+<meta name='robots' content='all' />
+<meta name='author' content='ExpressionEngine Dev Team' />
+<meta name='description' content='CodeIgniter User Guide' />
+
+</head>
+<body>
+
+<!-- START NAVIGATION -->
+<div id="nav"><div id="nav_inner"><script type="text/javascript">create_menu('../');</script></div></div>
+<div id="nav2"><a name="top"></a><a href="javascript:void(0);" onclick="myHeight.toggle();"><img src="../images/nav_toggle_darker.jpg" width="154" height="43" border="0" title="Toggle Table of Contents" alt="Toggle Table of Contents" /></a></div>
+<div id="masthead">
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td><h1>CodeIgniter User Guide Version 2.0.2</h1></td>
+<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
+</tr>
+</table>
+</div>
+<!-- END NAVIGATION -->
+
+
+<!-- START BREADCRUMB -->
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td id="breadcrumb">
+<a href="http://codeigniter.com/">CodeIgniter Home</a> &nbsp;&#8250;&nbsp;
+<a href="../index.html">User Guide Home</a> &nbsp;&#8250;&nbsp;
+Profiling Your Application
+</td>
+<td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="codeigniter.com/user_guide/" />Search User Guide&nbsp; <input type="text" class="input" style="width:200px;" name="q" id="q" size="31" maxlength="255" value="" />&nbsp;<input type="submit" class="submit" name="sa" value="Go" /></form></td>
+</tr>
+</table>
+<!-- END BREADCRUMB -->
+
+<br clear="all" />
+
+
+<!-- START CONTENT -->
+<div id="content">
+
+
+<h1>Profiling Your Application</h1>
+
+<p>The Profiler Class will display benchmark results, queries you have run, and $_POST data at the bottom of your pages.
+This information can be useful during development in order to help with debugging and optimization.</p>
+
+
+<h2>Initializing the Class</h2>
+
+<p class="important"><strong>Important:</strong>&nbsp; This class does <kbd>NOT</kbd> need to be initialized. It is loaded automatically by the
+<a href="../libraries/output.html">Output Class</a> if profiling is enabled as shown below.</p>
+
+<h2>Enabling the Profiler</h2>
+
+       <p>To enable the profiler place the following function anywhere within your <a href="controllers.html">Controller</a> functions:</p>
+       <code>$this->output->enable_profiler(TRUE);</code>
+
+       <p>When enabled a report will be generated and inserted at the bottom of your pages.</p>
+
+       <p>To disable the profiler you will use:</p>
+       <code>$this->output->enable_profiler(FALSE);</code>
+
+
+<h2>Setting Benchmark Points</h2>
+
+       <p>In order for the Profiler to compile and display your benchmark data you must name your mark points using specific syntax.</p>
+
+       <p>Please read the information on setting Benchmark points in <a href="../libraries/benchmark.html">Benchmark Class</a> page.</p>
+
+
+<h2>Enabling and Disabling Profiler Sections</h2>
+
+       <p>Each section of Profiler data can be enabled or disabled by setting a corresponding config variable to <var>TRUE</var> or <var>FALSE</var>.  This can be done one of two ways.  First, you can set application wide defaults with the <dfn>application/config/profiler.php</dfn> config file.</p>
+
+       <code>$config['config']&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;= FALSE;<br />
+       $config['queries']&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;= FALSE;<br /></code>
+
+       <p>In your controllers, you can override the defaults and config file values by calling the <kbd>set_profiler_sections()</kbd> method of the <a href="../libraries/output.html">Output class</a>:</p>
+
+       <code>$sections = array(<br />
+       &nbsp;&nbsp;&nbsp;&nbsp;'config' &nbsp;=> TRUE,<br />
+       &nbsp;&nbsp;&nbsp;&nbsp;'queries' => TRUE<br />
+       &nbsp;&nbsp;&nbsp;&nbsp;);<br />
+       <br />
+       $this->output->set_profiler_sections($sections);</code>
+
+       <p>Available sections and the array key used to access them are described in the table below.</p>
+
+       <table cellpadding="0" cellspacing="1" border="0" style="width:100%" class="tableborder">
+               <tr>
+               <th>Key</th>
+               <th>Description</th>
+               <th>Default</th>
+               </tr><tr>
+
+               <td class="td"><strong>benchmarks</strong></td>
+               <td class="td">Elapsed time of Benchmark points and total execution time</td>
+               <td class="td">TRUE</td>
+               </tr><tr>
+
+               <td class="td"><strong>config</strong></td>
+               <td class="td">CodeIgniter Config variables</td>
+               <td class="td">TRUE</td>
+               </tr><tr>
+
+               <td class="td"><strong>controller_info</strong></td>
+               <td class="td">The Controller class and method requested</td>
+               <td class="td">TRUE</td>
+               </tr><tr>
+
+               <td class="td"><strong>get</strong></td>
+               <td class="td">Any GET data passed in the request</td>
+               <td class="td">TRUE</td>
+               </tr><tr>
+
+               <td class="td"><strong>http_headers</strong></td>
+               <td class="td">The HTTP headers for the current request</td>
+               <td class="td">TRUE</td>
+               </tr><tr>
+
+               <td class="td"><strong>memory_usage</strong></td>
+               <td class="td">Amount of memory consumed by the current request, in bytes</td>
+               <td class="td">TRUE</td>
+               </tr><tr>
+
+               <td class="td"><strong>post</strong></td>
+               <td class="td">Any POST data passed in the request</td>
+               <td class="td">TRUE</td>
+               </tr><tr>
+
+               <td class="td"><strong>queries</strong></td>
+               <td class="td">Listing of all database queries executed, including execution time</td>
+               <td class="td">TRUE</td>
+               </tr><tr>
+
+               <td class="td"><strong>uri_string</strong></td>
+               <td class="td">The URI of the current request</td>
+               <td class="td">TRUE</td>
+               </tr><tr>
+       </table>
+
+
+</div>
+<!-- END CONTENT -->
+
+
+<div id="footer">
+<p>
+Previous Topic:&nbsp;&nbsp;<a href="caching.html">Caching</a>
+&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+<a href="#top">Top of Page</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+<a href="../index.html">User Guide Home</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+Next Topic:&nbsp;&nbsp;<a href="managing_apps.html">Managing Applications</a>
+</p>
+<p><a href="http://codeigniter.com">CodeIgniter</a> &nbsp;&middot;&nbsp; Copyright &#169; 2006 - 2011 &nbsp;&middot;&nbsp; <a href="http://ellislab.com/">EllisLab, Inc.</a></p>
+</div>
+
+</body>
+</html>
\ No newline at end of file
diff --git a/user_guide/general/quick_reference.html b/user_guide/general/quick_reference.html
new file mode 100755 (executable)
index 0000000..9273708
--- /dev/null
@@ -0,0 +1,77 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head>
+
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+<title>Quick Reference Chart : CodeIgniter User Guide</title>
+
+<style type='text/css' media='all'>@import url('../userguide.css');</style>
+<link rel='stylesheet' type='text/css' media='all' href='../userguide.css' />
+
+<script type="text/javascript" src="../nav/nav.js"></script>
+<script type="text/javascript" src="../nav/prototype.lite.js"></script>
+<script type="text/javascript" src="../nav/moo.fx.js"></script>
+<script type="text/javascript" src="../nav/user_guide_menu.js"></script>
+
+<meta http-equiv='expires' content='-1' />
+<meta http-equiv= 'pragma' content='no-cache' />
+<meta name='robots' content='all' />
+<meta name='author' content='ExpressionEngine Dev Team' />
+<meta name='description' content='CodeIgniter User Guide' />
+
+</head>
+<body>
+
+<!-- START NAVIGATION -->
+<div id="nav"><div id="nav_inner"><script type="text/javascript">create_menu('../');</script></div></div>
+<div id="nav2"><a name="top"></a><a href="javascript:void(0);" onclick="myHeight.toggle();"><img src="../images/nav_toggle_darker.jpg" width="154" height="43" border="0" title="Toggle Table of Contents" alt="Toggle Table of Contents" /></a></div>
+<div id="masthead">
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td><h1>CodeIgniter User Guide Version 2.0.2</h1></td>
+<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
+</tr>
+</table>
+</div>
+<!-- END NAVIGATION -->
+
+
+<!-- START BREADCRUMB -->
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td id="breadcrumb">
+<a href="http://codeigniter.com/">CodeIgniter Home</a> &nbsp;&#8250;&nbsp;
+<a href="../index.html">User Guide Home</a> &nbsp;&#8250;&nbsp;
+Quick Reference Chart
+</td>
+<td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="codeigniter.com/user_guide/" />Search User Guide&nbsp; <input type="text" class="input" style="width:200px;" name="q" id="q" size="31" maxlength="255" value="" />&nbsp;<input type="submit" class="submit" name="sa" value="Go" /></form></td>
+</tr>
+</table>
+<!-- END BREADCRUMB -->
+
+<br clear="all" />
+
+
+<!-- START CONTENT -->
+<div id="content">
+
+<h1>Quick Reference Chart</h1>
+
+<p>For a PDF version of this chart, <a href="http://codeigniter.com/download_files/ci_quick_ref.pdf">click here</a>.</p>
+
+<p><img src="../images/ci_quick_ref.png" width="763" height="994" border="0" /></p>
+
+</div>
+<!-- END CONTENT -->
+
+
+<div id="footer">
+<p>
+<a href="#top">Top of Page</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+<a href="../index.html">User Guide Home</a>
+</p>
+<p><a href="http://codeigniter.com">CodeIgniter</a> &nbsp;&middot;&nbsp; Copyright &#169; 2006 - 2011 &nbsp;&middot;&nbsp; <a href="http://ellislab.com/">EllisLab, Inc.</a></p>
+</div>
+
+</body>
+</html>
\ No newline at end of file
diff --git a/user_guide/general/requirements.html b/user_guide/general/requirements.html
new file mode 100755 (executable)
index 0000000..ab0e288
--- /dev/null
@@ -0,0 +1,82 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head>
+
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+<title>Server Requirements : CodeIgniter User Guide</title>
+
+<style type='text/css' media='all'>@import url('../userguide.css');</style>
+<link rel='stylesheet' type='text/css' media='all' href='../userguide.css' />
+
+<script type="text/javascript" src="../nav/nav.js"></script>
+<script type="text/javascript" src="../nav/prototype.lite.js"></script>
+<script type="text/javascript" src="../nav/moo.fx.js"></script>
+<script type="text/javascript" src="../nav/user_guide_menu.js"></script>
+
+<meta http-equiv='expires' content='-1' />
+<meta http-equiv= 'pragma' content='no-cache' />
+<meta name='robots' content='all' />
+<meta name='author' content='ExpressionEngine Dev Team' />
+<meta name='description' content='CodeIgniter User Guide' />
+
+</head>
+<body>
+
+<!-- START NAVIGATION -->
+<div id="nav"><div id="nav_inner"><script type="text/javascript">create_menu('../');</script></div></div>
+<div id="nav2"><a name="top"></a><a href="javascript:void(0);" onclick="myHeight.toggle();"><img src="../images/nav_toggle_darker.jpg" width="154" height="43" border="0" title="Toggle Table of Contents" alt="Toggle Table of Contents" /></a></div>
+<div id="masthead">
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td><h1>CodeIgniter User Guide Version 2.0.2</h1></td>
+<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
+</tr>
+</table>
+</div>
+<!-- END NAVIGATION -->
+
+
+<!-- START BREADCRUMB -->
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td id="breadcrumb">
+<a href="http://codeigniter.com/">CodeIgniter Home</a> &nbsp;&#8250;&nbsp;
+<a href="../index.html">User Guide Home</a> &nbsp;&#8250;&nbsp;
+Server Requirements
+</td>
+<td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="codeigniter.com/user_guide/" />Search User Guide&nbsp; <input type="text" class="input" style="width:200px;" name="q" id="q" size="31" maxlength="255" value="" />&nbsp;<input type="submit" class="submit" name="sa" value="Go" /></form></td>
+</tr>
+</table>
+<!-- END BREADCRUMB -->
+
+<br clear="all" />
+
+
+<!-- START CONTENT -->
+<div id="content">
+
+<h1>Server Requirements</h1>
+
+<ul>
+       <li><a href="http://www.php.net/">PHP</a> version 5.1.6 or newer.</li>
+       <li>A Database is required for most web application programming. Current supported databases are MySQL (4.1+), MySQLi, MS SQL, Postgres, Oracle, SQLite, and ODBC.</li>
+</ul>
+
+
+
+</div>
+<!-- END CONTENT -->
+
+
+
+<div id="footer">
+<p>
+<a href="#top">Top of Page</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+<a href="../index.html">User Guide Home</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+Next Topic:&nbsp;&nbsp;<a href="../license.html">License Agreement</a>
+</p>
+<p><a href="http://codeigniter.com">CodeIgniter</a> &nbsp;&middot;&nbsp; Copyright &#169; 2006 - 2011 &nbsp;&middot;&nbsp; <a href="http://ellislab.com/">EllisLab, Inc.</a></p>
+</div>
+
+</body>
+</html>
\ No newline at end of file
diff --git a/user_guide/general/reserved_names.html b/user_guide/general/reserved_names.html
new file mode 100755 (executable)
index 0000000..d1ee295
--- /dev/null
@@ -0,0 +1,127 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head>
+
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+<title>Reserved Names : CodeIgniter User Guide</title>
+
+<style type='text/css' media='all'>@import url('../userguide.css');</style>
+<link rel='stylesheet' type='text/css' media='all' href='../userguide.css' />
+
+<script type="text/javascript" src="../nav/nav.js"></script>
+<script type="text/javascript" src="../nav/prototype.lite.js"></script>
+<script type="text/javascript" src="../nav/moo.fx.js"></script>
+<script type="text/javascript" src="../nav/user_guide_menu.js"></script>
+
+<meta http-equiv='expires' content='-1' />
+<meta http-equiv= 'pragma' content='no-cache' />
+<meta name='robots' content='all' />
+<meta name='author' content='ExpressionEngine Dev Team' />
+<meta name='description' content='CodeIgniter User Guide' />
+
+</head>
+<body>
+
+<!-- START NAVIGATION -->
+<div id="nav"><div id="nav_inner"><script type="text/javascript">create_menu('../');</script></div></div>
+<div id="nav2"><a name="top"></a><a href="javascript:void(0);" onclick="myHeight.toggle();"><img src="../images/nav_toggle_darker.jpg" width="154" height="43" border="0" title="Toggle Table of Contents" alt="Toggle Table of Contents" /></a></div>
+<div id="masthead">
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td><h1>CodeIgniter User Guide Version 2.0.2</h1></td>
+<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
+</tr>
+</table>
+</div>
+<!-- END NAVIGATION -->
+
+
+<!-- START BREADCRUMB -->
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td id="breadcrumb">
+<a href="http://codeigniter.com/">CodeIgniter Home</a> &nbsp;&#8250;&nbsp;
+<a href="../index.html">User Guide Home</a> &nbsp;&#8250;&nbsp;
+Controllers
+</td>
+<td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="codeigniter.com/user_guide/" />Search User Guide&nbsp; <input type="text" class="input" style="width:200px;" name="q" id="q" size="31" maxlength="255" value="" />&nbsp;<input type="submit" class="submit" name="sa" value="Go" /></form></td>
+</tr>
+</table>
+<!-- END BREADCRUMB -->
+
+<br clear="all" />
+
+
+<!-- START CONTENT -->
+<div id="content">
+
+<h1>Reserved Names</h1>
+
+<p>In order to help out, CodeIgniter uses a series of functions and names in its operation. Because of this, some names cannot be used by a developer. Following is a list of reserved names that cannot be used.</p>
+<h3>Controller names</h3>
+<p>Since your controller classes will extend the main application controller you
+must be careful not to name your functions identically to the ones used by that class, otherwise your local functions
+will override them.  The following
+is a list of reserved names.  Do not name your controller any of these:</p>
+<ul>
+       <li>Controller</li>
+       <li>CI_Base</li>
+       <li>_ci_initialize</li>
+       <li>Default</li>
+       <li>index</li>
+</ul>
+<h3>Functions</h3>
+<ul>
+       <li>is_really_writable()</li>
+       <li>load_class()</li>
+       <li>get_config()</li>
+       <li>config_item()</li>
+       <li>show_error()</li>
+       <li>show_404()</li>
+       <li>log_message()</li>
+       <li>_exception_handler()</li>
+       <li>get_instance()</li>
+       </ul>
+<h3>Variables</h3>
+<ul>
+       <li>$config</li>
+       <li>$mimes</li>
+       <li>$lang</li>
+</ul>
+<h3>Constants</h3>
+<ul>
+       <li>EXT</li>
+       <li>FCPATH</li>
+       <li>SELF</li>
+       <li>BASEPATH</li>
+       <li>APPPATH</li>
+       <li>CI_VERSION</li>
+       <li>FILE_READ_MODE</li>
+       <li>FILE_WRITE_MODE</li>
+       <li>DIR_READ_MODE</li>
+       <li>DIR_WRITE_MODE</li>
+       <li>FOPEN_READ</li>
+       <li>FOPEN_READ_WRITE</li>
+       <li>FOPEN_WRITE_CREATE_DESTRUCTIVE</li>
+       <li>FOPEN_READ_WRITE_CREATE_DESTRUCTIVE</li>
+       <li>FOPEN_WRITE_CREATE</li>
+       <li>FOPEN_READ_WRITE_CREATE</li>
+       <li>FOPEN_WRITE_CREATE_STRICT</li>
+       <li>FOPEN_READ_WRITE_CREATE_STRICT</li>
+</ul>
+</div>
+<!-- END CONTENT -->
+
+
+<div id="footer">
+<p>
+Previous Topic:&nbsp;&nbsp;<a href="controllers.html">Controllers</a>
+&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+<a href="#top">Top of Page</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+<a href="../index.html">User Guide Home</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+Next Topic:&nbsp;&nbsp;<a href="views.html">Views</a></p>
+<p><a href="http://codeigniter.com">CodeIgniter</a> &nbsp;&middot;&nbsp; Copyright &#169; 2006 - 2011 &nbsp;&middot;&nbsp; <a href="http://ellislab.com/">EllisLab, Inc.</a></p>
+</div>
+
+</body>
+</html>
\ No newline at end of file
diff --git a/user_guide/general/routing.html b/user_guide/general/routing.html
new file mode 100755 (executable)
index 0000000..6ee6ad3
--- /dev/null
@@ -0,0 +1,166 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head>
+
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+<title>URI Routing : CodeIgniter User Guide</title>
+
+<style type='text/css' media='all'>@import url('../userguide.css');</style>
+<link rel='stylesheet' type='text/css' media='all' href='../userguide.css' />
+
+<script type="text/javascript" src="../nav/nav.js"></script>
+<script type="text/javascript" src="../nav/prototype.lite.js"></script>
+<script type="text/javascript" src="../nav/moo.fx.js"></script>
+<script type="text/javascript" src="../nav/user_guide_menu.js"></script>
+
+<meta http-equiv='expires' content='-1' />
+<meta http-equiv= 'pragma' content='no-cache' />
+<meta name='robots' content='all' />
+<meta name='author' content='ExpressionEngine Dev Team' />
+<meta name='description' content='CodeIgniter User Guide' />
+
+</head>
+<body>
+
+<!-- START NAVIGATION -->
+<div id="nav"><div id="nav_inner"><script type="text/javascript">create_menu('../');</script></div></div>
+<div id="nav2"><a name="top"></a><a href="javascript:void(0);" onclick="myHeight.toggle();"><img src="../images/nav_toggle_darker.jpg" width="154" height="43" border="0" title="Toggle Table of Contents" alt="Toggle Table of Contents" /></a></div>
+<div id="masthead">
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td><h1>CodeIgniter User Guide Version 2.0.2</h1></td>
+<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
+</tr>
+</table>
+</div>
+<!-- END NAVIGATION -->
+
+
+<!-- START BREADCRUMB -->
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td id="breadcrumb">
+<a href="http://codeigniter.com/">CodeIgniter Home</a> &nbsp;&#8250;&nbsp;
+<a href="../index.html">User Guide Home</a> &nbsp;&#8250;&nbsp;
+URI Routing
+</td>
+<td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="codeigniter.com/user_guide/" />Search User Guide&nbsp; <input type="text" class="input" style="width:200px;" name="q" id="q" size="31" maxlength="255" value="" />&nbsp;<input type="submit" class="submit" name="sa" value="Go" /></form></td>
+</tr>
+</table>
+<!-- END BREADCRUMB -->
+
+<br clear="all" />
+
+
+<!-- START CONTENT -->
+<div id="content">
+
+<h1>URI Routing</h1>
+
+<p>Typically there is a one-to-one relationship between a URL string and its corresponding controller class/method.
+The segments in a URI normally follow this pattern:</p>
+
+<code>example.com/<dfn>class</dfn>/<samp>function</samp>/<var>id</var>/</code>
+
+<p>In some instances, however, you may want to remap this relationship so that a different class/function can be called
+instead of the one corresponding to the URL.</p>
+
+<p>For example, lets say you want your URLs to have this prototype:</p>
+
+<p>
+example.com/product/1/<br />
+example.com/product/2/<br />
+example.com/product/3/<br />
+example.com/product/4/
+</p>
+
+<p>Normally the second segment of the URL is reserved for the function name, but in the example above it instead has a product ID.
+To overcome this, CodeIgniter allows you to remap the URI handler.</p>
+
+
+<h2>Setting your own routing rules</h2>
+
+<p>Routing rules are defined in your <var>application/config/routes.php</var> file.  In it you'll see an array called <dfn>$route</dfn> that
+permits you to specify your own routing criteria. Routes can either be specified using <dfn>wildcards</dfn> or <dfn>Regular Expressions</dfn></p>
+
+
+<h2>Wildcards</h2>
+
+<p>A typical wildcard route might look something like this:</p>
+
+<code>$route['product/:num'] = "catalog/product_lookup";</code>
+
+<p>In a route, the array key contains the URI to be matched, while the array value  contains the destination it should be re-routed to.
+In the above example, if the literal word "product" is found in the first segment of the URL, and a number is found in the second segment,
+the "catalog" class and the "product_lookup" method are instead used.</p>
+
+<p>You can match literal values or you can use two wildcard types:</p>
+
+<p><strong>(:num)</strong> will match a segment containing only numbers.<br />
+<strong>(:any)</strong> will match a segment containing any character.
+</p>
+
+<p class="important"><strong>Note:</strong> Routes will run in the order they are defined.
+Higher routes will always take precedence over lower ones.</p>
+
+<h2>Examples</h2>
+
+<p>Here are a few routing examples:</p>
+
+<code>$route['journals'] = "blogs";</code>
+<p>A URL containing the word "journals" in the first segment will be remapped to the "blogs" class.</p>
+
+<code>$route['blog/joe'] = "blogs/users/34";</code>
+<p>A URL containing the segments blog/joe will be remapped to the "blogs" class and the "users" method.  The ID will be set to "34".</p>
+
+<code>$route['product/(:any)'] = "catalog/product_lookup";</code>
+<p>A URL with "product" as the first segment, and anything in the second will be remapped to the "catalog" class and the  "product_lookup" method.</p>
+
+<code>$route['product/(:num)'] = "catalog/product_lookup_by_id/$1";</code>
+<p>A URL with "product" as the first segment, and a number in the second will be remapped to the "catalog" class and the "product_lookup_by_id" method passing in the match as a variable to the function.</p>
+
+<p class="important"><strong>Important:</strong> Do not use leading/trailing slashes.</p>
+
+<h2>Regular Expressions</h2>
+
+<p>If you prefer you can use regular expressions to define your routing rules.  Any valid regular expression is allowed, as are back-references.</p>
+
+<p class="important"><strong>Note:</strong>&nbsp; If you use back-references you must use the dollar syntax rather than the double backslash syntax.</p>
+
+<p>A typical RegEx route might look something like this:</p>
+
+<code>$route['products/([a-z]+)/(\d+)'] = "$1/id_$2";</code>
+
+<p>In the above example, a URI similar to <dfn>products/shirts/123</dfn> would instead call the <dfn>shirts</dfn> controller class and the <dfn>id_123</dfn> function.</p>
+
+<p>You can also mix and match wildcards with regular expressions.</p>
+
+<h2>Reserved Routes</h2>
+
+<p>There are two reserved routes:</p>
+
+<code>$route['default_controller'] = 'welcome';</code>
+
+<p>This route indicates which controller class should be loaded if the URI contains no data, which will be the case
+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.</p>
+
+<p class="important"><strong>Important:</strong>&nbsp; The reserved routes must come before any wildcard or regular expression routes.</p>
+
+</div>
+<!-- END CONTENT -->
+
+
+<div id="footer">
+<p>
+Previous Topic:&nbsp;&nbsp;<a href="common_functions.html">Common Functions</a>
+&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+<a href="#top">Top of Page</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+<a href="../index.html">User Guide Home</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+Next Topic:&nbsp;&nbsp;<a href="errors.html">Error Handling</a>
+</p>
+<p><a href="http://codeigniter.com">CodeIgniter</a> &nbsp;&middot;&nbsp; Copyright &#169; 2006 - 2011 &nbsp;&middot;&nbsp; <a href="http://ellislab.com/">EllisLab, Inc.</a></p>
+</div>
+
+</body>
+</html>
\ No newline at end of file
diff --git a/user_guide/general/security.html b/user_guide/general/security.html
new file mode 100755 (executable)
index 0000000..ab92a94
--- /dev/null
@@ -0,0 +1,170 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head>
+
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+<title>Security : CodeIgniter User Guide</title>
+
+<style type='text/css' media='all'>@import url('../userguide.css');</style>
+<link rel='stylesheet' type='text/css' media='all' href='../userguide.css' />
+
+<script type="text/javascript" src="../nav/nav.js"></script>
+<script type="text/javascript" src="../nav/prototype.lite.js"></script>
+<script type="text/javascript" src="../nav/moo.fx.js"></script>
+<script type="text/javascript" src="../nav/user_guide_menu.js"></script>
+
+<meta http-equiv='expires' content='-1' />
+<meta http-equiv= 'pragma' content='no-cache' />
+<meta name='robots' content='all' />
+<meta name='author' content='ExpressionEngine Dev Team' />
+<meta name='description' content='CodeIgniter User Guide' />
+
+</head>
+<body>
+
+<!-- START NAVIGATION -->
+<div id="nav"><div id="nav_inner"><script type="text/javascript">create_menu('../');</script></div></div>
+<div id="nav2"><a name="top"></a><a href="javascript:void(0);" onclick="myHeight.toggle();"><img src="../images/nav_toggle_darker.jpg" width="154" height="43" border="0" title="Toggle Table of Contents" alt="Toggle Table of Contents" /></a></div>
+<div id="masthead">
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td><h1>CodeIgniter User Guide Version 2.0.2</h1></td>
+<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
+</tr>
+</table>
+</div>
+<!-- END NAVIGATION -->
+
+
+<!-- START BREADCRUMB -->
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td id="breadcrumb">
+<a href="http://codeigniter.com/">CodeIgniter Home</a> &nbsp;&#8250;&nbsp;
+<a href="../index.html">User Guide Home</a> &nbsp;&#8250;&nbsp;
+Security
+</td>
+<td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="codeigniter.com/user_guide/" />Search User Guide&nbsp; <input type="text" class="input" style="width:200px;" name="q" id="q" size="31" maxlength="255" value="" />&nbsp;<input type="submit" class="submit" name="sa" value="Go" /></form></td>
+</tr>
+</table>
+<!-- END BREADCRUMB -->
+
+<br clear="all" />
+
+
+<!-- START CONTENT -->
+<div id="content">
+
+<h1>Security</h1>
+
+<p>This page describes some "best practices" regarding web security, and details
+CodeIgniter's internal security features.</p>
+
+
+<h2>URI Security</h2>
+
+<p>CodeIgniter is fairly restrictive regarding which characters it allows in your URI strings in order to help
+minimize the possibility that malicious data can be passed to your application.  URIs may only contain the following:
+</p>
+
+<ul>
+<li>Alpha-numeric text</li>
+<li>Tilde: ~ </li>
+<li>Period: .</li>
+<li>Colon: :</li>
+<li>Underscore: _</li>
+<li>Dash: -</li>
+</ul>
+
+<h2>GET, POST, and COOKIE Data</h2>
+
+<p>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 <strong>unset</strong> by the Input class during system initialization.</p>
+
+<h2>Register_globals</h2>
+
+<p>During system initialization all global variables are unset, except those found in the $_POST and $_COOKIE arrays. The unsetting
+routine is effectively the same as register_globals = off.</p>
+
+<a name="error_reporting"></a>
+<h2>error_reporting</h2>
+
+<p>
+    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.
+</p>
+
+<p>
+    Setting CodeIgniter's <kbd>ENVIRONMENT</kbd> constant in index.php to a
+    value of '<kbd>production</kbd>' will turn off these errors. In development
+    mode, it is recommended that a value of '<kbd>development</kbd>' is used.
+    More information about differentiating between environments can be found
+    on the <a href="environments.html">Handling Environments</a> page.
+</p>
+
+<h2>magic_quotes_runtime</h2>
+
+<p>The magic_quotes_runtime directive is turned off during system initialization so that you don't have to remove slashes when
+retrieving data from your database.</p>
+
+<h1>Best Practices</h1>
+
+<p>Before accepting any data into your application, whether it be POST data from a form submission, COOKIE data, URI data,
+XML-RPC data, or even data from the SERVER array, you are encouraged to practice this three step approach:</p>
+
+<ol>
+<li>Filter the data as if it were tainted.</li>
+<li>Validate the data to ensure it conforms to the correct  type, length, size, etc. (sometimes this step can replace step one)</li>
+<li>Escape the data before submitting it into your database.</li>
+</ol>
+
+<p>CodeIgniter provides the following functions to assist in this process:</p>
+
+<ul>
+
+<li><h2>XSS Filtering</h2>
+
+<p>CodeIgniter comes with a Cross Site Scripting filter.  This filter looks for commonly
+used techniques to embed malicious Javascript into your data, or other types of code that attempt to hijack cookies
+or do other malicious things. The XSS Filter is described <a href="../libraries/security.html">here</a>.
+</p>
+</li>
+
+<li><h2>Validate the data</h2>
+
+<p>CodeIgniter has a <a href="../libraries/form_validation.html">Form Validation Class</a> that assists you in validating, filtering, and prepping
+your data.</p>
+</li>
+
+<li><h2>Escape all data before database insertion</h2>
+
+<p>Never insert information into your database without escaping it. Please see the section that discusses
+<a href="../database/queries.html">queries</a> for more information.</p>
+
+</li>
+
+</ul>
+
+
+
+
+</div>
+<!-- END CONTENT -->
+
+
+<div id="footer">
+<p>
+Previous Topic:&nbsp;&nbsp;<a href="alternative_php.html">Alternative PHP</a>
+&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+<a href="#top">Top of Page</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+<a href="../index.html">User Guide Home</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+Next Topic:&nbsp;&nbsp;<a href="styleguide.html">PHP Style Guide</a>
+</p>
+<p><a href="http://codeigniter.com">CodeIgniter</a> &nbsp;&middot;&nbsp; Copyright &#169; 2006 - 2011 &nbsp;&middot;&nbsp; <a href="http://ellislab.com/">EllisLab, Inc.</a></p>
+</div>
+
+</body>
+</html>
\ No newline at end of file
diff --git a/user_guide/general/styleguide.html b/user_guide/general/styleguide.html
new file mode 100755 (executable)
index 0000000..b2b681d
--- /dev/null
@@ -0,0 +1,679 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head>
+
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+<title>Style Guide : CodeIgniter User Guide</title>
+
+<style type='text/css' media='all'>@import url('../userguide.css');</style>
+<link rel='stylesheet' type='text/css' media='all' href='../userguide.css' />
+
+<style type="text/css" media="screen">
+       code {
+               white-space: pre;
+       }
+</style>
+
+<script type="text/javascript" src="../nav/nav.js"></script>
+<script type="text/javascript" src="../nav/prototype.lite.js"></script>
+<script type="text/javascript" src="../nav/moo.fx.js"></script>
+<script type="text/javascript" src="../nav/user_guide_menu.js"></script>
+
+<meta http-equiv='expires' content='-1' />
+<meta http-equiv= 'pragma' content='no-cache' />
+<meta name='robots' content='all' />
+<meta name='author' content='ExpressionEngine Dev Team' />
+<meta name='description' content='CodeIgniter User Guide' />
+
+</head>
+<body>
+
+<!-- START NAVIGATION -->
+<div id="nav"><div id="nav_inner"><script type="text/javascript">create_menu('../');</script></div></div>
+<div id="nav2"><a name="top"></a><a href="javascript:void(0);" onclick="myHeight.toggle();"><img src="../images/nav_toggle_darker.jpg" width="154" height="43" border="0" title="Toggle Table of Contents" alt="Toggle Table of Contents" /></a></div>
+<div id="masthead">
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td><h1>CodeIgniter User Guide Version 2.0.2</h1></td>
+<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
+</tr>
+</table>
+</div>
+<!-- END NAVIGATION -->
+
+
+<!-- START BREADCRUMB -->
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td id="breadcrumb">
+<a href="http://codeigniter.com/">CodeIgniter Home</a> &nbsp;&#8250;&nbsp;
+<a href="../index.html">User Guide Home</a> &nbsp;&#8250;&nbsp;
+Style Guide
+</td>
+<td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="codeigniter.com/user_guide/" />Search User Guide&nbsp; <input type="text" class="input" style="width:200px;" name="q" id="q" size="31" maxlength="255" value="" />&nbsp;<input type="submit" class="submit" name="sa" value="Go" /></form></td>
+</tr>
+</table>
+<!-- END BREADCRUMB -->
+
+<br clear="all" />
+
+
+<!-- START CONTENT -->
+<div id="content">
+
+
+<h1>General Style and Syntax</h1>
+
+<p>The following page describes the use of coding rules adhered to when developing CodeIgniter.</p>
+
+
+<h2>Table of Contents</h2>
+<ul class="minitoc">
+       <li><a href="#file_format">File Format</a></li>
+       <li><a href="#php_closing_tag">PHP Closing Tag</a></li>
+       <li><a href="#class_and_method_naming">Class and Method Naming</a></li>
+       <li><a href="#variable_names">Variable Names</a></li>
+       <li><a href="#commenting">Commenting</a></li>
+       <li><a href="#constants">Constants</a></li>
+       <li><a href="#true_false_and_null">TRUE, FALSE, and NULL</a></li>
+       <li><a href="#logical_operators">Logical Operators</a></li>
+       <li><a href="#comparing_return_values_and_typecasting">Comparing Return Values and Typecasting</a></li>
+       <li><a href="#debugging_code">Debugging Code</a></li>
+       <li><a href="#whitespace_in_files">Whitespace in Files</a></li>
+       <li><a href="#compatibility">Compatibility</a></li>
+       <li><a href="#class_and_file_names_using_common_words">Class and File Names using Common Words</a></li>
+       <li><a href="#database_table_names">Database Table Names</a></li>
+       <li><a href="#one_file_per_class">One File per Class</a></li>
+       <li><a href="#whitespace">Whitespace</a></li>
+       <li><a href="#line_breaks">Line Breaks</a></li>
+       <li><a href="#code_indenting">Code Indenting</a></li>
+       <li><a href="#bracket_spacing">Bracket and Parenthetic Spacing</li>
+       <li><a href="#localized_text">Localized Text</a></li>
+       <li><a href="#private_methods_and_variables">Private Methods and Variables</a></li>
+       <li><a href="#php_errors">PHP Errors</a></li>
+       <li><a href="#short_open_tags">Short Open Tags</a></li>
+       <li><a href="#one_statement_per_line">One Statement Per Line</a></li>
+       <li><a href="#strings">Strings</a></li>
+       <li><a href="#sql_queries">SQL Queries</a></li>
+       <li><a href="#default_function_arguments">Default Function Arguments</a></li>
+</ul>
+
+<li>
+
+               <h2><a name="file_format"></a>File Format</h2>
+               <div class="guidelineDetails">
+                       <p>Files should be saved with Unicode (UTF-8) encoding.  The <abbr title="Byte Order Mark">BOM</abbr>
+                               should <em>not</em> be used.  Unlike UTF-16 and UTF-32, there's no byte order to indicate in
+                               a UTF-8 encoded file, and the <abbr title="Byte Order Mark">BOM</abbr> can have a negative side effect in PHP of sending output,
+                               preventing the application from being able to set its own headers.  Unix line endings should
+                               be used (LF).</p>
+
+                       <p>Here is how to apply these settings in some of the more common text editors.  Instructions for your
+                               text editor may vary; check your text editor's documentation.</p>
+
+                       <h5>TextMate</h5>
+
+                       <ol>
+                               <li>Open the Application Preferences</li>
+                               <li>Click Advanced, and then the "Saving" tab</li>
+                               <li>In "File Encoding", select "UTF-8 (recommended)"</li>
+                               <li>In "Line Endings", select "LF (recommended)"</li>
+                               <li><em>Optional:</em> Check "Use for existing files as well" if you wish to modify the line
+                                       endings of files you open to your new preference.</li>
+                       </ol>
+
+                       <h5>BBEdit</h5>
+
+                       <ol>
+                               <li>Open the Application Preferences</li>
+                               <li>Select "Text Encodings" on the left.</li>
+                               <li>In "Default text encoding for new documents", select "Unicode (UTF-8, no BOM)"</li>
+                               <li><em>Optional:</em> In "If file's encoding can't be guessed, use", select
+                                       "Unicode (UTF-8, no BOM)"</li>
+                               <li>Select "Text Files" on the left.</li>
+                               <li>In "Default line breaks", select "Mac OS X and Unix (LF)"</li>
+                       </ol>
+               </div>
+
+               <h2><a name="php_closing_tag"></a>PHP Closing Tag</h2>
+               <div class="guidelineDetails">
+                       <p>The PHP closing tag on a PHP document <strong>?&gt;</strong> is optional to the PHP parser.  However, if used, any whitespace following the closing tag, whether introduced
+                               by the developer, user, or an FTP application, can cause unwanted output, PHP errors, or if the latter are suppressed, blank pages.  For this reason, all PHP files should
+                               <strong>OMIT</strong> the closing PHP tag, and instead use a comment block to mark the end of file and it's location relative to the application root.
+                               This allows you to still identify a file as being complete and not truncated.</p>
+<code><strong>INCORRECT</strong>:
+&lt;?php
+
+echo "Here's my code!";
+
+?&gt;
+
+<strong>CORRECT</strong>:
+&lt;?php
+
+echo "Here's my code!";
+
+/* End of file myfile.php */
+/* Location: ./system/modules/mymodule/myfile.php */
+</code>
+               </div>
+
+
+               <h2><a name="class_and_method_naming"></a>Class and Method Naming</h2>
+               <div class="guidelineDetails">
+                       <p>Class names should always start with an uppercase letter.  Multiple words should be separated with an underscore, and not CamelCased.  All other class methods should be entirely lowercased and named to clearly indicate their function, preferably including a verb.  Try to avoid overly long and verbose names.</p>
+
+       <code><strong>INCORRECT</strong>:
+class superclass
+class SuperClass
+
+<strong>CORRECT</strong>:
+class Super_class</code>
+
+
+       <code>class Super_class {
+
+       function __construct()
+       {
+
+       }
+}</code>
+
+                       <p>Examples of improper and proper method naming:</p>
+
+       <code><strong>INCORRECT</strong>:
+function fileproperties()              // not descriptive and needs underscore separator
+function fileProperties()              // not descriptive and uses CamelCase
+function getfileproperties()           // Better!  But still missing underscore separator
+function getFileProperties()           // uses CamelCase
+function get_the_file_properties_from_the_file()       // wordy
+
+<strong>CORRECT</strong>:
+function get_file_properties() // descriptive, underscore separator, and all lowercase letters</code>
+
+               </div>
+
+
+               <h2><a name="variable_names"></a>Variable Names</h2>
+               <div class="guidelineDetails">
+                       <p>The guidelines for variable naming is very similar to that used for class methods.  Namely, variables should contain only lowercase letters, use underscore separators, and be reasonably named to indicate their purpose and contents. Very short, non-word variables should only be used as iterators in for() loops.</p>
+<code><strong>INCORRECT</strong>:
+$j = &apos;foo&apos;;          // single letter variables should only be used in for() loops
+$Str                   // contains uppercase letters
+$bufferedText          // uses CamelCasing, and could be shortened without losing semantic meaning
+$groupid               // multiple words, needs underscore separator
+$name_of_last_city_used        // too long
+
+<strong>CORRECT</strong>:
+for ($j = 0; $j &lt; 10; $j++)
+$str
+$buffer
+$group_id
+$last_city
+</code>
+               </div>
+
+
+               <h2><a name="commenting"></a>Commenting</h2>
+               <div class="guidelineDetails">
+                       <p>In general, code should be commented prolifically.  It not only helps describe the flow and intent of the code for less experienced programmers, but can prove invaluable when returning to your own code months down the line.  There is not a required format for comments, but the following are recommended.</p>
+
+                       <p><a href="http://manual.phpdoc.org/HTMLSmartyConverter/HandS/phpDocumentor/tutorial_phpDocumentor.howto.pkg.html#basics.docblock">DocBlock</a> style comments preceding class and method declarations so they can be picked up by IDEs:</p>
+
+<code>/**
+ * Super Class
+ *
+ * @package    Package Name
+ * @subpackage Subpackage
+ * @category   Category
+ * @author     Author Name
+ * @link       http://example.com
+ */
+class Super_class {</code>
+
+<code>/**
+ * Encodes string for use in XML
+ *
+ * @access     public
+ * @param      string
+ * @return     string
+ */
+function xml_encode($str)</code>
+
+                       <p>Use single line comments within code, leaving a blank line between large comment blocks and code.</p>
+
+<code>// break up the string by newlines
+$parts = explode("\n", $str);
+
+// A longer comment that needs to give greater detail on what is
+// occurring and why can use multiple single-line comments.  Try to
+// keep the width reasonable, around 70 characters is the easiest to
+// read.  Don't hesitate to link to permanent external resources
+// that may provide greater detail:
+//
+// http://example.com/information_about_something/in_particular/
+
+$parts = $this->foo($parts);
+</code>
+               </div>
+
+
+               <h2><a name="constants"></a>Constants</h2>
+               <div class="guidelineDetails">
+                       <p>Constants follow the same guidelines as do variables, except constants should always be fully uppercase.  <em>Always use CodeIgniter constants when appropriate, i.e. SLASH, LD, RD, PATH_CACHE, etc.</em></p>
+<code><strong>INCORRECT</strong>:
+myConstant     // missing underscore separator and not fully uppercase
+N              // no single-letter constants
+S_C_VER                // not descriptive
+$str = str_replace('{foo}', 'bar', $str);      // should use LD and RD constants
+
+<strong>CORRECT</strong>:
+MY_CONSTANT
+NEWLINE
+SUPER_CLASS_VERSION
+$str = str_replace(LD.'foo'.RD, 'bar', $str);
+</code>
+               </div>
+
+
+               <h2><a name="true_false_and_null"></a>TRUE, FALSE, and NULL</h2>
+               <div class="guidelineDetails">
+                       <p><strong>TRUE</strong>, <strong>FALSE</strong>, and <strong>NULL</strong> keywords should always be fully uppercase.</p>
+<code><strong>INCORRECT</strong>:
+if ($foo == true)
+$bar = false;
+function foo($bar = null)
+
+<strong>CORRECT</strong>:
+if ($foo == TRUE)
+$bar = FALSE;
+function foo($bar = NULL)</code>
+               </div>
+
+
+
+               <h2><a name="logical_operators"></a>Logical Operators</h2>
+               <div class="guidelineDetails">
+                       <p>Use of <strong>||</strong> is discouraged as its clarity on some output devices is low (looking like the number 11 for instance).
+                               <strong>&amp;&amp;</strong> is preferred over <strong>AND</strong> but either are acceptable, and a space should always precede and follow <strong>!</strong>.</p>
+<code><strong>INCORRECT</strong>:
+if ($foo || $bar)
+if ($foo AND $bar)  // okay but not recommended for common syntax highlighting applications
+if (!$foo)
+if (! is_array($foo))
+
+<strong>CORRECT</strong>:
+if ($foo OR $bar)
+if ($foo && $bar) // recommended
+if ( ! $foo)
+if ( ! is_array($foo))
+</code>
+               </div>
+
+
+
+               <h2><a name="comparing_return_values_and_typecasting"></a>Comparing Return Values and Typecasting</h2>
+               <div class="guidelineDetails">
+                       <p>Some PHP functions return FALSE on failure, but may also have a valid return value of "" or 0, which would evaluate to FALSE in loose comparisons.  Be explicit by comparing the variable type when using these return values in conditionals to ensure the return value is indeed what you expect, and not a value that has an equivalent loose-type evaluation.</p>
+                       <p>Use the same stringency in returning and checking your own variables.  Use <strong>===</strong> and <strong>!==</strong> as necessary.
+
+<code><strong>INCORRECT</strong>:
+// If 'foo' is at the beginning of the string, strpos will return a 0,
+// resulting in this conditional evaluating as TRUE
+if (strpos($str, 'foo') == FALSE)
+
+<strong>CORRECT</strong>:
+if (strpos($str, 'foo') === FALSE)
+</code>
+
+<code><strong>INCORRECT</strong>:
+function build_string($str = "")
+{
+       if ($str == "") // uh-oh!  What if FALSE or the integer 0 is passed as an argument?
+       {
+
+       }
+}
+
+<strong>CORRECT</strong>:
+function build_string($str = "")
+{
+       if ($str === "")
+       {
+
+       }
+}</code>
+
+               <p>See also information regarding <a href="http://us3.php.net/manual/en/language.types.type-juggling.php#language.types.typecasting">typecasting</a>, which can be quite useful.  Typecasting has a slightly different effect which may be desirable.  When casting a variable as a string, for instance, NULL and boolean FALSE variables become empty strings, 0 (and other numbers) become strings of digits, and boolean TRUE becomes "1":</p>
+
+<code>$str = (string) $str;    // cast $str as a string</code>
+
+               </div>
+
+
+               <h2><a name="debugging_code"></a>Debugging Code</h2>
+               <div class="guidelineDetails">
+                       <p>No debugging code can be left in place for submitted add-ons unless it is commented out, i.e. no var_dump(), print_r(), die(), and exit() calls that were used while creating the add-on, unless they are commented out.</p>
+
+<code>// print_r($foo);</code>
+               </div>
+
+
+
+               <h2><a name="whitespace_in_files"></a>Whitespace in Files</h2>
+               <div class="guidelineDetails">
+                       <p>No whitespace can precede the opening PHP tag or follow the closing PHP tag.  Output is buffered, so whitespace in your files can cause output to begin before CodeIgniter outputs its content, leading to errors and an inability for CodeIgniter to send proper headers.  In the examples below, select the text with your mouse to reveal the incorrect whitespace.</p>
+
+                       <p><strong>INCORRECT</strong>:</p>
+<code>
+&lt;?php
+       // ...there is whitespace and a linebreak above the opening PHP tag
+       // as well as whitespace after the closing PHP tag
+?&gt;
+</code>
+                       <p><strong>CORRECT</strong>:</p>
+<code>&lt;?php
+       // this sample has no whitespace before or after the opening and closing PHP tags
+?&gt;</code>
+
+               </div>
+
+
+               <h2><a name="compatibility"></a>Compatibility</h2>
+               <div class="guidelineDetails">
+                       <p>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.</p>
+               </div>
+
+
+
+               <h2><a name="class_and_file_names_using_common_words"></a>Class and File Names using Common Words</h2>
+               <div class="guidelineDetails">
+                       <p>When your class or filename is a common word, or might quite likely be identically named in another PHP script, provide a unique prefix to help prevent collision.  Always realize that your end users may be running other add-ons or third party PHP scripts.  Choose a prefix that is unique to your identity as a developer or company.</p>
+
+<code><strong>INCORRECT</strong>:
+class Email            pi.email.php
+class Xml              ext.xml.php
+class Import           mod.import.php
+
+<strong>CORRECT</strong>:
+class Pre_email                pi.pre_email.php
+class Pre_xml          ext.pre_xml.php
+class Pre_import       mod.pre_import.php
+</code>
+               </div>
+
+
+               <h2><a name="database_table_names"></a>Database Table Names</h2>
+               <div class="guidelineDetails">
+                       <p>Any tables that your add-on might use must use the 'exp_' prefix, followed by a prefix uniquely identifying you as the developer or company, and then a short descriptive table name.  You do not need to be concerned about the database prefix being used on the user's installation, as CodeIgniter's database class will automatically convert 'exp_' to what is actually being used.</p>
+
+<code><strong>INCORRECT</strong>:
+email_addresses                // missing both prefixes
+pre_email_addresses    // missing exp_ prefix
+exp_email_addresses    // missing unique prefix
+
+<strong>CORRECT</strong>:
+exp_pre_email_addresses
+</code>
+
+                       <p class="important"><strong>NOTE:</strong> Be mindful that MySQL has a limit of 64 characters for table names.  This should not be an issue as table names that would exceed this would likely have unreasonable names.  For instance, the following table name exceeds this limitation by one character.  Silly, no? <strong>exp_pre_email_addresses_of_registered_users_in_seattle_washington</strong>
+               </div>
+
+
+
+               <h2><a name="one_file_per_class"></a>One File per Class</h2>
+               <div class="guidelineDetails">
+                       <p>Use separate files for each class your add-on uses, unless the classes are <em>closely related</em>.  An example of CodeIgniter files that contains multiple classes is the Database class file, which contains both the DB class and the DB_Cache class, and the Magpie plugin, which contains both the Magpie and Snoopy classes.</p>
+               </div>
+
+
+
+               <h2><a name="whitespace"></a>Whitespace</h2>
+               <div class="guidelineDetails">
+                       <p>Use tabs for whitespace in your code, not spaces.  This may seem like a small thing, but using tabs instead of whitespace allows the developer looking at your code to have indentation at levels that they prefer and customize in whatever application they use.  And as a side benefit, it results in (slightly) more compact files, storing one tab character versus, say, four space characters.</p>
+               </div>
+
+
+
+               <h2><a name="line_breaks"></a>Line Breaks</h2>
+               <div class="guidelineDetails">
+                       <p>Files must be saved with Unix line breaks.  This is more of an issue for developers who work in Windows, but in any case ensure that your text editor is setup to save files with Unix line breaks.</p>
+               </div>
+
+
+
+               <h2><a name="code_indenting"></a>Code Indenting</h2>
+               <div class="guidelineDetails">
+                       <p>Use Allman style indenting.  With the exception of Class declarations, braces are always placed on a line by themselves, and indented at the same level as the control statement that "owns" them.</p>
+
+<code><strong>INCORRECT</strong>:
+function foo($bar) {
+       // ...
+}
+
+foreach ($arr as $key => $val) {
+       // ...
+}
+
+if ($foo == $bar) {
+       // ...
+} else {
+       // ...
+}
+
+for ($i = 0; $i &lt; 10; $i++)
+       {
+       for ($j = 0; $j &lt; 10; $j++)
+               {
+               // ...
+               }
+       }
+
+<strong>CORRECT</strong>:
+function foo($bar)
+{
+       // ...
+}
+
+foreach ($arr as $key => $val)
+{
+       // ...
+}
+
+if ($foo == $bar)
+{
+       // ...
+}
+else
+{
+       // ...
+}
+
+for ($i = 0; $i &lt; 10; $i++)
+{
+       for ($j = 0; $j &lt; 10; $j++)
+       {
+               // ...
+       }
+}</code>
+               </div>
+
+
+       <h2><a name="bracket_spacing"></a>Bracket and Parenthetic Spacing</h2>
+               <div class="guidelineDetails">
+                       <p>In general, parenthesis and brackets should not use any additional spaces.  The exception is that a space should always follow PHP control structures that accept arguments with parenthesis (declare, do-while, elseif, for, foreach, if, switch, while), to help distinguish them from functions and increase readability.</p>
+
+<code>INCORRECT:
+$arr[ $foo ] = 'foo';
+
+CORRECT:
+$arr[$foo] = 'foo'; // no spaces around array keys
+
+
+INCORRECT:
+function foo ( $bar )
+{
+
+}
+
+CORRECT:
+function foo($bar) // no spaces around parenthesis in function declarations
+{
+
+}
+
+
+INCORRECT:
+foreach( $query->result() as $row )
+
+CORRECT:
+foreach ($query->result() as $row) // single space following PHP control structures, but not in interior parenthesis
+</code>
+               </div>
+
+
+
+               <h2><a name="localized_text"></a>Localized Text</h2>
+               <div class="guidelineDetails">
+                       <p>Any text that is output in the control panel should use language variables in your lang file to allow localization.</p>
+
+<code>INCORRECT:
+return "Invalid Selection";
+
+CORRECT:
+return $this->lang->line('invalid_selection');</code>
+               </div>
+
+
+
+               <h2><a name="private_methods_and_variables"></a>Private Methods and Variables</h2>
+               <div class="guidelineDetails">
+                       <p>Methods and variables that are only accessed internally by your class, such as utility and helper functions that your public methods use for code abstraction, should be prefixed with an underscore.</p>
+
+<code>convert_text()           // public method
+_convert_text()                // private method</code>
+               </div>
+
+
+
+               <h2><a name="php_errors"></a>PHP Errors</h2>
+               <div class="guidelineDetails">
+                       <p>Code must run error free and not rely on warnings and notices to be hidden to meet this requirement.  For instance, never access a variable that you did not set yourself (such as $_POST array keys) without first checking to see that it isset().</p>
+
+                       <p>Make sure that while developing your add-on, error reporting is enabled for ALL users, and that display_errors is enabled in the PHP environment.  You can check this setting with:</p>
+
+<code>if (ini_get('display_errors') == 1)
+{
+       exit "Enabled";
+}</code>
+
+                       <p>On some servers where display_errors is disabled, and you do not have the ability to change this in the php.ini, you can often enable it with:</p>
+
+<code>ini_set('display_errors', 1);</code>
+
+                       <p class="important"><strong>NOTE:</strong> Setting the <a href="http://us.php.net/manual/en/ref.errorfunc.php#ini.display-errors">display_errors</a> setting with ini_set() at runtime is not identical to having it enabled in the PHP environment.  Namely, it will not have any effect if the script has fatal errors</p>
+               </div>
+
+
+
+               <h2><a name="short_open_tags"></a>Short Open Tags</h2>
+               <div class="guidelineDetails">
+                       <p>Always use full PHP opening tags, in case a server does not have short_open_tag enabled.</p>
+
+<code><strong>INCORRECT</strong>:
+&lt;? echo $foo; ?&gt;
+
+&lt;?=$foo?&gt;
+
+<strong>CORRECT</strong>:
+&lt;?php echo $foo; ?&gt;</code>
+               </div>
+
+
+
+               <h2><a name="one_statement_per_line"></a>One Statement Per Line</h2>
+               <div class="guidelineDetails">
+                       <p>Never combine statements on one line.</p>
+
+<code><strong>INCORRECT</strong>:
+$foo = 'this'; $bar = 'that'; $bat = str_replace($foo, $bar, $bag);
+
+<strong>CORRECT</strong>:
+$foo = 'this';
+$bar = 'that';
+$bat = str_replace($foo, $bar, $bag);
+</code>
+               </div>
+
+
+
+               <h2><a name="strings"></a>Strings</h2>
+               <div class="guidelineDetails">
+                       <p>Always use single quoted strings unless you need variables parsed, and in cases where you do need variables parsed, use braces to prevent greedy token parsing.  You may also use double-quoted strings if the string contains single quotes, so you do not have to use escape characters.</p>
+
+<code><strong>INCORRECT</strong>:
+"My String"                                    // no variable parsing, so no use for double quotes
+"My string $foo"                               // needs braces
+'SELECT foo FROM bar WHERE baz = \'bag\''      // ugly
+
+<strong>CORRECT</strong>:
+'My String'
+"My string {$foo}"
+"SELECT foo FROM bar WHERE baz = 'bag'"</code>
+               </div>
+
+
+
+               <h2><a name="sql_queries"></a>SQL Queries</h2>
+               <div class="guidelineDetails">
+                       <p>MySQL keywords are always capitalized: SELECT, INSERT, UPDATE, WHERE, AS, JOIN, ON, IN, etc.</p>
+
+                       <p>Break up long queries into multiple lines for legibility, preferably breaking for each clause.</p>
+
+<code><strong>INCORRECT</strong>:
+// keywords are lowercase and query is too long for
+// a single line (... indicates continuation of line)
+$query = $this->db->query("select foo, bar, baz, foofoo, foobar as raboof, foobaz from exp_pre_email_addresses
+...where foo != 'oof' and baz != 'zab' order by foobaz limit 5, 100");
+
+<strong>CORRECT</strong>:
+$query = $this->db->query("SELECT foo, bar, baz, foofoo, foobar AS raboof, foobaz
+                               FROM exp_pre_email_addresses
+                               WHERE foo != 'oof'
+                               AND baz != 'zab'
+                               ORDER BY foobaz
+                               LIMIT 5, 100");</code>
+               </div>
+
+
+
+               <h2><a name="default_function_arguments"></a>Default Function Arguments</h2>
+               <div class="guidelineDetails">
+                       <p>Whenever appropriate, provide function argument defaults, which helps prevent PHP errors with mistaken calls and provides common fallback values which can save a few lines of code. Example:</p>
+
+<code>function foo($bar = '', $baz = FALSE)</code>
+               </div>
+
+
+
+</div>
+
+
+
+</div>
+<!-- END CONTENT -->
+
+
+<div id="footer">
+<p>
+Previous Topic:&nbsp;&nbsp;<a href="security.html">Security</a>
+&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+<a href="#top">Top of Page</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+<a href="../index.html">User Guide Home</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+Next Topic:&nbsp;&nbsp;<a href="../doc_style/index.html">Writing Documentation</a>
+</p>
+<p><a href="http://codeigniter.com">CodeIgniter</a> &nbsp;&middot;&nbsp; Copyright &#169; 2006 - 2011 &nbsp;&middot;&nbsp; <a href="http://ellislab.com/">EllisLab, Inc.</a></p>
+</div>
+
+</body>
+</html>
\ No newline at end of file
diff --git a/user_guide/general/urls.html b/user_guide/general/urls.html
new file mode 100755 (executable)
index 0000000..421f513
--- /dev/null
@@ -0,0 +1,151 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head>
+
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+<title>CodeIgniter URLs : CodeIgniter User Guide</title>
+
+<style type='text/css' media='all'>@import url('../userguide.css');</style>
+<link rel='stylesheet' type='text/css' media='all' href='../userguide.css' />
+
+<script type="text/javascript" src="../nav/nav.js"></script>
+<script type="text/javascript" src="../nav/prototype.lite.js"></script>
+<script type="text/javascript" src="../nav/moo.fx.js"></script>
+<script type="text/javascript" src="../nav/user_guide_menu.js"></script>
+
+<meta http-equiv='expires' content='-1' />
+<meta http-equiv= 'pragma' content='no-cache' />
+<meta name='robots' content='all' />
+<meta name='author' content='ExpressionEngine Dev Team' />
+<meta name='description' content='CodeIgniter User Guide' />
+
+</head>
+<body>
+
+<!-- START NAVIGATION -->
+<div id="nav"><div id="nav_inner"><script type="text/javascript">create_menu('../');</script></div></div>
+<div id="nav2"><a name="top"></a><a href="javascript:void(0);" onclick="myHeight.toggle();"><img src="../images/nav_toggle_darker.jpg" width="154" height="43" border="0" title="Toggle Table of Contents" alt="Toggle Table of Contents" /></a></div>
+<div id="masthead">
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td><h1>CodeIgniter User Guide Version 2.0.2</h1></td>
+<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
+</tr>
+</table>
+</div>
+<!-- END NAVIGATION -->
+
+
+<!-- START BREADCRUMB -->
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td id="breadcrumb">
+<a href="http://codeigniter.com/">CodeIgniter Home</a> &nbsp;&#8250;&nbsp;
+<a href="../index.html">User Guide Home</a> &nbsp;&#8250;&nbsp;
+URLS
+</td>
+<td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="codeigniter.com/user_guide/" />Search User Guide&nbsp; <input type="text" class="input" style="width:200px;" name="q" id="q" size="31" maxlength="255" value="" />&nbsp;<input type="submit" class="submit" name="sa" value="Go" /></form></td>
+</tr>
+</table>
+<!-- END BREADCRUMB -->
+
+<br clear="all" />
+
+
+<!-- START CONTENT -->
+<div id="content">
+
+
+<h1>CodeIgniter URLs</h1>
+
+<p>By default, URLs in CodeIgniter are designed to be search-engine and human friendly.  Rather than using the standard "query string"
+approach to URLs that is synonymous with dynamic systems, CodeIgniter uses a <strong>segment-based</strong> approach:</p>
+
+<code>example.com/<var>news</var>/<dfn>article</dfn>/<samp>my_article</samp></code>
+
+<p class="important"><strong>Note:</strong> Query string URLs can be optionally enabled, as described below.</p>
+
+<h2>URI Segments</h2>
+
+<p>The segments in the URL, in following with the Model-View-Controller approach, usually represent:</p>
+
+<code>example.com/<var>class</var>/<dfn>function</dfn>/<samp>ID</samp></code>
+
+<ol>
+<li>The first segment represents the controller <strong>class</strong> that should be invoked.</li>
+<li>The second segment represents the class <strong>function</strong>, or method, that should be called.</li>
+<li>The third, and any additional segments, represent the ID and any variables that will be passed to the controller.</li>
+</ol>
+
+<p>The <a href="../libraries/uri.html">URI Class</a> and the <a href="../helpers/url_helper.html">URL Helper</a>
+contain functions that make it easy to work with your URI data.  In addition, your URLs can be remapped using the
+<a href="routing.html">URI Routing</a> feature for more flexibility.</p>
+
+
+
+<h2>Removing the index.php file</h2>
+
+<p>By default, the <strong>index.php</strong> file will be included in your URLs:</p>
+
+<code>example.com/<var>index.php</var>/news/article/my_article</code>
+
+<p>You can easily remove this file by using a .htaccess file with some simple rules. Here is an example
+ of such a file, using the "negative" method in which everything is redirected except the specified items:</p>
+
+<code>RewriteEngine on<br />
+RewriteCond $1 !^(index\.php|images|robots\.txt)<br />
+RewriteRule ^(.*)$ /index.php/$1 [L]</code>
+
+<p>In the above example, any HTTP request other than those for index.php, images, and robots.txt is treated as
+a request for your index.php file.</p>
+
+
+<h2>Adding a URL Suffix</h2>
+
+<p>In your <dfn>config/config.php</dfn> file you can specify a suffix that will be added to all URLs generated
+by CodeIgniter.  For example, if a URL is this:</p>
+
+<code>example.com/index.php/products/view/shoes</code>
+
+<p>You can optionally add a suffix, like <kbd>.html</kbd>, making the page appear to be of a certain type:</p>
+
+<code>example.com/index.php/products/view/shoes.html</code>
+
+
+<h2>Enabling Query Strings</h2>
+
+<p>In some cases you might prefer to use query strings URLs:</p>
+
+<code>index.php?c=products&amp;m=view&amp;id=345</code>
+
+<p>CodeIgniter optionally supports this capability, which can be enabled in your <dfn>application/config.php</dfn> file. If you
+open your config file you'll see these items:</p>
+
+<code>$config['enable_query_strings'] = FALSE;<br />
+$config['controller_trigger'] = 'c';<br />
+$config['function_trigger'] = 'm';</code>
+
+<p>If you change "enable_query_strings" to TRUE this feature will become active.  Your controllers and functions will then
+be accessible using the "trigger" words you've set to invoke your controllers and methods:</p>
+
+<code>index.php?c=controller&amp;m=method</code>
+
+<p class="important"><strong>Please note:</strong> If you are using query strings you will have to build your own URLs, rather than utilizing
+the URL helpers (and other helpers that generate URLs, like some of the form helpers) as these are designed to work with
+segment based URLs.</p>
+
+
+</div>
+<!-- END CONTENT -->
+
+
+<div id="footer">
+<p>
+<a href="#top">Top of Page</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+<a href="../index.html">User Guide Home</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+Next Topic:&nbsp;&nbsp;<a href="controllers.html">Controllers</a></p>
+<p><a href="http://codeigniter.com">CodeIgniter</a> &nbsp;&middot;&nbsp; Copyright &#169; 2006 - 2011 &nbsp;&middot;&nbsp; <a href="http://ellislab.com/">EllisLab, Inc.</a></p>
+</div>
+
+</body>
+</html>
\ No newline at end of file
diff --git a/user_guide/general/views.html b/user_guide/general/views.html
new file mode 100755 (executable)
index 0000000..ad93f4b
--- /dev/null
@@ -0,0 +1,274 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head>
+
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+<title>Views : CodeIgniter User Guide</title>
+
+<style type='text/css' media='all'>@import url('../userguide.css');</style>
+<link rel='stylesheet' type='text/css' media='all' href='../userguide.css' />
+
+<script type="text/javascript" src="../nav/nav.js"></script>
+<script type="text/javascript" src="../nav/prototype.lite.js"></script>
+<script type="text/javascript" src="../nav/moo.fx.js"></script>
+<script type="text/javascript" src="../nav/user_guide_menu.js"></script>
+
+<meta http-equiv='expires' content='-1' />
+<meta http-equiv= 'pragma' content='no-cache' />
+<meta name='robots' content='all' />
+<meta name='author' content='ExpressionEngine Dev Team' />
+<meta name='description' content='CodeIgniter User Guide' />
+
+</head>
+<body>
+
+<!-- START NAVIGATION -->
+<div id="nav"><div id="nav_inner"><script type="text/javascript">create_menu('../');</script></div></div>
+<div id="nav2"><a name="top"></a><a href="javascript:void(0);" onclick="myHeight.toggle();"><img src="../images/nav_toggle_darker.jpg" width="154" height="43" border="0" title="Toggle Table of Contents" alt="Toggle Table of Contents" /></a></div>
+<div id="masthead">
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td><h1>CodeIgniter User Guide Version 2.0.2</h1></td>
+<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
+</tr>
+</table>
+</div>
+<!-- END NAVIGATION -->
+
+
+<!-- START BREADCRUMB -->
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td id="breadcrumb">
+<a href="http://codeigniter.com/">CodeIgniter Home</a> &nbsp;&#8250;&nbsp;
+<a href="../index.html">User Guide Home</a> &nbsp;&#8250;&nbsp;
+Views
+</td>
+<td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="codeigniter.com/user_guide/" />Search User Guide&nbsp; <input type="text" class="input" style="width:200px;" name="q" id="q" size="31" maxlength="255" value="" />&nbsp;<input type="submit" class="submit" name="sa" value="Go" /></form></td>
+</tr>
+</table>
+<!-- END BREADCRUMB -->
+
+<br clear="all" />
+
+
+<!-- START CONTENT -->
+<div id="content">
+
+<h1>Views</h1>
+
+<p>A <dfn>view</dfn> is simply a web page, or a page fragment, like a header, footer, sidebar, etc.
+In fact, views can flexibly be embedded within other views (within other views, etc., etc.) if you need this type
+of hierarchy.</p>
+
+<p>Views are never called directly, they must be loaded by a <a href="controllers.html">controller</a>.  Remember that in an MVC framework, the Controller acts as the
+traffic cop, so it is responsible for fetching a particular view. If you have not read the <a href="controllers.html">Controllers</a> page
+you should do so before continuing.</p>
+
+<p>Using the example controller you created in the <a href="controllers.html">controller</a> page, let's add a view to it.</p>
+
+<h2>Creating a View</h2>
+
+<p>Using your text editor, create a file called <dfn>blogview.php</dfn>, and put this in it:</p>
+
+<textarea class="textarea" style="width:100%" cols="50" rows="10">
+&lt;html>
+&lt;head>
+&lt;title>My Blog&lt;/title>
+&lt;/head>
+&lt;body>
+       &lt;h1>Welcome to my Blog!&lt;/h1>
+&lt;/body>
+&lt;/html>
+</textarea>
+
+<p>Then save the file in your <dfn>application/views/</dfn> folder.</p>
+
+<h2>Loading a View</h2>
+
+<p>To load a particular view file you will use the following function:</p>
+
+<code>$this->load->view('<var>name</var>');</code>
+
+<p>Where <var>name</var> is the name of your view file.  Note: The .php file extension does not need to be specified unless you use something other than <kbd>.php</kbd>.</p>
+
+
+<p>Now, open the controller file you made earlier called <dfn>blog.php</dfn>, and replace the echo statement with the view loading function:</p>
+
+
+<textarea class="textarea" style="width:100%" cols="50" rows="10">
+&lt;?php
+class Blog extends CI_Controller {
+
+       function index()
+       {
+               $this->load->view('blogview');
+       }
+}
+?&gt;
+</textarea>
+
+
+<p>If you visit your site using the URL you did earlier you should see your new view.  The URL was similar to this:</p>
+
+<code>example.com/index.php/<var>blog</var>/</code>
+
+<h2>Loading multiple views</h2>
+<p>CodeIgniter will intelligently handle  multiple calls to $this-&gt;load-&gt;view from within a controller.  If more than one call happens they will be appended together. For example, you may wish to have a header view, a menu view, a content view, and a footer view. That might look something like this:</p>
+<p><code>&lt;?php<br />
+<br />
+class Page extends CI_Controller {<br /><br />
+
+ &nbsp;&nbsp;&nbsp;function index()<br />
+&nbsp;&nbsp;&nbsp;{<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$data['page_title'] =  'Your title';<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$this-&gt;load-&gt;view('header');<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$this-&gt;load-&gt;view('menu');<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$this-&gt;load-&gt;view('content', $data);<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$this-&gt;load-&gt;view('footer');<br />
+&nbsp;&nbsp;&nbsp;}<br />
+<br />
+}<br />
+       ?&gt;</code></p>
+<p>In the example above, we are using &quot;dynamically added data&quot;, which you will see below.</p>
+<h2>Storing Views within Sub-folders</h2>
+<p>Your view files can also be stored within sub-folders if you prefer that type of organization.  When doing so you will need
+to include the folder name loading the view.  Example:</p>
+
+<code>$this->load->view('<kbd>folder_name</kbd>/<var>file_name</var>');</code>
+
+
+<h2>Adding Dynamic Data to the View</h2>
+
+<p>Data is passed from the controller to the view by way of an <strong>array</strong> or an <strong>object</strong> in the second
+parameter of the view loading function. Here is an example using an array:</p>
+
+<code>$data = array(<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'title' => 'My Title',<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'heading' => 'My Heading',<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'message' => 'My Message'<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;);<br />
+<br />
+$this->load->view('blogview', <var>$data</var>);</code>
+
+<p>And here's an example using an object:</p>
+
+<code>$data = new Someclass();<br />
+$this->load->view('blogview', <var>$data</var>);</code>
+
+<p>Note: If you use an object, the class variables will be turned into array elements.</p>
+
+
+<p>Let's try it with your controller file.  Open it add this code:</p>
+
+<textarea class="textarea" style="width:100%" cols="50" rows="14">
+&lt;?php
+class Blog extends CI_Controller {
+
+       function index()
+       {
+               $data['title'] = "My Real Title";
+               $data['heading'] = "My Real Heading";
+
+               $this->load->view('blogview', $data);
+       }
+}
+?&gt;
+</textarea>
+
+
+<p>Now open your view file and change the text to variables that correspond to the array keys in your data:</p>
+
+
+<textarea class="textarea" style="width:100%" cols="50" rows="10">
+&lt;html>
+&lt;head>
+&lt;title>&lt;?php echo $title;?>&lt;/title>
+&lt;/head>
+&lt;body>
+       &lt;h1>&lt;?php echo $heading;?>&lt;/h1>
+&lt;/body>
+&lt;/html>
+</textarea>
+
+<p>Then load the page at the URL you've been using and you should see the variables replaced.</p>
+
+<h2>Creating Loops</h2>
+
+<p>The data array you pass to your view files is not limited to simple variables.  You can
+pass multi dimensional arrays, which can be looped to generate multiple rows.  For example, if you
+pull data from your database it will typically be in the form of a multi-dimensional array.</p>
+
+<p>Here's a simple example. Add this to your controller:</p>
+
+<textarea class="textarea" style="width:100%" cols="50" rows="17">
+&lt;?php
+class Blog extends CI_Controller {
+
+       function index()
+       {
+               $data['todo_list'] = array('Clean House', 'Call Mom', 'Run Errands');
+
+               $data['title'] = "My Real Title";
+               $data['heading'] = "My Real Heading";
+
+               $this->load->view('blogview', $data);
+       }
+}
+?&gt;
+</textarea>
+
+
+<p>Now open your view file and create a loop:</p>
+
+
+<textarea class="textarea" style="width:100%" cols="50" rows="24">
+&lt;html>
+&lt;head>
+&lt;title>&lt;?php echo $title;?>&lt;/title>
+&lt;/head>
+&lt;body>
+&lt;h1>&lt;?php echo $heading;?>&lt;/h1>
+
+&lt;h3>My Todo List&lt;/h3>
+
+&lt;ul>
+&lt;?php foreach ($todo_list as $item):?>
+
+&lt;li>&lt;?php echo $item;?>&lt;/li>
+
+&lt;?php endforeach;?>
+&lt;/ul>
+
+&lt;/body>
+&lt;/html>
+</textarea>
+<p><strong>Note:</strong> You'll notice that in the example above we are using PHP's alternative syntax.  If you
+are not familiar with it you can read about it <a href="alternative_php.html">here</a>.</p>
+
+<h2>Returning views as data</h2>
+
+<p>There is a third <strong>optional</strong> parameter lets you change the behavior of the function so that it returns data as a string
+rather than sending it to your browser.  This can be useful if you want to process the data in some way.  If you
+set the parameter to <kbd>true</kbd> (boolean) it will return data.  The default behavior is <kbd>false</kbd>, which sends it
+to your browser.  Remember to assign it to a variable if you want the data returned:</p>
+
+<code>$string = $this->load->view('<var>myfile</var>', '', <kbd>true</kbd>);</code>
+
+</div>
+<!-- END CONTENT -->
+
+
+<div id="footer">
+<p>
+Previous Topic:&nbsp;&nbsp;<a href="reserved_names.html">Reserved Names</a>
+&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+<a href="#top">Top of Page</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+<a href="../index.html">User Guide Home</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+Next Topic:&nbsp;&nbsp;<a href="models.html">Models</a>
+</p>
+<p><a href="http://codeigniter.com">CodeIgniter</a> &nbsp;&middot;&nbsp; Copyright &#169; 2006 - 2011 &nbsp;&middot;&nbsp; <a href="http://ellislab.com/">EllisLab, Inc.</a></p>
+</div>
+
+</body>
+</html>
\ No newline at end of file
diff --git a/user_guide/helpers/array_helper.html b/user_guide/helpers/array_helper.html
new file mode 100755 (executable)
index 0000000..a196214
--- /dev/null
@@ -0,0 +1,170 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head>
+
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+<title>Array Helper : CodeIgniter User Guide</title>
+
+<style type='text/css' media='all'>@import url('../userguide.css');</style>
+<link rel='stylesheet' type='text/css' media='all' href='../userguide.css' />
+
+<script type="text/javascript" src="../nav/nav.js"></script>
+<script type="text/javascript" src="../nav/prototype.lite.js"></script>
+<script type="text/javascript" src="../nav/moo.fx.js"></script>
+<script type="text/javascript" src="../nav/user_guide_menu.js"></script>
+
+<meta http-equiv='expires' content='-1' />
+<meta http-equiv= 'pragma' content='no-cache' />
+<meta name='robots' content='all' />
+<meta name='author' content='ExpressionEngine Dev Team' />
+<meta name='description' content='CodeIgniter User Guide' />
+
+</head>
+<body>
+
+<!-- START NAVIGATION -->
+<div id="nav"><div id="nav_inner"><script type="text/javascript">create_menu('../');</script></div></div>
+<div id="nav2"><a name="top"></a><a href="javascript:void(0);" onclick="myHeight.toggle();"><img src="../images/nav_toggle_darker.jpg" width="154" height="43" border="0" title="Toggle Table of Contents" alt="Toggle Table of Contents" /></a></div>
+<div id="masthead">
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td><h1>CodeIgniter User Guide Version 2.0.2</h1></td>
+<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
+</tr>
+</table>
+</div>
+<!-- END NAVIGATION -->
+
+
+<!-- START BREADCRUMB -->
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td id="breadcrumb">
+<a href="http://codeigniter.com/">CodeIgniter Home</a> &nbsp;&#8250;&nbsp;
+<a href="../index.html">User Guide Home</a> &nbsp;&#8250;&nbsp;
+Array Helper
+</td>
+<td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="codeigniter.com/user_guide/" />Search User Guide&nbsp; <input type="text" class="input" style="width:200px;" name="q" id="q" size="31" maxlength="255" value="" />&nbsp;<input type="submit" class="submit" name="sa" value="Go" /></form></td>
+</tr>
+</table>
+<!-- END BREADCRUMB -->
+
+<br clear="all" />
+
+
+<!-- START CONTENT -->
+<div id="content">
+
+
+<h1>Array Helper</h1>
+
+<p>The Array Helper file contains functions that assist in working with arrays.</p>
+
+
+<h2>Loading this Helper</h2>
+
+<p>This helper is loaded using the following code:</p>
+<code>$this->load->helper('array');</code>
+
+<p>The following functions are available:</p>
+
+<h2>element()</h2>
+
+<p>Lets you fetch an item from an array.  The function tests whether the array index is set and whether it has a value.  If
+a value exists it is returned.  If a value does not exist it returns FALSE, or whatever you've specified as the default value via the third parameter.  Example:</p>
+
+<code>
+$array = array('color' => 'red', 'shape' => 'round', 'size' => '');<br />
+<br />
+// returns "red"<br />
+echo element('color', $array);<br />
+<br />
+// returns NULL<br />
+echo element('size', $array, NULL);
+</code>
+
+
+<h2>random_element()</h2>
+
+<p>Takes an array as input and returns a random element from it.  Usage example:</p>
+
+<code>$quotes = array(<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"I find that the harder I work, the more luck I seem to have. - Thomas Jefferson",<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"Don't stay in bed, unless you can make money in bed. - George Burns",<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"We didn't lose the game; we just ran out of time. - Vince Lombardi",<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"If everything seems under control, you're not going fast enough. - Mario Andretti",<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"Reality is merely an illusion, albeit a very persistent one. - Albert Einstein",<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"Chance favors the prepared mind - Louis Pasteur"<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;);<br />
+<br />
+echo random_element($quotes);</code>
+
+
+<h2>elements()</h2>
+
+<p>Lets you fetch a number of items from an array.  The function tests whether each of the array indices is set.  If an index does not exist
+it is set to FALSE, or whatever you've specified as the default value via the third parameter.  Example:</p>
+
+<code>
+$array = array(<br />
+&nbsp;&nbsp;&nbsp;&nbsp;'color' => 'red',<br />
+&nbsp;&nbsp;&nbsp;&nbsp;'shape' => 'round',<br />
+&nbsp;&nbsp;&nbsp;&nbsp;'radius' => '10',<br />
+&nbsp;&nbsp;&nbsp;&nbsp;'diameter' => '20'<br />
+);<br />
+<br />
+$my_shape = elements(array('color', 'shape', 'height'), $array);<br />
+</code>
+
+<p>The above will return the following array:</p>
+
+<code>
+array(<br />
+&nbsp;&nbsp;&nbsp;&nbsp;'color' => 'red',<br />
+&nbsp;&nbsp;&nbsp;&nbsp;'shape' => 'round',<br />
+&nbsp;&nbsp;&nbsp;&nbsp;'height' => FALSE<br />
+);
+</code>
+
+<p>You can set the third parameter to any default value you like:</p>
+
+<code>
+$my_shape = elements(array('color', 'shape', 'height'), $array, NULL);<br />
+</code>
+
+<p>The above will return the following array:</p>
+
+<code>
+array(<br />
+&nbsp;&nbsp;&nbsp;&nbsp;'color' => 'red',<br />
+&nbsp;&nbsp;&nbsp;&nbsp;'shape' => 'round',<br />
+&nbsp;&nbsp;&nbsp;&nbsp;'height' => NULL<br />
+);
+</code>
+
+<p>This is useful when sending the <kbd>$_POST</kbd> array to one of your Models.  This prevents users from
+sending additional POST data to be entered into your tables:</p>
+
+<code>
+$this->load->model('post_model');<br />
+<br />
+$this->post_model->update(elements(array('id', 'title', 'content'), $_POST));
+</code>
+
+<p>This ensures that only the id, title and content fields are sent to be updated.</p>
+
+</div>
+<!-- END CONTENT -->
+
+
+<div id="footer">
+<p>
+Previous Topic:&nbsp;&nbsp; <a href="../libraries/zip.html">Zip Encoding Class</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+<a href="#top">Top of Page</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+<a href="../index.html">User Guide Home</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+Next Topic:&nbsp;&nbsp;<a href="compatibility_helper.html">Compatibility Helper</a></p>
+<p><a href="http://codeigniter.com">CodeIgniter</a> &nbsp;&middot;&nbsp; Copyright &#169; 2006 - 2011 &nbsp;&middot;&nbsp; <a href="http://ellislab.com/">EllisLab, Inc.</a></p>
+</div>
+
+</body>
+</html>
\ No newline at end of file
diff --git a/user_guide/helpers/captcha_helper.html b/user_guide/helpers/captcha_helper.html
new file mode 100755 (executable)
index 0000000..2fd5a55
--- /dev/null
@@ -0,0 +1,195 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head>
+
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+<title>CAPTCHA Helper : CodeIgniter User Guide</title>
+
+<style type='text/css' media='all'>@import url('../userguide.css');</style>
+<link rel='stylesheet' type='text/css' media='all' href='../userguide.css' />
+
+<script type="text/javascript" src="../nav/nav.js"></script>
+<script type="text/javascript" src="../nav/prototype.lite.js"></script>
+<script type="text/javascript" src="../nav/moo.fx.js"></script>
+<script type="text/javascript" src="../nav/user_guide_menu.js"></script>
+
+<meta http-equiv='expires' content='-1' />
+<meta http-equiv= 'pragma' content='no-cache' />
+<meta name='robots' content='all' />
+<meta name='author' content='ExpressionEngine Dev Team' />
+<meta name='description' content='CodeIgniter User Guide' />
+
+</head>
+<body>
+
+<!-- START NAVIGATION -->
+<div id="nav"><div id="nav_inner"><script type="text/javascript">create_menu('../');</script></div></div>
+<div id="nav2"><a name="top"></a><a href="javascript:void(0);" onclick="myHeight.toggle();"><img src="../images/nav_toggle_darker.jpg" width="154" height="43" border="0" title="Toggle Table of Contents" alt="Toggle Table of Contents" /></a></div>
+<div id="masthead">
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td><h1>CodeIgniter User Guide Version 2.0.2</h1></td>
+<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
+</tr>
+</table>
+</div>
+<!-- END NAVIGATION -->
+
+
+<!-- START BREADCRUMB -->
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td id="breadcrumb">
+<a href="http://codeigniter.com/">CodeIgniter Home</a> &nbsp;&#8250;&nbsp;
+<a href="../index.html">User Guide Home</a> &nbsp;&#8250;&nbsp;
+CAPTCHA Helper
+</td>
+<td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="codeigniter.com/user_guide/" />Search User Guide&nbsp; <input type="text" class="input" style="width:200px;" name="q" id="q" size="31" maxlength="255" value="" />&nbsp;<input type="submit" class="submit" name="sa" value="Go" /></form></td>
+</tr>
+</table>
+<!-- END BREADCRUMB -->
+
+<br clear="all" />
+
+
+<!-- START CONTENT -->
+<div id="content">
+
+
+<h1>CAPTCHA Helper</h1>
+
+<p>The CAPTCHA Helper file contains functions that assist in creating CAPTCHA images.</p>
+
+
+<h2>Loading this Helper</h2>
+
+<p>This helper is loaded using the following code:</p>
+<code>$this->load->helper('captcha');</code>
+
+<p>The following functions are available:</p>
+
+<h2>create_captcha(<var>$data</var>)</h2>
+
+<p>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.</p>
+
+<code>[array]<br />
+(<br />
+&nbsp;&nbsp;'image' => IMAGE TAG<br />
+&nbsp;&nbsp;'time'     => TIMESTAMP (in microtime)<br />
+&nbsp;&nbsp;'word'     => CAPTCHA WORD<br />
+)</code>
+
+       <p>The "image" is the actual image tag:
+<code>&lt;img src=&quot;http://example.com/captcha/12345.jpg&quot; width=&quot;140&quot; height=&quot;50&quot; /&gt;</code></p>
+
+       <p>The "time" is the micro timestamp used as the image name without the file
+       extension.  It will be a number like this:  1139612155.3422</p>
+
+       <p>The "word" is the word that appears in the captcha image, which if not
+       supplied to the function, will be a random string.</p>
+
+       <h3>Using the CAPTCHA helper</h3>
+
+       <p>Once loaded you can generate a captcha like this:</p>
+
+<code>$vals = array(<br />
+&nbsp;&nbsp;&nbsp;&nbsp;'word'          => 'Random word',<br />
+&nbsp;&nbsp;&nbsp;&nbsp;'img_path'      => './captcha/',<br />
+&nbsp;&nbsp;&nbsp;&nbsp;'img_url'       => 'http://example.com/captcha/',<br />
+&nbsp;&nbsp;&nbsp;&nbsp;'font_path'     => './path/to/fonts/texb.ttf',<br />
+&nbsp;&nbsp;&nbsp;&nbsp;'img_width'     => '150',<br />
+&nbsp;&nbsp;&nbsp;&nbsp;'img_height' => 30,<br />
+&nbsp;&nbsp;&nbsp;&nbsp;'expiration' => 7200<br />
+&nbsp;&nbsp;&nbsp;&nbsp;);<br />
+<br />
+$cap = create_captcha($vals);<br />
+echo $cap['image'];</code>
+
+       <ul>
+               <li>The captcha function requires the GD image library.</li>
+               <li>Only the img_path and img_url are required.</li>
+               <li>If a "word" is not supplied, the function will generate a random
+               ASCII string.  You might put together your own word library that
+               you can draw randomly from.</li>
+               <li>If you do not specify a path to a TRUE TYPE font, the native ugly GD
+               font will be used.</li>
+               <li>The "captcha" folder must be writable (666, or 777)</li>
+               <li>The "expiration" (in seconds) signifies how long an image will
+               remain in the captcha folder before it will be deleted.  The default
+               is two hours.</li>
+       </ul>
+
+       <h3>Adding a Database</h3>
+
+       <p>In order for the captcha function to prevent someone from submitting, you will need
+       to add the information returned from <kbd>create_captcha()</kbd> function to your database.
+       Then, when the data from the form is submitted by the user you will need to verify
+       that the data exists in the database and has not expired.</p>
+
+       <p>Here is a table prototype:</p>
+
+<code>CREATE TABLE captcha (<br />
+&nbsp;captcha_id bigint(13) unsigned NOT NULL auto_increment,<br />
+&nbsp;captcha_time int(10) unsigned NOT NULL,<br />
+&nbsp;ip_address varchar(16) default '0' NOT NULL,<br />
+&nbsp;word varchar(20) NOT NULL,<br />
+&nbsp;PRIMARY KEY `captcha_id` (`captcha_id`),<br />
+&nbsp;KEY `word` (`word`)<br />
+);</code>
+
+       <p>Here is an example of usage with a database.  On the page where the CAPTCHA will be shown you'll have something like this:</p>
+
+<code>$this-&gt;load-&gt;helper(&#x27;captcha&#x27;);<br />
+$vals = array(<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&#x27;img_path&#x27;    =&gt; &#x27;./captcha/&#x27;,<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&#x27;img_url&#x27;     =&gt; &#x27;http://example.com/captcha/&#x27;<br />
+&nbsp;&nbsp;&nbsp;&nbsp;);<br />
+<br />
+$cap = create_captcha($vals);<br />
+<br />
+$data = array(<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&#x27;captcha_time&#x27;       =&gt; $cap[&#x27;time&#x27;],<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&#x27;ip_address&#x27; =&gt; $this-&gt;input-&gt;ip_address(),<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&#x27;word&#x27;                       =&gt; $cap[&#x27;word&#x27;]<br />
+&nbsp;&nbsp;&nbsp;&nbsp;);<br />
+<br />
+$query = $this-&gt;db-&gt;insert_string(&#x27;captcha&#x27;, $data);<br />
+$this-&gt;db-&gt;query($query);<br />
+<br />
+echo &#x27;Submit the word you see below:&#x27;;<br />
+echo $cap[&#x27;image&#x27;];<br />
+echo &#x27;&lt;input type=&quot;text&quot; name=&quot;captcha&quot; value=&quot;&quot; /&gt;&#x27;;</code>
+
+       <p>Then, on the page that accepts the submission you'll have something like this:</p>
+
+<code>// First, delete old captchas<br />
+$expiration = time()-7200; // Two hour limit<br />
+$this-&gt;db-&gt;query(&quot;DELETE FROM captcha WHERE captcha_time &lt; &quot;.$expiration);  <br />
+<br />
+// Then see if a captcha exists:<br />
+$sql = &quot;SELECT COUNT(*) AS count FROM captcha WHERE word = ? AND ip_address = ? AND captcha_time &gt; ?&quot;;<br />
+$binds = array($_POST[&#x27;captcha&#x27;], $this-&gt;input-&gt;ip_address(), $expiration);<br />
+$query = $this-&gt;db-&gt;query($sql, $binds);<br />
+$row = $query-&gt;row();<br />
+<br />
+if ($row-&gt;count == 0)<br />
+{<br />
+&nbsp;&nbsp;&nbsp;&nbsp;echo &quot;You must submit the word that appears in the image&quot;;<br />
+}</code>
+
+</div>
+<!-- END CONTENT -->
+
+
+<div id="footer">
+<p>
+Previous Topic:&nbsp;&nbsp;<a href="url_helper.html">URL Helper</a>
+&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+<a href="#top">Top of Page</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+<a href="../index.html">User Guide Home</a>
+</p>
+<p><a href="http://codeigniter.com">CodeIgniter</a> &nbsp;&middot;&nbsp; Copyright &#169; 2006 - 2011 &nbsp;&middot;&nbsp; <a href="http://ellislab.com/">EllisLab, Inc.</a></p>
+</div>
+
+</body>
+</html>
diff --git a/user_guide/helpers/cookie_helper.html b/user_guide/helpers/cookie_helper.html
new file mode 100755 (executable)
index 0000000..34faadb
--- /dev/null
@@ -0,0 +1,107 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head>
+
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+<title>Cookie Helper : CodeIgniter User Guide</title>
+
+<style type='text/css' media='all'>@import url('../userguide.css');</style>
+<link rel='stylesheet' type='text/css' media='all' href='../userguide.css' />
+
+<script type="text/javascript" src="../nav/nav.js"></script>
+<script type="text/javascript" src="../nav/prototype.lite.js"></script>
+<script type="text/javascript" src="../nav/moo.fx.js"></script>
+<script type="text/javascript" src="../nav/user_guide_menu.js"></script>
+
+<meta http-equiv='expires' content='-1' />
+<meta http-equiv= 'pragma' content='no-cache' />
+<meta name='robots' content='all' />
+<meta name='author' content='ExpressionEngine Dev Team' />
+<meta name='description' content='CodeIgniter User Guide' />
+
+</head>
+<body>
+
+<!-- START NAVIGATION -->
+<div id="nav"><div id="nav_inner"><script type="text/javascript">create_menu('../');</script></div></div>
+<div id="nav2"><a name="top"></a><a href="javascript:void(0);" onclick="myHeight.toggle();"><img src="../images/nav_toggle_darker.jpg" width="154" height="43" border="0" title="Toggle Table of Contents" alt="Toggle Table of Contents" /></a></div>
+<div id="masthead">
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td><h1>CodeIgniter User Guide Version 2.0.2</h1></td>
+<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
+</tr>
+</table>
+</div>
+<!-- END NAVIGATION -->
+
+
+<!-- START BREADCRUMB -->
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td id="breadcrumb">
+<a href="http://codeigniter.com/">CodeIgniter Home</a> &nbsp;&#8250;&nbsp;
+<a href="../index.html">User Guide Home</a> &nbsp;&#8250;&nbsp;
+Cookie Helper
+</td>
+<td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="codeigniter.com/user_guide/" />Search User Guide&nbsp; <input type="text" class="input" style="width:200px;" name="q" id="q" size="31" maxlength="255" value="" />&nbsp;<input type="submit" class="submit" name="sa" value="Go" /></form></td>
+</tr>
+</table>
+<!-- END BREADCRUMB -->
+
+<br clear="all" />
+
+
+<!-- START CONTENT -->
+<div id="content">
+
+
+<h1>Cookie Helper</h1>
+
+<p>The Cookie Helper file contains functions that assist in working with cookies.</p>
+
+
+<h2>Loading this Helper</h2>
+
+<p>This helper is loaded using the following code:</p>
+<code>$this->load->helper('cookie');</code>
+
+<p>The following functions are available:</p>
+
+<h2>set_cookie()</h2>
+
+<p>This helper function gives you view file friendly syntax to set browser cookies.  Refer to the <a href="../libraries/input.html">Input class</a> for a description of use, as this function is an alias to $this->input->set_cookie().</p>
+
+<h2>get_cookie()</h2>
+
+<p>This helper function gives you view file friendly syntax to get browser cookies.  Refer to the <a href="../libraries/input.html">Input class</a> for a description of use, as this function is an alias to $this->input->cookie().</p>
+
+
+<h2>delete_cookie()</h2>
+
+<p>Lets you delete a cookie.  Unless you've set a custom path or other values, only the name of the cookie is needed:</p>
+
+<code>delete_cookie("name");</code>
+
+<p>This function is otherwise identical to <dfn>set_cookie()</dfn>, except that it does not have the value and expiration parameters.  You can submit an array
+of values in the first parameter or you can set discrete parameters.</p>
+
+<code>delete_cookie($name, $domain, $path, $prefix)</code>
+
+
+</div>
+<!-- END CONTENT -->
+
+
+<div id="footer">
+<p>
+Previous Topic:&nbsp;&nbsp;<a href="compatibility_helper.html">Compatibility Helper</a>
+&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+<a href="#top">Top of Page</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+<a href="../index.html">User Guide Home</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+Next Topic:&nbsp;&nbsp;<a href="date_helper.html">Date Helper</a></p>
+<p><a href="http://codeigniter.com">CodeIgniter</a> &nbsp;&middot;&nbsp; Copyright &#169; 2006 - 2011 &nbsp;&middot;&nbsp; <a href="http://ellislab.com/">EllisLab, Inc.</a></p>
+</div>
+
+</body>
+</html>
\ No newline at end of file
diff --git a/user_guide/helpers/date_helper.html b/user_guide/helpers/date_helper.html
new file mode 100755 (executable)
index 0000000..44096ff
--- /dev/null
@@ -0,0 +1,408 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head>
+
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+<title>Date Helper : CodeIgniter User Guide</title>
+
+<style type='text/css' media='all'>@import url('../userguide.css');</style>
+<link rel='stylesheet' type='text/css' media='all' href='../userguide.css' />
+
+<script type="text/javascript" src="../nav/nav.js"></script>
+<script type="text/javascript" src="../nav/prototype.lite.js"></script>
+<script type="text/javascript" src="../nav/moo.fx.js"></script>
+<script type="text/javascript" src="../nav/user_guide_menu.js"></script>
+
+<meta http-equiv='expires' content='-1' />
+<meta http-equiv= 'pragma' content='no-cache' />
+<meta name='robots' content='all' />
+<meta name='author' content='ExpressionEngine Dev Team' />
+<meta name='description' content='CodeIgniter User Guide' />
+
+</head>
+<body>
+
+<!-- START NAVIGATION -->
+<div id="nav"><div id="nav_inner"><script type="text/javascript">create_menu('../');</script></div></div>
+<div id="nav2"><a name="top"></a><a href="javascript:void(0);" onclick="myHeight.toggle();"><img src="../images/nav_toggle_darker.jpg" width="154" height="43" border="0" title="Toggle Table of Contents" alt="Toggle Table of Contents" /></a></div>
+<div id="masthead">
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td><h1>CodeIgniter User Guide Version 2.0.2</h1></td>
+<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
+</tr>
+</table>
+</div>
+<!-- END NAVIGATION -->
+
+
+<!-- START BREADCRUMB -->
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td id="breadcrumb">
+<a href="http://codeigniter.com/">CodeIgniter Home</a> &nbsp;&#8250;&nbsp;
+<a href="../index.html">User Guide Home</a> &nbsp;&#8250;&nbsp;
+Date Helper
+</td>
+<td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="codeigniter.com/user_guide/" />Search User Guide&nbsp; <input type="text" class="input" style="width:200px;" name="q" id="q" size="31" maxlength="255" value="" />&nbsp;<input type="submit" class="submit" name="sa" value="Go" /></form></td>
+</tr>
+</table>
+<!-- END BREADCRUMB -->
+
+<br clear="all" />
+
+
+<!-- START CONTENT -->
+<div id="content">
+
+
+<h1>Date Helper</h1>
+
+<p>The Date Helper file contains functions that help you work with dates.</p>
+
+
+<h2>Loading this Helper</h2>
+
+<p>This helper is loaded using the following code:</p>
+<code>$this->load->helper('date');</code>
+
+
+<p>The following functions are available:</p>
+
+<h2>now()</h2>
+
+<p>Returns the current time as a Unix timestamp, referenced either to your server's local time or GMT, based on the "time reference"
+setting in your config file.  If you do not intend to set your master time reference to GMT (which you'll typically do if you
+run a site that lets each user set their own timezone settings) there is no benefit to using this function over PHP's time() function.
+</p>
+
+
+
+
+<h2>mdate()</h2>
+
+<p>This function is identical to PHPs <a href="http://www.php.net/date">date()</a> function, except that it lets you
+use MySQL style date codes, where each code letter is preceded with a percent sign:  %Y %m %d etc.</p>
+
+<p>The benefit of doing dates this way is that you don't have to worry about escaping any characters that
+are not date codes, as you would normally have to do with the date() function.  Example:</p>
+
+<code>$datestring = "Year: %Y Month: %m Day: %d - %h:%i %a";<br />
+$time = time();<br />
+<br />
+echo mdate($datestring, $time);</code>
+
+<p>If a timestamp is not included in the second parameter the current time will be used.</p>
+
+
+<h2>standard_date()</h2>
+
+<p>Lets you generate a date string in one of several standardized formats. Example:</p>
+
+<code>
+$format = 'DATE_RFC822';<br />
+$time = time();<br />
+<br />
+echo standard_date($format, $time);
+</code>
+
+<p>The first parameter must contain the format, the second parameter must contain the date as a Unix timestamp.</p>
+
+<p>Supported formats:</p>
+
+<table cellpadding="0" cellspacing="1" border="0" style="width:100%" class="tableborder">
+       <tr>
+               <th>Constant</th>
+               <th>Description</th>
+               <th>Example</th>
+       </tr>
+       <tr>
+               <td>DATE_ATOM</td>
+               <td>Atom</td>
+               <td>2005-08-15T16:13:03+0000</td>
+       </tr>
+       <tr>
+               <td>DATE_COOKIE</td>
+               <td>HTTP Cookies</td>
+               <td>Sun, 14 Aug 2005 16:13:03 UTC</td>
+       </tr>
+       <tr>
+               <td>DATE_ISO8601</td>
+               <td>ISO-8601</td>
+               <td>2005-08-14T16:13:03+00:00</td>
+       </tr>
+       <tr>
+               <td>DATE_RFC822</td>
+               <td>RFC 822</td>
+               <td>Sun, 14 Aug 05 16:13:03 UTC</td>
+       </tr>
+       <tr>
+               <td>DATE_RFC850</td>
+               <td>RFC 850</td>
+               <td>Sunday, 14-Aug-05 16:13:03 UTC</td>
+       </tr>
+       <tr>
+               <td>DATE_RFC1036</td>
+               <td>RFC 1036</td>
+               <td>Sunday, 14-Aug-05 16:13:03 UTC</td>
+       </tr>
+       <tr>
+               <td>DATE_RFC1123</td>
+               <td>RFC 1123</td>
+               <td>Sun, 14 Aug 2005 16:13:03 UTC</td>  
+       </tr>
+       <tr>
+               <td>DATE_RFC2822</td>
+               <td>RFC 2822</td>
+               <td>Sun, 14 Aug 2005 16:13:03 +0000</td>
+       </tr>
+       <tr>
+               <td>DATE_RSS</td>
+               <td>RSS</td>
+               <td>Sun, 14 Aug 2005 16:13:03 UTC</td>
+       </tr>
+       <tr>
+               <td>DATE_W3C</td>
+               <td>World Wide Web Consortium</td>
+               <td>2005-08-14T16:13:03+0000</td>
+       </tr>
+</table>
+
+<h2>local_to_gmt()</h2>
+
+<p>Takes a Unix timestamp as input and returns it as GMT.  Example:</p>
+
+<code>$now = time();<br />
+<br />
+$gmt = local_to_gmt($now);</code>
+
+
+<h2>gmt_to_local()</h2>
+
+<p>Takes a Unix timestamp (referenced to GMT) as input, and converts it to a localized timestamp based on the
+timezone and Daylight Saving time submitted.  Example:</p>
+
+<code>
+$timestamp = '1140153693';<br />
+$timezone  = 'UM8';<br />
+$daylight_saving = TRUE;<br />
+<br />
+echo gmt_to_local($timestamp, $timezone, $daylight_saving);</code>
+
+<p><strong>Note:</strong> For a list of timezones see the reference at the bottom of this page.</p>
+
+<h2>mysql_to_unix()</h2>
+
+<p>Takes a MySQL Timestamp as input and returns it as Unix. Example:</p>
+
+<code>$mysql = '20061124092345';<br />
+<br />
+$unix = mysql_to_unix($mysql);</code>
+
+
+<h2>unix_to_human()</h2>
+
+<p>Takes a Unix timestamp as input and returns it in a human readable format with this prototype:</p>
+
+<code>YYYY-MM-DD HH:MM:SS AM/PM</code>
+
+<p>This can be useful if you need to display a date in a form field for submission.</p>
+
+<p>The time can be formatted with or without seconds, and it can be set to European or US format.  If only
+the timestamp is submitted it will return the time without seconds formatted for the U.S. Examples:</p>
+
+<code>$now = time();<br />
+<br />
+echo unix_to_human($now); // U.S. time, no seconds<br />
+<br />
+echo unix_to_human($now, TRUE, 'us'); // U.S. time with seconds<br />
+<br />
+echo unix_to_human($now, TRUE, 'eu'); // Euro time with seconds</code>
+
+
+<h2>human_to_unix()</h2>
+
+<p>The opposite of the above function.  Takes a "human" time as input and returns it as Unix.  This function is
+useful if you accept "human" formatted dates submitted via a form.  Returns FALSE (boolean) if
+the date string passed to it is not formatted as indicated above.  Example:</p>
+
+<code>$now = time();<br />
+<br />
+$human = unix_to_human($now);<br />
+<br />
+$unix = human_to_unix($human);</code>
+
+
+
+
+
+<h2>timespan()</h2>
+
+<p>Formats a unix timestamp so that is appears similar to this:</p>
+
+<code>1 Year, 10 Months, 2 Weeks, 5 Days, 10 Hours, 16 Minutes</code>
+
+<p>The first parameter must contain a Unix timestamp.  The second parameter must contain a
+timestamp that is greater that the first timestamp.  If the second parameter empty, the current time will be used.  The most common purpose
+for this function is to show how much time has elapsed from some point in time in the past to now.  Example:</p>
+
+<code>$post_date = '1079621429';<br />
+$now = time();<br />
+<br />
+echo timespan($post_date, $now);</code>
+
+<p class="important"><strong>Note:</strong> The text generated by this function is found in the following language file: language/&lt;your_lang&gt;/date_lang.php</p>
+
+
+<h2>days_in_month()</h2>
+
+<p>Returns the number of days in a given month/year. Takes leap years into account.  Example:</p>
+<code>echo days_in_month(06, 2005);</code>
+
+<p>If the second parameter is empty, the current year will be used.</p>
+<h2>timezones()</h2>
+<p> Takes a timezone reference (for a list of valid timezones, see the &quot;Timezone Reference&quot; below) and returns the number of hours offset from UTC.</p>
+<p><code>echo timezones('UM5');</code></p>
+<p>This function is useful when used with timezone_menu(). </p>
+<h2>timezone_menu()</h2>
+<p>Generates a pull-down menu of timezones, like this one:</p>
+
+<form action="#">
+<select name="timezones">
+<option value='UM12'>(UTC - 12:00) Enitwetok, Kwajalien</option>
+<option value='UM11'>(UTC - 11:00) Nome, Midway Island, Samoa</option>
+<option value='UM10'>(UTC - 10:00) Hawaii</option>
+<option value='UM9'>(UTC - 9:00) Alaska</option>
+<option value='UM8'>(UTC - 8:00) Pacific Time</option>
+<option value='UM7'>(UTC - 7:00) Mountain Time</option>
+<option value='UM6'>(UTC - 6:00) Central Time, Mexico City</option>
+<option value='UM5'>(UTC - 5:00) Eastern Time, Bogota, Lima, Quito</option>
+<option value='UM4'>(UTC - 4:00) Atlantic Time, Caracas, La Paz</option>
+<option value='UM25'>(UTC - 3:30) Newfoundland</option>
+<option value='UM3'>(UTC - 3:00) Brazil, Buenos Aires, Georgetown, Falkland Is.</option>
+<option value='UM2'>(UTC - 2:00) Mid-Atlantic, Ascention Is., St Helena</option>
+<option value='UM1'>(UTC - 1:00) Azores, Cape Verde Islands</option>
+<option value='UTC' selected='selected'>(UTC) Casablanca, Dublin, Edinburgh, London, Lisbon, Monrovia</option>
+<option value='UP1'>(UTC + 1:00) Berlin, Brussels, Copenhagen, Madrid, Paris, Rome</option>
+<option value='UP2'>(UTC + 2:00) Kaliningrad, South Africa, Warsaw</option>
+<option value='UP3'>(UTC + 3:00) Baghdad, Riyadh, Moscow, Nairobi</option>
+<option value='UP25'>(UTC + 3:30) Tehran</option>
+<option value='UP4'>(UTC + 4:00) Adu Dhabi, Baku, Muscat, Tbilisi</option>
+<option value='UP35'>(UTC + 4:30) Kabul</option>
+<option value='UP5'>(UTC + 5:00) Islamabad, Karachi, Tashkent</option>
+<option value='UP45'>(UTC + 5:30) Bombay, Calcutta, Madras, New Delhi</option>
+<option value='UP6'>(UTC + 6:00) Almaty, Colomba, Dhaka</option>
+<option value='UP7'>(UTC + 7:00) Bangkok, Hanoi, Jakarta</option>
+<option value='UP8'>(UTC + 8:00) Beijing, Hong Kong, Perth, Singapore, Taipei</option>
+<option value='UP9'>(UTC + 9:00) Osaka, Sapporo, Seoul, Tokyo, Yakutsk</option>
+<option value='UP85'>(UTC + 9:30) Adelaide, Darwin</option>
+<option value='UP10'>(UTC + 10:00) Melbourne, Papua New Guinea, Sydney, Vladivostok</option>
+<option value='UP11'>(UTC + 11:00) Magadan, New Caledonia, Solomon Islands</option>
+<option value='UP12'>(UTC + 12:00) Auckland, Wellington, Fiji, Marshall Island</option>
+</select>
+</form>
+
+<p>This menu is useful if you run a membership site in which your users are allowed to set their local timezone value.</p>
+
+<p>The first parameter lets you set the "selected" state of the menu.  For example, to set Pacific time as the default you will do this:</p>
+
+<code>echo timezone_menu('UM8');</code>
+
+<p>Please see the timezone reference below to see the values of this menu.</p>
+
+<p>The second parameter lets you set a CSS class name for the menu.</p>
+
+<p class="important"><strong>Note:</strong> The text contained in the menu is found in the following language file: language/&lt;your_lang&gt;/date_lang.php</p>
+
+
+
+<h2>Timezone Reference</h2>
+
+<p>The following table indicates each timezone and its location.</p>
+
+<table cellpadding="0" cellspacing="1" border="0" style="width:100%" class="tableborder">
+<tr>
+<th>Time Zone</th>
+<th>Location</th>
+</tr><tr>
+
+<td class="td">UM12</td><td class="td">(UTC - 12:00) Enitwetok, Kwajalien</td>
+</tr><tr>
+<td class="td">UM11</td><td class="td">(UTC - 11:00) Nome, Midway Island, Samoa</td>
+</tr><tr>
+<td class="td">UM10</td><td class="td">(UTC - 10:00) Hawaii</td>
+</tr><tr>
+<td class="td">UM9</td><td class="td">(UTC - 9:00) Alaska</td>
+</tr><tr>
+<td class="td">UM8</td><td class="td">(UTC - 8:00) Pacific Time</td>
+</tr><tr>
+<td class="td">UM7</td><td class="td">(UTC - 7:00) Mountain Time</td>
+</tr><tr>
+<td class="td">UM6</td><td class="td">(UTC - 6:00) Central Time, Mexico City</td>
+</tr><tr>
+<td class="td">UM5</td><td class="td">(UTC - 5:00) Eastern Time, Bogota, Lima, Quito</td>
+</tr><tr>
+<td class="td">UM4</td><td class="td">(UTC - 4:00) Atlantic Time, Caracas, La Paz</td>
+</tr><tr>
+<td class="td">UM25</td><td class="td">(UTC - 3:30) Newfoundland</td>
+</tr><tr>
+<td class="td">UM3</td><td class="td">(UTC - 3:00) Brazil, Buenos Aires, Georgetown, Falkland Is.</td>
+</tr><tr>
+<td class="td">UM2</td><td class="td">(UTC - 2:00) Mid-Atlantic, Ascention Is., St Helena</td>
+</tr><tr>
+<td class="td">UM1</td><td class="td">(UTC - 1:00) Azores, Cape Verde Islands</td>
+</tr><tr>
+<td class="td">UTC</td><td class="td">(UTC) Casablanca, Dublin, Edinburgh, London, Lisbon, Monrovia</td>
+</tr><tr>
+<td class="td">UP1</td><td class="td">(UTC + 1:00) Berlin, Brussels, Copenhagen, Madrid, Paris, Rome</td>
+</tr><tr>
+<td class="td">UP2</td><td class="td">(UTC + 2:00) Kaliningrad, South Africa, Warsaw</td>
+</tr><tr>
+<td class="td">UP3</td><td class="td">(UTC + 3:00) Baghdad, Riyadh, Moscow, Nairobi</td>
+</tr><tr>
+<td class="td">UP25</td><td class="td">(UTC + 3:30) Tehran</td>
+</tr><tr>
+<td class="td">UP4</td><td class="td">(UTC + 4:00) Adu Dhabi, Baku, Muscat, Tbilisi</td>
+</tr><tr>
+<td class="td">UP35</td><td class="td">(UTC + 4:30) Kabul</td>
+</tr><tr>
+<td class="td">UP5</td><td class="td">(UTC + 5:00) Islamabad, Karachi, Tashkent</td>
+</tr><tr>
+<td class="td">UP45</td><td class="td">(UTC + 5:30) Bombay, Calcutta, Madras, New Delhi</td>
+</tr><tr>
+<td class="td">UP6</td><td class="td">(UTC + 6:00) Almaty, Colomba, Dhaka</td>
+</tr><tr>
+<td class="td">UP7</td><td class="td">(UTC + 7:00) Bangkok, Hanoi, Jakarta</td>
+</tr><tr>
+<td class="td">UP8</td><td class="td">(UTC + 8:00) Beijing, Hong Kong, Perth, Singapore, Taipei</td>
+</tr><tr>
+<td class="td">UP9</td><td class="td">(UTC + 9:00) Osaka, Sapporo, Seoul, Tokyo, Yakutsk</td>
+</tr><tr>
+<td class="td">UP85</td><td class="td">(UTC + 9:30) Adelaide, Darwin</td>
+</tr><tr>
+<td class="td">UP10</td><td class="td">(UTC + 10:00) Melbourne, Papua New Guinea, Sydney, Vladivostok</td>
+</tr><tr>
+<td class="td">UP11</td><td class="td">(UTC + 11:00) Magadan, New Caledonia, Solomon Islands</td>
+</tr><tr>
+<td class="td">UP12</td><td class="td">(UTC + 12:00) Auckland, Wellington, Fiji, Marshall Island</td>
+</tr>
+</table>
+
+
+</div>
+<!-- END CONTENT -->
+
+
+<div id="footer">
+<p>
+Previous Topic:&nbsp;&nbsp;<a href="cookie_helper.html">Cookie Helper</a>
+&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+<a href="#top">Top of Page</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+<a href="../index.html">User Guide Home</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+Next Topic:&nbsp;&nbsp;<a href="directory_helper.html">Directory Helper</a>
+</p>
+<p><a href="http://codeigniter.com">CodeIgniter</a> &nbsp;&middot;&nbsp; Copyright &#169; 2006 - 2011 &nbsp;&middot;&nbsp; <a href="http://ellislab.com/">EllisLab, Inc.</a></p>
+</div>
+
+</body>
+</html>
\ No newline at end of file
diff --git a/user_guide/helpers/directory_helper.html b/user_guide/helpers/directory_helper.html
new file mode 100755 (executable)
index 0000000..1a2f28d
--- /dev/null
@@ -0,0 +1,143 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head>
+
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+<title>Directory Helper : CodeIgniter User Guide</title>
+
+<style type='text/css' media='all'>@import url('../userguide.css');</style>
+<link rel='stylesheet' type='text/css' media='all' href='../userguide.css' />
+
+<script type="text/javascript" src="../nav/nav.js"></script>
+<script type="text/javascript" src="../nav/prototype.lite.js"></script>
+<script type="text/javascript" src="../nav/moo.fx.js"></script>
+<script type="text/javascript" src="../nav/user_guide_menu.js"></script>
+
+<meta http-equiv='expires' content='-1' />
+<meta http-equiv= 'pragma' content='no-cache' />
+<meta name='robots' content='all' />
+<meta name='author' content='ExpressionEngine Dev Team' />
+<meta name='description' content='CodeIgniter User Guide' />
+
+</head>
+<body>
+
+<!-- START NAVIGATION -->
+<div id="nav"><div id="nav_inner"><script type="text/javascript">create_menu('../');</script></div></div>
+<div id="nav2"><a name="top"></a><a href="javascript:void(0);" onclick="myHeight.toggle();"><img src="../images/nav_toggle_darker.jpg" width="154" height="43" border="0" title="Toggle Table of Contents" alt="Toggle Table of Contents" /></a></div>
+<div id="masthead">
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td><h1>CodeIgniter User Guide Version 2.0.2</h1></td>
+<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
+</tr>
+</table>
+</div>
+<!-- END NAVIGATION -->
+
+
+<!-- START BREADCRUMB -->
+
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td id="breadcrumb">
+<a href="http://codeigniter.com/">CodeIgniter Home</a> &nbsp;&#8250;&nbsp;
+<a href="../index.html">User Guide Home</a> &nbsp;&#8250;&nbsp;
+Directory Helper
+</td>
+<td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="codeigniter.com/user_guide/" />Search User Guide&nbsp; <input type="text" class="input" style="width:200px;" name="q" id="q" size="31" maxlength="255" value="" />&nbsp;<input type="submit" class="submit" name="sa" value="Go" /></form></td>
+</tr>
+</table>
+<!-- END BREADCRUMB -->
+
+<br clear="all" />
+
+
+<!-- START CONTENT -->
+<div id="content">
+
+
+<h1>Directory Helper</h1>
+
+<p>The Directory Helper file contains functions that assist in working with directories.</p>
+
+
+<h2>Loading this Helper</h2>
+
+<p>This helper is loaded using the following code:</p>
+<code>$this->load->helper('directory');</code>
+
+<p>The following functions are available:</p>
+
+<h2>directory_map('<var>source directory</var>')</h2>
+
+<p>This function reads the directory path specified in the first parameter
+and builds an array representation of it and all its contained files. Example:</p>
+
+<code>$map = directory_map('./mydirectory/');</code>
+
+<p class="important"><strong>Note:</strong> Paths are almost always relative to your main index.php file.</p>
+
+<p>Sub-folders contained within the directory will be mapped as well.  If you wish to control the recursion depth,
+you can do so using the second parameter (integer). A depth of 1 will only map the top level directory:</p>
+
+<code>$map = directory_map('./mydirectory/', 1);</code>
+
+<p>By default, hidden files will not be included in the returned array.  To override this behavior,
+you may set a third parameter to <var>true</var> (boolean):</p>
+
+<code>$map = directory_map('./mydirectory/', FALSE, TRUE);</code>
+
+<p>Each folder name will be an array index, while its contained files will be numerically indexed.
+Here is an example of a typical array:</p>
+
+<code>Array<br />
+(<br />
+&nbsp;&nbsp;&nbsp;[libraries] => Array<br />
+&nbsp;&nbsp;&nbsp;(<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;[0] => benchmark.html<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;[1] => config.html<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;[database] => Array<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;[0] => active_record.html<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;[1] => binds.html<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;[2] => configuration.html<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;[3] => connecting.html<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;[4] => examples.html<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;[5] => fields.html<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;[6] => index.html<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;[7] => queries.html<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;)<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;[2] => email.html<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;[3] => file_uploading.html<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;[4] => image_lib.html<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;[5] => input.html<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;[6] => language.html<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;[7] => loader.html<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;[8] => pagination.html<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;[9] => uri.html<br />
+)</code>
+
+
+
+
+
+
+
+</div>
+<!-- END CONTENT -->
+
+
+<div id="footer">
+<p>
+Previous Topic:&nbsp;&nbsp;<a href="date_helper.html">Date Helper</a>
+&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+<a href="#top">Top of Page</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+<a href="../index.html">User Guide Home</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+Next Topic:&nbsp;&nbsp;<a href="download_helper.html">Download Helper</a>
+</p>
+<p><a href="http://codeigniter.com">CodeIgniter</a> &nbsp;&middot;&nbsp; Copyright &#169; 2006 - 2011 &nbsp;&middot;&nbsp; <a href="http://ellislab.com/">EllisLab, Inc.</a></p>
+</div>
+
+</body>
+</html>
\ No newline at end of file
diff --git a/user_guide/helpers/download_helper.html b/user_guide/helpers/download_helper.html
new file mode 100755 (executable)
index 0000000..335e97d
--- /dev/null
@@ -0,0 +1,112 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head>
+
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+<title>Download Helper : CodeIgniter User Guide</title>
+
+<style type='text/css' media='all'>@import url('../userguide.css');</style>
+<link rel='stylesheet' type='text/css' media='all' href='../userguide.css' />
+
+<script type="text/javascript" src="../nav/nav.js"></script>
+<script type="text/javascript" src="../nav/prototype.lite.js"></script>
+<script type="text/javascript" src="../nav/moo.fx.js"></script>
+<script type="text/javascript" src="../nav/user_guide_menu.js"></script>
+
+<meta http-equiv='expires' content='-1' />
+<meta http-equiv= 'pragma' content='no-cache' />
+<meta name='robots' content='all' />
+<meta name='author' content='ExpressionEngine Dev Team' />
+<meta name='description' content='CodeIgniter User Guide' />
+
+</head>
+<body>
+
+<!-- START NAVIGATION -->
+<div id="nav"><div id="nav_inner"><script type="text/javascript">create_menu('../');</script></div></div>
+<div id="nav2"><a name="top"></a><a href="javascript:void(0);" onclick="myHeight.toggle();"><img src="../images/nav_toggle_darker.jpg" width="154" height="43" border="0" title="Toggle Table of Contents" alt="Toggle Table of Contents" /></a></div>
+<div id="masthead">
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td><h1>CodeIgniter User Guide Version 2.0.2</h1></td>
+<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
+</tr>
+</table>
+</div>
+<!-- END NAVIGATION -->
+
+
+<!-- START BREADCRUMB -->
+
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td id="breadcrumb">
+<a href="http://codeigniter.com/">CodeIgniter Home</a> &nbsp;&#8250;&nbsp;
+<a href="../index.html">User Guide Home</a> &nbsp;&#8250;&nbsp;
+Download Helper
+</td>
+<td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="codeigniter.com/user_guide/" />Search User Guide&nbsp; <input type="text" class="input" style="width:200px;" name="q" id="q" size="31" maxlength="255" value="" />&nbsp;<input type="submit" class="submit" name="sa" value="Go" /></form></td>
+</tr>
+</table>
+<!-- END BREADCRUMB -->
+
+<br clear="all" />
+
+
+<!-- START CONTENT -->
+<div id="content">
+
+
+<h1>Download Helper</h1>
+
+<p>The Download Helper lets you download data to your desktop.</p>
+
+
+<h2>Loading this Helper</h2>
+
+<p>This helper is loaded using the following code:</p>
+<code>$this->load->helper('download');</code>
+
+<p>The following functions are available:</p>
+
+<h2>force_download('<var>filename</var>', '<var>data</var>')</h2>
+
+<p>Generates server headers which force data to be downloaded to your desktop. Useful with file downloads.
+The first parameter is the <strong>name you want the downloaded file to be named</strong>, the second parameter is the file data.
+Example:</p>
+
+<code>
+$data = 'Here is some text!';<br />
+$name = 'mytext.txt';<br />
+<br />
+force_download($name, $data);
+</code>
+
+<p>If you want to download an existing file from your server you'll need to read the file into a string:</p>
+
+<code>
+$data = file_get_contents("/path/to/photo.jpg"); // Read the file's contents<br />
+$name = 'myphoto.jpg';<br />
+<br />
+force_download($name, $data);
+</code>
+
+
+
+
+</div>
+<!-- END CONTENT -->
+
+
+<div id="footer">
+<p>
+Previous Topic:&nbsp;&nbsp;<a href="directory_helper.html">Directory Helper</a>
+&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+<a href="#top">Top of Page</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+<a href="../index.html">User Guide Home</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+Next Topic:&nbsp;&nbsp;<a href="email_helper.html">Email Helper</a></p>
+<p><a href="http://codeigniter.com">CodeIgniter</a> &nbsp;&middot;&nbsp; Copyright &#169; 2006 - 2011 &nbsp;&middot;&nbsp; <a href="http://ellislab.com/">EllisLab, Inc.</a></p>
+</div>
+
+</body>
+</html>
\ No newline at end of file
diff --git a/user_guide/helpers/email_helper.html b/user_guide/helpers/email_helper.html
new file mode 100755 (executable)
index 0000000..8a3868a
--- /dev/null
@@ -0,0 +1,102 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head>
+
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+<title>Email Helper : CodeIgniter User Guide</title>
+
+<style type='text/css' media='all'>@import url('../userguide.css');</style>
+<link rel='stylesheet' type='text/css' media='all' href='../userguide.css' />
+
+<script type="text/javascript" src="../nav/nav.js"></script>
+<script type="text/javascript" src="../nav/prototype.lite.js"></script>
+<script type="text/javascript" src="../nav/moo.fx.js"></script>
+<script type="text/javascript" src="../nav/user_guide_menu.js"></script>
+
+<meta http-equiv='expires' content='-1' />
+<meta http-equiv= 'pragma' content='no-cache' />
+<meta name='robots' content='all' />
+<meta name='author' content='ExpressionEngine Dev Team' />
+<meta name='description' content='CodeIgniter User Guide' />
+
+</head>
+<body>
+
+<!-- START NAVIGATION -->
+<div id="nav"><div id="nav_inner"><script type="text/javascript">create_menu('../');</script></div></div>
+<div id="nav2"><a name="top"></a><a href="javascript:void(0);" onclick="myHeight.toggle();"><img src="../images/nav_toggle_darker.jpg" width="154" height="43" border="0" title="Toggle Table of Contents" alt="Toggle Table of Contents" /></a></div>
+<div id="masthead">
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td><h1>CodeIgniter User Guide Version 2.0.2</h1></td>
+<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
+</tr>
+</table>
+</div>
+<!-- END NAVIGATION -->
+
+
+<!-- START BREADCRUMB -->
+
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td id="breadcrumb">
+<a href="http://codeigniter.com/">CodeIgniter Home</a> &nbsp;&#8250;&nbsp;
+<a href="../index.html">User Guide Home</a> &nbsp;&#8250;&nbsp;
+Email Helper
+</td>
+<td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="codeigniter.com/user_guide/" />Search User Guide&nbsp; <input type="text" class="input" style="width:200px;" name="q" id="q" size="31" maxlength="255" value="" />&nbsp;<input type="submit" class="submit" name="sa" value="Go" /></form></td>
+</tr>
+</table>
+<!-- END BREADCRUMB -->
+
+<br clear="all" />
+
+
+<!-- START CONTENT -->
+<div id="content">
+
+
+<h1>Email Helper</h1>
+
+<p>The Email Helper provides some assistive functions for working with Email. For a more robust email solution, see CodeIgniter's <a href="../libraries/email.html">Email Class</a>.</p>
+
+<h2>Loading this Helper</h2>
+
+<p>This helper is loaded using the following code:</p>
+<p><code>$this->load->helper('email');</code></p>
+
+<p>The following functions are available:</p>
+
+<h2>valid_email('<var>email</var>')</h2>
+
+<p>Checks if an email is a correctly formatted email. Note that is doesn't actually prove the email will recieve mail, simply that it is a validly formed address.</p>
+<p>It returns TRUE/FALSE</p>
+<code> $this-&gt;load-&gt;helper('email');<br />
+<br />
+if (valid_email('email@somesite.com'))<br />
+{<br />
+&nbsp;&nbsp;&nbsp;&nbsp;echo 'email is valid';<br />
+}<br />
+else<br />
+{<br />
+&nbsp;&nbsp;&nbsp;&nbsp;echo 'email is not valid';<br />
+}</code>
+<h2>send_email('<var>recipient</var>', '<var>subject</var>', '<var>message</var>')</h2>
+<p>Sends an email using PHP's native <a href="http://www.php.net/function.mail">mail()</a> function. For a more robust email solution, see CodeIgniter's <a href="../libraries/email.html">Email Class</a>.</p>
+</div>
+<!-- END CONTENT -->
+
+
+<div id="footer">
+<p>
+Previous Topic:&nbsp;&nbsp;<a href="download_helper.html">Download Helper</a>
+&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+<a href="#top">Top of Page</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+<a href="../index.html">User Guide Home</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+Next Topic:&nbsp;&nbsp;<a href="file_helper.html">File Helper</a></p>
+<p><a href="http://codeigniter.com">CodeIgniter</a> &nbsp;&middot;&nbsp; Copyright &#169; 2006 - 2011 &nbsp;&middot;&nbsp; <a href="http://ellislab.com/">EllisLab, Inc.</a></p>
+</div>
+
+</body>
+</html>
\ No newline at end of file
diff --git a/user_guide/helpers/file_helper.html b/user_guide/helpers/file_helper.html
new file mode 100755 (executable)
index 0000000..c372354
--- /dev/null
@@ -0,0 +1,179 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head>
+
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+<title>File Helper : CodeIgniter User Guide</title>
+
+<style type='text/css' media='all'>@import url('../userguide.css');</style>
+<link rel='stylesheet' type='text/css' media='all' href='../userguide.css' />
+
+<script type="text/javascript" src="../nav/nav.js"></script>
+<script type="text/javascript" src="../nav/prototype.lite.js"></script>
+<script type="text/javascript" src="../nav/moo.fx.js"></script>
+<script type="text/javascript" src="../nav/user_guide_menu.js"></script>
+
+<meta http-equiv='expires' content='-1' />
+<meta http-equiv= 'pragma' content='no-cache' />
+<meta name='robots' content='all' />
+<meta name='author' content='ExpressionEngine Dev Team' />
+<meta name='description' content='CodeIgniter User Guide' />
+</head>
+<body>
+
+<!-- START NAVIGATION -->
+<div id="nav"><div id="nav_inner"><script type="text/javascript">create_menu('../');</script></div></div>
+<div id="nav2"><a name="top"></a><a href="javascript:void(0);" onclick="myHeight.toggle();"><img src="../images/nav_toggle_darker.jpg" width="154" height="43" border="0" title="Toggle Table of Contents" alt="Toggle Table of Contents" /></a></div>
+<div id="masthead">
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td><h1>CodeIgniter User Guide Version 2.0.2</h1></td>
+<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
+</tr>
+</table>
+</div>
+<!-- END NAVIGATION -->
+
+
+<!-- START BREADCRUMB -->
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td id="breadcrumb">
+<a href="http://codeigniter.com/">CodeIgniter Home</a> &nbsp;&#8250;&nbsp;
+<a href="../index.html">User Guide Home</a> &nbsp;&#8250;&nbsp;
+File Helper
+</td>
+<td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="codeigniter.com/user_guide/" />Search User Guide&nbsp; <input type="text" class="input" style="width:200px;" name="q" id="q" size="31" maxlength="255" value="" />&nbsp;<input type="submit" class="submit" name="sa" value="Go" /></form></td>
+</tr>
+</table>
+<!-- END BREADCRUMB -->
+
+<br clear="all" />
+
+
+<!-- START CONTENT -->
+<div id="content">
+
+
+<h1>File Helper</h1>
+
+<p>The File Helper file contains functions that assist in working with files.</p>
+
+
+<h2>Loading this Helper</h2>
+
+<p>This helper is loaded using the following code:</p>
+<code>$this->load->helper('file');</code>
+
+<p>The following functions are available:</p>
+
+<h2>read_file('<var>path</var>')</h2>
+
+<p>Returns the data contained in the file specified in the path.  Example:</p>
+
+<code>$string = read_file('./path/to/file.php');</code>
+
+<p>The path can be a relative or full server path.  Returns FALSE (boolean) on failure.</p>
+
+<p class="important"><strong>Note:</strong> The path is relative to your main site index.php file, NOT your controller or view files.
+CodeIgniter uses a front controller so paths are always relative to the main site index.</p>
+
+<p>If your server is running an open_basedir restriction this function
+might not work if you are trying to access a file above the calling script.</p>
+
+<h2>write_file('<var>path</var>', <kbd>$data</kbd>)</h2>
+
+<p>Writes data to the file specified in the path.  If the file does not exist the function will create it. Example:</p>
+
+<code>
+$data = 'Some file data';<br />
+<br />
+if ( ! write_file('./path/to/file.php', $data))<br />
+{<br />
+&nbsp;&nbsp;&nbsp;&nbsp; echo 'Unable to write the file';<br />
+}<br />
+else<br />
+{<br />
+&nbsp;&nbsp;&nbsp;&nbsp; echo 'File written!';<br />
+}</code>
+
+<p>You can optionally set the write mode via the third parameter:</p>
+
+<code>write_file('./path/to/file.php', $data, <var>'r+'</var>);</code>
+
+<p>The default mode is <kbd>wb</kbd>.  Please see the <a href="http://php.net/fopen">PHP user guide</a> for mode options.</p>
+
+<p>Note: In order for this function to write data to a file its file permissions must be set such that it is writable (666, 777, etc.).
+If the file does not already exist, the directory containing it must be writable.</p>
+
+<p class="important"><strong>Note:</strong> The path is relative to your main site index.php file, NOT your controller or view files.
+CodeIgniter uses a front controller so paths are always relative to the main site index.</p>
+
+<h2>delete_files('<var>path</var>')</h2>
+
+<p>Deletes ALL files contained in the supplied path.  Example:</p>
+<code>delete_files('./path/to/directory/');</code>
+
+<p>If the second parameter is set to <kbd>true</kbd>, any directories contained within the supplied root path will be deleted as well. Example:</p>
+
+<code>delete_files('./path/to/directory/', TRUE);</code>
+
+<p class="important"><strong>Note:</strong> The files must be writable or owned by the system in order to be deleted.</p>
+
+<h2>get_filenames('<var>path/to/directory/</var>')</h2>
+
+<p>Takes a server path as input and returns an array containing the names of all files contained within it. The file path
+can optionally be added to the file names by setting the second parameter to TRUE.</p>
+
+<h2>get_dir_file_info('<var>path/to/directory/</var>', <kbd>$top_level_only</kbd> = TRUE)</h2>
+
+<p>Reads the specified directory and builds an array containing the filenames, filesize, dates, and permissions.  Sub-folders contained within the specified path are only read if forced
+       by sending the second parameter, <kbd>$top_level_only</kbd> to <samp>FALSE</samp>, as this can be an intensive operation.</p>
+
+<h2>get_file_info('<var>path/to/file</var>', <kbd>$file_information</kbd>)</h2>
+
+<p>Given a file and path, returns the name, path, size, date modified. Second parameter allows you to explicitly declare what information you want returned; options are: name, server_path, size, date, readable, writable, executable, fileperms.  Returns FALSE if the file cannot be found.</p>
+
+<p class="important"><strong>Note:</strong> The &quot;writable&quot; uses the PHP function is_writable() which is known to have issues on the IIS webserver. Consider using fileperms instead, which returns information from PHP's fileperms() function.</p>
+<h2>get_mime_by_extension('<var>file</var>')</h2>
+
+<p>Translates a file extension into a mime type based on config/mimes.php. Returns FALSE if it can't determine the type, or open the mime config file.</p>
+<p>
+<code>$file = &quot;somefile.png&quot;;<br />
+echo $file . ' is has a mime type of ' . get_mime_by_extension($file);</code>
+</p>
+<p class="critical"><strong>Note:</strong> This is not an accurate way of determining file mime types, and is here strictly as a convenience. It should not be  used for security.</p>
+
+<h2>symbolic_permissions(<kbd>$perms</kbd>)</h2>
+
+<p>Takes numeric permissions (such as is returned by <kbd>fileperms()</kbd> and returns standard symbolic notation of file permissions.</p>
+
+<code>echo symbolic_permissions(fileperms('./index.php'));<br />
+<br />
+// -rw-r--r--</code>
+
+<h2>octal_permissions(<kbd>$perms</kbd>)</h2>
+
+<p>Takes numeric permissions (such as is returned by <kbd>fileperms()</kbd> and returns a three character octal notation of file permissions.</p>
+
+<code>echo octal_permissions(fileperms('./index.php'));<br />
+<br />
+// 644</code>
+
+</div>
+
+<!-- END CONTENT -->
+
+
+<div id="footer">
+<p>
+Previous Topic:&nbsp;&nbsp;<a href="email_helper.html">Email Helper</a>
+&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+<a href="#top">Top of Page</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+<a href="../index.html">User Guide Home</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+Next Topic:&nbsp;&nbsp;<a href="form_helper.html">Form Helper</a></p>
+<p><a href="http://codeigniter.com">CodeIgniter</a> &nbsp;&middot;&nbsp; Copyright &#169; 2006 - 2011 &nbsp;&middot;&nbsp; <a href="http://ellislab.com/">EllisLab, Inc.</a></p>
+</div>
+
+</body>
+</html>
\ No newline at end of file
diff --git a/user_guide/helpers/form_helper.html b/user_guide/helpers/form_helper.html
new file mode 100755 (executable)
index 0000000..f82c669
--- /dev/null
@@ -0,0 +1,484 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head>
+
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+<title>Form Helper : CodeIgniter User Guide</title>
+
+<style type='text/css' media='all'>@import url('../userguide.css');</style>
+<link rel='stylesheet' type='text/css' media='all' href='../userguide.css' />
+
+<script type="text/javascript" src="../nav/nav.js"></script>
+<script type="text/javascript" src="../nav/prototype.lite.js"></script>
+<script type="text/javascript" src="../nav/moo.fx.js"></script>
+<script type="text/javascript" src="../nav/user_guide_menu.js"></script>
+
+<meta http-equiv='expires' content='-1' />
+<meta http-equiv= 'pragma' content='no-cache' />
+<meta name='robots' content='all' />
+<meta name='author' content='ExpressionEngine Dev Team' />
+<meta name='description' content='CodeIgniter User Guide' />
+
+</head>
+<body>
+
+<!-- START NAVIGATION -->
+<div id="nav"><div id="nav_inner"><script type="text/javascript">create_menu('../');</script></div></div>
+<div id="nav2"><a name="top"></a><a href="javascript:void(0);" onclick="myHeight.toggle();"><img src="../images/nav_toggle_darker.jpg" width="154" height="43" border="0" title="Toggle Table of Contents" alt="Toggle Table of Contents" /></a></div>
+<div id="masthead">
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td><h1>CodeIgniter User Guide Version 2.0.2</h1></td>
+<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
+</tr>
+</table>
+</div>
+<!-- END NAVIGATION -->
+
+
+<!-- START BREADCRUMB -->
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td id="breadcrumb">
+<a href="http://codeigniter.com/">CodeIgniter Home</a> &nbsp;&#8250;&nbsp;
+<a href="../index.html">User Guide Home</a> &nbsp;&#8250;&nbsp;
+Form Helper
+</td>
+<td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="codeigniter.com/user_guide/" />Search User Guide&nbsp; <input type="text" class="input" style="width:200px;" name="q" id="q" size="31" maxlength="255" value="" />&nbsp;<input type="submit" class="submit" name="sa" value="Go" /></form></td>
+</tr>
+</table>
+<!-- END BREADCRUMB -->
+
+<br clear="all" />
+
+
+<!-- START CONTENT -->
+<div id="content">
+
+
+<h1>Form Helper</h1>
+
+<p>The Form Helper file contains functions that assist in working with forms.</p>
+
+
+<h2>Loading this Helper</h2>
+
+<p>This helper is loaded using the following code:</p>
+<code>$this->load->helper('form');</code>
+
+<p>The following functions are available:</p>
+
+
+
+<h2>form_open()</h2>
+
+<p>Creates an opening form tag with a base URL <strong>built from your config preferences</strong>.  It will optionally let you
+add form attributes and hidden input fields, and will always add the attribute <kbd>accept-charset</kbd> based on the charset value in your config file.</p>
+
+<p>The main benefit of using this tag rather than hard coding your own HTML is that it permits your site to be more portable
+in the event your URLs ever change.</p>
+
+<p>Here's a simple example:</p>
+
+<code>echo form_open('email/send');</code>
+
+<p>The above example would create a form that points to your base URL plus the "email/send" URI segments, like this:</p>
+
+<code>&lt;form method="post" accept-charset="utf-8" action="http:/example.com/index.php/email/send" /></code>
+
+<h4>Adding Attributes</h4>
+
+<p>Attributes can be added by passing an associative array to the second parameter, like this:</p>
+
+<code>
+$attributes = array('class' => 'email', 'id' => 'myform');<br />
+<br />
+echo form_open('email/send', $attributes);</code>
+
+<p>The above example would create a form similar to this:</p>
+
+<code>&lt;form method="post" accept-charset="utf-8" action="http:/example.com/index.php/email/send" &nbsp;class="email" &nbsp;id="myform" /></code>
+
+<h4>Adding Hidden Input Fields</h4>
+
+<p>Hidden fields can be added by passing an associative array to the third parameter, like this:</p>
+
+<code>
+$hidden = array('username' => 'Joe', 'member_id' => '234');<br />
+<br />
+echo form_open('email/send', '', $hidden);</code>
+
+<p>The above example would create a form similar to this:</p>
+
+<code>&lt;form method="post" accept-charset="utf-8" action="http:/example.com/index.php/email/send"><br />
+&lt;input type="hidden" name="username" value="Joe" /><br />
+&lt;input type="hidden" name="member_id" value="234" /></code>
+
+
+<h2>form_open_multipart()</h2>
+
+<p>This function is absolutely identical to the <dfn>form_open()</dfn> tag above except that it adds a multipart attribute,
+which is necessary if you would like to use the form to upload files with.</p>
+
+<h2>form_hidden()</h2>
+
+<p>Lets you generate hidden input fields.  You can either submit a name/value string to create one field:</p>
+
+<code>form_hidden('username', 'johndoe');<br />
+<br />
+// Would produce:<br /><br />
+&lt;input type="hidden" name="username" value="johndoe" /></code>
+
+<p>Or you can submit an associative array to create multiple fields:</p>
+
+<code>$data = array(<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'name'&nbsp;&nbsp;=> 'John Doe',<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'email' => 'john@example.com',<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'url'&nbsp;&nbsp;&nbsp;=> 'http://example.com'<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;);<br />
+<br />
+echo form_hidden($data);<br />
+<br />
+// Would produce:<br /><br />
+&lt;input type="hidden" name="name" value="John Doe" /><br />
+&lt;input type="hidden" name="email" value="john@example.com" /><br />
+&lt;input type="hidden" name="url" value="http://example.com" /></code>
+
+
+
+
+<h2>form_input()</h2>
+
+<p>Lets you generate a standard text input field.  You can minimally pass the field name and value in the first
+and second parameter:</p>
+
+<code>echo form_input('username', 'johndoe');</code>
+
+<p>Or you can pass an associative array containing any data you wish your form to contain:</p>
+
+<code>$data = array(<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'name'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=> 'username',<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'id'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=> 'username',<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'value'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=> 'johndoe',<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'maxlength'&nbsp;&nbsp;&nbsp;=> '100',<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'size'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=> '50',<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'style'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; => 'width:50%',<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;);<br />
+<br />
+echo form_input($data);<br />
+<br />
+// Would produce:<br /><br />
+&lt;input type="text" name="username" id="username" value="johndoe" maxlength="100" size="50" style="width:50%" /></code>
+
+<p>If you would like your form to contain some additional data, like Javascript, you can pass it as a string in the
+third parameter:</p>
+
+<code>$js = 'onClick="some_function()"';<br />
+<br />
+echo form_input('username', 'johndoe', $js);</code>
+
+<h2>form_password()</h2>
+
+<p>This function is identical in all respects to the <dfn>form_input()</dfn> function above
+except that is sets it as a "password" type.</p>
+
+<h2>form_upload()</h2>
+
+<p>This function is identical in all respects to the <dfn>form_input()</dfn> function above
+except that is sets it as a "file" type, allowing it to be used to upload files.</p>
+
+<h2>form_textarea()</h2>
+
+<p>This function is identical in all respects to the <dfn>form_input()</dfn> function above
+except that it generates a "textarea" type. Note: Instead of the "maxlength" and "size" attributes in the above
+example, you will instead specify "rows" and "cols".</p>
+
+
+<h2>form_dropdown()</h2>
+
+<p>Lets you create a standard drop-down field.  The first parameter will contain the name of the field,
+the second parameter will contain an associative array of options, and the third parameter will contain the
+value you wish to be selected.  You can also pass an array of multiple items through the third parameter, and CodeIgniter will create a multiple select for you. Example:</p>
+
+<code>$options = array(<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'small'&nbsp;&nbsp;=> 'Small Shirt',<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'med'&nbsp;&nbsp;&nbsp;&nbsp;=> 'Medium Shirt',<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'large'&nbsp;&nbsp; => 'Large Shirt',<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'xlarge' => 'Extra Large Shirt',<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;);<br />
+<br />
+$shirts_on_sale = array('small', 'large');<br />
+<br />
+echo form_dropdown('shirts', $options, 'large');<br />
+<br />
+// Would produce:<br />
+<br />
+&lt;select name=&quot;shirts&quot;&gt;<br />
+&lt;option value=&quot;small&quot;&gt;Small Shirt&lt;/option&gt;<br />
+&lt;option value=&quot;med&quot;&gt;Medium  Shirt&lt;/option&gt;<br />
+&lt;option value=&quot;large&quot; selected=&quot;selected&quot;&gt;Large Shirt&lt;/option&gt;<br />
+&lt;option value=&quot;xlarge&quot;&gt;Extra Large Shirt&lt;/option&gt;<br />
+&lt;/select&gt;<br />
+<br />
+echo form_dropdown('shirts', $options, $shirts_on_sale);<br />
+<br />
+// Would produce:<br />
+<br />
+&lt;select name=&quot;shirts&quot; multiple=&quot;multiple&quot;&gt;<br />
+&lt;option value=&quot;small&quot; selected=&quot;selected&quot;&gt;Small Shirt&lt;/option&gt;<br />
+&lt;option value=&quot;med&quot;&gt;Medium  Shirt&lt;/option&gt;<br />
+&lt;option value=&quot;large&quot; selected=&quot;selected&quot;&gt;Large Shirt&lt;/option&gt;<br />
+&lt;option value=&quot;xlarge&quot;&gt;Extra Large Shirt&lt;/option&gt;<br />
+&lt;/select&gt;</code>
+
+
+<p>If you would like the opening &lt;select> to contain additional data, like an <kbd>id</kbd> attribute or JavaScript, you can pass it as a string in the
+fourth parameter:</p>
+
+<code>$js = 'id="shirts" onChange="some_function();"';<br />
+<br />
+echo form_dropdown('shirts', $options, 'large', $js);</code>
+
+<p>If the array passed as $options is a multidimensional array, form_dropdown() will produce an &lt;optgroup&gt; with the array key as the label.</p>
+
+<h2>form_multiselect()</h2>
+
+<p>Lets you create a standard multiselect field.  The first parameter will contain the name of the field,
+the second parameter will contain an associative array of options, and the third parameter will contain the
+value or values you wish to be selected.  The parameter usage is identical to using <kbd>form_dropdown()</kbd> above,
+except of course that the name of the field will need to use POST array syntax, e.g. <samp>foo[]</samp>.</p>
+
+
+<h2>form_fieldset()</h2>
+
+<p>Lets you generate fieldset/legend fields.</p>
+<code>echo form_fieldset('Address Information');<br />
+echo &quot;&lt;p&gt;fieldset content here&lt;/p&gt;\n&quot;;<br />
+echo form_fieldset_close();
+<br />
+<br />
+// Produces<br />
+&lt;fieldset&gt;
+<br />
+&lt;legend&gt;Address Information&lt;/legend&gt;
+<br />
+&lt;p&gt;form content here&lt;/p&gt;
+<br />
+&lt;/fieldset&gt;</code>
+<p>Similar to other functions, you can submit an associative array in the second parameter if you prefer to set additional attributes. </p>
+<p><code>$attributes = array('id' =&gt; 'address_info', 'class' =&gt; 'address_info');<br />
+    echo form_fieldset('Address Information', $attributes);<br />
+echo &quot;&lt;p&gt;fieldset content here&lt;/p&gt;\n&quot;;<br />
+echo form_fieldset_close(); <br />
+<br />
+// Produces<br />
+&lt;fieldset id=&quot;address_info&quot; class=&quot;address_info&quot;&gt; <br />
+&lt;legend&gt;Address Information&lt;/legend&gt; <br />
+&lt;p&gt;form content here&lt;/p&gt; <br />
+&lt;/fieldset&gt;</code></p>
+<h2>form_fieldset_close()</h2>
+<p>Produces a closing &lt;/fieldset&gt; tag.  The only advantage to using this function is it permits you to pass data to it
+    which will be added below the tag.  For example:</p>
+<code>$string = &quot;&lt;/div&gt;&lt;/div&gt;&quot;;<br />
+<br />
+echo fieldset_close($string);<br />
+<br />
+// Would produce:<br />
+&lt;/fieldset&gt;<br />
+&lt;/div&gt;&lt;/div&gt;</code>
+<h2>form_checkbox()</h2>
+<p>Lets you generate a checkbox field. Simple example:</p>
+<code>echo form_checkbox('newsletter', 'accept', TRUE);<br />
+<br />
+// Would produce:<br />
+<br />
+&lt;input type=&quot;checkbox&quot; name=&quot;newsletter&quot; value=&quot;accept&quot; checked=&quot;checked&quot; /&gt;</code>
+<p>The third parameter contains a boolean TRUE/FALSE to determine whether the box should be checked or not.</p>
+<p>Similar to the other form functions in this helper, you can also pass an array of attributes to the function:</p>
+
+<code>$data = array(<br />
+&nbsp;&nbsp;&nbsp;&nbsp;'name'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=> 'newsletter',<br />
+&nbsp;&nbsp;&nbsp;&nbsp;'id'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=> 'newsletter',<br />
+&nbsp;&nbsp;&nbsp;&nbsp;'value'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=> 'accept',<br />
+&nbsp;&nbsp;&nbsp;&nbsp;'checked'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=> TRUE,<br />
+&nbsp;&nbsp;&nbsp;&nbsp;'style'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; => 'margin:10px',<br />
+&nbsp;&nbsp;&nbsp;&nbsp;);<br />
+<br />
+echo form_checkbox($data);<br />
+<br />
+// Would produce:<br /><br />
+&lt;input type="checkbox" name="newsletter" id="newsletter" value="accept" checked="checked" style="margin:10px" /></code>
+
+<p>As with other functions, if you would like the tag to contain  additional data, like JavaScript, you can pass it as a string in the
+fourth parameter:</p>
+
+<code>$js = 'onClick="some_function()"';<br />
+<br />
+ echo form_checkbox('newsletter', 'accept', TRUE, $js)</code>
+
+
+<h2>form_radio()</h2>
+<p>This function is identical in all respects to the <dfn>form_checkbox()</dfn> function above except that is sets it as a "radio" type.</p>
+
+
+<h2>form_submit()</h2>
+
+<p>Lets you generate a standard submit button. Simple example:</p>
+<code>echo form_submit('mysubmit', 'Submit Post!');<br />
+<br />
+// Would produce:<br />
+<br />
+&lt;input type=&quot;submit&quot; name=&quot;mysubmit&quot; value=&quot;Submit Post!&quot; /&gt;</code>
+<p>Similar to other functions, you can submit an associative array in the first parameter if you prefer to set your own attributes.
+    The third parameter lets you add extra data to your form, like JavaScript.</p>
+<h2>form_label()</h2>
+<p>Lets you generate a &lt;label&gt;. Simple example:</p>
+<code>echo form_label('What is your Name', 'username');<br />
+<br />
+// Would produce:
+<br />
+&lt;label for=&quot;username&quot;&gt;What is your Name&lt;/label&gt;</code>
+<p>Similar to other functions, you can submit an associative array in the third parameter if you prefer to set additional attributes.    </p>
+<p><code>$attributes = array(<br />
+&nbsp;&nbsp;&nbsp;&nbsp;'class' =&gt; 'mycustomclass',<br />
+&nbsp;&nbsp;&nbsp;&nbsp;'style' =&gt; 'color: #000;',<br />
+);<br />
+    echo form_label('What is your Name', 'username', $attributes);<br />
+        <br />
+// Would produce: <br />
+&lt;label for=&quot;username&quot; class=&quot;mycustomclass&quot; style=&quot;color: #000;&quot;&gt;What is your Name&lt;/label&gt;</code></p>
+<h2>form_reset()</h2>
+
+<p>Lets you generate a standard reset button. Use is identical to <dfn>form_submit()</dfn>.</p>
+
+<h2>form_button()</h2>
+
+<p>Lets you generate a standard button element. You can minimally pass the button name and content in the first and second parameter:</p>
+<code>
+echo form_button('name','content');<br />
+<br />
+// Would produce<br />
+&lt;button name="name" type="button"&gt;Content&lt;/button&gt;
+</code>
+
+Or you can pass an associative array containing any data you wish your form to contain:
+<code>
+$data = array(<br />
+&nbsp;&nbsp;&nbsp;&nbsp;'name' => 'button',<br />
+&nbsp;&nbsp;&nbsp;&nbsp;'id' => 'button',<br />
+&nbsp;&nbsp;&nbsp;&nbsp;'value' => 'true',<br />
+&nbsp;&nbsp;&nbsp;&nbsp;'type' => 'reset',<br />
+&nbsp;&nbsp;&nbsp;&nbsp;'content' => 'Reset'<br />
+);<br />
+<br />
+echo form_button($data);<br />
+<br />
+// Would produce:<br />
+&lt;button name="button" id="button" value="true" type="reset"&gt;Reset&lt;/button&gt;
+</code>
+
+If you would like your form to contain some additional data, like JavaScript, you can pass it as a string in the third parameter:
+<code>
+$js = 'onClick="some_function()"';<br /><br />
+echo form_button('mybutton', 'Click Me', $js);
+</code>
+
+
+<h2>form_close()</h2>
+
+<p>Produces a closing &lt;/form> tag.  The only advantage to using this function is it permits you to pass data to it
+which will be added below the tag.  For example:</p>
+
+<code>$string = "&lt;/div>&lt;/div>";<br />
+<br />
+echo form_close($string);<br />
+<br />
+// Would produce:<br />
+<br />
+&lt;/form><br />
+&lt;/div>&lt;/div></code>
+
+
+
+
+
+<h2>form_prep()</h2>
+
+<p>Allows you to safely use HTML and characters such as quotes within form elements without breaking out of the form.  Consider this example:</p>
+
+<code>$string = 'Here is a string containing <strong>"quoted"</strong> text.';<br />
+<br />
+&lt;input type="text" name="myform" value="<var>$string</var>" /></code>
+
+<p>Since the above string contains a set of quotes it will cause the form to break.
+The form_prep function converts HTML so that it can be used safely:</p>
+
+<code>&lt;input type="text" name="myform" value="<var>&lt;?php echo form_prep($string); ?></var>" /></code>
+
+<p class="important"><strong>Note:</strong> If you use any of the form helper functions listed in this page the form
+values will be prepped automatically, so there is no need to call this function. Use it only if you are
+creating your own form elements.</p>
+
+
+<h2>set_value()</h2>
+
+<p>Permits you to set the value of an input form or textarea. You must supply the field name via the first parameter of the function.
+The second (optional) parameter allows you to set a default value for the form. Example:</p>
+
+<code>&lt;input type="text" name="quantity" value="<dfn>&lt;?php echo set_value('quantity', '0'); ?></dfn>" size="50" /></code>
+
+<p>The above form will show "0" when loaded for the first time.</p>
+
+<h2>set_select()</h2>
+
+<p>If you use a <dfn>&lt;select></dfn> menu, this function permits you to display the menu item that was selected.  The first parameter
+must contain the name of the select menu, the second parameter must contain the value of
+each item, and the third (optional) parameter lets you set an item as the default (use boolean TRUE/FALSE).</p>
+
+<p>Example:</p>
+
+<code>
+&lt;select name="myselect"><br />
+&lt;option value="one" <dfn>&lt;?php echo  set_select('myselect', 'one', TRUE); ?></dfn> >One&lt;/option><br />
+&lt;option value="two" <dfn>&lt;?php echo  set_select('myselect', 'two'); ?></dfn> >Two&lt;/option><br />
+&lt;option value="three" <dfn>&lt;?php echo  set_select('myselect', 'three'); ?></dfn> >Three&lt;/option><br />
+&lt;/select>
+</code>
+
+
+<h2>set_checkbox()</h2>
+
+<p>Permits you to display a checkbox in the state it was submitted.  The first parameter
+must contain the name of the checkbox, the second parameter must contain its value, and the third (optional) parameter lets you set an item as the default (use boolean TRUE/FALSE). Example:</p>
+
+<code>&lt;input type="checkbox" name="mycheck" value="1" <dfn>&lt;?php echo set_checkbox('mycheck', '1'); ?></dfn> /><br />
+&lt;input type="checkbox" name="mycheck" value="2" <dfn>&lt;?php echo set_checkbox('mycheck', '2'); ?></dfn> /></code>
+
+
+<h2>set_radio()</h2>
+
+<p>Permits you to display radio buttons in the state they were submitted. This function is identical to the <strong>set_checkbox()</strong> function above.</p>
+
+<code>&lt;input type="radio" name="myradio" value="1" <dfn>&lt;?php echo  set_radio('myradio', '1', TRUE); ?></dfn> /><br />
+&lt;input type="radio" name="myradio" value="2" <dfn>&lt;?php echo  set_radio('myradio', '2'); ?></dfn> /></code>
+
+
+
+
+</div>
+<!-- END CONTENT -->
+
+
+<div id="footer">
+<p>
+Previous Topic:&nbsp;&nbsp;<a href="file_helper.html">File Helper</a>
+&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+<a href="#top">Top of Page</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+<a href="../index.html">User Guide Home</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+Next Topic:&nbsp;&nbsp;<a href="html_helper.html">HTML Helper</a>
+</p>
+<p><a href="http://codeigniter.com">CodeIgniter</a> &nbsp;&middot;&nbsp; Copyright &#169; 2006 - 2011 &nbsp;&middot;&nbsp; <a href="http://ellislab.com/">EllisLab, Inc.</a></p>
+</div>
+
+</body>
+</html>
\ No newline at end of file
diff --git a/user_guide/helpers/html_helper.html b/user_guide/helpers/html_helper.html
new file mode 100755 (executable)
index 0000000..1a0529f
--- /dev/null
@@ -0,0 +1,385 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head>
+
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+<title>HTML Helper : CodeIgniter User Guide</title>
+
+<style type='text/css' media='all'>@import url('../userguide.css');</style>
+<link rel='stylesheet' type='text/css' media='all' href='../userguide.css' />
+
+<script type="text/javascript" src="../nav/nav.js"></script>
+<script type="text/javascript" src="../nav/prototype.lite.js"></script>
+<script type="text/javascript" src="../nav/moo.fx.js"></script>
+<script type="text/javascript" src="../nav/user_guide_menu.js"></script>
+
+<meta http-equiv='expires' content='-1' />
+<meta http-equiv= 'pragma' content='no-cache' />
+<meta name='robots' content='all' />
+<meta name='author' content='ExpressionEngine Dev Team' />
+<meta name='description' content='CodeIgniter User Guide' />
+
+</head>
+<body>
+
+<!-- START NAVIGATION -->
+<div id="nav"><div id="nav_inner"><script type="text/javascript">create_menu('../');</script></div></div>
+<div id="nav2"><a name="top"></a><a href="javascript:void(0);" onclick="myHeight.toggle();"><img src="../images/nav_toggle_darker.jpg" width="154" height="43" border="0" title="Toggle Table of Contents" alt="Toggle Table of Contents" /></a></div>
+<div id="masthead">
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td><h1>CodeIgniter User Guide Version 2.0.2</h1></td>
+<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
+</tr>
+</table>
+</div>
+<!-- END NAVIGATION -->
+
+
+<!-- START BREADCRUMB -->
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td id="breadcrumb">
+<a href="http://codeigniter.com/">CodeIgniter Home</a> &nbsp;&#8250;&nbsp;
+<a href="../index.html">User Guide Home</a> &nbsp;&#8250;&nbsp;
+HTML Helper
+</td>
+<td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="codeigniter.com/user_guide/" />Search User Guide&nbsp; <input type="text" class="input" style="width:200px;" name="q" id="q" size="31" maxlength="255" value="" />&nbsp;<input type="submit" class="submit" name="sa" value="Go" /></form></td>
+</tr>
+</table>
+<!-- END BREADCRUMB -->
+
+<br clear="all" />
+
+
+<!-- START CONTENT -->
+<div id="content">
+
+
+<h1>HTML Helper</h1>
+
+<p>The HTML Helper file contains functions that assist in working with HTML.</p>
+
+<ul>
+       <li><a href="#br">br()</a></li>
+       <li><a href="#heading">heading()</a></li>
+       <li><a href="#img">img()</a></li>
+       <li><a href="#link_tag">link_tag()</a></li>
+       <li><a href="#nbs">nbs()</a></li>
+       <li><a href="#ol_and_ul">ol() and ul()</a></li>
+       <li><a href="#meta">meta()</a></li>
+       <li><a href="#doctype">doctype()</a></li>
+</ul>
+
+<h2>Loading this Helper</h2>
+
+<p>This helper is loaded using the following code:</p>
+<code>$this->load->helper('html');</code>
+
+<p>The following functions are available:</p>
+
+<h2><a name="br"></a>br()</h2>
+<p>Generates line break tags (&lt;br />) based on the number you submit. Example:</p>
+<code>echo br(3);</code>
+<p>The above would produce: &lt;br />&lt;br />&lt;br /></p>
+
+<h2><a name="heading"></a>heading()</h2>
+<p>Lets you create HTML &lt;h1> tags.  The first parameter will contain the data, the
+second the size of the heading.  Example:</p>
+<code>echo heading('Welcome!', 3);</code>
+<p>The above would produce:  &lt;h3>Welcome!&lt;/h3></p>
+
+<h2><a name="img"></a>img()</h2>
+<p>Lets you create HTML &lt;img /&gt; tags.  The first parameter  contains the image source. Example:</p>
+<code>echo img('images/picture.jpg');<br />
+// gives &lt;img src=&quot;http://site.com/images/picture.jpg&quot; /&gt;</code>
+<p>There is an optional second parameter that is a TRUE/FALSE value that specifics if the src should have the page specified by $config['index_page'] added to the address it creates. Presumably, this would be if you were using a media controller.</p>
+<p><code>echo img('images/picture.jpg', TRUE);<br />
+// gives &lt;img src=&quot;http://site.com/index.php/images/picture.jpg&quot; alt=&quot;&quot; /&gt;</code></p>
+<p>Additionally, an associative array can be passed to the img() function for complete control over all attributes and values. If an alt attribute is not provided, CodeIgniter will generate an empty string.</p>
+<p><code> $image_properties = array(<br />
+       &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'src' =&gt; 'images/picture.jpg',<br />
+       &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'alt' =&gt; 'Me, demonstrating how to eat 4 slices of pizza at one time',<br />
+       &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'class' =&gt; 'post_images',<br />
+       &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'width' =&gt; '200',<br />
+       &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'height' =&gt; '200',<br />
+       &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'title' =&gt; 'That was quite a night',<br />
+       &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'rel' =&gt; 'lightbox',<br />
+       );<br />
+       <br />
+       img($image_properties);<br />
+       // &lt;img src=&quot;http://site.com/index.php/images/picture.jpg&quot; alt=&quot;Me, demonstrating how to eat 4 slices of pizza at one time&quot; class=&quot;post_images&quot; width=&quot;200&quot; height=&quot;200&quot; title=&quot;That was quite a night&quot; rel=&quot;lightbox&quot; /&gt;</code></p>
+
+<h2><a name="link_tag"></a>link_tag()</h2>
+<p>Lets you create HTML &lt;link /> tags.  This is useful for stylesheet links, as well as other links. The parameters are href, with optional rel, type, title, media and index_page. index_page is a TRUE/FALSE value that specifics if the href should have the page specified by $config['index_page'] added to the address it creates.<code>
+echo link_tag('css/mystyles.css');<br />
+// gives &lt;link href=&quot;http://site.com/css/mystyles.css&quot; rel=&quot;stylesheet&quot; type=&quot;text/css&quot; /&gt;</code></p>
+<p>Further examples:</p>
+
+<code>
+       echo link_tag('favicon.ico', 'shortcut icon', 'image/ico');<br />
+       // &lt;link href=&quot;http://site.com/favicon.ico&quot; rel=&quot;shortcut icon&quot; type=&quot;image/ico&quot; /&gt;
+       <br />
+       <br />
+       echo link_tag('feed', 'alternate', 'application/rss+xml', 'My RSS Feed');<br />
+       // &lt;link href=&quot;http://site.com/feed&quot; rel=&quot;alternate&quot; type=&quot;application/rss+xml&quot; title=&quot;My RSS Feed&quot; /&gt; </code>
+<p>Additionally, an associative array can be passed to the link() function for complete control over all attributes and values.</p>
+<p><code>
+       $link = array(<br />
+       &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'href' =&gt; 'css/printer.css',<br />
+       &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'rel' =&gt; 'stylesheet',<br />
+       &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'type' =&gt; 'text/css',<br />
+       &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'media' =&gt; 'print'<br />
+       );<br />
+       <br />
+       echo link_tag($link);<br />
+       // &lt;link href=&quot;http://site.com/css/printer.css&quot; rel=&quot;stylesheet&quot; type=&quot;text/css&quot; media=&quot;print&quot; /&gt;</code></p>
+
+<h2><a name="nbs"></a>nbs()</h2>
+<p>Generates non-breaking spaces (&amp;nbsp;) based on the number you submit. Example:</p>
+<code>echo nbs(3);</code>
+<p>The above would produce: &amp;nbsp;&amp;nbsp;&amp;nbsp;</p>
+
+<h2><a name="ol_and_ul"></a>ol()&nbsp; and&nbsp; ul()</h2>
+
+<p>Permits you to generate ordered or unordered HTML lists from simple or multi-dimensional arrays. Example:</p>
+
+<code>
+$this->load->helper('html');<br />
+<br />
+$list = array(<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'red', <br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'blue', <br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'green',<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'yellow'<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;);<br />
+<br />
+$attributes = array(<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'class' => 'boldlist',<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'id'&nbsp;&nbsp;&nbsp;&nbsp;=> 'mylist'<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;);<br />
+<br />
+echo ul($list, $attributes);<br />
+</code>
+
+<p>The above code will produce this:</p>
+
+<code>
+&lt;ul&nbsp;class="boldlist"&nbsp;id="mylist"><br />
+&nbsp;&nbsp;&lt;li>red&lt;/li><br />
+&nbsp;&nbsp;&lt;li>blue&lt;/li><br />
+&nbsp;&nbsp;&lt;li>green&lt;/li><br />
+&nbsp;&nbsp;&lt;li>yellow&lt;/li><br />
+&lt;/ul>
+</code>
+
+<p>Here is a more complex example, using a multi-dimensional array:</p>
+
+<code>
+$this->load->helper('html');<br />
+<br />
+$attributes = array(<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'class' => 'boldlist',<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'id'&nbsp;&nbsp;&nbsp;&nbsp;=> 'mylist'<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;);<br />
+<br />
+$list = array(<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'colors' => array(<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'red',<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'blue',<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'green'<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;),<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'shapes' => array(<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'round', <br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'square',<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'circles' => array(<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'ellipse', <br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'oval', <br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'sphere'<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;)<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;),<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'moods'&nbsp;&nbsp;&nbsp;&nbsp;=> array(<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'happy', <br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'upset' => array(<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'defeated' => array(<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'dejected',<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'disheartened',<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'depressed'<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;),<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'annoyed',<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'cross',<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'angry'<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;)<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;)<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;);<br />
+<br />
+<br />
+echo ul($list, $attributes);</code>
+
+<p>The above code will produce this:</p>
+
+<code>
+&lt;ul&nbsp;class="boldlist"&nbsp;id="mylist"&gt;<br />
+&nbsp;&nbsp;&lt;li&gt;colors<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&lt;ul&gt;<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;li&gt;red&lt;/li&gt;<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;li&gt;blue&lt;/li&gt;<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;li&gt;green&lt;/li&gt;<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&lt;/ul&gt;<br />
+&nbsp;&nbsp;&lt;/li&gt;<br />
+&nbsp;&nbsp;&lt;li&gt;shapes<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&lt;ul&gt;<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;li&gt;round&lt;/li&gt;<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;li&gt;suare&lt;/li&gt;<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;li&gt;circles<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;ul&gt;<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;li&gt;elipse&lt;/li&gt;<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;li&gt;oval&lt;/li&gt;<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;li&gt;sphere&lt;/li&gt;<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;/ul&gt;<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;/li&gt;<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&lt;/ul&gt;<br />
+&nbsp;&nbsp;&lt;/li&gt;<br />
+&nbsp;&nbsp;&lt;li&gt;moods<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&lt;ul&gt;<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;li&gt;happy&lt;/li&gt;<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;li&gt;upset<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;ul&gt;<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;li&gt;defeated<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;ul&gt;<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;li&gt;dejected&lt;/li&gt;<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;li&gt;disheartened&lt;/li&gt;<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;li&gt;depressed&lt;/li&gt;<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;/ul&gt;<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;/li&gt;<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;li&gt;annoyed&lt;/li&gt;<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;li&gt;cross&lt;/li&gt;<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;li&gt;angry&lt;/li&gt;<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;/ul&gt;<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;/li&gt;<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&lt;/ul&gt;<br />
+&nbsp;&nbsp;&lt;/li&gt;<br />
+&lt;/ul&gt;
+</code>
+
+
+
+<h2><a name="meta"></a>meta()</h2>
+
+<p>Helps you generate meta tags.  You can pass strings to the function, or simple arrays, or multidimensional ones. Examples:</p>
+
+<code>
+echo meta('description', 'My Great site');<br />
+// Generates:  &lt;meta name="description" content="My Great Site" /><br />
+<br /><br />
+
+echo meta('Content-type', 'text/html; charset=utf-8', 'equiv'); // Note the third parameter.  Can be "equiv" or "name"<br />
+// Generates:  &lt;meta http-equiv="Content-type" content="text/html; charset=utf-8" /><br />
+
+<br /><br />
+
+echo meta(array('name' => 'robots', 'content' => 'no-cache'));<br />
+// Generates:  &lt;meta name="robots" content="no-cache" /><br />
+
+<br /><br />
+
+$meta = array(<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;array('name' => 'robots', 'content' => 'no-cache'),<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;array('name' => 'description', 'content' => 'My Great Site'),<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;array('name' => 'keywords', 'content' => 'love, passion, intrigue, deception'),<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;array('name' => 'robots', 'content' => 'no-cache'),<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;array('name' => 'Content-type', 'content' => 'text/html; charset=utf-8', 'type' => 'equiv')<br />
+&nbsp;&nbsp;&nbsp;&nbsp;);<br />
+<br />
+echo meta($meta);
+<br />
+// Generates:  <br />
+// &lt;meta name="robots" content="no-cache" /><br />
+// &lt;meta name="description" content="My Great Site" /><br />
+// &lt;meta name="keywords" content="love, passion, intrigue, deception" /><br />
+// &lt;meta name="robots" content="no-cache" /><br />
+// &lt;meta http-equiv="Content-type" content="text/html; charset=utf-8" />
+</code>
+
+
+<h2><a name="doctype"></a>doctype()</h2>
+
+<p>Helps you generate document type declarations, or DTD's. XHTML 1.0 Strict is used by default, but many doctypes are available.</p>
+
+<code>
+echo doctype();<br />
+// &lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"&gt;<br />
+<br />
+echo doctype('html4-trans');<br />
+// &lt;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"&gt;
+</code>
+
+<p>The following is a list of doctype choices.  These are configurable, and pulled from <samp>application/config/doctypes.php</samp></p>
+
+<table cellpadding="0" cellspacing="1" border="0" style="width:100%" class="tableborder">
+       <tr>
+       <th>Doctype</th>
+       <th>Option</th>
+       <th>Result</th>
+       </tr>
+       <tr>
+       <td class="td">XHTML 1.1</td>
+       <td class="td">doctype('xhtml11')</td>
+       <td class="td">&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"&gt;</td>
+       </tr>
+       <tr>
+       <td class="td">XHTML 1.0 Strict</td>
+       <td class="td">doctype('xhtml1-strict')</td>
+       <td class="td">&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"&gt;</td>
+       </tr>
+       <tr>
+       <td class="td">XHTML 1.0 Transitional</td>
+       <td class="td">doctype('xhtml1-trans')</td>
+       <td class="td">&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;</td>
+       </tr>
+       <tr>
+       <td class="td">XHTML 1.0 Frameset</td>
+       <td class="td">doctype('xhtml1-frame')</td>
+       <td class="td">&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd"&gt;</td>
+       </tr>
+       <tr>
+       <td class="td">HTML 5</td>
+       <td class="td">doctype('html5')</td>
+       <td class="td">&lt;!DOCTYPE html&gt;</td>
+       </tr>
+       <tr>
+       <td class="td">HTML 4 Strict</td>
+       <td class="td">doctype('html4-strict')</td>
+       <td class="td">&lt;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"&gt;</td>
+       </tr>
+       <tr>
+       <td class="td">HTML 4 Transitional</td>
+       <td class="td">doctype('html4-trans')</td>
+       <td class="td">&lt;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"&gt;</td>
+       </tr>
+       <tr>
+       <td class="td">HTML 4 Frameset</td>
+       <td class="td">doctype('html4-frame')</td>
+       <td class="td">&lt;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd"&gt;</td>
+       </tr>
+</table>
+
+
+
+
+</div>
+<!-- END CONTENT -->
+
+
+<div id="footer">
+<p>
+Previous Topic:&nbsp;&nbsp;<a href="form_helper.html">Form Helper</a>
+&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+<a href="#top">Top of Page</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+<a href="../index.html">User Guide Home</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+Next Topic:&nbsp;&nbsp;<a href="path_helper.html"> Path Helper</a></p>
+<p><a href="http://codeigniter.com">CodeIgniter</a> &nbsp;&middot;&nbsp; Copyright &#169; 2006 - 2011 &nbsp;&middot;&nbsp; <a href="http://ellislab.com/">EllisLab, Inc.</a></p>
+</div>
+
+</body>
+</html>
\ No newline at end of file
diff --git a/user_guide/helpers/inflector_helper.html b/user_guide/helpers/inflector_helper.html
new file mode 100755 (executable)
index 0000000..221c059
--- /dev/null
@@ -0,0 +1,151 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head>
+
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+<title>Inflector Helper : CodeIgniter User Guide</title>
+
+<style type='text/css' media='all'>@import url('../userguide.css');</style>
+<link rel='stylesheet' type='text/css' media='all' href='../userguide.css' />
+
+<script type="text/javascript" src="../nav/nav.js"></script>
+<script type="text/javascript" src="../nav/prototype.lite.js"></script>
+<script type="text/javascript" src="../nav/moo.fx.js"></script>
+<script type="text/javascript" src="../nav/user_guide_menu.js"></script>
+
+<meta http-equiv='expires' content='-1' />
+<meta http-equiv= 'pragma' content='no-cache' />
+<meta name='robots' content='all' />
+<meta name='author' content='ExpressionEngine Dev Team' />
+<meta name='description' content='CodeIgniter User Guide' />
+
+</head>
+<body>
+
+<!-- START NAVIGATION -->
+<div id="nav"><div id="nav_inner"><script type="text/javascript">create_menu('../');</script></div></div>
+<div id="nav2"><a name="top"></a><a href="javascript:void(0);" onclick="myHeight.toggle();"><img src="../images/nav_toggle_darker.jpg" width="154" height="43" border="0" title="Toggle Table of Contents" alt="Toggle Table of Contents" /></a></div>
+<div id="masthead">
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td><h1>CodeIgniter User Guide Version 2.0.2</h1></td>
+<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
+</tr>
+</table>
+</div>
+<!-- END NAVIGATION -->
+
+
+<!-- START BREADCRUMB -->
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td id="breadcrumb">
+<a href="http://codeigniter.com/">CodeIgniter Home</a> &nbsp;&#8250;&nbsp;
+<a href="../index.html">User Guide Home</a> &nbsp;&#8250;&nbsp;
+Inflector Helper
+</td>
+<td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="codeigniter.com/user_guide/" />Search User Guide&nbsp; <input type="text" class="input" style="width:200px;" name="q" id="q" size="31" maxlength="255" value="" />&nbsp;<input type="submit" class="submit" name="sa" value="Go" /></form></td>
+</tr>
+</table>
+<!-- END BREADCRUMB -->
+
+<br clear="all" />
+
+
+<!-- START CONTENT -->
+<div id="content">
+
+
+<h1>Inflector Helper</h1>
+
+<p>The Inflector Helper file contains functions that permits you to change words to plural, singular, camel case, etc.</p>
+
+
+<h2>Loading this Helper</h2>
+
+<p>This helper is loaded using the following code:</p>
+<code>$this->load->helper('inflector');</code>
+
+<p>The following functions are available:</p>
+
+
+<h2>singular()</h2>
+
+<p>Changes a plural word to singular.  Example:</p>
+
+<code>
+$word = "dogs";<br />
+echo singular($word); // Returns "dog"
+</code>
+
+
+<h2>plural()</h2>
+
+<p>Changes a singular word to plural.  Example:</p>
+
+<code>
+$word = "dog";<br />
+echo plural($word); // Returns "dogs"
+</code>
+
+
+<p>To force a word to end with &quot;es&quot; use a second &quot;true&quot; argument. </p>
+<code> $word = &quot;pass&quot;;<br />
+echo plural($word, TRUE); // Returns &quot;passes&quot; </code>
+
+<h2>camelize()</h2>
+<p>Changes a string of words separated by spaces or underscores to camel case.  Example:</p>
+
+<code>
+$word = "my_dog_spot";<br />
+echo camelize($word); // Returns "myDogSpot"
+</code>
+
+
+<h2>underscore()</h2>
+
+<p>Takes multiple words separated by spaces and underscores them.  Example:</p>
+
+<code>
+$word = "my dog spot";<br />
+echo underscore($word); // Returns "my_dog_spot"
+</code>
+
+
+<h2>humanize()</h2>
+
+<p>Takes multiple words separated by underscores and adds spaces between them.  Each word is capitalized. Example:</p>
+
+<code>
+$word = "my_dog_spot";<br />
+echo humanize($word); // Returns "My Dog Spot"
+</code>
+
+
+
+
+
+
+
+
+
+
+
+
+</div>
+<!-- END CONTENT -->
+
+
+<div id="footer">
+<p>
+Previous Topic:&nbsp;&nbsp;<a href="html_helper.html"> HTML Helper</a>
+&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+<a href="#top">Top of Page</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+<a href="../index.html">User Guide Home</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+Next Topic:&nbsp;&nbsp;<a href="number_helper.html">Number Helper</a>
+</p>
+<p><a href="http://codeigniter.com">CodeIgniter</a> &nbsp;&middot;&nbsp; Copyright &#169; 2006 - 2011 &nbsp;&middot;&nbsp; <a href="http://ellislab.com/">EllisLab, Inc.</a></p>
+</div>
+
+</body>
+</html>
\ No newline at end of file
diff --git a/user_guide/helpers/language_helper.html b/user_guide/helpers/language_helper.html
new file mode 100755 (executable)
index 0000000..3b3b87d
--- /dev/null
@@ -0,0 +1,98 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head>
+
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+<title>Language Helper : CodeIgniter User Guide</title>
+
+<style type='text/css' media='all'>@import url('../userguide.css');</style>
+<link rel='stylesheet' type='text/css' media='all' href='../userguide.css' />
+
+<script type="text/javascript" src="../nav/nav.js"></script>
+<script type="text/javascript" src="../nav/prototype.lite.js"></script>
+<script type="text/javascript" src="../nav/moo.fx.js"></script>
+<script type="text/javascript" src="../nav/user_guide_menu.js"></script>
+
+<meta http-equiv='expires' content='-1' />
+<meta http-equiv= 'pragma' content='no-cache' />
+<meta name='robots' content='all' />
+<meta name='author' content='ExpressionEngine Dev Team' />
+<meta name='description' content='CodeIgniter User Guide' />
+
+</head>
+<body>
+
+<!-- START NAVIGATION -->
+<div id="nav"><div id="nav_inner"><script type="text/javascript">create_menu('../');</script></div></div>
+<div id="nav2"><a name="top"></a><a href="javascript:void(0);" onclick="myHeight.toggle();"><img src="../images/nav_toggle_darker.jpg" width="154" height="43" border="0" title="Toggle Table of Contents" alt="Toggle Table of Contents" /></a></div>
+<div id="masthead">
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td><h1>CodeIgniter User Guide Version 2.0.2</h1></td>
+<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
+</tr>
+</table>
+</div>
+<!-- END NAVIGATION -->
+
+
+<!-- START BREADCRUMB -->
+
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td id="breadcrumb">
+<a href="http://codeigniter.com/">CodeIgniter Home</a> &nbsp;&#8250;&nbsp;
+<a href="../index.html">User Guide Home</a> &nbsp;&#8250;&nbsp;
+Language Helper
+</td>
+<td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="codeigniter.com/user_guide/" />Search User Guide&nbsp; <input type="text" class="input" style="width:200px;" name="q" id="q" size="31" maxlength="255" value="" />&nbsp;<input type="submit" class="submit" name="sa" value="Go" /></form></td>
+</tr>
+</table>
+<!-- END BREADCRUMB -->
+
+<br clear="all" />
+
+
+<!-- START CONTENT -->
+<div id="content">
+
+
+<h1>Language Helper</h1>
+
+<p>The Language Helper file contains functions that assist in working with language files.</p>
+
+
+<h2>Loading this Helper</h2>
+
+<p>This helper is loaded using the following code:</p>
+<code>$this->load->helper('language');</code>
+
+<p>The following functions are available:</p>
+
+<h2>lang('<var>language line</var>', '<var>element id</var>')</h2>
+
+<p>This function returns a line of text from a loaded language file with simplified syntax
+       that may be more desirable for view files than calling <kbd>$this-&gt;lang-&gt;line()</kbd>.
+       The optional second parameter will also output a form label for you.  Example:</p>
+
+<code>echo lang('<samp>language_key</samp>', '<samp>form_item_id</samp>');<br />
+// becomes &lt;label for="form_item_id"&gt;language_key&lt;/label&gt;</code>
+
+
+</div>
+<!-- END CONTENT -->
+
+
+<div id="footer">
+<p>
+Previous Topic:&nbsp;&nbsp;<a href="date_helper.html">Date Helper</a>
+&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+<a href="#top">Top of Page</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+<a href="../index.html">User Guide Home</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+Next Topic:&nbsp;&nbsp;<a href="download_helper.html">Download Helper</a>
+</p>
+<p><a href="http://codeigniter.com">CodeIgniter</a> &nbsp;&middot;&nbsp; Copyright &#169; 2006 - 2011 &nbsp;&middot;&nbsp; <a href="http://ellislab.com/">EllisLab, Inc.</a></p>
+</div>
+
+</body>
+</html>
\ No newline at end of file
diff --git a/user_guide/helpers/number_helper.html b/user_guide/helpers/number_helper.html
new file mode 100755 (executable)
index 0000000..51a4521
--- /dev/null
@@ -0,0 +1,113 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head>
+
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+<title>Number Helper : CodeIgniter User Guide</title>
+
+<style type='text/css' media='all'>@import url('../userguide.css');</style>
+<link rel='stylesheet' type='text/css' media='all' href='../userguide.css' />
+
+<script type="text/javascript" src="../nav/nav.js"></script>
+<script type="text/javascript" src="../nav/prototype.lite.js"></script>
+<script type="text/javascript" src="../nav/moo.fx.js"></script>
+<script type="text/javascript" src="../nav/user_guide_menu.js"></script>
+
+<meta http-equiv='expires' content='-1' />
+<meta http-equiv= 'pragma' content='no-cache' />
+<meta name='robots' content='all' />
+<meta name='author' content='ExpressionEngine Dev Team' />
+<meta name='description' content='CodeIgniter User Guide' />
+
+</head>
+<body>
+
+<!-- START NAVIGATION -->
+<div id="nav"><div id="nav_inner"><script type="text/javascript">create_menu('../');</script></div></div>
+<div id="nav2"><a name="top"></a><a href="javascript:void(0);" onclick="myHeight.toggle();"><img src="../images/nav_toggle_darker.jpg" width="154" height="43" border="0" title="Toggle Table of Contents" alt="Toggle Table of Contents" /></a></div>
+<div id="masthead">
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td><h1>CodeIgniter User Guide Version 2.0.2</h1></td>
+<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
+</tr>
+</table>
+</div>
+<!-- END NAVIGATION -->
+
+
+<!-- START BREADCRUMB -->
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td id="breadcrumb">
+<a href="http://codeigniter.com/">CodeIgniter Home</a> &nbsp;&#8250;&nbsp;
+<a href="../index.html">User Guide Home</a> &nbsp;&#8250;&nbsp;
+Number Helper
+</td>
+<td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="codeigniter.com/user_guide/" />Search User Guide&nbsp; <input type="text" class="input" style="width:200px;" name="q" id="q" size="31" maxlength="255" value="" />&nbsp;<input type="submit" class="submit" name="sa" value="Go" /></form></td>
+</tr>
+</table>
+<!-- END BREADCRUMB -->
+
+<br clear="all" />
+
+
+<!-- START CONTENT -->
+<div id="content">
+
+
+<h1>Number Helper</h1>
+
+<p>The Number Helper file contains functions that help you work with numeric data.</p>
+
+
+<h2>Loading this Helper</h2>
+
+<p>This helper is loaded using the following code:</p>
+<code>$this->load->helper('number');</code>
+
+<p>The following functions are available:</p>
+
+
+<h2>byte_format()</h2>
+
+<p>Formats a numbers as bytes, based on size, and adds the appropriate suffix.  Examples:</p>
+
+<code>
+echo byte_format(456); // Returns 456 Bytes<br />
+echo byte_format(4567); // Returns 4.5 KB<br />
+echo byte_format(45678); // Returns 44.6 KB<br />
+echo byte_format(456789); // Returns 447.8 KB<br />
+echo byte_format(3456789); // Returns 3.3 MB<br />
+echo byte_format(12345678912345); // Returns 1.8 GB<br />
+echo byte_format(123456789123456789); // Returns 11,228.3 TB
+</code>
+
+<p>An optional second parameter allows you to set the precision of the result.</p>
+
+<code>
+echo byte_format(45678, 2); // Returns 44.61 KB
+</code>
+
+<p class="important">
+<strong>Note:</strong>
+The text generated by this function is found in the following language file: language/<your_lang>/number_lang.php
+</p>
+
+</div>
+<!-- END CONTENT -->
+
+
+<div id="footer">
+<p>
+Previous Topic:&nbsp;&nbsp;<a href="inflector_helper.html">Inflector Helper</a>
+&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+<a href="#top">Top of Page</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+<a href="../index.html">User Guide Home</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+Next Topic:&nbsp;&nbsp;<a href="path_helper.html">Path Helper</a>
+</p>
+<p><a href="http://codeigniter.com">CodeIgniter</a> &nbsp;&middot;&nbsp; Copyright &#169; 2006 - 2011 &nbsp;&middot;&nbsp; <a href="http://ellislab.com/">EllisLab, Inc.</a></p>
+</div>
+
+</body>
+</html>
\ No newline at end of file
diff --git a/user_guide/helpers/path_helper.html b/user_guide/helpers/path_helper.html
new file mode 100755 (executable)
index 0000000..584a127
--- /dev/null
@@ -0,0 +1,106 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head>
+
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+<title>Path Helper : CodeIgniter User Guide</title>
+
+<style type='text/css' media='all'>@import url('../userguide.css');</style>
+<link rel='stylesheet' type='text/css' media='all' href='../userguide.css' />
+
+<script type="text/javascript" src="../nav/nav.js"></script>
+<script type="text/javascript" src="../nav/prototype.lite.js"></script>
+<script type="text/javascript" src="../nav/moo.fx.js"></script>
+<script type="text/javascript" src="../nav/user_guide_menu.js"></script>
+
+<meta http-equiv='expires' content='-1' />
+<meta http-equiv= 'pragma' content='no-cache' />
+<meta name='robots' content='all' />
+<meta name='author' content='ExpressionEngine Dev Team' />
+<meta name='description' content='CodeIgniter User Guide' />
+</head>
+<body>
+
+<!-- START NAVIGATION -->
+<div id="nav"><div id="nav_inner"><script type="text/javascript">create_menu('../');</script></div></div>
+<div id="nav2"><a name="top"></a><a href="javascript:void(0);" onclick="myHeight.toggle();"><img src="../images/nav_toggle_darker.jpg" width="154" height="43" border="0" title="Toggle Table of Contents" alt="Toggle Table of Contents" /></a></div>
+<div id="masthead">
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td><h1>CodeIgniter User Guide Version 2.0.2</h1></td>
+<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
+</tr>
+</table>
+</div>
+<!-- END NAVIGATION -->
+
+
+<!-- START BREADCRUMB -->
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td id="breadcrumb">
+<a href="http://codeigniter.com/">CodeIgniter Home</a> &nbsp;&#8250;&nbsp;
+<a href="../index.html">User Guide Home</a> &nbsp;&#8250;&nbsp;
+Path Helper
+</td>
+<td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="codeigniter.com/user_guide/" />Search User Guide&nbsp; <input type="text" class="input" style="width:200px;" name="q" id="q" size="31" maxlength="255" value="" />&nbsp;<input type="submit" class="submit" name="sa" value="Go" /></form></td>
+</tr>
+</table>
+<!-- END BREADCRUMB -->
+
+<br clear="all" />
+
+
+<!-- START CONTENT -->
+<div id="content">
+
+
+<h1>Path Helper</h1>
+
+<p>The Path Helper file contains functions that permits you to work with file paths on the server.</p>
+
+
+<h2>Loading this Helper</h2>
+
+<p>This helper is loaded using the following code:</p>
+<code>$this->load->helper('path');</code>
+
+<p>The following functions are available:</p>
+
+
+<h2>set_realpath()</h2>
+
+<p>Checks to see if the path exists. This function will return a server path without symbolic links or relative directory structures. An optional second argument will cause an error to be triggered if the path cannot be resolved.</p>
+
+<code>$directory = '/etc/passwd';<br />
+echo set_realpath($directory);<br />
+// returns &quot;/etc/passwd&quot;<br />
+<br />
+$non_existent_directory = '/path/to/nowhere';<br />
+echo set_realpath($non_existent_directory, TRUE);<br />
+// returns an <strong>error</strong>, as the path could not be resolved
+<br /><br />
+echo set_realpath($non_existent_directory, FALSE);<br />
+// returns &quot;/path/to/nowhere&quot;
+
+
+
+</code>
+<h2>&nbsp;</h2>
+</div>
+<!-- END CONTENT -->
+
+
+<div id="footer">
+<p>
+Previous Topic:&nbsp;&nbsp;<a href="number_helper.html">Number Helper</a>
+&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+<a href="#top">Top of Page</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+<a href="../index.html">User Guide Home</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+Next Topic:&nbsp;&nbsp;<a href="security_helper.html">Security Helper</a>
+</p>
+<p><a href="http://codeigniter.com">CodeIgniter</a> &nbsp;&middot;&nbsp; Copyright &#169; 2006 - 2011 &nbsp;&middot;&nbsp; <a href="http://ellislab.com/">EllisLab, Inc.</a></p>
+</div>
+
+</body>
+</html>
\ No newline at end of file
diff --git a/user_guide/helpers/security_helper.html b/user_guide/helpers/security_helper.html
new file mode 100755 (executable)
index 0000000..e0cace3
--- /dev/null
@@ -0,0 +1,132 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head>
+
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+<title>Security Helper : CodeIgniter User Guide</title>
+
+<style type='text/css' media='all'>@import url('../userguide.css');</style>
+<link rel='stylesheet' type='text/css' media='all' href='../userguide.css' />
+
+<script type="text/javascript" src="../nav/nav.js"></script>
+<script type="text/javascript" src="../nav/prototype.lite.js"></script>
+<script type="text/javascript" src="../nav/moo.fx.js"></script>
+<script type="text/javascript" src="../nav/user_guide_menu.js"></script>
+
+<meta http-equiv='expires' content='-1' />
+<meta http-equiv= 'pragma' content='no-cache' />
+<meta name='robots' content='all' />
+<meta name='author' content='ExpressionEngine Dev Team' />
+<meta name='description' content='CodeIgniter User Guide' />
+
+</head>
+<body>
+
+<!-- START NAVIGATION -->
+<div id="nav"><div id="nav_inner"><script type="text/javascript">create_menu('../');</script></div></div>
+<div id="nav2"><a name="top"></a><a href="javascript:void(0);" onclick="myHeight.toggle();"><img src="../images/nav_toggle_darker.jpg" width="154" height="43" border="0" title="Toggle Table of Contents" alt="Toggle Table of Contents" /></a></div>
+<div id="masthead">
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td><h1>CodeIgniter User Guide Version 2.0.2</h1></td>
+<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
+</tr>
+</table>
+</div>
+<!-- END NAVIGATION -->
+
+
+<!-- START BREADCRUMB -->
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td id="breadcrumb">
+<a href="http://codeigniter.com/">CodeIgniter Home</a> &nbsp;&#8250;&nbsp;
+<a href="../index.html">User Guide Home</a> &nbsp;&#8250;&nbsp;
+Security Helper
+</td>
+<td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="codeigniter.com/user_guide/" />Search User Guide&nbsp; <input type="text" class="input" style="width:200px;" name="q" id="q" size="31" maxlength="255" value="" />&nbsp;<input type="submit" class="submit" name="sa" value="Go" /></form></td>
+</tr>
+</table>
+<!-- END BREADCRUMB -->
+
+<br clear="all" />
+
+
+<!-- START CONTENT -->
+<div id="content">
+
+
+<h1>Security Helper</h1>
+
+<p>The Security Helper file contains security related functions.</p>
+
+
+<h2>Loading this Helper</h2>
+
+<p>This helper is loaded using the following code:</p>
+<code>$this->load->helper('security');</code>
+
+<p>The following functions are available:</p>
+
+
+<h2>xss_clean()</h2>
+
+<p>Provides Cross Site Script Hack filtering.  This function is an alias to the one in the
+<a href="../libraries/input.html">Input class</a>.  More info can be found there.</p>
+
+
+<h2>sanitize_filename()</h2>
+
+<p>Provides protection against directory traversal.  This function is an alias to the one in the
+<a href="../libraries/security.html">Security class</a>.  More info can be found there.</p>
+
+
+<h2>do_hash()</h2>
+
+<p>Permits you to create SHA1 or MD5 one way hashes suitable for encrypting passwords.  Will create SHA1 by default. Examples:</p>
+
+<code>
+$str = do_hash($str); // SHA1<br />
+<br />
+$str = do_hash($str, 'md5'); // MD5
+</code>
+
+<p class="important"><strong>Note:</strong>  This function was formerly named <kbd>dohash()</kbd>, which has been deprecated in favour of <kbd>do_hash()</kbd>.</p>
+
+
+
+<h2>strip_image_tags()</h2>
+
+<p>This is a security function that will strip image tags from a string.  It leaves the image URL as plain text.</p>
+
+<code>$string = strip_image_tags($string);</code>
+
+
+<h2>encode_php_tags()</h2>
+
+<p>This is a security function that converts PHP tags to entities. Note: If you use the XSS filtering function it does this automatically.</p>
+
+<code>$string = encode_php_tags($string);</code>
+
+
+
+
+
+
+
+</div>
+<!-- END CONTENT -->
+
+
+<div id="footer">
+<p>
+Previous Topic:&nbsp;&nbsp;<a href="path_helper.html"> Path Helper</a>
+&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+<a href="#top">Top of Page</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+<a href="../index.html">User Guide Home</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+Next Topic:&nbsp;&nbsp;<a href="smiley_helper.html">Smiley Helper</a></p>
+<p><a href="http://codeigniter.com">CodeIgniter</a> &nbsp;&middot;&nbsp; Copyright &#169; 2006 - 2011 &nbsp;&middot;&nbsp; <a href="http://ellislab.com/">EllisLab, Inc.</a></p>
+</div>
+
+</body>
+</html>
\ No newline at end of file
diff --git a/user_guide/helpers/smiley_helper.html b/user_guide/helpers/smiley_helper.html
new file mode 100755 (executable)
index 0000000..408df17
--- /dev/null
@@ -0,0 +1,215 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head>
+
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+<title>Smiley Helper : CodeIgniter User Guide</title>
+
+<style type='text/css' media='all'>@import url('../userguide.css');</style>
+<link rel='stylesheet' type='text/css' media='all' href='../userguide.css' />
+
+<script type="text/javascript" src="../nav/nav.js"></script>
+<script type="text/javascript" src="../nav/prototype.lite.js"></script>
+<script type="text/javascript" src="../nav/moo.fx.js"></script>
+<script type="text/javascript" src="../nav/user_guide_menu.js"></script>
+
+<meta http-equiv='expires' content='-1' />
+<meta http-equiv= 'pragma' content='no-cache' />
+<meta name='robots' content='all' />
+<meta name='author' content='ExpressionEngine Dev Team' />
+<meta name='description' content='CodeIgniter User Guide' />
+
+</head>
+<body>
+
+<!-- START NAVIGATION -->
+<div id="nav"><div id="nav_inner"><script type="text/javascript">create_menu('../');</script></div></div>
+<div id="nav2"><a name="top"></a><a href="javascript:void(0);" onclick="myHeight.toggle();"><img src="../images/nav_toggle_darker.jpg" width="154" height="43" border="0" title="Toggle Table of Contents" alt="Toggle Table of Contents" /></a></div>
+<div id="masthead">
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td><h1>CodeIgniter User Guide Version 2.0.2</h1></td>
+<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
+</tr>
+</table>
+</div>
+<!-- END NAVIGATION -->
+
+
+<!-- START BREADCRUMB -->
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td id="breadcrumb">
+<a href="http://codeigniter.com/">CodeIgniter Home</a> &nbsp;&#8250;&nbsp;
+<a href="../index.html">User Guide Home</a> &nbsp;&#8250;&nbsp;
+Smiley Helper
+</td>
+<td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="codeigniter.com/user_guide/" />Search User Guide&nbsp; <input type="text" class="input" style="width:200px;" name="q" id="q" size="31" maxlength="255" value="" />&nbsp;<input type="submit" class="submit" name="sa" value="Go" /></form></td>
+</tr>
+</table>
+<!-- END BREADCRUMB -->
+
+<br clear="all" />
+
+
+<!-- START CONTENT -->
+<div id="content">
+
+
+<h1>Smiley Helper</h1>
+
+<p>The Smiley Helper file contains functions that let you manage smileys (emoticons).</p>
+
+
+<h2>Loading this Helper</h2>
+
+<p>This helper is loaded using the following code:</p>
+<code>$this->load->helper('smiley');</code>
+
+<h2>Overview</h2>
+
+<p>The Smiley helper has a renderer that takes plain text simileys, like <dfn>:-)</dfn> and turns
+them into a image representation, like <img src="../images/smile.gif" width="19" height="19" border="0" alt="smile!" /></p>
+
+<p>It also lets you display a set of smiley images that when clicked will be inserted into a form field.
+For example, if you have a blog that allows user commenting you can show the smileys next to the comment form.
+Your users can click a desired smiley and with the help of some JavaScript it will be placed into the form field.</p>
+
+
+
+<h2>Clickable Smileys Tutorial</h2>
+
+<p>Here is an example demonstrating how you might create a set of clickable smileys next to a form field. This example
+requires that you first download and install the smiley images, then create a controller and the View as described.</p>
+
+<p class="important"><strong>Important:</strong> Before you begin, please <a href="http://codeigniter.com/download_files/smileys.zip">download the smiley images</a> and put them in
+a publicly accessible place on your server.  This helper also assumes you have the smiley replacement array located at
+<dfn>application/config/smileys.php</dfn></p>
+
+
+<h3>The Controller</h3>
+
+<p>In your <dfn>application/controllers/</dfn> folder, create a file called <kbd>smileys.php</kbd> and place the code below in it.</p>
+
+<p><strong>Important:</strong> Change the URL in the <dfn>get_clickable_smileys()</dfn> function below so that it points to
+your <dfn>smiley</dfn> folder.</p>
+
+<p>You'll notice that in addition to the smiley helper we are using the <a href="../libraries/table.html">Table Class</a>.</p>
+
+<textarea class="textarea" style="width:100%" cols="50" rows="25">
+&lt;?php
+
+class Smileys extends CI_Controller {
+
+       function __construct()
+       {
+               parent::__construct();
+       }
+
+       function index()
+       {
+               $this->load->helper('smiley');
+               $this->load->library('table');
+
+               $image_array = get_clickable_smileys('http://example.com/images/smileys/', 'comments');
+
+               $col_array = $this->table->make_columns($image_array, 8);
+
+               $data['smiley_table'] = $this->table->generate($col_array);
+
+               $this->load->view('smiley_view', $data);
+       }
+
+}
+?&gt;
+</textarea>
+
+<p>In your <dfn>application/views/</dfn> folder, create a file called <kbd>smiley_view.php</kbd> and place this code in it:</p>
+
+<textarea class="textarea" style="width:100%" cols="50" rows="20">
+&lt;html>
+&lt;head>
+&lt;title>Smileys&lt;/title>
+
+&lt;?php echo smiley_js(); ?>
+
+&lt;/head>
+&lt;body>
+
+&lt;form name="blog">
+&lt;textarea name="comments" id="comments" cols="40" rows="4">&lt;/textarea>
+&lt;/form>
+
+&lt;p>Click to insert a smiley!&lt;/p>
+
+&lt;?php echo $smiley_table; ?>
+
+&lt;/body>
+&lt;/html>
+</textarea>
+
+
+<p>When you have created the above controller and view, load it by visiting <dfn>http://www.example.com/index.php/smileys/</dfn></p>
+
+
+<h3>Field Aliases</h3>
+
+<p>When making changes to a view it can be inconvenient to have the field id in the controller. To work around this,
+you can give your smiley links a generic name that will be tied to a specific id in your view.</p>
+<code>$image_array = get_smiley_links("http://example.com/images/smileys/", "comment_textarea_alias");</code>
+
+<p>To map the alias to the field id, pass them both into the smiley_js function:</p>
+<code>$image_array = smiley_js("comment_textarea_alias", "comments");</code>
+
+
+<h1>Function Reference</h1>
+
+<h2>get_clickable_smileys()</h2>
+
+<p>Returns an array containing your smiley images wrapped in a clickable link.  You must supply the URL to your smiley folder
+and a field id or field alias.</p>
+
+<code>$image_array = get_smiley_links("http://example.com/images/smileys/", "comment");</code>
+<p class="important">Note: Usage of this function without the second parameter, in combination with js_insert_smiley has been deprecated.</p>
+
+
+<h2>smiley_js()</h2>
+
+<p>Generates the JavaScript that allows the images to be clicked and inserted into a form field.
+If you supplied an alias instead of an id when generating your smiley links, you need to pass the
+alias and corresponding form id into the function.
+This function is designed to be placed into the &lt;head&gt; area of your web page.</p>
+
+<code>&lt;?php echo smiley_js(); ?&gt;</code>
+<p class="important">Note: This function replaces js_insert_smiley, which has been deprecated.</p>
+
+
+<h2>parse_smileys()</h2>
+
+<p>Takes a string of text as input and replaces any contained plain text smileys into the image
+equivalent.  The first parameter must contain your string, the second must contain  the URL to your smiley folder:</p>
+
+<code>
+$str = 'Here are some simileys: :-)  ;-)';
+
+$str = parse_smileys($str, "http://example.com/images/smileys/");
+
+echo $str;
+</code>
+</div>
+<!-- END CONTENT -->
+
+
+<div id="footer">
+<p>
+Previous Topic:&nbsp;&nbsp;<a href="security_helper.html">Security Helper</a>
+&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+<a href="#top">Top of Page</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+<a href="../index.html">User Guide Home</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+Next Topic:&nbsp;&nbsp;<a href="string_helper.html">String Helper</a>
+</p>
+<p><a href="http://codeigniter.com">CodeIgniter</a> &nbsp;&middot;&nbsp; Copyright &#169; 2006 - 2011 &nbsp;&middot;&nbsp; <a href="http://ellislab.com/">EllisLab, Inc.</a></p>
+</div>
+
+</body>
+</html>
\ No newline at end of file
diff --git a/user_guide/helpers/string_helper.html b/user_guide/helpers/string_helper.html
new file mode 100755 (executable)
index 0000000..169ee4e
--- /dev/null
@@ -0,0 +1,178 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head>
+
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+<title>String Helper : CodeIgniter User Guide</title>
+
+<style type='text/css' media='all'>@import url('../userguide.css');</style>
+<link rel='stylesheet' type='text/css' media='all' href='../userguide.css' />
+
+<script type="text/javascript" src="../nav/nav.js"></script>
+<script type="text/javascript" src="../nav/prototype.lite.js"></script>
+<script type="text/javascript" src="../nav/moo.fx.js"></script>
+<script type="text/javascript" src="../nav/user_guide_menu.js"></script>
+
+<meta http-equiv='expires' content='-1' />
+<meta http-equiv= 'pragma' content='no-cache' />
+<meta name='robots' content='all' />
+<meta name='author' content='ExpressionEngine Dev Team' />
+<meta name='description' content='CodeIgniter User Guide' />
+
+</head>
+<body>
+
+<!-- START NAVIGATION -->
+<div id="nav"><div id="nav_inner"><script type="text/javascript">create_menu('../');</script></div></div>
+<div id="nav2"><a name="top"></a><a href="javascript:void(0);" onclick="myHeight.toggle();"><img src="../images/nav_toggle_darker.jpg" width="154" height="43" border="0" title="Toggle Table of Contents" alt="Toggle Table of Contents" /></a></div>
+<div id="masthead">
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td><h1>CodeIgniter User Guide Version 2.0.2</h1></td>
+<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
+</tr>
+</table>
+</div>
+<!-- END NAVIGATION -->
+
+
+<!-- START BREADCRUMB -->
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td id="breadcrumb">
+<a href="http://codeigniter.com/">CodeIgniter Home</a> &nbsp;&#8250;&nbsp;
+<a href="../index.html">User Guide Home</a> &nbsp;&#8250;&nbsp;
+String Helper
+</td>
+<td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="codeigniter.com/user_guide/" />Search User Guide&nbsp; <input type="text" class="input" style="width:200px;" name="q" id="q" size="31" maxlength="255" value="" />&nbsp;<input type="submit" class="submit" name="sa" value="Go" /></form></td>
+</tr>
+</table>
+<!-- END BREADCRUMB -->
+
+<br clear="all" />
+
+
+<!-- START CONTENT -->
+<div id="content">
+
+
+<h1>String Helper</h1>
+
+<p>The String Helper file contains functions that assist in working with strings.</p>
+
+
+<h2>Loading this Helper</h2>
+
+<p>This helper is loaded using the following code:</p>
+<code>$this->load->helper('string');</code>
+
+<p>The following functions are available:</p>
+
+<h2>random_string()</h2>
+
+<p>Generates a random string based on the type and length you specify.  Useful for creating passwords or generating random hashes.</p>
+
+<p>The first parameter specifies the type of string, the second parameter specifies the length.  The following choices are available:</p>
+
+ alpha, alunum, numeric, nozero, unique, md5, encrypt and sha1
+<ul>
+       <li><strong>alpha</strong>:&nbsp; A string with lower and uppercase letters only.</li>
+       <li><strong>alnum</strong>:&nbsp; Alpha-numeric string with lower and uppercase characters.</li>
+       <li><strong>numeric</strong>:&nbsp; Numeric string.</li>
+       <li><strong>nozero</strong>:&nbsp; Numeric string with no zeros.</li>
+       <li><strong>unique</strong>:&nbsp; Encrypted with MD5 and uniqid(). Note: The length parameter is not available for this type.
+       Returns a fixed length 32 character string.</li>
+       <li><strong>sha1</strong>:&nbsp; An encrypted random number based on <kbd>do_hash()</kbd> from the <a href="security_helper.html">security helper</a>.</li>
+</ul>
+
+<p>Usage example:</p>
+
+<code>echo random_string('alnum', 16);</code>
+
+
+<h2>alternator()</h2>
+
+<p>Allows two or more items to be alternated between, when cycling through a loop.  Example:</p>
+
+<code>for ($i = 0; $i < 10; $i++)<br />
+{<br />
+&nbsp;&nbsp;&nbsp;&nbsp;echo alternator('string one', 'string two');<br />
+}<br />
+</code>
+
+<p>You can add as many parameters as you want, and with each iteration of your loop the next item will be returned.</p>
+
+<code>for ($i = 0; $i < 10; $i++)<br />
+{<br />
+&nbsp;&nbsp;&nbsp;&nbsp;echo alternator('one', 'two', 'three', 'four', 'five');<br />
+}<br />
+</code>
+
+<p><strong>Note:</strong> To use multiple separate calls to this function simply call the function with no arguments to re-initialize.</p>
+
+
+
+<h2>repeater()</h2>
+<p>Generates repeating copies of the data you submit. Example:</p>
+<code>$string = "\n";<br />
+echo repeater($string, 30);</code>
+
+<p>The above would generate 30 newlines.</p>
+<h2>reduce_double_slashes()</h2>
+<p>Converts double slashes in a string to a single slash, except those found in http://. Example: </p>
+<code>$string = &quot;http://example.com//index.php&quot;;<br />
+echo reduce_double_slashes($string); // results in &quot;http://example.com/index.php&quot;</code>
+<h2>trim_slashes()</h2>
+<p>Removes any leading/trailing slashes from a string. Example:<br />
+       <br />
+       <code>$string = &quot;/this/that/theother/&quot;;<br />
+echo trim_slashes($string); // results in this/that/theother</code></p>
+
+
+<h2>reduce_multiples()</h2>
+<p>Reduces multiple instances of a particular character occuring directly after each other. Example:</p>
+<code>
+$string="Fred, Bill,, Joe, Jimmy";<br />
+$string=reduce_multiples($string,","); //results in "Fred, Bill, Joe, Jimmy"
+</code>
+<p>The function accepts the following parameters:
+<code>reduce_multiples(string: text to search in, string: character to reduce, boolean: whether to remove the character from the front and end of the string)</code>
+
+The first parameter contains the string in which you want to reduce the multiplies. The second parameter contains the character you want to have reduced.
+The third parameter is FALSE by default; if set to TRUE it will remove occurences of the character at the beginning and the end of the string. Example:
+
+<code>
+$string=",Fred, Bill,, Joe, Jimmy,";<br />
+$string=reduce_multiples($string, ", ", TRUE); //results in "Fred, Bill, Joe, Jimmy"
+</code>
+</p>
+
+<h2>quotes_to_entities()</h2>
+<p>Converts single and double quotes in a string to the corresponding HTML entities. Example:</p>
+<code>$string="Joe's \"dinner\"";<br />
+$string=quotes_to_entities($string); //results in "Joe&amp;#39;s &amp;quot;dinner&amp;quot;"
+</code>
+
+<h2>strip_quotes()</h2>
+<p>Removes single and double quotes from a string. Example:</p>
+<code>$string="Joe's \"dinner\"";<br />
+$string=strip_quotes($string); //results in "Joes dinner"
+</code>
+
+</div>
+<!-- END CONTENT -->
+
+
+<div id="footer">
+<p>
+Previous Topic:&nbsp;&nbsp;<a href="smiley_helper.html">Smiley Helper</a>
+&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+<a href="#top">Top of Page</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+<a href="../index.html">User Guide Home</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+Next Topic:&nbsp;&nbsp;<a href="text_helper.html">Text Helper</a>
+</p>
+<p><a href="http://codeigniter.com">CodeIgniter</a> &nbsp;&middot;&nbsp; Copyright &#169; 2006 - 2011 &nbsp;&middot;&nbsp; <a href="http://ellislab.com/">EllisLab, Inc.</a></p>
+</div>
+
+</body>
+</html>
\ No newline at end of file
diff --git a/user_guide/helpers/text_helper.html b/user_guide/helpers/text_helper.html
new file mode 100755 (executable)
index 0000000..f71d878
--- /dev/null
@@ -0,0 +1,211 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head>
+
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+<title>Text Helper : CodeIgniter User Guide</title>
+
+<style type='text/css' media='all'>@import url('../userguide.css');</style>
+<link rel='stylesheet' type='text/css' media='all' href='../userguide.css' />
+
+<script type="text/javascript" src="../nav/nav.js"></script>
+<script type="text/javascript" src="../nav/prototype.lite.js"></script>
+<script type="text/javascript" src="../nav/moo.fx.js"></script>
+<script type="text/javascript" src="../nav/user_guide_menu.js"></script>
+
+<meta http-equiv='expires' content='-1' />
+<meta http-equiv= 'pragma' content='no-cache' />
+<meta name='robots' content='all' />
+<meta name='author' content='ExpressionEngine Dev Team' />
+<meta name='description' content='CodeIgniter User Guide' />
+
+</head>
+<body>
+
+<!-- START NAVIGATION -->
+<div id="nav"><div id="nav_inner"><script type="text/javascript">create_menu('../');</script></div></div>
+<div id="nav2"><a name="top"></a><a href="javascript:void(0);" onclick="myHeight.toggle();"><img src="../images/nav_toggle_darker.jpg" width="154" height="43" border="0" title="Toggle Table of Contents" alt="Toggle Table of Contents" /></a></div>
+<div id="masthead">
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td><h1>CodeIgniter User Guide Version 2.0.2</h1></td>
+<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
+</tr>
+</table>
+</div>
+<!-- END NAVIGATION -->
+
+
+<!-- START BREADCRUMB -->
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td id="breadcrumb">
+<a href="http://codeigniter.com/">CodeIgniter Home</a> &nbsp;&#8250;&nbsp;
+<a href="../index.html">User Guide Home</a> &nbsp;&#8250;&nbsp;
+Text Helper
+</td>
+<td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="codeigniter.com/user_guide/" />Search User Guide&nbsp; <input type="text" class="input" style="width:200px;" name="q" id="q" size="31" maxlength="255" value="" />&nbsp;<input type="submit" class="submit" name="sa" value="Go" /></form></td>
+</tr>
+</table>
+<!-- END BREADCRUMB -->
+
+<br clear="all" />
+
+
+<!-- START CONTENT -->
+<div id="content">
+
+
+<h1>Text Helper</h1>
+
+<p>The Text Helper file contains functions that assist in working with text.</p>
+
+
+<h2>Loading this Helper</h2>
+
+<p>This helper is loaded using the following code:</p>
+<code>$this->load->helper('text');</code>
+
+<p>The following functions are available:</p>
+
+
+<h2>word_limiter()</h2>
+
+<p>Truncates a string to the number of <strong>words</strong> specified.  Example:</p>
+
+<code>
+$string = "Here is a nice text string consisting of eleven words.";<br />
+<br />
+$string = word_limiter($string, 4);<br /><br />
+
+// Returns:  Here is a nice&#8230;
+</code>
+
+<p>The third parameter is an optional suffix added to the string.  By default it adds an ellipsis.</p>
+
+
+<h2>character_limiter()</h2>
+
+<p>Truncates a string to the number of <strong>characters</strong> specified.  It maintains the integrity
+of words so the character count may be slightly more or less then what you specify. Example:</p>
+
+<code>
+$string = "Here is a nice text string consisting of eleven words.";<br />
+<br />
+$string = character_limiter($string, 20);<br /><br />
+
+// Returns:  Here is a nice text string&#8230;
+</code>
+
+<p>The third parameter is an optional suffix added to the string, if undeclared this helper uses an ellipsis.</p>
+
+
+
+<h2>ascii_to_entities()</h2>
+
+<p>Converts ASCII values to character entities, including high ASCII and MS Word characters that can cause problems when used in a web page,
+so that they can be shown consistently regardless of browser settings or stored reliably in a database.
+There is some dependence on your server's supported character sets, so it may not be 100% reliable in all cases, but for the most
+part it should correctly identify characters outside the normal range (like accented characters). Example:</p>
+
+<code>$string = ascii_to_entities($string);</code>
+
+
+<h2>entities_to_ascii()</h2>
+
+<p>This function does the opposite of the previous one; it turns character entities back into ASCII.</p>
+
+<h2>convert_accented_characters()</h2>
+
+<p>Transliterates high ASCII characters to low ASCII equivalents, useful when non-English characters need to be used where only standard ASCII characters are safely used, for instance, in URLs.</p>
+
+<code>$string = convert_accented_characters($string);</code>
+
+<p>This function uses a companion config file <dfn>application/config/foreign_chars.php</dfn> to define the to and from array for transliteration.</p>
+
+<h2>word_censor()</h2>
+
+<p>Enables you to censor words within a text string.  The first parameter will contain the original string.  The
+second will contain an array of words which you disallow.  The third (optional) parameter can contain a replacement value
+for the words.  If not specified they are replaced with pound signs: ####.  Example:</p>
+
+<code>
+$disallowed = array('darn', 'shucks', 'golly', 'phooey');<br />
+<br />
+$string = word_censor($string, $disallowed, 'Beep!');</code>
+
+
+<h2>highlight_code()</h2>
+
+<p>Colorizes a string of code (PHP, HTML, etc.).  Example:</p>
+
+<code>$string = highlight_code($string);</code>
+
+<p>The function uses PHP's highlight_string() function, so the colors used are the ones specified in your php.ini file.</p>
+
+
+<h2>highlight_phrase()</h2>
+
+<p>Will highlight a phrase within a text string.  The first parameter will contain the original string, the second will
+contain the phrase you wish to highlight.  The third and fourth parameters will contain the opening/closing HTML tags
+you would like the phrase wrapped in.  Example:</p>
+
+<code>
+$string = "Here is a nice text string about nothing in particular.";<br />
+<br />
+$string = highlight_phrase($string, "nice text", '&lt;span style="color:#990000">', '&lt;/span>');
+</code>
+
+<p>The above text returns:</p>
+
+<p>Here is a <span style="color:#990000">nice text</span> string about nothing in particular.</p>
+
+
+
+<h2>word_wrap()</h2>
+
+<p>Wraps text at the specified <strong>character</strong> count while maintaining complete words.  Example:</p>
+
+<code>$string = "Here is a simple string of text that will help us demonstrate this function.";<br />
+<br />
+echo word_wrap($string, 25);<br />
+<br />
+// Would produce:<br />
+<br />
+Here is a simple string<br />
+of text that will help<br />
+us demonstrate this<br />
+function</code>
+
+<h2>ellipsize()</h2>
+
+<p>This function will strip tags from a string, split it at a defined maximum length, and insert an ellipsis.</p>
+<p>The first parameter is the string to ellipsize, the second is the number of characters in the final string. The third parameter is where in the string the ellipsis should appear from 0 - 1, left to right.  For example.  a value of 1 will place the ellipsis at the right of the string, .5 in the middle, and 0 at the left.</p>
+<p>An optional forth parameter is the kind of ellipsis.  By default, <samp>&amp;hellip;</samp> will be inserted.</p>
+
+<code>$str = 'this_string_is_entirely_too_long_and_might_break_my_design.jpg';<br />
+<br />
+echo ellipsize($str, 32, .5);</code>
+
+Produces:
+
+<code>this_string_is_e&hellip;ak_my_design.jpg</code>
+
+
+</div>
+<!-- END CONTENT -->
+
+
+<div id="footer">
+<p>
+Previous Topic:&nbsp;&nbsp;<a href="string_helper.html">String Helper</a>
+&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+<a href="#top">Top of Page</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+<a href="../index.html">User Guide Home</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+Next Topic:&nbsp;&nbsp;<a href="typography_helper.html">Typography Helper</a>
+</p>
+<p><a href="http://codeigniter.com">CodeIgniter</a> &nbsp;&middot;&nbsp; Copyright &#169; 2006 - 2011 &nbsp;&middot;&nbsp; <a href="http://ellislab.com/">EllisLab, Inc.</a></p>
+</div>
+
+</body>
+</html>
\ No newline at end of file
diff --git a/user_guide/helpers/typography_helper.html b/user_guide/helpers/typography_helper.html
new file mode 100755 (executable)
index 0000000..00686a3
--- /dev/null
@@ -0,0 +1,112 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head>
+
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+<title>Typography Helper : CodeIgniter User Guide</title>
+
+<style type='text/css' media='all'>@import url('../userguide.css');</style>
+<link rel='stylesheet' type='text/css' media='all' href='../userguide.css' />
+
+<script type="text/javascript" src="../nav/nav.js"></script>
+<script type="text/javascript" src="../nav/prototype.lite.js"></script>
+<script type="text/javascript" src="../nav/moo.fx.js"></script>
+<script type="text/javascript" src="../nav/user_guide_menu.js"></script>
+
+<meta http-equiv='expires' content='-1' />
+<meta http-equiv= 'pragma' content='no-cache' />
+<meta name='robots' content='all' />
+<meta name='author' content='ExpressionEngine Dev Team' />
+<meta name='description' content='CodeIgniter User Guide' />
+
+</head>
+<body>
+
+<!-- START NAVIGATION -->
+<div id="nav"><div id="nav_inner"><script type="text/javascript">create_menu('../');</script></div></div>
+<div id="nav2"><a name="top"></a><a href="javascript:void(0);" onclick="myHeight.toggle();"><img src="../images/nav_toggle_darker.jpg" width="154" height="43" border="0" title="Toggle Table of Contents" alt="Toggle Table of Contents" /></a></div>
+<div id="masthead">
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td><h1>CodeIgniter User Guide Version 2.0.2</h1></td>
+<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
+</tr>
+</table>
+</div>
+<!-- END NAVIGATION -->
+
+
+<!-- START BREADCRUMB -->
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td id="breadcrumb">
+<a href="http://codeigniter.com/">CodeIgniter Home</a> &nbsp;&#8250;&nbsp;
+<a href="../index.html">User Guide Home</a> &nbsp;&#8250;&nbsp;
+Typography Helper
+</td>
+<td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="codeigniter.com/user_guide/" />Search User Guide&nbsp; <input type="text" class="input" style="width:200px;" name="q" id="q" size="31" maxlength="255" value="" />&nbsp;<input type="submit" class="submit" name="sa" value="Go" /></form></td>
+</tr>
+</table>
+<!-- END BREADCRUMB -->
+
+<br clear="all" />
+
+
+<!-- START CONTENT -->
+<div id="content">
+
+
+<h1>Typography Helper</h1>
+
+<p>The Typography Helper file contains functions that help your format text in semantically relevant ways.</p>
+
+
+<h2>Loading this Helper</h2>
+
+<p>This helper is loaded using the following code:</p>
+<code>$this->load->helper('typography');</code>
+
+<p>The following functions are available:</p>
+
+
+<h2>auto_typography()</h2>
+
+<p>Formats text so that it is semantically and typographically correct HTML.  Please see the <a href="../libraries/typography.html">Typography Class</a> for more info.</p>
+
+<p>Usage example:</p>
+
+<code>$string = auto_typography($string);</code>
+
+<p><strong>Note:</strong> Typographic formatting can be processor intensive, particularly if you have a lot of content being formatted.
+If you choose to use this function you may want to consider
+<a href="../general/caching.html">caching</a> your pages.</p>
+
+
+<h2>nl2br_except_pre()</h2>
+
+<p>Converts newlines to &lt;br /&gt; tags unless they appear within &lt;pre&gt; tags.
+This function is identical to the native PHP <dfn>nl2br()</dfn> function, except that it ignores &lt;pre&gt; tags.</p>
+
+<p>Usage example:</p>
+
+<code>$string = nl2br_except_pre($string);</code>
+
+
+
+</div>
+<!-- END CONTENT -->
+
+
+<div id="footer">
+<p>
+Previous Topic:&nbsp;&nbsp;<a href="text_helper.html">Text Helper</a>
+&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+<a href="#top">Top of Page</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+<a href="../index.html">User Guide Home</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+Next Topic:&nbsp;&nbsp;<a href="url_helper.html">URL Helper</a>
+</p>
+<p><a href="http://codeigniter.com">CodeIgniter</a> &nbsp;&middot;&nbsp; Copyright &#169; 2006 - 2011 &nbsp;&middot;&nbsp; <a href="http://ellislab.com/">EllisLab, Inc.</a></p>
+</div>
+
+</body>
+</html>
\ No newline at end of file
diff --git a/user_guide/helpers/url_helper.html b/user_guide/helpers/url_helper.html
new file mode 100755 (executable)
index 0000000..d20f1b1
--- /dev/null
@@ -0,0 +1,288 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head>
+
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+<title>URL Helper : CodeIgniter User Guide</title>
+
+<style type='text/css' media='all'>@import url('../userguide.css');</style>
+<link rel='stylesheet' type='text/css' media='all' href='../userguide.css' />
+
+<script type="text/javascript" src="../nav/nav.js"></script>
+<script type="text/javascript" src="../nav/prototype.lite.js"></script>
+<script type="text/javascript" src="../nav/moo.fx.js"></script>
+<script type="text/javascript" src="../nav/user_guide_menu.js"></script>
+
+<meta http-equiv='expires' content='-1' />
+<meta http-equiv= 'pragma' content='no-cache' />
+<meta name='robots' content='all' />
+<meta name='author' content='ExpressionEngine Dev Team' />
+<meta name='description' content='CodeIgniter User Guide' />
+</head>
+<body>
+
+<!-- START NAVIGATION -->
+<div id="nav"><div id="nav_inner"><script type="text/javascript">create_menu('../');</script></div></div>
+<div id="nav2"><a name="top"></a><a href="javascript:void(0);" onclick="myHeight.toggle();"><img src="../images/nav_toggle_darker.jpg" width="154" height="43" border="0" title="Toggle Table of Contents" alt="Toggle Table of Contents" /></a></div>
+<div id="masthead">
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td><h1>CodeIgniter User Guide Version 2.0.2</h1></td>
+<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
+</tr>
+</table>
+</div>
+<!-- END NAVIGATION -->
+
+
+<!-- START BREADCRUMB -->
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td id="breadcrumb">
+<a href="http://codeigniter.com/">CodeIgniter Home</a> &nbsp;&#8250;&nbsp;
+<a href="../index.html">User Guide Home</a> &nbsp;&#8250;&nbsp;
+URL Helper
+</td>
+<td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="codeigniter.com/user_guide/" />Search User Guide&nbsp; <input type="text" class="input" style="width:200px;" name="q" id="q" size="31" maxlength="255" value="" />&nbsp;<input type="submit" class="submit" name="sa" value="Go" /></form></td>
+</tr>
+</table>
+<!-- END BREADCRUMB -->
+
+<br clear="all" />
+
+
+<!-- START CONTENT -->
+<div id="content">
+
+
+<h1>URL Helper</h1>
+
+<p>The URL Helper file contains functions that assist in working with URLs.</p>
+
+
+<h2>Loading this Helper</h2>
+
+<p>This helper is loaded using the following code:</p>
+<code>$this->load->helper('url');</code>
+
+<p>The following functions are available:</p>
+
+<h2>site_url()</h2>
+
+<p>Returns your site URL, as specified in your config file.  The index.php file (or whatever you have set as your
+site <dfn>index_page</dfn> in your config file) will be added to the URL, as will any URI segments you pass to the function.</p>
+
+<p>You are encouraged to use this function any time you need to generate a local URL so that your pages become more portable
+in the event your URL changes.</p>
+
+<p>Segments can be optionally passed to the function as a string or an array.  Here is a string example:</p>
+
+<code>echo site_url("news/local/123");</code>
+
+<p>The above example would return something like: http://example.com/index.php/news/local/123</p>
+
+<p>Here is an example of segments passed as an array:</p>
+
+<code>
+$segments = array('news', 'local', '123');<br />
+<br />
+echo site_url($segments);</code>
+
+
+<h2>base_url()</h2>
+<p>Returns your site base URL, as specified in your config file.  Example:</p>
+<code>echo base_url();</code>
+
+
+<h2>current_url()</h2>
+<p>Returns the full URL (including segments) of the page being currently viewed.</p>
+
+
+<h2>uri_string()</h2>
+<p>Returns the URI segments of any page that contains this function.  For example, if your URL was this:</p>
+<code>http://some-site.com/blog/comments/123</code>
+
+<p>The function would return:</p>
+<code>/blog/comments/123</code>
+
+
+<h2>index_page()</h2>
+<p>Returns your site "index" page, as specified in your config file.  Example:</p>
+<code>echo index_page();</code>
+
+
+
+<h2>anchor()</h2>
+
+<p>Creates a standard HTML anchor link based on your local site URL:</p>
+
+<code>&lt;a href="http://example.com">Click Here&lt;/a></code>
+
+<p>The tag has three optional parameters:</p>
+
+<code>anchor(<var>uri segments</var>, <var>text</var>, <var>attributes</var>)</code>
+
+<p>The first parameter can contain any segments you wish appended to the URL.  As with the <dfn>site_url()</dfn> function above,
+segments can be a string or an array.</p>
+
+<p><strong>Note:</strong>&nbsp; If you are building links that are internal to your application do not include the base URL (http://...).  This
+will be added automatically from the information specified in your config file. Include only the URI segments you wish appended to the URL.</p>
+
+<p>The second segment is the text you would like the link to say.  If you leave it blank, the URL will be used.</p>
+
+<p>The third parameter can contain a list of attributes you would like added to the link.  The attributes can be a simple string or an associative array.</p>
+
+<p>Here are some examples:</p>
+
+<code>echo anchor('news/local/123', 'My News', 'title="News title"');</code>
+
+<p>Would produce: &lt;a href="http://example.com/index.php/news/local/123" title="News title">My News&lt;/a></p>
+
+<code>echo anchor('news/local/123', 'My News', array('title' => 'The best news!'));</code>
+
+<p>Would produce: &lt;a href="http://example.com/index.php/news/local/123" title="The best news!">My News&lt;/a></p>
+
+
+<h2>anchor_popup()</h2>
+
+<p>Nearly identical to the <dfn>anchor()</dfn> function except that it opens the URL in a new window.
+
+You can specify JavaScript window attributes in the third parameter to control how the window is opened. If
+the third parameter is not set it will simply open a new window with your own browser settings.  Here is an example
+with attributes:</p>
+
+<code>
+
+$atts = array(<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'width'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=> '800',<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'height'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=> '600',<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'scrollbars' => 'yes',<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'status'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=> 'yes',<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'resizable'&nbsp;&nbsp;=> 'yes',<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'screenx'&nbsp;&nbsp;&nbsp;&nbsp;=> '0',<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'screeny'&nbsp;&nbsp;&nbsp;&nbsp;=> '0'<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;);<br />
+<br />
+echo anchor_popup('news/local/123', 'Click Me!', $atts);</code>
+
+<p>Note: The above attributes are the function defaults so you only need to set the ones that are different from what you need.
+If you want the function to use all of its defaults simply pass an empty array in the third parameter:</p>
+
+<code>echo anchor_popup('news/local/123', 'Click Me!', array());</code>
+
+
+<h2>mailto()</h2>
+
+<p>Creates a standard HTML email link.  Usage example:</p>
+
+<code>echo mailto('me@my-site.com', 'Click Here to Contact Me');</code>
+
+<p>As with the <dfn>anchor()</dfn> tab above, you can set attributes using the third parameter.</p>
+
+
+<h2>safe_mailto()</h2>
+
+<p>Identical to the above function except it writes an obfuscated version of the mailto tag using ordinal numbers
+written with JavaScript to help prevent the email address from being harvested by spam bots.</p>
+
+
+<h2>auto_link()</h2>
+
+<p>Automatically turns URLs and email addresses contained in a string into links.  Example:</p>
+
+<code>$string = auto_link($string);</code>
+
+<p>The second parameter determines whether URLs and emails are converted or just one or the other.  Default behavior is both
+if the parameter is not specified.  Email links are encoded as safe_mailto() as shown above.</p>
+
+<p>Converts only URLs:</p>
+<code>$string = auto_link($string, 'url');</code>
+
+<p>Converts only Email addresses:</p>
+<code>$string = auto_link($string, 'email');</code>
+
+<p>The third parameter determines whether links are shown in a new window.  The value can be TRUE or FALSE (boolean):</p>
+<code>$string = auto_link($string, 'both', TRUE);</code>
+
+
+<h2>url_title()</h2>
+<p>Takes a string as input and creates a human-friendly URL string. This is useful if, for example, you have a blog
+in which you'd like to use the title of your entries in the URL.  Example:</p>
+
+<code>$title = "What's wrong with CSS?";<br />
+<br />
+$url_title = url_title($title);<br />
+<br />
+// Produces:  Whats-wrong-with-CSS
+</code>
+
+
+<p>The second parameter determines the word delimiter.  By default dashes are used.  Options are:  <dfn>dash</dfn>, or <dfn>underscore</dfn>:</p>
+
+<code>$title = "What's wrong with CSS?";<br />
+<br />
+$url_title = url_title($title, 'underscore');<br />
+<br />
+// Produces:  Whats_wrong_with_CSS
+</code>
+
+<p>The third parameter determines whether or not lowercase characters are forced.  By default they are not.  Options are boolean <dfn>TRUE</dfn>/<dfn>FALSE</dfn>:</p>
+
+<code>$title = "What's wrong with CSS?";<br />
+<br />
+$url_title = url_title($title, 'underscore', TRUE);<br />
+<br />
+// Produces:  whats_wrong_with_css
+</code>
+
+<h3>prep_url()</h3>
+<p>This function will add <kbd>http://</kbd> in the event that a scheme is missing from a URL.  Pass the URL string to the function like this:</p>
+<code>
+$url = "example.com";<br /><br />
+$url = prep_url($url);</code>
+
+
+
+
+<h2>redirect()</h2>
+
+<p>Does a "header redirect" to the URI specified. If you specify the full site URL that link will be build, but for local links simply providing the URI segments
+to the controller you want to direct to will create the link. The function will build the URL based on your config file values.</p>
+
+<p>The optional second parameter allows you to choose between the "location"
+method (default) or the "refresh" method.  Location is faster, but on Windows servers it can sometimes be a problem.  The optional third parameter allows you to send a specific HTTP Response Code - this could be used for example to create 301 redirects for search engine purposes. The default Response Code is 302. The third parameter is <em>only</em> available with 'location' redirects, and not 'refresh'. Examples:</p>
+
+<code>if ($logged_in == FALSE)<br />
+{<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;redirect('/login/form/', 'refresh');<br />
+}<br />
+<br />
+// with 301 redirect<br />
+redirect('/article/13', 'location', 301);</code>
+
+<p class="important"><strong>Note:</strong> In order for this function to work it must be used before anything is outputted
+to the browser since it utilizes server headers.<br />
+<strong>Note:</strong> For  very fine grained control over headers, you should use the <a href="../libraries/output.html">Output  Library</a>'s set_header() function.</p>
+
+
+
+
+
+
+</div>
+<!-- END CONTENT -->
+
+
+<div id="footer">
+<p>
+Previous Topic:&nbsp;&nbsp;<a href="typography_helper.html">Typography Helper</a>
+&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+<a href="#top">Top of Page</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+<a href="../index.html">User Guide Home</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+Next Topic:&nbsp;&nbsp;<a href="xml_helper.html">XML Helper</a>
+</p>
+<p><a href="http://codeigniter.com">CodeIgniter</a> &nbsp;&middot;&nbsp; Copyright &#169; 2006 - 2011 &nbsp;&middot;&nbsp; <a href="http://ellislab.com/">EllisLab, Inc.</a></p>
+</div>
+
+</body>
+</html>
\ No newline at end of file
diff --git a/user_guide/helpers/xml_helper.html b/user_guide/helpers/xml_helper.html
new file mode 100755 (executable)
index 0000000..ded9aaa
--- /dev/null
@@ -0,0 +1,105 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head>
+
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+<title>XML Helper : CodeIgniter User Guide</title>
+
+<style type='text/css' media='all'>@import url('../userguide.css');</style>
+<link rel='stylesheet' type='text/css' media='all' href='../userguide.css' />
+
+<script type="text/javascript" src="../nav/nav.js"></script>
+<script type="text/javascript" src="../nav/prototype.lite.js"></script>
+<script type="text/javascript" src="../nav/moo.fx.js"></script>
+<script type="text/javascript" src="../nav/user_guide_menu.js"></script>
+
+<meta http-equiv='expires' content='-1' />
+<meta http-equiv= 'pragma' content='no-cache' />
+<meta name='robots' content='all' />
+<meta name='author' content='ExpressionEngine Dev Team' />
+<meta name='description' content='CodeIgniter User Guide' />
+
+</head>
+<body>
+
+<!-- START NAVIGATION -->
+<div id="nav"><div id="nav_inner"><script type="text/javascript">create_menu('../');</script></div></div>
+<div id="nav2"><a name="top"></a><a href="javascript:void(0);" onclick="myHeight.toggle();"><img src="../images/nav_toggle_darker.jpg" width="154" height="43" border="0" title="Toggle Table of Contents" alt="Toggle Table of Contents" /></a></div>
+<div id="masthead">
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td><h1>CodeIgniter User Guide Version 2.0.2</h1></td>
+<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
+</tr>
+</table>
+</div>
+<!-- END NAVIGATION -->
+
+
+<!-- START BREADCRUMB -->
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td id="breadcrumb">
+<a href="http://codeigniter.com/">CodeIgniter Home</a> &nbsp;&#8250;&nbsp;
+<a href="../index.html">User Guide Home</a> &nbsp;&#8250;&nbsp;
+XML Helper
+</td>
+<td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="codeigniter.com/user_guide/" />Search User Guide&nbsp; <input type="text" class="input" style="width:200px;" name="q" id="q" size="31" maxlength="255" value="" />&nbsp;<input type="submit" class="submit" name="sa" value="Go" /></form></td>
+</tr>
+</table>
+<!-- END BREADCRUMB -->
+
+<br clear="all" />
+
+
+<!-- START CONTENT -->
+<div id="content">
+
+
+<h1>XML Helper</h1>
+
+<p>The XML Helper file contains functions that assist in working with XML data.</p>
+
+
+<h2>Loading this Helper</h2>
+
+<p>This helper is loaded using the following code:</p>
+<code>$this->load->helper('xml');</code>
+
+<p>The following functions are available:</p>
+
+<h2>xml_convert('<var>string</var>')</h2>
+
+<p>Takes a string as input and converts the following reserved XML characters to entities:</p>
+
+<p>
+Ampersands: &amp;<br />
+Less then and greater than characters: &lt; &gt;<br />
+Single and double quotes: ' &nbsp;"<br />
+Dashes: -</p>
+
+<p>This function ignores ampersands if they are part of existing character entities.  Example:</p>
+
+<code>$string = xml_convert($string);</code>
+
+
+
+
+
+
+</div>
+<!-- END CONTENT -->
+
+
+<div id="footer">
+<p>
+Previous Topic:&nbsp;&nbsp;<a href="url_helper.html">URL Helper</a>
+&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+<a href="#top">Top of Page</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+<a href="../index.html">User Guide Home</a>
+</p>
+<p><a href="http://codeigniter.com">CodeIgniter</a> &nbsp;&middot;&nbsp; Copyright &#169; 2006 - 2011 &nbsp;&middot;&nbsp; <a href="http://ellislab.com/">EllisLab, Inc.</a></p>
+</div>
+
+</body>
+</html>
\ No newline at end of file
diff --git a/user_guide/images/appflowchart.gif b/user_guide/images/appflowchart.gif
new file mode 100755 (executable)
index 0000000..422332c
Binary files /dev/null and b/user_guide/images/appflowchart.gif differ
diff --git a/user_guide/images/arrow.gif b/user_guide/images/arrow.gif
new file mode 100755 (executable)
index 0000000..9e9c79a
Binary files /dev/null and b/user_guide/images/arrow.gif differ
diff --git a/user_guide/images/ci_logo.jpg b/user_guide/images/ci_logo.jpg
new file mode 100755 (executable)
index 0000000..3ae0eee
Binary files /dev/null and b/user_guide/images/ci_logo.jpg differ
diff --git a/user_guide/images/ci_logo_flame.jpg b/user_guide/images/ci_logo_flame.jpg
new file mode 100755 (executable)
index 0000000..17e9c58
Binary files /dev/null and b/user_guide/images/ci_logo_flame.jpg differ
diff --git a/user_guide/images/ci_quick_ref.png b/user_guide/images/ci_quick_ref.png
new file mode 100755 (executable)
index 0000000..c07d6b4
Binary files /dev/null and b/user_guide/images/ci_quick_ref.png differ
diff --git a/user_guide/images/codeigniter_1.7.1_helper_reference.pdf b/user_guide/images/codeigniter_1.7.1_helper_reference.pdf
new file mode 100755 (executable)
index 0000000..85af7c8
Binary files /dev/null and b/user_guide/images/codeigniter_1.7.1_helper_reference.pdf differ
diff --git a/user_guide/images/codeigniter_1.7.1_helper_reference.png b/user_guide/images/codeigniter_1.7.1_helper_reference.png
new file mode 100755 (executable)
index 0000000..15a7c15
Binary files /dev/null and b/user_guide/images/codeigniter_1.7.1_helper_reference.png differ
diff --git a/user_guide/images/codeigniter_1.7.1_library_reference.pdf b/user_guide/images/codeigniter_1.7.1_library_reference.pdf
new file mode 100755 (executable)
index 0000000..13cb360
Binary files /dev/null and b/user_guide/images/codeigniter_1.7.1_library_reference.pdf differ
diff --git a/user_guide/images/codeigniter_1.7.1_library_reference.png b/user_guide/images/codeigniter_1.7.1_library_reference.png
new file mode 100755 (executable)
index 0000000..7f054f9
Binary files /dev/null and b/user_guide/images/codeigniter_1.7.1_library_reference.png differ
diff --git a/user_guide/images/file.gif b/user_guide/images/file.gif
new file mode 100755 (executable)
index 0000000..8141e03
Binary files /dev/null and b/user_guide/images/file.gif differ
diff --git a/user_guide/images/folder.gif b/user_guide/images/folder.gif
new file mode 100755 (executable)
index 0000000..fef31a6
Binary files /dev/null and b/user_guide/images/folder.gif differ
diff --git a/user_guide/images/nav_bg_darker.jpg b/user_guide/images/nav_bg_darker.jpg
new file mode 100755 (executable)
index 0000000..816efad
Binary files /dev/null and b/user_guide/images/nav_bg_darker.jpg differ
diff --git a/user_guide/images/nav_separator_darker.jpg b/user_guide/images/nav_separator_darker.jpg
new file mode 100755 (executable)
index 0000000..a09bd5a
Binary files /dev/null and b/user_guide/images/nav_separator_darker.jpg differ
diff --git a/user_guide/images/nav_toggle_darker.jpg b/user_guide/images/nav_toggle_darker.jpg
new file mode 100755 (executable)
index 0000000..eff33de
Binary files /dev/null and b/user_guide/images/nav_toggle_darker.jpg differ
diff --git a/user_guide/images/reactor-bullet.png b/user_guide/images/reactor-bullet.png
new file mode 100755 (executable)
index 0000000..89c8129
Binary files /dev/null and b/user_guide/images/reactor-bullet.png differ
diff --git a/user_guide/images/smile.gif b/user_guide/images/smile.gif
new file mode 100755 (executable)
index 0000000..bf09225
Binary files /dev/null and b/user_guide/images/smile.gif differ
diff --git a/user_guide/images/transparent.gif b/user_guide/images/transparent.gif
new file mode 100755 (executable)
index 0000000..b740647
Binary files /dev/null and b/user_guide/images/transparent.gif differ
diff --git a/user_guide/index.html b/user_guide/index.html
new file mode 100755 (executable)
index 0000000..2681004
--- /dev/null
@@ -0,0 +1,99 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head>
+
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+<title>Welcome to CodeIgniter : CodeIgniter User Guide</title>
+
+<style type='text/css' media='all'>@import url('userguide.css');</style>
+<link rel='stylesheet' type='text/css' media='all' href='userguide.css' />
+
+<script type="text/javascript" src="nav/nav.js"></script>
+<script type="text/javascript" src="nav/prototype.lite.js"></script>
+<script type="text/javascript" src="nav/moo.fx.js"></script>
+<script type="text/javascript" src="nav/user_guide_menu.js"></script>
+
+<meta http-equiv='expires' content='-1' />
+<meta http-equiv= 'pragma' content='no-cache' />
+<meta name='robots' content='all' />
+<meta name='author' content='ExpressionEngine Dev Team' />
+<meta name='description' content='CodeIgniter User Guide' />
+
+</head>
+<body>
+
+<!-- START NAVIGATION -->
+<div id="nav"><div id="nav_inner"><script type="text/javascript">create_menu('null');</script></div></div>
+<div id="nav2"><a name="top"></a><a href="javascript:void(0);" onclick="myHeight.toggle();"><img src="images/nav_toggle_darker.jpg" width="154" height="43" border="0" title="Toggle Table of Contents" alt="Toggle Table of Contents" /></a></div>
+<div id="masthead">
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td><h1>CodeIgniter User Guide Version 2.0.2</h1></td>
+<td id="breadcrumb_right"><a href="toc.html">Table of Contents Page</a></td>
+</tr>
+</table>
+</div>
+<!-- END NAVIGATION -->
+
+
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td id="breadcrumb">
+<a href="http://codeigniter.com/">CodeIgniter Home</a> &nbsp;&#8250;&nbsp; CodeIgniter User Guide
+</td>
+<td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="codeigniter.com/user_guide/" />Search User Guide&nbsp; <input type="text" class="input" style="width:200px;" name="q" id="q" size="31" maxlength="255" value="" />&nbsp;<input type="submit" class="submit" name="sa" value="Go" /></form></td>
+</tr>
+</table>
+
+
+
+<br clear="all" />
+
+<div class="center"><img src="images/ci_logo_flame.jpg" width="150" height="164" border="0" alt="CodeIgniter" /></div>
+
+
+<!-- START CONTENT -->
+<div id="content">
+
+
+
+<h2>Welcome to CodeIgniter</h2>
+
+<p>CodeIgniter is an Application Development Framework - a toolkit - for people who build web sites using PHP.
+Its goal is to enable you to develop projects much faster than you could if you were writing code
+from scratch, by providing a rich set of libraries for commonly needed tasks, as well as a simple interface and
+logical structure to access these libraries. CodeIgniter lets you creatively focus on your project by
+minimizing the amount of code needed for a given task.</p>
+
+
+<h2>Who is CodeIgniter For?</h2>
+
+<p>CodeIgniter is right for you if:</p>
+
+<ul>
+<li>You want a framework with a small footprint.</li>
+<li>You need exceptional performance.</li>
+<li>You need broad compatibility with standard hosting accounts that run a variety of PHP versions and configurations.</li>
+<li>You want a framework that requires nearly zero configuration.</li>
+<li>You want a framework that does not require you to use the command line.</li>
+<li>You want a framework that does not require you to adhere to restrictive coding rules.</li>
+<li>You are not interested in large-scale monolithic libraries like PEAR.</li>
+<li>You do not want to be forced to learn a templating language (although a template parser is optionally available if you desire one).</li>
+<li>You eschew complexity, favoring simple solutions.</li>
+<li>You need clear, thorough documentation.</li>
+</ul>
+
+
+</div>
+<!-- END CONTENT -->
+
+
+<div id="footer">
+<p><a href="#top">Top of Page</a></p>
+<p><a href="http://codeigniter.com">CodeIgniter</a> &nbsp;&middot;&nbsp; Copyright &#169; 2006 - 2011 &nbsp;&middot;&nbsp; <a href="http://ellislab.com/">EllisLab, Inc.</a></p>
+</div>
+
+
+
+</body>
+</html>
\ No newline at end of file
diff --git a/user_guide/installation/downloads.html b/user_guide/installation/downloads.html
new file mode 100755 (executable)
index 0000000..54fff5a
--- /dev/null
@@ -0,0 +1,113 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head>
+
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+<title>Downloading CodeIgniter : CodeIgniter User Guide</title>
+
+<style type='text/css' media='all'>@import url('../userguide.css');</style>
+<link rel='stylesheet' type='text/css' media='all' href='../userguide.css' />
+
+<script type="text/javascript" src="../nav/nav.js"></script>
+<script type="text/javascript" src="../nav/prototype.lite.js"></script>
+<script type="text/javascript" src="../nav/moo.fx.js"></script>
+<script type="text/javascript" src="../nav/user_guide_menu.js"></script>
+
+<meta http-equiv='expires' content='-1' />
+<meta http-equiv= 'pragma' content='no-cache' />
+<meta name='robots' content='all' />
+<meta name='author' content='ExpressionEngine Dev Team' />
+<meta name='description' content='CodeIgniter User Guide' />
+
+</head>
+<body>
+
+<!-- START NAVIGATION -->
+<div id="nav"><div id="nav_inner"><script type="text/javascript">create_menu('../');</script></div></div>
+<div id="nav2"><a name="top"></a><a href="javascript:void(0);" onclick="myHeight.toggle();"><img src="../images/nav_toggle_darker.jpg" width="154" height="43" border="0" title="Toggle Table of Contents" alt="Toggle Table of Contents" /></a></div>
+<div id="masthead">
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td><h1>CodeIgniter User Guide Version 2.0.2</h1></td>
+<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
+</tr>
+</table>
+</div>
+<!-- END NAVIGATION -->
+
+
+<!-- START BREADCRUMB -->
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td id="breadcrumb">
+<a href="http://codeigniter.com/">CodeIgniter Home</a> &nbsp;&#8250;&nbsp;
+<a href="../index.html">User Guide Home</a> &nbsp;&#8250;&nbsp;
+Downloading CodeIgniter
+</td>
+<td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="codeigniter.com/user_guide/" />Search User Guide&nbsp; <input type="text" class="input" style="width:200px;" name="q" id="q" size="31" maxlength="255" value="" />&nbsp;<input type="submit" class="submit" name="sa" value="Go" /></form></td>
+</tr>
+</table>
+<!-- END BREADCRUMB -->
+
+<br clear="all" />
+
+
+<!-- START CONTENT -->
+<div id="content">
+
+<h1>Downloading CodeIgniter</h1>
+
+<ul>
+       <li><a href="http://codeigniter.com/downloads/">CodeIgniter V 2.0.2 (Current version)</a></li>
+       <li><a href="http://codeigniter.com/download_files/CodeIgniter_2.0.1.zip">CodeIgniter V 2.0.1</a></li>
+       <li><a href="http://codeigniter.com/download_files/CodeIgniter_2.0.0.zip">CodeIgniter V 2.0.0</a></li>
+       <li><a href="http://codeigniter.com/download_files/CodeIgniter_1.7.3.zip">CodeIgniter V 1.7.3</a></li>
+       <li><a href="http://codeigniter.com/download_files/CodeIgniter_1.7.2.zip">CodeIgniter V 1.7.2</a></li>
+       <li><a href="http://codeigniter.com/download_files/CodeIgniter_1.7.1.zip">CodeIgniter V 1.7.1</a></li>
+       <li><a href="http://codeigniter.com/download_files/CodeIgniter_1.7.0.zip">CodeIgniter V 1.7.0</a></li>
+       <li><a href="http://codeigniter.com/download_files/CodeIgniter_1.6.3.zip">CodeIgniter V 1.6.3</a></li>
+       <li><a href="http://codeigniter.com/download_files/CodeIgniter_1.6.2.zip">CodeIgniter V 1.6.2</a></li>
+       <li><a href="http://codeigniter.com/download_files/CodeIgniter_1.6.1.zip">CodeIgniter V 1.6.1</a></li>
+       <li><a href="http://codeigniter.com/download_files/CodeIgniter_1.6.0.zip">CodeIgniter V 1.6.0</a></li>
+       <li><a href="http://codeigniter.com/download_files/CodeIgniter_1.5.4.zip">CodeIgniter V 1.5.4</a></li>
+       <li><a href="http://codeigniter.com/download_files/CodeIgniter_1.5.3.zip">CodeIgniter V 1.5.3</a></li>
+       <li><a href="http://codeigniter.com/download_files/CodeIgniter_1.5.2.zip">CodeIgniter V 1.5.2</a></li>
+       <li><a href="http://codeigniter.com/download_files/CodeIgniter_1.5.1.zip">CodeIgniter V 1.5.1</a></li>
+       <li><a href="http://codeigniter.com/download_files/CodeIgniter_1.4.1.zip">CodeIgniter V 1.4.1</a></li>
+       <li><a href="http://codeigniter.com/download_files/CodeIgniter_1.3.3.zip">CodeIgniter V 1.3.3</a></li>
+       <li><a href="http://codeigniter.com/download_files/CodeIgniter_1.3.2.zip">CodeIgniter V 1.3.2</a></li>
+       <li><a href="http://codeigniter.com/download_files/CodeIgniter_1.3.1.zip">CodeIgniter V 1.3.1</a></li>
+       <li><a href="http://codeigniter.com/download_files/CodeIgniter_1.3.zip">CodeIgniter V 1.3</a></li>
+       <li><a href="http://codeigniter.com/download_files/CodeIgniter_1.2.zip">CodeIgniter V 1.2</a></li>
+       <li><a href="http://codeigniter.com/download_files/CodeIgniter_1.1b.zip">CodeIgniter V 1.1</a></li>
+       <li><a href="http://codeigniter.com/download_files/CodeIgniter_1.0b.zip">CodeIgniter V 1.0</a></li>
+</ul>
+
+
+
+
+<h1 id="hg">Mercurial Server</h1>
+<p><a href="http://mercurial.selenic.com">Mercurial</a> is a distributed version control system.</p>
+
+                                                       <p>Public Hg access is available at <a href="http://bitbucket.org/ellislab/codeigniter-reactor/">BitBucket</a>.
+                                                               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.</p>
+
+                                                       <p>Beginning with version 1.6.1, stable tags are also available via BitBucket, simply select the version from the Tags dropdown.</p>
+</div>
+<!-- END CONTENT -->
+
+
+<div id="footer">
+<p>
+Previous Topic:&nbsp;&nbsp;<a href="../general/credits.html">Credits</a>
+&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+<a href="#top">Top of Page</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+<a href="../index.html">User Guide Home</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+Next Topic:&nbsp;&nbsp;<a href="../installation/index.html">Installation Instructions</a>
+</p>
+<p><a href="http://codeigniter.com">CodeIgniter</a> &nbsp;&middot;&nbsp; Copyright &#169; 2006 - 2011 &nbsp;&middot;&nbsp; <a href="http://ellislab.com/">EllisLab, Inc.</a></p>
+</div>
+
+</body>
+</html>
\ No newline at end of file
diff --git a/user_guide/installation/index.html b/user_guide/installation/index.html
new file mode 100755 (executable)
index 0000000..87da518
--- /dev/null
@@ -0,0 +1,108 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head>
+
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+<title>Installation Instructions : CodeIgniter User Guide</title>
+
+<style type='text/css' media='all'>@import url('../userguide.css');</style>
+<link rel='stylesheet' type='text/css' media='all' href='../userguide.css' />
+
+<script type="text/javascript" src="../nav/nav.js"></script>
+<script type="text/javascript" src="../nav/prototype.lite.js"></script>
+<script type="text/javascript" src="../nav/moo.fx.js"></script>
+<script type="text/javascript" src="../nav/user_guide_menu.js"></script>
+
+<meta http-equiv='expires' content='-1' />
+<meta http-equiv= 'pragma' content='no-cache' />
+<meta name='robots' content='all' />
+<meta name='author' content='ExpressionEngine Dev Team' />
+<meta name='description' content='CodeIgniter User Guide' />
+
+</head>
+<body>
+
+<!-- START NAVIGATION -->
+<div id="nav"><div id="nav_inner"><script type="text/javascript">create_menu('../');</script></div></div>
+<div id="nav2"><a name="top"></a><a href="javascript:void(0);" onclick="myHeight.toggle();"><img src="../images/nav_toggle_darker.jpg" width="154" height="43" border="0" title="Toggle Table of Contents" alt="Toggle Table of Contents" /></a></div>
+<div id="masthead">
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td><h1>CodeIgniter User Guide Version 2.0.2</h1></td>
+<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
+</tr>
+</table>
+</div>
+<!-- END NAVIGATION -->
+
+
+<!-- START BREADCRUMB -->
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td id="breadcrumb">
+<a href="http://codeigniter.com/">CodeIgniter Home</a> &nbsp;&#8250;&nbsp;
+<a href="../index.html">User Guide Home</a> &nbsp;&#8250;&nbsp;
+Installation Instructions
+</td>
+<td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="codeigniter.com/user_guide/" />Search User Guide&nbsp; <input type="text" class="input" style="width:200px;" name="q" id="q" size="31" maxlength="255" value="" />&nbsp;<input type="submit" class="submit" name="sa" value="Go" /></form></td>
+</tr>
+</table>
+<!-- END BREADCRUMB -->
+
+<br clear="all" />
+
+
+<!-- START CONTENT -->
+<div id="content">
+
+<h1>Installation Instructions</h1>
+
+<p>CodeIgniter is installed in four steps:</p>
+
+<ol>
+<li>Unzip the package.</li>
+<li>Upload the CodeIgniter folders and files to your server.  Normally the index.php file will be at your root.</li>
+<li>Open the <dfn>application/config/config.php</dfn> file with a text editor and set your base URL.  If you intend to use encryption or sessions, set your encryption key.</li>
+<li>If you intend to use a database, open the <dfn>application/config/database.php</dfn> file with a text editor and set your database settings.</li>
+</ol>
+
+<p>If you wish to increase security by hiding the location of your CodeIgniter files you can rename the <dfn>system</dfn> and <dfn>application</dfn> folders
+to something more private.  If you do rename them, you must open your main <kbd>index.php</kbd> file and set the <samp>$system_folder</samp> and <samp>$application_folder</samp>
+variables at the top of the file with the new name you've chosen.</p>
+
+<p>For the best security, both the <dfn>system</dfn> and any <dfn>application</dfn> folders should be placed above web root so that they are not directly accessible via a browser.  By default, .htaccess files are included in each folder to help prevent direct access, but it is best to remove them from public access entirely in case the web server configuration changes or doesn't abide by the .htaccess.</p>
+
+<p>After moving them, open your main <kdb>index.php</kbd> file and set the <samp>$system_folder</samp> and <samp>$application_folder</samp> variables, preferably with a full path, e.g. '<dfn>/www/MyUser/system</dfn>'.</p>
+
+<p>
+    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 <kbd>ENVIRONMENT</kbd> constant, which is
+    more fully described on the <a href="../general/security.html">security page</a>.
+</p>
+
+<p>That's it!</p>
+
+<p>If you're new to CodeIgniter, please read the <a href="../overview/getting_started.html">Getting Started</a> section of the User Guide to begin learning how
+to build dynamic PHP applications. Enjoy!</p>
+
+
+
+</div>
+<!-- END CONTENT -->
+
+
+<div id="footer">
+<p>
+Previous Topic:&nbsp;&nbsp;<a href="../general/credits.html">Credits</a>
+&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+<a href="#top">Top of Page</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+<a href="../index.html">User Guide Home</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+Next Topic:&nbsp;&nbsp;<a href="upgrading.html">Upgrading from a Previous Version</a>
+</p>
+
+<p><a href="http://codeigniter.com">CodeIgniter</a> &nbsp;&middot;&nbsp; Copyright &#169; 2006 - 2011 &nbsp;&middot;&nbsp; <a href="http://ellislab.com/">EllisLab, Inc.</a></p>
+</div>
+
+</body>
+</html>
\ No newline at end of file
diff --git a/user_guide/installation/troubleshooting.html b/user_guide/installation/troubleshooting.html
new file mode 100755 (executable)
index 0000000..2a50b8d
--- /dev/null
@@ -0,0 +1,90 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head>
+
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+<title>Troubleshooting : CodeIgniter User Guide</title>
+
+<style type='text/css' media='all'>@import url('../userguide.css');</style>
+<link rel='stylesheet' type='text/css' media='all' href='../userguide.css' />
+
+<script type="text/javascript" src="../nav/nav.js"></script>
+<script type="text/javascript" src="../nav/prototype.lite.js"></script>
+<script type="text/javascript" src="../nav/moo.fx.js"></script>
+<script type="text/javascript" src="../nav/user_guide_menu.js"></script>
+
+<meta http-equiv='expires' content='-1' />
+<meta http-equiv= 'pragma' content='no-cache' />
+<meta name='robots' content='all' />
+<meta name='author' content='ExpressionEngine Dev Team' />
+<meta name='description' content='CodeIgniter User Guide' />
+
+</head>
+<body>
+
+<!-- START NAVIGATION -->
+<div id="nav"><div id="nav_inner"><script type="text/javascript">create_menu('../');</script></div></div>
+<div id="nav2"><a name="top"></a><a href="javascript:void(0);" onclick="myHeight.toggle();"><img src="../images/nav_toggle_darker.jpg" width="154" height="43" border="0" title="Toggle Table of Contents" alt="Toggle Table of Contents" /></a></div>
+<div id="masthead">
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td><h1>CodeIgniter User Guide Version 2.0.2</h1></td>
+<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
+</tr>
+</table>
+</div>
+<!-- END NAVIGATION -->
+
+
+<!-- START BREADCRUMB -->
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td id="breadcrumb">
+<a href="http://codeigniter.com/">CodeIgniter Home</a> &nbsp;&#8250;&nbsp;
+<a href="../index.html">User Guide Home</a> &nbsp;&#8250;&nbsp;
+Trouble Shooting
+</td>
+<td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="codeigniter.com/user_guide/" />Search User Guide&nbsp; <input type="text" class="input" style="width:200px;" name="q" id="q" size="31" maxlength="255" value="" />&nbsp;<input type="submit" class="submit" name="sa" value="Go" /></form></td>
+</tr>
+</table>
+<!-- END BREADCRUMB -->
+
+<br clear="all" />
+
+
+<!-- START CONTENT -->
+<div id="content">
+
+<h1>Troubleshooting</h1>
+
+<p>If you find that no matter what you put in your URL only your default page is loading, it might be that your server
+does not support the PATH_INFO variable needed to serve search-engine friendly URLs.
+
+As a first step, open your <dfn>application/config/config.php</dfn> file and look for the <kbd>URI Protocol</kbd>
+information. It will recommend that you try a couple alternate settings.  If it still doesn't work after you've tried this you'll need
+to force CodeIgniter to add a question mark to your URLs.  To do this open your <kbd>application/config/config.php</kbd> file and change this:</p>
+
+<code>$config['index_page'] = "index.php";</code>
+
+<p>To this:</p>
+
+<code>$config['index_page'] = "index.php?";</code>
+
+
+</div>
+<!-- END CONTENT -->
+
+
+<div id="footer">
+<p>
+Previous Topic:&nbsp;&nbsp;<a href="upgrading.html">Upgrading from a Previous Version</a>
+&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+<a href="#top">Top of Page</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+<a href="../index.html">User Guide Home</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+Next Topic:&nbsp;&nbsp;<a href="../overview/at_a_glance.html">CodeIgniter at a Glance</a>
+</p>
+<p><a href="http://codeigniter.com">CodeIgniter</a> &nbsp;&middot;&nbsp; Copyright &#169; 2006 - 2011 &nbsp;&middot;&nbsp; <a href="http://ellislab.com/">EllisLab, Inc.</a></p>
+</div>
+
+</body>
+</html>
\ No newline at end of file
diff --git a/user_guide/installation/upgrade_120.html b/user_guide/installation/upgrade_120.html
new file mode 100755 (executable)
index 0000000..563c98c
--- /dev/null
@@ -0,0 +1,92 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head>
+
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+<title>CodeIgniter User Guide</title>
+
+<style type='text/css' media='all'>@import url('../userguide.css');</style>
+<link rel='stylesheet' type='text/css' media='all' href='../userguide.css' />
+
+<script type="text/javascript" src="../nav/nav.js"></script>
+<script type="text/javascript" src="../nav/prototype.lite.js"></script>
+<script type="text/javascript" src="../nav/moo.fx.js"></script>
+<script type="text/javascript" src="../nav/user_guide_menu.js"></script>
+
+<meta http-equiv='expires' content='-1' />
+<meta http-equiv= 'pragma' content='no-cache' />
+<meta name='robots' content='all' />
+<meta name='author' content='ExpressionEngine Dev Team' />
+<meta name='description' content='CodeIgniter User Guide' />
+
+</head>
+<body>
+
+<!-- START NAVIGATION -->
+<div id="nav"><div id="nav_inner"><script type="text/javascript">create_menu('../');</script></div></div>
+<div id="nav2"><a name="top"></a><a href="javascript:void(0);" onclick="myHeight.toggle();"><img src="../images/nav_toggle_darker.jpg" width="154" height="43" border="0" title="Toggle Table of Contents" alt="Toggle Table of Contents" /></a></div>
+<div id="masthead">
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td><h1>CodeIgniter User Guide Version 2.0.2</h1></td>
+<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
+</tr>
+</table>
+</div>
+<!-- END NAVIGATION -->
+
+
+<!-- START BREADCRUMB -->
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td id="breadcrumb">
+<a href="http://codeigniter.com/">CodeIgniter Home</a> &nbsp;&#8250;&nbsp;
+<a href="../index.html">User Guide Home</a> &nbsp;&#8250;&nbsp;
+Upgrading from Beta 1.1 to Final 1.2
+</td>
+<td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="codeigniter.com/user_guide/" />Search User Guide&nbsp; <input type="text" class="input" style="width:200px;" name="q" id="q" size="31" maxlength="255" value="" />&nbsp;<input type="submit" class="submit" name="sa" value="Go" /></form></td>
+</tr>
+</table>
+<!-- END BREADCRUMB -->
+
+<br clear="all" />
+
+
+<!-- START CONTENT -->
+<div id="content">
+
+<h1>Upgrading From Beta 1.0 to Final 1.2</h1>
+
+<p>To upgrade to Version 1.2 please replace the following directories with the new versions:</p>
+
+<p class="important"><strong>Note:</strong> If you have any custom developed files in these folders please make copies of them first.</p>
+
+<ul>
+<li>drivers</li>
+<li>helpers</li>
+<li>init</li>
+<li>language</li>
+<li>libraries</li>
+<li>plugins</li>
+<li>scaffolding</li>
+</ul>
+
+<p>Please also replace your local copy of the user guide with the new version.</p>
+
+</div>
+<!-- END CONTENT -->
+
+
+<div id="footer">
+<p>
+Previous Topic:&nbsp;&nbsp;<a href="index.html">Installation Instructions</a>
+&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+<a href="#top">Top of Page</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+<a href="../index.html">User Guide Home</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+Next Topic:&nbsp;&nbsp;<a href="troubleshooting.html">Troubleshooting</a>
+</p>
+<p><a href="http://codeigniter.com">CodeIgniter</a> &nbsp;&middot;&nbsp; Copyright &#169; 2006 - 2011 &nbsp;&middot;&nbsp; <a href="http://ellislab.com/">EllisLab, Inc.</a></p>
+</div>
+
+</body>
+</html>
\ No newline at end of file
diff --git a/user_guide/installation/upgrade_130.html b/user_guide/installation/upgrade_130.html
new file mode 100755 (executable)
index 0000000..f7ffac7
--- /dev/null
@@ -0,0 +1,203 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head>
+
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+<title>CodeIgniter User Guide</title>
+
+<style type='text/css' media='all'>@import url('../userguide.css');</style>
+<link rel='stylesheet' type='text/css' media='all' href='../userguide.css' />
+
+<script type="text/javascript" src="../nav/nav.js"></script>
+<script type="text/javascript" src="../nav/prototype.lite.js"></script>
+<script type="text/javascript" src="../nav/moo.fx.js"></script>
+<script type="text/javascript" src="../nav/user_guide_menu.js"></script>
+
+<meta http-equiv='expires' content='-1' />
+<meta http-equiv= 'pragma' content='no-cache' />
+<meta name='robots' content='all' />
+<meta name='author' content='ExpressionEngine Dev Team' />
+<meta name='description' content='CodeIgniter User Guide' />
+
+</head>
+<body>
+
+<!-- START NAVIGATION -->
+<div id="nav"><div id="nav_inner"><script type="text/javascript">create_menu('../');</script></div></div>
+<div id="nav2"><a name="top"></a><a href="javascript:void(0);" onclick="myHeight.toggle();"><img src="../images/nav_toggle_darker.jpg" width="154" height="43" border="0" title="Toggle Table of Contents" alt="Toggle Table of Contents" /></a></div>
+<div id="masthead">
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td><h1>CodeIgniter User Guide Version 2.0.2</h1></td>
+<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
+</tr>
+</table>
+</div>
+<!-- END NAVIGATION -->
+
+
+<!-- START BREADCRUMB -->
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td id="breadcrumb">
+<a href="http://codeigniter.com/">CodeIgniter Home</a> &nbsp;&#8250;&nbsp;
+<a href="../index.html">User Guide Home</a> &nbsp;&#8250;&nbsp;
+Upgrading from 1.2 to 1.3
+</td>
+<td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="codeigniter.com/user_guide/" />Search User Guide&nbsp; <input type="text" class="input" style="width:200px;" name="q" id="q" size="31" maxlength="255" value="" />&nbsp;<input type="submit" class="submit" name="sa" value="Go" /></form></td>
+</tr>
+</table>
+<!-- END BREADCRUMB -->
+
+<br clear="all" />
+
+
+<!-- START CONTENT -->
+<div id="content">
+
+<h1>Upgrading from 1.2 to 1.3</h1>
+
+<p class="important"><strong>Note:</strong> The instructions on this page assume you are running version 1.2.  If you
+have not upgraded to that version please do so first.</p>
+
+
+<p>Before performing an update you should take your site offline by replacing the index.php file
+with a static one.</p>
+
+
+<h2>Step 1: Update your CodeIgniter files</h2>
+
+<p>Replace the following directories in your "system" folder with the new versions:</p>
+
+<p class="important"><strong>Note:</strong> If you have any custom developed files in these folders please make copies of them first.</p>
+
+<ul>
+<li>application/<strong>models</strong>/&nbsp;&nbsp;  (new for 1.3)</li>
+<li>codeigniter&nbsp;&nbsp;   (new for 1.3)</li>
+<li>drivers</li>
+<li>helpers</li>
+<li>init</li>
+<li>language</li>
+<li>libraries</li>
+<li>plugins</li>
+<li>scaffolding</li>
+</ul>
+
+
+<h2>Step 2: Update your error files</h2>
+
+<p>Version 1.3 contains two new error templates located in <dfn>application/errors</dfn>, and for naming consistency the other error templates have
+been renamed.</p>
+
+<p>If you <strong>have not</strong> customized any of the error templates simply
+replace this folder:</p>
+
+<ul>
+<li>application/errors/</li>
+</ul>
+
+<p>If you <strong>have</strong> customized your error templates, rename them as follows:</p>
+
+
+<ul>
+<li>404.php&nbsp;&nbsp; =&nbsp; error_404.php</li>
+<li>error.php&nbsp;&nbsp; =&nbsp; error_general.php</li>
+<li>error_db.php&nbsp;&nbsp; (new)</li>
+<li>error_php.php&nbsp;&nbsp; (new)</li>
+</ul>
+
+
+<h2>Step 3: Update your index.php file</h2>
+
+<p>Please open your main <dfn>index.php</dfn> file (located at your root).  At the very bottom of the file, change this:</p>
+
+<code>require_once BASEPATH.'libraries/Front_controller'.EXT;</code>
+
+<p>To this:</p>
+
+<code>require_once BASEPATH.'codeigniter/CodeIgniter'.EXT;</code>
+
+
+<h2>Step 4: Update your config.php file</h2>
+
+<p>Open your <dfn>application/config/config.php</dfn> file and add these new items:</p>
+
+<pre>
+/*
+|------------------------------------------------
+| URL suffix
+|------------------------------------------------
+|
+| This option allows you to add a suffix to all URLs.
+| For example, if a URL is this:
+|
+| example.com/index.php/products/view/shoes
+|
+| You can optionally add a suffix, like ".html",
+| making the page appear to be of a certain type:
+|
+| example.com/index.php/products/view/shoes.html
+|
+*/
+$config['url_suffix'] = "";
+
+
+/*
+|------------------------------------------------
+| Enable Query Strings
+|------------------------------------------------
+|
+| By default CodeIgniter uses search-engine and
+| human-friendly segment based URLs:
+|
+| example.com/who/what/where/
+|
+| You can optionally enable standard query string
+| based URLs:
+|
+| example.com?who=me&what=something&where=here
+|
+| Options are: TRUE or FALSE (boolean)
+|
+| The two other items let you set the query string "words"
+| that will invoke your controllers and functions:
+| example.com/index.php?c=controller&m=function
+|
+*/
+$config['enable_query_strings'] = FALSE;
+$config['controller_trigger'] = 'c';
+$config['function_trigger'] = 'm';
+</pre>
+
+
+<h2>Step 5: Update your database.php file</h2>
+
+<p>Open your <dfn>application/config/database.php</dfn> file and add these new items:</p>
+
+<pre>
+$db['default']['dbprefix'] = "";
+$db['default']['active_r'] = TRUE;
+</pre>
+
+
+<h2>Step 6: Update your user guide</h2>
+
+<p>Please also replace your local copy of the user guide with the new version.</p>
+
+</div>
+<!-- END CONTENT -->
+
+
+<div id="footer">
+<p>
+Previous Topic:&nbsp;&nbsp;<a href="index.html">Installation Instructions</a>
+&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+<a href="#top">Top of Page</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+<a href="../index.html">User Guide Home</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+Next Topic:&nbsp;&nbsp;<a href="troubleshooting.html">Troubleshooting</a>
+</p>
+<p><a href="http://codeigniter.com">CodeIgniter</a> &nbsp;&middot;&nbsp; Copyright &#169; 2006 - 2011 &nbsp;&middot;&nbsp; <a href="http://ellislab.com/">EllisLab, Inc.</a></p>
+</div>
+
+</body>
+</html>
\ No newline at end of file
diff --git a/user_guide/installation/upgrade_131.html b/user_guide/installation/upgrade_131.html
new file mode 100755 (executable)
index 0000000..7541a83
--- /dev/null
@@ -0,0 +1,102 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head>
+
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+<title>CodeIgniter User Guide</title>
+
+<style type='text/css' media='all'>@import url('../userguide.css');</style>
+<link rel='stylesheet' type='text/css' media='all' href='../userguide.css' />
+
+<script type="text/javascript" src="../nav/nav.js"></script>
+<script type="text/javascript" src="../nav/prototype.lite.js"></script>
+<script type="text/javascript" src="../nav/moo.fx.js"></script>
+<script type="text/javascript" src="../nav/user_guide_menu.js"></script>
+
+<meta http-equiv='expires' content='-1' />
+<meta http-equiv= 'pragma' content='no-cache' />
+<meta name='robots' content='all' />
+<meta name='author' content='ExpressionEngine Dev Team' />
+<meta name='description' content='CodeIgniter User Guide' />
+
+</head>
+<body>
+
+<!-- START NAVIGATION -->
+<div id="nav"><div id="nav_inner"><script type="text/javascript">create_menu('../');</script></div></div>
+<div id="nav2"><a name="top"></a><a href="javascript:void(0);" onclick="myHeight.toggle();"><img src="../images/nav_toggle_darker.jpg" width="154" height="43" border="0" title="Toggle Table of Contents" alt="Toggle Table of Contents" /></a></div>
+<div id="masthead">
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td><h1>CodeIgniter User Guide Version 2.0.2</h1></td>
+<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
+</tr>
+</table>
+</div>
+<!-- END NAVIGATION -->
+
+
+<!-- START BREADCRUMB -->
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td id="breadcrumb">
+<a href="http://codeigniter.com/">CodeIgniter Home</a> &nbsp;&#8250;&nbsp;
+<a href="../index.html">User Guide Home</a> &nbsp;&#8250;&nbsp;
+Upgrading from 1.3 to 1.3.1
+</td>
+<td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="codeigniter.com/user_guide/" />Search User Guide&nbsp; <input type="text" class="input" style="width:200px;" name="q" id="q" size="31" maxlength="255" value="" />&nbsp;<input type="submit" class="submit" name="sa" value="Go" /></form></td>
+</tr>
+</table>
+<!-- END BREADCRUMB -->
+
+<br clear="all" />
+
+
+<!-- START CONTENT -->
+<div id="content">
+
+<h1>Upgrading from 1.3 to 1.3.1</h1>
+
+<p class="important"><strong>Note:</strong> The instructions on this page assume you are running version 1.3.  If you
+have not upgraded to that version please do so first.</p>
+
+<p>Before performing an update you should take your site offline by replacing the index.php file with a static one.</p>
+
+
+
+<h2>Step 1: Update your CodeIgniter files</h2>
+
+<p>Replace the following directories in your "system" folder with the new versions:</p>
+
+<p class="important"><strong>Note:</strong> If you have any custom developed files in these folders please make copies of them first.</p>
+
+<ul>
+<li>drivers</li>
+<li>init/init_unit_test.php (new for 1.3.1)</li>
+<li>language/</li>
+<li>libraries</li>
+<li>scaffolding</li>
+</ul>
+
+
+<h2>Step 2: Update your user guide</h2>
+
+<p>Please also replace your local copy of the user guide with the new version.</p>
+
+</div>
+<!-- END CONTENT -->
+
+
+<div id="footer">
+<p>
+Previous Topic:&nbsp;&nbsp;<a href="index.html">Installation Instructions</a>
+&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+<a href="#top">Top of Page</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+<a href="../index.html">User Guide Home</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+Next Topic:&nbsp;&nbsp;<a href="troubleshooting.html">Troubleshooting</a>
+</p>
+<p><a href="http://codeigniter.com">CodeIgniter</a> &nbsp;&middot;&nbsp; Copyright &#169; 2006 - 2011 &nbsp;&middot;&nbsp; <a href="http://ellislab.com/">EllisLab, Inc.</a></p>
+</div>
+
+</body>
+</html>
\ No newline at end of file
diff --git a/user_guide/installation/upgrade_132.html b/user_guide/installation/upgrade_132.html
new file mode 100755 (executable)
index 0000000..4fcbb46
--- /dev/null
@@ -0,0 +1,100 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head>
+
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+<title>CodeIgniter User Guide</title>
+
+<style type='text/css' media='all'>@import url('../userguide.css');</style>
+<link rel='stylesheet' type='text/css' media='all' href='../userguide.css' />
+
+<script type="text/javascript" src="../nav/nav.js"></script>
+<script type="text/javascript" src="../nav/prototype.lite.js"></script>
+<script type="text/javascript" src="../nav/moo.fx.js"></script>
+<script type="text/javascript" src="../nav/user_guide_menu.js"></script>
+
+<meta http-equiv='expires' content='-1' />
+<meta http-equiv= 'pragma' content='no-cache' />
+<meta name='robots' content='all' />
+<meta name='author' content='ExpressionEngine Dev Team' />
+<meta name='description' content='CodeIgniter User Guide' />
+
+</head>
+<body>
+
+<!-- START NAVIGATION -->
+<div id="nav"><div id="nav_inner"><script type="text/javascript">create_menu('../');</script></div></div>
+<div id="nav2"><a name="top"></a><a href="javascript:void(0);" onclick="myHeight.toggle();"><img src="../images/nav_toggle_darker.jpg" width="154" height="43" border="0" title="Toggle Table of Contents" alt="Toggle Table of Contents" /></a></div>
+<div id="masthead">
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td><h1>CodeIgniter User Guide Version 2.0.2</h1></td>
+<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
+</tr>
+</table>
+</div>
+<!-- END NAVIGATION -->
+
+
+<!-- START BREADCRUMB -->
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td id="breadcrumb">
+<a href="http://codeigniter.com/">CodeIgniter Home</a> &nbsp;&#8250;&nbsp;
+<a href="../index.html">User Guide Home</a> &nbsp;&#8250;&nbsp;
+Upgrading from 1.3.1 to 1.3.2
+</td>
+<td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="codeigniter.com/user_guide/" />Search User Guide&nbsp; <input type="text" class="input" style="width:200px;" name="q" id="q" size="31" maxlength="255" value="" />&nbsp;<input type="submit" class="submit" name="sa" value="Go" /></form></td>
+</tr>
+</table>
+<!-- END BREADCRUMB -->
+
+<br clear="all" />
+
+
+<!-- START CONTENT -->
+<div id="content">
+
+<h1>Upgrading from 1.3.1 to 1.3.2</h1>
+
+<p class="important"><strong>Note:</strong> The instructions on this page assume you are running version 1.3.1.  If you
+have not upgraded to that version please do so first.</p>
+
+<p>Before performing an update you should take your site offline by replacing the index.php file with a static one.</p>
+
+
+
+<h2>Step 1: Update your CodeIgniter files</h2>
+
+<p>Replace the following directories in your "system" folder with the new versions:</p>
+
+<p class="important"><strong>Note:</strong> If you have any custom developed files in these folders please make copies of them first.</p>
+
+<ul>
+<li>drivers</li>
+<li>init</li>
+<li>libraries</li>
+</ul>
+
+
+<h2>Step 2: Update your user guide</h2>
+
+<p>Please also replace your local copy of the user guide with the new version.</p>
+
+</div>
+<!-- END CONTENT -->
+
+
+<div id="footer">
+<p>
+Previous Topic:&nbsp;&nbsp;<a href="index.html">Installation Instructions</a>
+&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+<a href="#top">Top of Page</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+<a href="../index.html">User Guide Home</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+Next Topic:&nbsp;&nbsp;<a href="troubleshooting.html">Troubleshooting</a>
+</p>
+<p><a href="http://codeigniter.com">CodeIgniter</a> &nbsp;&middot;&nbsp; Copyright &#169; 2006 - 2011 &nbsp;&middot;&nbsp; <a href="http://ellislab.com/">EllisLab, Inc.</a></p>
+</div>
+
+</body>
+</html>
\ No newline at end of file
diff --git a/user_guide/installation/upgrade_133.html b/user_guide/installation/upgrade_133.html
new file mode 100755 (executable)
index 0000000..c634659
--- /dev/null
@@ -0,0 +1,112 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head>
+
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+<title>CodeIgniter User Guide</title>
+
+<style type='text/css' media='all'>@import url('../userguide.css');</style>
+<link rel='stylesheet' type='text/css' media='all' href='../userguide.css' />
+
+<script type="text/javascript" src="../nav/nav.js"></script>
+<script type="text/javascript" src="../nav/prototype.lite.js"></script>
+<script type="text/javascript" src="../nav/moo.fx.js"></script>
+<script type="text/javascript" src="../nav/user_guide_menu.js"></script>
+
+<meta http-equiv='expires' content='-1' />
+<meta http-equiv= 'pragma' content='no-cache' />
+<meta name='robots' content='all' />
+<meta name='author' content='ExpressionEngine Dev Team' />
+<meta name='description' content='CodeIgniter User Guide' />
+
+</head>
+<body>
+
+<!-- START NAVIGATION -->
+<div id="nav"><div id="nav_inner"><script type="text/javascript">create_menu('../');</script></div></div>
+<div id="nav2"><a name="top"></a><a href="javascript:void(0);" onclick="myHeight.toggle();"><img src="../images/nav_toggle_darker.jpg" width="154" height="43" border="0" title="Toggle Table of Contents" alt="Toggle Table of Contents" /></a></div>
+<div id="masthead">
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td><h1>CodeIgniter User Guide Version 2.0.2</h1></td>
+<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
+</tr>
+</table>
+</div>
+<!-- END NAVIGATION -->
+
+
+<!-- START BREADCRUMB -->
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td id="breadcrumb">
+<a href="http://codeigniter.com/">CodeIgniter Home</a> &nbsp;&#8250;&nbsp;
+<a href="../index.html">User Guide Home</a> &nbsp;&#8250;&nbsp;
+Upgrading from 1.3.2 to 1.3.3
+</td>
+<td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="codeigniter.com/user_guide/" />Search User Guide&nbsp; <input type="text" class="input" style="width:200px;" name="q" id="q" size="31" maxlength="255" value="" />&nbsp;<input type="submit" class="submit" name="sa" value="Go" /></form></td>
+</tr>
+</table>
+<!-- END BREADCRUMB -->
+
+<br clear="all" />
+
+
+<!-- START CONTENT -->
+<div id="content">
+
+<h1>Upgrading from 1.3.2 to 1.3.3</h1>
+
+<p class="important"><strong>Note:</strong> The instructions on this page assume you are running version 1.3.2.  If you
+have not upgraded to that version please do so first.</p>
+
+<p>Before performing an update you should take your site offline by replacing the index.php file with a static one.</p>
+
+
+
+<h2>Step 1: Update your CodeIgniter files</h2>
+
+<p>Replace the following directories in your "system" folder with the new versions:</p>
+
+<p class="important"><strong>Note:</strong> If you have any custom developed files in these folders please make copies of them first.</p>
+
+<ul>
+<li>codeigniter</li>
+<li>drivers</li>
+<li>helpers</li>
+<li>init</li>
+<li>libraries</li>
+</ul>
+
+
+<h2>Step 2: Update your Models</h2>
+
+<p>If you are <strong>NOT</strong> using CodeIgniter's <a href="../general/models.html">Models</a> feature disregard this step.</p>
+
+<p>As of version 1.3.3, CodeIgniter does <strong>not</strong> connect automatically to your database when a model is loaded.  This
+allows you greater flexibility in determining which databases you would like used with your models.  If your application is not connecting
+to your database prior to a model being loaded you will have to update your code.  There are several options for connecting,
+<a href="../general/models.html">as described here</a>.</p>
+
+
+<h2>Step 3: Update your user guide</h2>
+
+<p>Please also replace your local copy of the user guide with the new version.</p>
+
+</div>
+<!-- END CONTENT -->
+
+
+<div id="footer">
+<p>
+Previous Topic:&nbsp;&nbsp;<a href="index.html">Installation Instructions</a>
+&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+<a href="#top">Top of Page</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+<a href="../index.html">User Guide Home</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+Next Topic:&nbsp;&nbsp;<a href="troubleshooting.html">Troubleshooting</a>
+</p>
+<p><a href="http://codeigniter.com">CodeIgniter</a> &nbsp;&middot;&nbsp; Copyright &#169; 2006 - 2011 &nbsp;&middot;&nbsp; <a href="http://ellislab.com/">EllisLab, Inc.</a></p>
+</div>
+
+</body>
+</html>
\ No newline at end of file
diff --git a/user_guide/installation/upgrade_140.html b/user_guide/installation/upgrade_140.html
new file mode 100755 (executable)
index 0000000..2049628
--- /dev/null
@@ -0,0 +1,145 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head>
+
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+<title>CodeIgniter User Guide</title>
+
+<style type='text/css' media='all'>@import url('../userguide.css');</style>
+<link rel='stylesheet' type='text/css' media='all' href='../userguide.css' />
+
+<script type="text/javascript" src="../nav/nav.js"></script>
+<script type="text/javascript" src="../nav/prototype.lite.js"></script>
+<script type="text/javascript" src="../nav/moo.fx.js"></script>
+<script type="text/javascript" src="../nav/user_guide_menu.js"></script>
+
+<meta http-equiv='expires' content='-1' />
+<meta http-equiv= 'pragma' content='no-cache' />
+<meta name='robots' content='all' />
+<meta name='author' content='ExpressionEngine Dev Team' />
+<meta name='description' content='CodeIgniter User Guide' />
+
+</head>
+<body>
+
+<!-- START NAVIGATION -->
+<div id="nav"><div id="nav_inner"><script type="text/javascript">create_menu('../');</script></div></div>
+<div id="nav2"><a name="top"></a><a href="javascript:void(0);" onclick="myHeight.toggle();"><img src="../images/nav_toggle_darker.jpg" width="154" height="43" border="0" title="Toggle Table of Contents" alt="Toggle Table of Contents" /></a></div>
+<div id="masthead">
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td><h1>CodeIgniter User Guide Version 2.0.2</h1></td>
+<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
+</tr>
+</table>
+</div>
+<!-- END NAVIGATION -->
+
+
+<!-- START BREADCRUMB -->
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td id="breadcrumb">
+<a href="http://codeigniter.com/">CodeIgniter Home</a> &nbsp;&#8250;&nbsp;
+<a href="../index.html">User Guide Home</a> &nbsp;&#8250;&nbsp;
+Upgrading from 1.3.3 to 1.4.0
+</td>
+<td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="codeigniter.com/user_guide/" />Search User Guide&nbsp; <input type="text" class="input" style="width:200px;" name="q" id="q" size="31" maxlength="255" value="" />&nbsp;<input type="submit" class="submit" name="sa" value="Go" /></form></td>
+</tr>
+</table>
+<!-- END BREADCRUMB -->
+
+<br clear="all" />
+
+
+<!-- START CONTENT -->
+<div id="content">
+
+<h1>Upgrading from 1.3.3 to 1.4.0</h1>
+
+<p class="important"><strong>Note:</strong> The instructions on this page assume you are running version 1.3.3.  If you
+have not upgraded to that version please do so first.</p>
+
+<p>Before performing an update you should take your site offline by replacing the index.php file with a static one.</p>
+
+
+
+<h2>Step 1: Update your CodeIgniter files</h2>
+
+<p>Replace the following directories in your "system" folder with the new versions:</p>
+
+<p class="important"><strong>Note:</strong> If you have any custom developed files in these folders please make copies of them first.</p>
+
+<ul>
+<li>application/config/<strong>hooks.php</strong></li>
+<li>application/config/<strong>mimes.php</strong></li>
+<li>codeigniter</li>
+<li>drivers</li>
+<li>helpers</li>
+<li>init</li>
+<li>language</li>
+<li>libraries</li>
+<li>scaffolding</li>
+</ul>
+
+
+<h2>Step 2: Update your config.php file</h2>
+
+<p>Open your <dfn>application/config/config.php</dfn> file and add these new items:</p>
+
+<pre>
+
+/*
+|--------------------------------------------------------------------------
+| Enable/Disable System Hooks
+|--------------------------------------------------------------------------
+|
+| If you would like to use the "hooks" feature you must enable it by
+| setting this variable to TRUE (boolean).  See the user guide for details.
+|
+*/
+$config['enable_hooks'] = FALSE;
+
+
+/*
+|--------------------------------------------------------------------------
+| Allowed URL Characters
+|--------------------------------------------------------------------------
+|
+| This lets you specify which characters are permitted within your URLs.
+| When someone tries to submit a URL with disallowed characters they will
+| get a warning message.
+|
+| As a security measure you are STRONGLY encouraged to restrict URLs to
+| as few characters as possible.  By default only these are allowed: a-z 0-9~%.:_-
+|
+| Leave blank to allow all characters -- but only if you are insane.
+|
+| DO NOT CHANGE THIS UNLESS YOU FULLY UNDERSTAND THE REPERCUSSIONS!!
+|
+*/
+$config['permitted_uri_chars'] = 'a-z 0-9~%.:_-';
+</pre>
+
+
+<h2>Step 3: Update your user guide</h2>
+
+<p>Please also replace your local copy of the user guide with the new version.</p>
+
+</div>
+<!-- END CONTENT -->
+
+
+<div id="footer">
+<p>
+Previous Topic:&nbsp;&nbsp;<a href="index.html">Installation Instructions</a>
+&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+<a href="#top">Top of Page</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+<a href="../index.html">User Guide Home</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+Next Topic:&nbsp;&nbsp;<a href="troubleshooting.html">Troubleshooting</a>
+</p>
+<p><a href="http://codeigniter.com">CodeIgniter</a> &nbsp;&middot;&nbsp; Copyright &#169; 2006 - 2011 &nbsp;&middot;&nbsp; <a href="http://ellislab.com/">EllisLab, Inc.</a></p>
+</div>
+
+</body>
+</html>
\ No newline at end of file
diff --git a/user_guide/installation/upgrade_141.html b/user_guide/installation/upgrade_141.html
new file mode 100755 (executable)
index 0000000..c19143c
--- /dev/null
@@ -0,0 +1,148 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head>
+
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+<title>CodeIgniter User Guide</title>
+
+<style type='text/css' media='all'>@import url('../userguide.css');</style>
+<link rel='stylesheet' type='text/css' media='all' href='../userguide.css' />
+
+<script type="text/javascript" src="../nav/nav.js"></script>
+<script type="text/javascript" src="../nav/prototype.lite.js"></script>
+<script type="text/javascript" src="../nav/moo.fx.js"></script>
+<script type="text/javascript" src="../nav/user_guide_menu.js"></script>
+
+<meta http-equiv='expires' content='-1' />
+<meta http-equiv= 'pragma' content='no-cache' />
+<meta name='robots' content='all' />
+<meta name='author' content='ExpressionEngine Dev Team' />
+<meta name='description' content='CodeIgniter User Guide' />
+
+</head>
+<body>
+
+<!-- START NAVIGATION -->
+<div id="nav"><div id="nav_inner"><script type="text/javascript">create_menu('../');</script></div></div>
+<div id="nav2"><a name="top"></a><a href="javascript:void(0);" onclick="myHeight.toggle();"><img src="../images/nav_toggle_darker.jpg" width="154" height="43" border="0" title="Toggle Table of Contents" alt="Toggle Table of Contents" /></a></div>
+<div id="masthead">
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td><h1>CodeIgniter User Guide Version 2.0.2</h1></td>
+<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
+</tr>
+</table>
+</div>
+<!-- END NAVIGATION -->
+
+
+<!-- START BREADCRUMB -->
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td id="breadcrumb">
+<a href="http://codeigniter.com/">CodeIgniter Home</a> &nbsp;&#8250;&nbsp;
+<a href="../index.html">User Guide Home</a> &nbsp;&#8250;&nbsp;
+Upgrading from 1.4.0 to 1.4.1 </td>
+<td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="codeigniter.com/user_guide/" />Search User Guide&nbsp; <input type="text" class="input" style="width:200px;" name="q" id="q" size="31" maxlength="255" value="" />&nbsp;<input type="submit" class="submit" name="sa" value="Go" /></form></td>
+</tr>
+</table>
+<!-- END BREADCRUMB -->
+
+<br clear="all" />
+
+
+<!-- START CONTENT -->
+<div id="content">
+
+<h1>Upgrading from 1.4.0 to 1.4.1</h1>
+
+<p class="important"><strong>Note:</strong> The instructions on this page assume you are running version 1.4.0.  If you
+have not upgraded to that version please do so first.</p>
+
+<p>Before performing an update you should take your site offline by replacing the index.php file with a static one.</p>
+
+
+
+<h2>Step 1: Update your CodeIgniter files</h2>
+
+<p>Replace the following directories in your "system" folder with the new versions:</p>
+
+<p class="important"><strong>Note:</strong> If you have any custom developed files in these folders please make copies of them first.</p>
+
+<ul>
+<li>codeigniter</li>
+<li>drivers</li>
+<li>helpers</li>
+<li>libraries</li>
+</ul>
+
+
+<h2>Step 2: Update your config.php file</h2>
+
+<p>Open your <dfn>application/config/config.php</dfn> file and add this new item:</p>
+
+<pre>
+
+/*
+|--------------------------------------------------------------------------
+| Output Compression
+|--------------------------------------------------------------------------
+|
+| Enables Gzip output compression for faster page loads.  When enabled,
+| the output class will test whether your server supports Gzip.
+| Even if it does, however, not all browsers support compression
+| so enable only if you are reasonably sure your visitors can handle it.
+|
+| VERY IMPORTANT:  If you are getting a blank page when compression is enabled it
+| means you are prematurely outputting something to your browser. It could
+| even be a line of whitespace at the end of one of your scripts.  For
+| compression to work, nothing can be sent before the output buffer is called
+| by the output class.  Do not "echo" any values with compression enabled.
+|
+*/
+$config['compress_output'] = FALSE;
+
+</pre>
+
+
+
+<h2>Step 3: Rename an Autoload Item</h2>
+
+<p>Open the following file: <dfn>application/config/autoload.php</dfn></p>
+
+<p>Find this array item:</p>
+
+<code>$autoload['core'] = array();</code>
+
+<p>And rename it to this:</p>
+
+<code>$autoload['libraries'] = array();</code>
+
+<p>This change was made to improve clarity since some users were not sure that their own libraries could be auto-loaded.</p>
+
+
+
+
+
+
+<h2>Step 4: Update your user guide</h2>
+
+<p>Please also replace your local copy of the user guide with the new version.</p>
+
+</div>
+<!-- END CONTENT -->
+
+
+<div id="footer">
+<p>
+Previous Topic:&nbsp;&nbsp;<a href="index.html">Installation Instructions</a>
+&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+<a href="#top">Top of Page</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+<a href="../index.html">User Guide Home</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+Next Topic:&nbsp;&nbsp;<a href="troubleshooting.html">Troubleshooting</a>
+</p>
+<p><a href="http://codeigniter.com">CodeIgniter</a> &nbsp;&middot;&nbsp; Copyright &#169; 2006 - 2011 &nbsp;&middot;&nbsp; <a href="http://ellislab.com/">EllisLab, Inc.</a></p>
+</div>
+
+</body>
+</html>
\ No newline at end of file
diff --git a/user_guide/installation/upgrade_150.html b/user_guide/installation/upgrade_150.html
new file mode 100755 (executable)
index 0000000..342d486
--- /dev/null
@@ -0,0 +1,178 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head>
+
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+<title>CodeIgniter User Guide</title>
+
+<style type='text/css' media='all'>@import url('../userguide.css');</style>
+<link rel='stylesheet' type='text/css' media='all' href='../userguide.css' />
+
+<script type="text/javascript" src="../nav/nav.js"></script>
+<script type="text/javascript" src="../nav/prototype.lite.js"></script>
+<script type="text/javascript" src="../nav/moo.fx.js"></script>
+<script type="text/javascript" src="../nav/user_guide_menu.js"></script>
+
+<meta http-equiv='expires' content='-1' />
+<meta http-equiv= 'pragma' content='no-cache' />
+<meta name='robots' content='all' />
+<meta name='author' content='ExpressionEngine Dev Team' />
+<meta name='description' content='CodeIgniter User Guide' />
+
+</head>
+<body>
+
+<!-- START NAVIGATION -->
+<div id="nav"><div id="nav_inner"><script type="text/javascript">create_menu('../');</script></div></div>
+<div id="nav2"><a name="top"></a><a href="javascript:void(0);" onclick="myHeight.toggle();"><img src="../images/nav_toggle_darker.jpg" width="154" height="43" border="0" title="Toggle Table of Contents" alt="Toggle Table of Contents" /></a></div>
+<div id="masthead">
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td><h1>CodeIgniter User Guide Version 2.0.2</h1></td>
+<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
+</tr>
+</table>
+</div>
+<!-- END NAVIGATION -->
+
+
+<!-- START BREADCRUMB -->
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td id="breadcrumb">
+<a href="http://codeigniter.com/">CodeIgniter Home</a> &nbsp;&#8250;&nbsp;
+<a href="../index.html">User Guide Home</a> &nbsp;&#8250;&nbsp;
+Upgrading from 1.4.1 to 1.5.0
+</td>
+<td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="codeigniter.com/user_guide/" />Search User Guide&nbsp; <input type="text" class="input" style="width:200px;" name="q" id="q" size="31" maxlength="255" value="" />&nbsp;<input type="submit" class="submit" name="sa" value="Go" /></form></td>
+</tr>
+</table>
+<!-- END BREADCRUMB -->
+
+<br clear="all" />
+
+
+<!-- START CONTENT -->
+<div id="content">
+
+<h1>Upgrading from 1.4.1 to 1.5.0</h1>
+
+<p class="important"><strong>Note:</strong> The instructions on this page assume you are running version 1.4.1.  If you
+have not upgraded to that version please do so first.</p>
+
+<p>Before performing an update you should take your site offline by replacing the index.php file with a static one.</p>
+
+
+
+<h2>Step 1: Update your CodeIgniter files</h2>
+
+<p>Replace these files and directories in your "system" folder with the new versions:</p>
+
+<ul>
+
+<li><dfn>application/config/user_agents.php</dfn> (new file for 1.5)</li>
+<li><dfn>application/config/smileys.php</dfn> (new file for 1.5)</li>
+<li><dfn>codeigniter/</dfn></li>
+<li><dfn>database/</dfn> (new folder for 1.5. Replaces the "drivers" folder)</li>
+<li><dfn>helpers/</dfn></li>
+<li><dfn>language/</dfn></li>
+<li><dfn>libraries/</dfn></li>
+<li><dfn>scaffolding/</dfn></li>
+</ul>
+
+<p class="important"><strong>Note:</strong> If you have any custom developed files in these folders please make copies of them first.</p>
+
+
+<h2>Step 2: Update your database.php file</h2>
+
+<p>Open your <dfn>application/config/database.php</dfn> file and add these new items:</p>
+
+<pre>
+$db['default']['cache_on'] = FALSE;
+$db['default']['cachedir'] = '';
+</pre>
+
+
+
+<h2>Step 3: Update your config.php file</h2>
+
+<p>Open your <dfn>application/config/config.php</dfn> file and <kbd>ADD</kbd> these new items:</p>
+
+<pre>
+/*
+|--------------------------------------------------------------------------
+| Class Extension Prefix
+|--------------------------------------------------------------------------
+|
+| This item allows you to set the filename/classname prefix when extending
+| native libraries.  For more information please see the user guide:
+|
+| http://codeigniter.com/user_guide/general/core_classes.html
+| http://codeigniter.com/user_guide/general/creating_libraries.html
+|
+*/
+$config['subclass_prefix'] = 'MY_';
+
+/*
+|--------------------------------------------------------------------------
+| Rewrite PHP Short Tags
+|--------------------------------------------------------------------------
+|
+| If your PHP installation does not have short tag support enabled CI
+| can rewrite the tags on-the-fly, enabling you to utilize that syntax
+| in your view files.  Options are TRUE or FALSE (boolean)
+|
+*/
+$config['rewrite_short_tags'] = FALSE;
+</pre>
+
+<p>In that same file <kbd>REMOVE</kbd> this item:</p>
+
+
+<pre>
+/*
+|--------------------------------------------------------------------------
+| Enable/Disable Error Logging
+|--------------------------------------------------------------------------
+|
+| If you would like errors or debug messages logged set this variable to
+| TRUE (boolean).  Note: You must set the file permissions on the "logs" folder
+| such that it is writable.
+|
+*/
+$config['log_errors'] = FALSE;
+</pre>
+
+<p>Error logging is now disabled simply by setting the threshold to zero.</p>
+
+
+
+<h2>Step 4: Update your main index.php file</h2>
+
+<p>If you are running a stock <dfn>index.php</dfn> file simply replace your version with the new one.</p>
+
+<p>If your <dfn>index.php</dfn> file has internal modifications, please add your modifications to the new file and use it.</p>
+
+
+
+<h2>Step 5: Update your user guide</h2>
+
+<p>Please also replace your local copy of the user guide with the new version.</p>
+
+</div>
+<!-- END CONTENT -->
+
+
+<div id="footer">
+<p>
+Previous Topic:&nbsp;&nbsp;<a href="index.html">Installation Instructions</a>
+&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+<a href="#top">Top of Page</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+<a href="../index.html">User Guide Home</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+Next Topic:&nbsp;&nbsp;<a href="troubleshooting.html">Troubleshooting</a>
+</p>
+<p><a href="http://codeigniter.com">CodeIgniter</a> &nbsp;&middot;&nbsp; Copyright &#169; 2006 - 2011 &nbsp;&middot;&nbsp; <a href="http://ellislab.com/">EllisLab, Inc.</a></p>
+</div>
+
+</body>
+</html>
\ No newline at end of file
diff --git a/user_guide/installation/upgrade_152.html b/user_guide/installation/upgrade_152.html
new file mode 100755 (executable)
index 0000000..f601a25
--- /dev/null
@@ -0,0 +1,111 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head>
+
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+<title>CodeIgniter User Guide</title>
+
+<style type='text/css' media='all'>@import url('../userguide.css');</style>
+<link rel='stylesheet' type='text/css' media='all' href='../userguide.css' />
+
+<script type="text/javascript" src="../nav/nav.js"></script>
+<script type="text/javascript" src="../nav/prototype.lite.js"></script>
+<script type="text/javascript" src="../nav/moo.fx.js"></script>
+<script type="text/javascript" src="../nav/user_guide_menu.js"></script>
+
+<meta http-equiv='expires' content='-1' />
+<meta http-equiv= 'pragma' content='no-cache' />
+<meta name='robots' content='all' />
+<meta name='author' content='ExpressionEngine Dev Team' />
+<meta name='description' content='CodeIgniter User Guide' />
+
+</head>
+<body>
+
+<!-- START NAVIGATION -->
+<div id="nav"><div id="nav_inner"><script type="text/javascript">create_menu('../');</script></div></div>
+<div id="nav2"><a name="top"></a><a href="javascript:void(0);" onclick="myHeight.toggle();"><img src="../images/nav_toggle_darker.jpg" width="154" height="43" border="0" title="Toggle Table of Contents" alt="Toggle Table of Contents" /></a></div>
+<div id="masthead">
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td><h1>CodeIgniter User Guide Version 2.0.2</h1></td>
+<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
+</tr>
+</table>
+</div>
+<!-- END NAVIGATION -->
+
+
+<!-- START BREADCRUMB -->
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td id="breadcrumb">
+<a href="http://codeigniter.com/">CodeIgniter Home</a> &nbsp;&#8250;&nbsp;
+<a href="../index.html">User Guide Home</a> &nbsp;&#8250;&nbsp;
+Upgrading from 1.5.0 to 1.5.2
+</td>
+<td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="codeigniter.com/user_guide/" />Search User Guide&nbsp; <input type="text" class="input" style="width:200px;" name="q" id="q" size="31" maxlength="255" value="" />&nbsp;<input type="submit" class="submit" name="sa" value="Go" /></form></td>
+</tr>
+</table>
+<!-- END BREADCRUMB -->
+
+<br clear="all" />
+
+
+<!-- START CONTENT -->
+<div id="content">
+
+<h1>Upgrading from 1.5.0 to 1.5.2</h1>
+
+<p class="important"><strong>Note:</strong> The instructions on this page assume you are running version 1.5.0 or 1.5.1.  If you
+have not upgraded to that version please do so first.</p>
+
+<p>Before performing an update you should take your site offline by replacing the index.php file with a static one.</p>
+
+
+
+<h2>Step 1: Update your CodeIgniter files</h2>
+
+<p>Replace these files and directories in your "system" folder with the new versions:</p>
+
+<ul>
+
+<li><dfn>system/helpers/download_helper.php</dfn></li>
+<li><dfn>system/helpers/form_helper.php</dfn></li>
+<li><dfn>system/libraries/Table.php</dfn></li>
+<li><dfn>system/libraries/User_agent.php</dfn></li>
+<li><dfn>system/libraries/Exceptions.php</dfn></li>
+<li><dfn>system/libraries/Input.php</dfn></li>
+<li><dfn>system/libraries/Router.php</dfn></li>
+<li><dfn>system/libraries/Loader.php</dfn></li>
+<li><dfn>system/libraries/Image_lib.php</dfn></li>
+<li><dfn>system/language/english/unit_test_lang.php</dfn></li>
+<li><dfn>system/database/DB_active_rec.php</dfn></li>
+<li><dfn> system/database/drivers/mysqli/mysqli_driver.php</dfn></li>
+<li><dfn>codeigniter/</dfn></li>
+</ul>
+
+<p class="important"><strong>Note:</strong> If you have any custom developed files in these folders please make copies of them first.</p>
+
+
+<h2>Step 2: Update your user guide</h2>
+
+<p>Please also replace your local copy of the user guide with the new version.</p>
+
+</div>
+<!-- END CONTENT -->
+
+
+<div id="footer">
+<p>
+Previous Topic:&nbsp;&nbsp;<a href="index.html">Installation Instructions</a>
+&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+<a href="#top">Top of Page</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+<a href="../index.html">User Guide Home</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+Next Topic:&nbsp;&nbsp;<a href="troubleshooting.html">Troubleshooting</a>
+</p>
+<p><a href="http://codeigniter.com">CodeIgniter</a> &nbsp;&middot;&nbsp; Copyright &#169; 2006 - 2011 &nbsp;&middot;&nbsp; <a href="http://ellislab.com/">EllisLab, Inc.</a></p>
+</div>
+
+</body>
+</html>
\ No newline at end of file
diff --git a/user_guide/installation/upgrade_153.html b/user_guide/installation/upgrade_153.html
new file mode 100755 (executable)
index 0000000..fe6978a
--- /dev/null
@@ -0,0 +1,100 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head>
+
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+<title>CodeIgniter User Guide</title>
+
+<style type='text/css' media='all'>@import url('../userguide.css');</style>
+<link rel='stylesheet' type='text/css' media='all' href='../userguide.css' />
+
+<script type="text/javascript" src="../nav/nav.js"></script>
+<script type="text/javascript" src="../nav/prototype.lite.js"></script>
+<script type="text/javascript" src="../nav/moo.fx.js"></script>
+<script type="text/javascript" src="../nav/user_guide_menu.js"></script>
+
+<meta http-equiv='expires' content='-1' />
+<meta http-equiv= 'pragma' content='no-cache' />
+<meta name='robots' content='all' />
+<meta name='author' content='ExpressionEngine Dev Team' />
+<meta name='description' content='CodeIgniter User Guide' />
+
+</head>
+<body>
+
+<!-- START NAVIGATION -->
+<div id="nav"><div id="nav_inner"><script type="text/javascript">create_menu('../');</script></div></div>
+<div id="nav2"><a name="top"></a><a href="javascript:void(0);" onclick="myHeight.toggle();"><img src="../images/nav_toggle_darker.jpg" width="154" height="43" border="0" title="Toggle Table of Contents" alt="Toggle Table of Contents" /></a></div>
+<div id="masthead">
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td><h1>CodeIgniter User Guide Version 2.0.2</h1></td>
+<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
+</tr>
+</table>
+</div>
+<!-- END NAVIGATION -->
+
+
+<!-- START BREADCRUMB -->
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td id="breadcrumb">
+<a href="http://codeigniter.com/">CodeIgniter Home</a> &nbsp;&#8250;&nbsp;
+<a href="../index.html">User Guide Home</a> &nbsp;&#8250;&nbsp;Upgrading from 1.5.2 to 1.5.3
+</td>
+<td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="codeigniter.com/user_guide/" />Search User Guide&nbsp; <input type="text" class="input" style="width:200px;" name="q" id="q" size="31" maxlength="255" value="" />&nbsp;<input type="submit" class="submit" name="sa" value="Go" /></form></td>
+</tr>
+</table>
+<!-- END BREADCRUMB -->
+
+<br clear="all" />
+
+
+<!-- START CONTENT -->
+<div id="content">
+
+<h1>Upgrading from 1.5.2 to 1.5.3</h1>
+
+<p>Before performing an update you should take your site offline by replacing the index.php file with a static one.</p>
+
+
+
+<h2>Step 1: Update your CodeIgniter files</h2>
+
+<p>Replace these files and directories in your "system" folder with the new versions:</p>
+
+<ul>
+
+<li><dfn>system/database/drivers</dfn></li>
+<li><dfn>system/helpers</dfn></li>
+<li><dfn>system/libraries/Input.php</dfn></li>
+<li><dfn>system/libraries/Loader.php</dfn></li>
+<li><dfn>system/libraries/Profiler.php</dfn></li>
+<li><dfn>system/libraries/Table.php</dfn></li>
+</ul>
+
+<p class="important"><strong>Note:</strong> If you have any custom developed files in these folders please make copies of them first.</p>
+
+
+<h2>Step 2: Update your user guide</h2>
+
+<p>Please also replace your local copy of the user guide with the new version.</p>
+
+</div>
+<!-- END CONTENT -->
+
+
+<div id="footer">
+<p>
+Previous Topic:&nbsp;&nbsp;<a href="index.html">Installation Instructions</a>
+&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+<a href="#top">Top of Page</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+<a href="../index.html">User Guide Home</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+Next Topic:&nbsp;&nbsp;<a href="troubleshooting.html">Troubleshooting</a>
+</p>
+<p><a href="http://codeigniter.com">CodeIgniter</a> &nbsp;&middot;&nbsp; Copyright &#169; 2006 - 2011 &nbsp;&middot;&nbsp; <a href="http://ellislab.com/">EllisLab, Inc.</a></p>
+</div>
+
+</body>
+</html>
\ No newline at end of file
diff --git a/user_guide/installation/upgrade_154.html b/user_guide/installation/upgrade_154.html
new file mode 100755 (executable)
index 0000000..e508681
--- /dev/null
@@ -0,0 +1,116 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head>
+
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+<title>Upgrading from 1.5.3 to 1.5.4 : CodeIgniter User Guide</title>
+
+<style type='text/css' media='all'>@import url('../userguide.css');</style>
+<link rel='stylesheet' type='text/css' media='all' href='../userguide.css' />
+
+<script type="text/javascript" src="../nav/nav.js"></script>
+<script type="text/javascript" src="../nav/prototype.lite.js"></script>
+<script type="text/javascript" src="../nav/moo.fx.js"></script>
+<script type="text/javascript" src="../nav/user_guide_menu.js"></script>
+
+<meta http-equiv='expires' content='-1' />
+<meta http-equiv= 'pragma' content='no-cache' />
+<meta name='robots' content='all' />
+<meta name='author' content='ExpressionEngine Dev Team' />
+<meta name='description' content='CodeIgniter User Guide' />
+
+</head>
+<body>
+
+<!-- START NAVIGATION -->
+<div id="nav"><div id="nav_inner"><script type="text/javascript">create_menu('../');</script></div></div>
+<div id="nav2"><a name="top"></a><a href="javascript:void(0);" onclick="myHeight.toggle();"><img src="../images/nav_toggle_darker.jpg" width="154" height="43" border="0" title="Toggle Table of Contents" alt="Toggle Table of Contents" /></a></div>
+<div id="masthead">
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td><h1>CodeIgniter User Guide Version 2.0.2</h1></td>
+<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
+</tr>
+</table>
+</div>
+<!-- END NAVIGATION -->
+
+
+<!-- START BREADCRUMB -->
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td id="breadcrumb">
+<a href="http://codeigniter.com/">CodeIgniter Home</a> &nbsp;&#8250;&nbsp;
+<a href="../index.html">User Guide Home</a> &nbsp;&#8250;&nbsp;
+Upgrading from 1.5.3 to 1.5.4
+</td>
+<td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="codeigniter.com/user_guide/" />Search User Guide&nbsp; <input type="text" class="input" style="width:200px;" name="q" id="q" size="31" maxlength="255" value="" />&nbsp;<input type="submit" class="submit" name="sa" value="Go" /></form></td>
+</tr>
+</table>
+<!-- END BREADCRUMB -->
+
+<br clear="all" />
+
+
+<!-- START CONTENT -->
+<div id="content">
+
+<h1>Upgrading from 1.5.3 to 1.5.4</h1>
+
+<p>Before performing an update you should take your site offline by replacing the index.php file with a static one.</p>
+
+
+
+<h2>Step 1: Update your CodeIgniter files</h2>
+
+<p>Replace these files and directories in your "system" folder with the new versions:</p>
+
+<ul>
+
+<li><dfn>application/config/mimes.php</dfn></li>
+<li><dfn>system/codeigniter</dfn></li>
+<li><dfn>system/database</dfn></li>
+<li><dfn>system/helpers</dfn></li>
+<li><dfn>system/libraries</dfn></li>
+<li><dfn>system/plugins</dfn></li>
+</ul>
+
+<p class="important"><strong>Note:</strong> If you have any custom developed files in these folders please make copies of them first.</p>
+
+<h2>Step 2: Add charset to your config.php </h2>
+<p>Add the following to application/config/config.php</p>
+<code>/*<br />
+       |--------------------------------------------------------------------------<br />
+       | Default Character Set<br />
+       |--------------------------------------------------------------------------<br />
+       |<br />
+       | This determines which character set is used by default in various methods<br />
+       | that require a character set to be provided.<br />
+       |<br />
+       */<br />
+       $config['charset'] = &quot;UTF-8&quot;;</code>
+
+<h2>Step 3: Autoloading language files </h2>
+<p>If you want to autoload any language files, add this line to application/config/autoload.php</p>
+<code>$autoload['language'] = array();</code>
+
+<h2>Step 4: Update your user guide</h2>
+<p>Please also replace your local copy of the user guide with the new version.</p>
+
+</div>
+<!-- END CONTENT -->
+
+
+<div id="footer">
+<p>
+Previous Topic:&nbsp;&nbsp;<a href="index.html">Installation Instructions</a>
+&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+<a href="#top">Top of Page</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+<a href="../index.html">User Guide Home</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+Next Topic:&nbsp;&nbsp;<a href="troubleshooting.html">Troubleshooting</a>
+</p>
+<p><a href="http://codeigniter.com">CodeIgniter</a> &nbsp;&middot;&nbsp; Copyright &#169; 2006 - 2011 &nbsp;&middot;&nbsp; <a href="http://ellislab.com/">EllisLab, Inc.</a></p>
+</div>
+
+</body>
+</html>
\ No newline at end of file
diff --git a/user_guide/installation/upgrade_160.html b/user_guide/installation/upgrade_160.html
new file mode 100755 (executable)
index 0000000..d06f58e
--- /dev/null
@@ -0,0 +1,125 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head>
+
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+<title>Upgrading from 1.5.4 to 1.6.0 : CodeIgniter User Guide</title>
+
+<style type='text/css' media='all'>@import url('../userguide.css');</style>
+<link rel='stylesheet' type='text/css' media='all' href='../userguide.css' />
+
+<script type="text/javascript" src="../nav/nav.js"></script>
+<script type="text/javascript" src="../nav/prototype.lite.js"></script>
+<script type="text/javascript" src="../nav/moo.fx.js"></script>
+<script type="text/javascript" src="../nav/user_guide_menu.js"></script>
+
+<meta http-equiv='expires' content='-1' />
+<meta http-equiv= 'pragma' content='no-cache' />
+<meta name='robots' content='all' />
+<meta name='author' content='ExpressionEngine Dev Team' />
+<meta name='description' content='CodeIgniter User Guide' />
+
+</head>
+<body>
+
+<!-- START NAVIGATION -->
+<div id="nav"><div id="nav_inner"><script type="text/javascript">create_menu('../');</script></div></div>
+<div id="nav2"><a name="top"></a><a href="javascript:void(0);" onclick="myHeight.toggle();"><img src="../images/nav_toggle_darker.jpg" width="154" height="43" border="0" title="Toggle Table of Contents" alt="Toggle Table of Contents" /></a></div>
+<div id="masthead">
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td><h1>CodeIgniter User Guide Version 2.0.2</h1></td>
+<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
+</tr>
+</table>
+</div>
+<!-- END NAVIGATION -->
+
+
+<!-- START BREADCRUMB -->
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td id="breadcrumb">
+<a href="http://codeigniter.com/">CodeIgniter Home</a> &nbsp;&#8250;&nbsp;
+<a href="../index.html">User Guide Home</a> &nbsp;&#8250;&nbsp;
+Upgrading from 1.5.4 to 1.6.0
+</td>
+<td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="codeigniter.com/user_guide/" />Search User Guide&nbsp; <input type="text" class="input" style="width:200px;" name="q" id="q" size="31" maxlength="255" value="" />&nbsp;<input type="submit" class="submit" name="sa" value="Go" /></form></td>
+</tr>
+</table>
+<!-- END BREADCRUMB -->
+
+<br clear="all" />
+
+
+<!-- START CONTENT -->
+<div id="content">
+
+<h1>Upgrading from 1.5.4 to 1.6.0</h1>
+
+<p>Before performing an update you should take your site offline by replacing the index.php file with a static one.</p>
+
+
+
+<h2>Step 1: Update your CodeIgniter files</h2>
+
+<p>Replace these files and directories in your "system" folder with the new versions:</p>
+
+<ul>
+
+<li><dfn>system/codeigniter</dfn></li>
+<li><dfn>system/database</dfn></li>
+<li><dfn>system/helpers</dfn></li>
+<li><dfn>system/libraries</dfn></li>
+<li><dfn>system/plugins</dfn></li>
+<li><dfn>system/language</dfn></li>
+</ul>
+
+<p class="important"><strong>Note:</strong> If you have any custom developed files in these folders please make copies of them first.</p>
+
+<h2>Step 2: Add time_to_update to your config.php </h2>
+<p>Add the following to application/config/config.php with the other session configuration options</p>
+<p><code>$config['sess_time_to_update']                        = 300;</code></p>
+<h2>Step 3: Add $autoload['model']</h2>
+<p>Add the following to application/config/autoload.php</p>
+<p><code> /*<br />
+       | -------------------------------------------------------------------<br />
+       |  Auto-load Model files<br />
+       | -------------------------------------------------------------------<br />
+       | Prototype:<br />
+       |<br />
+       |  $autoload['model'] = array('my_model');<br />
+       |<br />
+       */<br />
+       <br />
+       $autoload['model'] = array();</code></p>
+<h2>Step 4: Add  to your database.php </h2>
+<p>Make the following changes to your application/config/database.php file:</p>
+<p>Add the following variable above the database configuration options, with <dfn>$active_group</dfn></p>
+<p><code>$active_record = TRUE;</code></p>
+<p>Remove the following from your database configuration options</p>
+<p><code>$db['default']['active_r'] = TRUE;</code></p>
+<p>Add the following to your database configuration options</p>
+<p><code>$db['default']['char_set'] = &quot;utf8&quot;;<br />
+$db['default']['dbcollat'] = &quot;utf8_general_ci&quot;;</code></p>
+
+<h2>Step 5: Update your user guide</h2>
+<p>Please also replace your local copy of the user guide with the new version.</p>
+
+</div>
+<!-- END CONTENT -->
+
+
+<div id="footer">
+<p>
+Previous Topic:&nbsp;&nbsp;<a href="index.html">Installation Instructions</a>
+&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+<a href="#top">Top of Page</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+<a href="../index.html">User Guide Home</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+Next Topic:&nbsp;&nbsp;<a href="troubleshooting.html">Troubleshooting</a>
+</p>
+<p><a href="http://codeigniter.com">CodeIgniter</a> &nbsp;&middot;&nbsp; Copyright &#169; 2006 - 2011 &nbsp;&middot;&nbsp; <a href="http://ellislab.com/">EllisLab, Inc.</a></p>
+</div>
+
+</body>
+</html>
\ No newline at end of file
diff --git a/user_guide/installation/upgrade_161.html b/user_guide/installation/upgrade_161.html
new file mode 100755 (executable)
index 0000000..2dc2de5
--- /dev/null
@@ -0,0 +1,98 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head>
+
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+<title>Upgrading from 1.6.0 to 1.6.1 : CodeIgniter User Guide</title>
+
+<style type='text/css' media='all'>@import url('../userguide.css');</style>
+<link rel='stylesheet' type='text/css' media='all' href='../userguide.css' />
+
+<script type="text/javascript" src="../nav/nav.js"></script>
+<script type="text/javascript" src="../nav/prototype.lite.js"></script>
+<script type="text/javascript" src="../nav/moo.fx.js"></script>
+<script type="text/javascript" src="../nav/user_guide_menu.js"></script>
+
+<meta http-equiv='expires' content='-1' />
+<meta http-equiv= 'pragma' content='no-cache' />
+<meta name='robots' content='all' />
+<meta name='author' content='ExpressionEngine Dev Team' />
+<meta name='description' content='CodeIgniter User Guide' />
+
+</head>
+<body>
+
+<!-- START NAVIGATION -->
+<div id="nav"><div id="nav_inner"><script type="text/javascript">create_menu('../');</script></div></div>
+<div id="nav2"><a name="top"></a><a href="javascript:void(0);" onclick="myHeight.toggle();"><img src="../images/nav_toggle_darker.jpg" width="154" height="43" border="0" title="Toggle Table of Contents" alt="Toggle Table of Contents" /></a></div>
+<div id="masthead">
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td><h1>CodeIgniter User Guide Version 2.0.2</h1></td>
+<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
+</tr>
+</table>
+</div>
+<!-- END NAVIGATION -->
+
+
+<!-- START BREADCRUMB -->
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td id="breadcrumb">
+<a href="http://codeigniter.com/">CodeIgniter Home</a> &nbsp;&#8250;&nbsp;
+<a href="../index.html">User Guide Home</a> &nbsp;&#8250;&nbsp;
+Upgrading from 1.6.0 to 1.6.1
+</td>
+<td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="codeigniter.com/user_guide/" />Search User Guide&nbsp; <input type="text" class="input" style="width:200px;" name="q" id="q" size="31" maxlength="255" value="" />&nbsp;<input type="submit" class="submit" name="sa" value="Go" /></form></td>
+</tr>
+</table>
+<!-- END BREADCRUMB -->
+
+<br clear="all" />
+
+
+<!-- START CONTENT -->
+<div id="content">
+
+<h1>Upgrading from 1.6.0 to 1.6.1</h1>
+
+<p>Before performing an update you should take your site offline by replacing the index.php file with a static one.</p>
+
+
+
+<h2>Step 1: Update your CodeIgniter files</h2>
+
+<p>Replace these files and directories in your "system" folder with the new versions:</p>
+
+<ul>
+
+<li><dfn>system/codeigniter</dfn></li>
+<li><dfn>system/database</dfn></li>
+<li><dfn>system/helpers</dfn></li>
+<li><dfn>system/language</dfn></li>
+<li><dfn>system/libraries</dfn></li>
+</ul>
+
+<p class="important"><strong>Note:</strong> If you have any custom developed files in these folders please make copies of them first.</p>
+
+<h2>Step 2: Update your user guide</h2>
+<p>Please also replace your local copy of the user guide with the new version.</p>
+
+</div>
+<!-- END CONTENT -->
+
+
+<div id="footer">
+<p>
+Previous Topic:&nbsp;&nbsp;<a href="index.html">Installation Instructions</a>
+&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+<a href="#top">Top of Page</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+<a href="../index.html">User Guide Home</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+Next Topic:&nbsp;&nbsp;<a href="troubleshooting.html">Troubleshooting</a>
+</p>
+<p><a href="http://codeigniter.com">CodeIgniter</a> &nbsp;&middot;&nbsp; Copyright &#169; 2006 - 2011 &nbsp;&middot;&nbsp; <a href="http://ellislab.com/">EllisLab, Inc.</a></p>
+</div>
+
+</body>
+</html>
\ No newline at end of file
diff --git a/user_guide/installation/upgrade_162.html b/user_guide/installation/upgrade_162.html
new file mode 100755 (executable)
index 0000000..0add80f
--- /dev/null
@@ -0,0 +1,106 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head>
+
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+<title>Upgrading from 1.6.1 to 1.6.2 : CodeIgniter User Guide</title>
+
+<style type='text/css' media='all'>@import url('../userguide.css');</style>
+<link rel='stylesheet' type='text/css' media='all' href='../userguide.css' />
+
+<script type="text/javascript" src="../nav/nav.js"></script>
+<script type="text/javascript" src="../nav/prototype.lite.js"></script>
+<script type="text/javascript" src="../nav/moo.fx.js"></script>
+<script type="text/javascript" src="../nav/user_guide_menu.js"></script>
+
+<meta http-equiv='expires' content='-1' />
+<meta http-equiv= 'pragma' content='no-cache' />
+<meta name='robots' content='all' />
+<meta name='author' content='ExpressionEngine Dev Team' />
+<meta name='description' content='CodeIgniter User Guide' />
+
+</head>
+<body>
+
+<!-- START NAVIGATION -->
+<div id="nav"><div id="nav_inner"><script type="text/javascript">create_menu('../');</script></div></div>
+<div id="nav2"><a name="top"></a><a href="javascript:void(0);" onclick="myHeight.toggle();"><img src="../images/nav_toggle_darker.jpg" width="154" height="43" border="0" title="Toggle Table of Contents" alt="Toggle Table of Contents" /></a></div>
+<div id="masthead">
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td><h1>CodeIgniter User Guide Version 2.0.2</h1></td>
+<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
+</tr>
+</table>
+</div>
+<!-- END NAVIGATION -->
+
+
+<!-- START BREADCRUMB -->
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td id="breadcrumb">
+<a href="http://codeigniter.com/">CodeIgniter Home</a> &nbsp;&#8250;&nbsp;
+<a href="../index.html">User Guide Home</a> &nbsp;&#8250;&nbsp;
+Upgrading from 1.6.1 to 1.6.2
+</td>
+<td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="codeigniter.com/user_guide/" />Search User Guide&nbsp; <input type="text" class="input" style="width:200px;" name="q" id="q" size="31" maxlength="255" value="" />&nbsp;<input type="submit" class="submit" name="sa" value="Go" /></form></td>
+</tr>
+</table>
+<!-- END BREADCRUMB -->
+
+<br clear="all" />
+
+
+<!-- START CONTENT -->
+<div id="content">
+
+<h1>Upgrading from 1.6.1 to 1.6.2</h1>
+
+<p>Before performing an update you should take your site offline by replacing the index.php file with a static one.</p>
+
+
+
+<h2>Step 1: Update your CodeIgniter files</h2>
+
+<p>Replace these files and directories in your "system" folder with the new versions:</p>
+
+<ul>
+
+<li><dfn>system/codeigniter</dfn></li>
+<li><dfn>system/database</dfn></li>
+<li><dfn>system/helpers</dfn></li>
+<li><dfn>system/language</dfn></li>
+<li><dfn>system/libraries</dfn></li>
+</ul>
+
+<p class="important"><strong>Note:</strong> If you have any custom developed files in these folders please make copies of them first.</p>
+
+
+<h2>Step 2: Encryption Key</h2>
+<p>If you are using sessions, open up application/config/config.php and verify you've set an encryption key.</p>
+
+<h2>Step 3: Constants File</h2>
+<p>Copy /application/config/constants.php to your installation, and modify if necessary.</p>
+<h2>Step 4: Mimes File</h2>
+<p>Replace /application/config/mimes.php with the dowloaded version. If you've added custom mime types, you'll need to re-add them.</p>
+<h2>Step 5: Update your user guide</h2>
+<p>Please also replace your local copy of the user guide with the new version.</p>
+
+</div>
+<!-- END CONTENT -->
+
+
+<div id="footer">
+<p>
+Previous Topic:&nbsp;&nbsp;<a href="index.html">Installation Instructions</a>
+&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+<a href="#top">Top of Page</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+<a href="../index.html">User Guide Home</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+Next Topic:&nbsp;&nbsp;<a href="troubleshooting.html">Troubleshooting</a>
+</p>
+<p><a href="http://codeigniter.com">CodeIgniter</a> &nbsp;&middot;&nbsp; Copyright &#169; 2006 - 2011 &nbsp;&middot;&nbsp; <a href="http://ellislab.com/">EllisLab, Inc.</a></p>
+</div>
+
+</body>
+</html>
\ No newline at end of file
diff --git a/user_guide/installation/upgrade_163.html b/user_guide/installation/upgrade_163.html
new file mode 100755 (executable)
index 0000000..7344139
--- /dev/null
@@ -0,0 +1,99 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head>
+
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+<title>Upgrading from 1.6.2 to 1.6.3 : CodeIgniter User Guide</title>
+
+<style type='text/css' media='all'>@import url('../userguide.css');</style>
+<link rel='stylesheet' type='text/css' media='all' href='../userguide.css' />
+
+<script type="text/javascript" src="../nav/nav.js"></script>
+<script type="text/javascript" src="../nav/prototype.lite.js"></script>
+<script type="text/javascript" src="../nav/moo.fx.js"></script>
+<script type="text/javascript" src="../nav/user_guide_menu.js"></script>
+
+<meta http-equiv='expires' content='-1' />
+<meta http-equiv= 'pragma' content='no-cache' />
+<meta name='robots' content='all' />
+<meta name='author' content='ExpressionEngine Dev Team' />
+<meta name='description' content='CodeIgniter User Guide' />
+
+</head>
+<body>
+
+<!-- START NAVIGATION -->
+<div id="nav"><div id="nav_inner"><script type="text/javascript">create_menu('../');</script></div></div>
+<div id="nav2"><a name="top"></a><a href="javascript:void(0);" onclick="myHeight.toggle();"><img src="../images/nav_toggle_darker.jpg" width="154" height="43" border="0" title="Toggle Table of Contents" alt="Toggle Table of Contents" /></a></div>
+<div id="masthead">
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td><h1>CodeIgniter User Guide Version 2.0.2</h1></td>
+<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
+</tr>
+</table>
+</div>
+<!-- END NAVIGATION -->
+
+
+<!-- START BREADCRUMB -->
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td id="breadcrumb">
+<a href="http://codeigniter.com/">CodeIgniter Home</a> &nbsp;&#8250;&nbsp;
+<a href="../index.html">User Guide Home</a> &nbsp;&#8250;&nbsp;
+Upgrading from 1.6.2 to 1.6.3
+</td>
+<td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="codeigniter.com/user_guide/" />Search User Guide&nbsp; <input type="text" class="input" style="width:200px;" name="q" id="q" size="31" maxlength="255" value="" />&nbsp;<input type="submit" class="submit" name="sa" value="Go" /></form></td>
+</tr>
+</table>
+<!-- END BREADCRUMB -->
+
+<br clear="all" />
+
+
+<!-- START CONTENT -->
+<div id="content">
+
+<h1>Upgrading from 1.6.2 to 1.6.3</h1>
+
+<p>Before performing an update you should take your site offline by replacing the index.php file with a static one.</p>
+
+
+
+<h2>Step 1: Update your CodeIgniter files</h2>
+
+<p>Replace these files and directories in your "system" folder with the new versions:</p>
+
+<ul>
+
+<li><dfn>system/codeigniter</dfn></li>
+<li><dfn>system/database</dfn></li>
+<li><dfn>system/helpers</dfn></li>
+<li><dfn>system/language</dfn></li>
+<li><dfn>system/libraries</dfn></li>
+</ul>
+
+<p class="important"><strong>Note:</strong> If you have any custom developed files in these folders please make copies of them first.</p>
+
+
+<h2>Step 2: Update your user guide</h2>
+<p>Please also replace your local copy of the user guide with the new version.</p>
+
+</div>
+<!-- END CONTENT -->
+
+
+<div id="footer">
+<p>
+Previous Topic:&nbsp;&nbsp;<a href="index.html">Installation Instructions</a>
+&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+<a href="#top">Top of Page</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+<a href="../index.html">User Guide Home</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+Next Topic:&nbsp;&nbsp;<a href="troubleshooting.html">Troubleshooting</a>
+</p>
+<p><a href="http://codeigniter.com">CodeIgniter</a> &nbsp;&middot;&nbsp; Copyright &#169; 2006 - 2011 &nbsp;&middot;&nbsp; <a href="http://ellislab.com/">EllisLab, Inc.</a></p>
+</div>
+
+</body>
+</html>
\ No newline at end of file
diff --git a/user_guide/installation/upgrade_170.html b/user_guide/installation/upgrade_170.html
new file mode 100755 (executable)
index 0000000..01597a4
--- /dev/null
@@ -0,0 +1,121 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head>
+
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+<title>Upgrading from 1.6.3 to 1.7.0 : CodeIgniter User Guide</title>
+
+<style type='text/css' media='all'>@import url('../userguide.css');</style>
+<link rel='stylesheet' type='text/css' media='all' href='../userguide.css' />
+
+<script type="text/javascript" src="../nav/nav.js"></script>
+<script type="text/javascript" src="../nav/prototype.lite.js"></script>
+<script type="text/javascript" src="../nav/moo.fx.js"></script>
+<script type="text/javascript" src="../nav/user_guide_menu.js"></script>
+
+<meta http-equiv='expires' content='-1' />
+<meta http-equiv= 'pragma' content='no-cache' />
+<meta name='robots' content='all' />
+<meta name='author' content='ExpressionEngine Dev Team' />
+<meta name='description' content='CodeIgniter User Guide' />
+
+</head>
+<body>
+
+<!-- START NAVIGATION -->
+<div id="nav"><div id="nav_inner"><script type="text/javascript">create_menu('../');</script></div></div>
+<div id="nav2"><a name="top"></a><a href="javascript:void(0);" onclick="myHeight.toggle();"><img src="../images/nav_toggle_darker.jpg" width="154" height="43" border="0" title="Toggle Table of Contents" alt="Toggle Table of Contents" /></a></div>
+<div id="masthead">
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td><h1>CodeIgniter User Guide Version 2.0.2</h1></td>
+<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
+</tr>
+</table>
+</div>
+<!-- END NAVIGATION -->
+
+
+<!-- START BREADCRUMB -->
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td id="breadcrumb">
+<a href="http://codeigniter.com/">CodeIgniter Home</a> &nbsp;&#8250;&nbsp;
+<a href="../index.html">User Guide Home</a> &nbsp;&#8250;&nbsp;
+Upgrading from 1.6.3 to 1.7.0
+</td>
+<td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="codeigniter.com/user_guide/" />Search User Guide&nbsp; <input type="text" class="input" style="width:200px;" name="q" id="q" size="31" maxlength="255" value="" />&nbsp;<input type="submit" class="submit" name="sa" value="Go" /></form></td>
+</tr>
+</table>
+<!-- END BREADCRUMB -->
+
+<br clear="all" />
+
+
+<!-- START CONTENT -->
+<div id="content">
+
+<h1>Upgrading from 1.6.3 to 1.7.0</h1>
+
+<p>Before performing an update you should take your site offline by replacing the index.php file with a static one.</p>
+
+
+
+<h2>Step 1: Update your CodeIgniter files</h2>
+
+<p>Replace these files and directories in your "system" folder with the new versions:</p>
+
+<ul>
+
+<li><dfn>system/codeigniter</dfn></li>
+<li><dfn>system/database</dfn></li>
+<li><dfn>system/helpers</dfn></li>
+<li><dfn>system/language</dfn></li>
+<li><dfn>system/libraries</dfn></li>
+</ul>
+
+<p class="important"><strong>Note:</strong> If you have any custom developed files in these folders please make copies of them first.</p>
+
+
+<h2>Step 2: Update your Session Table</h2>
+
+<p>If you are using the Session class in your application, AND if you are storing session data to a database, you must add a new column named <dfn>user_data</dfn> to your session table.
+Here is an example of what this column might look like for MySQL:</p>
+
+<code>user_data text NOT NULL</code>
+
+<p>To add this column you will run a query similar to this:</p>
+
+<code>ALTER TABLE `ci_sessions` ADD `user_data` text NOT NULL</code>
+
+<p>You'll find more information regarding the new Session functionality in the  <a href="../libraries/sessions.html">Session class</a> page.</p>
+
+
+<h2>Step 3: Update your Validation Syntax</h2>
+
+<p>This is an <strong>optional</strong>, but recommended step, for people currently using the Validation class.  CI 1.7 introduces a new  <a href="../libraries/form_validation.html">Form Validation class</a>, which
+deprecates the old Validation library.  We have left the old one in place so that existing applications that use it will not break, but you are encouraged to
+migrate to the new version as soon as possible.  Please read the user guide carefully as the new library works a little differently, and has several new features.</p>
+
+
+
+<h2>Step 4: Update your user guide</h2>
+<p>Please replace your local copy of the user guide with the new version, including the image files.</p>
+
+</div>
+<!-- END CONTENT -->
+
+
+<div id="footer">
+<p>
+Previous Topic:&nbsp;&nbsp;<a href="index.html">Installation Instructions</a>
+&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+<a href="#top">Top of Page</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+<a href="../index.html">User Guide Home</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+Next Topic:&nbsp;&nbsp;<a href="troubleshooting.html">Troubleshooting</a>
+</p>
+<p><a href="http://codeigniter.com">CodeIgniter</a> &nbsp;&middot;&nbsp; Copyright &#169; 2006 - 2011 &nbsp;&middot;&nbsp; <a href="http://ellislab.com/">EllisLab, Inc.</a></p>
+</div>
+
+</body>
+</html>
\ No newline at end of file
diff --git a/user_guide/installation/upgrade_171.html b/user_guide/installation/upgrade_171.html
new file mode 100755 (executable)
index 0000000..baee208
--- /dev/null
@@ -0,0 +1,98 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head>
+
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+<title>Upgrading from 1.7.0 to 1.7.1 : CodeIgniter User Guide</title>
+
+<style type='text/css' media='all'>@import url('../userguide.css');</style>
+<link rel='stylesheet' type='text/css' media='all' href='../userguide.css' />
+
+<script type="text/javascript" src="../nav/nav.js"></script>
+<script type="text/javascript" src="../nav/prototype.lite.js"></script>
+<script type="text/javascript" src="../nav/moo.fx.js"></script>
+<script type="text/javascript" src="../nav/user_guide_menu.js"></script>
+
+<meta http-equiv='expires' content='-1' />
+<meta http-equiv= 'pragma' content='no-cache' />
+<meta name='robots' content='all' />
+<meta name='author' content='ExpressionEngine Dev Team' />
+<meta name='description' content='CodeIgniter User Guide' />
+
+</head>
+<body>
+
+<!-- START NAVIGATION -->
+<div id="nav"><div id="nav_inner"><script type="text/javascript">create_menu('../');</script></div></div>
+<div id="nav2"><a name="top"></a><a href="javascript:void(0);" onclick="myHeight.toggle();"><img src="../images/nav_toggle_darker.jpg" width="154" height="43" border="0" title="Toggle Table of Contents" alt="Toggle Table of Contents" /></a></div>
+<div id="masthead">
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td><h1>CodeIgniter User Guide Version 2.0.2</h1></td>
+<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
+</tr>
+</table>
+</div>
+<!-- END NAVIGATION -->
+
+
+<!-- START BREADCRUMB -->
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td id="breadcrumb">
+<a href="http://codeigniter.com/">CodeIgniter Home</a> &nbsp;&#8250;&nbsp;
+<a href="../index.html">User Guide Home</a> &nbsp;&#8250;&nbsp;
+Upgrading from 1.7.0 to 1.7.1
+</td>
+<td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="codeigniter.com/user_guide/" />Search User Guide&nbsp; <input type="text" class="input" style="width:200px;" name="q" id="q" size="31" maxlength="255" value="" />&nbsp;<input type="submit" class="submit" name="sa" value="Go" /></form></td>
+</tr>
+</table>
+<!-- END BREADCRUMB -->
+
+<br clear="all" />
+
+
+<!-- START CONTENT -->
+<div id="content">
+
+<h1>Upgrading from 1.7.0 to 1.7.1</h1>
+
+<p>Before performing an update you should take your site offline by replacing the index.php file with a static one.</p>
+
+
+
+<h2>Step 1: Update your CodeIgniter files</h2>
+
+<p>Replace these files and directories in your "system" folder with the new versions:</p>
+
+<ul>
+
+<li><dfn>system/codeigniter</dfn></li>
+<li><dfn>system/database</dfn></li>
+<li><dfn>system/helpers</dfn></li>
+<li><dfn>system/language</dfn></li>
+<li><dfn>system/libraries</dfn></li>
+</ul>
+
+<p class="important"><strong>Note:</strong> If you have any custom developed files in these folders please make copies of them first.</p>
+
+<h2>Step 2: Update your user guide</h2>
+<p>Please replace your local copy of the user guide with the new version, including the image files.</p>
+
+</div>
+<!-- END CONTENT -->
+
+
+<div id="footer">
+<p>
+Previous Topic:&nbsp;&nbsp;<a href="index.html">Installation Instructions</a>
+&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+<a href="#top">Top of Page</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+<a href="../index.html">User Guide Home</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+Next Topic:&nbsp;&nbsp;<a href="troubleshooting.html">Troubleshooting</a>
+</p>
+<p><a href="http://codeigniter.com">CodeIgniter</a> &nbsp;&middot;&nbsp; Copyright &#169; 2006 - 2011 &nbsp;&middot;&nbsp; <a href="http://ellislab.com/">EllisLab, Inc.</a></p>
+</div>
+
+</body>
+</html>
\ No newline at end of file
diff --git a/user_guide/installation/upgrade_172.html b/user_guide/installation/upgrade_172.html
new file mode 100755 (executable)
index 0000000..dbf0fb0
--- /dev/null
@@ -0,0 +1,109 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head>
+
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+<title>Upgrading from 1.7.1 to 1.7.2 : CodeIgniter User Guide</title>
+
+<style type='text/css' media='all'>@import url('../userguide.css');</style>
+<link rel='stylesheet' type='text/css' media='all' href='../userguide.css' />
+
+<script type="text/javascript" src="../nav/nav.js"></script>
+<script type="text/javascript" src="../nav/prototype.lite.js"></script>
+<script type="text/javascript" src="../nav/moo.fx.js"></script>
+<script type="text/javascript" src="../nav/user_guide_menu.js"></script>
+
+<meta http-equiv='expires' content='-1' />
+<meta http-equiv= 'pragma' content='no-cache' />
+<meta name='robots' content='all' />
+<meta name='author' content='ExpressionEngine Dev Team' />
+<meta name='description' content='CodeIgniter User Guide' />
+
+</head>
+<body>
+
+<!-- START NAVIGATION -->
+<div id="nav"><div id="nav_inner"><script type="text/javascript">create_menu('../');</script></div></div>
+<div id="nav2"><a name="top"></a><a href="javascript:void(0);" onclick="myHeight.toggle();"><img src="../images/nav_toggle_darker.jpg" width="154" height="43" border="0" title="Toggle Table of Contents" alt="Toggle Table of Contents" /></a></div>
+<div id="masthead">
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td><h1>CodeIgniter User Guide Version 2.0.2</h1></td>
+<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
+</tr>
+</table>
+</div>
+<!-- END NAVIGATION -->
+
+
+<!-- START BREADCRUMB -->
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td id="breadcrumb">
+<a href="http://codeigniter.com/">CodeIgniter Home</a> &nbsp;&#8250;&nbsp;
+<a href="../index.html">User Guide Home</a> &nbsp;&#8250;&nbsp;
+Upgrading from 1.7.1 to 1.7.2
+</td>
+<td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="codeigniter.com/user_guide/" />Search User Guide&nbsp; <input type="text" class="input" style="width:200px;" name="q" id="q" size="31" maxlength="255" value="" />&nbsp;<input type="submit" class="submit" name="sa" value="Go" /></form></td>
+</tr>
+</table>
+<!-- END BREADCRUMB -->
+
+<br clear="all" />
+
+
+<!-- START CONTENT -->
+<div id="content">
+
+<h1>Upgrading from 1.7.1 to 1.7.2</h1>
+
+<p>Before performing an update you should take your site offline by replacing the index.php file with a static one.</p>
+
+
+
+<h2>Step 1: Update your CodeIgniter files</h2>
+
+<p>Replace these files and directories in your "system" folder with the new versions:</p>
+
+<ul>
+
+<li><dfn>system/codeigniter</dfn></li>
+<li><dfn>system/database</dfn></li>
+<li><dfn>system/helpers</dfn></li>
+<li><dfn>system/language</dfn></li>
+<li><dfn>system/libraries</dfn></li>
+<li><dfn>index.php</dfn></li>
+</ul>
+
+<p class="important"><strong>Note:</strong> If you have any custom developed files in these folders please make copies of them first.</p>
+
+<h2>Step 2: Remove header() from 404 error template</h2>
+<p>If you are using header() in your 404 error template, such as the case with the default <samp>error_404.php</samp> template shown below, remove that line of code.</p>
+
+<code>&lt;?php header(&quot;HTTP/1.1 404 Not Found&quot;); ?&gt;</code>
+
+<p>404 status headers are now properly handled in the show_404() method itself.</p>
+
+<h2>Step 3: Confirm your system_path</h2>
+<p>In your updated index.php file, confirm that the <dfn>$system_path</dfn> variable is set to your application's system folder.</p>
+
+<h2>Step 4: Update your user guide</h2>
+<p>Please replace your local copy of the user guide with the new version, including the image files.</p>
+
+</div>
+<!-- END CONTENT -->
+
+
+<div id="footer">
+<p>
+Previous Topic:&nbsp;&nbsp;<a href="index.html">Installation Instructions</a>
+&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+<a href="#top">Top of Page</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+<a href="../index.html">User Guide Home</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+Next Topic:&nbsp;&nbsp;<a href="troubleshooting.html">Troubleshooting</a>
+</p>
+<p><a href="http://codeigniter.com">CodeIgniter</a> &nbsp;&middot;&nbsp; Copyright &#169; 2006 - 2011 &nbsp;&middot;&nbsp; <a href="http://ellislab.com/">EllisLab, Inc.</a></p>
+</div>
+
+</body>
+</html>
\ No newline at end of file
diff --git a/user_guide/installation/upgrade_200.html b/user_guide/installation/upgrade_200.html
new file mode 100755 (executable)
index 0000000..0b24079
--- /dev/null
@@ -0,0 +1,131 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head>
+
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+<title>Upgrading from 1.7.2 to 2.0.0 : CodeIgniter User Guide</title>
+
+<style type='text/css' media='all'>@import url('../userguide.css');</style>
+<link rel='stylesheet' type='text/css' media='all' href='../userguide.css' />
+
+<script type="text/javascript" src="../nav/nav.js"></script>
+<script type="text/javascript" src="../nav/prototype.lite.js"></script>
+<script type="text/javascript" src="../nav/moo.fx.js"></script>
+<script type="text/javascript" src="../nav/user_guide_menu.js"></script>
+
+<meta http-equiv='expires' content='-1' />
+<meta http-equiv= 'pragma' content='no-cache' />
+<meta name='robots' content='all' />
+<meta name='author' content='ExpressionEngine Dev Team' />
+<meta name='description' content='CodeIgniter User Guide' />
+
+</head>
+<body>
+
+<!-- START NAVIGATION -->
+<div id="nav"><div id="nav_inner"><script type="text/javascript">create_menu('../');</script></div></div>
+<div id="nav2"><a name="top"></a><a href="javascript:void(0);" onclick="myHeight.toggle();"><img src="../images/nav_toggle_darker.jpg" width="154" height="43" border="0" title="Toggle Table of Contents" alt="Toggle Table of Contents" /></a></div>
+<div id="masthead">
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td><h1>CodeIgniter User Guide Version 2.0.2</h1></td>
+<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
+</tr>
+</table>
+</div>
+<!-- END NAVIGATION -->
+
+
+<!-- START BREADCRUMB -->
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td id="breadcrumb">
+<a href="http://codeigniter.com/">CodeIgniter Home</a> &nbsp;&#8250;&nbsp;
+<a href="../index.html">User Guide Home</a> &nbsp;&#8250;&nbsp;
+Upgrading from 1.7.2 to 2.0.0
+</td>
+<td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="codeigniter.com/user_guide/" />Search User Guide&nbsp; <input type="text" class="input" style="width:200px;" name="q" id="q" size="31" maxlength="255" value="" />&nbsp;<input type="submit" class="submit" name="sa" value="Go" /></form></td>
+</tr>
+</table>
+<!-- END BREADCRUMB -->
+
+<br clear="all" />
+
+
+<!-- START CONTENT -->
+<div id="content">
+
+<h1>Upgrading from 1.7.2 to 2.0.0</h1>
+
+<p>Before performing an update you should take your site offline by replacing the index.php file with a static one.</p>
+
+
+
+<h2>Step 1: Update your CodeIgniter files</h2>
+
+<p>Replace all files and directories in your "system" folder <strong>except</strong> your <kbd>application</kbd> folder.</p>
+
+<p class="important"><strong>Note:</strong> If you have any custom developed files in these folders please make copies of them first.</p>
+
+<h2>Step 2: Adjust get_dir_file_info() where necessary</h2>
+
+<p>Version 2.0.0 brings a non-backwards compatible change to <kbd>get_dir_file_info()</kbd> in the <a href="../helpers/file_helper.html">File Helper</a>.  Non-backwards compatible changes are extremely rare
+       in CodeIgniter, but this one we feel was warranted due to how easy it was to create serious server performance issues.  If you <em>need</em>
+       recursiveness where you are using this helper function, change such instances, setting the second parameter, <kbd>$top_level_only</kbd> to FALSE:</p>
+
+<code>get_dir_file_info('/path/to/directory', <kbd>FALSE</kbd>);</code>
+
+</p>
+
+<h2>Step 3: Convert your Plugins to Helpers</h2>
+
+<p>2.0.0 gets rid of the "Plugin" system as their functionality was identical to Helpers, but non-extensible.  You will need to rename your plugin files from <var>filename_pi.php</var> to <var>filename_helper.php</var>, move them to your <kbd>helpers</kbd> folder, and change all instances of:
+
+       <code>$this->load->plugin('foo');</code>
+
+to
+
+       <code>$this->load->helper('foo');</code>
+
+</p>
+
+<h2>Step 4: Update stored encrypted data</h2>
+
+<p class="important"><strong>Note:</strong> If your application does not use the Encryption library, does not store Encrypted data permanently, or is on an environment that does not support Mcrypt, you may skip this step.</p>
+
+<p>The Encryption library has had a number of improvements, some for encryption strength and some for performance, that has an unavoidable consequence of
+       making it no longer possible to decode encrypted data produced by the original version of this library.  To help with the transition, a new method has
+       been added, <kbd>encode_from_legacy()</kbd> that will decode the data with the original algorithm and return a re-encoded string using the improved methods.
+       This will enable you to easily replace stale encrypted data with fresh in your applications, either on the fly or en masse.</p>
+
+<p>Please read <a href="../libraries/encryption.html#legacy">how to use this method</a> in the Encryption library documentation.</p>
+
+<h2>Step 5: Remove loading calls for the compatibility helper.</h2>
+<p>The compatibility helper has been removed from the CodeIgniter core. All methods in it should be natively available in supported PHP versions.</p>
+
+<h2>Step 6: Update Class extension</h2>
+<p>All core classes are now prefixed with <kbd>CI_</kbd>.  Update Models and Controllers to extend CI_Model and CI_Controller, respectively.</p> 
+
+<h2>Step 7: Update Parent Constructor calls</h2>
+<p>All native CodeIgniter classes now use the PHP 5 <kbd>__construct()</kbd> convention. Please update extended libraries to call <kbd>parent::__construct()</kbd>.</p>
+
+<h2>Step 8: Update your user guide</h2>
+<p>Please replace your local copy of the user guide with the new version, including the image files.</p>
+
+</div>
+<!-- END CONTENT -->
+
+
+<div id="footer">
+<p>
+Previous Topic:&nbsp;&nbsp;<a href="index.html">Installation Instructions</a>
+&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+<a href="#top">Top of Page</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+<a href="../index.html">User Guide Home</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+Next Topic:&nbsp;&nbsp;<a href="troubleshooting.html">Troubleshooting</a>
+</p>
+<p><a href="http://codeigniter.com">CodeIgniter</a> &nbsp;&middot;&nbsp; Copyright &#169; 2006 - 2011 &nbsp;&middot;&nbsp; <a href="http://ellislab.com/">EllisLab, Inc.</a></p>
+</div>
+
+</body>
+</html>
\ No newline at end of file
diff --git a/user_guide/installation/upgrade_201.html b/user_guide/installation/upgrade_201.html
new file mode 100755 (executable)
index 0000000..fe99cc0
--- /dev/null
@@ -0,0 +1,105 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head>
+
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+<title>Upgrading from 2.0.0 to 2.0.1 : CodeIgniter User Guide</title>
+
+<style type='text/css' media='all'>@import url('../userguide.css');</style>
+<link rel='stylesheet' type='text/css' media='all' href='../userguide.css' />
+
+<script type="text/javascript" src="../nav/nav.js"></script>
+<script type="text/javascript" src="../nav/prototype.lite.js"></script>
+<script type="text/javascript" src="../nav/moo.fx.js"></script>
+<script type="text/javascript" src="../nav/user_guide_menu.js"></script>
+
+<meta http-equiv='expires' content='-1' />
+<meta http-equiv= 'pragma' content='no-cache' />
+<meta name='robots' content='all' />
+<meta name='author' content='ExpressionEngine Dev Team' />
+<meta name='description' content='CodeIgniter User Guide' />
+
+</head>
+<body>
+
+<!-- START NAVIGATION -->
+<div id="nav"><div id="nav_inner"><script type="text/javascript">create_menu('../');</script></div></div>
+<div id="nav2"><a name="top"></a><a href="javascript:void(0);" onclick="myHeight.toggle();"><img src="../images/nav_toggle_darker.jpg" width="154" height="43" border="0" title="Toggle Table of Contents" alt="Toggle Table of Contents" /></a></div>
+<div id="masthead">
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td><h1>CodeIgniter User Guide Version 2.0.2</h1></td>
+<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
+</tr>
+</table>
+</div>
+<!-- END NAVIGATION -->
+
+
+<!-- START BREADCRUMB -->
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td id="breadcrumb">
+<a href="http://codeigniter.com/">CodeIgniter Home</a> &nbsp;&#8250;&nbsp;
+<a href="../index.html">User Guide Home</a> &nbsp;&#8250;&nbsp;
+Upgrading from 2.0.0 to 2.0.1
+</td>
+<td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="codeigniter.com/user_guide/" />Search User Guide&nbsp; <input type="text" class="input" style="width:200px;" name="q" id="q" size="31" maxlength="255" value="" />&nbsp;<input type="submit" class="submit" name="sa" value="Go" /></form></td>
+</tr>
+</table>
+<!-- END BREADCRUMB -->
+
+<br clear="all" />
+
+
+<!-- START CONTENT -->
+<div id="content">
+
+<h1>Upgrading from 2.0.0 to 2.0.1</h1>
+
+<p>Before performing an update you should take your site offline by replacing the index.php file with a static one.</p>
+
+
+<h2>Step 1: Update your CodeIgniter files</h2>
+
+<p>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.</p>
+
+<p class="important"><strong>Note:</strong> If you have any custom developed files in these folders please make copies of them first.</p>
+
+
+<h2>Step 2: Replace config/mimes.php</h2>
+
+<p>This config file has been updated to contain more mime types, please copy it to <kbd>application/config/mimes.php</kbd>.</p>
+
+
+<h2>Step 3: Check for forms posting to default controller</h2>
+
+<p>
+       The default behavior for <kbd>form_open()</kbd> 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:
+</p>
+
+<code>echo form_open(); //&lt;form action="" method="post" accept-charset="utf-8"></code>
+
+<p>to use either a / or <kbd>base_url()</kbd>:</p>
+
+<code>echo form_open('/'); //&lt;form action="http://example.com/index.php/" method="post" accept-charset="utf-8"><br/>
+echo form_open(base_url()); //&lt;form action="http://example.com/" method="post" accept-charset="utf-8"></code>
+
+</div>
+<!-- END CONTENT -->
+
+
+<div id="footer">
+<p>
+Previous Topic:&nbsp;&nbsp;<a href="index.html">Installation Instructions</a>
+&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+<a href="#top">Top of Page</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+<a href="../index.html">User Guide Home</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+Next Topic:&nbsp;&nbsp;<a href="troubleshooting.html">Troubleshooting</a>
+</p>
+<p><a href="http://codeigniter.com">CodeIgniter</a> &nbsp;&middot;&nbsp; Copyright &#169; 2006 - 2011 &nbsp;&middot;&nbsp; <a href="http://ellislab.com/">EllisLab, Inc.</a></p>
+</div>
+
+</body>
+</html>
\ 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 100755 (executable)
index 0000000..e6273f5
--- /dev/null
@@ -0,0 +1,95 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head>
+
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+<title>Upgrading from 2.0.1 to 2.0.2 : CodeIgniter User Guide</title>
+
+<style type='text/css' media='all'>@import url('../userguide.css');</style>
+<link rel='stylesheet' type='text/css' media='all' href='../userguide.css' />
+
+<script type="text/javascript" src="../nav/nav.js"></script>
+<script type="text/javascript" src="../nav/prototype.lite.js"></script>
+<script type="text/javascript" src="../nav/moo.fx.js"></script>
+<script type="text/javascript" src="../nav/user_guide_menu.js"></script>
+
+<meta http-equiv='expires' content='-1' />
+<meta http-equiv= 'pragma' content='no-cache' />
+<meta name='robots' content='all' />
+<meta name='author' content='ExpressionEngine Dev Team' />
+<meta name='description' content='CodeIgniter User Guide' />
+
+</head>
+<body>
+
+<!-- START NAVIGATION -->
+<div id="nav"><div id="nav_inner"><script type="text/javascript">create_menu('../');</script></div></div>
+<div id="nav2"><a name="top"></a><a href="javascript:void(0);" onclick="myHeight.toggle();"><img src="../images/nav_toggle_darker.jpg" width="154" height="43" border="0" title="Toggle Table of Contents" alt="Toggle Table of Contents" /></a></div>
+<div id="masthead">
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td><h1>CodeIgniter User Guide Version 2.0.2</h1></td>
+<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
+</tr>
+</table>
+</div>
+<!-- END NAVIGATION -->
+
+
+<!-- START BREADCRUMB -->
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td id="breadcrumb">
+<a href="http://codeigniter.com/">CodeIgniter Home</a> &nbsp;&#8250;&nbsp;
+<a href="../index.html">User Guide Home</a> &nbsp;&#8250;&nbsp;
+Upgrading from 2.0.1 to 2.0.2
+</td>
+<td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="codeigniter.com/user_guide/" />Search User Guide&nbsp; <input type="text" class="input" style="width:200px;" name="q" id="q" size="31" maxlength="255" value="" />&nbsp;<input type="submit" class="submit" name="sa" value="Go" /></form></td>
+</tr>
+</table>
+<!-- END BREADCRUMB -->
+
+<br clear="all" />
+
+
+<!-- START CONTENT -->
+<div id="content">
+
+<h1>Upgrading from 2.0.1 to 2.0.2</h1>
+
+<p>Before performing an update you should take your site offline by replacing the index.php file with a static one.</p>
+
+
+<h2>Step 1: Update your CodeIgniter files</h2>
+
+<p>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.</p>
+
+<p class="important"><strong>Note:</strong> If you have any custom developed files in these folders please make copies of them first.</p>
+
+
+<h2>Step 2: Remove loading calls for the Security Library</h2>
+
+<p>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.</p>
+
+
+<h2>Step 3: Move MY_Security</h2>
+
+<p>If you are overriding or extending the Security library, you will need to move it to <kbd>application/core</kbd>.</p>
+
+</div>
+<!-- END CONTENT -->
+
+
+<div id="footer">
+<p>
+Previous Topic:&nbsp;&nbsp;<a href="index.html">Installation Instructions</a>
+&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+<a href="#top">Top of Page</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+<a href="../index.html">User Guide Home</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+Next Topic:&nbsp;&nbsp;<a href="troubleshooting.html">Troubleshooting</a>
+</p>
+<p><a href="http://codeigniter.com">CodeIgniter</a> &nbsp;&middot;&nbsp; Copyright &#169; 2006 - 2011 &nbsp;&middot;&nbsp; <a href="http://ellislab.com/">EllisLab, Inc.</a></p>
+</div>
+
+</body>
+</html>
\ No newline at end of file
diff --git a/user_guide/installation/upgrade_b11.html b/user_guide/installation/upgrade_b11.html
new file mode 100755 (executable)
index 0000000..add7228
--- /dev/null
@@ -0,0 +1,144 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head>
+
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+<title>CodeIgniter User Guide</title>
+
+<style type='text/css' media='all'>@import url('../userguide.css');</style>
+<link rel='stylesheet' type='text/css' media='all' href='../userguide.css' />
+
+<script type="text/javascript" src="../nav/nav.js"></script>
+<script type="text/javascript" src="../nav/prototype.lite.js"></script>
+<script type="text/javascript" src="../nav/moo.fx.js"></script>
+<script type="text/javascript" src="../nav/user_guide_menu.js"></script>
+
+<meta http-equiv='expires' content='-1' />
+<meta http-equiv= 'pragma' content='no-cache' />
+<meta name='robots' content='all' />
+<meta name='author' content='ExpressionEngine Dev Team' />
+<meta name='description' content='CodeIgniter User Guide' />
+
+</head>
+<body>
+
+<!-- START NAVIGATION -->
+<div id="nav"><div id="nav_inner"><script type="text/javascript">create_menu('../');</script></div></div>
+<div id="nav2"><a name="top"></a><a href="javascript:void(0);" onclick="myHeight.toggle();"><img src="../images/nav_toggle_darker.jpg" width="154" height="43" border="0" title="Toggle Table of Contents" alt="Toggle Table of Contents" /></a></div>
+<div id="masthead">
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td><h1>CodeIgniter User Guide Version 2.0.2</h1></td>
+<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
+</tr>
+</table>
+</div>
+<!-- END NAVIGATION -->
+
+
+<!-- START BREADCRUMB -->
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td id="breadcrumb">
+<a href="http://codeigniter.com/">CodeIgniter Home</a> &nbsp;&#8250;&nbsp;
+<a href="../index.html">User Guide Home</a> &nbsp;&#8250;&nbsp;
+Upgrading from Beta 1.0 to Beta 1.1
+</td>
+<td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="codeigniter.com/user_guide/" />Search User Guide&nbsp; <input type="text" class="input" style="width:200px;" name="q" id="q" size="31" maxlength="255" value="" />&nbsp;<input type="submit" class="submit" name="sa" value="Go" /></form></td>
+</tr>
+</table>
+<!-- END BREADCRUMB -->
+
+<br clear="all" />
+
+
+<!-- START CONTENT -->
+<div id="content">
+
+<h1>Upgrading From Beta 1.0 to Beta 1.1</h1>
+
+<p>To upgrade to Beta 1.1 please perform the following steps:</p>
+
+<h2>Step 1: Replace your index file</h2>
+
+<p>Replace your main <kbd>index.php</kbd> file with the new index.php file. Note:  If you have renamed your "system" folder you will need to edit this info in the new file.</p>
+
+<h2>Step 2: Relocate your config folder</h2>
+
+<p>This version of CodeIgniter now permits multiple sets of "applications" to all share a common set of backend files. In order to enable
+each application to have its own configuration values, the <kbd>config</kbd> directory must now reside
+inside of your <dfn>application</dfn> folder, so please move it there.</p>
+
+
+<h2>Step 3: Replace directories</h2>
+
+<p>Replace the following directories with the new versions:</p>
+
+<ul>
+<li>drivers</li>
+<li>helpers</li>
+<li>init</li>
+<li>libraries</li>
+<li>scaffolding</li>
+</ul>
+
+
+<h2>Step 4: Add the calendar language file</h2>
+
+<p>There is a new language file corresponding to the new calendaring class which must be added to your language folder. Add
+the following item to your version: <dfn>language/english/calendar_lang.php</dfn></p>
+
+
+<h2>Step 5: Edit your config file</h2>
+
+<p>The original <kbd>application/config/config.php</kbd> file has a typo in it  Open the file and look for the items related to cookies:</p>
+
+<code>$conf['cookie_prefix']   = "";<br />
+$conf['cookie_domain'] = "";<br />
+$conf['cookie_path']   = "/";</code>
+
+<p>Change the array name from <kbd>$conf</kbd> to <kbd>$config</kbd>, like this:</p>
+
+<code>$config['cookie_prefix'] = "";<br />
+$config['cookie_domain']       = "";<br />
+$config['cookie_path'] = "/";</code>
+
+<p>Lastly, add the following new item to the config file (and edit the option if needed):</p>
+
+<code><br />
+/*<br />
+|------------------------------------------------<br />
+| URI PROTOCOL<br />
+|------------------------------------------------<br />
+|<br />
+| This item determines which server global <br />
+| should be used to retrieve the URI string.  The <br />
+| default setting of "auto" works for most servers.<br />
+| If your links do not seem to work, try one of <br />
+| the other delicious flavors:<br />
+| <br />
+| 'auto'                       Default - auto detects<br />
+| 'path_info'          Uses the PATH_INFO <br />
+| 'query_string'       Uses the QUERY_STRING<br />
+*/<br />
+<br />
+$config['uri_protocol']        = "auto";</code>
+
+
+</div>
+<!-- END CONTENT -->
+
+
+<div id="footer">
+<p>
+Previous Topic:&nbsp;&nbsp;<a href="index.html">Installation Instructions</a>
+&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+<a href="#top">Top of Page</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+<a href="../index.html">User Guide Home</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+Next Topic:&nbsp;&nbsp;<a href="troubleshooting.html">Troubleshooting</a>
+</p>
+<p><a href="http://codeigniter.com">CodeIgniter</a> &nbsp;&middot;&nbsp; Copyright &#169; 2006 - 2011 &nbsp;&middot;&nbsp; <a href="http://ellislab.com/">EllisLab, Inc.</a></p>
+</div>
+
+</body>
+</html>
\ No newline at end of file
diff --git a/user_guide/installation/upgrading.html b/user_guide/installation/upgrading.html
new file mode 100755 (executable)
index 0000000..1c4eb88
--- /dev/null
@@ -0,0 +1,104 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head>
+
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+<title>Upgrading From a Previous Version : CodeIgniter User Guide</title>
+
+<style type='text/css' media='all'>@import url('../userguide.css');</style>
+<link rel='stylesheet' type='text/css' media='all' href='../userguide.css' />
+
+<script type="text/javascript" src="../nav/nav.js"></script>
+<script type="text/javascript" src="../nav/prototype.lite.js"></script>
+<script type="text/javascript" src="../nav/moo.fx.js"></script>
+<script type="text/javascript" src="../nav/user_guide_menu.js"></script>
+
+<meta http-equiv='expires' content='-1' />
+<meta http-equiv= 'pragma' content='no-cache' />
+<meta name='robots' content='all' />
+<meta name='author' content='ExpressionEngine Dev Team' />
+<meta name='description' content='CodeIgniter User Guide' />
+
+</head>
+<body>
+
+<!-- START NAVIGATION -->
+<div id="nav"><div id="nav_inner"><script type="text/javascript">create_menu('../');</script></div></div>
+<div id="nav2"><a name="top"></a><a href="javascript:void(0);" onclick="myHeight.toggle();"><img src="../images/nav_toggle_darker.jpg" width="154" height="43" border="0" title="Toggle Table of Contents" alt="Toggle Table of Contents" /></a></div>
+<div id="masthead">
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td><h1>CodeIgniter User Guide Version 2.0.2</h1></td>
+<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
+</tr>
+</table>
+</div>
+<!-- END NAVIGATION -->
+
+
+<!-- START BREADCRUMB -->
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td id="breadcrumb">
+<a href="http://codeigniter.com/">CodeIgniter Home</a> &nbsp;&#8250;&nbsp;
+<a href="../index.html">User Guide Home</a> &nbsp;&#8250;&nbsp;
+Upgrading from a Previous Version
+</td>
+<td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="codeigniter.com/user_guide/" />Search User Guide&nbsp; <input type="text" class="input" style="width:200px;" name="q" id="q" size="31" maxlength="255" value="" />&nbsp;<input type="submit" class="submit" name="sa" value="Go" /></form></td>
+</tr>
+</table>
+<!-- END BREADCRUMB -->
+
+<br clear="all" />
+
+
+<!-- START CONTENT -->
+<div id="content">
+
+<h1>Upgrading From a Previous Version</h1>
+
+<p>Please read the upgrade notes corresponding to the version you are upgrading from.</p>
+
+<ul>
+       <li><a href="upgrade_202.html">Upgrading from 2.0.1 to 2.0.2</a></li>
+       <li><a href="upgrade_201.html">Upgrading from 2.0 to 2.0.1</a></li>
+       <li><a href="upgrade_200.html">Upgrading from 1.7.2 to 2.0</a></li>
+       <li><a href="upgrade_172.html">Upgrading from 1.7.1 to 1.7.2</a></li>
+       <li><a href="upgrade_171.html">Upgrading from 1.7.0 to 1.7.1</a></li>
+       <li><a href="upgrade_170.html">Upgrading from 1.6.3 to 1.7.0</a></li>
+       <li><a href="upgrade_163.html">Upgrading from 1.6.2 to 1.6.3</a></li>
+       <li><a href="upgrade_162.html">Upgrading from 1.6.1 to 1.6.2</a></li>
+       <li><a href="upgrade_161.html">Upgrading from 1.6.0 to 1.6.1</a></li>
+       <li><a href="upgrade_160.html">Upgrading from 1.5.4 to 1.6.0</a></li>
+       <li><a href="upgrade_154.html">Upgrading from 1.5.3 to 1.5.4</a></li>
+       <li><a href="upgrade_153.html">Upgrading from 1.5.2 to 1.5.3</a></li>
+       <li><a href="upgrade_152.html">Upgrading from 1.5.0 or 1.5.1 to 1.5.2</a></li>
+       <li><a href="upgrade_150.html">Upgrading from 1.4.1 to 1.5.0</a></li>
+       <li><a href="upgrade_141.html">Upgrading from 1.4.0 to 1.4.1</a></li>
+       <li><a href="upgrade_140.html">Upgrading from 1.3.3 to 1.4.0</a></li>
+       <li><a href="upgrade_133.html">Upgrading from 1.3.2 to 1.3.3</a></li>
+       <li><a href="upgrade_132.html">Upgrading from 1.3.1 to 1.3.2</a></li>
+       <li><a href="upgrade_131.html">Upgrading from 1.3 to 1.3.1</a></li>
+       <li><a href="upgrade_130.html">Upgrading from 1.2 to 1.3</a></li>
+       <li><a href="upgrade_120.html">Upgrading from 1.1 to 1.2</a></li>
+       <li><a href="upgrade_b11.html">Upgrading from Beta 1.0 to Beta 1.1</a></li>
+</ul>
+
+
+</div>
+<!-- END CONTENT -->
+
+
+<div id="footer">
+<p>
+Previous Topic:&nbsp;&nbsp;<a href="index.html">Installation Instructions</a>
+&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+<a href="#top">Top of Page</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+<a href="../index.html">User Guide Home</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+Next Topic:&nbsp;&nbsp;<a href="troubleshooting.html">Troubleshooting</a>
+</p>
+<p><a href="http://codeigniter.com">CodeIgniter</a> &nbsp;&middot;&nbsp; Copyright &#169; 2006 - 2011 &nbsp;&middot;&nbsp; <a href="http://ellislab.com/">EllisLab, Inc.</a></p>
+</div>
+
+</body>
+</html>
\ No newline at end of file
diff --git a/user_guide/libraries/benchmark.html b/user_guide/libraries/benchmark.html
new file mode 100755 (executable)
index 0000000..c29acb7
--- /dev/null
@@ -0,0 +1,198 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head>
+
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+<title>Benchmarking Class : CodeIgniter User Guide</title>
+
+<style type='text/css' media='all'>@import url('../userguide.css');</style>
+<link rel='stylesheet' type='text/css' media='all' href='../userguide.css' />
+
+<script type="text/javascript" src="../nav/nav.js"></script>
+<script type="text/javascript" src="../nav/prototype.lite.js"></script>
+<script type="text/javascript" src="../nav/moo.fx.js"></script>
+<script type="text/javascript" src="../nav/user_guide_menu.js"></script>
+
+<meta http-equiv='expires' content='-1' />
+<meta http-equiv= 'pragma' content='no-cache' />
+<meta name='robots' content='all' />
+<meta name='author' content='ExpressionEngine Dev Team' />
+<meta name='description' content='CodeIgniter User Guide' />
+
+</head>
+<body>
+
+<!-- START NAVIGATION -->
+<div id="nav"><div id="nav_inner"><script type="text/javascript">create_menu('../');</script></div></div>
+<div id="nav2"><a name="top"></a><a href="javascript:void(0);" onclick="myHeight.toggle();"><img src="../images/nav_toggle_darker.jpg" width="154" height="43" border="0" title="Toggle Table of Contents" alt="Toggle Table of Contents" /></a></div>
+<div id="masthead">
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td><h1>CodeIgniter User Guide Version 2.0.2</h1></td>
+<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
+</tr>
+</table>
+</div>
+<!-- END NAVIGATION -->
+
+
+<!-- START BREADCRUMB -->
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td id="breadcrumb">
+<a href="http://codeigniter.com/">CodeIgniter Home</a> &nbsp;&#8250;&nbsp;
+<a href="../index.html">User Guide Home</a> &nbsp;&#8250;&nbsp;
+Benchmarking Class
+</td>
+<td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="codeigniter.com/user_guide/" />Search User Guide&nbsp; <input type="text" class="input" style="width:200px;" name="q" id="q" size="31" maxlength="255" value="" />&nbsp;<input type="submit" class="submit" name="sa" value="Go" /></form></td>
+</tr>
+</table>
+<!-- END BREADCRUMB -->
+
+<br clear="all" />
+
+
+<!-- START CONTENT -->
+<div id="content">
+
+
+<h1>Benchmarking Class</h1>
+
+<p>CodeIgniter has a Benchmarking class that is always active, enabling the time difference between any
+two marked points to be calculated.</p>
+
+<p class="important"><strong>Note:</strong> This class is initialized automatically by the system so there is no need to do it manually.</p>
+
+
+<p>In addition, the benchmark is always started the moment the framework is
+invoked, and ended by the output class right before sending the final view to the browser, enabling a very accurate
+timing of the entire system execution to be shown.</p>
+
+
+<h3>Table of Contents</h3>
+
+<ul>
+<li><a href="#using">Using the Benchmark Class</a></li>
+<li><a href="#profiler">Profiling Your Benchmark Points</a></li>
+<li><a href="#execution">Displaying Total Execution Time</a></li>
+<li><a href="#memory">Displaying Memory Consumption</a></li>
+</ul>
+
+
+
+<a name="using"></a>
+<h2>Using the Benchmark Class</h2>
+
+<p>The Benchmark class can be used within your <a href="../general/controllers.html">controllers</a>,  <a href="../general/views.html">views</a>, or your  <a href="../general/models.html">models</a>.  The process for usage is this:</p>
+
+<ol>
+<li>Mark a start point</li>
+<li>Mark an end point</li>
+<li>Run the "elapsed time" function to view the results</li>
+</ol>
+
+<p>Here's an example using real code:</p>
+
+<code>$this->benchmark->mark('code_start');<br />
+<br />
+// Some code happens here<br />
+<br />
+$this->benchmark->mark('code_end');<br />
+<br />
+echo $this->benchmark->elapsed_time('code_start', 'code_end');</code>
+
+<p class="important"><strong>Note:</strong> The words "code_start" and "code_end" are arbitrary.  They are simply words used to set two markers.  You can
+use any words you want, and you can set multiple sets of markers. Consider this example:</p>
+
+<code>$this->benchmark->mark('dog');<br />
+<br />
+// Some code happens here<br />
+<br />
+$this->benchmark->mark('cat');<br />
+<br />
+// More code happens here<br />
+<br />
+$this->benchmark->mark('bird');<br />
+<br />
+echo $this->benchmark->elapsed_time('dog', 'cat');<br />
+echo $this->benchmark->elapsed_time('cat', 'bird');<br />
+echo $this->benchmark->elapsed_time('dog', 'bird');</code>
+
+
+<a name="profiler"></a>
+<h2>Profiling Your Benchmark Points</h2>
+
+<p>If you want your benchmark data to be available to the
+<a href="../general/profiling.html">Profiler</a> all of your marked points must be set up in pairs, and
+each mark point name must end with <kbd>_start</kbd> and <kbd>_end</kbd>.
+Each pair of points must otherwise be named identically. Example:</p>
+
+<code>
+$this->benchmark->mark('my_mark<kbd>_start</kbd>');<br />
+<br />
+// Some code happens here...<br />
+<br />
+$this->benchmark->mark('my_mark<kbd>_end</kbd>');
+<br /><br />
+
+$this->benchmark->mark('another_mark<kbd>_start</kbd>');<br />
+<br />
+// Some more code happens here...<br />
+<br />
+$this->benchmark->mark('another_mark<kbd>_end</kbd>');
+</code>
+
+<p>Please read the <a href="../general/profiling.html">Profiler page</a> for more information.</p>
+
+
+<a name="execution"></a>
+<h2>Displaying Total Execution Time</h2>
+
+<p>If you would like to display the total elapsed time from the moment CodeIgniter starts to the moment the final output
+is sent to the browser, simply place this in one of your view templates:</p>
+
+<code>&lt;?php echo $this->benchmark->elapsed_time();?&gt;</code>
+
+<p>You'll notice that it's the same function used in the examples above to calculate the time between two point, except you are
+<strong>not</strong> using any parameters.  When the parameters are absent, CodeIgniter does not stop the benchmark until right before the final
+output is sent to the browser.  It doesn't matter where you use the function call, the timer will continue to run until the very end.</p>
+
+<p>An alternate way to show your elapsed time in your view files is to use this pseudo-variable, if you prefer not to use the pure PHP:</p>
+<code>{elapsed_time}</code>
+
+<p class="important"><strong>Note:</strong> If you want to benchmark anything within your controller
+functions you must set your own start/end points.</p>
+
+<a name="memory"></a>
+<h2>Displaying Memory Consumption</h2>
+
+<p>If your PHP installation is configured with --enable-memory-limit, you can display the amount of memory consumed by the entire
+system using the following code in one of your view file:</p>
+
+<code>&lt;?php echo $this->benchmark->memory_usage();?&gt;</code>
+<p>Note: This function can only be used in your view files. The consumption will reflect the total memory used by the entire app.</p>
+
+<p>An alternate way to show your memory usage in your view files is to use this pseudo-variable, if you prefer not to use the pure PHP:</p>
+<code>{memory_usage}</code>
+
+
+
+
+</div>
+<!-- END CONTENT -->
+
+
+
+<div id="footer">
+<p>
+Previous Topic:&nbsp;&nbsp;<a href="../doc_style/index.html">Writing Documentaion</a>
+&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+<a href="#top">Top of Page</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+<a href="../index.html">User Guide Home</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+Next Topic:&nbsp;&nbsp;<a href="calendar.html">Calendar Class</a>
+</p>
+<p><a href="http://codeigniter.com">CodeIgniter</a> &nbsp;&middot;&nbsp; Copyright &#169; 2006 - 2011 &nbsp;&middot;&nbsp; <a href="http://ellislab.com/">EllisLab, Inc.</a></p>
+</div>
+
+</body>
+</html>
\ No newline at end of file
diff --git a/user_guide/libraries/caching.html b/user_guide/libraries/caching.html
new file mode 100755 (executable)
index 0000000..190232e
--- /dev/null
@@ -0,0 +1,193 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head>
+
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+<title>Caching Driver : CodeIgniter User Guide</title>
+
+<style type='text/css' media='all'>@import url('../userguide.css');</style>
+<link rel='stylesheet' type='text/css' media='all' href='../userguide.css' />
+
+<script type="text/javascript" src="../nav/nav.js"></script>
+<script type="text/javascript" src="../nav/prototype.lite.js"></script>
+<script type="text/javascript" src="../nav/moo.fx.js"></script>
+<script type="text/javascript" src="../nav/user_guide_menu.js"></script>
+
+<meta http-equiv='expires' content='-1' />
+<meta http-equiv= 'pragma' content='no-cache' />
+<meta name='robots' content='all' />
+<meta name='author' content='ExpressionEngine Dev Team' />
+<meta name='description' content='CodeIgniter User Guide' />
+
+</head>
+<body>
+
+<!-- START NAVIGATION -->
+<div id="nav"><div id="nav_inner"><script type="text/javascript">create_menu('../');</script></div></div>
+<div id="nav2"><a name="top"></a><a href="javascript:void(0);" onclick="myHeight.toggle();"><img src="../images/nav_toggle_darker.jpg" width="154" height="43" border="0" title="Toggle Table of Contents" alt="Toggle Table of Contents" /></a></div>
+<div id="masthead">
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td><h1>CodeIgniter User Guide Version 2.0.2</h1></td>
+<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
+</tr>
+</table>
+</div>
+<!-- END NAVIGATION -->
+
+
+<!-- START BREADCRUMB -->
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td id="breadcrumb">
+<a href="http://codeigniter.com/">CodeIgniter Home</a> &nbsp;&#8250;&nbsp;
+<a href="../index.html">User Guide Home</a> &nbsp;&#8250;&nbsp;
+<a href="../general/drivers.html">Drivers</a> &nbsp;&#8250;&nbsp;
+Caching Driver
+</td>
+<td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="codeigniter.com/user_guide/" />Search User Guide&nbsp; <input type="text" class="input" style="width:200px;" name="q" id="q" size="31" maxlength="255" value="" />&nbsp;<input type="submit" class="submit" name="sa" value="Go" /></form></td>
+</tr>
+</table>
+<!-- END BREADCRUMB -->
+
+<br clear="all" />
+
+
+<!-- START CONTENT -->
+<div id="content">
+
+<h1>Caching Driver</h1>
+
+<p>CodeIgniter features wrappers around some of the most popular forms of fast and dynamic caching.  All but file-based caching require specific server requirements, and a Fatal Exception will be thrown if server requirements are not met.</p>
+
+<h2>Table of Contents</h2>
+<ul>
+       <li><a href="#example_usage" title="Example Usage">Example Usage</a></li>
+       <li><a href="#function_reference" title="Function Reference">Function Reference</a></li>
+</ul>
+
+<h3>Available Drivers</h3>
+<ul>
+       <li><a href="#apc" title="APC Cache">Alternative PHP Cache (APC) Caching</a></li>
+       <li><a href="#file" title="File Caching">File-based Caching</a></li>
+       <li><a href="#memcached" title="Memcached">Memcached Caching</a></li>
+       <li><a href="#dummy" title="Dummy Caching">Dummy Cache</a></li>
+</ul>
+
+<h2 id="example_usage">Example Usage</h2>
+
+<p>The following example will load the cache driver, specify <a href="#apc" title="APC">APC</a> as the driver to use, and fall back to file-based caching if APC is not available in the hosting environment.</p>
+
+<code>
+$this->load->driver('cache', array('adapter' => 'apc', 'backup' => 'file'));<br />
+<br />
+if ( ! $foo = $this->cache->get('foo'))<br />
+{<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;echo 'Saving to the cache!&lt;br />';<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$foo = 'foobarbaz!';<br />
+<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// Save into the cache for 5 minutes<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$this->cache->save('foo', $foo, 300);<br />
+}<br />
+<br />
+echo $foo;
+</code>
+
+<h1 id="function_reference">Function Reference</h1>
+
+<h2>is_supported(<var>driver</var>['string'])</h2>
+
+<p>This function is automatically called when accessing drivers via <samp>$this->cache->get()</samp>.  However, if the individual drivers are used, make sure to call this function to ensure the driver is supported in the hosting environment.</p>
+
+<code>
+if ($this->cache->apc->is_supported())<br />
+{<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if ($data = $this->cache->apc->get('my_cache'))<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// do things.<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br />
+}
+</code>
+
+<h2>get(<var>id</var>['string'])</h2>
+
+<p>This function will attempt to fetch an item from the cache store.  If the item does not exist, the function will return <samp>FALSE</samp>.</p>
+<code>$foo = $this->cache->get('my_cached_item');</code>
+
+<h2>save(<var>id</var>['string'], <var>data</var>['mixed'], <var>ttl</var>['int'])</h2>
+
+<p>This function will save an item to the cache store.  If saving fails, the function will return <samp>FALSE</samp>.</p>
+<p>The optional third parameter (Time To Live) defaults to 60 seconds.</p>
+<code>$this->cache->save('cache_item_id', 'data_to_cache');</code>
+
+<h2>delete(<var>id</var>['string'])</h2>
+
+<p>This function will delete a specific item from the cache store.  If item deletion fails, the function will return <samp>FALSE</samp>.</p>
+<code>$this->cache->delete('cache_item_id');</code>
+
+<h2>clean()</h2>
+
+<p>This function will 'clean' the entire cache.  If the deletion of the cache files fails, the function will return <samp>FALSE</samp>.</p>
+
+<code>$this->cache->clean();</code>
+
+<h2>cache_info()</h2>
+
+<p>This function will return information on the entire cache.</p>
+
+<code>var_dump($this->cache->cache_info());</code>
+
+<h2>get_metadata(<var>id</var>['string'])</h2>
+
+<p>This function will return detailed information on a specific item in the cache.</p>
+
+<code>var_dump($this->cache->get_metadata('my_cached_item'));</code>
+
+<h1>Drivers</h1>
+
+<h2 id="apc">Alternative PHP Cache (APC) Caching</h2>
+
+<p>All of the functions listed above can be accessed without passing a specific adapter to the driver loader as follows:</p>
+<code>$this->load->driver('cache');<br />
+       $this->cache->apc->save('foo', 'bar', 10);</code>
+<p>For more information on APC, please see <a href="http://php.net/apc">http://php.net/apc</a></p>
+
+<h2 id="file">File-based Caching</h2>
+
+<p>Unlike caching from the Output Class, the driver file-based caching allows for pieces of view files to be cached.  Use this with care, and make sure to benchmark your application, as a point can come where disk I/O will negate positive gains by caching.</p>
+
+<p>All of the functions listed above can be accessed without passing a specific adapter to the driver loader as follows:</p>
+<code>$this->load->driver('cache');<br />
+       $this->cache->file->save('foo', 'bar', 10);</code>
+
+<h2 id="memcached">Memcached Caching</h2>
+
+<p>Multiple Memcached servers can be specified in the memcached.php configuration file, located in the <samp>application/config/</samp> directory.
+
+<p>All of the functions listed above can be accessed without passing a specific adapter to the driver loader as follows:</p>
+<code>$this->load->driver('cache');<br />
+       $this->cache->memcached->save('foo', 'bar', 10);</code>
+
+<p>For more information on Memcached, please see <a href="http://php.net/memcached">http://php.net/memcached</a></p>
+
+<h2 id="dummy">Dummy Cache</h2>
+
+<p>This is a caching backend that will always 'miss.'  It stores no data, but lets you keep your caching code in place in environments that don't support your chosen cache.</p>
+
+</div>
+<!-- END CONTENT -->
+
+
+<div id="footer">
+<p>
+Previous Topic:&nbsp;&nbsp;<a href="errors.html">Error Handling</a>
+&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+<a href="#top">Top of Page</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+<a href="../index.html">User Guide Home</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+Next Topic:&nbsp;&nbsp;<a href="profiling.html">Profiling Your Application</a>
+</p>
+<p><a href="http://codeigniter.com">CodeIgniter</a> &nbsp;&middot;&nbsp; Copyright &#169; 2006 - 2011 &nbsp;&middot;&nbsp; <a href="http://ellislab.com/">EllisLab, Inc.</a></p>
+</div>
+
+</body>
+</html>
\ No newline at end of file
diff --git a/user_guide/libraries/calendar.html b/user_guide/libraries/calendar.html
new file mode 100755 (executable)
index 0000000..e1af71c
--- /dev/null
@@ -0,0 +1,249 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head>
+
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+<title>Calendaring Class : CodeIgniter User Guide</title>
+
+<style type='text/css' media='all'>@import url('../userguide.css');</style>
+<link rel='stylesheet' type='text/css' media='all' href='../userguide.css' />
+
+<script type="text/javascript" src="../nav/nav.js"></script>
+<script type="text/javascript" src="../nav/prototype.lite.js"></script>
+<script type="text/javascript" src="../nav/moo.fx.js"></script>
+<script type="text/javascript" src="../nav/user_guide_menu.js"></script>
+
+<meta http-equiv='expires' content='-1' />
+<meta http-equiv= 'pragma' content='no-cache' />
+<meta name='robots' content='all' />
+<meta name='author' content='ExpressionEngine Dev Team' />
+<meta name='description' content='CodeIgniter User Guide' />
+
+</head>
+<body>
+
+<!-- START NAVIGATION -->
+<div id="nav"><div id="nav_inner"><script type="text/javascript">create_menu('../');</script></div></div>
+<div id="nav2"><a name="top"></a><a href="javascript:void(0);" onclick="myHeight.toggle();"><img src="../images/nav_toggle_darker.jpg" width="154" height="43" border="0" title="Toggle Table of Contents" alt="Toggle Table of Contents" /></a></div>
+<div id="masthead">
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td><h1>CodeIgniter User Guide Version 2.0.2</h1></td>
+<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
+</tr>
+</table>
+</div>
+<!-- END NAVIGATION -->
+
+
+<!-- START BREADCRUMB -->
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td id="breadcrumb">
+<a href="http://codeigniter.com/">CodeIgniter Home</a> &nbsp;&#8250;&nbsp;
+<a href="../index.html">User Guide Home</a> &nbsp;&#8250;&nbsp;
+Calendaring Class
+</td>
+<td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="codeigniter.com/user_guide/" />Search User Guide&nbsp; <input type="text" class="input" style="width:200px;" name="q" id="q" size="31" maxlength="255" value="" />&nbsp;<input type="submit" class="submit" name="sa" value="Go" /></form></td>
+</tr>
+</table>
+<!-- END BREADCRUMB -->
+
+<br clear="all" />
+
+
+<!-- START CONTENT -->
+<div id="content">
+
+
+
+
+<h1>Calendaring Class</h1>
+
+<p>The Calendar class enables you to dynamically create calendars. Your calendars can be formatted through the use of a calendar
+template, allowing 100% control over every aspect of its design. In addition, you can pass data to your calendar cells.</p>
+
+<h2>Initializing the Class</h2>
+
+<p>Like most other classes in CodeIgniter, the Calendar class is initialized in your controller using the <dfn>$this->load->library</dfn> function:</p>
+
+<code>$this->load->library('calendar');</code>
+<p>Once loaded, the Calendar object will be available using: <dfn>$this->calendar</dfn></p>
+
+
+<h2>Displaying a Calendar</h2>
+
+<p>Here is a very simple example showing how you can display a calendar:</p>
+
+<code>$this->load->library('calendar');<br />
+<br />
+echo $this->calendar->generate();</code>
+
+<p>The above code will generate a calendar for the current month/year based on your server time.
+To show a calendar for a specific month and year you will pass this information to the calendar generating function:</p>
+
+<code>$this->load->library('calendar');<br />
+<br />
+echo $this->calendar->generate(<kbd>2006</kbd>, <kbd>6</kbd>);</code>
+
+<p>The above code will generate a calendar showing the month of June in 2006.  The first parameter specifies the year, the second parameter specifies the month.</p>
+
+<h2>Passing Data to your Calendar Cells</h2>
+
+<p>To add data to your calendar cells involves creating an associative array in which the keys correspond to the days
+you wish to populate and the array value contains the data.  The array is passed to the third parameter of the calendar
+generating function.  Consider this example:</p>
+
+<code>$this->load->library('calendar');<br />
+<br />
+$data = array(<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;3&nbsp; => 'http://example.com/news/article/2006/03/',<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;7&nbsp; => 'http://example.com/news/article/2006/07/',<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;13 => 'http://example.com/news/article/2006/13/',<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;26 => 'http://example.com/news/article/2006/26/'<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;);<br />
+<br />
+echo $this->calendar->generate(<kbd>2006</kbd>, <kbd>6</kbd>, <var>$data</var>);</code>
+
+<p>Using the above example, day numbers 3, 7, 13, and 26 will become links pointing to the URLs you've provided.</p>
+
+<p class="important"><strong>Note:</strong> By default it is assumed that your array will contain links.
+In the section that explains the calendar template below you'll see how you can customize
+how data passed to your cells is handled so you can pass different types of information.</p>
+
+
+<h2>Setting Display Preferences</h2>
+
+<p>There are seven preferences you can set to control various aspects of the calendar.  Preferences are set by passing an
+array of preferences in the second parameter of the loading function. Here is an example:</p>
+
+
+<code>
+$prefs = array (<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'start_day'&nbsp;&nbsp;&nbsp; => 'saturday',<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'month_type'&nbsp;&nbsp; => 'long',<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'day_type'&nbsp;&nbsp;&nbsp;&nbsp; => 'short'<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;);<br />
+<br />
+$this->load->library('calendar', $prefs);<br />
+<br />
+echo $this->calendar->generate();</code>
+
+<p>The above code would start the calendar on saturday, use the "long" month heading, and the "short" day names.  More information
+regarding preferences below.</p>
+
+
+
+
+<table cellpadding="0" cellspacing="1" border="0" style="width:100%" class="tableborder">
+<tr>
+<th>Preference</th>
+<th>Default&nbsp;Value</th>
+<th>Options</th>
+<th>Description</th>
+</tr><tr>
+<td class="td"><strong>template</strong></td><td class="td">None</td><td class="td">None</td><td class="td">A string containing your calendar template. See the template section below.</td>
+</tr><tr>
+<td class="td"><strong>local_time</strong></td><td class="td">time()</td><td class="td">None</td><td class="td">A Unix timestamp corresponding to the current time.</td>
+</tr><tr>
+<td class="td"><strong>start_day</strong></td><td class="td">sunday</td><td class="td">Any week day (sunday, monday, tuesday, etc.)</td><td class="td">Sets the day of the week the calendar should start on.</td>
+</tr><tr>
+<td class="td"><strong>month_type</strong></td><td class="td">long</td><td class="td">long, short</td><td class="td">Determines what version of the month name to use in the header. long = January, short = Jan.</td>
+</tr><tr>
+<td class="td"><strong>day_type</strong></td><td class="td">abr</td><td class="td">long, short, abr</td><td class="td">Determines what version of the weekday names to use in the column headers. long = Sunday, short = Sun, abr = Su.</td>
+</tr><tr>
+<td class="td"><strong>show_next_prev</strong></td><td class="td">FALSE</td><td class="td">TRUE/FALSE (boolean)</td><td class="td">Determines whether to display links allowing you to toggle to next/previous months. See information on this feature below.</td>
+</tr><tr>
+<td class="td"><strong>next_prev_url</strong></td><td class="td">None</td><td class="td">A URL</td><td class="td">Sets the basepath used in the next/previous calendar links.</td>
+</tr>
+</table>
+
+
+
+<h2>Showing Next/Previous Month Links</h2>
+
+<p>To allow your calendar to dynamically increment/decrement via the next/previous links requires that you set up your calendar
+code similar to this example:</p>
+
+
+<code>$prefs = array (<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'show_next_prev'&nbsp;&nbsp;=> TRUE,<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'next_prev_url'&nbsp;&nbsp; => 'http://example.com/index.php/calendar/show/'<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;);<br />
+<br />
+$this-&gt;load-&gt;library('calendar', $prefs);<br />
+<br />
+echo $this->calendar->generate(<var>$this->uri->segment(3)</var>, <var>$this->uri->segment(4)</var>);</code>
+
+<p>You'll notice a few things about the above example:</p>
+
+<ul>
+<li>You must set the "show_next_prev" to TRUE.</li>
+<li>You must supply the URL to the controller containing your calendar in the "next_prev_url" preference.</li>
+<li>You must supply the "year" and "month" to the calendar generating function via the URI segments where they appear (Note:  The calendar class automatically adds the year/month to the base URL you provide.).</li>
+</ul>
+
+
+
+<h2>Creating a Calendar Template</h2>
+
+<p>By creating a calendar template you have 100% control over the design of your calendar. Each component of your
+calendar will be placed within a pair of pseudo-variables as shown here:</p>
+
+
+<code>
+$prefs['template'] = '<br /><br />
+&nbsp;&nbsp;&nbsp;<dfn>{table_open}</dfn><var>&lt;table border="0" cellpadding="0" cellspacing="0"></var><dfn>{/table_open}</dfn><br />
+<br />
+&nbsp;&nbsp;&nbsp;<dfn>{heading_row_start}</dfn><var>&lt;tr></var><dfn>{/heading_row_start}</dfn><br />
+<br />
+&nbsp;&nbsp;&nbsp;<dfn>{heading_previous_cell}</dfn><var>&lt;th>&lt;a href="</var><kbd>{previous_url}</kbd><var>">&amp;lt;&amp;lt;&lt;/a>&lt;/th></var><dfn>{/heading_previous_cell}</dfn><br />
+&nbsp;&nbsp;&nbsp;<dfn>{heading_title_cell}</dfn><var>&lt;th colspan="</var><kbd>{colspan}</kbd><var>"></var><kbd>{heading}</kbd><var>&lt;/th></var><dfn>{/heading_title_cell}</dfn><br />
+&nbsp;&nbsp;&nbsp;<dfn>{heading_next_cell}</dfn><var>&lt;th>&lt;a href="</var><kbd>{next_url}</kbd><var>">&amp;gt;&amp;gt;&lt;/a>&lt;/th></var><dfn>{/heading_next_cell}</dfn><br />
+<br />
+&nbsp;&nbsp;&nbsp;<dfn>{heading_row_end}</dfn><var>&lt;/tr></var><dfn>{/heading_row_end}</dfn><br />
+<br />
+&nbsp;&nbsp;&nbsp;<dfn>{week_row_start}</dfn><var>&lt;tr></var><dfn>{/week_row_start}</dfn><br />
+&nbsp;&nbsp;&nbsp;<dfn>{week_day_cell}</dfn><var>&lt;td></var><dfn>{week_day}</dfn><var>&lt;/td></var><dfn>{/week_day_cell}</dfn><br />
+&nbsp;&nbsp;&nbsp;<dfn>{week_row_end}</dfn><var>&lt;/tr></var><dfn>{/week_row_end}</dfn><br />
+<br />
+&nbsp;&nbsp;&nbsp;<dfn>{cal_row_start}</dfn><var>&lt;tr></var><dfn>{/cal_row_start}</dfn><br />
+&nbsp;&nbsp;&nbsp;<dfn>{cal_cell_start}</dfn><var>&lt;td></var><dfn>{/cal_cell_start}</dfn><br />
+<br />
+&nbsp;&nbsp;&nbsp;<dfn>{cal_cell_content}</dfn><var>&lt;a href="</var><kbd>{content}</kbd><var>"></var><kbd>{day}</kbd><var>&lt;/a></var><dfn>{/cal_cell_content}</dfn><br />
+&nbsp;&nbsp;&nbsp;<dfn>{cal_cell_content_today}</dfn><var>&lt;div class="highlight">&lt;a href="</var><kbd>{content}</kbd><var>"></var><kbd>{day}</kbd><var>&lt;/a>&lt;/div></var><dfn>{/cal_cell_content_today}</dfn><br />
+<br />
+&nbsp;&nbsp;&nbsp;<dfn>{cal_cell_no_content}</dfn><var></var><kbd>{day}</kbd><var></var><dfn>{/cal_cell_no_content}</dfn><br />
+&nbsp;&nbsp;&nbsp;<dfn>{cal_cell_no_content_today}</dfn><var>&lt;div class="highlight"></var><kbd>{day}</kbd><var>&lt;/div></var><dfn>{/cal_cell_no_content_today}</dfn><br />
+<br />
+&nbsp;&nbsp;&nbsp;<dfn>{cal_cell_blank}</dfn><var>&amp;nbsp;</var><dfn>{/cal_cell_blank}</dfn><br />
+<br />
+&nbsp;&nbsp;&nbsp;<dfn>{cal_cell_end}</dfn><var>&lt;/td></var><dfn>{/cal_cell_end}</dfn><br />
+&nbsp;&nbsp;&nbsp;<dfn>{cal_row_end}</dfn><var>&lt;/tr></var><dfn>{/cal_row_end}</dfn><br />
+<br />
+&nbsp;&nbsp;&nbsp;<dfn>{table_close}</dfn><var>&lt;/table></var><dfn>{/table_close}</dfn><br />
+';<br />
+<br />
+$this->load->library('calendar', $prefs);<br />
+<br />
+echo $this->calendar->generate();</code>
+
+
+
+</div>
+<!-- END CONTENT -->
+
+
+<div id="footer">
+<p>
+Previous Topic:&nbsp;&nbsp;<a href="benchmark.html">Benchmark Class</a>
+&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+<a href="#top">Top of Page</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+<a href="../index.html">User Guide Home</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+Next Topic:&nbsp;&nbsp;<a href="cart.html">Cart Class</a>
+</p>
+<p><a href="http://codeigniter.com">CodeIgniter</a> &nbsp;&middot;&nbsp; Copyright &#169; 2006 - 2011 &nbsp;&middot;&nbsp; <a href="http://ellislab.com/">EllisLab, Inc.</a></p>
+</div>
+
+</body>
+</html>
\ No newline at end of file
diff --git a/user_guide/libraries/cart.html b/user_guide/libraries/cart.html
new file mode 100755 (executable)
index 0000000..f084d5d
--- /dev/null
@@ -0,0 +1,346 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head>
+
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+<title>Shopping Cart Class : CodeIgniter User Guide</title>
+
+<style type='text/css' media='all'>@import url('../userguide.css');</style>
+<link rel='stylesheet' type='text/css' media='all' href='../userguide.css' />
+
+<script type="text/javascript" src="../nav/nav.js"></script>
+<script type="text/javascript" src="../nav/prototype.lite.js"></script>
+<script type="text/javascript" src="../nav/moo.fx.js"></script>
+<script type="text/javascript" src="../nav/user_guide_menu.js"></script>
+
+<meta http-equiv='expires' content='-1' />
+<meta http-equiv= 'pragma' content='no-cache' />
+<meta name='robots' content='all' />
+<meta name='author' content='ExpressionEngine Dev Team' />
+<meta name='description' content='CodeIgniter User Guide' />
+
+</head>
+<body>
+
+<!-- START NAVIGATION -->
+<div id="nav"><div id="nav_inner"><script type="text/javascript">create_menu('../');</script></div></div>
+<div id="nav2"><a name="top"></a><a href="javascript:void(0);" onclick="myHeight.toggle();"><img src="../images/nav_toggle_darker.jpg" width="154" height="43" border="0" title="Toggle Table of Contents" alt="Toggle Table of Contents" /></a></div>
+<div id="masthead">
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td><h1>CodeIgniter User Guide Version 2.0.2</h1></td>
+<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
+</tr>
+</table>
+</div>
+<!-- END NAVIGATION -->
+
+
+<!-- START BREADCRUMB -->
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td id="breadcrumb">
+<a href="http://codeigniter.com/">CodeIgniter Home</a> &nbsp;&#8250;&nbsp;
+<a href="../index.html">User Guide Home</a> &nbsp;&#8250;&nbsp;
+Shopping Cart Class
+</td>
+<td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="codeigniter.com/user_guide/" />Search User Guide&nbsp; <input type="text" class="input" style="width:200px;" name="q" id="q" size="31" maxlength="255" value="" />&nbsp;<input type="submit" class="submit" name="sa" value="Go" /></form></td>
+</tr>
+</table>
+<!-- END BREADCRUMB -->
+
+<br clear="all" />
+
+
+<!-- START CONTENT -->
+<div id="content">
+
+
+<h1>Shopping Cart Class</h1>
+
+<p>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.</p>
+
+<p>Please note that the Cart Class ONLY provides the core "cart" functionality.  It does not provide shipping, credit card authorization, or other processing components.</p>
+
+
+<h2>Initializing the Shopping Cart Class</h2>
+
+<p><strong>Important:</strong> The Cart class utilizes CodeIgniter's
+<a href="sessions.html">Session Class</a>  to save the cart information to a database, so before using the Cart class you must set up a database table
+as indicated in the <a href="sessions.html">Session Documentation</a> , and set the session preferences in your <kbd>application/config/config.php</kbd> file to utilize a database.</p>
+
+<p>To initialize the Shopping Cart Class in your controller constructor, use the <dfn>$this->load->library</dfn> function:</p>
+
+<code>$this->load->library('cart');</code>
+<p>Once loaded, the Cart object will be available using: <dfn>$this->cart</dfn></p>
+
+<p class="important"><strong>Note:</strong> The Cart Class will load and initialize the Session Class automatically, so unless you are using sessions elsewhere in your application, you do not need to load the Session class.</p>
+
+<h2>Adding an Item to The Cart</h2>
+
+<p>To add an item to the shopping cart, simply pass an array with the product information to the <dfn>$this->cart->insert()</dfn> function, as shown below:</p>
+
+<code>
+$data = array(<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'id'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; => 'sku_123ABC',<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'qty'&nbsp;&nbsp;&nbsp;&nbsp; => 1,<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'price'&nbsp;&nbsp; => 39.95,<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'name'&nbsp;&nbsp;&nbsp; => 'T-Shirt',<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'options' => array('Size' => 'L', 'Color' => 'Red')<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;);<br />
+<br />
+
+$this->cart->insert($data);
+
+</code>
+
+<p class="important"><strong>Important:</strong> The first four array indexes above (<dfn>id</dfn>, <dfn>qty</dfn>, <dfn>price</dfn>, and <dfn>name</dfn>) are <strong>required</strong>.
+If you omit any of them the data will not be saved to the cart. The fifth index (<dfn>options</dfn>) is optional.
+It is intended to be used in cases where your product has options associated with it. Use an array for options, as shown above.</p>
+
+<p>The five reserved indexes are:</p>
+
+<ul>
+<li><strong>id</strong> - Each product in your store must have a unique identifier. Typically this will be an "sku" or other such identifier.</li>
+<li><strong>qty</strong> - The quantity being purchased.
+<li><strong>price</strong> - The price of the item.
+<li><strong>name</strong> - The name of the item.
+<li><strong>options</strong> - Any additional attributes that are needed to identify the product.  These must be passed via an array.
+</ul>
+
+<p>In addition to the five indexes above, there are two reserved words: <dfn>rowid</dfn> and <dfn>subtotal</dfn>.  These are used internally by the Cart class, so
+please do NOT use those words as index names when inserting data into the cart.</p>
+
+<p>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.</p>
+
+
+<h2>Adding Multiple Items to The Cart</h2>
+
+<p>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.</p>
+
+
+<code>
+$data = array(<br />
+
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;array(<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'id'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; => 'sku_123ABC',<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'qty'&nbsp;&nbsp;&nbsp;&nbsp; => 1,<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'price'&nbsp;&nbsp; => 39.95,<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'name'&nbsp;&nbsp;&nbsp; => 'T-Shirt',<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'options' => array('Size' => 'L', 'Color' => 'Red')<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;),<br />
+
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;array(<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'id'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; => 'sku_567ZYX',<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'qty'&nbsp;&nbsp;&nbsp;&nbsp; => 1,<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'price'&nbsp;&nbsp; => 9.95,<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'name'&nbsp;&nbsp;&nbsp; => 'Coffee Mug'<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;),<br />
+
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;array(<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'id'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; => 'sku_965QRS',<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'qty'&nbsp;&nbsp;&nbsp;&nbsp; => 1,<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'price'&nbsp;&nbsp; => 29.95,<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'name'&nbsp;&nbsp;&nbsp; => 'Shot Glass'<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;)<br />
+
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;);<br />
+<br />
+
+$this->cart->insert($data);
+
+</code>
+
+
+
+
+<h2>Displaying the Cart</h2>
+
+<p>To display the cart you will create a <a href="../general/views.html">view file</a> with code similar to the one shown below.</p>
+
+<p>Please note that this example uses the <a href="../helpers/form_helper.html">form helper</a>.</p>
+
+
+<textarea class="textarea" style="width:100%" cols="50" rows="55">
+&lt;?php echo form_open('path/to/controller/update/function'); ?>
+
+&lt;table cellpadding="6" cellspacing="1" style="width:100%" border="0">
+
+&lt;tr>
+  &lt;th>QTY&lt;/th>
+  &lt;th>Item Description&lt;/th>
+  &lt;th style="text-align:right">Item Price&lt;/th>
+  &lt;th style="text-align:right">Sub-Total&lt;/th>
+&lt;/tr>
+
+&lt;?php $i = 1; ?>
+
+&lt;?php foreach ($this->cart->contents() as $items): ?>
+
+       &lt;?php echo form_hidden($i.'[rowid]', $items['rowid']); ?>
+
+       &lt;tr>
+         &lt;td>&lt;?php echo form_input(array('name' => $i.'[qty]', 'value' => $items['qty'], 'maxlength' => '3', 'size' => '5')); ?>&lt;/td>
+         &lt;td>
+               &lt;?php echo $items['name']; ?>
+
+                       &lt;?php if ($this->cart->has_options($items['rowid']) == TRUE): ?>
+
+                               &lt;p>
+                                       &lt;?php foreach ($this->cart->product_options($items['rowid']) as $option_name => $option_value): ?>
+
+                                               &lt;strong>&lt;?php echo $option_name; ?>:&lt;/strong> &lt;?php echo $option_value; ?>&lt;br />
+
+                                       &lt;?php endforeach; ?>
+                               &lt;/p>
+
+                       &lt;?php endif; ?>
+
+         &lt;/td>
+         &lt;td style="text-align:right">&lt;?php echo $this->cart->format_number($items['price']); ?>&lt;/td>
+         &lt;td style="text-align:right">$&lt;?php echo $this->cart->format_number($items['subtotal']); ?>&lt;/td>
+       &lt;/tr>
+
+&lt;?php $i++; ?>
+
+&lt;?php endforeach; ?>
+
+&lt;tr>
+  &lt;td colspan="2">&nbsp;&lt;/td>
+  &lt;td class="right">&lt;strong>Total&lt;/strong>&lt;/td>
+  &lt;td class="right">$&lt;?php echo $this->cart->format_number($this->cart->total()); ?>&lt;/td>
+&lt;/tr>
+
+&lt;/table>
+
+&lt;p>&lt;?php echo form_submit('', 'Update your Cart'); ?>&lt;/p>
+</textarea>
+
+
+
+
+<h2>Updating The Cart</h2>
+
+<p>To update the information in your cart, you must pass an array containing the <kbd>Row ID</kbd> and quantity to the <dfn>$this->cart->update()</dfn> function:</p>
+
+<p class="important"><strong>Note:</strong> If the quantity is set to zero, the item will be removed from the cart.</p>
+
+<code>
+$data = array(<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'rowid' => 'b99ccdf16028f015540f341130b6d8ec',<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'qty'&nbsp;&nbsp; => 3<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;);<br />
+<br />
+
+$this->cart->update($data);
+<br /><br />
+// Or a multi-dimensional array<br /><br />
+$data = array(<br />
+
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;array(<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'rowid'&nbsp;&nbsp; => 'b99ccdf16028f015540f341130b6d8ec',<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'qty'&nbsp;&nbsp;&nbsp;&nbsp; => 3<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;),<br />
+
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;array(<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'rowid'&nbsp;&nbsp; => 'xw82g9q3r495893iajdh473990rikw23',<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'qty'&nbsp;&nbsp;&nbsp;&nbsp; => 4<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;),<br />
+
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;array(<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'rowid'&nbsp;&nbsp; => 'fh4kdkkkaoe30njgoe92rkdkkobec333',<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'qty'&nbsp;&nbsp;&nbsp;&nbsp; => 2<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;)<br />
+
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;);<br />
+<br />
+
+$this->cart->update($data);
+
+
+
+
+</code>
+
+<p><strong>What is a Row ID?</strong>&nbsp; The <kbd>row ID</kbd> 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.</p>
+
+<p>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.</p>
+
+<p>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
+with the "row ID", other then making sure your "view cart" page contains this information in a hidden form field, and making sure it gets passed to the update
+function when the update form is submitted. Please examine the construction of the "view cart" page above for more information.</p>
+
+
+
+<p>&nbsp;<br /></p>
+
+
+<h1>Function Reference</h1>
+
+<h2>$this->cart->insert();</h2>
+
+<p>Permits you to add items to the shopping cart, as outlined above.</p>
+
+
+<h2>$this->cart->update();</h2>
+
+<p>Permits you to update items in the shopping cart, as outlined above.</p>
+
+
+<h2>$this->cart->total();</h2>
+
+<p>Displays the total amount in the cart.</p>
+
+
+<h2>$this->cart->total_items();</h2>
+
+<p>Displays the total number of items in the cart.</p>
+
+
+<h2>$this->cart->contents();</h2>
+
+<p>Returns an array containing everything in the cart.</p>
+
+
+
+<h2>$this->cart->has_options(rowid);</h2>
+
+<p>Returns TRUE (boolean) if a particular row in the cart contains options.  This function is designed to be used in a loop with <dfn>$this->cart->contents()</dfn>, since you must pass the <kbd>rowid</kbd> to this function, as shown in the <dfn>Displaying the Cart</dfn> example above.</p>
+
+
+<h2>$this->cart->product_options(rowid);</h2>
+
+<p>Returns an array of options for a particular product. This function is designed to be used in a loop with <dfn>$this->cart->contents()</dfn>, since you must pass the <kbd>rowid</kbd> to this function, as shown in the <dfn>Displaying the Cart</dfn> example above.</p>
+
+
+
+<h2>$this->cart->destroy();</h2>
+
+<p>Permits you to destroy the cart.  This function will likely be called when you are finished processing the customer's order.</p>
+
+
+
+
+</div>
+<!-- END CONTENT -->
+
+
+<div id="footer">
+<p>
+Previous Topic:&nbsp;&nbsp;<a href="calendar.html">Calendar Class</a>
+&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+<a href="#top">Top of Page</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+<a href="../index.html">User Guide Home</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+Next Topic:&nbsp;&nbsp;<a href="config.html">Config Class</a>
+</p>
+<p><a href="http://codeigniter.com">CodeIgniter</a> &nbsp;&middot;&nbsp; Copyright &#169; 2006 - 2011 &nbsp;&middot;&nbsp; <a href="http://ellislab.com/">EllisLab, Inc.</a></p>
+</div>
+
+</body>
+</html>
\ No newline at end of file
diff --git a/user_guide/libraries/config.html b/user_guide/libraries/config.html
new file mode 100755 (executable)
index 0000000..2433ec4
--- /dev/null
@@ -0,0 +1,217 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head>
+
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+<title>Config Class : CodeIgniter User Guide</title>
+
+<style type='text/css' media='all'>@import url('../userguide.css');</style>
+<link rel='stylesheet' type='text/css' media='all' href='../userguide.css' />
+
+<script type="text/javascript" src="../nav/nav.js"></script>
+<script type="text/javascript" src="../nav/prototype.lite.js"></script>
+<script type="text/javascript" src="../nav/moo.fx.js"></script>
+<script type="text/javascript" src="../nav/user_guide_menu.js"></script>
+
+<meta http-equiv='expires' content='-1' />
+<meta http-equiv= 'pragma' content='no-cache' />
+<meta name='robots' content='all' />
+<meta name='author' content='ExpressionEngine Dev Team' />
+<meta name='description' content='CodeIgniter User Guide' />
+
+</head>
+<body>
+
+<!-- START NAVIGATION -->
+<div id="nav"><div id="nav_inner"><script type="text/javascript">create_menu('../');</script></div></div>
+<div id="nav2"><a name="top"></a><a href="javascript:void(0);" onclick="myHeight.toggle();"><img src="../images/nav_toggle_darker.jpg" width="154" height="43" border="0" title="Toggle Table of Contents" alt="Toggle Table of Contents" /></a></div>
+<div id="masthead">
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td><h1>CodeIgniter User Guide Version 2.0.2</h1></td>
+<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
+</tr>
+</table>
+</div>
+<!-- END NAVIGATION -->
+
+
+<!-- START BREADCRUMB -->
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td id="breadcrumb">
+<a href="http://codeigniter.com/">CodeIgniter Home</a> &nbsp;&#8250;&nbsp;
+<a href="../index.html">User Guide Home</a> &nbsp;&#8250;&nbsp;
+Config Class
+</td>
+<td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="codeigniter.com/user_guide/" />Search User Guide&nbsp; <input type="text" class="input" style="width:200px;" name="q" id="q" size="31" maxlength="255" value="" />&nbsp;<input type="submit" class="submit" name="sa" value="Go" /></form></td>
+</tr>
+</table>
+<!-- END BREADCRUMB -->
+
+<br clear="all" />
+
+
+<!-- START CONTENT -->
+<div id="content">
+
+
+<h1>Config Class</h1>
+
+<p>The Config class provides a means to retrieve configuration preferences.  These preferences can
+come from the default config file (<samp>application/config/config.php</samp>) or from your own custom config files.</p>
+
+<p class="important"><strong>Note:</strong> This class is initialized automatically by the system so there is no need to do it manually.</p>
+
+
+<h2>Anatomy of a Config File</h2>
+
+<p>By default, CodeIgniter has one primary config file, located at <samp>application/config/config.php</samp>.  If you open the file using
+your text editor you'll see that config items are stored in an array called <var>$config</var>.</p>
+
+<p>You can add your own config items to
+this file, or if you prefer to keep your configuration items separate (assuming you even need config items),
+simply create your own file and save it in <dfn>config</dfn> folder.</p>
+
+<p><strong>Note:</strong> If you do create your own config files use the same format as the primary one, storing your items in
+an array called  <var>$config</var>. CodeIgniter will intelligently manage these files so there will be no conflict even though
+the array has the same name (assuming an array index is not named the same as another).</p>
+
+<h2>Loading a Config File</h2>
+
+<p><strong>Note:</strong> CodeIgniter automatically loads the primary config file (<samp>application/config/config.php</samp>),
+so you will only need to load a config file if you have created your own.</p>
+
+<p>There are two ways to load a config file:</p>
+
+<ol><li><strong>Manual Loading</strong>
+
+<p>To load one of your custom config files you will use the following function within the <a href="../general/controllers.html">controller</a> that needs it:</p>
+
+<code>$this->config->load('<var>filename</var>');</code>
+
+<p>Where <var>filename</var> is the name of your config file, without the .php file extension.</p>
+
+<p>If you need to load multiple config files normally they will be merged into one master config array.  Name collisions can occur, however, if
+you have identically named array indexes in different config files.  To avoid collisions you can set the second parameter to <kbd>TRUE</kbd>
+and each config file will be stored in an array index corresponding to the name of the config file. Example:</p>
+
+<code>
+// Stored in an array with this prototype:  $this->config['blog_settings'] = $config<br />
+$this->config->load('<var>blog_settings</var>', <kbd>TRUE</kbd>);</code>
+
+<p>Please see the section entitled <dfn>Fetching Config Items</dfn> below to learn how to retrieve config items set this way.</p>
+
+<p>The third parameter allows you to suppress errors in the event that a config file does not exist:</p>
+
+<code>$this->config->load('<var>blog_settings</var>', <dfn>FALSE</dfn>, <kbd>TRUE</kbd>);</code>
+
+</li>
+<li><strong>Auto-loading</strong>
+
+<p>If you find that you need a particular config file globally, you can have it loaded automatically by the system.  To do this,
+open the <strong>autoload.php</strong> file, located at <samp>application/config/autoload.php</samp>, and add your config file as
+indicated in the file.</p>
+</li>
+</ol>
+
+
+<h2>Fetching Config Items</h2>
+
+<p>To retrieve an item from your config file, use the following function:</p>
+
+<code>$this->config->item('<var>item name</var>');</code>
+
+<p>Where <var>item name</var> is the $config array index you want to retrieve. For example, to fetch your language choice you'll do this:</p>
+
+<code>$lang = $this->config->item('language');</code>
+
+<p>The function returns FALSE (boolean) if the item you are trying to fetch does not exist.</p>
+
+<p>If you are using the second parameter of the <kbd>$this->config->load</kbd> function in order to assign your config items to a specific index
+you can retrieve it by specifying the index name in the second parameter of the <kbd>$this->config->item()</kbd> function.  Example:</p>
+
+<code>
+// Loads a config file named blog_settings.php and assigns it to an index named "blog_settings"<br />
+$this->config->load('<var>blog_settings</var>', <kbd>TRUE</kbd>);<br /><br />
+
+// Retrieve a config item named site_name contained within the blog_settings array<br />
+$site_name = $this->config->item('<dfn>site_name</dfn>', '<var>blog_settings</var>');<br /><br />
+
+// An alternate way to specify the same item:<br />
+$blog_config = $this->config->item('<var>blog_settings</var>');<br />
+$site_name = $blog_config['site_name'];</code>
+
+<h2>Setting a Config Item</h2>
+
+<p>If you would like to dynamically set a config item or change an existing one, you can do so using:</p>
+
+<code>$this->config->set_item('<var>item_name</var>', '<var>item_value</var>');</code>
+
+<p>Where <var>item_name</var> is the $config array index you want to change, and <var>item_value</var> is its value.</p>
+
+<a name="environments"></a>
+<h2>Environments</h2>
+
+<p>
+    You may load different configuration files depending on the current environment.
+    The <kbd>ENVIRONMENT</kbd> constant is defined in index.php, and is described
+    in detail in the <a href="../general/environments.html">Handling Environments</a>
+    section.
+</p>
+
+<p>
+    To create an environment-specific configuration file,
+    create or copy a configuration file in application/config/{ENVIRONMENT}/{FILENAME}.php
+</p>
+
+<p>For example, to create a production-only config.php, you would:</p>
+
+<ol>
+    <li>Create the directory application/config/production/</li>
+    <li>Copy your existing config.php into the above directory</li>
+    <li>Edit application/config/production/config.php so it contains your production settings</li>
+</ol>
+
+<p>
+    When you set the <kbd>ENVIRONMENT</kbd> constant to 'production', the settings
+    for your new production-only config.php will be loaded.
+</p>
+
+<p>You can place the following configuration files in environment-specific folders:</p>
+       
+<ul>
+<li>Default CodeIgniter configuration files</li>
+<li>Your own custom configuration files</li>
+</ul>
+
+<p><strong>Note:</strong> 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 <samp>application/config/</samp>) is loaded. This means you are not obligated to place <strong>all</strong> of your configuration files in an environment folder &minus; only the files that change per environment.</p>
+
+<h2>Helper Functions</h2>
+
+<p>The config class has the following helper functions:</p>
+
+<h2>$this->config->site_url();</h2>
+<p>This function retrieves the URL to your site, along with the "index" value you've specified in the config file.</p>
+
+<h2>$this->config->system_url();</h2>
+<p>This function retrieves the URL to your <dfn>system folder</dfn>.</p>
+
+
+</div>
+<!-- END CONTENT -->
+
+
+<div id="footer">
+<p>
+Previous Topic:&nbsp;&nbsp;<a href="calendar.html">Calendaring Class</a>
+&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+<a href="#top">Top of Page</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+<a href="../index.html">User Guide Home</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+Next Topic:&nbsp;&nbsp;<a href="../database/index.html">Database Class</a>
+</p>
+<p><a href="http://codeigniter.com">CodeIgniter</a> &nbsp;&middot;&nbsp; Copyright &#169; 2006 - 2011 &nbsp;&middot;&nbsp; <a href="http://ellislab.com/">EllisLab, Inc.</a></p>
+</div>
+
+</body>
+</html>
diff --git a/user_guide/libraries/email.html b/user_guide/libraries/email.html
new file mode 100755 (executable)
index 0000000..5a8814d
--- /dev/null
@@ -0,0 +1,307 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head>
+
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+<title>Email Class : CodeIgniter User Guide</title>
+
+<style type='text/css' media='all'>@import url('../userguide.css');</style>
+<link rel='stylesheet' type='text/css' media='all' href='../userguide.css' />
+
+<script type="text/javascript" src="../nav/nav.js"></script>
+<script type="text/javascript" src="../nav/prototype.lite.js"></script>
+<script type="text/javascript" src="../nav/moo.fx.js"></script>
+<script type="text/javascript" src="../nav/user_guide_menu.js"></script>
+
+<meta http-equiv='expires' content='-1' />
+<meta http-equiv= 'pragma' content='no-cache' />
+<meta name='robots' content='all' />
+<meta name='author' content='ExpressionEngine Dev Team' />
+<meta name='description' content='CodeIgniter User Guide' />
+
+</head>
+<body>
+
+<!-- START NAVIGATION -->
+<div id="nav"><div id="nav_inner"><script type="text/javascript">create_menu('../');</script></div></div>
+<div id="nav2"><a name="top"></a><a href="javascript:void(0);" onclick="myHeight.toggle();"><img src="../images/nav_toggle_darker.jpg" width="154" height="43" border="0" title="Toggle Table of Contents" alt="Toggle Table of Contents" /></a></div>
+<div id="masthead">
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td><h1>CodeIgniter User Guide Version 2.0.2</h1></td>
+<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
+</tr>
+</table>
+</div>
+<!-- END NAVIGATION -->
+
+
+<!-- START BREADCRUMB -->
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td id="breadcrumb">
+<a href="http://codeigniter.com/">CodeIgniter Home</a> &nbsp;&#8250;&nbsp;
+<a href="../index.html">User Guide Home</a> &nbsp;&#8250;&nbsp;
+Email Class
+</td>
+<td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="codeigniter.com/user_guide/" />Search User Guide&nbsp; <input type="text" class="input" style="width:200px;" name="q" id="q" size="31" maxlength="255" value="" />&nbsp;<input type="submit" class="submit" name="sa" value="Go" /></form></td>
+</tr>
+</table>
+<!-- END BREADCRUMB -->
+
+<br clear="all" />
+
+
+<!-- START CONTENT -->
+<div id="content">
+
+
+<h1>Email Class</h1>
+
+<p>CodeIgniter's robust Email Class supports the following features:</p>
+
+
+<ul>
+<li>Multiple Protocols: Mail, Sendmail, and SMTP</li>
+<li>Multiple recipients</li>
+<li>CC and BCCs</li>
+<li>HTML or Plaintext email</li>
+<li>Attachments</li>
+<li>Word wrapping</li>
+<li>Priorities</li>
+<li>BCC Batch Mode, enabling large email lists to be broken into small BCC batches.</li>
+<li>Email Debugging tools</li>
+</ul>
+
+
+<h2>Sending Email</h2>
+
+<p>Sending email is not only simple, but you can configure it on the fly or set your preferences in a config file.</p>
+
+<p>Here is a basic example demonstrating how you might send email.  Note:  This example assumes you are sending the email from one of your
+<a href="../general/controllers.html">controllers</a>.</p>
+
+<code>$this->load->library('email');<br />
+<br />
+$this->email->from('your@example.com', 'Your Name');<br />
+$this->email->to('someone@example.com'); <br />
+$this->email->cc('another@another-example.com'); <br />
+$this->email->bcc('them@their-example.com'); <br />
+<br />
+$this->email->subject('Email Test');<br />
+$this->email->message('Testing the email class.');     <br />
+<br />
+$this->email->send();<br />
+<br />
+echo $this->email->print_debugger();</code>
+
+
+
+
+<h2>Setting Email Preferences</h2>
+
+<p>There are 17 different preferences available to tailor how your email messages are sent. You can either set them manually
+as described here, or automatically via preferences stored in your config file, described below:</p>
+
+<p>Preferences are set by passing an array of preference values to the email <dfn>initialize</dfn> function.  Here is an example of how you might set some preferences:</p>
+
+<code>$config['protocol'] = 'sendmail';<br />
+$config['mailpath'] = '/usr/sbin/sendmail';<br />
+$config['charset'] = 'iso-8859-1';<br />
+$config['wordwrap'] = TRUE;<br />
+<br />
+$this->email->initialize($config);</code>
+
+<p><strong>Note:</strong> Most of the preferences have default values that will be used if you do not set them.</p
+
+><h3>Setting Email Preferences in a Config File</h3>
+
+<p>If you prefer not to set preferences using the above method, you can instead put them into a config file.
+Simply create a new file called the <var>email.php</var>,  add the <var>$config</var>
+array in that file. Then save the file at <var>config/email.php</var> and it will be used automatically. You
+will NOT need to use the <dfn>$this->email->initialize()</dfn> function if you save your preferences in a config file.</p>
+
+
+
+
+<h2>Email Preferences</h2>
+
+<p>The following is a list of all the preferences that can be set when sending email.</p>
+
+
+<table cellpadding="0" cellspacing="1" border="0" style="width:100%" class="tableborder">
+<tr>
+<th>Preference</th>
+<th>Default&nbsp;Value</th>
+<th>Options</th>
+<th>Description</th>
+</tr><tr>
+<td class="td"><strong>useragent</strong></td><td class="td">CodeIgniter</td><td class="td">None</td><td class="td">The "user agent".</td>
+</tr><tr>
+<td class="td"><strong>protocol</strong></td><td class="td">mail</td><td class="td">mail, sendmail, or smtp</td><td class="td">The mail sending protocol.</td>
+</tr><tr>
+<td class="td"><strong>mailpath</strong></td><td class="td">/usr/sbin/sendmail</td><td class="td">None</td><td class="td">The server path to Sendmail.</td>
+</tr><tr>
+<td class="td"><strong>smtp_host</strong></td><td class="td">No Default</td><td class="td">None</td><td class="td">SMTP Server Address.</td>
+</tr><tr>
+<td class="td"><strong>smtp_user</strong></td><td class="td">No Default</td><td class="td">None</td><td class="td">SMTP Username.</td>
+</tr><tr>
+<td class="td"><strong>smtp_pass</strong></td><td class="td">No Default</td><td class="td">None</td><td class="td">SMTP Password.</td>
+</tr><tr>
+<td class="td"><strong>smtp_port</strong></td><td class="td">25</td><td class="td">None</td><td class="td">SMTP Port.</td>
+</tr><tr>
+<td class="td"><strong>smtp_timeout</strong></td><td class="td">5</td><td class="td">None</td><td class="td">SMTP Timeout (in seconds).</td>
+</tr><tr>
+<td class="td"><strong>wordwrap</strong></td><td class="td">TRUE</td><td class="td">TRUE or FALSE (boolean)</td><td class="td">Enable word-wrap.</td>
+</tr><tr>
+<td class="td"><strong>wrapchars</strong></td><td class="td">76</td><td class="td"> </td><td class="td">Character count to wrap at.</td>
+</tr><tr>
+<td class="td"><strong>mailtype</strong></td><td class="td">text</td><td class="td">text or html</td><td class="td">Type of mail. If you send HTML email you must send it as a complete web page.  Make sure you don't have any relative links or relative image paths otherwise they will not work.</td>
+</tr><tr>
+<td class="td"><strong>charset</strong></td><td class="td">utf-8</td><td class="td"></td><td class="td">Character set (utf-8, iso-8859-1, etc.).</td>
+</tr><tr>
+<td class="td"><strong>validate</strong></td><td class="td">FALSE</td><td class="td">TRUE or FALSE  (boolean)</td><td class="td">Whether to validate the email address.</td>
+</tr><tr>
+<td class="td"><strong>priority</strong></td><td class="td">3</td><td class="td">1, 2, 3, 4, 5</td><td class="td">Email Priority. 1 = highest.  5 = lowest.  3 = normal.</td>
+</tr>
+<tr>
+       <td class="td"><strong>crlf</strong></td>
+       <td class="td">\n</td>
+       <td class="td">&quot;\r\n&quot; or &quot;\n&quot; or &quot;\r&quot;</td>
+       <td class="td">Newline character. (Use &quot;\r\n&quot; to comply with RFC 822).</td>
+</tr>
+<tr>
+<td class="td"><strong>newline</strong></td><td class="td">\n</td>
+<td class="td">"\r\n" or "\n" or &quot;\r&quot;</td><td class="td">Newline character. (Use "\r\n" to comply with RFC 822).</td>
+</tr><tr>
+<td class="td"><strong>bcc_batch_mode</strong></td><td class="td">FALSE</td><td class="td">TRUE or FALSE (boolean)</td><td class="td">Enable BCC Batch Mode.</td>
+</tr><tr>
+<td class="td"><strong>bcc_batch_size</strong></td><td class="td">200</td><td class="td">None</td><td class="td">Number of emails in each BCC batch.</td>
+</tr>
+</table>
+
+
+<h2>Email Function Reference</h2>
+
+<h3>$this->email->from()</h3>
+<p>Sets the email address and name of the person sending the email:</p>
+<code>$this->email->from('<var>you@example.com</var>', '<var>Your Name</var>');</code>
+
+<h3>$this->email->reply_to()</h3>
+<p>Sets the reply-to address.  If the information is not provided the information in the "from" function is used. Example:</p>
+<code>$this->email->reply_to('<var>you@example.com</var>', '<var>Your Name</var>');</code>
+
+
+<h3>$this->email->to()</h3>
+<p>Sets the email address(s) of the recipient(s).  Can be a single email, a comma-delimited list or an array:</p>
+
+<code>$this->email->to('<var>someone@example.com</var>');</code>
+<code>$this->email->to('<var>one@example.com</var>, <var>two@example.com</var>, <var>three@example.com</var>');</code>
+
+<code>$list = array('<var>one@example.com</var>', '<var>two@example.com</var>', '<var>three@example.com</var>');<br />
+<br />
+$this->email->to(<var>$list</var>);</code>
+
+<h3>$this->email->cc()</h3>
+<p>Sets the CC email address(s). Just like the "to", can be a single email, a comma-delimited list or an array.</p>
+
+<h3>$this->email->bcc()</h3>
+<p>Sets the BCC email address(s). Just like the "to", can be a single email, a comma-delimited list or an array.</p>
+
+
+<h3>$this->email->subject()</h3>
+<p>Sets the email subject:</p>
+<code>$this->email->subject('<var>This is my subject</var>');</code>
+
+<h3>$this->email->message()</h3>
+<p>Sets the email message body:</p>
+<code>$this->email->message('<var>This is my message</var>');</code>
+
+<h3>$this->email->set_alt_message()</h3>
+<p>Sets the alternative email message body:</p>
+<code>$this->email->set_alt_message('<var>This is the alternative message</var>');</code>
+
+<p>This is an optional message string which can be used if you send HTML formatted email.  It lets you specify an alternative
+message with no HTML formatting which is added to the header string for people who do not accept HTML email.
+If you do not set your own message CodeIgniter will extract the message from your HTML email and strip the tags.</p>
+
+
+
+<h3>$this->email->clear()</h3>
+<p>Initializes all the email variables to an empty state.  This function is intended for use if you run the email sending function
+in a loop, permitting the data to be reset between cycles.</p>
+<code>foreach ($list as $name => $address)<br />
+{<br />
+&nbsp;&nbsp;&nbsp;&nbsp;$this->email->clear();<br /><br />
+
+&nbsp;&nbsp;&nbsp;&nbsp;$this->email->to($address);<br />
+&nbsp;&nbsp;&nbsp;&nbsp;$this->email->from('your@example.com');<br />
+&nbsp;&nbsp;&nbsp;&nbsp;$this->email->subject('Here is your info '.$name);<br />
+&nbsp;&nbsp;&nbsp;&nbsp;$this->email->message('Hi '.$name.' Here is the info you requested.');<br />
+&nbsp;&nbsp;&nbsp;&nbsp;$this->email->send();<br />
+}</code>
+
+<p>If you set the parameter to TRUE any attachments will be cleared as well:</p>
+
+<code>$this->email->clear(TRUE);</code>
+
+
+<h3>$this->email->send()</h3>
+<p>The Email sending function. Returns boolean TRUE or FALSE based on success or failure, enabling it to be used
+conditionally:</p>
+
+<code>if ( ! $this->email->send())<br />
+{<br />
+&nbsp;&nbsp;&nbsp;&nbsp;// Generate error<br />
+}</code>
+
+
+<h3>$this->email->attach()</h3>
+<p>Enables you to send an attachment. Put the file path/name in the first parameter. Note: Use a file path, not a URL.
+For multiple attachments use the function multiple times. For example:</p>
+
+<code>$this->email->attach('/path/to/photo1.jpg');<br />
+$this->email->attach('/path/to/photo2.jpg');<br />
+$this->email->attach('/path/to/photo3.jpg');<br />
+<br />
+$this->email->send();</code>
+
+
+<h3>$this->email->print_debugger()</h3>
+<p>Returns a string containing any server messages, the email headers, and the email messsage.  Useful for debugging.</p>
+
+
+<h2>Overriding Word Wrapping</h2>
+
+<p>If you have word wrapping enabled (recommended to comply with RFC 822) and you have a very long link in your email it can
+get wrapped too, causing it to become un-clickable by the person receiving it.  CodeIgniter lets you manually override
+word wrapping within part of your message like this:</p>
+
+<code>The text of your email that<br />
+gets wrapped normally.<br />
+<br />
+<var>{unwrap}</var>http://example.com/a_long_link_that_should_not_be_wrapped.html<var>{/unwrap}</var><br />
+<br />
+More text that will be<br />
+wrapped normally.</code>
+
+<p>Place the item you do not want word-wrapped between: <var>{unwrap}</var> <var>{/unwrap}</var></p>
+
+
+</div>
+<!-- END CONTENT -->
+
+
+<div id="footer">
+<p>
+Previous Topic:&nbsp;&nbsp;<a href="../database/index.html">Database Class</a>
+&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+<a href="#top">Top of Page</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+<a href="../index.html">User Guide Home</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+Next Topic:&nbsp;&nbsp;<a href="encryption.html">Encryption Class</a>
+</p>
+<p><a href="http://codeigniter.com">CodeIgniter</a> &nbsp;&middot;&nbsp; Copyright &#169; 2006 - 2011 &nbsp;&middot;&nbsp; <a href="http://ellislab.com/">EllisLab, Inc.</a></p>
+</div>
+
+</body>
+</html>
\ No newline at end of file
diff --git a/user_guide/libraries/encryption.html b/user_guide/libraries/encryption.html
new file mode 100755 (executable)
index 0000000..6009931
--- /dev/null
@@ -0,0 +1,224 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head>
+
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+<title>Encryption Class : CodeIgniter User Guide</title>
+
+<style type='text/css' media='all'>@import url('../userguide.css');</style>
+<link rel='stylesheet' type='text/css' media='all' href='../userguide.css' />
+
+<script type="text/javascript" src="../nav/nav.js"></script>
+<script type="text/javascript" src="../nav/prototype.lite.js"></script>
+<script type="text/javascript" src="../nav/moo.fx.js"></script>
+<script type="text/javascript" src="../nav/user_guide_menu.js"></script>
+
+<meta http-equiv='expires' content='-1' />
+<meta http-equiv= 'pragma' content='no-cache' />
+<meta name='robots' content='all' />
+<meta name='author' content='ExpressionEngine Dev Team' />
+<meta name='description' content='CodeIgniter User Guide' />
+
+</head>
+<body>
+
+<!-- START NAVIGATION -->
+<div id="nav"><div id="nav_inner"><script type="text/javascript">create_menu('../');</script></div></div>
+<div id="nav2"><a name="top"></a><a href="javascript:void(0);" onclick="myHeight.toggle();"><img src="../images/nav_toggle_darker.jpg" width="154" height="43" border="0" title="Toggle Table of Contents" alt="Toggle Table of Contents" /></a></div>
+<div id="masthead">
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td><h1>CodeIgniter User Guide Version 2.0.2</h1></td>
+<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
+</tr>
+</table>
+</div>
+<!-- END NAVIGATION -->
+
+
+<!-- START BREADCRUMB -->
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td id="breadcrumb">
+<a href="http://codeigniter.com/">CodeIgniter Home</a> &nbsp;&#8250;&nbsp;
+<a href="../index.html">User Guide Home</a> &nbsp;&#8250;&nbsp;
+Encryption Class
+</td>
+<td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="codeigniter.com/user_guide/" />Search User Guide&nbsp; <input type="text" class="input" style="width:200px;" name="q" id="q" size="31" maxlength="255" value="" />&nbsp;<input type="submit" class="submit" name="sa" value="Go" /></form></td>
+</tr>
+</table>
+<!-- END BREADCRUMB -->
+
+<br clear="all" />
+
+
+<!-- START CONTENT -->
+<div id="content">
+
+
+<h1>Encryption Class</h1>
+
+<p>The Encryption Class provides two-way data encryption.  It uses a scheme that either compiles
+the message using a randomly hashed bitwise XOR encoding scheme, or is encrypted using
+the Mcrypt library.  If Mcrypt is not available on your server the encoded message will
+still provide a reasonable degree of security for encrypted sessions or other such "light" purposes.
+If Mcrypt is available, you'll be provided with a high degree of security appropriate for storage.</p>
+
+
+<h2>Setting your Key</h2>
+
+<p>A <em>key</em> is a piece of information that controls the cryptographic process and permits an encrypted string to be decoded.
+In fact, the key you chose will provide the <strong>only</strong> means to decode data that was encrypted with that key,
+so not only must you choose the key carefully, you must never change it if you intend use it for persistent data.</p>
+
+<p>It goes without saying that you should guard your key carefully.
+Should someone gain access to your key, the data will be easily decoded.  If your server is not totally under your control
+it's impossible to ensure key security so you may want to think carefully before using it for anything
+that requires high security, like storing credit card numbers.</p>
+
+<p>To take maximum advantage of the encryption algorithm, your key should be 32 characters in length (128 bits).
+The key should be as random a string as you can concoct, with numbers and uppercase and lowercase letters.
+Your key should <strong>not</strong> be a simple text string. In order to be cryptographically secure it
+needs to be as random as possible.</p>
+
+<p>Your key can be either stored in your <dfn>application/config/config.php</dfn>, or you can design your own
+storage mechanism and pass the key dynamically when encoding/decoding.</p>
+
+<p>To save your key to your <dfn>application/config/config.php</dfn>, open the file and set:</p>
+<code>$config['encryption_key'] = "YOUR KEY";</code>
+
+
+<h2>Message Length</h2>
+
+<p>It's important for you to know that the encoded messages the encryption function generates will be approximately 2.6 times longer than the original
+message.  For example, if you encrypt the string "my super secret data", which is 21 characters in length, you'll end up
+with an encoded string that is roughly 55 characters (we say "roughly" because the encoded string length increments in
+64 bit clusters, so it's not exactly linear).  Keep this information in mind when selecting your data storage mechanism.  Cookies,
+for example, can only hold 4K of information.</p>
+
+
+<h2>Initializing the Class</h2>
+
+<p>Like most other classes in CodeIgniter, the Encryption class is initialized in your controller using the <dfn>$this->load->library</dfn> function:</p>
+
+<code>$this->load->library('encrypt');</code>
+<p>Once loaded, the Encrypt library object will be available using: <dfn>$this->encrypt</dfn></p>
+
+
+<h2>$this->encrypt->encode()</h2>
+
+<p>Performs the data encryption and returns it as a string. Example:</p>
+<code>
+$msg = 'My secret message';<br />
+<br />
+$encrypted_string = $this->encrypt->encode($msg);</code>
+
+<p>You can optionally pass your encryption key via the second parameter if you don't want to use the one in your config file:</p>
+
+<code>
+$msg = 'My secret message';<br />
+$key = 'super-secret-key';<br />
+<br />
+$encrypted_string = $this->encrypt->encode($msg, $key);</code>
+
+
+<h2>$this->encrypt->decode()</h2>
+
+<p>Decrypts an encoded string.  Example:</p>
+
+<code>
+$encrypted_string = 'APANtByIGI1BpVXZTJgcsAG8GZl8pdwwa84';<br />
+<br />
+$plaintext_string = $this->encrypt->decode($encrypted_string);</code>
+
+<p>You can optionally pass your encryption key via the second parameter if you don't want to use the one in your config file:</p>
+
+<code>
+$msg = 'My secret message';<br />
+$key = 'super-secret-key';<br />
+<br />
+$encrypted_string = $this->encrypt->decode($msg, $key);</code>
+
+
+<h2>$this->encrypt->set_cipher();</h2>
+
+<p>Permits you to set an Mcrypt cipher.  By default it uses <samp>MCRYPT_RIJNDAEL_256</samp>.  Example:</p>
+<code>$this->encrypt->set_cipher(MCRYPT_BLOWFISH);</code>
+<p>Please visit php.net for a list of  <a href="http://php.net/mcrypt">available ciphers</a>.</p>
+
+<p>If you'd like to manually test whether your server supports Mcrypt you can use:</p>
+<code>echo ( ! function_exists('mcrypt_encrypt')) ? 'Nope' : 'Yup';</code>
+
+
+<h2>$this->encrypt->set_mode();</h2>
+
+<p>Permits you to set an Mcrypt mode.  By default it uses <samp>MCRYPT_MODE_CBC</samp>.  Example:</p>
+<code>$this->encrypt->set_mode(MCRYPT_MODE_CFB);</code>
+<p>Please visit php.net for a list of  <a href="http://php.net/mcrypt">available modes</a>.</p>
+
+
+<h2>$this->encrypt->sha1();</h2>
+<p>SHA1 encoding function.  Provide a string and it will return a 160 bit one way hash.  Note:  SHA1, just like MD5 is non-decodable. Example:</p>
+<code>$hash = $this->encrypt->sha1('Some string');</code>
+
+<p>Many PHP installations have SHA1 support by default so if all you need is to encode a hash it's simpler to use the native
+function:</p>
+
+<code>$hash = sha1('Some string');</code>
+
+<p>If your server does not support SHA1 you can use the provided function.</p>
+
+<h2 id="legacy">$this->encrypt->encode_from_legacy(<kbd>$orig_data</kbd>, <kbd>$legacy_mode</kbd> = MCRYPT_MODE_ECB, <kbd>$key</kbd> = '');</h2>
+<p>Enables you to re-encode data that was originally encrypted with CodeIgniter 1.x to be compatible with the Encryption library in CodeIgniter 2.x.  It is only
+       necessary to use this method if you have encrypted data stored permanently such as in a file or database and are on a server that supports Mcrypt.  "Light" use encryption
+       such as encrypted session data or transitory encrypted flashdata require no intervention on your part.  However, existing encrypted Sessions will be
+       destroyed since data encrypted prior to 2.x will not be decoded.</p>
+
+<p class="important"><strong>Why only a method to re-encode the data instead of maintaining legacy methods for both encoding and decoding?</strong>  The algorithms in
+       the Encryption library have improved in CodeIgniter 2.x both for performance and security, and we do not wish to encourage continued use of the older methods.
+       You can of course extend the Encryption library if you wish and replace the new methods with the old and retain seamless compatibility with CodeIgniter 1.x
+       encrypted data, but this a decision that a developer should make cautiously and deliberately, if at all.</p>
+
+<code>$new_data = $this->encrypt->encode_from_legacy(<kbd>$old_encrypted_string</kbd>);</code>
+
+<table cellpadding="0" cellspacing="1" border="0" style="width:100%" class="tableborder">
+<tr>
+       <th>Parameter</th>
+       <th>Default</th>
+       <th>Description</th>
+</tr>
+<tr>
+       <td class="td"><strong>$orig_data</strong></td>
+       <td class="td">n/a</td>
+       <td class="td">The original encrypted data from CodeIgniter 1.x's Encryption library</td>
+</tr>
+<tr>
+       <td class="td"><strong>$legacy_mode</strong></td>
+       <td class="td">MCRYPT_MODE_ECB</td>
+       <td class="td">The Mcrypt mode that was used to generate the original encrypted data.  CodeIgniter 1.x's default was MCRYPT_MODE_ECB, and it will
+               assume that to be the case unless overridden by this parameter.</td>
+</tr>
+<tr>
+       <td class="td"><strong>$key</strong></td>
+       <td class="td">n/a</td>
+       <td class="td">The encryption key.  This it typically specified in your config file as outlined above.</td>
+</tr>
+</table>
+
+</div>
+<!-- END CONTENT -->
+
+
+<div id="footer">
+<p>
+Previous Topic:&nbsp;&nbsp;<a href="email.html">Email Class</a>
+&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+<a href="#top">Top of Page</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+<a href="../index.html">User Guide Home</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+Next Topic:&nbsp;&nbsp;<a href="file_uploading.html">File Uploading Class</a>
+</p>
+<p><a href="http://codeigniter.com">CodeIgniter</a> &nbsp;&middot;&nbsp; Copyright &#169; 2006 - 2011 &nbsp;&middot;&nbsp; <a href="http://ellislab.com/">EllisLab, Inc.</a></p>
+</div>
+
+</body>
+</html>
\ No newline at end of file
diff --git a/user_guide/libraries/file_uploading.html b/user_guide/libraries/file_uploading.html
new file mode 100755 (executable)
index 0000000..e4e842e
--- /dev/null
@@ -0,0 +1,451 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head>
+
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+<title>File Uploading Class : CodeIgniter User Guide</title>
+
+<style type='text/css' media='all'>@import url('../userguide.css');</style>
+<link rel='stylesheet' type='text/css' media='all' href='../userguide.css' />
+
+<script type="text/javascript" src="../nav/nav.js"></script>
+<script type="text/javascript" src="../nav/prototype.lite.js"></script>
+<script type="text/javascript" src="../nav/moo.fx.js"></script>
+<script type="text/javascript" src="../nav/user_guide_menu.js"></script>
+
+<meta http-equiv='expires' content='-1' />
+<meta http-equiv= 'pragma' content='no-cache' />
+<meta name='robots' content='all' />
+<meta name='author' content='ExpressionEngine Dev Team' />
+<meta name='description' content='CodeIgniter User Guide' />
+
+</head>
+<body>
+
+<!-- START NAVIGATION -->
+<div id="nav"><div id="nav_inner"><script type="text/javascript">create_menu('../');</script></div></div>
+<div id="nav2"><a name="top"></a><a href="javascript:void(0);" onclick="myHeight.toggle();"><img src="../images/nav_toggle_darker.jpg" width="154" height="43" border="0" title="Toggle Table of Contents" alt="Toggle Table of Contents" /></a></div>
+<div id="masthead">
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td><h1>CodeIgniter User Guide Version 2.0.2</h1></td>
+<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
+</tr>
+</table>
+</div>
+<!-- END NAVIGATION -->
+
+
+<!-- START BREADCRUMB -->
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td id="breadcrumb">
+<a href="http://codeigniter.com/">CodeIgniter Home</a> &nbsp;&#8250;&nbsp;
+<a href="../index.html">User Guide Home</a> &nbsp;&#8250;&nbsp;
+File Uploading Class
+</td>
+<td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="codeigniter.com/user_guide/" />Search User Guide&nbsp; <input type="text" class="input" style="width:200px;" name="q" id="q" size="31" maxlength="255" value="" />&nbsp;<input type="submit" class="submit" name="sa" value="Go" /></form></td>
+</tr>
+</table>
+<!-- END BREADCRUMB -->
+
+<br clear="all" />
+
+
+<!-- START CONTENT -->
+<div id="content">
+
+
+<h1>File Uploading Class</h1>
+
+<p>CodeIgniter's File Uploading Class permits files to be uploaded.  You can set various
+preferences, restricting the type and size of the files.</p>
+
+
+<h2>The Process</h2>
+
+<p>Uploading a file involves the following general process:</p>
+
+
+<ul>
+<li>An upload form is displayed, allowing a user to select a file and upload it.</li>
+<li>When the form is submitted, the file is uploaded to the destination you specify.</li>
+<li>Along the way, the file is validated to make sure it is allowed to be uploaded based on the preferences you set.</li>
+<li>Once uploaded, the user will be shown a success message.</li>
+</ul>
+
+<p>To demonstrate this process here is brief tutorial. Afterward you'll find reference information.</p>
+
+<h2>Creating the Upload Form</h2>
+
+
+
+<p>Using a text editor, create a form called <dfn>upload_form.php</dfn>.  In it, place this code and save it to your <samp>applications/views/</samp>
+folder:</p>
+
+
+<textarea class="textarea" style="width:100%" cols="50" rows="23">
+&lt;html>
+&lt;head>
+&lt;title>Upload Form&lt;/title>
+&lt;/head>
+&lt;body>
+
+&lt;?php echo $error;?>
+
+&lt;?php echo form_open_multipart('upload/do_upload');?>
+
+&lt;input type="file" name="userfile" size="20" />
+
+&lt;br />&lt;br />
+
+&lt;input type="submit" value="upload" />
+
+&lt;/form>
+
+&lt;/body>
+&lt;/html></textarea>
+
+<p>You'll notice we are using a form helper to create the opening form tag.  File uploads require a multipart form, so the helper
+creates the proper syntax for you.  You'll also notice we have an $error variable.  This is so we can show error messages in the event
+the user does something wrong.</p>
+
+
+<h2>The Success Page</h2>
+
+<p>Using a text editor, create a form called <dfn>upload_success.php</dfn>.
+In it, place this code and save it to your <samp>applications/views/</samp> folder:</p>
+
+<textarea class="textarea" style="width:100%" cols="50" rows="20">&lt;html>
+&lt;head>
+&lt;title>Upload Form&lt;/title>
+&lt;/head>
+&lt;body>
+
+&lt;h3>Your file was successfully uploaded!&lt;/h3>
+
+&lt;ul>
+&lt;?php foreach ($upload_data as $item => $value):?>
+&lt;li>&lt;?php echo $item;?>: &lt;?php echo $value;?>&lt;/li>
+&lt;?php endforeach; ?>
+&lt;/ul>
+
+&lt;p>&lt;?php echo anchor('upload', 'Upload Another File!'); ?>&lt;/p>
+
+&lt;/body>
+&lt;/html></textarea>
+
+
+<h2>The Controller</h2>
+
+<p>Using a text editor, create a controller called <dfn>upload.php</dfn>.  In it, place this code and save it to your <samp>applications/controllers/</samp>
+folder:</p>
+
+
+<textarea class="textarea" style="width:100%" cols="50" rows="43">&lt;?php
+
+class Upload extends CI_Controller {
+
+       function __construct()
+       {
+               parent::__construct();
+               $this->load->helper(array('form', 'url'));
+       }
+
+       function index()
+       {
+               $this->load->view('upload_form', array('error' => ' ' ));
+       }
+
+       function do_upload()
+       {
+               $config['upload_path'] = './uploads/';
+               $config['allowed_types'] = 'gif|jpg|png';
+               $config['max_size']     = '100';
+               $config['max_width']  = '1024';
+               $config['max_height']  = '768';
+
+               $this->load->library('upload', $config);
+
+               if ( ! $this->upload->do_upload())
+               {
+                       $error = array('error' => $this->upload->display_errors());
+
+                       $this->load->view('upload_form', $error);
+               }
+               else
+               {
+                       $data = array('upload_data' => $this->upload->data());
+
+                       $this->load->view('upload_success', $data);
+               }
+       }
+}
+?&gt;</textarea>
+
+
+<h2>The Upload Folder</h2>
+
+<p>You'll need a destination folder for your uploaded images.  Create a folder at the root of your CodeIgniter installation called
+<dfn>uploads</dfn> and set its file permissions to 777.</p>
+
+
+<h2>Try it!</h2>
+
+<p>To try your form, visit your site using a URL similar to this one:</p>
+
+<code>example.com/index.php/<var>upload</var>/</code>
+
+<p>You should see an upload form. Try uploading an image file (either a jpg, gif, or png). If the path in your
+controller is correct it should work.</p>
+
+
+<p>&nbsp;</p>
+
+<h1>Reference Guide</h1>
+
+
+<h2>Initializing the Upload Class</h2>
+
+<p>Like most other classes in CodeIgniter, the Upload class is initialized in your controller using the <dfn>$this->load->library</dfn> function:</p>
+
+<code>$this->load->library('upload');</code>
+<p>Once the Upload class is loaded, the object will be available using: <dfn>$this->upload</dfn></p>
+
+
+<h2>Setting Preferences</h2>
+
+<p>Similar to other libraries, you'll control what is allowed to be upload based on your preferences.  In the controller you
+built above you set the following preferences:</p>
+
+<code>$config['upload_path'] = './uploads/';<br />
+$config['allowed_types'] = 'gif|jpg|png';<br />
+$config['max_size']    = '100';<br />
+$config['max_width']  = '1024';<br />
+$config['max_height']  = '768';<br />
+<br />
+$this->load->library('upload', $config);<br /><br />
+
+// Alternately you can set preferences by calling the initialize function.  Useful if you auto-load the class:<br />
+$this->upload->initialize($config);</code>
+
+<p>The above preferences should be fairly self-explanatory.  Below is a table describing all available preferences.</p>
+
+
+<h2>Preferences</h2>
+
+<p>The following preferences are available.  The default value indicates what will be used if you do not specify that preference.</p>
+
+<table cellpadding="0" cellspacing="1" border="0" style="width:100%" class="tableborder">
+<tr>
+<th>Preference</th>
+<th>Default&nbsp;Value</th>
+<th>Options</th>
+<th>Description</th>
+</tr>
+
+<tr>
+<td class="td"><strong>upload_path</strong></td>
+<td class="td">None</td>
+<td class="td">None</td>
+<td class="td">The path to the folder where the upload should be placed.  The folder must be writable and the path can be absolute or relative.</td>
+</tr>
+
+<tr>
+<td class="td"><strong>allowed_types</strong></td>
+<td class="td">None</td>
+<td class="td">None</td>
+<td class="td">The mime types corresponding to the types of files you allow to be uploaded.  Usually the file extension can be used as the mime type.  Separate multiple types with a pipe.</td>
+</tr>
+
+
+<tr>
+<td class="td"><strong>file_name</strong></td>
+<td class="td">None</td>
+<td class="td">Desired file name</td>
+<td class="td">
+       <p>If set CodeIgniter will rename the uploaded file to this name.  The extension provided in the file name must also be an allowed file type.</p>
+</td>
+</tr>
+
+<tr>
+<td class="td"><strong>overwrite</strong></td>
+<td class="td">FALSE</td>
+<td class="td">TRUE/FALSE (boolean)</td>
+<td class="td">If set to true, if a file with the same name as the one you are uploading exists, it will be overwritten. If set to false, a number will be appended to the filename if another with the same name exists.</td>
+</tr>
+
+
+<tr>
+<td class="td"><strong>max_size</strong></td>
+<td class="td">0</td>
+<td class="td">None</td>
+<td class="td">The maximum size (in kilobytes) that the file can be.  Set to zero for no limit. Note:  Most PHP installations have their own limit, as specified in the php.ini file.  Usually 2 MB (or 2048 KB) by default.</td>
+</tr>
+
+<tr>
+<td class="td"><strong>max_width</strong></td>
+<td class="td">0</td>
+<td class="td">None</td>
+<td class="td">The maximum width (in pixels) that the file can be.  Set to zero for no limit.</td>
+</tr>
+
+<tr>
+<td class="td"><strong>max_height</strong></td>
+<td class="td">0</td>
+<td class="td">None</td>
+<td class="td">The maximum height (in pixels) that the file can be.  Set to zero for no limit.</td>
+</tr>
+
+<tr>
+<td class="td"><strong>max_filename</strong></td>
+<td class="td">0</td>
+<td class="td">None</td>
+<td class="td">The maximum length that a file name can be.  Set to zero for no limit.</td>
+</tr>
+
+<tr>
+<td class="td"><strong>encrypt_name</strong></td>
+<td class="td">FALSE</td>
+<td class="td">TRUE/FALSE (boolean)</td>
+<td class="td">If set to TRUE the file name will be converted to a random encrypted string. This can be useful if you would like the file saved with a name that can not be discerned by the person uploading it.</td>
+</tr>
+
+<tr>
+<td class="td"><strong>remove_spaces</strong></td>
+<td class="td">TRUE</td>
+<td class="td">TRUE/FALSE (boolean)</td>
+<td class="td">If set to TRUE, any spaces in the file name will be converted to underscores. This is recommended.</td>
+</tr>
+</table>
+
+
+<h2>Setting preferences in a config file</h2>
+
+<p>If you prefer not to set preferences using the above method, you can instead put them into a config file.
+Simply create a new file called the <var>upload.php</var>,  add the <var>$config</var>
+array in that file. Then save the file in: <var>config/upload.php</var> and it will be used automatically. You
+will NOT need to use the <dfn>$this->upload->initialize</dfn> function if you save your preferences in a config file.</p>
+
+
+<h2>Function Reference</h2>
+
+<p>The following functions are available</p>
+
+
+<h2>$this->upload->do_upload()</h2>
+
+<p>Performs the upload based on the preferences you've set.  Note:  By default the upload routine expects the file to come from a form field
+called <dfn>userfile</dfn>, and the form must be a "multipart type:</p>
+
+<code>&lt;form method="post" action="some_action" enctype="multipart/form-data" /></code>
+
+<p>If you would like to set your own field name simply pass its value to the <dfn>do_upload</dfn> function:</p>
+
+<code>
+$field_name = "some_field_name";<br />
+$this->upload->do_upload($field_name)</code>
+
+
+<h2>$this->upload->display_errors()</h2>
+
+<p>Retrieves any error messages if the <dfn>do_upload()</dfn> function returned false.  The function does not echo automatically, it
+returns the data so you can assign it however you need.</p>
+
+<h3>Formatting Errors</h3>
+<p>By default the above function wraps any errors within &lt;p> tags.  You can set your own delimiters like this:</p>
+
+<code>$this->upload->display_errors('<var>&lt;p></var>', '<var>&lt;/p></var>');</code>
+
+<h2>$this->upload->data()</h2>
+
+<p>This is a helper function that returns an array containing all of the data related to the file you uploaded.
+Here is the array prototype:</p>
+
+<code>Array<br />
+(<br />
+&nbsp;&nbsp;&nbsp;&nbsp;[file_name]&nbsp;&nbsp;&nbsp;&nbsp;=> mypic.jpg<br />
+&nbsp;&nbsp;&nbsp;&nbsp;[file_type]&nbsp;&nbsp;&nbsp;&nbsp;=> image/jpeg<br />
+&nbsp;&nbsp;&nbsp;&nbsp;[file_path]&nbsp;&nbsp;&nbsp;&nbsp;=> /path/to/your/upload/<br />
+&nbsp;&nbsp;&nbsp;&nbsp;[full_path]&nbsp;&nbsp;&nbsp;&nbsp;=> /path/to/your/upload/jpg.jpg<br />
+&nbsp;&nbsp;&nbsp;&nbsp;[raw_name]&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=> mypic<br />
+&nbsp;&nbsp;&nbsp;&nbsp;[orig_name]&nbsp;&nbsp;&nbsp;&nbsp;=> mypic.jpg<br />
+&nbsp;&nbsp;&nbsp;&nbsp;[client_name]&nbsp;&nbsp;=> mypic.jpg<br />
+&nbsp;&nbsp;&nbsp;&nbsp;[file_ext]&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=> .jpg<br />
+&nbsp;&nbsp;&nbsp;&nbsp;[file_size]&nbsp;&nbsp;&nbsp;&nbsp;=> 22.2<br />
+&nbsp;&nbsp;&nbsp;&nbsp;[is_image]&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=> 1<br />
+&nbsp;&nbsp;&nbsp;&nbsp;[image_width]&nbsp;&nbsp;=> 800<br />
+&nbsp;&nbsp;&nbsp;&nbsp;[image_height] => 600<br />
+&nbsp;&nbsp;&nbsp;&nbsp;[image_type]&nbsp;&nbsp;&nbsp;=> jpeg<br />
+&nbsp;&nbsp;&nbsp;&nbsp;[image_size_str] => width="800" height="200"<br />
+)</code>
+
+<h3>Explanation</h3>
+
+<p>Here is an explanation of the above array items.</p>
+
+<table cellpadding="0" cellspacing="1" border="0" style="width:100%" class="tableborder">
+<tr><th>Item</th><th>Description</th></tr>
+
+<tr><td class="td"><strong>file_name</strong></td>
+<td class="td">The name of the file that was uploaded including the file extension.</td></tr>
+
+<tr><td class="td"><strong>file_type</strong></td>
+<td class="td">The file's Mime type</td></tr>
+
+<tr><td class="td"><strong>file_path</strong></td>
+<td class="td">The absolute server path to the file</td></tr>
+
+<tr><td class="td"><strong>full_path</strong></td>
+<td class="td">The absolute server path including the file name</td></tr>
+
+<tr><td class="td"><strong>raw_name</strong></td>
+<td class="td">The file name without the extension</td></tr>
+
+<tr><td class="td"><strong>orig_name</strong></td>
+<td class="td">The original file name.  This is only useful if you use the encrypted name option.</td></tr>
+
+<tr><td class="td"><strong>client_name</strong></td>
+<td class="td">The file name as supplied by the client user agent, prior to any file name preparation or incrementing.</td></tr>
+
+<tr><td class="td"><strong>file_ext</strong></td>
+<td class="td">The file extension with period</td></tr>
+
+<tr><td class="td"><strong>file_size</strong></td>
+<td class="td">The file size in kilobytes</td></tr>
+
+<tr><td class="td"><strong>is_image</strong></td>
+<td class="td">Whether the file is an image or not.  1 = image. 0 = not.</td></tr>
+
+<tr><td class="td"><strong>image_width</strong></td>
+<td class="td">Image width.</td></tr>
+
+<tr><td class="td"><strong>image_height</strong></td>
+<td class="td">Image height</td></tr>
+
+<tr><td class="td"><strong>image_type</strong></td>
+<td class="td">Image type.  Typically the file extension without the period.</td></tr>
+
+<tr><td class="td"><strong>image_size_str</strong></td>
+<td class="td">A string containing the width and height.  Useful to put into an image tag.</td></tr>
+
+
+</table>
+
+</div>
+<!-- END CONTENT -->
+
+
+<div id="footer">
+<p>
+Previous Topic:&nbsp;&nbsp;<a href="encryption.html">Encryption Helper</a>
+&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+<a href="#top">Top of Page</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+<a href="../index.html">User Guide Home</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+Next Topic:&nbsp;&nbsp;<a href="form_validation.html">Form Validation Class</a>
+</p>
+<p><a href="http://codeigniter.com">CodeIgniter</a> &nbsp;&middot;&nbsp; Copyright &#169; 2006 - 2011 &nbsp;&middot;&nbsp; <a href="http://ellislab.com/">Ellislab, Inc.</a></p>
+</div>
+
+</body>
+</html>
\ No newline at end of file
diff --git a/user_guide/libraries/form_validation.html b/user_guide/libraries/form_validation.html
new file mode 100755 (executable)
index 0000000..8fdcd14
--- /dev/null
@@ -0,0 +1,1246 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head>
+
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+<title>Form Validation : CodeIgniter User Guide</title>
+
+<style type='text/css' media='all'>@import url('../userguide.css');</style>
+<link rel='stylesheet' type='text/css' media='all' href='../userguide.css' />
+
+<script type="text/javascript" src="../nav/nav.js"></script>
+<script type="text/javascript" src="../nav/prototype.lite.js"></script>
+<script type="text/javascript" src="../nav/moo.fx.js"></script>
+<script type="text/javascript" src="../nav/user_guide_menu.js"></script>
+
+<meta http-equiv='expires' content='-1' />
+<meta http-equiv= 'pragma' content='no-cache' />
+<meta name='robots' content='all' />
+<meta name='author' content='ExpressionEngine Dev Team' />
+<meta name='description' content='CodeIgniter User Guide' />
+</head>
+<body>
+
+<!-- START NAVIGATION -->
+<div id="nav"><div id="nav_inner"><script type="text/javascript">create_menu('../');</script></div></div>
+<div id="nav2"><a name="top"></a><a href="javascript:void(0);" onclick="myHeight.toggle();"><img src="../images/nav_toggle_darker.jpg" width="154" height="43" border="0" title="Toggle Table of Contents" alt="Toggle Table of Contents" /></a></div>
+<div id="masthead">
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td><h1>CodeIgniter User Guide Version 2.0.2</h1></td>
+<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
+</tr>
+</table>
+</div>
+<!-- END NAVIGATION -->
+
+
+<!-- START BREADCRUMB -->
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td id="breadcrumb">
+<a href="http://codeigniter.com/">CodeIgniter Home</a> &nbsp;&#8250;&nbsp;
+<a href="../index.html">User Guide Home</a> &nbsp;&#8250;&nbsp;
+Form Validation
+</td>
+<td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="codeigniter.com/user_guide/" />Search User Guide&nbsp; <input type="text" class="input" style="width:200px;" name="q" id="q" size="31" maxlength="255" value="" />&nbsp;<input type="submit" class="submit" name="sa" value="Go" /></form></td>
+</tr>
+</table>
+<!-- END BREADCRUMB -->
+
+<br clear="all" />
+
+
+<!-- START CONTENT -->
+<div id="content">
+
+<h1>Form Validation</h1>
+
+<p>CodeIgniter provides a comprehensive form validation and data prepping class that helps minimize the amount of code you'll write.</p>
+
+<ul>
+<li><a href="#overview">Overview</a></li>
+<li><a href="#tutorial">Form Validation Tutorial</a>
+
+       <ul>
+               <li><a href="#theform">The Form</a></li>
+               <li><a href="#thesuccesspage">The Success Page</a></li>
+               <li><a href="#thecontroller">The Controller</a></li>
+               <li><a href="#validationrules">Setting Validation Rules</a></li>
+               <li><a href="#validationrulesasarray">Setting Validation Rules Using an Array</a></li>
+               <li><a href="#cascadingrules">Cascading Rules</a></li>
+               <li><a href="#preppingdata">Prepping Data</a></li>
+               <li><a href="#repopulatingform">Re-populating the Form</a></li>
+               <li><a href="#callbacks">Callbacks</a></li>
+               <li><a href="#settingerrors">Setting Error Messages</a></li>
+               <li><a href="#errordelimiters">Changing the Error Delimiters</a></li>
+               <li><a href="#translatingfn">Translating Field Names</a></li>
+               <li><a href="#individualerrors">Showing Errors Individually</a></li>
+               <li><a href="#savingtoconfig">Saving Sets of Validation Rules to a Config File</a></li>
+               <li><a href="#arraysasfields">Using Arrays as Field Names</a></li>
+       </ul>
+</li>
+<li><a href="#rulereference">Rule Reference</a></li>
+<li><a href="#preppingreference">Prepping Reference</a></li>
+<li><a href="#functionreference">Function Reference</a></li>
+<li><a href="#helperreference">Helper Reference</a></li>
+
+</ul>
+
+
+
+
+
+
+<p>&nbsp;</p>
+
+<a name="overview"></a>
+<h1>Overview</h1>
+
+
+<p>Before explaining CodeIgniter's approach to data validation, let's describe the ideal scenario:</p>
+
+<ol>
+<li>A form is displayed.</li>
+<li>You fill it in and submit it.</li>
+<li>If you submitted something invalid, or perhaps missed a required item, the form is redisplayed containing your data
+along with an error message describing the problem.</li>
+<li>This process continues until you have submitted a valid form.</li>
+</ol>
+
+<p>On the receiving end, the script must:</p>
+
+<ol>
+<li>Check for required data.</li>
+<li>Verify that the data is of the correct type, and meets the correct criteria. For example, if a username is submitted
+it must be validated to contain only permitted characters.  It must be of a minimum length,
+and not exceed a maximum length. The username can't be someone else's existing username, or perhaps even a reserved word. Etc.</li>
+<li>Sanitize the data for security.</li>
+<li>Pre-format the data if needed (Does the data need to be trimmed?  HTML encoded?  Etc.)</li>
+<li>Prep the data for insertion in the database.</li>
+</ol>
+
+
+<p>Although there is nothing terribly complex about the above process, it usually requires a significant
+amount of code, and to display error messages, various control structures are usually placed within the form HTML.
+Form validation, while simple to create, is generally very messy and tedious to implement.</p>
+
+<p>&nbsp;</p>
+
+
+<a name="tutorial"></a>
+<h1>Form Validation Tutorial</h1>
+
+<p>What follows is a "hands on" tutorial for implementing CodeIgniters Form Validation.</p>
+
+
+<p>In order to implement form validation you'll need three things:</p>
+
+<ol>
+<li>A <a href="../general/views.html">View</a> file containing a form.</li>
+<li>A View file containing a "success" message to be displayed upon successful submission.</li>
+<li>A <a href="../general/controllers.html">controller</a> function to receive and process the submitted data.</li>
+</ol>
+
+<p>Let's create those three things, using a member sign-up form as the example.</p>
+
+
+
+<a name="theform"></a>
+
+<h2>The Form</h2>
+
+<p>Using a text editor, create a form called <dfn>myform.php</dfn>.  In it, place this code and save it to your <samp>applications/views/</samp>
+folder:</p>
+
+
+<textarea class="textarea" style="width:100%" cols="50" rows="30">&lt;html>
+&lt;head>
+&lt;title>My Form&lt;/title>
+&lt;/head>
+&lt;body>
+
+&lt;?php echo validation_errors(); ?>
+
+&lt;?php echo form_open('form'); ?>
+
+&lt;h5>Username&lt;/h5>
+&lt;input type="text" name="username" value="" size="50" />
+
+&lt;h5>Password&lt;/h5>
+&lt;input type="text" name="password" value="" size="50" />
+
+&lt;h5>Password Confirm&lt;/h5>
+&lt;input type="text" name="passconf" value="" size="50" />
+
+&lt;h5>Email Address&lt;/h5>
+&lt;input type="text" name="email" value="" size="50" />
+
+&lt;div>&lt;input type="submit" value="Submit" />&lt;/div>
+
+&lt;/form>
+
+&lt;/body>
+&lt;/html>
+</textarea>
+
+
+
+
+<a name="thesuccesspage"></a>
+<h2>The Success Page</h2>
+
+
+<p>Using a text editor, create a form called <dfn>formsuccess.php</dfn>.  In it, place this code and save it to your <samp>applications/views/</samp>
+folder:</p>
+
+
+<textarea class="textarea" style="width:100%" cols="50" rows="14">
+&lt;html>
+&lt;head>
+&lt;title>My Form&lt;/title>
+&lt;/head>
+&lt;body>
+
+&lt;h3>Your form was successfully submitted!&lt;/h3>
+
+&lt;p>&lt;?php echo anchor('form', 'Try it again!'); ?>&lt;/p>
+
+&lt;/body>
+&lt;/html>
+</textarea>
+
+
+
+<a name="thecontroller"></a>
+<h2>The Controller</h2>
+
+<p>Using a text editor, create a controller called <dfn>form.php</dfn>.  In it, place this code and save it to your <samp>applications/controllers/</samp>
+folder:</p>
+
+
+<textarea class="textarea" style="width:100%" cols="50" rows="21">&lt;?php
+
+class Form extends CI_Controller {
+
+       function index()
+       {
+               $this->load->helper(array('form', 'url'));
+
+               $this->load->library('form_validation');
+
+               if ($this->form_validation->run() == FALSE)
+               {
+                       $this->load->view('myform');
+               }
+               else
+               {
+                       $this->load->view('formsuccess');
+               }
+       }
+}
+?></textarea>
+
+
+<h2>Try it!</h2>
+
+<p>To try your form, visit your site using a URL similar to this one:</p>
+
+<code>example.com/index.php/<var>form</var>/</code>
+
+<p><dfn>If you submit the form you should simply see the form reload.  That's because you haven't set up any validation
+rules yet.</dfn></p>
+
+<p><strong>Since you haven't told the Form Validation class to validate anything yet, it returns <kbd>FALSE</kbd> (boolean false) by default.  The <samp>run()</samp>
+function only returns <kbd>TRUE</kbd> if it has successfully applied your rules without any of them failing.</strong></p>
+
+
+<h2>Explanation</h2>
+
+<p>You'll notice several things about the above pages:</p>
+
+<p>The <dfn>form</dfn> (myform.php) is a standard web form with a couple exceptions:</p>
+
+<ol>
+<li>It uses a <dfn>form helper</dfn> to create the form opening.
+Technically, this isn't necessary.  You could create the form using standard HTML.  However, the benefit of using the helper
+is that it generates the action URL for you, based on the URL in your config file.  This makes your application more portable in the event your URLs change.</li>
+
+<li>At the top of the form you'll notice the following function call:
+<code>&lt;?php echo validation_errors(); ?&gt;</code>
+
+<p>This function will return any error messages sent back by the validator. If there are no messages it returns an empty string.</p>
+</li>
+</ol>
+
+<p>The <dfn>controller</dfn> (form.php) has one function: <dfn>index()</dfn>. This function initializes the validation class and
+loads the <var>form helper</var> and <var>URL helper</var> used by your view files. It also <samp>runs</samp>
+the validation routine. Based on
+whether the validation was successful it either presents the form or the success page.</p>
+
+
+
+
+<a name="validationrules"></a>
+
+<h2>Setting Validation Rules</h2>
+
+<p>CodeIgniter lets you set as many validation rules as you need for a given field, cascading them in order, and it even lets you prep and pre-process the field data
+at the same time. To set validation rules you will use the <dfn>set_rules()</dfn> function:</p>
+
+<code>$this->form_validation->set_rules();</code>
+
+<p>The above function takes <strong>three</strong> parameters as input:</p>
+
+<ol>
+       <li>The field name - the exact name you've given the form field.</li>
+       <li>A "human" name for this field, which will be inserted into the error message. For example, if your field is named "user" you might give it a human name of "Username". <strong>Note:</strong> If you would like the field name to be stored in a language file, please see <a href="#translatingfn">Translating Field Names</a>.</li>
+       <li>The validation rules for this form field.</li>
+</ol>
+
+
+<p><br />Here is an example. In your <dfn>controller</dfn> (form.php), add this code just below the validation initialization function:</p>
+
+<code>
+$this->form_validation->set_rules('username', 'Username', 'required');<br />
+$this->form_validation->set_rules('password', 'Password', 'required');<br />
+$this->form_validation->set_rules('passconf', 'Password Confirmation', 'required');<br />
+$this->form_validation->set_rules('email', 'Email', 'required');<br />
+</code>
+
+<p>Your controller should now look like this:</p>
+
+<textarea class="textarea" style="width:100%" cols="50" rows="28">&lt;?php
+
+class Form extends CI_Controller {
+
+       function index()
+       {
+               $this->load->helper(array('form', 'url'));
+
+               $this->load->library('form_validation');
+
+               $this->form_validation->set_rules('username', 'Username', 'required');
+               $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');
+
+               if ($this->form_validation->run() == FALSE)
+               {
+                       $this->load->view('myform');
+               }
+               else
+               {
+                       $this->load->view('formsuccess');
+               }
+       }
+}
+?></textarea>
+
+<p><dfn>Now submit the form with the fields blank and you should see the error messages.
+If you submit the form with all the fields populated you'll see your success page.</dfn></p>
+
+<p class="important"><strong>Note:</strong> The form fields are not yet being re-populated with the data when
+there is an error.  We'll get to that shortly.</p>
+
+
+
+
+<a name="validationrulesasarray"></a>
+<h2>Setting Rules Using an Array</h2>
+
+<p>Before moving on it should be noted that the rule setting function can be passed an array if you prefer to set all your rules in one action.
+If you use this approach you must name your array keys as indicated:</p>
+
+<code>
+$config = array(<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;array(<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'field'&nbsp;&nbsp;&nbsp;=> 'username', <br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'label'&nbsp;&nbsp;&nbsp;=> 'Username', <br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'rules'&nbsp;&nbsp;&nbsp;=> 'required'<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;),<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;array(<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'field'&nbsp;&nbsp;&nbsp;=> 'password', <br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'label'&nbsp;&nbsp;&nbsp;=> 'Password', <br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'rules'&nbsp;&nbsp;&nbsp;=> 'required'<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;),<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;array(<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'field'&nbsp;&nbsp;&nbsp;=> 'passconf', <br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'label'&nbsp;&nbsp;&nbsp;=> 'Password Confirmation', <br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'rules'&nbsp;&nbsp;&nbsp;=> 'required'<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;),&nbsp;&nbsp;&nbsp;<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;array(<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'field'&nbsp;&nbsp;&nbsp;=> 'email', <br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'label'&nbsp;&nbsp;&nbsp;=> 'Email', <br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'rules'&nbsp;&nbsp;&nbsp;=> 'required'<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;)<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;);<br />
+<br />
+$this->form_validation->set_rules($config);
+</code>
+
+
+
+
+
+
+<a name="cascadingrules"></a>
+<h2>Cascading Rules</h2>
+
+<p>CodeIgniter lets you pipe multiple rules together.  Let's try it. Change your rules in the third parameter of rule setting function, like this:</p>
+
+<code>
+$this->form_validation->set_rules('username', 'Username', 'required|min_length[5]|max_length[12]');<br />
+$this->form_validation->set_rules('password', 'Password', 'required|matches[passconf]');<br />
+$this->form_validation->set_rules('passconf', 'Password Confirmation', 'required');<br />
+$this->form_validation->set_rules('email', 'Email', 'required|valid_email');<br />
+</code>
+
+<p>The above code sets the following rules:</p>
+
+<ol>
+<li>The username field be no shorter than 5 characters and no longer than 12.</li>
+<li>The password field must match the password confirmation field.</li>
+<li>The email field must contain a valid email address.</li>
+</ol>
+
+<p>Give it a try! Submit your form without the proper data and you'll see new error messages that correspond to your new rules.
+There are numerous rules available which you can read about in the validation reference.</p>
+
+
+
+<a name="preppingdata"></a>
+<h2>Prepping Data</h2>
+
+<p>In addition to the validation functions like the ones we used above, you can also prep your data in various ways.
+For example, you can set up rules like this:</p>
+
+<code>
+$this->form_validation->set_rules('username', 'Username', '<kbd>trim</kbd>|required|min_length[5]|max_length[12]|<kbd>xss_clean</kbd>');<br />
+$this->form_validation->set_rules('password', 'Password', '<kbd>trim</kbd>|required|matches[passconf]|<kbd>md5</kbd>');<br />
+$this->form_validation->set_rules('passconf', 'Password Confirmation', '<kbd>trim</kbd>|required');<br />
+$this->form_validation->set_rules('email', 'Email', '<kbd>trim</kbd>|required|valid_email');<br />
+</code>
+
+
+<p>In the above example, we are "trimming" the fields, converting the password to MD5, and running the username through
+the "xss_clean" function, which removes malicious data.</p>
+
+<p><strong>Any native PHP function that accepts one parameter can be used as a rule, like <dfn>htmlspecialchars</dfn>,
+<dfn>trim</dfn>,  <dfn>MD5</dfn>, etc.</strong></p>
+
+<p><strong>Note:</strong> You will generally want to use the prepping functions <strong>after</strong>
+the validation rules so if there is an error, the original data will be shown in the form.</p>
+
+
+
+
+<a name="repopulatingform"></a>
+<h2>Re-populating the form</h2>
+
+<p>Thus far we have only been dealing with errors.  It's time to repopulate the form field with the submitted data. CodeIgniter offers several helper functions
+that permit you to do this. The one you will use most commonly is:</p>
+
+<code>set_value('field name')</code>
+
+
+<p>Open your <dfn>myform.php</dfn> view file and update the <strong>value</strong> in each field using the <dfn>set_value()</dfn> function:</p>
+
+<p><strong>Don't forget to include each field name in the <dfn>set_value()</dfn> functions!</strong></p>
+
+
+<textarea class="textarea" style="width:100%" cols="50" rows="30">
+&lt;html>
+&lt;head>
+&lt;title>My Form&lt;/title>
+&lt;/head>
+&lt;body>
+
+&lt;?php echo validation_errors(); ?>
+
+&lt;?php echo form_open('form'); ?>
+
+&lt;h5>Username&lt;/h5>
+&lt;input type="text" name="username" value="&lt;?php echo set_value('username'); ?>" size="50" />
+
+&lt;h5>Password&lt;/h5>
+&lt;input type="text" name="password" value="&lt;?php echo set_value('password'); ?>" size="50" />
+
+&lt;h5>Password Confirm&lt;/h5>
+&lt;input type="text" name="passconf" value="&lt;?php echo set_value('passconf'); ?>" size="50" />
+
+&lt;h5>Email Address&lt;/h5>
+&lt;input type="text" name="email" value="&lt;?php echo set_value('email'); ?>" size="50" />
+
+&lt;div>&lt;input type="submit" value="Submit" />&lt;/div>
+
+&lt;/form>
+
+&lt;/body>
+&lt;/html>
+</textarea>
+
+
+<p><dfn>Now reload your page and submit the form so that it triggers an error.  Your form fields should now be re-populated</dfn></p>
+
+<p class="important"><strong>Note:</strong> The <a href="#functionreference">Function Reference</a> section below contains functions that
+permit you to re-populate &lt;select> menus, radio buttons, and checkboxes.</p>
+
+
+<p><strong>Important Note:</strong> If you use an array as the name of a form field, you must supply it as an array to the function.  Example:</p>
+
+<code>&lt;input type="text" name="<kbd>colors[]</kbd>" value="&lt;?php echo set_value('<kbd>colors[]</kbd>'); ?>" size="50" /></code>
+
+<p>For more info please see the <a href="#arraysasfields">Using Arrays as Field Names</a> section below.</p>
+
+
+
+
+
+<a name="callbacks"></a>
+<h2>Callbacks: Your own Validation Functions</h2>
+
+<p>The validation system supports callbacks to your own validation functions.  This permits you to extend the validation class
+to meet your needs.  For example, if you need to run a database query to see if the user is choosing a unique username, you can
+create a callback function that does that.  Let's create a example of this.</p>
+
+<p>In your controller, change the "username" rule to this:</p>
+
+<code>$this->form_validation->set_rules('username', 'Username', '<kbd>callback_username_check</kbd>');</code>
+
+
+<p>Then add a new function called <dfn>username_check</dfn> to your controller.  Here's how your controller should now look:</p>
+
+
+<textarea class="textarea" style="width:100%" cols="50" rows="44">&lt;?php
+
+class Form extends CI_Controller {
+
+       function index()
+       {
+               $this->load->helper(array('form', 'url'));
+
+               $this->load->library('form_validation');
+
+               $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');
+
+               if ($this->form_validation->run() == FALSE)
+               {
+                       $this->load->view('myform');
+               }
+               else
+               {
+                       $this->load->view('formsuccess');
+               }
+       }
+
+       function username_check($str)
+       {
+               if ($str == 'test')
+               {
+                       $this->form_validation->set_message('username_check', 'The %s field can not be the word "test"');
+                       return FALSE;
+               }
+               else
+               {
+                       return TRUE;
+               }
+       }
+
+}
+?></textarea>
+
+<p><dfn>Reload your form and submit it with the word "test" as the username.  You can see that the form field data was passed to your
+callback function for you to process.</dfn></p>
+
+<p><strong>To invoke a callback just put the function name in a rule, with "callback_" as the rule prefix.</strong></p>
+
+<p>You can also process the form data that is passed to your callback and return it.  If your callback returns anything other than a boolean TRUE/FALSE
+it is assumed that the data is your newly processed form data.</p>
+
+
+
+
+<a name="settingerrors"></a>
+<h2>Setting Error Messages</h2>
+
+
+<p>All of the native error messages are located in the following language file:  <dfn>language/english/form_validation_lang.php</dfn></p>
+
+<p>To set your own custom message you can either edit that file, or use the following function:</p>
+
+<code>$this->form_validation->set_message('<var>rule</var>', '<var>Error Message</var>');</code>
+
+<p>Where <var>rule</var> corresponds to the name of a particular rule, and <var>Error Message</var> is the text you would like displayed.</p>
+
+<p>If you include <dfn>%s</dfn> in your error string, it will be replaced with the "human" name you used for your field when you set your rules.</p>
+
+<p>In the "callback" example above, the error message was set by passing the name of the function:</p>
+
+<code>$this->form_validation->set_message('username_check')</code>
+
+<p>You can also override any error message found in the language file.  For example, to change the message for the "required" rule you will do this:</p>
+
+<code>$this->form_validation->set_message('required', 'Your custom message here');</code>
+
+
+
+<a name="translatingfn"></a>
+<h2>Translating Field Names</h2>
+
+<p>If you would like to store the "human" name you passed to the <dfn>set_rules()</dfn> function in a language file, and therefore make the name able to be translated, here's how:</p>
+
+<p>First, prefix your "human" name with <dfn>lang:</dfn>, as in this example:</p>
+
+<code>
+$this->form_validation->set_rules('first_name', '<kbd>lang:</kbd>first_name', 'required');<br />
+</code>
+
+<p>Then, store the name in one of your language file arrays (without the prefix):</p>
+
+<code>$lang['first_name'] = 'First Name';</code>
+
+<p><strong>Note:</strong> If you store your array item in a language file that is not loaded automatically by CI, you'll need to remember to load it in your controller using:</p>
+
+<code>$this->lang->load('file_name');</code>
+
+<p>See the <a href="language.html">Language Class</a> page for more info regarding language files.</p>
+
+
+<a name="errordelimiters"></a>
+<h2>Changing the Error Delimiters</h2>
+
+<p>By default, the Form Validation class adds a paragraph tag (&lt;p&gt;) around each error message shown. You can either change these delimiters globally or
+individually.</p>
+
+<ol>
+
+<li><strong>Changing delimiters Globally</strong>
+
+<p>To globally change the error delimiters, in your controller function, just after loading the Form Validation class, add this:</p>
+
+<code>$this->form_validation->set_error_delimiters('<kbd>&lt;div class="error"></kbd>', '<kbd>&lt;/div></kbd>');</code>
+
+<p>In this example, we've switched to using div tags.</p>
+
+</li>
+
+<li><strong>Changing delimiters Individually</strong>
+
+<p>Each of the two error generating functions shown in this tutorial can be supplied their own delimiters as follows:</p>
+
+<code>&lt;?php echo form_error('field name', '<kbd>&lt;div class="error"></kbd>', '<kbd>&lt;/div></kbd>'); ?></code>
+
+<p>Or:</p>
+
+<code>&lt;?php echo validation_errors('<kbd>&lt;div class="error"></kbd>', '<kbd>&lt;/div></kbd>'); ?></code>
+
+</li>
+</ol>
+
+
+
+
+<a name="individualerrors"></a>
+<h2>Showing Errors Individually</h2>
+
+<p>If you prefer to show an error message next to each form field, rather than as a list, you can use the <dfn>form_error()</dfn> function.</p>
+
+<p>Try it! Change your form so that it looks like this:</p>
+
+<textarea class="textarea" style="width:100%" cols="50" rows="18">
+&lt;h5>Username&lt;/h5>
+&lt;?php echo form_error('username'); ?>
+&lt;input type="text" name="username" value="&lt;?php echo set_value('username'); ?>" size="50" />
+
+&lt;h5>Password&lt;/h5>
+&lt;?php echo form_error('password'); ?>
+&lt;input type="text" name="password" value="&lt;?php echo set_value('password'); ?>" size="50" />
+
+&lt;h5>Password Confirm&lt;/h5>
+&lt;?php echo form_error('passconf'); ?>
+&lt;input type="text" name="passconf" value="&lt;?php echo set_value('passconf'); ?>" size="50" />
+
+&lt;h5>Email Address&lt;/h5>
+&lt;?php echo form_error('email'); ?>
+&lt;input type="text" name="email" value="&lt;?php echo set_value('email'); ?>" size="50" />
+</textarea>
+
+<p>If there are no errors, nothing will be shown.  If there is an error, the message will appear.</p>
+
+<p><strong>Important Note:</strong> If you use an array as the name of a form field, you must supply it as an array to the function.  Example:</p>
+
+<code>&lt;?php echo form_error('<kbd>options[size]</kbd>'); ?><br />
+&lt;input type="text" name="<kbd>options[size]</kbd>" value="&lt;?php echo set_value("<kbd>options[size]</kbd>"); ?>" size="50" />
+</code>
+
+<p>For more info please see the <a href="#arraysasfields">Using Arrays as Field Names</a> section below.</p>
+
+
+
+
+<p>&nbsp;</p>
+
+
+<a name="savingtoconfig"></a>
+<h1>Saving Sets of Validation Rules to a Config File</h1>
+
+<p>A nice feature of the Form Validation class is that it permits you to store all your validation rules for your entire application in a config file.  You
+can organize these rules into "groups".  These groups can either be loaded automatically when a matching controller/function is called, or
+you can manually call each set as needed.</p>
+
+<h3>How to save your rules</h3>
+
+<p>To store your validation rules, simply create a file named <kbd>form_validation.php</kbd> in your <dfn>application/config/</dfn> folder.
+In that file you will place an array named <kbd>$config</kbd> with your rules. As shown earlier, the validation array will have this prototype:</p>
+
+<code>
+$config = array(<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;array(<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'field'&nbsp;&nbsp;&nbsp;=> 'username', <br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'label'&nbsp;&nbsp;&nbsp;=> 'Username', <br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'rules'&nbsp;&nbsp;&nbsp;=> 'required'<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;),<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;array(<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'field'&nbsp;&nbsp;&nbsp;=> 'password', <br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'label'&nbsp;&nbsp;&nbsp;=> 'Password', <br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'rules'&nbsp;&nbsp;&nbsp;=> 'required'<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;),<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;array(<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'field'&nbsp;&nbsp;&nbsp;=> 'passconf', <br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'label'&nbsp;&nbsp;&nbsp;=> 'Password Confirmation', <br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'rules'&nbsp;&nbsp;&nbsp;=> 'required'<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;),&nbsp;&nbsp;&nbsp;<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;array(<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'field'&nbsp;&nbsp;&nbsp;=> 'email', <br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'label'&nbsp;&nbsp;&nbsp;=> 'Email', <br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'rules'&nbsp;&nbsp;&nbsp;=> 'required'<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;)<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;);<br />
+</code>
+
+<p><dfn>Your validation rule file will be loaded automatically and used when you call the run() function.</dfn></p>
+
+<p class="important">Please note that you MUST name your array $config.</p>
+
+<h3>Creating Sets of Rules</h3>
+
+<p>In order to organize your rules into "sets" requires that you place them into "sub arrays".  Consider the following example, showing two sets of rules.
+We've arbitrarily called these two rules "signup" and "email".  You can name your rules anything you want:</p>
+
+
+<code>$config = array(<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'<kbd>signup</kbd>' => array(<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;array(<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'field' => 'username',<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'label' => 'Username',<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'rules' => 'required'<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;),<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;array(<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'field' => 'password',<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'label' => 'Password',<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'rules' => 'required'<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;),<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;array(<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'field' => 'passconf',<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'label' => 'PasswordConfirmation',<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'rules' => 'required'<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;),<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;array(<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'field' => 'email',<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'label' => 'Email',<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'rules' => 'required'<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;)<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;),<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'<kbd>email</kbd>' => array(<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;array(<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'field' => 'emailaddress',<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'label' => 'EmailAddress',<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'rules' => 'required|valid_email'<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;),<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;array(<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'field' => 'name',<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'label' => 'Name',<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'rules' => 'required|alpha'<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;),<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;array(<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'field' => 'title',<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'label' => 'Title',<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'rules' => 'required'<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;),<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;array(<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'field' => 'message',<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'label' => 'MessageBody',<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'rules' => 'required'<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;)<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;);<br />
+</code>
+
+
+<h3>Calling a Specific Rule Group</h3>
+
+<p>In order to call a specific group you will pass its name to the <kbd>run()</kbd> function.  For example, to call the <kbd>signup</kbd> rule you will do this:</p>
+
+<code>
+if ($this->form_validation->run('<kbd>signup</kbd>') == FALSE)<br />
+{<br />
+&nbsp;&nbsp;&nbsp;$this->load->view('myform');<br />
+}<br />
+else<br />
+{<br />
+&nbsp;&nbsp;&nbsp;$this->load->view('formsuccess');<br />
+}<br />
+</code>
+
+
+
+<h3>Associating a Controller Function with a Rule Group</h3>
+
+<p>An alternate (and more automatic) method of calling a rule group is to name it according to the controller class/function you intend to use it with.  For example, let's say you
+have a controller named <kbd>Member</kbd> and a function named <kbd>signup</kbd>.  Here's what your class might look like:</p>
+
+<code>
+&lt;?php<br /><br />
+class <kbd>Member</kbd> extends CI_Controller {<br />
+<br />
+&nbsp;&nbsp;&nbsp;function <kbd>signup</kbd>()<br />
+&nbsp;&nbsp;&nbsp;{&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$this->load->library('form_validation');<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if ($this->form_validation->run() == FALSE)<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$this->load->view('myform');<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;else<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$this->load->view('formsuccess');<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br />
+&nbsp;&nbsp;&nbsp;}<br />
+}<br />
+?></code>
+
+<p>In your validation config file, you will name your rule group <kbd>member/signup</kbd>:</p>
+
+
+<code>$config = array(<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'<kbd>member/signup</kbd>' => array(<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;array(<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'field' => 'username',<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'label' => 'Username',<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'rules' => 'required'<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;),<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;array(<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'field' => 'password',<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'label' => 'Password',<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'rules' => 'required'<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;),<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;array(<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'field' => 'passconf',<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'label' => 'PasswordConfirmation',<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'rules' => 'required'<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;),<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;array(<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'field' => 'email',<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'label' => 'Email',<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'rules' => 'required'<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;)<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;)<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;);<br />
+</code>
+
+<p><dfn>When a rule group is named identically to a controller class/function it will be used automatically when the run() function is invoked from that class/function.</dfn></p>
+
+<p>&nbsp;</p>
+
+
+<a name="arraysasfields"></a>
+<h1>Using Arrays as Field Names</h1>
+
+<p>The Form Validation class supports the use of arrays as field names.  Consider this example:</p>
+
+<code>&lt;input type="text" name="<kbd>options[]</kbd>" value="" size="50" /></code>
+
+<p>If you do use an array as a field name, you must use the EXACT array name in the <a href="#helperreference">Helper Functions</a> that require the field name,
+and as your Validation Rule field name.</p>
+
+<p>For example, to set a rule for the above field you would use:</p>
+
+<code>$this->form_validation->set_rules('<kbd>options[]</kbd>', 'Options', 'required');</code>
+
+<p>Or, to show an error for the above field you would use:</p>
+
+<code>&lt;?php echo form_error('<kbd>options[]</kbd>'); ?></code>
+
+<p>Or to re-populate the field you would use:</p>
+
+<code>&lt;input type="text" name="<kbd>options[]</kbd>" value="<kbd>&lt;?php echo set_value('<kbd>options[]</kbd>'); ?></kbd>" size="50" /></code>
+
+<p>You can use multidimensional arrays as field names as well. For example:</p>
+
+<code>&lt;input type="text" name="<kbd>options[size]</kbd>" value="" size="50" /></code>
+
+<p>Or even:</p>
+
+<code>&lt;input type="text" name="<kbd>sports[nba][basketball]</kbd>" value="" size="50" /></code>
+
+<p>As with our first example, you must use the exact array name in the helper functions:</p>
+
+<code>&lt;?php echo form_error('<kbd>sports[nba][basketball]</kbd>'); ?></code>
+
+<p>If you are using checkboxes (or other fields) that have multiple options, don't forget to leave an empty bracket after each option, so that all selections will be added to the
+POST array:</p>
+
+<code>
+&lt;input type="checkbox" name="<kbd>options[]</kbd>" value="red" /><br />
+&lt;input type="checkbox" name="<kbd>options[]</kbd>" value="blue" /><br />
+&lt;input type="checkbox" name="<kbd>options[]</kbd>" value="green" />
+</code>
+
+<p>Or if you use a multidimensional array:</p>
+
+<code>
+&lt;input type="checkbox" name="<kbd>options[color][]</kbd>" value="red" /><br />
+&lt;input type="checkbox" name="<kbd>options[color][]</kbd>" value="blue" /><br />
+&lt;input type="checkbox" name="<kbd>options[color][]</kbd>" value="green" />
+</code>
+
+<p>When you use a helper function you'll include the bracket as well:</p>
+
+<code>&lt;?php echo form_error('<kbd>options[color][]</kbd>'); ?></code>
+
+
+
+
+<p>&nbsp;</p>
+
+
+<a name="rulereference"></a>
+<h1>Rule Reference</h1>
+
+<p>The following is a list of all the native rules that are available to use:</p>
+
+
+<table cellpadding="0" cellspacing="1" border="0" style="width:100%" class="tableborder">
+       <tr>
+               <th>Rule</th>
+               <th>Parameter</th>
+               <th>Description</th>
+               <th>Example</th>
+       </tr>
+
+       <tr>
+               <td class="td"><strong>required</strong></td>
+               <td class="td">No</td>
+               <td class="td">Returns FALSE if the form element is empty.</td>
+               <td class="td">&nbsp;</td>
+       </tr>
+
+       <tr>
+               <td class="td"><strong>matches</strong></td>
+               <td class="td">Yes</td>
+               <td class="td">Returns FALSE if the form element does not match the one in the parameter.</td>
+               <td class="td">matches[form_item]</td>
+       </tr>
+
+       <tr>
+               <td class="td"><strong>min_length</strong></td>
+               <td class="td">Yes</td>
+               <td class="td">Returns FALSE if the form element is shorter then the parameter value.</td>
+               <td class="td">min_length[6]</td>
+       </tr>
+
+       <tr>
+               <td class="td"><strong>max_length</strong></td>
+               <td class="td">Yes</td>
+               <td class="td">Returns FALSE if the form element is longer then the parameter value.</td>
+               <td class="td">max_length[12]</td>
+       </tr>
+
+       <tr>
+               <td class="td"><strong>exact_length</strong></td>
+               <td class="td">Yes</td>
+               <td class="td">Returns FALSE if the form element is not exactly the parameter value.</td>
+               <td class="td">exact_length[8]</td>
+       </tr>
+
+       <tr>
+               <td class="td"><strong>greater_than</strong></td>
+               <td class="td">Yes</td>
+               <td class="td">Returns FALSE if the form element is less than the parameter value or not numeric.</td>
+               <td class="td">greater_than[8]</td>
+       </tr>
+
+       <tr>
+               <td class="td"><strong>less_than</strong></td>
+               <td class="td">Yes</td>
+               <td class="td">Returns FALSE if the form element is greater than the parameter value or not numeric.</td>
+               <td class="td">less_than[8]</td>
+       </tr>
+
+       <tr>
+               <td class="td"><strong>alpha</strong></td>
+               <td class="td">No</td>
+               <td class="td">Returns FALSE if the form element contains anything other than alphabetical characters.</td>
+               <td class="td">&nbsp;</td>
+       </tr>
+
+       <tr>
+               <td class="td"><strong>alpha_numeric</strong></td>
+               <td class="td">No</td>
+               <td class="td">Returns FALSE if the form element contains anything other than alpha-numeric characters.</td>
+               <td class="td">&nbsp;</td>
+       </tr>
+
+       <tr>
+               <td class="td"><strong>alpha_dash</strong></td>
+               <td class="td">No</td>
+               <td class="td">Returns FALSE if the form element contains anything other than alpha-numeric characters, underscores or dashes.</td>
+               <td class="td">&nbsp;</td>
+       </tr>
+
+       <tr>
+               <td class="td"><strong>numeric</strong></td>
+               <td class="td">No</td>
+               <td class="td">Returns FALSE if the form element contains anything other than numeric characters.</td>
+               <td class="td">&nbsp;</td>
+       </tr>
+
+       <tr>
+               <td class="td"><strong>integer</strong></td>
+               <td class="td">No</td>
+               <td class="td">Returns FALSE if the form element contains anything other than an integer.</td>
+               <td class="td">&nbsp;</td>
+       </tr>
+
+       <tr>
+               <td class="td"><strong>decimal</strong></td>
+               <td class="td">Yes</td>
+               <td class="td">Returns FALSE if the form element is not exactly the parameter value.</td>
+               <td class="td">&nbsp;</td>
+       </tr>
+
+       <tr>
+               <td class="td"><strong>is_natural</strong></td>
+               <td class="td">No</td>
+               <td class="td">Returns FALSE if the form element contains anything other than a natural number: 0, 1, 2, 3, etc.</td>
+               <td class="td">&nbsp;</td>
+       </tr>
+
+       <tr>
+               <td class="td"><strong>is_natural_no_zero</strong></td>
+               <td class="td">No</td>
+               <td class="td">Returns FALSE if the form element contains anything other than a natural number, but not zero: 1, 2, 3, etc.</td>
+               <td class="td">&nbsp;</td>
+       </tr>
+
+       <tr>
+               <td class="td"><strong>valid_email</strong></td>
+               <td class="td">No</td>
+               <td class="td">Returns FALSE if the form element does not contain a valid email address.</td>
+               <td class="td">&nbsp;</td>
+       </tr>
+
+       <tr>
+               <td class="td"><strong>valid_emails</strong></td>
+               <td class="td">No</td>
+               <td class="td">Returns FALSE if any value provided in a comma separated list is not a valid email.</td>
+               <td class="td">&nbsp;</td>
+       </tr>
+
+       <tr>
+               <td class="td"><strong>valid_ip</strong></td>
+               <td class="td">No</td>
+               <td class="td">Returns FALSE if the supplied IP is not valid.</td>
+               <td class="td">&nbsp;</td>
+       </tr>
+
+       <tr>
+               <td class="td"><strong>valid_base64</strong></td>
+               <td class="td">No</td>
+               <td class="td">Returns FALSE if the supplied string contains anything other than valid Base64 characters.</td>
+               <td class="td">&nbsp;</td>
+       </tr>
+
+
+</table>
+
+<p><strong>Note:</strong> These rules can also be called as discrete functions. For example:</p>
+
+<code>$this->form_validation->required($string);</code>
+
+<p class="important"><strong>Note:</strong> You can also use any native PHP functions that permit one parameter.</p>
+
+
+
+<p>&nbsp;</p>
+
+<a name="preppingreference"></a>
+<h1>Prepping Reference</h1>
+
+<p>The following is a list of all the prepping functions that are available to use:</p>
+
+
+
+<table cellpadding="0" cellspacing="1" border="0" style="width:100%" class="tableborder">
+       <tr>
+               <th>Name</th>
+               <th>Parameter</th>
+               <th>Description</th>
+       </tr><tr>
+
+               <td class="td"><strong>xss_clean</strong></td>
+               <td class="td">No</td>
+               <td class="td">Runs the data through the XSS filtering function, described in the <a href="input.html">Input Class</a> page.</td>
+       </tr><tr>
+
+               <td class="td"><strong>prep_for_form</strong></td>
+               <td class="td">No</td>
+               <td class="td">Converts special characters so that HTML data can be shown in a form field without breaking it.</td>
+       </tr><tr>
+
+               <td class="td"><strong>prep_url</strong></td>
+               <td class="td">No</td>
+               <td class="td">Adds "http://" to URLs if missing.</td>
+       </tr><tr>
+
+               <td class="td"><strong>strip_image_tags</strong></td>
+               <td class="td">No</td>
+               <td class="td">Strips the HTML from image tags leaving the raw URL.</td>
+       </tr><tr>
+
+               <td class="td"><strong>encode_php_tags</strong></td>
+               <td class="td">No</td>
+               <td class="td">Converts PHP tags to entities.</td>
+       </tr>
+
+</table>
+
+<p class="important"><strong>Note:</strong> You can also use any native PHP functions that permit one parameter,
+like <kbd>trim</kbd>, <kbd>htmlspecialchars</kbd>, <kbd>urldecode</kbd>, etc.</p>
+
+
+
+
+
+
+
+<p>&nbsp;</p>
+
+<a name="functionreference"></a>
+<h1>Function Reference</h1>
+
+<p>The following functions are intended for use in your controller functions.</p>
+
+<h2>$this->form_validation->set_rules();</h2>
+
+<p>Permits you to set validation rules, as described in the tutorial sections above:</p>
+
+<ul>
+<li><a href="#validationrules">Setting Validation Rules</a></li>
+<li><a href="#savingtoconfig">Saving Groups of Validation Rules to a Config File</a></li>
+</ul>
+
+
+<h2>$this->form_validation->run();</h2>
+
+<p>Runs the validation routines.  Returns boolean TRUE on success and FALSE on failure. You can optionally pass the name of the validation
+group via the function, as described in: <a href="#savingtoconfig">Saving Groups of Validation Rules to a Config File</a>.</p>
+
+
+<h2>$this->form_validation->set_message();</h2>
+
+<p>Permits you to set custom error messages.  See <a href="#settingerrors">Setting Error Messages</a> above.</p>
+
+
+<p>&nbsp;</p>
+
+<a name="helperreference"></a>
+<h1>Helper Reference</h1>
+
+<p>The following helper functions are available for use in the view files containing your forms.  Note that these are procedural functions, so they
+<strong>do not</strong> require you to prepend them with $this->form_validation.</p>
+
+<h2>form_error()</h2>
+
+<p>Shows an individual error message associated with the field name supplied to the function.  Example:</p>
+
+<code>&lt;?php echo form_error('username'); ?></code>
+
+<p>The error delimiters can be optionally specified.  See the <a href="#errordelimiters">Changing the Error Delimiters</a> section above.</p>
+
+
+
+<h2>validation_errors()</h2>
+<p>Shows all error messages as a string:  Example:</p>
+
+<code>&lt;?php echo validation_errors(); ?></code>
+
+<p>The error delimiters can be optionally specified.  See the <a href="#errordelimiters">Changing the Error Delimiters</a> section above.</p>
+
+
+
+<h2>set_value()</h2>
+
+<p>Permits you to set the value of an input form or textarea. You must supply the field name via the first parameter of the function.
+The second (optional) parameter allows you to set a default value for the form. Example:</p>
+
+<code>&lt;input type="text" name="quantity" value="<dfn>&lt;?php echo set_value('quantity', '0'); ?></dfn>" size="50" /></code>
+
+<p>The above form will show "0" when loaded for the first time.</p>
+
+<h2>set_select()</h2>
+
+<p>If you use a <dfn>&lt;select></dfn> menu, this function permits you to display the menu item that was selected.  The first parameter
+must contain the name of the select menu, the second parameter must contain the value of
+each item, and the third (optional) parameter lets you set an item as the default (use boolean TRUE/FALSE).</p>
+
+<p>Example:</p>
+
+<code>
+&lt;select name="myselect"><br />
+&lt;option value="one" <dfn>&lt;?php echo  set_select('myselect', 'one', TRUE); ?></dfn> >One&lt;/option><br />
+&lt;option value="two" <dfn>&lt;?php echo  set_select('myselect', 'two'); ?></dfn> >Two&lt;/option><br />
+&lt;option value="three" <dfn>&lt;?php echo  set_select('myselect', 'three'); ?></dfn> >Three&lt;/option><br />
+&lt;/select>
+</code>
+
+
+<h2>set_checkbox()</h2>
+
+<p>Permits you to display a checkbox in the state it was submitted.  The first parameter
+must contain the name of the checkbox, the second parameter must contain its value, and the third (optional) parameter lets you set an item as the default (use boolean TRUE/FALSE). Example:</p>
+
+<code>&lt;input type="checkbox" name="mycheck[]" value="1" <dfn>&lt;?php echo set_checkbox('mycheck[]', '1'); ?></dfn> /><br />
+&lt;input type="checkbox" name="mycheck[]" value="2" <dfn>&lt;?php echo set_checkbox('mycheck[]', '2'); ?></dfn> /></code>
+
+
+<h2>set_radio()</h2>
+
+<p>Permits you to display radio buttons in the state they were submitted. This function is identical to the <strong>set_checkbox()</strong> function above.</p>
+
+<code>&lt;input type="radio" name="myradio" value="1" <dfn>&lt;?php echo  set_radio('myradio', '1', TRUE); ?></dfn> /><br />
+&lt;input type="radio" name="myradio" value="2" <dfn>&lt;?php echo  set_radio('myradio', '2'); ?></dfn> /></code>
+
+
+
+</div>
+<!-- END CONTENT -->
+
+
+<div id="footer">
+<p>
+Previous Topic:&nbsp;&nbsp;<a href="file_uploading.html">File Uploading Class</a>
+&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+<a href="#top">Top of Page</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+<a href="../index.html">User Guide Home</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+Next Topic:&nbsp;&nbsp;<a href="ftp.html">FTP Class</a>
+</p>
+<p><a href="http://codeigniter.com">CodeIgniter</a> &nbsp;&middot;&nbsp; Copyright &#169; 2006 - 2011 &nbsp;&middot;&nbsp; <a href="http://ellislab.com/">EllisLab, Inc.</a></p>
+</div>
+
+</body>
+</html>
\ No newline at end of file
diff --git a/user_guide/libraries/ftp.html b/user_guide/libraries/ftp.html
new file mode 100755 (executable)
index 0000000..43b949a
--- /dev/null
@@ -0,0 +1,316 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head>
+
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+<title>FTP Class : CodeIgniter User Guide</title>
+
+<style type='text/css' media='all'>@import url('../userguide.css');</style>
+<link rel='stylesheet' type='text/css' media='all' href='../userguide.css' />
+
+<script type="text/javascript" src="../nav/nav.js"></script>
+<script type="text/javascript" src="../nav/prototype.lite.js"></script>
+<script type="text/javascript" src="../nav/moo.fx.js"></script>
+<script type="text/javascript" src="../nav/user_guide_menu.js"></script>
+
+<meta http-equiv='expires' content='-1' />
+<meta http-equiv= 'pragma' content='no-cache' />
+<meta name='robots' content='all' />
+<meta name='author' content='ExpressionEngine Dev Team' />
+<meta name='description' content='CodeIgniter User Guide' />
+
+</head>
+<body>
+
+<!-- START NAVIGATION -->
+<div id="nav"><div id="nav_inner"><script type="text/javascript">create_menu('../');</script></div></div>
+<div id="nav2"><a name="top"></a><a href="javascript:void(0);" onclick="myHeight.toggle();"><img src="../images/nav_toggle_darker.jpg" width="154" height="43" border="0" title="Toggle Table of Contents" alt="Toggle Table of Contents" /></a></div>
+<div id="masthead">
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td><h1>CodeIgniter User Guide Version 2.0.2</h1></td>
+<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
+</tr>
+</table>
+</div>
+<!-- END NAVIGATION -->
+
+
+<!-- START BREADCRUMB -->
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td id="breadcrumb">
+<a href="http://codeigniter.com/">CodeIgniter Home</a> &nbsp;&#8250;&nbsp;
+<a href="../index.html">User Guide Home</a> &nbsp;&#8250;&nbsp;
+FTP Class
+</td>
+<td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="codeigniter.com/user_guide/" />Search User Guide&nbsp; <input type="text" class="input" style="width:200px;" name="q" id="q" size="31" maxlength="255" value="" />&nbsp;<input type="submit" class="submit" name="sa" value="Go" /></form></td>
+</tr>
+</table>
+<!-- END BREADCRUMB -->
+
+<br clear="all" />
+
+
+<!-- START CONTENT -->
+<div id="content">
+
+
+<h1>FTP Class</h1>
+
+<p>CodeIgniter's FTP Class permits files to be transfered to a remote server. Remote files can also be moved, renamed,
+and deleted.  The FTP class also includes a "mirroring" function that permits an entire local directory to be recreated remotely via FTP.</p>
+
+<p class="important"><strong>Note:</strong>&nbsp; SFTP and SSL FTP protocols are not supported, only standard FTP.</p>
+
+<h2>Initializing the Class</h2>
+
+<p>Like most other classes in CodeIgniter, the FTP class is initialized in your controller using the <dfn>$this->load->library</dfn> function:</p>
+
+<code>$this->load->library('ftp');</code>
+<p>Once loaded, the FTP object will be available using: <dfn>$this->ftp</dfn></p>
+
+
+<h2>Usage Examples</h2>
+
+<p>In this example a connection is opened to the FTP server, and a local file is read and uploaded in ASCII mode. The
+file permissions are set to 755.  Note: Setting permissions requires PHP 5.</p>
+
+<code>
+$this->load->library('ftp');<br />
+<br />
+$config['hostname'] = 'ftp.example.com';<br />
+$config['username'] = 'your-username';<br />
+$config['password'] = 'your-password';<br />
+$config['debug']       = TRUE;<br />
+<br />
+$this->ftp->connect($config);<br />
+<br />
+$this->ftp->upload('/local/path/to/myfile.html', '/public_html/myfile.html', 'ascii', 0775);<br />
+<br />
+$this->ftp->close();
+
+</code>
+
+
+<p>In this example a list of files is retrieved from the server.</p>
+
+<code>
+$this->load->library('ftp');<br />
+<br />
+$config['hostname'] = 'ftp.example.com';<br />
+$config['username'] = 'your-username';<br />
+$config['password'] = 'your-password';<br />
+$config['debug']       = TRUE;<br />
+<br />
+$this->ftp->connect($config);<br />
+<br />
+$list = $this->ftp->list_files('/public_html/');<br />
+<br />
+print_r($list);<br />
+<br />
+$this->ftp->close();
+</code>
+
+<p>In this example a local directory is mirrored on the server.</p>
+
+
+<code>
+$this->load->library('ftp');<br />
+<br />
+$config['hostname'] = 'ftp.example.com';<br />
+$config['username'] = 'your-username';<br />
+$config['password'] = 'your-password';<br />
+$config['debug']       = TRUE;<br />
+<br />
+$this->ftp->connect($config);<br />
+<br />
+$this->ftp->mirror('/path/to/myfolder/', '/public_html/myfolder/');<br />
+<br />
+$this->ftp->close();
+</code>
+
+
+<h1>Function Reference</h1>
+
+<h2>$this->ftp->connect()</h2>
+
+<p>Connects and logs into to the FTP server. Connection preferences are set by passing an array
+to the function, or you can store them in a config file.</p>
+
+
+<p>Here is an example showing how you set preferences manually:</p>
+
+<code>
+$this->load->library('ftp');<br />
+<br />
+$config['hostname'] = 'ftp.example.com';<br />
+$config['username'] = 'your-username';<br />
+$config['password'] = 'your-password';<br />
+$config['port']&nbsp;&nbsp;&nbsp;&nbsp; = 21;<br />
+$config['passive']&nbsp;&nbsp;= FALSE;<br />
+$config['debug']&nbsp;&nbsp;&nbsp;&nbsp;= TRUE;<br />
+<br />
+$this->ftp->connect($config);<br />
+</code>
+
+<h3>Setting FTP Preferences in a Config File</h3>
+
+<p>If you prefer you can store your FTP preferences in a config file.
+Simply create a new file called the <var>ftp.php</var>,  add the <var>$config</var>
+array in that file. Then save the file at <var>config/ftp.php</var> and it will be used automatically.</p>
+
+<h3>Available connection options:</h3>
+
+
+<ul>
+<li><strong>hostname</strong> - the FTP hostname.  Usually something like:&nbsp; <dfn>ftp.example.com</dfn></li>
+<li><strong>username</strong> - the FTP username.</li>
+<li><strong>password</strong> - the FTP password.</li>
+<li><strong>port</strong> - The port number. Set to <dfn>21</dfn> by default.</li>
+<li><strong>debug</strong> - <kbd>TRUE/FALSE</kbd> (boolean). Whether to enable debugging to display error messages.</li>
+<li><strong>passive</strong> - <kbd>TRUE/FALSE</kbd> (boolean). Whether to use passive mode.  Passive is set automatically by default.</li>
+</ul>
+
+
+
+<h2>$this->ftp->upload()</h2>
+
+<p>Uploads a file to your server.  You must supply the local path and the remote path, and you can optionally set the mode and permissions.
+Example:</p>
+
+
+<code>$this->ftp->upload('/local/path/to/myfile.html', '/public_html/myfile.html', 'ascii', 0775);</code>
+
+<p><strong>Mode options are:</strong>&nbsp; <kbd>ascii</kbd>, <kbd>binary</kbd>, and <kbd>auto</kbd> (the default). If
+<kbd>auto</kbd> is used it will base the mode on the file extension of the source file.</p>
+
+<p>Permissions are available if you are running PHP 5 and can be passed as an <kbd>octal</kbd> value in the fourth parameter.</p>
+
+
+<h2>$this->ftp->download()</h2>
+
+<p>Downloads a file from your server.  You must supply the remote path and the local path, and you can optionally set the mode.
+Example:</p>
+
+<code>$this->ftp->download('/public_html/myfile.html', '/local/path/to/myfile.html', 'ascii');</code>
+
+<p><strong>Mode options are:</strong>&nbsp; <kbd>ascii</kbd>, <kbd>binary</kbd>, and <kbd>auto</kbd> (the default). If
+<kbd>auto</kbd> is used it will base the mode on the file extension of the source file.</p>
+
+<p>Returns FALSE if the download does not execute successfully (including if PHP does not have permission to write the local file)</p>
+
+
+<h2>$this->ftp->rename()</h2>
+<p>Permits you to rename a file.  Supply the source file name/path and the new file name/path.</p>
+
+<code>
+// Renames green.html to blue.html<br />
+$this->ftp->rename('/public_html/foo/green.html', '/public_html/foo/blue.html');
+</code>
+
+<h2>$this->ftp->move()</h2>
+<p>Lets you move a file.  Supply the source and destination paths:</p>
+
+<code>
+// Moves blog.html from "joe" to "fred"<br />
+$this->ftp->move('/public_html/joe/blog.html', '/public_html/fred/blog.html');
+</code>
+
+<p>Note: if the destination file name is different the file will be renamed.</p>
+
+
+<h2>$this->ftp->delete_file()</h2>
+<p>Lets you delete a file.  Supply the source path with the file name.</p>
+
+<code>
+$this->ftp->delete_file('/public_html/joe/blog.html');
+</code>
+
+
+<h2>$this->ftp->delete_dir()</h2>
+<p>Lets you delete a directory and everything it contains.  Supply the source path to the directory with a trailing slash.</p>
+
+<p class="important"><strong>Important</strong>&nbsp; Be VERY careful with this function.  It will recursively delete
+<b>everything</b> within the supplied path, including sub-folders and all files.  Make absolutely sure your path is correct.
+Try using the <kbd>list_files()</kbd> function first to verify that your path is correct.</p>
+
+<code>
+$this->ftp->delete_dir('/public_html/path/to/folder/');
+</code>
+
+
+
+<h2>$this->ftp->list_files()</h2>
+<p>Permits you to retrieve a list of files on your server returned as an <dfn>array</dfn>.  You must supply
+the path to the desired directory.</p>
+
+<code>
+$list = $this->ftp->list_files('/public_html/');<br />
+<br />
+print_r($list);
+</code>
+
+
+<h2>$this->ftp->mirror()</h2>
+
+<p>Recursively reads a local folder and everything it contains (including sub-folders) and creates a
+mirror via FTP based on it.  Whatever the directory structure of the original file path will be recreated on the server.
+You must supply a source path and a destination path:</p>
+
+<code>
+$this->ftp->mirror('/path/to/myfolder/', '/public_html/myfolder/');
+</code>
+
+
+
+<h2>$this->ftp->mkdir()</h2>
+
+<p>Lets you create a directory on your server.  Supply the path ending in the folder name you wish to create, with a trailing slash.
+Permissions can be set by passed an <kbd>octal</kbd> value in the second parameter (if you are running PHP 5).</p>
+
+<code>
+// Creates a folder named "bar"<br />
+$this->ftp->mkdir('/public_html/foo/bar/', DIR_WRITE_MODE);
+</code>
+
+
+<h2>$this->ftp->chmod()</h2>
+
+<p>Permits you to set file permissions.  Supply the path to the file or folder you wish to alter permissions on:</p>
+
+<code>
+// Chmod "bar" to 777<br />
+$this->ftp->chmod('/public_html/foo/bar/', DIR_WRITE_MODE);
+</code>
+
+
+
+
+<h2>$this->ftp->close();</h2>
+<p>Closes the connection to your server.  It's recommended that you use this when you are finished uploading.</p>
+
+
+
+
+
+
+
+
+</div>
+<!-- END CONTENT -->
+
+
+<div id="footer">
+<p>
+Previous Topic:&nbsp;&nbsp;<a href="form_validation.html">Form Validation Class</a>
+&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+<a href="#top">Top of Page</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+<a href="../index.html">User Guide Home</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+Next Topic:&nbsp;&nbsp;<a href="table.html">HTML Table Class</a>
+</p>
+<p><a href="http://codeigniter.com">CodeIgniter</a> &nbsp;&middot;&nbsp; Copyright &#169; 2006 - 2011 &nbsp;&middot;&nbsp; <a href="http://ellislab.com/">EllisLab, Inc.</a></p>
+</div>
+
+</body>
+</html>
\ No newline at end of file
diff --git a/user_guide/libraries/image_lib.html b/user_guide/libraries/image_lib.html
new file mode 100755 (executable)
index 0000000..dbf0776
--- /dev/null
@@ -0,0 +1,667 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head>
+
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+<title>Image Manipulation Class : CodeIgniter User Guide</title>
+
+<style type='text/css' media='all'>@import url('../userguide.css');</style>
+<link rel='stylesheet' type='text/css' media='all' href='../userguide.css' />
+
+<script type="text/javascript" src="../nav/nav.js"></script>
+<script type="text/javascript" src="../nav/prototype.lite.js"></script>
+<script type="text/javascript" src="../nav/moo.fx.js"></script>
+<script type="text/javascript" src="../nav/user_guide_menu.js"></script>
+
+<meta http-equiv='expires' content='-1' />
+<meta http-equiv= 'pragma' content='no-cache' />
+<meta name='robots' content='all' />
+<meta name='author' content='ExpressionEngine Dev Team' />
+<meta name='description' content='CodeIgniter User Guide' />
+
+</head>
+<body>
+
+<!-- START NAVIGATION -->
+<div id="nav"><div id="nav_inner"><script type="text/javascript">create_menu('../');</script></div></div>
+<div id="nav2"><a name="top"></a><a href="javascript:void(0);" onclick="myHeight.toggle();"><img src="../images/nav_toggle_darker.jpg" width="154" height="43" border="0" title="Toggle Table of Contents" alt="Toggle Table of Contents" /></a></div>
+<div id="masthead">
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td><h1>CodeIgniter User Guide Version 2.0.2</h1></td>
+<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
+</tr>
+</table>
+</div>
+<!-- END NAVIGATION -->
+
+
+<!-- START BREADCRUMB -->
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td id="breadcrumb">
+<a href="http://codeigniter.com/">CodeIgniter Home</a> &nbsp;&#8250;&nbsp;
+<a href="../index.html">User Guide Home</a> &nbsp;&#8250;&nbsp;
+Image Manipulation Class
+</td>
+<td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="codeigniter.com/user_guide/" />Search User Guide&nbsp; <input type="text" class="input" style="width:200px;" name="q" id="q" size="31" maxlength="255" value="" />&nbsp;<input type="submit" class="submit" name="sa" value="Go" /></form></td>
+</tr>
+</table>
+<!-- END BREADCRUMB -->
+
+<br clear="all" />
+
+
+<!-- START CONTENT -->
+<div id="content">
+
+
+<h1>Image Manipulation Class</h1>
+
+<p>CodeIgniter's Image Manipulation class lets you perform the following actions:</p>
+
+<ul>
+<li>Image Resizing</li>
+<li>Thumbnail Creation</li>
+<li>Image Cropping</li>
+<li>Image Rotating</li>
+<li>Image Watermarking</li>
+</ul>
+
+<p>All three major image libraries are supported:  GD/GD2, NetPBM, and ImageMagick</p>
+
+<p class="important"><strong>Note:</strong> Watermarking is only available using the GD/GD2 library.
+In addition, even though other libraries are supported, GD is required in
+order for the script to calculate the image properties.  The image processing, however, will be performed with the
+library you specify.</p>
+
+
+<h2>Initializing the Class</h2>
+
+<p>Like most other classes in CodeIgniter, the image class is initialized in your controller
+using the <dfn>$this->load-&gt;library</dfn> function:</p>
+<code>$this->load->library('image_lib');</code>
+
+<p>Once the library is loaded it will be ready for use.  The image library object you will use to call all functions is: <dfn>$this->image_lib</dfn></p>
+
+
+<h2>Processing an Image</h2>
+
+<p>Regardless of the type of processing you would like to perform (resizing, cropping, rotation, or watermarking), the general process is
+identical. You will set some preferences corresponding to the action you intend to perform, then
+call one of four available processing functions.  For example, to create an image thumbnail you'll do this:</p>
+
+<code>$config['image_library'] = 'gd2';<br />
+$config['source_image']        = '/path/to/image/mypic.jpg';<br />
+$config['create_thumb'] = TRUE;<br />
+$config['maintain_ratio'] = TRUE;<br />
+$config['width']               = 75;<br />
+$config['height']      = 50;<br />
+<br />
+$this->load->library('image_lib', $config);
+<br />
+<br />
+$this->image_lib->resize();</code>
+
+<p>The above code tells the <dfn>image_resize</dfn> function to look for an image called <em>mypic.jpg</em>
+located in the <dfn>source_image</dfn> folder, then create a thumbnail that is 75 X 50 pixels using the GD2 <dfn>image_library</dfn>.
+Since the <dfn>maintain_ratio</dfn> option is enabled, the thumb will be as close to the target <dfn>width</dfn> and
+<dfn>height</dfn> as possible while preserving the original aspect ratio.  The thumbnail will be called <em>mypic_thumb.jpg</em>
+</p>
+
+<p class="important"><strong>Note:</strong> In order for the image class to be allowed to do any processing, the
+folder containing the image files must have write permissions.</p>
+
+<p class="important"><strong>Note:</strong> Image processing can require a considerable amount of server memory for some operations. If you are experiencing out of memory errors while processing images you may need to limit their maximum size, and/or adjust PHP memory limits.</p>
+
+<h2>Processing Functions</h2>
+
+<p>There are four available processing functions:</p>
+
+<ul>
+<li>$this->image_lib->resize()</li>
+<li>$this->image_lib->crop()</li>
+<li>$this->image_lib->rotate()</li>
+<li>$this->image_lib->watermark()</li>
+<li>$this-&gt;image_lib-&gt;clear()</li>
+</ul>
+
+<p>These functions return boolean TRUE upon success and FALSE for failure.  If they fail you can retrieve the
+error message using this function:</p>
+
+<code>echo $this->image_lib->display_errors();</code>
+
+<p>A good practice is use the processing function conditionally, showing an error upon failure, like this:</p>
+
+<code>if ( ! $this->image_lib->resize())<br />
+{<br />
+&nbsp;&nbsp;&nbsp;&nbsp;echo $this->image_lib->display_errors();<br />
+}</code>
+
+<p>Note:  You can optionally specify the HTML formatting to be applied to the errors, by submitting the opening/closing
+tags in the function, like this:</p>
+
+<code>$this->image_lib->display_errors('<var>&lt;p></var>', '<var>&lt;/p></var>');</code>
+
+
+<h2>Preferences</h2>
+
+<p>The  preferences described below allow you to tailor the image processing to suit your needs.</p>
+
+<p>Note that not all preferences are available for every
+function.  For example, the x/y axis preferences are only available for image cropping. Likewise, the width and height
+preferences have no effect on cropping.  The "availability" column indicates which functions support a given preference.</p>
+
+<p>Availability Legend:</p>
+
+<ul>
+<li><var>R</var> - Image Resizing</li>
+<li><var>C</var> - Image Cropping</li>
+<li><var>X</var> - Image Rotation</li>
+<li><var>W</var> - Image Watermarking</li>
+
+</ul>
+
+
+
+
+
+<table cellpadding="0" cellspacing="1" border="0" style="width:100%" class="tableborder">
+<tr>
+<th>Preference</th>
+<th>Default&nbsp;Value</th>
+<th>Options</th>
+<th>Description</th>
+<th>Availability</th>
+</tr>
+
+<tr>
+<td class="td"><strong>image_library</strong></td>
+<td class="td">GD2</td>
+<td class="td">GD, GD2, ImageMagick, NetPBM</td>
+<td class="td">Sets the image library to be used.</td>
+<td class="td">R, C, X, W</td>
+</tr>
+
+<tr>
+<td class="td"><strong>library_path</strong></td>
+<td class="td">None</td>
+<td class="td">None</td>
+<td class="td">Sets the server path to your ImageMagick or NetPBM library.  If you use either of those libraries you must supply the path.</td>
+<td class="td">R, C, X</td>
+</tr>
+
+<tr>
+<td class="td"><strong>source_image</strong></td>
+<td class="td">None</td>
+<td class="td">None</td>
+<td class="td">Sets the source image name/path.  The path must be a relative or absolute server path, not a URL.</td>
+<td class="td">R, C, S, W</td>
+</tr>
+
+<tr>
+<td class="td"><strong>dynamic_output</strong></td>
+<td class="td">FALSE</td>
+<td class="td">TRUE/FALSE (boolean)</td>
+<td class="td">Determines whether the new image file should be written to disk or generated dynamically.  Note: If you choose the dynamic setting, only one image can be shown at a time, and it can't be positioned on the page. It simply outputs the raw image dynamically to your browser, along with image headers.</td>
+<td class="td">R, C, X, W</td>
+</tr>
+
+
+<tr>
+<td class="td"><strong>quality</strong></td>
+<td class="td">90%</td>
+<td class="td">1 - 100%</td>
+<td class="td">Sets the quality of the image. The higher the quality the larger the file size.</td>
+<td class="td">R, C, X, W</td>
+</tr>
+
+
+<tr>
+<td class="td"><strong>new_image</strong></td>
+<td class="td">None</td>
+<td class="td">None</td>
+<td class="td">Sets the destination image name/path.  You'll use this preference when creating an image copy. The path must be a relative or absolute server path, not a URL.</td>
+<td class="td">R, C, X, W</td>
+</tr>
+
+<tr>
+<td class="td"><strong>width</strong></td>
+<td class="td">None</td>
+<td class="td">None</td>
+<td class="td">Sets the width you would like the image set to.</td>
+<td class="td">R, C </td>
+</tr>
+
+<tr>
+<td class="td"><strong>height</strong></td>
+<td class="td">None</td>
+<td class="td">None</td>
+<td class="td">Sets the height you would like the image set to.</td>
+<td class="td">R, C </td>
+</tr>
+
+<tr>
+<td class="td"><strong>create_thumb</strong></td>
+<td class="td">FALSE</td>
+<td class="td">TRUE/FALSE (boolean)</td>
+<td class="td">Tells the image processing function to create a thumb.</td>
+<td class="td">R</td>
+</tr>
+
+<tr>
+<td class="td"><strong>thumb_marker</strong></td>
+<td class="td">_thumb</td>
+<td class="td">None</td>
+<td class="td">Specifies the thumbnail indicator.  It will be inserted just before the file extension, so mypic.jpg would become mypic_thumb.jpg</td>
+<td class="td">R</td>
+</tr>
+
+<tr>
+<td class="td"><strong>maintain_ratio</strong></td>
+<td class="td">TRUE</td>
+<td class="td">TRUE/FALSE (boolean)</td>
+<td class="td">Specifies whether to maintain the original aspect ratio when resizing or use hard values.</td>
+<td class="td">R, C</td>
+</tr>
+
+
+<tr>
+<td class="td"><strong>master_dim</strong></td>
+<td class="td">auto</td>
+<td class="td">auto, width, height</td>
+<td class="td">Specifies what to use as the master axis when resizing or creating thumbs. For example, let's say you want to resize an image to 100 X 75 pixels. If the source image size does not allow perfect resizing to those dimensions, this setting determines which axis should be used as the hard value. "auto" sets the axis automatically based on whether the image is taller then wider, or vice versa.</td>
+<td class="td">R</td>
+</tr>
+
+
+
+
+<tr>
+<td class="td"><strong>rotation_angle</strong></td>
+<td class="td">None</td>
+<td class="td">90, 180, 270, vrt, hor</td>
+<td class="td">Specifies the angle of rotation when rotating images.  Note that PHP rotates counter-clockwise, so a 90 degree rotation to the right must be specified as 270.</td>
+<td class="td">X</td>
+</tr>
+
+<tr>
+<td class="td"><strong>x_axis</strong></td>
+<td class="td">None</td>
+<td class="td">None</td>
+<td class="td">Sets the X coordinate in pixels for image cropping. For example, a setting of 30 will crop an image 30 pixels from the left.</td>
+<td class="td">C</td>
+</tr>
+<tr>
+<td class="td"><strong>y_axis</strong></td>
+<td class="td">None</td>
+<td class="td">None</td>
+<td class="td">Sets the Y coordinate in pixels for image cropping. For example, a setting of 30 will crop an image 30 pixels from the top.</td>
+<td class="td">C</td>
+</tr>
+
+</table>
+
+
+<h2>Setting preferences in a config file</h2>
+
+<p>If you prefer not to set preferences using the above method, you can instead put them into a config file.
+Simply create a new file called <var>image_lib.php</var>,  add the <var>$config</var>
+array in that file. Then save the file in: <var>config/image_lib.php</var> and it will be used automatically. You
+will NOT need to use the <dfn>$this->image_lib->initialize</dfn> function if you save your preferences in a config file.</p>
+
+
+<h2>$this->image_lib->resize()</h2>
+
+<p>The image resizing function lets you resize the original image, create a copy (with or without resizing),
+or create a thumbnail image.</p>
+
+<p>For practical purposes there is no difference between creating a copy and creating
+a thumbnail except a thumb will have the thumbnail marker as part of the name (ie, mypic_thumb.jpg).</p>
+
+<p>All preferences listed in the table above are available for this function except these three:  rotation_angle, x_axis, and y_axis.</p>
+
+<h3>Creating a Thumbnail</h3>
+
+<p>The resizing function will create a thumbnail file (and preserve the original) if you set this preference to TRUE:</p>
+
+<code>$config['create_thumb'] = TRUE;</code>
+
+<p>This single preference determines whether a thumbnail is created or not.</p>
+
+<h3>Creating a Copy</h3>
+
+<p>The resizing function will create a copy of the image file (and preserve the original) if you set
+a path and/or a new filename using this preference:</p>
+
+<code>$config['new_image'] = '/path/to/new_image.jpg';</code>
+
+<p>Notes regarding this preference:</p>
+<ul>
+<li>If only the new image name is specified it will be placed in the same folder as the original</li>
+<li>If only the path is specified, the new image will be placed in the destination with the same name as the original.</li>
+<li>If both the path and image name are specified it will placed in its own destination and given the new name.</li>
+</ul>
+
+
+<h3>Resizing the Original Image</h3>
+
+<p>If neither of the two preferences listed above (create_thumb, and new_image) are used, the resizing function will instead
+target the original image for processing.</p>
+
+
+<h2>$this->image_lib->crop()</h2>
+
+<p>The cropping function works nearly identically to the resizing function except it requires that you set
+preferences for the X and Y axis (in pixels) specifying where to crop, like this:</p>
+
+<code>$config['x_axis'] = '100';<br />
+$config['y_axis'] = '40';</code>
+
+<p>All preferences listed in the table above are available for this function except these:  rotation_angle, width, height, create_thumb, new_image.</p>
+
+<p>Here's an example showing how you might crop an image:</p>
+
+<code>$config['image_library'] = 'imagemagick';<br />
+$config['library_path'] = '/usr/X11R6/bin/';<br />
+$config['source_image']        = '/path/to/image/mypic.jpg';<br />
+$config['x_axis'] = '100';<br />
+$config['y_axis'] = '60';<br />
+<br />
+$this->image_lib->initialize($config);
+<br />
+<br />
+if ( ! $this->image_lib->crop())<br />
+{<br />
+&nbsp;&nbsp;&nbsp;&nbsp;echo $this->image_lib->display_errors();<br />
+}</code>
+
+
+<p>Note: Without a visual interface it is difficult to crop images, so this function is not very useful
+unless you intend to build such an interface.  That's exactly what we did using for the photo
+gallery module in ExpressionEngine, the CMS we develop.  We added a JavaScript UI that lets the cropping
+area be selected.</p>
+
+<h2>$this->image_lib->rotate()</h2>
+
+<p>The image rotation function requires that the angle of rotation be set via its preference:</p>
+
+<code>$config['rotation_angle'] = '90';</code>
+
+<p>There are 5 rotation options:</p>
+
+<ol>
+<li>90 - rotates counter-clockwise by 90 degrees.</li>
+<li>180 - rotates counter-clockwise by 180 degrees.</li>
+<li>270 - rotates counter-clockwise by 270 degrees.</li>
+<li>hor - flips the image horizontally.</li>
+<li>vrt - flips the image vertically.</li>
+</ol>
+
+<p>Here's an example showing how you might rotate an image:</p>
+
+<code>$config['image_library'] = 'netpbm';<br />
+$config['library_path'] = '/usr/bin/';<br />
+$config['source_image']        = '/path/to/image/mypic.jpg';<br />
+$config['rotation_angle'] = 'hor';<br />
+<br />
+$this->image_lib->initialize($config);
+<br />
+<br />
+if ( ! $this->image_lib->rotate())<br />
+{<br />
+&nbsp;&nbsp;&nbsp;&nbsp;echo $this->image_lib->display_errors();<br />
+}</code>
+
+
+
+<h2>$this-&gt;image_lib-&gt;clear()</h2>
+<p>The clear function resets all of the values used when processing an image. You will want to call this if you are processing images in a loop.</p>
+<p><code>$this-&gt;image_lib-&gt;clear();</code></p>
+<p>&nbsp;</p>
+<h1>Image Watermarking</h1>
+
+<p>The Watermarking feature requires the GD/GD2 library.</p>
+
+
+<h2>Two Types of Watermarking</h2>
+
+<p>There are two types of watermarking that you can use:</p>
+
+<ul>
+<li><strong>Text</strong>: The watermark message will be generating using text, either with a True Type font that you specify, or
+using the native text output that the GD library supports. If you use the True Type version your GD installation
+must be compiled with True Type support (most are, but not all).</li>
+
+<li><strong>Overlay</strong>: The watermark message will be generated by overlaying an image (usually a transparent PNG or GIF)
+containing your watermark over the source image.</li>
+
+</ul>
+
+
+<h2>Watermarking an Image</h2>
+
+<p>Just as with the other functions (resizing, cropping, and rotating) the general process for watermarking
+involves setting the preferences corresponding to the action you intend to perform, then
+calling the watermark function.  Here is an example:</p>
+
+<code>
+$config['source_image']        = '/path/to/image/mypic.jpg';<br />
+$config['wm_text'] = 'Copyright 2006 - John Doe';<br />
+$config['wm_type'] = 'text';<br />
+$config['wm_font_path'] = './system/fonts/texb.ttf';<br />
+$config['wm_font_size']        = '16';<br />
+$config['wm_font_color'] = 'ffffff';<br />
+$config['wm_vrt_alignment']  = 'bottom';<br />
+$config['wm_hor_alignment']  = 'center';<br />
+$config['wm_padding']  = '20';<br />
+<br />
+$this->image_lib->initialize($config);
+<br />
+<br />
+$this->image_lib->watermark();</code>
+
+
+<p>The above example will use a 16 pixel True Type font to create the text "Copyright 2006 - John Doe".  The watermark
+will be positioned at the bottom/center of the image, 20 pixels from the bottom of the image.</p>
+
+<p class="important"><strong>Note:</strong> In order for the image class to be allowed to do any processing, the image file must have &quot;write&quot; file permissions. For example, 777.</p>
+
+
+<h2>Watermarking Preferences</h2>
+
+<p>This table shown the preferences that are available for both types of watermarking (text or overlay)</p>
+
+<table cellpadding="0" cellspacing="1" border="0" style="width:100%" class="tableborder">
+<tr>
+<th>Preference</th>
+<th>Default&nbsp;Value</th>
+<th>Options</th>
+<th>Description</th>
+</tr>
+
+<tr>
+<td class="td"><strong>wm_type</strong></td>
+<td class="td">text</td>
+<td class="td">text, overlay</td>
+<td class="td">Sets the type of watermarking that should be used.</td>
+</tr>
+
+<tr>
+<td class="td"><strong>source_image</strong></td>
+<td class="td">None</td>
+<td class="td">None</td>
+<td class="td">Sets the source image name/path.  The path must be a relative or absolute server path, not a URL.</td>
+</tr>
+
+<tr>
+<td class="td"><strong>dynamic_output</strong></td>
+<td class="td">FALSE</td>
+<td class="td">TRUE/FALSE (boolean)</td>
+<td class="td">Determines whether the new image file should be written to disk or generated dynamically.  Note: If you choose the dynamic setting, only one image can be shown at a time, and it can't be positioned on the page. It simply outputs the raw image dynamically to your browser, along with image headers.</td>
+</tr>
+
+<tr>
+<td class="td"><strong>quality</strong></td>
+<td class="td">90%</td>
+<td class="td">1 - 100%</td>
+<td class="td">Sets the quality of the image. The higher the quality the larger the file size.</td>
+</tr>
+
+<tr>
+<td class="td"><strong>padding</strong></td>
+<td class="td">None</td>
+<td class="td">A number</td>
+<td class="td">The amount of padding, set in pixels, that will be applied to the watermark to set it away from the edge of your images.</td>
+</tr>
+
+<tr>
+<td class="td"><strong>wm_vrt_alignment</strong></td>
+<td class="td">bottom</td>
+<td class="td">top, middle, bottom</td>
+<td class="td">Sets the vertical alignment for the watermark image.</td>
+</tr>
+
+<tr>
+<td class="td"><strong>wm_hor_alignment</strong></td>
+<td class="td">center</td>
+<td class="td">left, center, right</td>
+<td class="td">Sets the horizontal alignment for the watermark image.</td>
+</tr>
+
+<tr>
+<td class="td"><strong>wm_hor_offset</strong></td>
+<td class="td">None</td>
+<td class="td">None</td>
+<td class="td">You may specify a horizontal offset (in pixels) to apply to the watermark position. The offset normally moves the watermark to the right, except if you have your alignment set to "right" then your offset value will move the watermark toward the left of the image.</td>
+</tr>
+
+<tr>
+<td class="td"><strong>wm_vrt_offset</strong></td>
+<td class="td">None</td>
+<td class="td">None</td>
+<td class="td">You may specify a vertical offset (in pixels) to apply to the watermark position. The offset normally moves the watermark down, except if you have your alignment set to "bottom" then your offset value will move the watermark toward the top of the image.</td>
+</tr>
+
+</table>
+
+
+
+<h3>Text Preferences</h3>
+<p>This table shown the preferences that are available for the text type of watermarking.</p>
+
+
+<table cellpadding="0" cellspacing="1" border="0" style="width:100%" class="tableborder">
+<tr>
+<th>Preference</th>
+<th>Default&nbsp;Value</th>
+<th>Options</th>
+<th>Description</th>
+</tr>
+
+<tr>
+<td class="td"><strong>wm_text</strong></td>
+<td class="td">None</td>
+<td class="td">None</td>
+<td class="td">The text you would like shown as the watermark.  Typically this will be a copyright notice.</td>
+</tr>
+
+<tr>
+<td class="td"><strong>wm_font_path</strong></td>
+<td class="td">None</td>
+<td class="td">None</td>
+<td class="td">The server path to the True Type Font you would like to use.  If you do not use this option, the native GD font will be used.</td>
+</tr>
+
+<tr>
+<td class="td"><strong>wm_font_size</strong></td>
+<td class="td">16</td>
+<td class="td">None</td>
+<td class="td">The size of the text.  Note: If you are not using the True Type option above, the number is set using a range of 1 - 5.  Otherwise, you can use any valid pixel size for the font you're using.</td>
+</tr>
+
+<tr>
+<td class="td"><strong>wm_font_color</strong></td>
+<td class="td">ffffff</td>
+<td class="td">None</td>
+<td class="td">The font color, specified in hex.  Note, you must use the full 6 character hex value (ie, 993300), rather than the three character abbreviated version (ie fff).</td>
+</tr>
+
+
+<tr>
+<td class="td"><strong>wm_shadow_color</strong></td>
+<td class="td">None</td>
+<td class="td">None</td>
+<td class="td">The color of the drop shadow, specified in hex. If you leave this blank a drop shadow will not be used. Note, you must use the full 6 character hex value (ie, 993300), rather than the three character abbreviated version (ie fff).</td>
+</tr>
+
+<tr>
+<td class="td"><strong>wm_shadow_distance</strong></td>
+<td class="td">3</td>
+<td class="td">None</td>
+<td class="td">The distance (in pixels) from the font that the drop shadow should appear.</td>
+</tr>
+
+</table>
+
+
+
+
+<h3>Overlay Preferences</h3>
+<p>This table shown the preferences that are available for the overlay type of watermarking.</p>
+
+
+<table cellpadding="0" cellspacing="1" border="0" style="width:100%" class="tableborder">
+<tr>
+<th>Preference</th>
+<th>Default&nbsp;Value</th>
+<th>Options</th>
+<th>Description</th>
+</tr>
+
+<tr>
+<td class="td"><strong>wm_overlay_path</strong></td>
+<td class="td">None</td>
+<td class="td">None</td>
+<td class="td">The server path to the image you wish to use as your watermark. Required only if you are using the overlay method.</td>
+</tr>
+
+<tr>
+<td class="td"><strong>wm_opacity</strong></td>
+<td class="td">50</td>
+<td class="td">1 - 100</td>
+<td class="td">Image opacity. You may specify the opacity (i.e. transparency) of your watermark image. This allows the watermark to be faint and not completely obscure the details from the original image behind it. A 50% opacity is typical.</td>
+</tr>
+
+<tr>
+<td class="td"><strong>wm_x_transp</strong></td>
+<td class="td">4</td>
+<td class="td">A number</td>
+<td class="td">If your watermark image is a PNG or GIF image, you may specify a color on the image to be "transparent". This setting (along with the next) will allow you to specify that color. This works by specifying the "X" and "Y" coordinate pixel (measured from the upper left) within the image that corresponds to a pixel representative of the color you want to be transparent.</td>
+</tr>
+
+<tr>
+<td class="td"><strong>wm_y_transp</strong></td>
+<td class="td">4</td>
+<td class="td">A number</td>
+<td class="td">Along with the previous setting, this allows you to specify the coordinate to a pixel representative of the color you want to be transparent.</td>
+</tr>
+</table>
+
+</div>
+<!-- END CONTENT -->
+
+
+<div id="footer">
+<p>
+Previous Topic:&nbsp;&nbsp;<a href="table.html">HTML Table Class</a>
+&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+<a href="#top">Top of Page</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+<a href="../index.html">User Guide Home</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+Next Topic:&nbsp;&nbsp;<a href="input.html">Input Class</a>
+</p>
+<p><a href="http://codeigniter.com">CodeIgniter</a> &nbsp;&middot;&nbsp; Copyright &#169; 2006 - 2011 &nbsp;&middot;&nbsp; <a href="http://ellislab.com/">EllisLab, Inc.</a></p>
+</div>
+
+</body>
+</html>
\ No newline at end of file
diff --git a/user_guide/libraries/input.html b/user_guide/libraries/input.html
new file mode 100755 (executable)
index 0000000..08b8ab0
--- /dev/null
@@ -0,0 +1,295 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head>
+
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+<title>Input Class : CodeIgniter User Guide</title>
+
+<style type='text/css' media='all'>@import url('../userguide.css');</style>
+<link rel='stylesheet' type='text/css' media='all' href='../userguide.css' />
+
+<script type="text/javascript" src="../nav/nav.js"></script>
+<script type="text/javascript" src="../nav/prototype.lite.js"></script>
+<script type="text/javascript" src="../nav/moo.fx.js"></script>
+<script type="text/javascript" src="../nav/user_guide_menu.js"></script>
+
+<meta http-equiv='expires' content='-1' />
+<meta http-equiv= 'pragma' content='no-cache' />
+<meta name='robots' content='all' />
+<meta name='author' content='ExpressionEngine Dev Team' />
+<meta name='description' content='CodeIgniter User Guide' />
+
+</head>
+<body>
+
+<!-- START NAVIGATION -->
+<div id="nav"><div id="nav_inner"><script type="text/javascript">create_menu('../');</script></div></div>
+<div id="nav2"><a name="top"></a><a href="javascript:void(0);" onclick="myHeight.toggle();"><img src="../images/nav_toggle_darker.jpg" width="154" height="43" border="0" title="Toggle Table of Contents" alt="Toggle Table of Contents" /></a></div>
+<div id="masthead">
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td><h1>CodeIgniter User Guide Version 2.0.2</h1></td>
+<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
+</tr>
+</table>
+</div>
+<!-- END NAVIGATION -->
+
+
+<!-- START BREADCRUMB -->
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td id="breadcrumb">
+<a href="http://codeigniter.com/">CodeIgniter Home</a> &nbsp;&#8250;&nbsp;
+<a href="../index.html">User Guide Home</a> &nbsp;&#8250;&nbsp;
+Input Class
+</td>
+<td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="codeigniter.com/user_guide/" />Search User Guide&nbsp; <input type="text" class="input" style="width:200px;" name="q" id="q" size="31" maxlength="255" value="" />&nbsp;<input type="submit" class="submit" name="sa" value="Go" /></form></td>
+</tr>
+</table>
+<!-- END BREADCRUMB -->
+
+<br clear="all" />
+
+
+<!-- START CONTENT -->
+<div id="content">
+
+
+<h1>Input Class</h1>
+
+<p>The Input Class serves two purposes:</p>
+
+<ol>
+<li>It pre-processes global input data for security.</li>
+<li>It provides some helper functions for fetching input data and pre-processing it.</li>
+</ol>
+
+<p class="important"><strong>Note:</strong> This class is initialized automatically by the system so there is no need to do it manually.</p>
+
+
+<h2>Security Filtering</h2>
+
+<p>The security filtering function is called automatically when a new <a href="../general/controllers.html">controller</a> is invoked.  It does the following:</p>
+
+<ul>
+<li>Destroys the global GET array.  Since CodeIgniter does not utilize GET strings, there is no reason to allow it.</li>
+<li>Destroys all global variables in the event register_globals is turned on.</li>
+<li>Filters the POST/COOKIE array keys, permitting only alpha-numeric (and a few other) characters.</li>
+<li>Provides XSS (Cross-site Scripting Hacks) filtering.  This can be enabled globally, or upon request.</li>
+<li>Standardizes newline characters to \n</li>
+</ul>
+
+
+<h2>XSS Filtering</h2>
+
+<p>The Input class has the ability to filter input automatically to prevent cross-site scripting attacks.  If you want the filter to run automatically every time it encounters POST or COOKIE data you can enable it by opening your
+<kbd>application/config/config.php</kbd> file and setting this:</p>
+
+<code>$config['global_xss_filtering'] = TRUE;</code>
+
+<p>Please refer to the <a href="security.html">Security class</a> documentation for information on using XSS Filtering in your application.</p>
+
+
+<h2>Using POST, COOKIE, or SERVER Data</h2>
+
+<p>CodeIgniter comes with three helper functions that let you fetch POST, COOKIE or SERVER items.  The main advantage of using the provided
+functions rather than fetching an item directly ($_POST['something']) is that the functions will check to see if the item is set and
+return false (boolean) if not.  This lets you conveniently use data without having to test whether an item exists first.
+In other words, normally you might do something like this:</p>
+
+<code>
+if ( ! isset($_POST['something']))<br />
+{<br />
+&nbsp;&nbsp;&nbsp;&nbsp;$something = FALSE;<br />
+}<br />
+else<br />
+{<br />
+&nbsp;&nbsp;&nbsp;&nbsp;$something = $_POST['something'];<br />
+}</code>
+
+<p>With CodeIgniter's built in functions you can simply do this:</p>
+
+<code>$something = $this->input->post('something');</code>
+
+<p>The three functions are:</p>
+
+<ul>
+<li>$this->input->post()</li>
+<li>$this->input->cookie()</li>
+<li>$this->input->server()</li>
+</ul>
+
+<h2>$this->input->post()</h2>
+
+<p>The first parameter will contain the name of the POST item you are looking for:</p>
+
+<code>$this->input->post('some_data');</code>
+
+<p>The function returns FALSE (boolean) if the item you are attempting to retrieve does not exist.</p>
+
+<p>The second optional parameter lets you run the data through the XSS filter.  It's enabled by setting the second parameter to boolean TRUE;</p>
+
+<code>$this->input->post('some_data', TRUE);</code>
+
+<p>To return an array of all POST items call without any parameters.</p>
+<p>To return all POST items and pass them through the XSS filter leave the first parameter blank while setting the second parameter to boolean;</p>
+<p>The function returns FALSE (boolean) if there are no items in the POST.</p>
+
+<code>
+       $this->input->post(); // returns all POST items with XSS filter
+       <br />
+       $this->input->post(NULL, FALSE); // returns all POST items without XSS
+</code>
+
+<h2>$this->input->get()</h2>
+
+<p>This function is identical to the post function, only it fetches get data:</p>
+
+<code>$this->input->get('some_data', TRUE);</code>
+
+<p>To return an array of all GET items call without any parameters.</p>
+<p>To return all GET items and pass them through the XSS filter leave the first parameter blank while setting the second parameter to boolean;</p>
+<p>The function returns FALSE (boolean) if there are no items in the GET.</p>
+
+<code>
+       $this->input->get(); // returns all GET items with XSS filter
+       <br />
+       $this->input->get(NULL, FALSE); // returns all GET items without XSS filtering
+</code>
+
+<h2>$this->input->get_post()</h2>
+
+<p>This function will search through both the post and get streams for data, looking first in post, and then in get:</p>
+
+<code>$this->input->get_post('some_data', TRUE);</code>
+
+<h2>$this->input->cookie()</h2>
+
+<p>This function is identical to the post function, only it fetches cookie data:</p>
+
+<code>$this->input->cookie('some_data', TRUE);</code>
+
+<h2>$this->input->server()</h2>
+
+<p>This function is identical to the above functions, only it fetches server data:</p>
+
+<code>$this->input->server('some_data');</code>
+
+
+<h2>$this->input->set_cookie()</h2>
+
+<p>Sets a cookie containing the values you specify.  There are two ways to pass information to this function so that a cookie can be set:
+Array Method, and Discrete Parameters:</p>
+
+<h4>Array Method</h4>
+
+<p>Using this method, an associative array is passed to the first parameter:</p>
+
+<code>$cookie = array(<br />
+&nbsp;&nbsp;&nbsp;&nbsp;'name'&nbsp;&nbsp;&nbsp;=> 'The Cookie Name',<br />
+&nbsp;&nbsp;&nbsp;&nbsp;'value'&nbsp;&nbsp;=> 'The Value',<br />
+&nbsp;&nbsp;&nbsp;&nbsp;'expire' => '86500',<br />
+&nbsp;&nbsp;&nbsp;&nbsp;'domain' => '.some-domain.com',<br />
+&nbsp;&nbsp;&nbsp;&nbsp;'path'&nbsp;&nbsp;&nbsp;=> '/',<br />
+&nbsp;&nbsp;&nbsp;&nbsp;'prefix' => 'myprefix_',<br />
+&nbsp;&nbsp;&nbsp;&nbsp;'secure' => TRUE<br />
+);<br />
+<br />
+$this->input->set_cookie($cookie);
+</code>
+
+<p><strong>Notes:</strong></p>
+
+<p>Only the name and value are required. To delete a cookie set it with the expiration blank.</p>
+
+<p>The expiration is set in <strong>seconds</strong>, which will be added to the current time.  Do not include the time, but rather only the
+number of seconds from <em>now</em> that you wish the cookie to be valid.  If the expiration is set to
+zero the cookie will only last as long as the browser is open.</p>
+<p>For site-wide cookies regardless of how your site is requested, add your URL to the <strong>domain</strong> starting with a period, like this:  .your-domain.com</p>
+<p>The path is usually not needed since the function sets a root path.</p>
+<p>The prefix is only needed if you need to avoid name collisions with other identically named cookies for your server.</p>
+<p>The secure boolean is only needed if you want to make it a secure cookie by setting it to TRUE.</p>
+
+<h4>Discrete Parameters</h4>
+
+<p>If you prefer, you can set the cookie by passing data using individual parameters:</p>
+
+<code>$this->input->set_cookie($name, $value, $expire, $domain, $path, $prefix, $secure);</code>
+
+<h2>$this->input->cookie()</h2>
+
+<p>Lets you fetch a cookie.  The first parameter will contain the name of the cookie you are looking for (including any prefixes):</p>
+
+<code>cookie('some_cookie');</code>
+
+<p>The function returns FALSE (boolean) if the item you are attempting to retrieve does not exist.</p>
+
+<p>The second optional parameter lets you run the data through the XSS filter.  It's enabled by setting the second parameter to boolean TRUE;</p>
+
+<p><code>cookie('some_cookie', TRUE);</code></p>
+
+
+<h2>$this->input->ip_address()</h2>
+<p>Returns the IP address for the current user.  If the IP address is not valid, the function will return an IP of: 0.0.0.0</p>
+<code>echo $this->input->ip_address();</code>
+
+
+<h2>$this->input->valid_ip(<var>$ip</var>)</h2>
+
+<p>Takes an IP address as input and returns TRUE or FALSE (boolean) if it is valid or not.  Note:  The $this->input->ip_address() function above
+validates the IP automatically.</p>
+
+<code>if ( ! $this-&gt;input-&gt;valid_ip($ip))<br />
+{<br />
+&nbsp;&nbsp;&nbsp;&nbsp; echo 'Not Valid';<br />
+}<br />
+else<br />
+{<br />
+&nbsp;&nbsp;&nbsp;&nbsp; echo 'Valid';<br />
+}</code>
+
+
+<h2>$this->input->user_agent()</h2>
+<p>Returns the user agent (web browser) being used by the current user. Returns FALSE if it's not available.</p>
+<code>echo $this->input->user_agent();</code>
+<p>See the <a href="user_agent.html">User Agent Class</a> for methods which extract information from the user agent string.</p>
+
+<h2>$this->input->request_headers()</h2>
+<p>Useful if running in a non-Apache environment where <a href="http://php.net/apache_request_headers">apache_request_headers()</a> will not be supported.  Returns an array of headers.</p>
+
+<code>$headers = $this->input->request_headers();</code>
+
+<h2>$this->input->get_request_header();</h2>
+<p>Returns a single member of the request headers array.</p>
+
+<code>$this->input->get_request_header('some-header', TRUE);</code>
+
+
+<h2>$this->input->is_ajax_request()</h2>
+<p>Checks to see if the <var>HTTP_X_REQUESTED_WITH</var> server header has been set, and returns a boolean response.</p>
+
+
+<h2>$this->input->is_cli_request()</h2>
+<p>Checks to see if the <var>STDIN</var> constant is set, which is a failsafe way to see if PHP is being run on the command line.</p>
+
+<code>$this->input->is_cli_request()</code>
+
+
+</div>
+<!-- END CONTENT -->
+
+
+<div id="footer">
+<p>
+Previous Topic:&nbsp;&nbsp;<a href="image_lib.html">Image Manipulation Class</a>
+&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+<a href="#top">Top of Page</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+<a href="../index.html">User Guide Home</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+Next Topic:&nbsp;&nbsp;<a href="loader.html">Loader Class</a>
+</p>
+<p><a href="http://codeigniter.com">CodeIgniter</a> &nbsp;&middot;&nbsp; Copyright &#169; 2006 - 2011 &nbsp;&middot;&nbsp; <a href="http://ellislab.com/">EllisLab, Inc.</a></p>
+</div>
+
+</body>
+</html>
\ No newline at end of file
diff --git a/user_guide/libraries/javascript.html b/user_guide/libraries/javascript.html
new file mode 100755 (executable)
index 0000000..4e26227
--- /dev/null
@@ -0,0 +1,247 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head>
+
+<title>CodeIgniter User Guide : JavaScript Class</title>
+
+<style type='text/css' media='all'>@import url('../userguide.css');</style>
+<link rel='stylesheet' type='text/css' media='all' href='../userguide.css' />
+
+<script type="text/javascript" src="../nav/nav.js"></script>
+<script type="text/javascript" src="../nav/prototype.lite.js"></script>
+<script type="text/javascript" src="../nav/moo.fx.js"></script>
+<script type="text/javascript" src="../nav/user_guide_menu.js"></script>
+
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+<meta http-equiv='expires' content='-1' />
+<meta http-equiv= 'pragma' content='no-cache' />
+<meta name='robots' content='all' />
+<meta name='author' content='ExpressionEngine Dev Team' />
+<meta name='description' content='CodeIgniter User Guide' />
+
+</head>
+<body>
+
+<!-- START NAVIGATION -->
+<div id="nav"><div id="nav_inner"><script type="text/javascript">create_menu('../');</script></div></div>
+<div id="nav2"><a name="top"></a><a href="javascript:void(0);" onclick="myHeight.toggle();"><img src="../images/nav_toggle_darker.jpg" width="153" height="44" border="0" title="Toggle Table of Contents" alt="Toggle Table of Contents" /></a></div>
+<div id="masthead">
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td><h1>CodeIgniter User Guide Version 2.0.2</h1></td>
+<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
+</tr>
+</table>
+</div>
+<!-- END NAVIGATION -->
+
+
+<!-- START BREADCRUMB -->
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td id="breadcrumb">
+<a href="http://codeigniter.com/">CodeIgniter Home</a> &nbsp;&#8250;&nbsp;
+<a href="../index.html">User Guide Home</a> &nbsp;&#8250;&nbsp;
+<a href="../general/drivers.html">Drivers</a> &nbsp;&#8250;&nbsp;
+JavaScript Driver
+</td>
+<td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="codeigniter.com/user_guide/" />Search User Guide&nbsp; <input type="text" class="input" style="width:200px;" name="q" id="q" size="31" maxlength="255" value="" />&nbsp;<input type="submit" class="submit" name="sa" value="Go" /></form></td>
+</tr>
+</table>
+<!-- END BREADCRUMB -->
+
+<br clear="all" />
+
+
+<!-- START CONTENT -->
+<div id="content">
+
+<p class="important"><strong>Note:</strong> This driver is experimental. Its feature set and implementation may change in future releases.</p><br>
+
+<h1>Javascript Class</h1>
+<p>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.</p>
+<h2>Initializing the Class</h2>
+<p>To initialize the Javascript class manually in your controller constructor, use the <dfn>$this-&gt;load-&gt;library</dfn> function. Currently, the only available library is jQuery, which will automatically be loaded like this:</p>
+
+<code>$this-&gt;load-&gt;library('javascript');</code>
+
+<p>The Javascript class also accepts parameters, <dfn>js_library_driver (string) default 'jquery'</dfn> and <dfn>autoload (bool) default TRUE</dfn>.  You may override the defaults if you wish by sending an associative array:</p>
+
+<code>$this-&gt;load-&gt;library('javascript', array('js_library_driver' =&gt; 'scripto', 'autoload' =&gt; FALSE));</code>
+
+<p>Again, presently only 'jquery' is available.  You may wish to set <dfn>autoload</dfn> to FALSE, though, if you do not want the jQuery library to automatically include a script tag for the main jQuery script file.  This is useful if you are loading it from a location outside of CodeIgniter, or already have the script tag in your markup.</p>
+
+<p>Once loaded, the jQuery library object will be available using: <dfn>$this-&gt;javascript</dfn></p>
+<h2>Setup and Configuration</h2>
+<h3>Set these variables in your view</h3>
+<p>As a Javascript library, your files must be available to your application.</p>
+<p>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 &lt;head&gt; sections of your output.</p>
+<p><code>&lt;?php echo $library_src;?&gt;<br />
+&lt;?php echo $script_head;?&gt;
+</code></p>
+<p>$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.</p>
+<h3>Set the path to the librarys with config items</h3>
+<p>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. </p>
+<p>An image to be used as an &quot;ajax loader&quot;, or progress indicator. Without one, the simple text message of &quot;loading&quot; will appear when Ajax calls need to be made.</p>
+<p><code>$config['javascript_location'] = 'http://localhost/codeigniter/themes/js/jquery/';<br />
+               $config['javascript_ajax_img'] = 'images/ajax-loader.gif';</code></p>
+<p>If you keep your files in the same directories they were downloaded from, then you need not set this configuration items.</p>
+
+<h2>The jQuery Class</h2>
+
+<p>To initialize the jQuery class manually in your controller constructor, use the <dfn>$this-&gt;load-&gt;library</dfn> function:</p>
+
+<code>$this-&gt;load-&gt;library('jquery');</code>
+
+<p>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:</p>
+
+<code>$this-&gt;load-&gt;library('jquery', FALSE);</code>
+
+<p>Once loaded, the jQuery library object will be available using: <dfn>$this-&gt;jquery</dfn></p>
+
+<h2>jQuery Events</h2>
+
+<p>Events are set using the following syntax.</p>
+
+<p><code>$this-&gt;jquery-&gt;event('element_path', code_to_run());</code></p>
+
+<p>In the above example:</p>
+
+<ul>
+       <li>&quot;event&quot; is any of blur, change, click, dblclick, error, focus, hover, keydown, keyup, load, mousedown, mouseup, mouseover, mouseup, resize, scroll, or unload.</li>
+       <li>&quot;element_path&quot; is any valid <a href="http://docs.jquery.com/Selectors">jQuery selector</a>. Due to jQuery's unique selector syntax, this is usually an element id, or CSS selector. For example &quot;#notice_area&quot; would effect &lt;div id=&quot;notice_area&quot;&gt;, and &quot;#content a.notice&quot; would effect all anchors with a class of &quot;notice&quot; in the div with id &quot;content&quot;.</li>
+       <li>&quot;code_to_run()&quot; is script your write yourself, or an action such as an effect from the jQuery library below.</li>
+       </ul>
+
+<h2>Effects</h2>
+
+<p>The query library supports a powerful <a href="http://docs.jquery.com/Effects">Effects</a> repertoire.  Before an effect can be used, it must be loaded:</p>
+
+<p><code>$this->jquery->effect([optional path] plugin name);
+// for example
+$this->jquery->effect('bounce');
+</code></p>
+
+<h3>hide() / show()</h3>
+
+<p>Each of this functions will affect the visibility of an item on your page. hide() will set an item invisible, show() will reveal it.</p>
+<p><code>$this-&gt;jquery-&gt;hide(target,  optional speed, optional extra information);<br />
+       $this-&gt;jquery-&gt;show(target,  optional speed, optional extra information);</code></p>
+
+<ul>
+       <li>&quot;target&quot; will be any valid jQuery selector or selectors.</li>
+       <li>&quot;speed&quot; is optional, and is set to either slow, normal, fast, or alternatively a number of milliseconds.</li>
+       <li>&quot;extra information&quot; is optional, and could include a callback, or other additional information.</li>
+</ul>
+
+<h3>toggle()</h3>
+
+<p>toggle() will change the visibility of an item to the opposite of its current state, hiding visible elements, and revealing hidden ones.</p>
+<p><code>$this-&gt;jquery-&gt;toggle(target);</code></p>
+<ul>
+       <li>&quot;target&quot; will be any valid jQuery selector or selectors.</li>
+</ul>
+
+<h3>animate()</h3>
+
+<p><code> $this-&gt;jquery-&gt;animate(target, parameters, optional speed, optional extra information);</code></p>
+<ul>
+       <li>&quot;target&quot; will be any valid jQuery selector or selectors.</li>
+       <li>&quot;parameters&quot; in jQuery would generally include a series of CSS properties that you wish to change.</li>
+       <li>&quot;speed&quot; is optional, and is set to either slow, normal, fast, or alternatively a number of milliseconds.</li>
+       <li>&quot;extra information&quot; is optional, and could include a callback, or other additional information.</li>
+</ul>
+<p>For a full summary, see <a href="http://docs.jquery.com/Effects/animate">http://docs.jquery.com/Effects/animate</a></p>
+<p>Here is an example of an animate() called on a div with an id of &quot;note&quot;, and triggered by a click using the jQuery library's click() event.</p>
+<p><code> $params = array(<br />
+       'height' =&gt; 80,<br />
+       'width' =&gt; '50%',<br />
+       'marginLeft' =&gt; 125<br />
+);<br />
+$this-&gt;jquery-&gt;click('#trigger', $this-&gt;jquery-&gt;animate('#note', $params, normal));</code></p>
+
+<h3>fadeIn() / fadeOut()</h3>
+
+<p><code>$this-&gt;jquery-&gt;fadeIn(target,  optional speed, optional extra information);<br />
+       $this-&gt;jquery-&gt;fadeOut(target,  optional speed, optional extra information);</code></p>
+<ul>
+       <li>&quot;target&quot; will be any valid jQuery selector or selectors.</li>
+       <li>&quot;speed&quot; is optional, and is set to either slow, normal, fast, or alternatively a number of milliseconds.</li>
+       <li>&quot;extra information&quot; is optional, and could include a callback, or other additional information.</li>
+</ul>
+
+<h3>toggleClass()</h3>
+
+<p>This function will add or remove a CSS class to its target.</p>
+<p><code>$this-&gt;jquery-&gt;toggleClass(target, class)</code></p>
+<ul>
+       <li>&quot;target&quot; will be any valid jQuery selector or selectors.</li>
+       <li>&quot;class&quot; is any CSS classname. Note that this class must be defined and available in a CSS that is already loaded.</li>
+       </ul>
+
+<h3>fadeIn() / fadeOut()</h3>
+
+<p>These effects cause an element(s) to disappear or reappear over time.</p>
+<p><code>$this-&gt;jquery-&gt;fadeIn(target,  optional speed, optional extra information);<br />
+       $this-&gt;jquery-&gt;fadeOut(target,  optional speed, optional extra information);</code></p>
+<ul>
+       <li>&quot;target&quot; will be any valid jQuery selector or selectors.</li>
+       <li>&quot;speed&quot; is optional, and is set to either slow, normal, fast, or alternatively a number of milliseconds.</li>
+       <li>&quot;extra information&quot; is optional, and could include a callback, or other additional information.</li>
+</ul>
+
+<h3>slideUp() / slideDown() / slideToggle()</h3>
+
+<p>These effects cause an element(s) to slide.</p>
+<p><code>$this-&gt;jquery-&gt;slideUp(target,  optional speed, optional extra information);<br />
+       $this-&gt;jquery-&gt;slideDown(target,  optional speed, optional extra information);<br />
+$this-&gt;jquery-&gt;slideToggle(target,  optional speed, optional extra information);</code></p>
+<ul>
+       <li>&quot;target&quot; will be any valid jQuery selector or selectors.</li>
+       <li>&quot;speed&quot; is optional, and is set to either slow, normal, fast, or alternatively a number of milliseconds.</li>
+       <li>&quot;extra information&quot; is optional, and could include a callback, or other additional information.</li>
+</ul>
+
+<h2>Plugins</h2>
+
+<p>
+
+<p>Some select jQuery plugins are made available using this library.</p>
+
+<h3>corner()</h3>
+<p>Used to add distinct corners to page elements. For full details see <a href="http://www.malsup.com/jquery/corner/">http://www.malsup.com/jquery/corner/</a></p>
+<p><code>$this-&gt;jquery-&gt;corner(target, corner_style);</code></p>
+<ul>
+       <li>&quot;target&quot; will be any valid jQuery selector or selectors.</li>
+       <li>&quot;corner_style&quot; 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 &quot;tl&quot; (top left), &quot;tr&quot; (top right), &quot;bl&quot; (bottom left), or &quot;br&quot; (bottom right).</li>
+</ul>
+<p><code>$this-&gt;jquery-&gt;corner(&quot;#note&quot;, &quot;cool tl br&quot;);</code></p>
+
+<h3>tablesorter()</h3>
+
+<p>description to come</p>
+
+<h3>modal()</h3>
+
+<p>description to come</p>
+
+<h3>calendar()</h3>
+
+<p>description to come</p>
+
+</div>
+<!-- END CONTENT -->
+
+
+<div id="footer">
+<p>
+Previous Topic:&nbsp;&nbsp;<a href="input.html">Input Class</a>
+&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+<a href="#top">Top of Page</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+<a href="../index.html">User Guide Home</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+Next Topic:&nbsp;&nbsp;<a href="language.html">Language Class</a></p>
+<p><a href="http://codeigniter.com">CodeIgniter</a> &nbsp;&middot;&nbsp; Copyright &#169; 2006 - 2011 &nbsp;&middot;&nbsp; <a href="http://ellislab.com/">EllisLab, Inc.</a></p>
+</div>
+
+</body>
+</html>
diff --git a/user_guide/libraries/language.html b/user_guide/libraries/language.html
new file mode 100755 (executable)
index 0000000..75863c2
--- /dev/null
@@ -0,0 +1,137 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head>
+
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+<title>Language Class : CodeIgniter User Guide</title>
+
+<style type='text/css' media='all'>@import url('../userguide.css');</style>
+<link rel='stylesheet' type='text/css' media='all' href='../userguide.css' />
+
+<script type="text/javascript" src="../nav/nav.js"></script>
+<script type="text/javascript" src="../nav/prototype.lite.js"></script>
+<script type="text/javascript" src="../nav/moo.fx.js"></script>
+<script type="text/javascript" src="../nav/user_guide_menu.js"></script>
+
+<meta http-equiv='expires' content='-1' />
+<meta http-equiv= 'pragma' content='no-cache' />
+<meta name='robots' content='all' />
+<meta name='author' content='ExpressionEngine Dev Team' />
+<meta name='description' content='CodeIgniter User Guide' />
+
+</head>
+<body>
+
+<!-- START NAVIGATION -->
+<div id="nav"><div id="nav_inner"><script type="text/javascript">create_menu('../');</script></div></div>
+<div id="nav2"><a name="top"></a><a href="javascript:void(0);" onclick="myHeight.toggle();"><img src="../images/nav_toggle_darker.jpg" width="154" height="43" border="0" title="Toggle Table of Contents" alt="Toggle Table of Contents" /></a></div>
+<div id="masthead">
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td><h1>CodeIgniter User Guide Version 2.0.2</h1></td>
+<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
+</tr>
+</table>
+</div>
+<!-- END NAVIGATION -->
+
+
+<!-- START BREADCRUMB -->
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td id="breadcrumb">
+<a href="http://codeigniter.com/">CodeIgniter Home</a> &nbsp;&#8250;&nbsp;
+<a href="../index.html">User Guide Home</a> &nbsp;&#8250;&nbsp;
+Language Class
+</td>
+<td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="codeigniter.com/user_guide/" />Search User Guide&nbsp; <input type="text" class="input" style="width:200px;" name="q" id="q" size="31" maxlength="255" value="" />&nbsp;<input type="submit" class="submit" name="sa" value="Go" /></form></td>
+</tr>
+</table>
+<!-- END BREADCRUMB -->
+
+<br clear="all" />
+
+
+<!-- START CONTENT -->
+<div id="content">
+
+
+<h1>Language Class</h1>
+
+<p>The Language Class provides functions to retrieve language files and lines of text for purposes of internationalization.</p>
+
+<p>In your CodeIgniter system folder you'll find one called <dfn>language</dfn> containing sets of language files.  You can create
+your own language files as needed in order to display error and other messages in other languages.</p>
+
+<p>Language files are typically stored in your <dfn>system/language</dfn> directory.  Alternately you can create a folder called <kbd>language</kbd> inside
+your <kbd>application</kbd> folder and store them there.  CodeIgniter will look first in your <dfn>application/language</dfn>
+directory.  If the directory does not exist or the specified language is not located there CI will instead look in your global
+<dfn>system/language</dfn> folder.</p>
+
+<p class="important"><strong>Note:</strong>&nbsp; Each language should be stored in its own folder.  For example, the English files are located at:
+<dfn>system/language/english</dfn></p>
+
+
+
+<h2>Creating Language Files</h2>
+
+<p>Language files must be named with <kbd>_lang.php</kbd> as the file extension.  For example, let's say you want to create a file
+containing error messages.  You might name it:  <kbd>error_lang.php</kbd></p>
+
+<p>Within the file you will assign each line of text to an array called <var>$lang</var> with this prototype:</p>
+
+<code>$lang['language_key'] = "The actual message to be shown";</code>
+
+<p><strong>Note:</strong> It's a good practice to use a common prefix for all messages in a given file to avoid collisions with
+similarly named items in other files.  For example, if you are creating error messages you might prefix them with <var>error_</var></p>
+
+<code>$lang['<var>error</var>_email_missing'] = "You must submit an email address";<br />
+$lang['<var>error</var>_url_missing'] = "You must submit a URL";<br />
+$lang['<var>error</var>_username_missing'] = "You must submit a username";</code>
+
+
+<h2>Loading A Language File</h2>
+
+<p>In order to fetch a line from a particular file you must load the file first.  Loading a language file is done with the following code:</p>
+
+<code>$this->lang->load('<samp>filename</samp>', '<dfn>language</dfn>');</code>
+
+<p>Where <samp>filename</samp> is the name of the file you wish to load (without the file extension), and <dfn>language</dfn>
+is the language set containing it (ie, english).  If the second parameter is missing, the default language set in your
+<kbd>application/config/config.php</kbd> file will be used.</p>
+
+
+<h2>Fetching a Line of Text</h2>
+
+<p>Once your desired language file is loaded you can access any line of text using this function:</p>
+
+<code>$this->lang->line('<samp>language_key</samp>');</code>
+
+<p>Where <samp>language_key</samp> is the array key corresponding to the line you wish to show.</p>
+
+<p>Note: This function simply returns the line.  It does not echo it for you.</p>
+
+<h3>Using language lines as form labels</h3>
+
+<p class="important">This feature has been deprecated from the language library and moved to the <kbd>lang()</kbd> function of the <a href="../helpers/language_helper.html">Language helper</a>.</p>
+
+<h2>Auto-loading Languages</h2>
+<p>If you find that you need a particular language globally throughout your application, you can tell CodeIgniter to <a href="../general/autoloader.html">auto-load</a> it during system initialization. This is done by opening the application/config/autoload.php file and adding the language(s) to the autoload array.</p>
+<p>&nbsp;</p>
+</div>
+<!-- END CONTENT -->
+
+
+<div id="footer">
+<p>
+Previous Topic:&nbsp;&nbsp;<a href="loader.html">Loader Class</a>
+&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+<a href="#top">Top of Page</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+<a href="../index.html">User Guide Home</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+Next Topic:&nbsp;&nbsp;<a href="output.html">Output Class</a>
+</p>
+<p><a href="http://codeigniter.com">CodeIgniter</a> &nbsp;&middot;&nbsp; Copyright &#169; 2006 - 2011 &nbsp;&middot;&nbsp; <a href="http://ellislab.com/">EllisLab, Inc.</a></p>
+</div>
+
+</body>
+</html>
\ No newline at end of file
diff --git a/user_guide/libraries/loader.html b/user_guide/libraries/loader.html
new file mode 100755 (executable)
index 0000000..42f8cf9
--- /dev/null
@@ -0,0 +1,262 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head>
+
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+<title>Loader Class : CodeIgniter User Guide</title>
+
+<style type='text/css' media='all'>@import url('../userguide.css');</style>
+<link rel='stylesheet' type='text/css' media='all' href='../userguide.css' />
+
+<script type="text/javascript" src="../nav/nav.js"></script>
+<script type="text/javascript" src="../nav/prototype.lite.js"></script>
+<script type="text/javascript" src="../nav/moo.fx.js"></script>
+<script type="text/javascript" src="../nav/user_guide_menu.js"></script>
+
+<meta http-equiv='expires' content='-1' />
+<meta http-equiv= 'pragma' content='no-cache' />
+<meta name='robots' content='all' />
+<meta name='author' content='ExpressionEngine Dev Team' />
+<meta name='description' content='CodeIgniter User Guide' />
+
+</head>
+<body>
+
+<!-- START NAVIGATION -->
+<div id="nav"><div id="nav_inner"><script type="text/javascript">create_menu('../');</script></div></div>
+<div id="nav2"><a name="top"></a><a href="javascript:void(0);" onclick="myHeight.toggle();"><img src="../images/nav_toggle_darker.jpg" width="154" height="43" border="0" title="Toggle Table of Contents" alt="Toggle Table of Contents" /></a></div>
+<div id="masthead">
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td><h1>CodeIgniter User Guide Version 2.0.2</h1></td>
+<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
+</tr>
+</table>
+</div>
+<!-- END NAVIGATION -->
+
+
+<!-- START BREADCRUMB -->
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td id="breadcrumb">
+<a href="http://codeigniter.com/">CodeIgniter Home</a> &nbsp;&#8250;&nbsp;
+<a href="../index.html">User Guide Home</a> &nbsp;&#8250;&nbsp;
+Loader Class
+</td>
+<td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="codeigniter.com/user_guide/" />Search User Guide&nbsp; <input type="text" class="input" style="width:200px;" name="q" id="q" size="31" maxlength="255" value="" />&nbsp;<input type="submit" class="submit" name="sa" value="Go" /></form></td>
+</tr>
+</table>
+<!-- END BREADCRUMB -->
+
+<br clear="all" />
+
+
+<!-- START CONTENT -->
+<div id="content">
+
+
+<h1>Loader Class</h1>
+
+<p>Loader, as the name suggests, is used to load elements.  These elements can be libraries (classes) <a href="../general/views.html">View files</a>,
+<a href="../general/helpers.html">Helpers</a>, <a href="../general/models.html">Models</a>, or your own files.</p>
+
+<p class="important"><strong>Note:</strong> This class is initialized automatically by the system so there is no need to do it manually.</p>
+
+<p>The following functions are available in this class:</p>
+
+
+<h2>$this->load->library('<var>class_name</var>', <samp>$config</samp>, <kbd>'object name'</kbd>)</h2>
+
+
+<p>This function is used to load core classes.  Where <var>class_name</var> is the name of the class you want to load.
+Note: We use the terms "class" and "library" interchangeably.</p>
+
+<p>For example, if you would like to send email with CodeIgniter, the first step is to load the email class within your controller:</p>
+
+<code>$this->load->library('email');</code>
+
+<p>Once loaded, the library will be ready for use, using <kbd>$this->email-></kbd><samp><em>some_function</em>()</samp>.</p>
+
+<p>Library files can be stored in subdirectories within the main "libraries" folder, or within your personal <dfn>application/libraries</dfn> folder.
+To load a file located in a subdirectory, simply include the path, relative to the "libraries" folder.
+For example, if you have file located at:</p>
+
+<code>libraries/flavors/chocolate.php</code>
+
+<p>You will load it using:</p>
+
+<code>$this->load->library('flavors/chocolate');</code>
+
+<p>You may nest the file in as many subdirectories as you want.</p>
+
+<p>Additionally, multiple libraries can be loaded at the same time by passing an array of libraries to the load function.</p>
+
+<code>$this->load->library(array('<var>email</var>', '<var>table</var>'));</code>
+
+<h3>Setting options</h3>
+
+<p>The second (optional) parameter allows you to optionally pass configuration setting.  You will typically pass these as an array:</p>
+
+<code>
+$config = array (<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'mailtype' => 'html',<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'charset'&nbsp; => 'utf-8,<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'priority' => '1'<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;);<br />
+<br />
+$this->load->library('email', $config);</code>
+
+<p>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.</p>
+
+<p>Please take note, when multiple libraries are supplied in an array for the first parameter, each will receive the same parameter information.</p>
+
+<h3>Assigning a Library to a different object name</h3>
+
+<p>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 <dfn>Session</dfn>, it
+will be assigned to a variable named <dfn>$this->session</dfn>.</p>
+
+<p>If you prefer to set your own class names you can pass its value to the third parameter:</p>
+
+<code>$this->load->library('session', '', 'my_session');<br /><br />
+
+// Session class is now accessed using:<br /><br />
+
+$this->my_session
+
+</code>
+
+<p>Please take note, when multiple libraries are supplied in an array for the first parameter, this parameter is discarded.</p>
+
+
+<h2>$this->load->view('<var>file_name</var>', <samp>$data</samp>, <kbd>true/false</kbd>)</h2>
+
+<p>This function is used to load your View files.  If you haven't read the <a href="../general/views.html">Views</a> section of the
+user guide it is recommended that you do since it shows you how this function is typically used.</p>
+
+<p>The first parameter is required.  It is the name of the view file you would like to load. &nbsp;Note: The .php file extension does not need to be specified unless you use something other than <kbd>.php</kbd>.</p>
+
+<p>The second <strong>optional</strong> parameter can take
+an associative array or an object as input, which it runs through the PHP <a href="http://www.php.net/extract">extract</a> function to
+convert to variables that can be used in your view files.  Again, read the <a href="../general/views.html">Views</a> page to learn
+how this might be useful.</p>
+
+<p>The third <strong>optional</strong> parameter lets you change the behavior of the function so that it returns data as a string
+rather than sending it to your browser.  This can be useful if you want to process the data in some way.  If you
+set the parameter to <kbd>true</kbd> (boolean) it will return data.  The default behavior is <kbd>false</kbd>, which sends it
+to your browser.  Remember to assign it to a variable if you want the data returned:</p>
+
+<code>$string = $this->load->view('<var>myfile</var>', '', <kbd>true</kbd>);</code>
+
+
+<h2>$this-&gt;load-&gt;model('<var>Model_name</var>');</h2>
+<p><code>$this-&gt;load-&gt;model('<var>Model_name</var>');</code></p>
+<p>If your model is located in a sub-folder, include the relative path from your models folder. For example, if you have a model located at application/models/blog/queries.php you'll load it using:</p>
+<p><code>$this-&gt;load-&gt;model('<var>blog/queries</var>');</code></p>
+<p>If you would like your model assigned to a different object name you can specify it via the second parameter of the loading
+       function:</p>
+<code> $this-&gt;load-&gt;model('<var>Model_name</var>', '<kbd>fubar</kbd>');<br />
+<br />
+$this-&gt;<kbd>fubar</kbd>-&gt;function();</code>
+<h2>$this->load->database('<var>options</var>', <kbd>true/false</kbd>)</h2>
+<p>This function lets you load the database class.  The two parameters are <strong>optional</strong>.  Please see the
+<a href="../database/index.html">database</a> section for more info.</p>
+
+
+
+
+<h2>$this->load->vars(<samp>$array</samp>)</h2>
+
+<p>This function takes an associative array as input and generates variables using the PHP <a href="http://www.php.net/extract">extract</a> function.
+This function produces the same result as using the second parameter of the <dfn>$this->load->view()</dfn> function above.  The reason you might
+want to use this function independently is if you would like to set some global variables in the constructor of your controller
+and have them become available in any view file loaded from any function.  You can have multiple calls to this function.  The data get cached
+and merged into one array for conversion to variables.
+</p>
+
+
+<h2>$this->load->helper('<var>file_name</var>')</h2>
+<p>This function loads helper files, where <var>file_name</var> is the name of the file, without the <kbd>_helper.php</kbd> extension.</p>
+
+
+<h2>$this->load->file('<var>filepath/filename</var>', <kbd>true/false</kbd>)</h2>
+<p>This is a generic file loading function.  Supply the filepath and name in the first parameter and it will open and read the file.
+By default the data is sent to your browser, just like a View file, but if you set the second parameter to <kbd>true</kbd> (boolean)
+it will instead return the data as a string.</p>
+
+
+<h2>$this->load->language('<var>file_name</var>')</h2>
+<p>This function is an alias of the <a href="language.html">language loading function</a>: $this->lang->load()</p>
+
+<h2>$this->load->config('<var>file_name</var>')</h2>
+<p>This function is an alias of the <a href="config.html">config file loading function</a>: $this->config->load()</p>
+
+
+<h2>Application "Packages"</h2>
+
+<p>An application package allows for the easy distribution of complete sets of resources in a single directory, complete with its own libraries, models, helpers, config, and language files.  It is recommended that these packages be placed in the <dfn>application/third_party</dfn> folder.  Below is a sample map of an package directory</p>
+
+
+<h2>Sample Package "Foo Bar" Directory Map</h2>
+
+<p>The following is an example of a directory for an application package named "Foo Bar".</p>
+
+<code>/application/third_party/foo_bar<br />
+<br />
+config/<br />
+helpers/<br />
+language/<br />
+libraries/<br />
+models/<br />
+</code>
+
+<p>Whatever the purpose of the "Foo Bar" application package, it has its own config files, helpers, language files, libraries, and models.  To use these resources in your controllers, you first need to tell the Loader that you are going to be loading resources from a package, by adding the package path.</p>
+
+<h3>$this->load->add_package_path()</h3>
+
+<p>Adding a package path instructs the Loader class to prepend a given path for subsequent requests for resources.  As an example, the "Foo Bar" application package above has a library named <dfn>Foo_bar.php</dfn>. In our controller, we'd do the following:</p>
+
+<code>$this->load->add_package_path(<var>APPPATH</var>.'third_party/<var>foo_bar</var>/');<br />
+$this->load->library('foo_bar');</code>
+
+<h3>$this->load->remove_package_path()</h3>
+
+<p>When your controller is finished using resources from an application package, and particularly if you have other application packages you want to work with, you may wish to remove the package path so the Loader no longer looks in that folder for resources.  To remove the last path added, simply call the method with no parameters.</p>
+
+<h3>$this->load->remove_package_path()</h3>
+
+<p>Or to remove a specific package path, specify the same path previously given to <kbd>add_package_path() for a package.</kbd>:</p>
+
+<code>$this->load->remove_package_path(<var>APPPATH</var>.'third_party/<var>foo_bar</var>/');</code>
+
+<h3>Package view files</h3>
+
+<p>@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.</p>
+
+<code>// ... save the original view path, and set to our Foo Bar package view folder<br />
+$orig_view_path = $this->load->_ci_view_path;<br />
+$this->load->_ci_view_path = <var>APPPATH</var>.'third_party/<var>foo_bar</var>/views/';<br />
+<br />
+// ... code using the package's view files<br />
+<br />
+// ... then return the view path to the application's original view path<br />
+$this->load->_ci_view_path = $orig_view_path;</code>
+
+
+</div>
+<!-- END CONTENT -->
+
+
+<div id="footer">
+<p>
+Previous Topic:&nbsp;&nbsp;<a href="input.html">Input Class</a>
+&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+<a href="#top">Top of Page</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+<a href="../index.html">User Guide Home</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+Next Topic:&nbsp;&nbsp;<a href="language.html">Language Class</a>
+</p>
+<p><a href="http://codeigniter.com">CodeIgniter</a> &nbsp;&middot;&nbsp; Copyright &#169; 2006 - 2011 &nbsp;&middot;&nbsp; <a href="http://ellislab.com/">EllisLab, Inc.</a></p>
+</div>
+
+</body>
+</html>
\ No newline at end of file
diff --git a/user_guide/libraries/output.html b/user_guide/libraries/output.html
new file mode 100755 (executable)
index 0000000..4d1f8d9
--- /dev/null
@@ -0,0 +1,177 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head>
+
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+<title>Output Class : CodeIgniter User Guide</title>
+
+<style type='text/css' media='all'>@import url('../userguide.css');</style>
+<link rel='stylesheet' type='text/css' media='all' href='../userguide.css' />
+
+<script type="text/javascript" src="../nav/nav.js"></script>
+<script type="text/javascript" src="../nav/prototype.lite.js"></script>
+<script type="text/javascript" src="../nav/moo.fx.js"></script>
+<script type="text/javascript" src="../nav/user_guide_menu.js"></script>
+
+<meta http-equiv='expires' content='-1' />
+<meta http-equiv= 'pragma' content='no-cache' />
+<meta name='robots' content='all' />
+<meta name='author' content='ExpressionEngine Dev Team' />
+<meta name='description' content='CodeIgniter User Guide' />
+
+</head>
+<body>
+
+<!-- START NAVIGATION -->
+<div id="nav"><div id="nav_inner"><script type="text/javascript">create_menu('../');</script></div></div>
+<div id="nav2"><a name="top"></a><a href="javascript:void(0);" onclick="myHeight.toggle();"><img src="../images/nav_toggle_darker.jpg" width="154" height="43" border="0" title="Toggle Table of Contents" alt="Toggle Table of Contents" /></a></div>
+<div id="masthead">
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td><h1>CodeIgniter User Guide Version 2.0.2</h1></td>
+<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
+</tr>
+</table>
+</div>
+<!-- END NAVIGATION -->
+
+
+<!-- START BREADCRUMB -->
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td id="breadcrumb">
+<a href="http://codeigniter.com/">CodeIgniter Home</a> &nbsp;&#8250;&nbsp;
+<a href="../index.html">User Guide Home</a> &nbsp;&#8250;&nbsp;
+Output Class
+</td>
+<td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="codeigniter.com/user_guide/" />Search User Guide&nbsp; <input type="text" class="input" style="width:200px;" name="q" id="q" size="31" maxlength="255" value="" />&nbsp;<input type="submit" class="submit" name="sa" value="Go" /></form></td>
+</tr>
+</table>
+<!-- END BREADCRUMB -->
+
+<br clear="all" />
+
+
+<!-- START CONTENT -->
+<div id="content">
+
+
+<h1>Output Class</h1>
+
+<p>The Output class is a small class with one main function:  To send the finalized web page to the requesting browser.  It is
+also responsible for <a href="../general/caching.html">caching</a> your web pages, if you use that feature.</p>
+
+<p class="important"><strong>Note:</strong> This class is initialized automatically by the system so there is no need to do it manually.</p>
+
+<p>Under normal circumstances you won't even notice the Output class since it works transparently without your intervention.
+For example, when you use the <a href="../libraries/loader.html">Loader</a> class to load a view file, it's automatically
+passed to the Output class, which will be called automatically by CodeIgniter at the end of system execution.
+It is possible, however, for you to manually intervene with the output if you need to, using either of the two following functions:</p>
+
+<h2>$this->output->set_output();</h2>
+
+<p>Permits you to manually set the final output string.  Usage example:</p>
+
+<code>$this->output->set_output($data);</code>
+
+<p><strong>Important:</strong> If you do set your output manually, it must be the last thing done in the function you call it from.
+For example, if you build a page in one of your controller functions, don't set the output until the end.</p>
+
+
+<h2>$this->output->set_content_type();</h2>
+
+<p>Permits you to set the mime-type of your page so you can serve JSON data, JPEG's, XML, etc easily.</p>
+
+<code>$this->output<br/>
+&nbsp;&nbsp;&nbsp;&nbsp;->set_content_type('application/json')<br/>
+&nbsp;&nbsp;&nbsp;&nbsp;->set_output(json_encode(array('foo' => 'bar')));<br/>
+<br/>
+$this->output<br/>
+&nbsp;&nbsp;&nbsp;&nbsp;->set_content_type('jpeg') // You could also use ".jpeg" which will have the full stop removed before looking in config/mimes.php<br/>
+&nbsp;&nbsp;&nbsp;&nbsp;->set_output(file_get_contents('files/something.jpg'));</code>
+
+<p><strong>Important:</strong> Make sure any non-mime string you pass to this method exists in config/mimes.php or it will have no effect.</p>
+
+
+<h2>$this->output->get_output();</h2>
+
+<p>Permits you to manually retrieve any output that has been sent for storage in the output class.  Usage example:</p>
+<code>$string = $this->output->get_output();</code>
+
+<p>Note that data will only be retrievable from this function if it has been previously sent to the output class by one of the
+CodeIgniter functions like <var>$this->load->view()</var>.</p>
+
+
+<h2>$this->output->append_output();</h2>
+
+<p>Appends data onto the output string.  Usage example:</p>
+
+<code>$this->output->append_output($data);</code>
+
+
+
+<h2>$this->output->set_header();</h2>
+
+<p>Permits you to manually set server headers, which the output class will send for you when outputting the final rendered display.  Example:</p>
+
+<code>
+$this->output->set_header("HTTP/1.0 200 OK");<br />
+$this->output->set_header("HTTP/1.1 200 OK");<br />
+$this->output->set_header('Last-Modified: '.gmdate('D, d M Y H:i:s', $last_update).' GMT');<br />
+$this->output->set_header("Cache-Control: no-store, no-cache, must-revalidate");<br />
+$this->output->set_header("Cache-Control: post-check=0, pre-check=0");<br />
+$this->output->set_header("Pragma: no-cache"); </code>
+
+
+<h2>$this->output->set_status_header(<var>code</var>, '<var>text</var>');</h2>
+
+<p>Permits you to manually set a server status header.  Example:</p>
+
+<code>$this->output->set_status_header('401');<br />
+// Sets the header as:  Unauthorized</code>
+
+<p><a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html">See here</a> for a full list of headers.</p>
+
+<h2>$this->output->enable_profiler();</h2>
+
+<p>Permits you to enable/disable the <a href="../general/profiling.html">Profiler</a>, which will display benchmark and other data
+at the bottom of your pages for debugging and optimization purposes.</p>
+
+<p>To enable the profiler place the following function anywhere within your <a href="../general/controllers.html">Controller</a> functions:</p>
+<code>$this->output->enable_profiler(TRUE);</code>
+
+<p>When enabled a report will be generated and inserted at the bottom of your pages.</p>
+
+<p>To disable the profiler you will use:</p>
+<code>$this->output->enable_profiler(FALSE);</code>
+
+<h2>$this->output->set_profiler_sections();</h2>
+
+<p>Permits you to enable/disable specific sections of the Profiler when enabled.  Please refer to the <a href="../general/profiling.html">Profiler</a> documentation for further information.</p>
+
+<h2>$this->output->cache();</h2>
+<p>The CodeIgniter output library also controls caching.  For more information, please see the <a href="../general/caching.html">caching documentation</a>.</p>
+
+<h2>Parsing Execution Variables</h2>
+
+       <p>CodeIgniter will parse the pseudo-variables <var>{elapsed_time}</var> and <var>{memory_usage}</var> in your output by default.  To disable this, set the <var>$parse_exec_vars</var> class property to <var>FALSE</var> in your controller.
+
+       <code>$this->output->parse_exec_vars = FALSE;</code>
+
+</div>
+<!-- END CONTENT -->
+
+
+<div id="footer">
+<p>
+Previous Topic:&nbsp;&nbsp;<a href="language.html">Language Class</a>
+&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+<a href="#top">Top of Page</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+<a href="../index.html">User Guide Home</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+Next Topic:&nbsp;&nbsp;<a href="pagination.html">Pagination Class</a>
+</p>
+<p><a href="http://codeigniter.com">CodeIgniter</a> &nbsp;&middot;&nbsp; Copyright &#169; 2006 - 2011 &nbsp;&middot;&nbsp; <a href="http://ellislab.com/">EllisLab, Inc.</a></p>
+</div>
+
+</body>
+</html>
\ No newline at end of file
diff --git a/user_guide/libraries/pagination.html b/user_guide/libraries/pagination.html
new file mode 100755 (executable)
index 0000000..e86ec13
--- /dev/null
@@ -0,0 +1,229 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head>
+
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+<title>Pagination Class : CodeIgniter User Guide</title>
+
+<style type='text/css' media='all'>@import url('../userguide.css');</style>
+<link rel='stylesheet' type='text/css' media='all' href='../userguide.css' />
+
+<script type="text/javascript" src="../nav/nav.js"></script>
+<script type="text/javascript" src="../nav/prototype.lite.js"></script>
+<script type="text/javascript" src="../nav/moo.fx.js"></script>
+<script type="text/javascript" src="../nav/user_guide_menu.js"></script>
+
+<meta http-equiv='expires' content='-1' />
+<meta http-equiv= 'pragma' content='no-cache' />
+<meta name='robots' content='all' />
+<meta name='author' content='ExpressionEngine Dev Team' />
+<meta name='description' content='CodeIgniter User Guide' />
+
+</head>
+<body>
+
+<!-- START NAVIGATION -->
+<div id="nav"><div id="nav_inner"><script type="text/javascript">create_menu('../');</script></div></div>
+<div id="nav2"><a name="top"></a><a href="javascript:void(0);" onclick="myHeight.toggle();"><img src="../images/nav_toggle_darker.jpg" width="154" height="43" border="0" title="Toggle Table of Contents" alt="Toggle Table of Contents" /></a></div>
+<div id="masthead">
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td><h1>CodeIgniter User Guide Version 2.0.2</h1></td>
+<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
+</tr>
+</table>
+</div>
+<!-- END NAVIGATION -->
+
+
+<!-- START BREADCRUMB -->
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td id="breadcrumb">
+<a href="http://codeigniter.com/">CodeIgniter Home</a> &nbsp;&#8250;&nbsp;
+<a href="../index.html">User Guide Home</a> &nbsp;&#8250;&nbsp;
+Pagination Class
+</td>
+<td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="codeigniter.com/user_guide/" />Search User Guide&nbsp; <input type="text" class="input" style="width:200px;" name="q" id="q" size="31" maxlength="255" value="" />&nbsp;<input type="submit" class="submit" name="sa" value="Go" /></form></td>
+</tr>
+</table>
+<!-- END BREADCRUMB -->
+
+<br clear="all" />
+
+
+<!-- START CONTENT -->
+<div id="content">
+
+
+<h1>Pagination Class</h1>
+
+<p>CodeIgniter's Pagination class is very easy to use, and it is 100% customizable, either dynamically or via stored preferences.</p>
+
+<p>If you are not familiar with the term "pagination", it refers to links that allows you to navigate from page to page, like this:</p>
+
+<code><a href="#">&laquo; First</a>&nbsp;&nbsp;<a href="#">&lt;</a>&nbsp;<a href="#">1</a>&nbsp;<a href="#">2</a>&nbsp;<b>3</b>&nbsp;<a href="#">4</a>&nbsp;<a href="#">5</a>&nbsp;<a href="#">&gt;</a>&nbsp;&nbsp;<a href="#">Last &raquo;</a></code>
+
+<h2>Example</h2>
+
+<p>Here is a simple example showing how to create pagination in one of your <a href="../general/controllers.html">controller</a> functions:</p>
+
+<code>
+$this->load->library('pagination');<br /><br />
+$config['base_url'] = 'http://example.com/index.php/test/page/';<br />
+$config['total_rows'] = '200';<br />
+$config['per_page']  = '20';
+<br /><br />
+$this->pagination->initialize($config);
+
+<br /><br />
+echo  $this->pagination->create_links();</code>
+
+<h3>Notes:</h3>
+
+<p>The <var>$config</var> array contains your configuration variables.  It is passed to the <dfn>$this->pagination->initialize</dfn> function as shown above.  Although there are some twenty items you can configure, at
+minimum you need the three shown.  Here is a description of what those items represent:</p>
+
+<ul>
+       <li><strong>base_url</strong> This is the full URL to the controller class/function containing your pagination.  In the example
+       above, it is pointing to a controller called "Test" and a function called "page".  Keep in mind that you can
+       <a href="../general/routing.html">re-route your URI</a> if you need a different structure.</li>
+       <li><strong>total_rows</strong> This number represents the total rows in the result set you are creating pagination for.
+       Typically this number will be the total rows that your database query returned.
+       </li>
+       <li><strong>per_page</strong> The number of items you intend to show per page.  In the above example, you would be showing 20 items per page.</li>
+</ul>
+
+<p>The <var>create_links()</var> function returns an empty string when there is no pagination to show.</p>
+
+
+<h3>Setting preferences in a config file</h3>
+
+<p>If you prefer not to set preferences using the above method, you can instead put them into a config file.
+Simply create a new file called <var>pagination.php</var>,  add the <var>$config</var>
+array in that file. Then save the file in: <var>config/pagination.php</var> and it will be used automatically. You
+will NOT need to use the <dfn>$this->pagination->initialize</dfn> function if you save your preferences in a config file.</p>
+
+
+<h2>Customizing the Pagination</h2>
+
+<p>The following is a list of all the preferences you can pass to the initialization function to tailor the display.</p>
+
+
+<h4>$config['uri_segment'] = 3;</h4>
+
+<p>The pagination function automatically determines which segment of your URI contains the page number. If you need
+something different you can specify it.</p>
+
+<h4>$config['num_links'] = 2;</h4>
+
+<p>The number of &quot;digit&quot; links you would like before and after the selected page number. For example, the number 2
+       will place two digits on either side, as in the example links at the very top of this page.</p>
+<h4>$config['page_query_string'] = TRUE</h4>
+<p>By default, the pagination library assume you are using <a href="../general/urls.html">URI Segments</a>, and constructs your links something like</p>
+<p><code>http://example.com/index.php/test/page/20</code></p>
+<p>If you have $config['enable_query_strings']  set to TRUE your links will automatically be re-written using Query Strings. This option can also be explictly set. Using $config['page_query_string'] set to TRUE, the pagination link will become.</p>
+<p><code>http://example.com/index.php?c=test&amp;m=page&amp;per_page=20</code></p>
+<p>Note that &quot;per_page&quot; is the default query string  passed, however can be configured using $config['query_string_segment'] = 'your_string'</p>
+<h2>Adding Enclosing Markup</h2>
+
+<p>If you would like to surround the entire pagination with some markup you can do it with these two prefs:</p>
+
+<h4>$config['full_tag_open'] = '&lt;p>';</h4>
+<p>The opening tag placed on the left side of the entire result.</p>
+
+<h4>$config['full_tag_close'] = '&lt;/p>';</h4>
+<p>The closing tag placed on the right side of the entire result.</p>
+
+
+<h2>Customizing the First Link</h2>
+
+<h4>$config['first_link'] = 'First';</h4>
+<p>The text you would like shown in the "first" link on the left. If you do not want this link rendered, you can set its value to FALSE.</p>
+
+<h4>$config['first_tag_open'] = '&lt;div>';</h4>
+<p>The opening tag for the "first" link.</p>
+
+<h4>$config['first_tag_close'] = '&lt;/div>';</h4>
+<p>The closing tag for the "first" link.</p>
+
+<h2>Customizing the Last Link</h2>
+
+<h4>$config['last_link'] = 'Last';</h4>
+<p>The text you would like shown in the "last" link on the right. If you do not want this link rendered, you can set its value to FALSE.</p>
+
+<h4>$config['last_tag_open'] = '&lt;div>';</h4>
+<p>The opening tag for the "last" link.</p>
+
+<h4>$config['last_tag_close'] = '&lt;/div>';</h4>
+<p>The closing tag for the "last" link.</p>
+
+<h2>Customizing the "Next" Link</h2>
+
+<h4>$config['next_link'] = '&amp;gt;';</h4>
+<p>The text you would like shown in the "next" page link. If you do not want this link rendered, you can set its value to FALSE.</p>
+
+<h4>$config['next_tag_open'] = '&lt;div>';</h4>
+<p>The opening tag for the "next" link.</p>
+
+<h4>$config['next_tag_close'] = '&lt;/div>';</h4>
+<p>The closing tag for the "next" link.</p>
+
+<h2>Customizing the "Previous" Link</h2>
+
+<h4>$config['prev_link'] = '&amp;lt;';</h4>
+<p>The text you would like shown in the "previous" page link. If you do not want this link rendered, you can set its value to FALSE.</p>
+
+<h4>$config['prev_tag_open'] = '&lt;div>';</h4>
+<p>The opening tag for the "previous" link.</p>
+
+<h4>$config['prev_tag_close'] = '&lt;/div>';</h4>
+<p>The closing tag for the "previous" link.</p>
+
+<h2>Customizing the "Current Page" Link</h2>
+
+<h4>$config['cur_tag_open'] = '&lt;b>';</h4>
+<p>The opening tag for the "current" link.</p>
+
+<h4>$config['cur_tag_close'] = '&lt;/b>';</h4>
+<p>The closing tag for the "current" link.</p>
+
+
+<h2>Customizing the "Digit" Link</h2>
+
+<h4>$config['num_tag_open'] = '&lt;div>';</h4>
+<p>The opening tag for the "digit" link.</p>
+
+<h4>$config['num_tag_close'] = '&lt;/div>';</h4>
+<p>The closing tag for the "digit" link.</p>
+
+<h2>Hiding the Pages</h2>
+
+<p>If you wanted to not list the specific pages (for example, you only want "next" and "previous" links), you can suppress their rendering by adding:</p>
+
+<code>
+$config['display_pages'] = FALSE;
+</code>
+
+
+<h2>Adding a class to every anchor</h2>
+
+<p>If you want to add a class attribute to every link rendered by the pagination class, you can set the config "anchor_class" equal to the classname you want.</p>
+
+</div>
+<!-- END CONTENT -->
+
+
+<div id="footer">
+<p>
+Previous Topic:&nbsp;&nbsp;<a href="output.html">Output Class</a>
+&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+<a href="#top">Top of Page</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+<a href="../index.html">User Guide Home</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+Next Topic:&nbsp;&nbsp;<a href="sessions.html">Session Class</a>
+</p>
+<p><a href="http://codeigniter.com">CodeIgniter</a> &nbsp;&middot;&nbsp; Copyright &#169; 2006 - 2011 &nbsp;&middot;&nbsp; <a href="http://ellislab.com/">EllisLab, Inc.</a></p>
+</div>
+
+</body>
+</html>
\ No newline at end of file
diff --git a/user_guide/libraries/parser.html b/user_guide/libraries/parser.html
new file mode 100755 (executable)
index 0000000..cb2f100
--- /dev/null
@@ -0,0 +1,212 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head>
+
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+<title>Template Parser Class : CodeIgniter User Guide</title>
+
+<style type='text/css' media='all'>@import url('../userguide.css');</style>
+<link rel='stylesheet' type='text/css' media='all' href='../userguide.css' />
+
+<script type="text/javascript" src="../nav/nav.js"></script>
+<script type="text/javascript" src="../nav/prototype.lite.js"></script>
+<script type="text/javascript" src="../nav/moo.fx.js"></script>
+<script type="text/javascript" src="../nav/user_guide_menu.js"></script>
+
+<meta http-equiv='expires' content='-1' />
+<meta http-equiv= 'pragma' content='no-cache' />
+<meta name='robots' content='all' />
+<meta name='author' content='ExpressionEngine Dev Team' />
+<meta name='description' content='CodeIgniter User Guide' />
+
+</head>
+<body>
+
+<!-- START NAVIGATION -->
+<div id="nav"><div id="nav_inner"><script type="text/javascript">create_menu('../');</script></div></div>
+<div id="nav2"><a name="top"></a><a href="javascript:void(0);" onclick="myHeight.toggle();"><img src="../images/nav_toggle_darker.jpg" width="154" height="43" border="0" title="Toggle Table of Contents" alt="Toggle Table of Contents" /></a></div>
+<div id="masthead">
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td><h1>CodeIgniter User Guide Version 2.0.2</h1></td>
+<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
+</tr>
+</table>
+</div>
+<!-- END NAVIGATION -->
+
+
+<!-- START BREADCRUMB -->
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td id="breadcrumb">
+<a href="http://codeigniter.com/">CodeIgniter Home</a> &nbsp;&#8250;&nbsp;
+<a href="../index.html">User Guide Home</a> &nbsp;&#8250;&nbsp;
+Template Parser Class
+</td>
+<td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="codeigniter.com/user_guide/" />Search User Guide&nbsp; <input type="text" class="input" style="width:200px;" name="q" id="q" size="31" maxlength="255" value="" />&nbsp;<input type="submit" class="submit" name="sa" value="Go" /></form></td>
+</tr>
+</table>
+<!-- END BREADCRUMB -->
+
+<br clear="all" />
+
+
+<!-- START CONTENT -->
+<div id="content">
+
+
+
+
+<h1>Template Parser Class</h1>
+
+<p>The Template Parser Class enables you to parse pseudo-variables contained within your view files. It can parse simple
+variables or variable tag pairs. If you've never used a template engine, pseudo-variables look like this:</p>
+
+<code>&lt;html&gt;<br />
+&lt;head&gt;<br />
+&lt;title&gt;<kbd>{blog_title}</kbd>&lt;/title&gt;<br />
+&lt;/head&gt;<br />
+&lt;body&gt;<br />
+<br />
+&lt;h3&gt;<kbd>{blog_heading}</kbd>&lt;/h3&gt;<br />
+<br />
+<kbd>{blog_entries}</kbd><br />
+&lt;h5&gt;<kbd>{title}</kbd>&lt;/h5&gt;<br />
+&lt;p&gt;<kbd>{body}</kbd>&lt;/p&gt;<br />
+<kbd>{/blog_entries}</kbd><br />
+
+&lt;/body&gt;<br />
+&lt;/html&gt;</code>
+
+<p>These variables are not actual PHP variables, but rather plain text representations that allow you to eliminate
+PHP from your templates (view files).</p>
+
+<p class="important"><strong>Note:</strong> CodeIgniter does <strong>not</strong> require you to use this class
+since using pure PHP in your view pages lets them run a little faster.  However, some developers prefer to use a template engine if
+they work with designers who they feel would find some confusion working with PHP.</p>
+
+<p><strong>Also Note:</strong> The Template Parser Class is <strong>not</strong>  a
+full-blown template parsing solution. We've kept it very lean on purpose in order to maintain maximum performance.</p>
+
+
+<h2>Initializing the Class</h2>
+
+<p>Like most other classes in CodeIgniter, the Parser class is initialized in your controller using the <dfn>$this->load->library</dfn> function:</p>
+
+<code>$this->load->library('parser');</code>
+<p>Once loaded, the Parser library object will be available using: <dfn>$this->parser</dfn></p>
+
+
+<p>The following functions are available in this library:</p>
+
+<h2>$this->parser->parse()</h2>
+
+<p>This method accepts a template name and data array as input, and it generates a parsed version.  Example:</p>
+
+<code>$this->load->library('parser');<br />
+<br />
+$data = array(<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'blog_title' => 'My Blog Title',<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'blog_heading' => 'My Blog Heading'<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;);<br />
+<br />
+$this->parser->parse('blog_template', $data);</code>
+
+<p>The first parameter contains the name of the <a href="../general/views.html">view file</a> (in this example the file would be called blog_template.php),
+and the second parameter contains an associative array of data to be replaced in the template.  In the above example, the
+template would contain two variables: {blog_title} and {blog_heading}</p>
+
+<p>There is no need to "echo" or do something with the data returned by <dfn>$this->parser->parse()</dfn>.  It is automatically
+passed to the output class to be sent to the browser.  However, if you do want the data returned instead of sent to the output class you can
+pass TRUE (boolean) to the third parameter:</p>
+
+<code>$string = $this->parser->parse('blog_template', $data, TRUE);</code>
+
+<h2>$this->parser->parse_string()</h2>
+
+<p>This method works exactly like parse(), only accepts a string as the first parameter in place of a view file.</p>
+
+
+<h2>Variable Pairs</h2>
+
+<p>The above example code allows simple variables to be replaced.  What if you would like an entire block of variables to be
+repeated, with each iteration containing new values?  Consider the template example we showed at the top of the page:</p>
+
+<code>&lt;html&gt;<br />
+&lt;head&gt;<br />
+&lt;title&gt;<kbd>{blog_title}</kbd>&lt;/title&gt;<br />
+&lt;/head&gt;<br />
+&lt;body&gt;<br />
+<br />
+&lt;h3&gt;<kbd>{blog_heading}</kbd>&lt;/h3&gt;<br />
+<br />
+<kbd>{blog_entries}</kbd><br />
+&lt;h5&gt;<kbd>{title}</kbd>&lt;/h5&gt;<br />
+&lt;p&gt;<kbd>{body}</kbd>&lt;/p&gt;<br />
+<kbd>{/blog_entries}</kbd><br />
+
+&lt;/body&gt;<br />
+&lt;/html&gt;</code>
+
+<p>In the above code you'll notice a pair of variables: <kbd>{blog_entries}</kbd> data... <kbd>{/blog_entries}</kbd>.
+In a case like this, the entire chunk of data between these pairs would be repeated multiple times, corresponding
+to the number of rows in a result.</p>
+
+<p>Parsing variable pairs is done using the identical code shown above to parse single variables,
+except, you will add a multi-dimensional array corresponding to your variable pair data.
+Consider this example:</p>
+
+
+<code>$this->load->library('parser');<br />
+<br />
+$data = array(<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'blog_title'&nbsp;&nbsp; => 'My Blog Title',<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'blog_heading' => 'My Blog Heading',<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'blog_entries' => array(<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;array('title' => 'Title 1', 'body' => 'Body 1'),<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;array('title' => 'Title 2', 'body' => 'Body 2'),<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;array('title' => 'Title 3', 'body' => 'Body 3'),<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;array('title' => 'Title 4', 'body' => 'Body 4'),<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;array('title' => 'Title 5', 'body' => 'Body 5')<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;)<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;);<br />
+<br />
+$this->parser->parse('blog_template', $data);</code>
+
+<p>If your "pair" data is coming from a database result, which is already a multi-dimensional array, you can simply
+use the database result_array() function:</p>
+
+<code>
+$query = $this->db->query("SELECT * FROM blog");<br />
+<br />
+$this->load->library('parser');<br />
+<br />
+$data = array(<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'blog_title'&nbsp;&nbsp; => 'My Blog Title',<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'blog_heading' => 'My Blog Heading',<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'blog_entries' => $query->result_array()<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;);<br />
+<br />
+$this->parser->parse('blog_template', $data);</code>
+
+
+
+
+</div>
+<!-- END CONTENT -->
+
+
+<div id="footer">
+<p>
+Previous Topic:&nbsp;&nbsp;<a href="trackback.html">Trackback Class</a>
+&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+<a href="#top">Top of Page</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+<a href="../index.html">User Guide Home</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+Next Topic:&nbsp;&nbsp;<a href="typography.html">Typography</a>
+</p>
+<p><a href="http://codeigniter.com">CodeIgniter</a> &nbsp;&middot;&nbsp; Copyright &#169; 2006 - 2011 &nbsp;&middot;&nbsp; <a href="http://ellislab.com/">EllisLab, Inc.</a></p>
+</div>
+
+</body>
+</html>
\ No newline at end of file
diff --git a/user_guide/libraries/security.html b/user_guide/libraries/security.html
new file mode 100755 (executable)
index 0000000..7351874
--- /dev/null
@@ -0,0 +1,135 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head>
+
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+<title>Security Class : CodeIgniter User Guide</title>
+
+<style type='text/css' media='all'>@import url('../userguide.css');</style>
+<link rel='stylesheet' type='text/css' media='all' href='../userguide.css' />
+
+<script type="text/javascript" src="../nav/nav.js"></script>
+<script type="text/javascript" src="../nav/prototype.lite.js"></script>
+<script type="text/javascript" src="../nav/moo.fx.js"></script>
+<script type="text/javascript" src="../nav/user_guide_menu.js"></script>
+
+<meta http-equiv='expires' content='-1' />
+<meta http-equiv= 'pragma' content='no-cache' />
+<meta name='robots' content='all' />
+<meta name='author' content='ExpressionEngine Dev Team' />
+<meta name='description' content='CodeIgniter User Guide' />
+
+</head>
+<body>
+
+<!-- START NAVIGATION -->
+<div id="nav"><div id="nav_inner"><script type="text/javascript">create_menu('../');</script></div></div>
+<div id="nav2"><a name="top"></a><a href="javascript:void(0);" onclick="myHeight.toggle();"><img src="../images/nav_toggle_darker.jpg" width="154" height="43" border="0" title="Toggle Table of Contents" alt="Toggle Table of Contents" /></a></div>
+<div id="masthead">
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td><h1>CodeIgniter User Guide Version 2.0.2</h1></td>
+<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
+</tr>
+</table>
+</div>
+<!-- END NAVIGATION -->
+
+
+<!-- START BREADCRUMB -->
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td id="breadcrumb">
+<a href="http://codeigniter.com/">CodeIgniter Home</a> &nbsp;&#8250;&nbsp;
+<a href="../index.html">User Guide Home</a> &nbsp;&#8250;&nbsp;
+Security Class
+</td>
+<td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="codeigniter.com/user_guide/" />Search User Guide&nbsp; <input type="text" class="input" style="width:200px;" name="q" id="q" size="31" maxlength="255" value="" />&nbsp;<input type="submit" class="submit" name="sa" value="Go" /></form></td>
+</tr>
+</table>
+<!-- END BREADCRUMB -->
+
+<br clear="all" />
+
+
+<!-- START CONTENT -->
+<div id="content">
+
+
+<h1>Security Class</h1>
+
+<p>The Security Class contains methods that help you create a secure application, processing input data for security.</p>
+
+<h2>XSS Filtering</h2>
+
+<p>CodeIgniter comes with a Cross Site Scripting Hack prevention filter which can either run automatically to filter
+all POST and COOKIE data that is encountered, or you can run it on a per item basis.  By default it does <strong>not</strong>
+run globally since it requires a bit of processing overhead, and since you may not need it in all cases.</p>
+
+<p>The XSS filter looks for commonly used techniques to trigger Javascript or other types of code that attempt to hijack cookies
+or do other malicious things.  If anything disallowed is encountered it is rendered safe by converting the data to character entities.</p>
+
+<p>
+Note: This function should only be used to deal with data upon submission. It's not something that should be used for general runtime processing since it requires a fair amount of processing overhead.</p>
+
+
+<p>To filter data through the XSS filter use this function:</p>
+
+<h2>$this->security->xss_clean()</h2>
+
+<p>Here is an usage example:</p>
+
+<code>$data = $this->security->xss_clean($data);</code>
+
+<p>If you want the filter to run automatically every time it encounters POST or COOKIE data you can enable it by opening your
+<kbd>application/config/config.php</kbd> file and setting this:</p>
+
+<code>$config['global_xss_filtering'] = TRUE;</code>
+
+<p>Note: If you use the form validation class, it gives you the option of XSS filtering as well.</p>
+
+<p>An optional second parameter, <dfn>is_image</dfn>, allows this function to be used to test images for potential XSS attacks, useful for file upload security.  When this second parameter is set to <dfn>TRUE</dfn>, instead of returning an altered string, the function returns TRUE if the image is safe, and FALSE if it contained potentially malicious information that a browser may attempt to execute.</p>
+
+<code>if ($this->security->xss_clean($file, TRUE) === FALSE)<br />
+{<br />
+&nbsp;&nbsp;&nbsp;&nbsp;// file failed the XSS test<br />
+}</code>
+
+
+<h2>$this->security->sanitize_filename()</h2>
+
+<p>When accepting filenames from user input, it is best to sanitize them to prevent directory traversal and other security related issues.  To do so, use the <dfn>sanitize_filename()</dfn> method of the Security class.  Here is an example:</p>
+
+<code>$filename = $this->security->sanitize_filename($this->input->post('filename'));</code>
+
+<p>If it is acceptable for the user input to include relative paths, e.g. <kbd>file/in/some/approved/folder.txt</kbd>, you can set the second optional parameter,
+       <samp>$relative_path</samp> to TRUE.</p>
+
+<code>$filename = $this->security->sanitize_filename($this->input->post('filename'), TRUE);</code>
+
+<!-- @todo write docs for CSRF methods -->
+
+<h2>Cross-site request forgery (CSRF)</h2>
+
+<p>You can enable csrf protection by opening your <kbd>application/config/config.php</kbd> file and setting this:</p>
+<code>$config['csrf_protection'] = TRUE;</code>
+
+<p>If you use the <a href="../helpers/form_helper.html">form helper</a> the <var>form_open()</var> function will automatically insert a hidden csrf field in your forms.</p>
+
+</div>
+<!-- END CONTENT -->
+
+
+<div id="footer">
+<p>
+Previous Topic:&nbsp;&nbsp;<a href="pagination.html">Pagination Class</a>
+&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+<a href="#top">Top of Page</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+<a href="../index.html">User Guide Home</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+Next Topic:&nbsp;&nbsp;<a href="sessions.html">Session Class</a>
+</p>
+<p><a href="http://codeigniter.com">CodeIgniter</a> &nbsp;&middot;&nbsp; Copyright &#169; 2006 - 2011 &nbsp;&middot;&nbsp; <a href="http://ellislab.com/">EllisLab, Inc.</a></p>
+</div>
+
+</body>
+</html>
\ No newline at end of file
diff --git a/user_guide/libraries/sessions.html b/user_guide/libraries/sessions.html
new file mode 100755 (executable)
index 0000000..600d301
--- /dev/null
@@ -0,0 +1,322 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head>
+
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+<title>Session Class : CodeIgniter User Guide</title>
+
+<style type='text/css' media='all'>@import url('../userguide.css');</style>
+<link rel='stylesheet' type='text/css' media='all' href='../userguide.css' />
+
+<script type="text/javascript" src="../nav/nav.js"></script>
+<script type="text/javascript" src="../nav/prototype.lite.js"></script>
+<script type="text/javascript" src="../nav/moo.fx.js"></script>
+<script type="text/javascript" src="../nav/user_guide_menu.js"></script>
+
+<meta http-equiv='expires' content='-1' />
+<meta http-equiv= 'pragma' content='no-cache' />
+<meta name='robots' content='all' />
+<meta name='author' content='ExpressionEngine Dev Team' />
+<meta name='description' content='CodeIgniter User Guide' />
+
+</head>
+<body>
+
+<!-- START NAVIGATION -->
+<div id="nav"><div id="nav_inner"><script type="text/javascript">create_menu('../');</script></div></div>
+<div id="nav2"><a name="top"></a><a href="javascript:void(0);" onclick="myHeight.toggle();"><img src="../images/nav_toggle_darker.jpg" width="154" height="43" border="0" title="Toggle Table of Contents" alt="Toggle Table of Contents" /></a></div>
+<div id="masthead">
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td><h1>CodeIgniter User Guide Version 2.0.2</h1></td>
+<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
+</tr>
+</table>
+</div>
+<!-- END NAVIGATION -->
+
+
+<!-- START BREADCRUMB -->
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td id="breadcrumb">
+<a href="http://codeigniter.com/">CodeIgniter Home</a> &nbsp;&#8250;&nbsp;
+<a href="../index.html">User Guide Home</a> &nbsp;&#8250;&nbsp;
+Session Class
+</td>
+<td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="codeigniter.com/user_guide/" />Search User Guide&nbsp; <input type="text" class="input" style="width:200px;" name="q" id="q" size="31" maxlength="255" value="" />&nbsp;<input type="submit" class="submit" name="sa" value="Go" /></form></td>
+</tr>
+</table>
+<!-- END BREADCRUMB -->
+
+<br clear="all" />
+
+
+<!-- START CONTENT -->
+<div id="content">
+
+
+<h1>Session Class</h1>
+
+<p>The Session class permits you maintain a user's "state" and track their activity while they browse your site.
+The Session class stores session information for each user as serialized (and optionally encrypted) data in a cookie.
+It can also store the session data in a database table for added security, as this permits the session ID in the
+user's cookie to be matched against the stored session ID. By default only the cookie is saved.  If you choose to
+use the database option you'll need to create the session table as indicated below.
+</p>
+
+<p class="important"><strong>Note:</strong> The Session class does <strong>not</strong> utilize native PHP sessions. It
+generates its own session data, offering more flexibility for developers.</p>
+
+<p class="important"><strong>Note:</strong> Even if you are not using encrypted sessions, you must set
+an <a href="./encryption.html">encryption key</a> in your config file which is used to aid in preventing session data manipulation.</p>
+
+<h2>Initializing a Session</h2>
+
+<p>Sessions will typically run globally with each page load, so the session class must either be
+<a href="../general/libraries.html">initialized</a> in your
+<a href="../general/controllers.html">controller</a> constructors, or it can be
+<a href="../general/autoloader.html">auto-loaded</a> by the system.
+For the most part the session class will run unattended in the background, so simply initializing the class
+will cause it to read, create, and update sessions.</p>
+
+
+<p>To initialize the Session class manually in your controller constructor, use the <dfn>$this->load->library</dfn> function:</p>
+
+<code>$this->load->library('session');</code>
+<p>Once loaded, the Sessions library object will be available using: <dfn>$this->session</dfn></p>
+
+
+<h2>How do Sessions work?</h2>
+
+<p>When a page is loaded, the session class will check to see if valid session data exists in the user's session cookie.
+If sessions data does <strong>not</strong> exist (or if it has expired) a new session will be created and saved in the cookie.
+If a session does exist, its information will be updated and the cookie will be updated. With each update, the session_id will be regenerated.</p>
+
+<p>It's important for you to understand that once initialized, the Session class runs automatically.  There is nothing
+you need to do to cause the above behavior to happen.  You can, as you'll see below, work with session data or
+even add your own data to a user's session, but the process of reading, writing, and updating a session is automatic.</p>
+
+
+<h2>What is Session Data?</h2>
+
+<p>A <em>session</em>, as far as CodeIgniter is concerned, is simply an array containing the following information:</p>
+
+<ul>
+<li>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)</li>
+<li>The user's IP Address</li>
+<li>The user's User Agent data (the first 50 characters of the browser data string)</li>
+<li>The "last activity"  time stamp.</li>
+</ul>
+
+<p>The above data is stored in a cookie as a serialized array with this prototype:</p>
+
+<code>[array]<br />
+(<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'session_id'&nbsp;&nbsp;&nbsp;&nbsp;=> random hash,<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'ip_address'&nbsp;&nbsp;&nbsp;&nbsp;=> 'string - user IP address',<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'user_agent'&nbsp;&nbsp;&nbsp;&nbsp;=> 'string - user agent data',<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'last_activity' => timestamp<br />
+)</code>
+
+<p>If you have the encryption option enabled, the serialized array will be encrypted before being stored in the cookie,
+making the data highly secure and impervious to being read or altered by someone. More info regarding encryption
+can be <a href="encryption.html">found here</a>, although the Session class will take care of initializing
+and encrypting the data automatically.</p>
+
+<p>Note: Session cookies are only updated every five minutes by default to reduce processor load.  If you repeatedly reload a page
+you'll notice that the "last activity" time only updates if five minutes or more has passed since the last time
+the cookie was written. This time is configurable by changing the $config['sess_time_to_update'] line in your system/config/config.php file.</p>
+
+<h2>Retrieving Session Data</h2>
+
+<p>Any piece of information from the session array is available using the following function:</p>
+
+<code>$this->session->userdata('<samp>item</samp>');</code>
+
+<p>Where <samp>item</samp> is the array index corresponding to the item you wish to fetch.  For example, to fetch the session ID you
+will do this:</p>
+
+<code>$session_id = $this->session->userdata('<samp>session_id</samp>');</code>
+
+<p><strong>Note:</strong> The function returns FALSE (boolean) if the item you are trying to access does not exist.</p>
+
+
+<h2>Adding Custom Session Data</h2>
+
+<p>A useful aspect of the session array is that you can add your own data to it and it will be stored in the user's cookie.
+Why would you want to do this?  Here's one example:</p>
+
+<p>Let's say a particular user logs into your site. Once authenticated,
+you could add their username and email address to the session cookie, making that data globally available to you without
+having to run a database query when you need it.</p>
+
+<p>To add your data to the session array involves passing an array containing your new data to this function:</p>
+
+<code>$this->session->set_userdata(<samp>$array</samp>);</code>
+
+<p>Where <samp>$array</samp> is an associative array containing your new data.  Here's an example:</p>
+
+
+<p><code>$newdata = array(<br />
+       &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'username'&nbsp; => 'johndoe',<br />
+       &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'email'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=> 'johndoe@some-site.com',<br />
+       &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'logged_in' => TRUE<br />
+       &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;);<br />
+       <br />
+       $this->session->set_userdata(<samp>$newdata</samp>);</code></p>
+<p>If you want to add userdata one value at a time, set_userdata() also supports this syntax. </p>
+<p><code>$this-&gt;session-&gt;set_userdata('some_name', 'some_value');</code></p>
+<p class="important"><strong>Note:</strong> 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.</p>
+
+<h2>Removing Session Data</h2>
+<p>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: </p>
+<p><code>$this-&gt;session-&gt;unset_userdata('some_name');</code></p>
+<p>This function can also be passed an associative array of items to unset.</p>
+<p><code>$array_items = array('username' => '', 'email' => '');<br />
+<br />
+$this-&gt;session-&gt;unset_userdata(<samp>$array_items</samp>);</code></p>
+<h2>Flashdata</h2>
+<p>CodeIgniter supports &quot;flashdata&quot;, or session data that will only be available for the next server request, and are then automatically cleared. These can be very useful, and are typically used for informational or status messages (for example: &quot;record 2 deleted&quot;).</p>
+<p>Note: Flash variables are prefaced with &quot;flash_&quot; so avoid this prefix in your own session names.</p>
+<p>To add flashdata:</p>
+<p><code>$this-&gt;session-&gt;set_flashdata('item', 'value');</code></p>
+<p>You can also pass an array to set_flashdata(), in the same manner as set_userdata(). </p>
+<p>To read a flashdata variable:</p>
+<p><code>$this-&gt;session-&gt;flashdata('item');</code></p>
+<p>If you find that you need to preserve a flashdata variable through an additional request, you can do so using the keep_flashdata() function.</p>
+<p><code>$this-&gt;session-&gt;keep_flashdata('item');</code></p>
+<h2>Saving Session Data to a Database</h2>
+<p>While the session data array stored in the user's cookie contains a Session ID,
+unless you store session data in a database there is no way to validate it.  For some applications that require little or no
+security, session ID validation may not be needed, but if your application requires security, validation is mandatory.  Otherwise, an old session
+could be restored by a user modifying their cookies.</p>
+
+<p>When session data is available in a database, every time a valid session is found in the user's cookie, a database
+query is performed to match it.  If the session ID does not match, the session is destroyed.  Session IDs can never
+be updated, they can only be generated when a new session is created.</p>
+
+
+<p>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:</p>
+
+<textarea class="textarea" style="width:100%" cols="50" rows="8">
+CREATE TABLE IF NOT EXISTS  `ci_sessions` (
+session_id varchar(40) DEFAULT '0' NOT NULL,
+ip_address varchar(16) DEFAULT '0' NOT NULL,
+user_agent varchar(50) NOT NULL,
+last_activity int(10) unsigned DEFAULT 0 NOT NULL,
+user_data text DEFAULT '' NOT NULL,
+PRIMARY KEY (session_id)
+);</textarea>
+
+<p><strong>Note:</strong> By default the table is called <dfn>ci_sessions</dfn>, but you can name it anything you want
+as long as you update the <kbd>application/config/config.php</kbd> file so that it contains the name you have chosen.
+Once you have created your database table you can enable the database option in your config.php file as follows:</p>
+
+<code>$config['sess_use_database'] = TRUE;</code>
+
+<p>Once enabled, the Session class will store session data in the DB.</p>
+
+<p>Make sure you've specified the table name in your config file as well:</p>
+
+<code>$config['sess_table_name'] = 'ci_sessions';</code>
+
+<p class="important"><strong>Note:</strong> The Session class has built-in garbage collection which clears out expired sessions so you
+do not need to write your own routine to do it.</p>
+
+
+<h2>Destroying a Session </h2>
+<p>To clear the current session: </p>
+<code>$this-&gt;session-&gt;sess_destroy();</code>
+<p class="important"><strong>Note:</strong> This function should be the last one called, and even flash variables will no longer be available.  If you only want some items destroyed and not all, use <dfn>unset_userdata()</dfn>.</p>
+
+
+
+<h2>Session Preferences</h2>
+<p>You'll find the following Session related preferences in your <kbd>application/config/config.php</kbd> file:</p>
+
+
+<table cellpadding="0" cellspacing="1" border="0" style="width:100%" class="tableborder">
+<tr>
+       <th>Preference</th>
+       <th>Default</th>
+       <th>Options</th>
+       <th>Description</th>
+</tr>
+<tr>
+       <td class="td"><strong>sess_cookie_name</strong></td>
+       <td class="td">ci_session</td>
+       <td class="td">None</td>
+       <td class="td">The name you want the session cookie saved as.</td>
+</tr>
+<tr>
+       <td class="td"><strong>sess_expiration</strong></td>
+       <td class="td">7200</td>
+       <td class="td">None</td>
+       <td class="td">The number of seconds you would like the session to last. The default value is 2 hours (7200 seconds). If you would like a non-expiring session set the value to zero: 0</td>
+</tr>
+<tr>
+       <td class="td"><strong>sess_expire_on_close</strong></td>
+       <td class="td">FALSE</td>
+       <td class="td">TRUE/FALSE (boolean)</td>
+       <td class="td">Whether to cause the session to expire automatically when the browser window is closed.</td>
+</tr>
+<tr>
+       <td class="td"><strong>sess_encrypt_cookie</strong></td>
+       <td class="td">FALSE</td>
+       <td class="td">TRUE/FALSE (boolean)</td>
+       <td class="td">Whether to encrypt the session data.</td>
+</tr>
+<tr>
+       <td class="td"><strong>sess_use_database</strong></td>
+       <td class="td">FALSE</td>
+       <td class="td">TRUE/FALSE (boolean)</td>
+       <td class="td">Whether to save the session data to a database.  You must create the table before enabling this option.</td>
+</tr>
+<tr>
+       <td class="td"><strong>sess_table_name</strong></td>
+       <td class="td">ci_sessions</td>
+       <td class="td">Any valid SQL table name</td>
+       <td class="td">The name of the session database table.</td>
+</tr>
+<tr>
+       <td class="td"><strong>sess_time_to_update</strong></td>
+       <td class="td">300</td>
+       <td class="td">Time in seconds</td>
+       <td class="td">This options controls how often the session class will regenerate itself and create a new session id.</td>
+</tr>
+<tr>
+       <td class="td"><strong>sess_match_ip</strong></td>
+       <td class="td">FALSE</td>
+       <td class="td">TRUE/FALSE (boolean)</td>
+       <td class="td">Whether to match the user's IP address when reading the session data.  Note that some ISPs dynamically
+       changes the IP, so if you want a non-expiring session you will likely set this to FALSE.</td>
+</tr>
+<tr>
+       <td class="td"><strong>sess_match_useragent</strong></td>
+       <td class="td">TRUE</td>
+       <td class="td">TRUE/FALSE (boolean)</td>
+       <td class="td">Whether to match the User Agent when reading the session data.</td>
+</tr>
+</table>
+
+
+</div>
+<!-- END CONTENT -->
+
+
+<div id="footer">
+<p>
+Previous Topic:&nbsp;&nbsp;<a href="security.html">Security Class</a>
+&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+<a href="#top">Top of Page</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+<a href="../index.html">User Guide Home</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+Next Topic:&nbsp;&nbsp;<a href="trackback.html">Trackback Class</a>
+</p>
+<p><a href="http://codeigniter.com">CodeIgniter</a> &nbsp;&middot;&nbsp; Copyright &#169; 2006 - 2011 &nbsp;&middot;&nbsp; <a href="http://ellislab.com/">EllisLab, Inc.</a></p>
+</div>
+
+</body>
+</html>
\ No newline at end of file
diff --git a/user_guide/libraries/table.html b/user_guide/libraries/table.html
new file mode 100755 (executable)
index 0000000..eeb3b42
--- /dev/null
@@ -0,0 +1,315 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head>
+
+<title>CodeIgniter User Guide : HTML Table Class</title>
+
+<link rel='stylesheet' type='text/css' media='all' href='../userguide.css' />
+
+<script type="text/javascript" src="../nav/nav.js"></script>
+<script type="text/javascript" src="../nav/prototype.lite.js"></script>
+<script type="text/javascript" src="../nav/moo.fx.js"></script>
+<script type="text/javascript" src="../nav/user_guide_menu.js"></script>
+
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+<meta http-equiv='expires' content='-1' />
+<meta http-equiv= 'pragma' content='no-cache' />
+<meta name='robots' content='all' />
+<meta name='author' content='ExpressionEngine Dev Team' />
+<meta name='description' content='CodeIgniter User Guide' />
+
+</head>
+<body>
+
+<!-- START NAVIGATION -->
+<div id="nav"><div id="nav_inner"><script type="text/javascript">create_menu('../');</script></div></div>
+<div id="nav2"><a name="top"></a><a href="javascript:void(0);" onclick="myHeight.toggle();"><img src="../images/nav_toggle_darker.jpg" width="153" height="44" border="0" title="Toggle Table of Contents" alt="Toggle Table of Contents" /></a></div>
+<div id="masthead">
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td><h1>CodeIgniter User Guide Version 2.0.2</h1></td>
+<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
+</tr>
+</table>
+</div>
+<!-- END NAVIGATION -->
+
+
+<!-- START BREADCRUMB -->
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td id="breadcrumb">
+<a href="http://codeigniter.com/">CodeIgniter Home</a> &nbsp;&#8250;&nbsp;
+<a href="../index.html">User Guide Home</a> &nbsp;&#8250;&nbsp;
+HTML Table Class
+</td>
+<td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="codeigniter.com/user_guide/" />Search User Guide&nbsp; <input type="text" class="input" style="width:200px;" name="q" id="q" size="31" maxlength="255" value="" />&nbsp;<input type="submit" class="submit" name="sa" value="Go" /></form></td>
+</tr>
+</table>
+<!-- END BREADCRUMB -->
+
+<br clear="all" />
+
+
+<!-- START CONTENT -->
+<div id="content">
+
+
+<h1>HTML Table Class</h1>
+
+<p>The Table Class provides functions that enable you to auto-generate HTML tables from arrays or database result sets.</p>
+
+<h2>Initializing the Class</h2>
+
+<p>Like most other classes in CodeIgniter, the Table class is initialized in your controller using the <dfn>$this->load->library</dfn> function:</p>
+
+<code>$this->load->library('table');</code>
+<p>Once loaded, the Table library object will be available using: <dfn>$this->table</dfn></p>
+
+
+<h2>Examples</h2>
+
+<p>Here is an example showing how you can create a table from a multi-dimensional array.
+Note that the first array index will become the table heading (or you can set your own headings using the
+<dfn>set_heading()</dfn> function described in the function reference below).</p>
+
+<code>
+$this->load->library('table');<br />
+<br />
+$data = array(<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;array('Name', 'Color', 'Size'),<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;array('Fred', 'Blue', 'Small'),<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;array('Mary', 'Red', 'Large'),<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;array('John', 'Green', 'Medium') <br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;);<br />
+<br />
+echo $this->table->generate($data);
+</code>
+
+<p>Here is an example of a table created from a database query result. The table class will automatically generate the
+headings based on the table names (or you can set your own headings using the <dfn>set_heading()</dfn> function described
+in the function reference below).</p>
+
+<code>
+$this->load->library('table');<br />
+<br />
+$query = $this->db->query("SELECT * FROM my_table");<br />
+<br />
+echo $this->table->generate($query);
+</code>
+
+
+<p>Here is an example showing how you might create a table using discrete parameters:</p>
+
+<code>
+$this->load->library('table');<br />
+<br />
+$this->table->set_heading('Name', 'Color', 'Size');<br />
+<br />
+$this->table->add_row('Fred', 'Blue', 'Small');<br />
+$this->table->add_row('Mary', 'Red', 'Large');<br />
+$this->table->add_row('John', 'Green', 'Medium');<br />
+<br />
+echo $this->table->generate();
+</code>
+
+<p>Here is the same example, except instead of individual parameters, arrays are used:</p>
+
+<code>
+$this->load->library('table');<br />
+<br />
+$this->table->set_heading(array('Name', 'Color', 'Size'));<br />
+<br />
+$this->table->add_row(array('Fred', 'Blue', 'Small'));<br />
+$this->table->add_row(array('Mary', 'Red', 'Large'));<br />
+$this->table->add_row(array('John', 'Green', 'Medium'));<br />
+<br />
+echo $this->table->generate();
+</code>
+
+
+<h2>Changing the Look of Your Table</h2>
+
+<p>The Table Class permits you to set a table template with which you can specify the design of your layout.  Here is the template
+prototype:</p>
+
+<code>
+$tmpl =  array (<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'table_open'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=> '&lt;table border="0" cellpadding="4" cellspacing="0">',<br />
+<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'heading_row_start'&nbsp;&nbsp;&nbsp;=> '&lt;tr>',<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'heading_row_end'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=> '&lt;/tr>',<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'heading_cell_start'&nbsp;&nbsp;=> '&lt;th>',<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'heading_cell_end'&nbsp;&nbsp;&nbsp;&nbsp;=> '&lt;/th>',<br />
+<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'row_start'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=> '&lt;tr>',<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'row_end'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=> '&lt;/tr>',<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'cell_start'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=> '&lt;td>',<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'cell_end'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=> '&lt;/td>',<br />
+<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'row_alt_start'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=> '&lt;tr>',<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'row_alt_end'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=> '&lt;/tr>',<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'cell_alt_start'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=> '&lt;td>',<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'cell_alt_end'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=> '&lt;/td>',<br />
+<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'table_close'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=> '&lt;/table>'<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;);<br />
+
+<br />
+$this->table->set_template($tmpl);
+</code>
+
+<p class="important"><strong>Note:</strong>&nbsp; You'll notice there are two sets of "row" blocks in the template.  These permit you to create alternating row colors or design elements that alternate with each
+iteration of the row data.</p>
+
+<p>You are NOT required to submit a complete template.  If you only need to change parts of the layout you can simply submit those elements.
+In this example, only the table opening tag is being changed:</p>
+
+<code>
+$tmpl =  array ( 'table_open'&nbsp;&nbsp;=> '&lt;table border="1" cellpadding="2" cellspacing="1" class="mytable">' );<br />
+
+<br />
+$this->table->set_template($tmpl);
+</code>
+
+<br />
+<h1>Function Reference</h1>
+
+<h2>$this->table->generate()</h2>
+<p>Returns a string containing the generated table.  Accepts an optional parameter which can be an array or a database result object.</p>
+
+<h2>$this->table->set_caption()</h2>
+
+<p>Permits you to add a caption to the table.</p>
+
+<code>$this->table->set_caption('Colors');</code>
+
+<h2>$this->table->set_heading()</h2>
+
+<p>Permits you to set the table heading.  You can submit an array or discrete params:</p>
+
+<code>$this->table->set_heading('Name', 'Color', 'Size');</code>
+<code>$this->table->set_heading(array('Name', 'Color', 'Size'));</code>
+
+<h2>$this->table->add_row()</h2>
+
+<p>Permits you to add a row to your table.  You can submit an array or discrete params:</p>
+
+<code>$this->table->add_row('Blue', 'Red', 'Green');</code>
+<code>$this->table->add_row(array('Blue', 'Red', 'Green'));</code>
+
+<p>If you would like to set an individual cell's tag attributes, you can use an associative array for that cell.  The associative key <dfn>'data'</dfn> defines the cell's data.  Any other key =&gt; val pairs are added as <dfn>key='val'</dfn> attributes to the tag:</p>
+
+<code>$cell = array('data' => 'Blue', 'class' => 'highlight', 'colspan' => 2);<br />
+$this->table->add_row($cell, 'Red', 'Green');<br />
+<br />
+// generates<br />
+// &lt;td class='highlight' colspan='2'&gt;Blue&lt;/td&gt;&lt;td&gt;Red&lt;/td&gt;&lt;td&gt;Green&lt;/td&gt;
+</code>
+
+<h2>$this->table->make_columns()</h2>
+
+<p>This function takes a one-dimensional array as input and creates
+a multi-dimensional array with a depth equal to the number of
+columns desired.  This allows a single array with many elements to  be
+displayed in a table that has a fixed column count.  Consider this example:</p>
+
+<code>
+$list = array('one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten', 'eleven', 'twelve');<br />
+<br />
+$new_list = $this->table->make_columns($list, 3);<br />
+<br />
+$this->table->generate($new_list);<br />
+<br />
+// Generates a table with this prototype<br />
+<br />
+&lt;table border="0" cellpadding="4" cellspacing="0"&gt;<br />
+&lt;tr&gt;<br />
+&lt;td&gt;one&lt;/td&gt;&lt;td&gt;two&lt;/td&gt;&lt;td&gt;three&lt;/td&gt;<br />
+&lt;/tr&gt;&lt;tr&gt;<br />
+&lt;td&gt;four&lt;/td&gt;&lt;td&gt;five&lt;/td&gt;&lt;td&gt;six&lt;/td&gt;<br />
+&lt;/tr&gt;&lt;tr&gt;<br />
+&lt;td&gt;seven&lt;/td&gt;&lt;td&gt;eight&lt;/td&gt;&lt;td&gt;nine&lt;/td&gt;<br />
+&lt;/tr&gt;&lt;tr&gt;<br />
+&lt;td&gt;ten&lt;/td&gt;&lt;td&gt;eleven&lt;/td&gt;&lt;td&gt;twelve&lt;/td&gt;&lt;/tr&gt;<br />
+&lt;/table&gt;</code>
+
+
+
+<h2>$this->table->set_template()</h2>
+
+<p>Permits you to set your template. You can submit a full or partial template.</p>
+
+<code>
+$tmpl =  array ( 'table_open'&nbsp;&nbsp;=> '&lt;table border="1" cellpadding="2" cellspacing="1" class="mytable">' );<br />
+
+<br />
+$this->table->set_template($tmpl);
+</code>
+
+
+<h2>$this->table->set_empty()</h2>
+
+<p>Let's you set a default value for use in any table cells that are empty.  You might, for example, set a non-breaking space:</p>
+
+<code>
+$this->table->set_empty("&amp;nbsp;");
+</code>
+
+<h2>$this->table->clear()</h2>
+
+<p>Lets you clear the table heading and row data.  If you need to show multiple tables with different data you should
+to call this function after each table has been generated to empty the previous table information. Example:</p>
+
+<code>
+$this->load->library('table');<br />
+<br />
+$this->table->set_heading('Name', 'Color', 'Size');<br />
+$this->table->add_row('Fred', 'Blue', 'Small');<br />
+$this->table->add_row('Mary', 'Red', 'Large');<br />
+$this->table->add_row('John', 'Green', 'Medium');<br />
+<br />
+echo $this->table->generate();<br />
+<br />
+<kbd>$this->table->clear();</kbd><br />
+<br />
+$this->table->set_heading('Name', 'Day', 'Delivery');<br />
+$this->table->add_row('Fred', 'Wednesday', 'Express');<br />
+$this->table->add_row('Mary', 'Monday', 'Air');<br />
+$this->table->add_row('John', 'Saturday', 'Overnight');<br />
+<br />
+echo $this->table->generate();
+</code>
+
+<h2>$this->table->function</h2>
+
+<p>Allows you to specify a native PHP function or a valid function array object to be applied to all cell data.</p>
+
+<code>$this->load->library('table');<br />
+<br />
+$this->table->set_heading('Name', 'Color', 'Size');<br />
+$this->table->add_row('Fred', '&lt;strong&gt;Blue&lt;/strong&gt;', 'Small');<br />
+<br />
+$this->table->function = 'htmlspecialchars';<br />
+echo $this->table->generate();<br />
+</code>
+
+<p>In the above example, all cell data would be ran through PHP's <dfn>htmlspecialchars()</dfn> function, resulting in:</p>
+
+<code>&lt;td&gt;Fred&lt;/td&gt;&lt;td&gt;&amp;lt;strong&amp;gt;Blue&amp;lt;/strong&amp;gt;&lt;/td&gt;&lt;td&gt;Small&lt;/td&gt;</code>
+</div>
+<!-- END CONTENT -->
+
+
+<div id="footer">
+<p>
+Previous Topic:&nbsp;<a href="ftp.html">&nbsp;FTP Class</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+<a href="#top">Top of Page</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+<a href="../index.html">User Guide Home</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+Next Topic:&nbsp;&nbsp;<a href="image_lib.html">Image Manipulation Class</a>
+</p>
+<p><a href="http://codeigniter.com">CodeIgniter</a> &nbsp;&middot;&nbsp; Copyright &#169; 2006 - 2011 &nbsp;&middot;&nbsp; <a href="http://ellislab.com/">EllisLab, Inc.</a></p>
+</div>
+
+</body>
+</html>
\ No newline at end of file
diff --git a/user_guide/libraries/trackback.html b/user_guide/libraries/trackback.html
new file mode 100755 (executable)
index 0000000..7f89b4f
--- /dev/null
@@ -0,0 +1,246 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head>
+
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+<title>Trackback Class : CodeIgniter User Guide</title>
+
+<style type='text/css' media='all'>@import url('../userguide.css');</style>
+<link rel='stylesheet' type='text/css' media='all' href='../userguide.css' />
+
+<script type="text/javascript" src="../nav/nav.js"></script>
+<script type="text/javascript" src="../nav/prototype.lite.js"></script>
+<script type="text/javascript" src="../nav/moo.fx.js"></script>
+<script type="text/javascript" src="../nav/user_guide_menu.js"></script>
+
+<meta http-equiv='expires' content='-1' />
+<meta http-equiv= 'pragma' content='no-cache' />
+<meta name='robots' content='all' />
+<meta name='author' content='ExpressionEngine Dev Team' />
+<meta name='description' content='CodeIgniter User Guide' />
+
+</head>
+<body>
+
+<!-- START NAVIGATION -->
+<div id="nav"><div id="nav_inner"><script type="text/javascript">create_menu('../');</script></div></div>
+<div id="nav2"><a name="top"></a><a href="javascript:void(0);" onclick="myHeight.toggle();"><img src="../images/nav_toggle_darker.jpg" width="154" height="43" border="0" title="Toggle Table of Contents" alt="Toggle Table of Contents" /></a></div>
+<div id="masthead">
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td><h1>CodeIgniter User Guide Version 2.0.2</h1></td>
+<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
+</tr>
+</table>
+</div>
+<!-- END NAVIGATION -->
+
+
+<!-- START BREADCRUMB -->
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td id="breadcrumb">
+<a href="http://codeigniter.com/">CodeIgniter Home</a> &nbsp;&#8250;&nbsp;
+<a href="../index.html">User Guide Home</a> &nbsp;&#8250;&nbsp;
+Trackback Class
+</td>
+<td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="codeigniter.com/user_guide/" />Search User Guide&nbsp; <input type="text" class="input" style="width:200px;" name="q" id="q" size="31" maxlength="255" value="" />&nbsp;<input type="submit" class="submit" name="sa" value="Go" /></form></td>
+</tr>
+</table>
+<!-- END BREADCRUMB -->
+
+<br clear="all" />
+
+
+<!-- START CONTENT -->
+<div id="content">
+
+
+<h1>Trackback Class</h1>
+
+<p>The Trackback Class provides functions that enable you to send and receive Trackback data.</p>
+
+
+<p>If you are not familiar with Trackbacks you'll find more information <a href="http://en.wikipedia.org/wiki/Trackback">here</a>.</p>
+
+<h2>Initializing the Class</h2>
+
+<p>Like most other classes in CodeIgniter, the Trackback class is initialized in your controller using the <dfn>$this->load->library</dfn> function:</p>
+
+<code>$this->load->library('trackback');</code>
+<p>Once loaded, the Trackback library object will be available using: <dfn>$this->trackback</dfn></p>
+
+
+<h2>Sending Trackbacks</h2>
+
+<p>A Trackback can be sent from any of your controller functions using code similar to this example:</p>
+
+<code>$this->load->library('trackback');<br />
+<br />
+$tb_data = array(<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'ping_url'&nbsp;&nbsp;=> 'http://example.com/trackback/456',<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'url'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=> 'http://www.my-example.com/blog/entry/123',<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'title'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=> 'The Title of My Entry',<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'excerpt'&nbsp;&nbsp;&nbsp;=> 'The entry content.',<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'blog_name' => 'My Blog Name',<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'charset'&nbsp;&nbsp;&nbsp;=> 'utf-8'<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;);<br />
+<br />
+if ( ! $this->trackback->send($tb_data))<br />
+{<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;echo $this->trackback->display_errors();<br />
+}<br />
+else<br />
+{<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;echo 'Trackback was sent!';<br />
+}</code>
+
+<p>Description of array data:</p>
+
+<ul>
+<li><strong>ping_url</strong> - The URL of the site you are sending the Trackback to. You can send Trackbacks to multiple URLs by separating each URL with a comma.</li>
+<li><strong>url</strong> - The URL to YOUR site where the weblog entry can be seen.</li>
+<li><strong>title</strong> - The title of your weblog entry.</li>
+<li><strong>excerpt</strong> - The content of your weblog entry. Note: the Trackback class will automatically send only the first 500 characters of your entry.  It will also strip all HTML.</li>
+<li><strong>blog_name</strong> - The name of your weblog.</li>
+<li><strong>charset</strong> - The character encoding your weblog is written in.  If omitted, UTF-8 will be used.</li>
+</ul>
+
+<p>The Trackback sending function returns TRUE/FALSE (boolean) on success or failure.  If it fails, you can retrieve the error message using:</p>
+
+<code>$this->trackback->display_errors();</code>
+
+
+<h2>Receiving Trackbacks</h2>
+
+<p>Before you can receive Trackbacks you must create a weblog.  If you don't have a blog yet there's no point in continuing.</p>
+
+<p>Receiving Trackbacks is a little more complex than sending them, only because you will need a database table in which to store them,
+and you will need to validate the incoming trackback data.  You are encouraged to implement a thorough validation process to
+guard against spam and duplicate data.  You may also want to limit the number of Trackbacks you allow from a particular IP within
+a given span of time to further curtail spam.  The process of receiving a Trackback is quite simple;
+the validation is what takes most of the effort.</p>
+
+<h2>Your Ping URL</h2>
+
+<p>In order to accept Trackbacks you must display a Trackback URL next to each one of your weblog entries.  This will be the URL
+that people will use to send you Trackbacks (we will refer to this as your "Ping URL").</p>
+
+<p>Your Ping URL must point to a controller function where your Trackback receiving code is located, and the URL
+must contain the ID number for each particular entry, so that when the Trackback is received you'll be
+able to associate it with a particular entry.</p>
+
+<p>For example, if your controller class is called <dfn>Trackback</dfn>, and the receiving function is called <dfn>receive</dfn>, your
+Ping URLs will look something like this:</p>
+
+<code>http://example.com/index.php/trackback/receive/<samp>entry_id</samp></code>
+
+<p>Where <samp>entry_id</samp> represents the individual ID number for each of your entries.</p>
+
+
+<h2>Creating a Trackback Table</h2>
+
+<p>Before you can receive Trackbacks you must create a table in which to store them.  Here is a basic prototype for such a table:</p>
+
+<textarea class="textarea" style="width:100%" cols="50" rows="13">
+CREATE TABLE trackbacks (
+ tb_id int(10) unsigned NOT NULL auto_increment,
+ entry_id int(10) unsigned NOT NULL default 0,
+ url varchar(200) NOT NULL,
+ title varchar(100) NOT NULL,
+ excerpt text NOT NULL,
+ blog_name varchar(100) NOT NULL,
+ tb_date int(10) NOT NULL,
+ ip_address varchar(16) NOT NULL,
+ PRIMARY KEY `tb_id` (`tb_id`),
+ KEY `entry_id` (`entry_id`)
+);</textarea>
+
+
+<p>The Trackback specification only requires four pieces of information to be sent in a Trackback (url, title, excerpt, blog_name),
+but to make the data more useful we've added a few more fields in the above table schema (date, IP address, etc.).</p>
+
+<h2>Processing a Trackback</h2>
+
+<p>Here is an example showing how you will receive and process a Trackback.  The following
+code is intended for use within the controller function where you expect to receive Trackbacks.</p>
+
+<code>$this->load->library('trackback');<br />
+$this->load->database();<br />
+<br />
+if ($this->uri->segment(3) == FALSE)<br />
+{<br />
+&nbsp;&nbsp;&nbsp;&nbsp;$this->trackback->send_error("Unable to determine the entry ID");<br />
+}<br />
+<br />
+if ( ! $this->trackback->receive())<br />
+{<br />
+&nbsp;&nbsp;&nbsp;&nbsp;$this->trackback->send_error("The Trackback did not contain valid data");<br />
+}<br />
+<br />
+$data = array(<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'tb_id'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=> '',<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'entry_id'&nbsp;&nbsp;&nbsp;=> $this->uri->segment(3),<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'url'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=> $this->trackback->data('url'),<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'title'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=> $this->trackback->data('title'),<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'excerpt'&nbsp;&nbsp;&nbsp;&nbsp;=> $this->trackback->data('excerpt'),<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'blog_name'&nbsp;&nbsp;=> $this->trackback->data('blog_name'),<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'tb_date'&nbsp;&nbsp;&nbsp;&nbsp;=> time(),<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'ip_address' => $this->input->ip_address()<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;);<br />
+<br />
+$sql = $this->db->insert_string('trackbacks', $data);<br />
+$this->db->query($sql);<br />
+<br />
+$this->trackback->send_success();</code>
+
+<h4>Notes:</h4>
+
+<p>The entry ID number is expected in the third segment of your URL.  This is based on the URI example we gave earlier:</p>
+
+<code>http://example.com/index.php/trackback/receive/<samp>entry_id</samp></code>
+
+<p>Notice the entry_id is in the third URI segment, which you can retrieve using:</p>
+
+<code>$this->uri->segment(3);</code>
+
+<p>In our Trackback receiving code above, if the third segment is missing, we will issue an error.  Without a valid entry ID, there's no
+reason to continue.</p>
+
+<p>The <dfn>$this->trackback->receive()</dfn> function is simply a validation function that looks at the incoming data
+and makes sure it contains the four pieces of data that are required (url, title, excerpt, blog_name).
+It returns TRUE on success and FALSE on failure.  If it fails you will issue an error message.</p>
+
+<p>The incoming Trackback data can be retrieved using this function:</p>
+
+<code>$this->trackback->data('<var>item</var>')</code>
+
+<p>Where <var>item</var> represents one of these four pieces of info: url, title, excerpt, or blog_name</p>
+
+<p>If the Trackback data is successfully received, you will issue a success message using:</p>
+
+<code>$this->trackback->send_success();</code>
+
+<p class="important"><strong>Note:</strong> The above code contains no data validation, which you are encouraged to add.</p>
+
+
+
+
+
+</div>
+<!-- END CONTENT -->
+
+
+<div id="footer">
+<p>
+Previous Topic:&nbsp;&nbsp;<a href="sessions.html">Session Class</a>
+&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+<a href="#top">Top of Page</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+<a href="../index.html">User Guide Home</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+Next Topic:&nbsp;&nbsp;<a href="parser.html">Template Parser Class</a>
+</p>
+<p><a href="http://codeigniter.com">CodeIgniter</a> &nbsp;&middot;&nbsp; Copyright &#169; 2006 - 2011 &nbsp;&middot;&nbsp; <a href="http://ellislab.com/">EllisLab, Inc.</a></p>
+</div>
+
+</body>
+</html>
\ No newline at end of file
diff --git a/user_guide/libraries/typography.html b/user_guide/libraries/typography.html
new file mode 100755 (executable)
index 0000000..895e76f
--- /dev/null
@@ -0,0 +1,160 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head>
+
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+<title>Typography Class : CodeIgniter User Guide</title>
+
+<style type='text/css' media='all'>@import url('../userguide.css');</style>
+<link rel='stylesheet' type='text/css' media='all' href='../userguide.css' />
+
+<script type="text/javascript" src="../nav/nav.js"></script>
+<script type="text/javascript" src="../nav/prototype.lite.js"></script>
+<script type="text/javascript" src="../nav/moo.fx.js"></script>
+<script type="text/javascript" src="../nav/user_guide_menu.js"></script>
+
+<meta http-equiv='expires' content='-1' />
+<meta http-equiv= 'pragma' content='no-cache' />
+<meta name='robots' content='all' />
+<meta name='author' content='ExpressionEngine Dev Team' />
+<meta name='description' content='CodeIgniter User Guide' />
+
+</head>
+<body>
+
+<!-- START NAVIGATION -->
+<div id="nav"><div id="nav_inner"><script type="text/javascript">create_menu('../');</script></div></div>
+<div id="nav2"><a name="top"></a><a href="javascript:void(0);" onclick="myHeight.toggle();"><img src="../images/nav_toggle_darker.jpg" width="154" height="43" border="0" title="Toggle Table of Contents" alt="Toggle Table of Contents" /></a></div>
+<div id="masthead">
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td><h1>CodeIgniter User Guide Version 2.0.2</h1></td>
+<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
+</tr>
+</table>
+</div>
+<!-- END NAVIGATION -->
+
+
+<!-- START BREADCRUMB -->
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td id="breadcrumb">
+<a href="http://codeigniter.com/">CodeIgniter Home</a> &nbsp;&#8250;&nbsp;
+<a href="../index.html">User Guide Home</a> &nbsp;&#8250;&nbsp;
+Typography Class
+</td>
+<td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="codeigniter.com/user_guide/" />Search User Guide&nbsp; <input type="text" class="input" style="width:200px;" name="q" id="q" size="31" maxlength="255" value="" />&nbsp;<input type="submit" class="submit" name="sa" value="Go" /></form></td>
+</tr>
+</table>
+<!-- END BREADCRUMB -->
+
+<br clear="all" />
+
+
+<!-- START CONTENT -->
+<div id="content">
+
+
+<h1>Typography Class</h1>
+
+<p>The Typography Class provides functions that help you format text.</p>
+
+
+<h2>Initializing the Class</h2>
+
+<p>Like most other classes in CodeIgniter, the Typography class is initialized in your controller using the <dfn>$this->load->library</dfn> function:</p>
+
+<code>$this->load->library('typography');</code>
+<p>Once loaded, the Typography library object will be available using: <dfn>$this->typography</dfn></p>
+
+
+<h2>auto_typography()</h2>
+
+<p>Formats text so that it is semantically and typographically correct HTML.  Takes a string as input and returns it with
+the following formatting:</p>
+
+<ul>
+<li>Surrounds paragraphs within &lt;p&gt;&lt;/p&gt; (looks for double line breaks to identify paragraphs).</li>
+<li>Single line breaks are converted to &lt;br /&gt;, except those that appear within &lt;pre&gt; tags.</li>
+<li>Block level elements, like &lt;div&gt; tags, are not wrapped within paragraphs, but their contained text is if it contains paragraphs.</li>
+<li>Quotes are converted to correctly facing curly quote entities, except those that appear within tags.</li>
+<li>Apostrophes are converted to curly apostrophe entities.</li>
+<li>Double dashes (either like -- this or like--this) are converted to em&#8212;dashes.</li>
+<li>Three consecutive periods either preceding or following a word are converted to ellipsis&#8230;</li>
+<li>Double spaces following sentences are converted to non-breaking spaces to mimic double spacing.</li>
+</ul>
+
+<p>Usage example:</p>
+
+<code>$string = $this->typography->auto_typography($string);</code>
+
+<h3>Parameters</h3>
+
+<p>There is one optional parameters that determines whether the parser should reduce more then two consecutive line breaks down to two. Use boolean <kbd>TRUE</kbd> or <kbd>FALSE</kbd>.</p>
+
+<p>By default the parser does not reduce line breaks. In other words, if no parameters are submitted, it is the same as doing this:</p>
+
+<code>$string = $this->typography->auto_typography($string, <kbd>FALSE</kbd>);</code>
+
+
+<p class="important"><strong>Note:</strong> Typographic formatting can be processor intensive, particularly if you have a lot of content being formatted.
+If you choose to use this function you may want to consider
+<a href="../general/caching.html">caching</a> your pages.</p>
+
+
+
+<h2>format_characters()</h2>
+
+<p>This function is similar to the <dfn>auto_typography</dfn> function above, except that it only does character conversion:</p>
+
+<ul>
+<li>Quotes are converted to correctly facing curly quote entities, except those that appear within tags.</li>
+<li>Apostrophes are converted to curly apostrophe entities.</li>
+<li>Double dashes (either like -- this or like--this) are converted to em&#8212;dashes.</li>
+<li>Three consecutive periods either preceding or following a word are converted to ellipsis&#8230;</li>
+<li>Double spaces following sentences are converted to non-breaking spaces to mimic double spacing.</li>
+</ul>
+
+<p>Usage example:</p>
+
+<code>$string = $this->typography->format_characters($string);</code>
+
+
+<h2>nl2br_except_pre()</h2>
+
+<p>Converts newlines to &lt;br /&gt; tags unless they appear within &lt;pre&gt; tags.
+This function is identical to the native PHP <dfn>nl2br()</dfn> function, except that it ignores &lt;pre&gt; tags.</p>
+
+<p>Usage example:</p>
+
+<code>$string = $this->typography->nl2br_except_pre($string);</code>
+
+<h2>protect_braced_quotes</h2>
+
+<p>When using the Typography library in conjunction with the Template Parser library it can often be desirable to protect single
+       and double quotes within curly braces.  To enable this, set the <kbd>protect_braced_quotes</kbd> class property to <samp>TRUE</samp>.</p>
+
+<p>Usage example:</p>
+
+<code>$this->load->library('typography');<br />
+$this->typography->protect_braced_quotes = TRUE;
+</code>
+
+</div>
+<!-- END CONTENT -->
+
+
+<div id="footer">
+<p>
+Previous Topic:&nbsp;&nbsp;<a href="parser.html">Template Parser</a>
+&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+<a href="#top">Top of Page</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+<a href="../index.html">User Guide Home</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+Next Topic:&nbsp;&nbsp;<a href="unit_testing.html">Unit Testing Class</a>
+</p>
+<p><a href="http://codeigniter.com">CodeIgniter</a> &nbsp;&middot;&nbsp; Copyright &#169; 2006 - 2011 &nbsp;&middot;&nbsp; <a href="http://ellislab.com/">EllisLab, Inc.</a></p>
+</div>
+
+</body>
+</html>
\ No newline at end of file
diff --git a/user_guide/libraries/unit_testing.html b/user_guide/libraries/unit_testing.html
new file mode 100755 (executable)
index 0000000..5e0c4c1
--- /dev/null
@@ -0,0 +1,226 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head>
+
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+<title>Unit Testing Class : CodeIgniter User Guide</title>
+
+<style type='text/css' media='all'>@import url('../userguide.css');</style>
+<link rel='stylesheet' type='text/css' media='all' href='../userguide.css' />
+
+<script type="text/javascript" src="../nav/nav.js"></script>
+<script type="text/javascript" src="../nav/prototype.lite.js"></script>
+<script type="text/javascript" src="../nav/moo.fx.js"></script>
+<script type="text/javascript" src="../nav/user_guide_menu.js"></script>
+
+<meta http-equiv='expires' content='-1' />
+<meta http-equiv= 'pragma' content='no-cache' />
+<meta name='robots' content='all' />
+<meta name='author' content='ExpressionEngine Dev Team' />
+<meta name='description' content='CodeIgniter User Guide' />
+
+</head>
+<body>
+
+<!-- START NAVIGATION -->
+<div id="nav"><div id="nav_inner"><script type="text/javascript">create_menu('../');</script></div></div>
+<div id="nav2"><a name="top"></a><a href="javascript:void(0);" onclick="myHeight.toggle();"><img src="../images/nav_toggle_darker.jpg" width="154" height="43" border="0" title="Toggle Table of Contents" alt="Toggle Table of Contents" /></a></div>
+<div id="masthead">
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td><h1>CodeIgniter User Guide Version 2.0.2</h1></td>
+<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
+</tr>
+</table>
+</div>
+<!-- END NAVIGATION -->
+
+
+<!-- START BREADCRUMB -->
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td id="breadcrumb">
+<a href="http://codeigniter.com/">CodeIgniter Home</a> &nbsp;&#8250;&nbsp;
+<a href="../index.html">User Guide Home</a> &nbsp;&#8250;&nbsp;
+Unit Testing Class
+</td>
+<td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="codeigniter.com/user_guide/" />Search User Guide&nbsp; <input type="text" class="input" style="width:200px;" name="q" id="q" size="31" maxlength="255" value="" />&nbsp;<input type="submit" class="submit" name="sa" value="Go" /></form></td>
+</tr>
+</table>
+<!-- END BREADCRUMB -->
+
+<br clear="all" />
+
+
+<!-- START CONTENT -->
+<div id="content">
+
+
+<h1>Unit Testing Class</h1>
+
+<p>Unit testing is an approach to software development in which tests are written for each function in your application.
+If you are not familiar with the concept you might do a little googling on the subject.</p>
+
+<p>CodeIgniter's Unit Test class is quite simple, consisting of an evaluation function and two result functions.
+It's not intended to be a full-blown test suite but rather a simple mechanism to evaluate your code
+to determine if it is producing the correct data type and result.
+</p>
+
+
+<h2>Initializing the Class</h2>
+
+<p>Like most other classes in CodeIgniter, the Unit Test class is initialized in your controller using the <dfn>$this->load->library</dfn> function:</p>
+
+<code>$this->load->library('unit_test');</code>
+<p>Once loaded, the Unit Test object will be available using: <dfn>$this->unit</dfn></p>
+
+
+<h2>Running Tests</h2>
+
+<p>Running a test involves supplying a test and an expected result to the following function:</p>
+
+<h2>$this->unit->run( <var>test</var>, <var>expected result</var>, '<var>test name</var>', '<var>notes</var>');</h2>
+
+<p>Where <var>test</var> is the result of the code you wish to test, <var>expected result</var> is the data type you expect,
+<var>test name</var> is an optional name you can give your test, and <var>notes</var> are optional notes. Example:</p>
+
+<code>$test = 1 + 1;<br />
+<br />
+$expected_result = 2;<br />
+<br />
+$test_name = 'Adds one plus one';<br />
+<br />
+$this->unit->run($test, $expected_result, $test_name);</code>
+
+<p>The expected result you supply can either be a literal match, or a data type match.  Here's an example of a literal:</p>
+
+<code>$this->unit->run('Foo', 'Foo');</code>
+
+<p>Here is an example of a data type match:</p>
+
+<code>$this->unit->run('Foo', 'is_string');</code>
+
+<p>Notice the use of "is_string" in the second parameter?  This tells the function to evaluate whether your test is producing a string
+as the result.  Here is a list of allowed comparison types:</p>
+
+<ul>
+<li>is_object</li>
+<li>is_string</li>
+<li>is_bool</li>
+<li>is_true</li>
+<li>is_false</li>
+<li>is_int</li>
+<li>is_numeric</li>
+<li>is_float</li>
+<li>is_double</li>
+<li>is_array</li>
+<li>is_null</li>
+</ul>
+
+
+<h2>Generating Reports</h2>
+
+<p>You can either display results after each test, or your can run several tests and generate a report at the end.
+To show a report directly simply echo or return the <var>run</var> function:</p>
+
+<code>echo $this->unit->run($test, $expected_result);</code>
+
+<p>To run a full report of all tests, use this:</p>
+
+<code>echo $this->unit->report();</code>
+
+<p>The report will be formatted in an HTML table for viewing.  If you prefer the raw data you can retrieve an array using:</p>
+
+<code>echo $this->unit->result();</code>
+
+
+<h2>Strict Mode</h2>
+
+<p>By default the unit test class evaluates literal matches loosely.  Consider this example:</p>
+
+<code>$this->unit->run(1, TRUE);</code>
+
+<p>The test is evaluating an integer, but the expected result is a boolean.  PHP, however, due to it's loose data-typing
+will evaluate the above code as TRUE using a normal equality test:</p>
+
+<code>if (1 == TRUE) echo 'This evaluates as true';</code>
+
+<p>If you prefer, you can put the unit test class in to strict mode, which will compare the data type as well as the value:</p>
+
+<code>if (1 === TRUE) echo 'This evaluates as FALSE';</code>
+
+<p>To enable strict mode use this:</p>
+
+<code>$this->unit->use_strict(TRUE);</code>
+
+<h2>Enabling/Disabling Unit Testing</h2>
+
+<p>If you would like to leave some testing in place in your scripts, but not have it run unless you need it, you can disable
+unit testing using:</p>
+
+<code>$this->unit->active(FALSE)</code>
+
+<h2>Unit Test Display</h2>
+
+<p>When your unit test results display, the following items show by default:</p>
+
+<ul>
+       <li>Test Name (test_name)</li>
+       <li>Test Datatype (test_datatype)</li>
+       <li>Expected Datatype (res_datatype)</li>
+       <li>Result (result)</li>
+       <li>File Name (file)</li>
+       <li>Line Number (line)</li>
+       <li>Any notes you entered for the test (notes)</li>
+</ul>
+
+You can customize which of these items get displayed by using <kbd>$this->unit->set_items()</kbd>. For example, if you only wanted the test name and the result displayed:</p>
+
+<h3>Customizing displayed tests</h3>
+
+<code>
+       $this->unit->set_test_items(array('test_name', 'result'));
+</code>
+
+<h3>Creating a Template</h3>
+
+<p>If you would like your test results formatted differently then the default you can set your own template.  Here is an
+example of a simple template.  Note the required pseudo-variables:</p>
+
+<code>
+$str = '<br />
+&lt;table border="0" cellpadding="4" cellspacing="1"><br />
+&nbsp;&nbsp;&nbsp;&nbsp;<kbd>{rows}</kbd><br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;tr><br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;td><kbd>{item}</kbd>&lt;/td><br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;td><kbd>{result}</kbd>&lt;/td><br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;/tr><br />
+&nbsp;&nbsp;&nbsp;&nbsp;<kbd>{/rows}</kbd><br />
+&lt;/table>';<br />
+<br />
+$this->unit->set_template($str);
+</code>
+
+<p class="important"><strong>Note:</strong> Your template must be declared <strong>before</strong> running the unit test process.</p>
+
+
+
+
+
+</div>
+<!-- END CONTENT -->
+
+
+<div id="footer">
+<p>
+Previous Topic:&nbsp;&nbsp;<a href="typography.html">Typography Class</a>
+&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+<a href="#top">Top of Page</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+<a href="../index.html">User Guide Home</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+Next Topic:&nbsp;&nbsp;<a href="uri.html">URI Class</a>
+</p>
+<p><a href="http://codeigniter.com">CodeIgniter</a> &nbsp;&middot;&nbsp; Copyright &#169; 2006 - 2011 &nbsp;&middot;&nbsp; <a href="http://ellislab.com/">EllisLab, Inc.</a></p>
+</div>
+
+</body>
+</html>
\ No newline at end of file
diff --git a/user_guide/libraries/uri.html b/user_guide/libraries/uri.html
new file mode 100755 (executable)
index 0000000..e4e0f9d
--- /dev/null
@@ -0,0 +1,252 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head>
+
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+<title>URI Class : CodeIgniter User Guide</title>
+
+<style type='text/css' media='all'>@import url('../userguide.css');</style>
+<link rel='stylesheet' type='text/css' media='all' href='../userguide.css' />
+
+<script type="text/javascript" src="../nav/nav.js"></script>
+<script type="text/javascript" src="../nav/prototype.lite.js"></script>
+<script type="text/javascript" src="../nav/moo.fx.js"></script>
+<script type="text/javascript" src="../nav/user_guide_menu.js"></script>
+
+<meta http-equiv='expires' content='-1' />
+<meta http-equiv= 'pragma' content='no-cache' />
+<meta name='robots' content='all' />
+<meta name='author' content='ExpressionEngine Dev Team' />
+<meta name='description' content='CodeIgniter User Guide' />
+
+</head>
+<body>
+
+<!-- START NAVIGATION -->
+<div id="nav"><div id="nav_inner"><script type="text/javascript">create_menu('../');</script></div></div>
+<div id="nav2"><a name="top"></a><a href="javascript:void(0);" onclick="myHeight.toggle();"><img src="../images/nav_toggle_darker.jpg" width="154" height="43" border="0" title="Toggle Table of Contents" alt="Toggle Table of Contents" /></a></div>
+<div id="masthead">
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td><h1>CodeIgniter User Guide Version 2.0.2</h1></td>
+<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
+</tr>
+</table>
+</div>
+<!-- END NAVIGATION -->
+
+
+<!-- START BREADCRUMB -->
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td id="breadcrumb">
+<a href="http://codeigniter.com/">CodeIgniter Home</a> &nbsp;&#8250;&nbsp;
+<a href="../index.html">User Guide Home</a> &nbsp;&#8250;&nbsp;
+URI Class
+</td>
+<td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="codeigniter.com/user_guide/" />Search User Guide&nbsp; <input type="text" class="input" style="width:200px;" name="q" id="q" size="31" maxlength="255" value="" />&nbsp;<input type="submit" class="submit" name="sa" value="Go" /></form></td>
+</tr>
+</table>
+<!-- END BREADCRUMB -->
+
+<br clear="all" />
+
+
+<!-- START CONTENT -->
+<div id="content">
+
+
+<h1>URI Class</h1>
+
+<p>The URI Class provides functions that help you retrieve information from your URI strings. If you use URI routing, you can
+also retrieve information about the re-routed segments.</p>
+
+<p class="important"><strong>Note:</strong> This class is initialized automatically by the system so there is no need to do it manually.</p>
+
+<h2>$this->uri->segment(<var>n</var>)</h2>
+
+<p>Permits you to retrieve a specific segment. Where <var>n</var> is the segment number you wish to retrieve.
+Segments are numbered from left to right. For example, if your full URL is this:</p>
+
+<code>http://example.com/index.php/news/local/metro/crime_is_up</code>
+
+<p>The segment numbers would be this:</p>
+
+<ol>
+<li>news</li>
+<li>local</li>
+<li>metro</li>
+<li>crime_is_up</li>
+</ol>
+
+<p>By default the function returns FALSE (boolean) if the segment does not exist. There is an optional second parameter that
+permits you to set your own default value if the segment is missing.
+For example, this would tell the function to return the number zero in the event of failure:</p>
+
+<code>$product_id = $this->uri->segment(3, 0);</code>
+
+<p>It helps avoid having to write code like this:</p>
+
+<code>if ($this->uri->segment(3) === FALSE)<br />
+{<br />
+&nbsp;&nbsp;&nbsp;&nbsp;$product_id = 0;<br />
+}<br />
+else<br />
+{<br />
+&nbsp;&nbsp;&nbsp;&nbsp;$product_id = $this->uri->segment(3);<br />
+}<br />
+</code>
+
+<h2>$this->uri->rsegment(<var>n</var>)</h2>
+
+<p>This function is identical to the previous one, except that it lets you retrieve a specific segment from your
+re-routed URI in the event you are using CodeIgniter's <a href="../general/routing.html">URI Routing</a> feature.</p>
+
+
+<h2>$this->uri->slash_segment(<var>n</var>)</h2>
+
+<p>This function is almost identical to <dfn>$this->uri->segment()</dfn>, except it adds a trailing and/or leading slash based on the second
+parameter.  If the parameter is not used, a trailing slash added.  Examples:</p>
+
+<code>$this->uri->slash_segment(<var>3</var>);<br />
+$this->uri->slash_segment(<var>3</var>, 'leading');<br />
+$this->uri->slash_segment(<var>3</var>, 'both');</code>
+
+<p>Returns:</p>
+
+<ol>
+<li>segment/</li>
+<li>/segment</li>
+<li>/segment/</li>
+</ol>
+
+
+<h2>$this->uri->slash_rsegment(<var>n</var>)</h2>
+
+<p>This function is identical to the previous one, except that it lets you add slashes a specific segment from your
+re-routed URI in the event you are using CodeIgniter's <a href="../general/routing.html">URI Routing</a> feature.</p>
+
+
+
+<h2>$this->uri->uri_to_assoc(<var>n</var>)</h2>
+
+<p>This function lets you turn URI segments into and associative array of key/value pairs.  Consider this URI:</p>
+
+<code>index.php/user/search/name/joe/location/UK/gender/male</code>
+
+<p>Using this function you can turn the URI into an associative array with this prototype:</p>
+
+<code>[array]<br />
+(<br />
+&nbsp;&nbsp;&nbsp;&nbsp;'name' => 'joe'<br />
+&nbsp;&nbsp;&nbsp;&nbsp;'location'     => 'UK'<br />
+&nbsp;&nbsp;&nbsp;&nbsp;'gender'       => 'male'<br />
+)</code>
+
+<p>The first parameter of the function lets you set an offset.  By default it is set to <kbd>3</kbd> since your
+URI will normally contain a controller/function in the first and second segments. Example:</p>
+
+<code>
+$array = $this->uri->uri_to_assoc(3);<br />
+<br />
+echo $array['name'];
+</code>
+
+
+<p>The second parameter lets you set default key names, so that the array returned by the function will always contain expected indexes, even if missing from the URI. Example:</p>
+
+<code>
+$default = array('name', 'gender', 'location', 'type', 'sort');<br />
+<br />
+$array = $this->uri->uri_to_assoc(3, $default);</code>
+
+<p>If the URI does not contain a value in your default, an array index will be set to that name, with a value of FALSE.</p>
+
+<p>Lastly, if a corresponding value is not found for a given key (if there is an odd number of URI segments) the value will be set to FALSE (boolean).</p>
+
+
+<h2>$this->uri->ruri_to_assoc(<var>n</var>)</h2>
+
+<p>This function is identical to the previous one, except that it creates an associative array using the
+re-routed URI in the event you are using CodeIgniter's <a href="../general/routing.html">URI Routing</a> feature.</p>
+
+
+<h2>$this->uri->assoc_to_uri()</h2>
+
+<p>Takes an associative array as input and generates a URI string from it.  The array keys will be included in the string.  Example:</p>
+
+<code>$array = array('product' => 'shoes', 'size' => 'large', 'color' => 'red');<br />
+<br />
+$str = $this->uri->assoc_to_uri($array);<br />
+<br />
+// Produces:  product/shoes/size/large/color/red
+</code>
+
+
+<h2>$this->uri->uri_string()</h2>
+
+<p>Returns a string with the complete URI.  For example, if this is your full URL:</p>
+
+<code>http://example.com/index.php/news/local/345</code>
+
+<p>The function would return this:</p>
+
+<code>/news/local/345</code>
+
+
+<h2>$this->uri->ruri_string()</h2>
+
+<p>This function is identical to the previous one, except that it returns the
+re-routed URI in the event you are using CodeIgniter's <a href="../general/routing.html">URI Routing</a> feature.</p>
+
+
+
+<h2>$this->uri->total_segments()</h2>
+
+<p>Returns the total number of segments.</p>
+
+
+<h2>$this->uri->total_rsegments()</h2>
+
+<p>This function is identical to the previous one, except that it returns the total number of segments in your
+re-routed URI in the event you are using CodeIgniter's <a href="../general/routing.html">URI Routing</a> feature.</p>
+
+
+
+<h2>$this->uri->segment_array()</h2>
+
+<p>Returns an array containing the URI segments.  For example:</p>
+
+<code>
+$segs = $this->uri->segment_array();<br />
+<br />
+foreach ($segs as $segment)<br />
+{<br />
+&nbsp;&nbsp;&nbsp;&nbsp;echo $segment;<br />
+&nbsp;&nbsp;&nbsp;&nbsp;echo '&lt;br />';<br />
+}</code>
+
+<h2>$this->uri->rsegment_array()</h2>
+
+<p>This function is identical to the previous one, except that it returns the array of segments in your
+re-routed URI in the event you are using CodeIgniter's <a href="../general/routing.html">URI Routing</a> feature.</p>
+
+
+
+</div>
+<!-- END CONTENT -->
+
+
+<div id="footer">
+<p>
+Previous Topic:&nbsp;&nbsp;<a href="unit_testing.html">Unit Testing Class</a>
+&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+<a href="#top">Top of Page</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+<a href="../index.html">User Guide Home</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+Next Topic:&nbsp;&nbsp;<a href="user_agent.html">User Agent Class</a>
+</p>
+<p><a href="http://codeigniter.com">CodeIgniter</a> &nbsp;&middot;&nbsp; Copyright &#169; 2006 - 2011 &nbsp;&middot;&nbsp; <a href="http://ellislab.com/">EllisLab, Inc.</a></p>
+</div>
+
+</body>
+</html>
\ No newline at end of file
diff --git a/user_guide/libraries/user_agent.html b/user_guide/libraries/user_agent.html
new file mode 100755 (executable)
index 0000000..24e8071
--- /dev/null
@@ -0,0 +1,226 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head>
+
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+<title>User Agent Class : CodeIgniter User Guide</title>
+
+<style type='text/css' media='all'>@import url('../userguide.css');</style>
+<link rel='stylesheet' type='text/css' media='all' href='../userguide.css' />
+
+<script type="text/javascript" src="../nav/nav.js"></script>
+<script type="text/javascript" src="../nav/prototype.lite.js"></script>
+<script type="text/javascript" src="../nav/moo.fx.js"></script>
+<script type="text/javascript" src="../nav/user_guide_menu.js"></script>
+
+<meta http-equiv='expires' content='-1' />
+<meta http-equiv= 'pragma' content='no-cache' />
+<meta name='robots' content='all' />
+<meta name='author' content='ExpressionEngine Dev Team' />
+<meta name='description' content='CodeIgniter User Guide' />
+
+</head>
+<body>
+
+<!-- START NAVIGATION -->
+<div id="nav"><div id="nav_inner"><script type="text/javascript">create_menu('../');</script></div></div>
+<div id="nav2"><a name="top"></a><a href="javascript:void(0);" onclick="myHeight.toggle();"><img src="../images/nav_toggle_darker.jpg" width="154" height="43" border="0" title="Toggle Table of Contents" alt="Toggle Table of Contents" /></a></div>
+<div id="masthead">
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td><h1>CodeIgniter User Guide Version 2.0.2</h1></td>
+<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
+</tr>
+</table>
+</div>
+<!-- END NAVIGATION -->
+
+
+<!-- START BREADCRUMB -->
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td id="breadcrumb">
+<a href="http://codeigniter.com/">CodeIgniter Home</a> &nbsp;&#8250;&nbsp;
+<a href="../index.html">User Guide Home</a> &nbsp;&#8250;&nbsp;
+User Agent Class
+</td>
+<td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="codeigniter.com/user_guide/" />Search User Guide&nbsp; <input type="text" class="input" style="width:200px;" name="q" id="q" size="31" maxlength="255" value="" />&nbsp;<input type="submit" class="submit" name="sa" value="Go" /></form></td>
+</tr>
+</table>
+<!-- END BREADCRUMB -->
+
+<br clear="all" />
+
+
+<!-- START CONTENT -->
+<div id="content">
+
+
+<h1>User Agent Class</h1>
+
+<p>The User Agent Class provides functions that help identify information about the browser, mobile device, or robot visiting your site.
+In addition you can get referrer information as well as language and supported character-set information.</p>
+
+<h2>Initializing the Class</h2>
+
+<p>Like most other classes in CodeIgniter, the User Agent class is initialized in your controller using the <dfn>$this->load->library</dfn> function:</p>
+
+<code>$this->load->library('user_agent');</code>
+<p>Once loaded, the object will be available using: <dfn>$this->agent</dfn></p>
+
+<h2>User Agent Definitions</h2>
+
+<p>The user agent name definitions are located in a config file located at: <dfn>application/config/user_agents.php</dfn>.  You may add items to the
+various user agent arrays if needed.</p>
+
+<h2>Example</h2>
+
+<p>When the User Agent class is initialized it will attempt to determine whether the user agent browsing your site is
+a web browser, a mobile device, or a robot.  It will also gather the platform information if it is available.</p>
+
+
+<code>
+$this->load->library('user_agent');<br />
+<br />
+if ($this->agent->is_browser())<br />
+{<br />
+&nbsp;&nbsp;&nbsp;&nbsp;$agent  = $this->agent->browser().' '.$this->agent->version();<br />
+}<br />
+elseif ($this->agent->is_robot())<br />
+{<br />
+&nbsp;&nbsp;&nbsp;&nbsp;$agent = $this->agent->robot();<br />
+}<br />
+elseif ($this->agent->is_mobile())<br />
+{<br />
+&nbsp;&nbsp;&nbsp;&nbsp;$agent = $this->agent->mobile();<br />
+}<br />
+else<br />
+{<br />
+&nbsp;&nbsp;&nbsp;&nbsp;$agent = 'Unidentified User Agent';<br />
+}<br />
+<br />
+echo $agent;<br />
+<br />
+echo $this->agent->platform(); // Platform info (Windows, Linux, Mac, etc.)
+</code>
+
+
+<h1>Function Reference</h1>
+
+
+<h2>$this->agent->is_browser()</h2>
+<p>Returns TRUE/FALSE (boolean) if the user agent is a known web browser.</p>
+
+<code> if ($this->agent->is_browser('Safari'))<br />
+{<br />
+&nbsp;&nbsp;&nbsp;&nbsp;echo 'You are using Safari.';<br />
+}<br />
+else if ($this->agent->is_browser())<br />
+{<br />
+&nbsp;&nbsp;&nbsp;&nbsp;echo 'You are using a browser.';<br />
+}</code>
+
+<p class="important"><strong>Note:</strong>&nbsp; The string "Safari" in this example is an array key in the list of browser definitions.
+You can find this list in <dfn>application/config/user_agents.php</dfn> if you want to add new browsers or change the stings.</p>
+
+<h2>$this->agent->is_mobile()</h2>
+<p>Returns TRUE/FALSE (boolean) if the user agent is a known mobile device.</p>
+
+<code> if ($this->agent->is_mobile('iphone'))<br />
+{<br />
+&nbsp;&nbsp;&nbsp;&nbsp;$this->load->view('iphone/home');<br />
+}<br />
+else if ($this->agent->is_mobile())<br />
+{<br />
+&nbsp;&nbsp;&nbsp;&nbsp;$this->load->view('mobile/home');<br />
+}<br/>
+else<br />
+{<br />
+&nbsp;&nbsp;&nbsp;&nbsp;$this->load->view('web/home');<br />
+}</code>
+
+<h2>$this->agent->is_robot()</h2>
+<p>Returns TRUE/FALSE (boolean) if the user agent is a known robot.</p>
+
+<p class="important"><strong>Note:</strong>&nbsp; The user agent library only contains the most common robot
+definitions.  It is not a complete list of bots. There are hundreds of them so searching for each one would not be
+very efficient. If you find that some bots that commonly visit your site are missing from the list you can add them to your
+<dfn>application/config/user_agents.php</dfn> file.</p>
+
+<h2>$this->agent->is_referral()</h2>
+<p>Returns TRUE/FALSE (boolean) if the user agent was referred from another site.</p>
+
+
+<h2>$this->agent->browser()</h2>
+<p>Returns a string containing the name of the web browser viewing your site.</p>
+
+<h2>$this->agent->version()</h2>
+<p>Returns a string containing the version number of the web browser viewing your site.</p>
+
+<h2>$this->agent->mobile()</h2>
+<p>Returns a string containing the name of the mobile device viewing your site.</p>
+
+<h2>$this->agent->robot()</h2>
+<p>Returns a string containing the name of the robot viewing your site.</p>
+
+<h2>$this->agent->platform()</h2>
+<p>Returns a string containing the platform viewing your site (Linux, Windows, OS X, etc.).</p>
+
+<h2>$this->agent->referrer()</h2>
+<p>The referrer, if the user agent was referred from another site. Typically you'll test for this as follows:</p>
+
+<code> if ($this->agent->is_referral())<br />
+{<br />
+&nbsp;&nbsp;&nbsp;&nbsp;echo $this->agent->referrer();<br />
+}</code>
+
+
+<h2>$this->agent->agent_string()</h2>
+<p>Returns a string containing the full user agent string.  Typically it will be something like this:</p>
+
+<code>Mozilla/5.0 (Macintosh; U; Intel Mac OS X; en-US; rv:1.8.0.4) Gecko/20060613 Camino/1.0.2</code>
+
+
+<h2>$this->agent->accept_lang()</h2>
+<p>Lets you determine if the user agent accepts a particular language. Example:</p>
+
+<code>if ($this->agent->accept_lang('en'))<br />
+{<br />
+&nbsp;&nbsp;&nbsp;&nbsp;echo 'You accept English!';<br />
+}</code>
+
+<p class="important"><strong>Note:</strong> This function is not typically very reliable
+since some browsers do not provide language info, and even among those that do, it is not always accurate. </p>
+
+
+
+<h2>$this->agent->accept_charset()</h2>
+<p>Lets you determine if the user agent accepts a particular character set. Example:</p>
+
+<code>if ($this->agent->accept_charset('utf-8'))<br />
+{<br />
+&nbsp;&nbsp;&nbsp;&nbsp;echo 'You browser supports UTF-8!';<br />
+}</code>
+
+<p class="important"><strong>Note:</strong> This function is not typically very reliable
+since some browsers do not provide character-set info, and even among those that do, it is not always accurate. </p>
+
+
+
+</div>
+<!-- END CONTENT -->
+
+
+<div id="footer">
+<p>
+Previous Topic:&nbsp;&nbsp;<a href="uri.html">URI Class</a>
+&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+<a href="#top">Top of Page</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+<a href="../index.html">User Guide Home</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+Next Topic:&nbsp;&nbsp;<a href="xmlrpc.html">XML-RPC Class</a>
+</p>
+<p><a href="http://codeigniter.com">CodeIgniter</a> &nbsp;&middot;&nbsp; Copyright &#169; 2006 - 2011 &nbsp;&middot;&nbsp; <a href="http://ellislab.com/">EllisLab, Inc.</a></p>
+</div>
+
+</body>
+</html>
\ No newline at end of file
diff --git a/user_guide/libraries/xmlrpc.html b/user_guide/libraries/xmlrpc.html
new file mode 100755 (executable)
index 0000000..5ba8513
--- /dev/null
@@ -0,0 +1,519 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head>
+
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+<title>XML-RPC and XML-RPC Server Classes : CodeIgniter User Guide</title>
+
+<style type='text/css' media='all'>@import url('../userguide.css');</style>
+<link rel='stylesheet' type='text/css' media='all' href='../userguide.css' />
+
+<script type="text/javascript" src="../nav/nav.js"></script>
+<script type="text/javascript" src="../nav/prototype.lite.js"></script>
+<script type="text/javascript" src="../nav/moo.fx.js"></script>
+<script type="text/javascript" src="../nav/user_guide_menu.js"></script>
+
+<meta http-equiv='expires' content='-1' />
+<meta http-equiv= 'pragma' content='no-cache' />
+<meta name='robots' content='all' />
+<meta name='author' content='ExpressionEngine Dev Team' />
+<meta name='description' content='CodeIgniter User Guide' />
+
+</head>
+<body>
+
+<!-- START NAVIGATION -->
+<div id="nav"><div id="nav_inner"><script type="text/javascript">create_menu('../');</script></div></div>
+<div id="nav2"><a name="top"></a><a href="javascript:void(0);" onclick="myHeight.toggle();"><img src="../images/nav_toggle_darker.jpg" width="154" height="43" border="0" title="Toggle Table of Contents" alt="Toggle Table of Contents" /></a></div>
+<div id="masthead">
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td><h1>CodeIgniter User Guide Version 2.0.2</h1></td>
+<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
+</tr>
+</table>
+</div>
+<!-- END NAVIGATION -->
+
+
+<!-- START BREADCRUMB -->
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td id="breadcrumb">
+<a href="http://codeigniter.com/">CodeIgniter Home</a> &nbsp;&#8250;&nbsp;
+<a href="../index.html">User Guide Home</a> &nbsp;&#8250;&nbsp;
+XML-RPC and XML-RPC Server Classes
+</td>
+<td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="codeigniter.com/user_guide/" />Search User Guide&nbsp; <input type="text" class="input" style="width:200px;" name="q" id="q" size="31" maxlength="255" value="" />&nbsp;<input type="submit" class="submit" name="sa" value="Go" /></form></td>
+</tr>
+</table>
+<!-- END BREADCRUMB -->
+
+<br clear="all" />
+
+
+<!-- START CONTENT -->
+<div id="content">
+
+
+<h1>XML-RPC and XML-RPC Server Classes</h1>
+
+
+<p>CodeIgniter's XML-RPC classes permit you to send requests to another server, or set up
+your own XML-RPC server to receive requests.</p>
+
+
+<h2>What is XML-RPC?</h2>
+
+<p>Quite simply it is a way for two computers to communicate over the internet using XML.
+One computer, which we will call the <dfn>client</dfn>, sends an XML-RPC <strong>request</strong> to
+another computer, which we will call the <dfn>server</dfn>.  Once the server receives and processes the request it
+will send back a <strong>response</strong> to the client.</p>
+
+<p>For example, using the MetaWeblog API, an XML-RPC Client (usually a desktop publishing tool) will
+send a request to an XML-RPC Server running on your site.  This request might be a new weblog entry
+being sent for publication, or it could be a request for an existing entry for editing.
+
+When the XML-RPC Server receives this request it will examine it to determine which class/method should be called to process the request.
+Once processed, the server will then send back a response message.</p>
+
+<p>For detailed specifications, you can visit the <a href="http://www.xmlrpc.com/">XML-RPC</a> site.</p>
+
+<h2>Initializing the Class</h2>
+
+<p>Like most other classes in CodeIgniter, the XML-RPC and XML-RPCS classes are initialized in your controller using the <dfn>$this->load->library</dfn> function:</p>
+
+<p>To load the XML-RPC class you will use:</p>
+<code>$this->load->library('xmlrpc');</code>
+<p>Once loaded, the xml-rpc library object will be available using: <dfn>$this->xmlrpc</dfn></p>
+
+<p>To load the XML-RPC Server class you will use:</p>
+<code>
+$this->load->library('xmlrpc');<br />
+$this->load->library('xmlrpcs');
+</code>
+<p>Once loaded, the xml-rpcs library object will be available using: <dfn>$this->xmlrpcs</dfn></p>
+
+<p class="important"><strong>Note:</strong>&nbsp; When using the XML-RPC Server class you must load BOTH the XML-RPC class and the XML-RPC Server class.</p>
+
+
+
+<h2>Sending XML-RPC Requests</h2>
+
+<p>To send a request to an XML-RPC server you must specify the following information:</p>
+
+<ul>
+<li>The URL of the server</li>
+<li>The method on the server you wish to call</li>
+<li>The <em>request</em> data (explained below).</li>
+</ul>
+
+<p>Here is a basic example that sends a simple Weblogs.com ping to the <a href="http://pingomatic.com/">Ping-o-Matic</a></p>
+
+
+<code>$this->load->library('xmlrpc');<br />
+<br />
+$this->xmlrpc->server('http://rpc.pingomatic.com/', 80);<br />
+$this->xmlrpc->method('weblogUpdates.ping');<br />
+
+<br />
+$request = array('My Photoblog', 'http://www.my-site.com/photoblog/');<br />
+$this->xmlrpc->request($request);<br />
+<br />
+if ( ! $this->xmlrpc->send_request())<br />
+{<br />
+&nbsp;&nbsp;&nbsp;&nbsp;echo $this-&gt;xmlrpc->display_error();<br />
+}</code>
+
+<h3>Explanation</h3>
+
+<p>The above code initializes the XML-RPC class, sets the server URL and method to be called (weblogUpdates.ping).  The
+request (in this case, the title and URL of your site) is placed into an array for transportation, and
+compiled using the request() function.
+Lastly, the full request is sent.  If the <dfn>send_request()</dfn> method returns false we will display the error message
+sent back from the XML-RPC Server.</p>
+
+<h2>Anatomy of a Request</h2>
+
+<p>An XML-RPC <dfn>request</dfn> is simply the data you are sending to the XML-RPC server.  Each piece of data in a request
+is referred to as a <dfn>request parameter</dfn>.  The above example has two parameters:
+The URL and title of your site. When the XML-RPC server receives your request, it will look for parameters it requires.</p>
+
+<p>Request parameters must be placed into an array for transportation, and each parameter can be one
+of seven data types (strings, numbers, dates, etc.). If your parameters are something other than strings
+you will have to include the data type in the request array.</p>
+
+<p>Here is an example of a simple array with three parameters:</p>
+
+<code>$request = array('John', 'Doe', 'www.some-site.com');<br />
+$this->xmlrpc->request($request);</code>
+
+<p>If you use data types other than strings, or if you have several different data types, you will place
+each parameter into its own array, with the data type in the second position:</p>
+
+<code>
+$request = array (<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;array('John', 'string'),<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;array('Doe', 'string'),<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;array(FALSE, 'boolean'),<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;array(12345, 'int')<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;);
+<br />
+$this->xmlrpc->request($request);</code>
+
+The  <a href="#datatypes">Data Types</a>  section below has a full list of data types.
+
+
+
+<h2>Creating an XML-RPC Server</h2>
+
+<p>An XML-RPC Server acts as a traffic cop of sorts, waiting for incoming requests and redirecting them to the
+appropriate functions for processing.</p>
+
+<p>To create your own XML-RPC server involves initializing the XML-RPC Server class in your controller where you expect the incoming
+request to appear, then setting up an array with mapping instructions so that incoming requests can be sent to the appropriate
+class and method for processing.</p>
+
+<p>Here is an example to illustrate:</p>
+
+<code>
+$this->load->library('xmlrpc');<br />
+$this->load->library('xmlrpcs');<br />
+<br />
+$config['functions']['<var>new_post</var>'] = array('function' => '<dfn>My_blog.new_entry</dfn>'),<br />
+$config['functions']['<var>update_post</var>'] = array('function' => '<dfn>My_blog.update_entry</dfn>');<br />
+$config['object'] = $this;<br />
+<br />
+$this->xmlrpcs->initialize($config);<br />
+$this->xmlrpcs->serve();</code>
+
+<p>The above example contains an array specifying two method requests that the Server allows.
+The allowed methods are on the left side of the array. When either of those are received, they will be mapped to the class and method on the right.</p>
+
+<p>The '<var>object</var>' key is a special key that you pass an instantiated class object with, which is necessary when the method you are mapping to is not
+       part of the CodeIgniter super object.</p>
+
+<p>In other words, if an XML-RPC Client sends a request for the <var>new_post</var> method, your
+server will load the <dfn>My_blog</dfn> class and call the <dfn>new_entry</dfn> function.
+If the request is for the <var>update_post</var> method, your
+server will load the <dfn>My_blog</dfn> class and call the <dfn>update_entry</dfn> function.</p>
+
+<p>The function names in the above example are arbitrary.  You'll decide what they should be called on your server,
+or if you are using standardized APIs, like the Blogger or MetaWeblog API, you'll use their function names.</p>
+
+<p>There are two additional configuration keys you may make use of when initializing the server class: <var>debug</var> can be set to TRUE in order to enable debugging, and <var>xss_clean</var> may be set to FALSE to prevent sending data through the Security library's xss_clean function.
+
+<h2>Processing Server Requests</h2>
+
+<p>When the XML-RPC Server receives a request and loads the class/method for processing, it will pass
+an object to that method containing the data sent by the client.</p>
+
+<p>Using the above example, if the <var>new_post</var> method is requested, the server will expect a class
+to exist with this prototype:</p>
+
+<code>class <kbd>My_blog</kbd> extends CI_Controller {<br />
+<br />
+&nbsp;&nbsp;&nbsp;&nbsp;function <kbd>new_post</kbd>(<var>$request</var>)<br />
+&nbsp;&nbsp;&nbsp;&nbsp;{<br />
+       <br />
+&nbsp;&nbsp;&nbsp;&nbsp;}<br />
+}
+</code>
+
+<p>The <var>$request</var> variable is an object compiled by the Server, which contains the data sent by the XML-RPC Client.
+Using this object you will have access to the <em>request parameters</em> enabling you to process the request.  When
+you are done you will send a <dfn>Response</dfn> back to the Client.</p>
+
+<p>Below is a real-world example, using the Blogger API.  One of the methods in the Blogger API is <dfn>getUserInfo()</dfn>.
+Using this method, an XML-RPC Client can send the Server a username and password, in return the Server sends
+back information about that particular user (nickname, user ID, email address, etc.).  Here is how the processing
+function might look:</p>
+
+
+<code>class <kbd>My_blog</kbd> extends CI_Controller {<br />
+<br />
+&nbsp;&nbsp;&nbsp;&nbsp;function <kbd>getUserInfo</kbd>(<var>$request</var>)<br />
+&nbsp;&nbsp;&nbsp;&nbsp;{<br />
+
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$username = 'smitty';<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$password = 'secretsmittypass';<br /><br />
+
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$this->load->library('xmlrpc');<br />
+&nbsp;&nbsp;&nbsp;&nbsp;<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$parameters&nbsp;=&nbsp;$request->output_parameters();<br />
+&nbsp;&nbsp;&nbsp;&nbsp;<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;($parameters['1'] != $username AND $parameters['2'] != $password)<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return&nbsp;$this->xmlrpc->send_error_message('100',&nbsp;'Invalid&nbsp;Access');<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br />
+&nbsp;&nbsp;&nbsp;&nbsp;<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$response&nbsp;=&nbsp;array(array('nickname'&nbsp;&nbsp;=>&nbsp;array('Smitty','string'),<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'userid'&nbsp;&nbsp;&nbsp;&nbsp;=>&nbsp;array('99','string'),<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'url'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=>&nbsp;array('http://yoursite.com','string'),<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'email'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=>&nbsp;array('jsmith@yoursite.com','string'),<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'lastname'&nbsp;&nbsp;=>&nbsp;array('Smith','string'),<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'firstname'&nbsp;=>&nbsp;array('John','string')<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;),<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'struct');<br />
+<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return $this->xmlrpc->send_response($response);<br />
+&nbsp;&nbsp;&nbsp;&nbsp;}<br />
+}
+</code>
+
+<h3>Notes:</h3>
+<p>The <dfn>output_parameters()</dfn> function retrieves an indexed array corresponding to the request parameters sent by the client.
+In the above example, the output parameters will be the username and password.</p>
+
+<p>If the username and password sent by the client were not valid, and error message is returned using <dfn>send_error_message()</dfn>.</p>
+
+<p>If the operation was successful, the client will be sent back a response array containing the user's info.</p>
+
+
+<h2>Formatting a Response</h2>
+
+<p>Similar to <em>Requests</em>, <em>Responses</em> must be formatted as an array.  However, unlike requests, a response is an array
+<strong>that contains a single item</strong>.  This item can be an array with several additional arrays, but there
+can be only one primary array index.  In other words, the basic prototype is this:</p>
+
+<code>$response = array('Response data',  'array');</code>
+
+<p>Responses, however, usually contain multiple pieces of information. In order to accomplish this we must put the response into its own
+array so that the primary array continues to contain a single piece of data.  Here's an example showing how this might be accomplished:</p>
+
+<code>
+$response = array (<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;array(<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'first_name' => array('John', 'string'),<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'last_name' => array('Doe', 'string'),<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'member_id' => array(123435, 'int'),<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'todo_list' => array(array('clean house', 'call mom', 'water plants'), 'array'),<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;),<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'struct'<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;);
+</code>
+
+<p class="important">Notice that the above array is formatted as a <dfn>struct</dfn>.  This is the most common data type for responses.</p>
+
+<p>As with Requests, a response can be one of the seven data types listed in the  <a href="#datatypes">Data Types</a>  section.</p>
+
+
+<h2>Sending an Error Response</h2>
+
+<p>If you need to send the client an error response you will use the following:</p>
+
+<code>return $this->xmlrpc->send_error_message('123', 'Requested data not available');</code>
+
+<p>The first parameter is the error number while the second parameter is the error message.</p>
+
+
+
+
+
+
+<h2>Creating Your Own Client and Server</h2>
+
+<p>To help you understand everything we've covered thus far, let's create a couple controllers that act as
+XML-RPC Client and Server.  You'll use the Client to send a request to the Server and receive a response.</p>
+
+<h3>The Client</h3>
+
+<p>Using a text editor, create a controller called <dfn>xmlrpc_client.php</dfn>.
+In it, place this code and save it to your <samp>applications/controllers/</samp> folder:</p>
+
+<textarea class="textarea" style="width:100%" cols="50" rows="32">&lt;?php
+
+class Xmlrpc_client extends CI_Controller {
+
+       function index()
+       {
+               $this->load->helper('url');
+               $server_url = site_url('xmlrpc_server');
+
+               $this->load->library('xmlrpc');
+
+               $this->xmlrpc->server($server_url, 80);
+               $this->xmlrpc->method('Greetings');
+
+               $request = array('How is it going?');
+               $this->xmlrpc->request($request);
+
+               if ( ! $this->xmlrpc->send_request())
+               {
+                       echo $this->xmlrpc->display_error();
+               }
+               else
+               {
+                       echo '<pre>';
+                       print_r($this->xmlrpc->display_response());
+                       echo '</pre>';
+               }
+       }
+}
+?></textarea>
+
+<p>Note: In the above code we are using a "url helper".  You can find more information in the <a href="../general/helpers.html">Helpers Functions</a> page.</p>
+
+<h3>The Server</h3>
+
+<p>Using a text editor, create a controller called <dfn>xmlrpc_server.php</dfn>.
+In it, place this code and save it to your <samp>applications/controllers/</samp> folder:</p>
+
+<textarea class="textarea" style="width:100%" cols="50" rows="30">&lt;?php
+
+class Xmlrpc_server extends CI_Controller {
+
+       function index()
+       {
+               $this->load->library('xmlrpc');
+               $this->load->library('xmlrpcs');
+
+               $config['functions']['Greetings'] = array('function' => 'Xmlrpc_server.process');
+
+               $this->xmlrpcs->initialize($config);
+               $this->xmlrpcs->serve();
+       }
+
+
+       function process($request)
+       {
+               $parameters = $request->output_parameters();
+
+               $response = array(
+                                                       array(
+                                                                       'you_said'  => $parameters['0'],
+                                                                       'i_respond' => 'Not bad at all.'),
+                                                       'struct');
+
+               return $this->xmlrpc->send_response($response);
+       }
+}
+?></textarea>
+
+<h3>Try it!</h3>
+
+<p>Now visit the your site using a URL similar to this:</p>
+<code>example.com/index.php/<var>xmlrpc_client</var>/</code>
+
+<p>You should now see the message you sent to the server, and its response back to you.</p>
+
+<p>The client you created sends a message ("How's is going?") to the server, along with a request for the "Greetings" method.
+The Server receives the request and maps it to the "process" function, where a response is sent back.</p>
+
+<h2>Using Associative Arrays In a Request Parameter</h2>
+
+<p>If you wish to use an associative array in your method parameters you will need to use a struct datatype:</p>
+
+<code>$request = array(<br />
+       &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;array(<br />
+       &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// Param 0<br />
+       &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;array(<br />
+       &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'name'=&gt;'John'<br />
+       &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;        ),<br />
+       &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'struct'<br />
+       &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;),<br />
+       &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;array(<br />
+       &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// Param 1<br />
+       &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;array(<br />
+       &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;    'size'=&gt;'large',<br />
+       &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'shape'=&gt;'round'<br />
+       &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;    ),<br />
+       &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'struct'<br />
+       &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;)<br />
+       &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;);<br />
+       $this-&gt;xmlrpc-&gt;request($request);</code>
+
+<p>You can retrieve the associative array when processing the request in the Server.</p>
+
+<code>$parameters = $request-&gt;output_parameters();<br />
+       $name = $parameters['0']['name'];<br />
+       $size = $parameters['1']['size'];<br />
+       $size = $parameters['1']['shape']; </code>
+
+<h1>XML-RPC Function Reference</h1>
+
+<h2>$this->xmlrpc->server()</h2>
+<p>Sets the URL and port number of the server to which a request is to be sent:</p>
+<code>$this->xmlrpc->server('http://www.sometimes.com/pings.php', 80);</code>
+
+<h2>$this->xmlrpc->timeout()</h2>
+<p>Set a time out period (in seconds) after which the request will be canceled:</p>
+<code>$this->xmlrpc->timeout(6);</code>
+
+<h2>$this->xmlrpc->method()</h2>
+<p>Sets the method that will be requested from the XML-RPC server:</p>
+<code>$this->xmlrpc->method('<var>method</var>');</code>
+
+<p>Where <var>method</var> is the name of the method.</p>
+
+<h2>$this->xmlrpc->request()</h2>
+<p>Takes an array of data and builds request to be sent to XML-RPC server:</p>
+<code>$request = array(array('My Photoblog', 'string'), 'http://www.yoursite.com/photoblog/');<br />
+$this->xmlrpc->request($request);</code>
+
+<h2>$this->xmlrpc->send_request()</h2>
+<p>The request sending function.  Returns boolean TRUE or FALSE based on success for failure, enabling it to be used conditionally.</p>
+
+<h2>$this->xmlrpc->set_debug(TRUE);</h2>
+<p>Enables debugging, which will display a variety of information and error data helpful during development.</p>
+
+
+<h2>$this->xmlrpc->display_error()</h2>
+<p>Returns an error message as a string if your request failed for some reason.</p>
+<code>echo $this->xmlrpc->display_error();</code>
+
+<h2>$this->xmlrpc->display_response()</h2>
+<p>Returns the response from the remote server once request is received.  The response will typically be an associative array.</p>
+<code>$this->xmlrpc->display_response();</code>
+
+<h2>$this->xmlrpc->send_error_message()</h2>
+<p>This function lets you send an error message from your server to the client. First parameter is the error number while the second parameter
+is the error message.</p>
+<code>return $this->xmlrpc->send_error_message('123', 'Requested data not available');</code>
+
+<h2>$this->xmlrpc->send_response()</h2>
+<p>Lets you send the response from your server to the client. An array of valid data values must be sent with this method.</p>
+<code>$response = array(<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;array(<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'flerror' => array(FALSE, 'boolean'),<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'message' => "Thanks for the ping!"<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;)<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'struct');<br />
+return $this->xmlrpc->send_response($response);</code>
+
+
+<a name="datatypes"></a>
+<h2>Data Types</h2>
+
+<p>According to the <a href="http://www.xmlrpc.com/spec">XML-RPC spec</a> there are seven types
+of values that you can send via XML-RPC:</p>
+
+<ul>
+<li><em>int</em> or <em>i4</em></li>
+<li><em>boolean</em></li>
+<li><em>string</em></li>
+<li><em>double</em></li>
+<li><em>dateTime.iso8601</em></li>
+<li><em>base64</em></li>
+<li><em>struct</em> (contains array of values)</li>
+<li><em>array</em> (contains array of values)</li>
+</ul>
+
+
+</div>
+<!-- END CONTENT -->
+
+
+<div id="footer">
+<p>
+Previous Topic:&nbsp;&nbsp;<a href="user_agent.html">User Agent Class</a>
+&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+<a href="#top">Top of Page</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+<a href="../index.html">User Guide Home</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+Next Topic:&nbsp;&nbsp;<a href="zip.html">Zip Encoding Class</a>
+</p>
+<p><a href="http://codeigniter.com">CodeIgniter</a> &nbsp;&middot;&nbsp; Copyright &#169; 2006 - 2011 &nbsp;&middot;&nbsp; <a href="http://ellislab.com/">EllisLab, Inc.</a></p>
+</div>
+
+</body>
+</html>
\ No newline at end of file
diff --git a/user_guide/libraries/zip.html b/user_guide/libraries/zip.html
new file mode 100755 (executable)
index 0000000..0311266
--- /dev/null
@@ -0,0 +1,288 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head>
+
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+<title>Zip Encoding Class : CodeIgniter User Guide</title>
+
+<style type='text/css' media='all'>@import url('../userguide.css');</style>
+<link rel='stylesheet' type='text/css' media='all' href='../userguide.css' />
+
+<script type="text/javascript" src="../nav/nav.js"></script>
+<script type="text/javascript" src="../nav/prototype.lite.js"></script>
+<script type="text/javascript" src="../nav/moo.fx.js"></script>
+<script type="text/javascript" src="../nav/user_guide_menu.js"></script>
+
+<meta http-equiv='expires' content='-1' />
+<meta http-equiv= 'pragma' content='no-cache' />
+<meta name='robots' content='all' />
+<meta name='author' content='ExpressionEngine Dev Team' />
+<meta name='description' content='CodeIgniter User Guide' />
+
+</head>
+<body>
+
+<!-- START NAVIGATION -->
+<div id="nav"><div id="nav_inner"><script type="text/javascript">create_menu('../');</script></div></div>
+<div id="nav2"><a name="top"></a><a href="javascript:void(0);" onclick="myHeight.toggle();"><img src="../images/nav_toggle_darker.jpg" width="154" height="43" border="0" title="Toggle Table of Contents" alt="Toggle Table of Contents" /></a></div>
+<div id="masthead">
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td><h1>CodeIgniter User Guide Version 2.0.2</h1></td>
+<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
+</tr>
+</table>
+</div>
+<!-- END NAVIGATION -->
+
+
+<!-- START BREADCRUMB -->
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td id="breadcrumb">
+<a href="http://codeigniter.com/">CodeIgniter Home</a> &nbsp;&#8250;&nbsp;
+<a href="../index.html">User Guide Home</a> &nbsp;&#8250;&nbsp;
+Zip Encoding Class
+</td>
+<td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="codeigniter.com/user_guide/" />Search User Guide&nbsp; <input type="text" class="input" style="width:200px;" name="q" id="q" size="31" maxlength="255" value="" />&nbsp;<input type="submit" class="submit" name="sa" value="Go" /></form></td>
+</tr>
+</table>
+<!-- END BREADCRUMB -->
+
+<br clear="all" />
+
+
+<!-- START CONTENT -->
+<div id="content">
+
+
+<h1>Zip Encoding Class</h1>
+<p>CodeIgniter's Zip Encoding Class classes permit you to create Zip archives. Archives can be downloaded to your
+desktop or saved to a directory.</p>
+
+
+<h2>Initializing the Class</h2>
+<p>Like most other classes in CodeIgniter, the Zip class is initialized in your controller using the <dfn>$this->load->library</dfn> function:</p>
+
+<code>$this->load->library('zip');</code>
+<p>Once loaded, the Zip library object will be available using: <dfn>$this->zip</dfn></p>
+
+
+<h2>Usage Example</h2>
+
+<p>This example demonstrates how to compress a file, save it to a folder on your server, and download it to your desktop.</p>
+
+<code>
+$name = 'mydata1.txt';<br />
+$data = 'A Data String!';<br />
+<br />
+$this->zip->add_data($name, $data);<br />
+<br />
+// Write the zip file to a folder on your server. Name it "my_backup.zip"<br />
+$this->zip->archive('/path/to/directory/my_backup.zip');
+<br /><br />
+ // Download the file to your desktop.  Name it "my_backup.zip"<br />
+$this->zip->download('my_backup.zip');
+</code>
+
+<h1>Function Reference</h1>
+
+<h2>$this->zip->add_data()</h2>
+
+<p>Permits you to add data to the Zip archive. The first parameter must contain the name you would like
+given to the file, the second parameter must contain the file data as a string:</p>
+
+<code>
+$name = 'my_bio.txt';<br />
+$data = 'I was born in an elevator...';<br />
+<br />
+$this->zip->add_data($name, $data);
+</code>
+
+<p>You are allowed multiple calls to this function in order to
+add several files to your archive.  Example:</p>
+
+<code>
+$name = 'mydata1.txt';<br />
+$data = 'A Data String!';<br />
+$this->zip->add_data($name, $data);<br />
+<br />
+$name = 'mydata2.txt';<br />
+$data = 'Another Data String!';<br />
+$this->zip->add_data($name, $data);<br />
+</code>
+
+<p>Or you can pass multiple files using an array:</p>
+
+<code>
+$data = array(<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'mydata1.txt' => 'A Data String!',<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'mydata2.txt' => 'Another Data String!'<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;);<br />
+<br />
+$this->zip->add_data($data);<br />
+<br />
+$this->zip->download('my_backup.zip');
+</code>
+
+<p>If you would like your compressed data organized into sub-folders, include the path as part of the filename:</p>
+
+<code>
+$name = '<kbd>personal/</kbd>my_bio.txt';<br />
+$data = 'I was born in an elevator...';<br />
+<br />
+$this->zip->add_data($name, $data);
+</code>
+
+<p>The above example will place <dfn>my_bio.txt</dfn> inside a folder called <kbd>personal</kbd>.</p>
+
+
+<h2>$this->zip->add_dir()</h2>
+
+<p>Permits you to add a directory.  Usually this function is unnecessary since you can place your data into folders when
+using <dfn>$this->zip->add_data()</dfn>, but if you would like to create an empty folder you can do so.  Example:</p>
+
+<code>$this->zip->add_dir('myfolder'); // Creates a folder called "myfolder"</code>
+
+
+
+<h2>$this->zip->read_file()</h2>
+
+<p>Permits you to compress a file that already exists somewhere on your server.  Supply a file path and the zip class will
+read it and add it to the archive:</p>
+
+<code>
+$path = '/path/to/photo.jpg';<br /><br />
+$this->zip->read_file($path);
+<br /><br />
+ // Download the file to your desktop.  Name it "my_backup.zip"<br />
+$this->zip->download('my_backup.zip');
+</code>
+
+<p>If you would like the Zip archive to maintain the directory structure of the file in it, pass <kbd>TRUE</kbd> (boolean) in the
+second parameter.  Example:</p>
+
+
+<code>
+$path = '/path/to/photo.jpg';<br /><br />
+$this->zip->read_file($path, <kbd>TRUE</kbd>);
+<br /><br />
+ // Download the file to your desktop.  Name it "my_backup.zip"<br />
+$this->zip->download('my_backup.zip');
+</code>
+
+<p>In the above example, <dfn>photo.jpg</dfn> will be placed inside two folders:  <kbd>path/to/</kbd></p>
+
+
+
+<h2>$this->zip->read_dir()</h2>
+
+<p>Permits you to compress a folder (and its contents) that already exists somewhere on your server.  Supply a file path to the
+directory and the zip class will recursively read it and recreate it as a Zip archive.  All files contained within the
+supplied path will be encoded, as will any sub-folders contained within it.  Example:</p>
+
+<code>
+$path = '/path/to/your/directory/';<br /><br />
+$this->zip->read_dir($path);
+<br /><br />
+ // Download the file to your desktop.  Name it "my_backup.zip"<br />
+$this->zip->download('my_backup.zip');
+</code>
+
+<p>By default the Zip archive will place all directories listed in the first parameter inside the zip. If you want the tree preceding the target folder to be ignored
+you can pass <kbd>FALSE</kbd> (boolean) in the second parameter.  Example:</p>
+
+<code>
+$path = '/path/to/your/directory/';<br /><br />
+$this->zip->read_dir($path, FALSE);
+</code>
+
+<p>This will create a ZIP with the folder "directory" inside, then all sub-folders stored correctly inside that, but will not include the folders <samp>/path/to/your</samp>.</p>
+
+
+
+
+<h2>$this->zip->archive()</h2>
+
+<p>Writes the Zip-encoded file to a directory on your server.  Submit a valid server path ending in the file name.  Make sure the
+directory is writable (666 or 777 is usually OK). Example:</p>
+
+<code>$this->zip->archive('/path/to/folder/myarchive.zip'); // Creates a file named myarchive.zip</code>
+
+
+<h2>$this->zip->download()</h2>
+
+<p>Causes the Zip file to be downloaded from your server. The function must be passed the name you would like the zip file called.
+Example:</p>
+
+<code>$this->zip->download('latest_stuff.zip'); // File will be named "latest_stuff.zip"</code>
+
+<p class="important"><strong>Note:</strong>&nbsp; Do not display any data in the controller in which you call this function since it sends various server headers
+that cause the download to happen and the file to be treated as binary.</p>
+
+
+<h2>$this->zip->get_zip()</h2>
+
+<p>Returns the Zip-compressed file data.  Generally you will not need this function unless you want to do something unique with the data.
+Example:</p>
+
+<code>
+$name = 'my_bio.txt';<br />
+$data = 'I was born in an elevator...';<br />
+<br />
+$this->zip->add_data($name, $data);<br /><br />
+
+$zip_file = $this->zip->get_zip();
+</code>
+
+
+<h2>$this->zip->clear_data()</h2>
+
+<p>The Zip class caches your zip data so that it doesn't need to recompile the Zip archive for each function you use above.
+If, however, you need to create multiple Zips, each with different data, you can clear the cache between calls. Example:</p>
+
+<code>
+$name = 'my_bio.txt';<br />
+$data = 'I was born in an elevator...';<br />
+<br />
+$this->zip->add_data($name, $data);<br />
+$zip_file = $this->zip->get_zip();<br />
+<br />
+<kbd>$this->zip->clear_data();</kbd>
+<br /><br />
+
+$name = 'photo.jpg';<br />
+$this->zip->read_file("/path/to/photo.jpg"); // Read the file's contents<br />
+<br /><br />
+$this->zip->download('myphotos.zip');
+</code>
+
+
+
+
+
+
+
+
+
+
+
+
+
+</div>
+<!-- END CONTENT -->
+
+
+<div id="footer">
+<p>
+Previous Topic:&nbsp;&nbsp;<a href="xmlrpc.html"> XML-RPC Class</a>
+&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+<a href="#top">Top of Page</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+<a href="../index.html">User Guide Home</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+Next Topic:&nbsp;&nbsp;<a href="../helpers/array_helper.html">Array Helper</a>
+</p>
+<p><a href="http://codeigniter.com">CodeIgniter</a> &nbsp;&middot;&nbsp; Copyright &#169; 2006 - 2011 &nbsp;&middot;&nbsp; <a href="http://ellislab.com/">EllisLab, Inc.</a></p>
+</div>
+
+</body>
+</html>
\ No newline at end of file
diff --git a/user_guide/license.html b/user_guide/license.html
new file mode 100755 (executable)
index 0000000..8f53851
--- /dev/null
@@ -0,0 +1,107 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head>
+
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+<title>CodeIgniter License Agreement : CodeIgniter User Guide</title>
+
+<style type='text/css' media='all'>@import url('userguide.css');</style>
+<link rel='stylesheet' type='text/css' media='all' href='userguide.css' />
+
+<script type="text/javascript" src="nav/nav.js"></script>
+<script type="text/javascript" src="nav/prototype.lite.js"></script>
+<script type="text/javascript" src="nav/moo.fx.js"></script>
+<script type="text/javascript" src="nav/user_guide_menu.js"></script>
+
+<meta http-equiv='expires' content='-1' />
+<meta http-equiv= 'pragma' content='no-cache' />
+<meta name='robots' content='all' />
+<meta name='author' content='ExpressionEngine Dev Team' />
+<meta name='description' content='CodeIgniter User Guide' />
+
+</head>
+<body>
+
+<!-- START NAVIGATION -->
+<div id="nav"><div id="nav_inner"><script type="text/javascript">create_menu('null');</script></div></div>
+<div id="nav2"><a name="top"></a><a href="javascript:void(0);" onclick="myHeight.toggle();"><img src="images/nav_toggle_darker.jpg" width="154" height="43" border="0" title="Toggle Table of Contents" alt="Toggle Table of Contents" /></a></div>
+<div id="masthead">
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td><h1>CodeIgniter User Guide Version 2.0.2</h1></td>
+<td id="breadcrumb_right"><a href="toc.html">Table of Contents Page</a></td>
+</tr>
+</table>
+</div>
+<!-- END NAVIGATION -->
+
+
+<!-- START BREADCRUMB -->
+
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td id="breadcrumb">
+<a href="http://codeigniter.com/">CodeIgniter Home</a> &nbsp;&#8250;&nbsp;
+<a href="index.html">User Guide Home</a> &nbsp;&#8250;&nbsp;
+License Agreement
+</td>
+<td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="codeigniter.com/user_guide/" />Search User Guide&nbsp; <input type="text" class="input" style="width:200px;" name="q" id="q" size="31" maxlength="255" value="" />&nbsp;<input type="submit" class="submit" name="sa" value="Go" /></form></td>
+</tr>
+</table>
+<!-- END BREADCRUMB -->
+
+
+
+<br clear="all" />
+
+
+<!-- START CONTENT -->
+<div id="content">
+
+<h1>CodeIgniter License Agreement</h1>
+
+<p>Copyright (c) 2008 - 2011, EllisLab, Inc.<br />
+All rights reserved.</p>
+
+<p>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.</p>
+
+<h2>Permitted Use</h2>
+<p>You are permitted to use, copy, modify, and distribute the Software and its documentation, with or without modification, for any purpose, provided that the following conditions are met:</p>
+
+<ol>
+<li>A copy of this license agreement must be included with the distribution.</li>
+<li>Redistributions of source code must retain the above copyright notice in all source code files.</li>
+<li>Redistributions in binary form must reproduce the above copyright notice in the documentation and/or other materials provided with the distribution.</li>
+<li>Any files that have been modified must carry notices stating the nature of the change and the names of those who changed them.</li>
+<li>Products derived from the Software must include an acknowledgment that they are derived from CodeIgniter in their documentation and/or other materials provided with the distribution.</li>
+<li>Products derived from the Software may not be called "CodeIgniter", nor may "CodeIgniter" appear in their name, without prior written permission from EllisLab, Inc.</li>
+</ol>
+
+<h2>Indemnity</h2>
+<p>You agree to indemnify and hold harmless the authors of the Software and any contributors for any direct, indirect, incidental, or consequential third-party claims, actions or suits, as well as any related expenses, liabilities, damages, settlements or fees arising from your use or misuse of the Software, or a violation of any terms of this license.</p>
+
+<h2>Disclaimer of Warranty</h2>
+<p>THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, WARRANTIES OF QUALITY, PERFORMANCE, NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.</p>
+
+<h2>Limitations of Liability</h2>
+<p>YOU ASSUME ALL RISK ASSOCIATED WITH THE INSTALLATION AND USE OF THE SOFTWARE. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS OF THE SOFTWARE BE LIABLE FOR CLAIMS, DAMAGES OR OTHER LIABILITY ARISING FROM, OUT OF, OR IN CONNECTION WITH THE SOFTWARE. LICENSE HOLDERS ARE SOLELY RESPONSIBLE FOR DETERMINING THE APPROPRIATENESS OF USE AND ASSUME ALL RISKS ASSOCIATED WITH ITS USE, INCLUDING BUT NOT LIMITED TO THE RISKS OF PROGRAM ERRORS, DAMAGE TO EQUIPMENT, LOSS OF DATA OR SOFTWARE PROGRAMS, OR UNAVAILABILITY OR INTERRUPTION OF OPERATIONS.</p>
+
+
+
+</div>
+<!-- END CONTENT -->
+
+
+<div id="footer">
+<p>
+Previous Topic:&nbsp;&nbsp;<a href="general/requirements.html">Server Requirements</a>
+&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+<a href="#top">Top of Page</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+<a href="index.html">User Guide Home</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+Next Topic:&nbsp;&nbsp;<a href="changelog.html">Change Log</a>
+</p>
+<p><a href="http://codeigniter.com">CodeIgniter</a> &nbsp;&middot;&nbsp; Copyright &#169; 2006 - 2011 &nbsp;&middot;&nbsp; <a href="http://ellislab.com/">EllisLab, Inc.</a></p>
+</div>
+
+</body>
+</html>
\ No newline at end of file
diff --git a/user_guide/nav/hacks.txt b/user_guide/nav/hacks.txt
new file mode 100755 (executable)
index 0000000..8c17f00
--- /dev/null
@@ -0,0 +1,10 @@
+I did the following hack in moo.fx.js:
+
+At line 79 in the toggle: function()  function, I added:
+
+document.getElementById('nav').style.display = 'block';
+
+-- Rick Ellis
+
+
+Also removed fx.Opacity and fx.Height from moo.fx.js -- Pascal
\ No newline at end of file
diff --git a/user_guide/nav/moo.fx.js b/user_guide/nav/moo.fx.js
new file mode 100755 (executable)
index 0000000..256371d
--- /dev/null
@@ -0,0 +1,83 @@
+/*
+moo.fx, simple effects library built with prototype.js (http://prototype.conio.net).
+by Valerio Proietti (http://mad4milk.net) MIT-style LICENSE.
+for more info (http://moofx.mad4milk.net).
+10/24/2005
+v(1.0.2)
+*/
+
+//base
+var fx = new Object();
+fx.Base = function(){};
+fx.Base.prototype = {
+       setOptions: function(options) {
+       this.options = {
+               duration: 500,
+               onComplete: ''
+       }
+       Object.extend(this.options, options || {});
+       },
+
+       go: function() {
+               this.duration = this.options.duration;
+               this.startTime = (new Date).getTime();
+               this.timer = setInterval (this.step.bind(this), 13);
+       },
+
+       step: function() {
+               var time  = (new Date).getTime();
+               var Tpos   = (time - this.startTime) / (this.duration);
+               if (time >= this.duration+this.startTime) {
+                       this.now = this.to;
+                       clearInterval (this.timer);
+                       this.timer = null;
+                       if (this.options.onComplete) setTimeout(this.options.onComplete.bind(this), 10);
+               }
+               else {
+                       this.now = ((-Math.cos(Tpos*Math.PI)/2) + 0.5) * (this.to-this.from) + this.from;
+                       //this time-position, sinoidal transition thing is from script.aculo.us
+               }
+               this.increase();
+       },
+
+       custom: function(from, to) {
+               if (this.timer != null) return;
+               this.from = from;
+               this.to = to;
+               this.go();
+       },
+
+       hide: function() {
+               this.now = 0;
+               this.increase();
+       },
+
+       clearTimer: function() {
+               clearInterval(this.timer);
+               this.timer = null;
+       }
+}
+
+//stretchers
+fx.Layout = Class.create();
+fx.Layout.prototype = Object.extend(new fx.Base(), {
+       initialize: function(el, options) {
+               this.el = $(el);
+               this.el.style.overflow = "hidden";
+               this.el.iniWidth = this.el.offsetWidth;
+               this.el.iniHeight = this.el.offsetHeight;
+               this.setOptions(options);
+       }
+});
+
+fx.Height = Class.create();
+Object.extend(Object.extend(fx.Height.prototype, fx.Layout.prototype), {
+       increase: function() {
+               this.el.style.height = this.now + "px";
+       },
+
+       toggle: function() {
+               if (this.el.offsetHeight > 0) this.custom(this.el.offsetHeight, 0);
+               else this.custom(0, this.el.scrollHeight);
+       }
+});
diff --git a/user_guide/nav/nav.js b/user_guide/nav/nav.js
new file mode 100755 (executable)
index 0000000..ce783fc
--- /dev/null
@@ -0,0 +1,144 @@
+function create_menu(basepath)
+{
+       var base = (basepath == 'null') ? '' : basepath;
+
+       document.write(
+               '<table cellpadding="0" cellspaceing="0" border="0" style="width:98%"><tr>' +
+               '<td class="td" valign="top">' +
+
+               '<ul>' +
+               '<li><a href="'+base+'index.html">User Guide Home</a></li>' +
+               '<li><a href="'+base+'toc.html">Table of Contents Page</a></li>' +
+               '</ul>' +
+
+               '<h3>Basic Info</h3>' +
+               '<ul>' +
+                       '<li><a href="'+base+'general/requirements.html">Server Requirements</a></li>' +
+                       '<li><a href="'+base+'license.html">License Agreement</a></li>' +
+                       '<li><a href="'+base+'changelog.html">Change Log</a></li>' +
+                       '<li><a href="'+base+'general/credits.html">Credits</a></li>' +
+               '</ul>' +
+
+               '<h3>Installation</h3>' +
+               '<ul>' +
+                       '<li><a href="'+base+'installation/downloads.html">Downloading CodeIgniter</a></li>' +
+                       '<li><a href="'+base+'installation/index.html">Installation Instructions</a></li>' +
+                       '<li><a href="'+base+'installation/upgrading.html">Upgrading from a Previous Version</a></li>' +
+                       '<li><a href="'+base+'installation/troubleshooting.html">Troubleshooting</a></li>' +
+               '</ul>' +
+
+               '<h3>Introduction</h3>' +
+               '<ul>' +
+                       '<li><a href="'+base+'overview/getting_started.html">Getting Started</a></li>' +
+                       '<li><a href="'+base+'overview/at_a_glance.html">CodeIgniter at a Glance</a></li>' +
+                       '<li><a href="'+base+'overview/cheatsheets.html">CodeIgniter Cheatsheets</a></li>' +
+                       '<li><a href="'+base+'overview/features.html">Supported Features</a></li>' +
+                       '<li><a href="'+base+'overview/appflow.html">Application Flow Chart</a></li>' +
+                       '<li><a href="'+base+'overview/mvc.html">Model-View-Controller</a></li>' +
+                       '<li><a href="'+base+'overview/goals.html">Architectural Goals</a></li>' +
+               '</ul>' +
+
+               '</td><td class="td_sep" valign="top">' +
+
+               '<h3>General Topics</h3>' +
+               '<ul>' +
+                       '<li><a href="'+base+'general/urls.html">CodeIgniter URLs</a></li>' +
+                       '<li><a href="'+base+'general/controllers.html">Controllers</a></li>' +
+                       '<li><a href="'+base+'general/reserved_names.html">Reserved Names</a></li>' +
+                       '<li><a href="'+base+'general/views.html">Views</a></li>' +
+                       '<li><a href="'+base+'general/models.html">Models</a></li>' +
+                       '<li><a href="'+base+'general/helpers.html">Helpers</a></li>' +
+                       '<li><a href="'+base+'general/libraries.html">Using CodeIgniter Libraries</a></li>' +
+                       '<li><a href="'+base+'general/creating_libraries.html">Creating Your Own Libraries</a></li>' +
+                       '<li><a href="'+base+'general/core_classes.html">Creating Core Classes</a></li>' +
+                       '<li><a href="'+base+'general/hooks.html">Hooks - Extending the Core</a></li>' +
+                       '<li><a href="'+base+'general/autoloader.html">Auto-loading Resources</a></li>' +
+                       '<li><a href="'+base+'general/common_functions.html">Common Functions</a></li>' +
+                       '<li><a href="'+base+'general/routing.html">URI Routing</a></li>' +
+                       '<li><a href="'+base+'general/errors.html">Error Handling</a></li>' +
+                       '<li><a href="'+base+'general/caching.html">Caching</a></li>' +
+                       '<li><a href="'+base+'general/profiling.html">Profiling Your Application</a></li>' +
+                       '<li><a href="'+base+'general/cli.html">Running via the CLI</a></li>' +
+                       '<li><a href="'+base+'general/managing_apps.html">Managing Applications</a></li>' +
+                       '<li><a href="'+base+'general/environments.html">Handling Multiple Environments</a></li>' +
+                       '<li><a href="'+base+'general/alternative_php.html">Alternative PHP Syntax</a></li>' +
+                       '<li><a href="'+base+'general/security.html">Security</a></li>' +
+                       '<li><a href="'+base+'general/styleguide.html">PHP Style Guide</a></li>' +
+                       '<li><a href="'+base+'doc_style/index.html">Writing Documentation</a></li>' +
+               '</ul>' +
+
+               '<h3>Additional Resources</h3>' +
+               '<ul>' +
+               '<li><a href="http://codeigniter.com/forums/">Community Forums</a></li>' +
+               '<li><a href="http://codeigniter.com/wiki/">Community Wiki</a></li>' +
+               '</ul>' +
+
+               '</td><td class="td_sep" valign="top">' +
+
+               '<h3>Class Reference</h3>' +
+               '<ul>' +
+               '<li><a href="'+base+'libraries/benchmark.html">Benchmarking Class</a></li>' +
+               '<li><a href="'+base+'libraries/calendar.html">Calendar Class</a></li>' +
+               '<li><a href="'+base+'libraries/cart.html">Cart Class</a></li>' +
+               '<li><a href="'+base+'libraries/config.html">Config Class</a></li>' +
+               '<li><a href="'+base+'libraries/email.html">Email Class</a></li>' +
+               '<li><a href="'+base+'libraries/encryption.html">Encryption Class</a></li>' +
+               '<li><a href="'+base+'libraries/file_uploading.html">File Uploading Class</a></li>' +
+               '<li><a href="'+base+'libraries/form_validation.html">Form Validation Class</a></li>' +
+               '<li><a href="'+base+'libraries/ftp.html">FTP Class</a></li>' +
+               '<li><a href="'+base+'libraries/table.html">HTML Table Class</a></li>' +
+               '<li><a href="'+base+'libraries/image_lib.html">Image Manipulation Class</a></li>' +
+               '<li><a href="'+base+'libraries/input.html">Input Class</a></li>' +
+               '<li><a href="'+base+'libraries/javascript.html">Javascript Class</a></li>' +
+               '<li><a href="'+base+'libraries/loader.html">Loader Class</a></li>' +
+               '<li><a href="'+base+'libraries/language.html">Language Class</a></li>' +
+               '<li><a href="'+base+'libraries/output.html">Output Class</a></li>' +
+               '<li><a href="'+base+'libraries/pagination.html">Pagination Class</a></li>' +
+               '<li><a href="'+base+'libraries/security.html">Security Class</a></li>' +
+               '<li><a href="'+base+'libraries/sessions.html">Session Class</a></li>' +
+               '<li><a href="'+base+'libraries/trackback.html">Trackback Class</a></li>' +
+               '<li><a href="'+base+'libraries/parser.html">Template Parser Class</a></li>' +
+               '<li><a href="'+base+'libraries/typography.html">Typography Class</a></li>' +
+               '<li><a href="'+base+'libraries/unit_testing.html">Unit Testing Class</a></li>' +
+               '<li><a href="'+base+'libraries/uri.html">URI Class</a></li>' +
+               '<li><a href="'+base+'libraries/user_agent.html">User Agent Class</a></li>' +
+               '<li><a href="'+base+'libraries/xmlrpc.html">XML-RPC Class</a></li>' +
+               '<li><a href="'+base+'libraries/zip.html">Zip Encoding Class</a></li>' +
+               '</ul>' +
+
+               '</td><td class="td_sep" valign="top">' +
+
+               '<h3>Driver Reference</h3>' +
+               '<ul>' +
+               '<li><a href="'+base+'libraries/caching.html">Caching Class</a></li>' +
+               '<li><a href="'+base+'database/index.html">Database Class</a></li>' +
+               '<li><a href="'+base+'libraries/javascript.html">Javascript Class</a></li>' +
+               '</ul>' +
+
+               '<h3>Helper Reference</h3>' +
+               '<ul>' +
+               '<li><a href="'+base+'helpers/array_helper.html">Array Helper</a></li>' +
+               '<li><a href="'+base+'helpers/captcha_helper.html">CAPTCHA Helper</a></li>' +
+               '<li><a href="'+base+'helpers/cookie_helper.html">Cookie Helper</a></li>' +
+               '<li><a href="'+base+'helpers/date_helper.html">Date Helper</a></li>' +
+               '<li><a href="'+base+'helpers/directory_helper.html">Directory Helper</a></li>' +
+               '<li><a href="'+base+'helpers/download_helper.html">Download Helper</a></li>' +
+               '<li><a href="'+base+'helpers/email_helper.html">Email Helper</a></li>' +
+               '<li><a href="'+base+'helpers/file_helper.html">File Helper</a></li>' +
+               '<li><a href="'+base+'helpers/form_helper.html">Form Helper</a></li>' +
+               '<li><a href="'+base+'helpers/html_helper.html">HTML Helper</a></li>' +
+               '<li><a href="'+base+'helpers/inflector_helper.html">Inflector Helper</a></li>' +
+               '<li><a href="'+base+'helpers/language_helper.html">Language Helper</a></li>' +
+               '<li><a href="'+base+'helpers/number_helper.html">Number Helper</a></li>' +
+               '<li><a href="'+base+'helpers/path_helper.html">Path Helper</a></li>' +
+               '<li><a href="'+base+'helpers/security_helper.html">Security Helper</a></li>' +
+               '<li><a href="'+base+'helpers/smiley_helper.html">Smiley Helper</a></li>' +
+               '<li><a href="'+base+'helpers/string_helper.html">String Helper</a></li>' +
+               '<li><a href="'+base+'helpers/text_helper.html">Text Helper</a></li>' +
+               '<li><a href="'+base+'helpers/typography_helper.html">Typography Helper</a></li>' +
+               '<li><a href="'+base+'helpers/url_helper.html">URL Helper</a></li>' +
+               '<li><a href="'+base+'helpers/xml_helper.html">XML Helper</a></li>' +
+               '</ul>' +
+
+               '</td></tr></table>');
+}
\ No newline at end of file
diff --git a/user_guide/nav/prototype.lite.js b/user_guide/nav/prototype.lite.js
new file mode 100755 (executable)
index 0000000..e6c3622
--- /dev/null
@@ -0,0 +1,127 @@
+/*  Prototype JavaScript framework
+ *  (c) 2005 Sam Stephenson <sam@conio.net>
+ *
+ *  Prototype is freely distributable under the terms of an MIT-style license.
+ *
+ *  For details, see the Prototype web site: http://prototype.conio.net/
+ *
+/*--------------------------------------------------------------------------*/
+
+
+//note: this is a stripped down version of prototype, to be used with moo.fx by mad4milk (http://moofx.mad4milk.net).
+
+var Class = {
+  create: function() {
+       return function() {
+         this.initialize.apply(this, arguments);
+       }
+  }
+}
+
+Object.extend = function(destination, source) {
+  for (property in source) {
+       destination[property] = source[property];
+  }
+  return destination;
+}
+
+Function.prototype.bind = function(object) {
+  var __method = this;
+  return function() {
+       return __method.apply(object, arguments);
+  }
+}
+
+function $() {
+  var elements = new Array();
+
+  for (var i = 0; i < arguments.length; i++) {
+       var element = arguments[i];
+       if (typeof element == 'string')
+         element = document.getElementById(element);
+
+       if (arguments.length == 1)
+         return element;
+
+       elements.push(element);
+  }
+
+  return elements;
+}
+
+//-------------------------
+
+document.getElementsByClassName = function(className) {
+  var children = document.getElementsByTagName('*') || document.all;
+  var elements = new Array();
+
+  for (var i = 0; i < children.length; i++) {
+       var child = children[i];
+       var classNames = child.className.split(' ');
+       for (var j = 0; j < classNames.length; j++) {
+         if (classNames[j] == className) {
+               elements.push(child);
+               break;
+         }
+       }
+  }
+
+  return elements;
+}
+
+//-------------------------
+
+if (!window.Element) {
+  var Element = new Object();
+}
+
+Object.extend(Element, {
+  remove: function(element) {
+       element = $(element);
+       element.parentNode.removeChild(element);
+  },
+
+  hasClassName: function(element, className) {
+       element = $(element);
+       if (!element)
+         return;
+       var a = element.className.split(' ');
+       for (var i = 0; i < a.length; i++) {
+         if (a[i] == className)
+               return true;
+       }
+       return false;
+  },
+
+  addClassName: function(element, className) {
+       element = $(element);
+       Element.removeClassName(element, className);
+       element.className += ' ' + className;
+  },
+
+  removeClassName: function(element, className) {
+       element = $(element);
+       if (!element)
+         return;
+       var newClassName = '';
+       var a = element.className.split(' ');
+       for (var i = 0; i < a.length; i++) {
+         if (a[i] != className) {
+               if (i > 0)
+                 newClassName += ' ';
+               newClassName += a[i];
+         }
+       }
+       element.className = newClassName;
+  },
+
+  // removes whitespace-only text node children
+  cleanWhitespace: function(element) {
+       element = $(element);
+       for (var i = 0; i < element.childNodes.length; i++) {
+         var node = element.childNodes[i];
+         if (node.nodeType == 3 && !/\S/.test(node.nodeValue))
+               Element.remove(node);
+       }
+  }
+});
\ No newline at end of file
diff --git a/user_guide/nav/user_guide_menu.js b/user_guide/nav/user_guide_menu.js
new file mode 100755 (executable)
index 0000000..ce5d077
--- /dev/null
@@ -0,0 +1,4 @@
+window.onload = function() {
+       myHeight = new fx.Height('nav', {duration: 400});
+       myHeight.hide();
+}
\ No newline at end of file
diff --git a/user_guide/overview/appflow.html b/user_guide/overview/appflow.html
new file mode 100755 (executable)
index 0000000..bcbc43f
--- /dev/null
@@ -0,0 +1,95 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head>
+
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+<title>Application Flow Chart : CodeIgniter User Guide</title>
+
+<style type='text/css' media='all'>@import url('../userguide.css');</style>
+<link rel='stylesheet' type='text/css' media='all' href='../userguide.css' />
+
+<script type="text/javascript" src="../nav/nav.js"></script>
+<script type="text/javascript" src="../nav/prototype.lite.js"></script>
+<script type="text/javascript" src="../nav/moo.fx.js"></script>
+<script type="text/javascript" src="../nav/user_guide_menu.js"></script>
+
+<meta http-equiv='expires' content='-1' />
+<meta http-equiv= 'pragma' content='no-cache' />
+<meta name='robots' content='all' />
+<meta name='author' content='ExpressionEngine Dev Team' />
+<meta name='description' content='CodeIgniter User Guide' />
+
+</head>
+<body>
+
+<!-- START NAVIGATION -->
+<div id="nav"><div id="nav_inner"><script type="text/javascript">create_menu('../');</script></div></div>
+<div id="nav2"><a name="top"></a><a href="javascript:void(0);" onclick="myHeight.toggle();"><img src="../images/nav_toggle_darker.jpg" width="154" height="43" border="0" title="Toggle Table of Contents" alt="Toggle Table of Contents" /></a></div>
+<div id="masthead">
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td><h1>CodeIgniter User Guide Version 2.0.2</h1></td>
+<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
+</tr>
+</table>
+</div>
+<!-- END NAVIGATION -->
+
+
+<!-- START BREADCRUMB -->
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td id="breadcrumb">
+<a href="http://codeigniter.com/">CodeIgniter Home</a> &nbsp;&#8250;&nbsp;
+<a href="../index.html">User Guide Home</a> &nbsp;&#8250;&nbsp;
+Appflow
+</td>
+<td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="codeigniter.com/user_guide/" />Search User Guide&nbsp; <input type="text" class="input" style="width:200px;" name="q" id="q" size="31" maxlength="255" value="" />&nbsp;<input type="submit" class="submit" name="sa" value="Go" /></form></td>
+</tr>
+</table>
+<!-- END BREADCRUMB -->
+
+<br clear="all" />
+
+
+<!-- START CONTENT -->
+<div id="content">
+
+
+<h1>Application Flow Chart</h1>
+
+<p>The following graphic illustrates how data flows throughout the system:</p>
+
+<div><img src="../images/appflowchart.gif" width="697" height="205" border="0" alt="CodeIgniter application flow" /></div>
+
+
+<ol>
+<li>The index.php serves as the front controller, initializing the base resources needed to run CodeIgniter.</li>
+<li>The Router examines the HTTP request to determine what should be done with it.</li>
+<li>If a cache file exists, it is sent directly to the browser, bypassing the normal system execution.</li>
+<li>Security.  Before the application controller is loaded, the HTTP request and any user submitted data is filtered for security.</li>
+<li>The Controller loads the model, core libraries, helpers, and any other resources needed to process the specific request.</li>
+<li>The finalized View is rendered then sent to the web browser to be seen. If caching is enabled, the view is cached first so
+that on subsequent requests it can be served.</li>
+</ol>
+
+
+
+
+</div>
+<!-- END CONTENT -->
+
+
+<div id="footer">
+<p>
+Previous Topic:&nbsp;&nbsp;<a href="features.html">CodeIgniter Features</a>
+&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+<a href="#top">Top of Page</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+<a href="../index.html">User Guide Home</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+Next Topic:&nbsp;&nbsp;<a href="mvc.html">Model-View-Controller</a>
+</p>
+<p><a href="http://codeigniter.com">CodeIgniter</a> &nbsp;&middot;&nbsp; Copyright &#169; 2006 - 2011 &nbsp;&middot;&nbsp; <a href="http://ellislab.com/">EllisLab, Inc.</a></p>
+</div>
+
+</body>
+</html>
\ No newline at end of file
diff --git a/user_guide/overview/at_a_glance.html b/user_guide/overview/at_a_glance.html
new file mode 100755 (executable)
index 0000000..b6b81d7
--- /dev/null
@@ -0,0 +1,162 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head>
+
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+<title>CodeIgniter at a Glance : CodeIgniter User Guide</title>
+
+<style type='text/css' media='all'>@import url('../userguide.css');</style>
+<link rel='stylesheet' type='text/css' media='all' href='../userguide.css' />
+
+<script type="text/javascript" src="../nav/nav.js"></script>
+<script type="text/javascript" src="../nav/prototype.lite.js"></script>
+<script type="text/javascript" src="../nav/moo.fx.js"></script>
+<script type="text/javascript" src="../nav/user_guide_menu.js"></script>
+
+<meta http-equiv='expires' content='-1' />
+<meta http-equiv= 'pragma' content='no-cache' />
+<meta name='robots' content='all' />
+<meta name='author' content='ExpressionEngine Dev Team' />
+<meta name='description' content='CodeIgniter User Guide' />
+
+</head>
+<body>
+
+<!-- START NAVIGATION -->
+<div id="nav"><div id="nav_inner"><script type="text/javascript">create_menu('../');</script></div></div>
+<div id="nav2"><a name="top"></a><a href="javascript:void(0);" onclick="myHeight.toggle();"><img src="../images/nav_toggle_darker.jpg" width="154" height="43" border="0" title="Toggle Table of Contents" alt="Toggle Table of Contents" /></a></div>
+<div id="masthead">
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td><h1>CodeIgniter User Guide Version 2.0.2</h1></td>
+<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
+</tr>
+</table>
+</div>
+<!-- END NAVIGATION -->
+
+
+<!-- START BREADCRUMB -->
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td id="breadcrumb">
+<a href="http://codeigniter.com/">CodeIgniter Home</a> &nbsp;&#8250;&nbsp;
+<a href="../index.html">User Guide Home</a> &nbsp;&#8250;&nbsp;
+What is CodeIgniter?
+</td>
+<td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="codeigniter.com/user_guide/" />Search User Guide&nbsp; <input type="text" class="input" style="width:200px;" name="q" id="q" size="31" maxlength="255" value="" />&nbsp;<input type="submit" class="submit" name="sa" value="Go" /></form></td>
+</tr>
+</table>
+<!-- END BREADCRUMB -->
+
+<br clear="all" />
+
+
+<!-- START CONTENT -->
+<div id="content">
+
+<h1>CodeIgniter at a Glance</h1>
+
+
+<h2>CodeIgniter is an Application Framework</h2>
+
+<p>CodeIgniter is a toolkit for people who build web applications using PHP.  Its goal is to enable you to develop projects much faster than you could if you were writing code
+from scratch, by providing a rich set of libraries for commonly needed tasks, as well as a simple interface and
+logical structure to access these libraries. CodeIgniter lets you creatively focus on your project by
+minimizing the amount of code needed for a given task.</p>
+
+<h2>CodeIgniter is Free</h2>
+<p>CodeIgniter is licensed under an Apache/BSD-style open source license so you can use it however you please.
+For more information please read the <a href="../license.html">license agreement</a>.</p>
+
+<h2>CodeIgniter is Light Weight</h2>
+<p>Truly light weight.  The core system requires only a few very small libraries. This is in stark contrast to many frameworks that require significantly more resources.
+Additional libraries are loaded dynamically upon request, based on your needs for a given process, so the base system
+is very lean and quite fast.
+</p>
+
+<h2>CodeIgniter is Fast</h2>
+<p>Really fast. We challenge you to find a framework that has better performance than CodeIgniter.</p>
+
+
+<h2>CodeIgniter Uses M-V-C</h2>
+<p>CodeIgniter uses the Model-View-Controller approach, which allows great separation between logic and presentation.
+This is particularly good for projects in which designers are working with your template files, as the code these file contain will be minimized. We describe MVC in more detail on its own page.</p>
+
+<h2>CodeIgniter Generates Clean URLs</h2>
+<p>The URLs generated by CodeIgniter are clean and search-engine friendly.  Rather than using the standard "query string"
+approach to URLs that is synonymous with dynamic systems, CodeIgniter uses a segment-based approach:</p>
+
+<code>example.com/<var>news</var>/<dfn>article</dfn>/<samp>345</samp></code>
+
+<p>Note: By default the index.php file is included in the URL but it can be removed using a simple .htaccess file.</p>
+
+<h2>CodeIgniter Packs a Punch</h2>
+<p>CodeIgniter comes with  full-range of libraries that enable the most commonly needed web development tasks,
+like accessing a database, sending email, validating form data, maintaining sessions, manipulating images, working with XML-RPC data and
+much more.</p>
+
+<h2>CodeIgniter is Extensible</h2>
+<p>The system can be easily extended through the use of your own libraries, helpers, or through class extensions or system hooks.</p>
+
+
+<h2>CodeIgniter Does Not Require a Template Engine</h2>
+<p>Although CodeIgniter <em>does</em> come with a simple template parser that can be optionally used, it does not force you to use one.
+
+Template engines simply can not match the performance of native PHP, and the syntax that must be learned to use a template
+engine is usually only marginally easier than learning the basics of PHP.  Consider this block of PHP code:</p>
+
+<code>&lt;ul><br />
+<br />
+&lt;?php foreach ($addressbook as $name):?><br />
+<br />
+&lt;li>&lt;?=$name?>&lt;/li><br />
+<br />
+&lt;?php endforeach; ?><br />
+<br />
+&lt;/ul></code>
+
+<p>Contrast this with the pseudo-code used by a template engine:</p>
+
+<code>&lt;ul><br />
+<br />
+{foreach from=$addressbook item="name"}<br />
+<br />
+&lt;li>{$name}&lt;/li><br />
+<br />
+{/foreach}<br />
+<br />
+&lt;/ul></code>
+
+<p>Yes, the template engine example is a bit cleaner, but it comes at the price of performance, as the pseudo-code must be converted
+back into PHP to run. Since one of our goals is <em>maximum performance</em>, we opted to not require the use of a template engine.</p>
+
+
+<h2>CodeIgniter is Thoroughly Documented</h2>
+<p>Programmers love to code and hate to write documentation.  We're no different, of course, but
+since documentation is <strong>as important</strong> as the code itself,
+we are committed to doing it. Our source code is extremely clean and well commented as well.</p>
+
+
+<h2>CodeIgniter has a Friendly Community of Users</h2>
+
+<p>Our growing community of users can be seen actively participating in our <a href="http://codeigniter.com/forums/">Community Forums</a>.</p>
+
+
+</div>
+<!-- END CONTENT -->
+
+
+<div id="footer">
+<p>
+Previous Topic:&nbsp;&nbsp;<a href="getting_started.html">Getting Started</a>
+&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+<a href="#top">Top of Page</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+<a href="../index.html">User Guide Home</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+Next Topic:&nbsp;&nbsp;<a href="cheatsheets.html">CodeIgniter Cheatsheets</a>
+</p>
+<p><a href="http://codeigniter.com">CodeIgniter</a> &nbsp;&middot;&nbsp; Copyright &#169; 2006 - 2011 &nbsp;&middot;&nbsp; <a href="http://ellislab.com/">EllisLab, Inc.</a></p>
+</div>
+
+</body>
+</html>
\ No newline at end of file
diff --git a/user_guide/overview/cheatsheets.html b/user_guide/overview/cheatsheets.html
new file mode 100755 (executable)
index 0000000..1c58c58
--- /dev/null
@@ -0,0 +1,83 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head>
+
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+<title>CodeIgniter Cheatsheets : CodeIgniter User Guide</title>
+
+<style type='text/css' media='all'>@import url('../userguide.css');</style>
+<link rel='stylesheet' type='text/css' media='all' href='../userguide.css' />
+
+<script type="text/javascript" src="../nav/nav.js"></script>
+<script type="text/javascript" src="../nav/prototype.lite.js"></script>
+<script type="text/javascript" src="../nav/moo.fx.js"></script>
+<script type="text/javascript" src="../nav/user_guide_menu.js"></script>
+
+<meta http-equiv='expires' content='-1' />
+<meta http-equiv= 'pragma' content='no-cache' />
+<meta name='robots' content='all' />
+<meta name='author' content='ExpressionEngine Dev Team' />
+<meta name='description' content='CodeIgniter User Guide' />
+
+</head>
+<body>
+
+<!-- START NAVIGATION -->
+<div id="nav"><div id="nav_inner"><script type="text/javascript">create_menu('../');</script></div></div>
+<div id="nav2"><a name="top"></a><a href="javascript:void(0);" onclick="myHeight.toggle();"><img src="../images/nav_toggle_darker.jpg" width="154" height="43" border="0" title="Toggle Table of Contents" alt="Toggle Table of Contents" /></a></div>
+<div id="masthead">
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td><h1>CodeIgniter User Guide Version 2.0.2</h1></td>
+<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
+</tr>
+</table>
+</div>
+<!-- END NAVIGATION -->
+
+
+<!-- START BREADCRUMB -->
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td id="breadcrumb">
+<a href="http://codeigniter.com/">CodeIgniter Home</a> &nbsp;&#8250;&nbsp;
+<a href="../index.html">User Guide Home</a> &nbsp;&#8250;&nbsp;
+CodeIgniter Cheatsheets
+</td>
+<td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="codeigniter.com/user_guide/" />Search User Guide&nbsp; <input type="text" class="input" style="width:200px;" name="q" id="q" size="31" maxlength="255" value="" />&nbsp;<input type="submit" class="submit" name="sa" value="Go" /></form></td>
+</tr>
+</table>
+<!-- END BREADCRUMB -->
+
+<br clear="all" />
+
+
+<!-- START CONTENT -->
+<div id="content">
+
+<h1>CodeIgniter Cheatsheets</h1>
+
+<h2>Library Reference</h2>
+
+<div><a href="../images/codeigniter_1.7.1_library_reference.pdf"><img src="../images/codeigniter_1.7.1_library_reference.png" width="600" height="195" border="0" alt="CodeIgniter Library Reference" /></a></div>
+
+<h2>Helpers Reference</h2>
+<div><a href="../images/codeigniter_1.7.1_helper_reference.pdf"><img src="../images/codeigniter_1.7.1_helper_reference.png" width="600" height="196" border="0" alt="CodeIgniter Library Reference" /></a></div>
+
+</div>
+<!-- END CONTENT -->
+
+
+<div id="footer">
+<p>
+Previous Topic:&nbsp;&nbsp;<a href="at_a_glance.html">CodeIgniter at a Glance</a>
+&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+<a href="#top">Top of Page</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+<a href="../index.html">User Guide Home</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+Next Topic:&nbsp;&nbsp;<a href="features.html">CodeIgniter Features</a>
+</p>
+<p><a href="http://codeigniter.com">CodeIgniter</a> &nbsp;&middot;&nbsp; Copyright &#169; 2006 - 2011 &nbsp;&middot;&nbsp; <a href="http://ellislab.com/">EllisLab, Inc.</a></p>
+</div>
+
+</body>
+</html>
\ No newline at end of file
diff --git a/user_guide/overview/features.html b/user_guide/overview/features.html
new file mode 100755 (executable)
index 0000000..e20219e
--- /dev/null
@@ -0,0 +1,118 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head>
+
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+<title>CodeIgniter Features : CodeIgniter User Guide</title>
+
+<style type='text/css' media='all'>@import url('../userguide.css');</style>
+<link rel='stylesheet' type='text/css' media='all' href='../userguide.css' />
+
+<script type="text/javascript" src="../nav/nav.js"></script>
+<script type="text/javascript" src="../nav/prototype.lite.js"></script>
+<script type="text/javascript" src="../nav/moo.fx.js"></script>
+<script type="text/javascript" src="../nav/user_guide_menu.js"></script>
+
+<meta http-equiv='expires' content='-1' />
+<meta http-equiv= 'pragma' content='no-cache' />
+<meta name='robots' content='all' />
+<meta name='author' content='ExpressionEngine Dev Team' />
+<meta name='description' content='CodeIgniter User Guide' />
+
+</head>
+<body>
+
+<!-- START NAVIGATION -->
+<div id="nav"><div id="nav_inner"><script type="text/javascript">create_menu('../');</script></div></div>
+<div id="nav2"><a name="top"></a><a href="javascript:void(0);" onclick="myHeight.toggle();"><img src="../images/nav_toggle_darker.jpg" width="154" height="43" border="0" title="Toggle Table of Contents" alt="Toggle Table of Contents" /></a></div>
+<div id="masthead">
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td><h1>CodeIgniter User Guide Version 2.0.2</h1></td>
+<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
+</tr>
+</table>
+</div>
+<!-- END NAVIGATION -->
+
+
+<!-- START BREADCRUMB -->
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td id="breadcrumb">
+<a href="http://codeigniter.com/">CodeIgniter Home</a> &nbsp;&#8250;&nbsp;
+<a href="../index.html">User Guide Home</a> &nbsp;&#8250;&nbsp;
+Features
+</td>
+<td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="codeigniter.com/user_guide/" />Search User Guide&nbsp; <input type="text" class="input" style="width:200px;" name="q" id="q" size="31" maxlength="255" value="" />&nbsp;<input type="submit" class="submit" name="sa" value="Go" /></form></td>
+</tr>
+</table>
+<!-- END BREADCRUMB -->
+
+<br clear="all" />
+
+
+<!-- START CONTENT -->
+<div id="content">
+
+
+<h1>CodeIgniter Features</h1>
+
+<p>Features in and of themselves are a very poor way to judge an application since they tell you nothing
+about the user experience, or how intuitively or intelligently it is designed.  Features
+don't reveal anything about the quality of the code, or the performance, or the attention to detail, or security practices.
+The only way to really judge an app is to try it and get to know the code. <a href="../installation/">Installing</a>
+CodeIgniter is child's play so we encourage you to do just that.  In the mean time here's a list of CodeIgniter's main features.</p>
+
+<ul>
+<li>Model-View-Controller Based System</li>
+<li>Extremely Light Weight</li>
+<li>Full Featured database classes with support for several platforms.</li>
+<li>Active Record Database Support</li>
+<li>Form and Data Validation</li>
+<li>Security and XSS Filtering</li>
+<li>Session Management</li>
+<li>Email Sending Class. Supports Attachments, HTML/Text email, multiple protocols (sendmail, SMTP, and Mail) and more.</li>
+<li>Image Manipulation Library (cropping, resizing, rotating, etc.).  Supports GD, ImageMagick, and NetPBM</li>
+<li>File Uploading Class</li>
+<li>FTP Class</li>
+<li>Localization</li>
+<li>Pagination</li>
+<li>Data Encryption</li>
+<li>Benchmarking</li>
+<li>Full Page Caching</li>
+<li>Error Logging</li>
+<li>Application Profiling</li>
+<li>Calendaring Class</li>
+<li>User Agent Class</li>
+<li>Zip Encoding Class</li>
+<li>Template Engine Class</li>
+<li>Trackback Class</li>
+<li>XML-RPC Library</li>
+<li>Unit Testing Class</li>
+<li>Search-engine Friendly URLs</li>
+<li>Flexible URI Routing</li>
+<li>Support for Hooks and Class Extensions</li>
+<li>Large library of "helper" functions</li>
+</ul>
+
+
+
+
+</div>
+<!-- END CONTENT -->
+
+
+<div id="footer">
+<p>
+Previous Topic:&nbsp;&nbsp;<a href="cheatsheets.html">CodeIgniter Cheatsheets</a>
+&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+<a href="#top">Top of Page</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+<a href="../index.html">User Guide Home</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+Next Topic:&nbsp;&nbsp;<a href="appflow.html">Application Flow Chart</a>
+</p>
+<p><a href="http://codeigniter.com">CodeIgniter</a> &nbsp;&middot;&nbsp; Copyright &#169; 2006 - 2011 &nbsp;&middot;&nbsp; <a href="http://ellislab.com/">EllisLab, Inc.</a></p>
+</div>
+
+</body>
+</html>
\ No newline at end of file
diff --git a/user_guide/overview/getting_started.html b/user_guide/overview/getting_started.html
new file mode 100755 (executable)
index 0000000..f120913
--- /dev/null
@@ -0,0 +1,92 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head>
+
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+<title>Getting Started With CodeIgniter : CodeIgniter User Guide</title>
+
+<style type='text/css' media='all'>@import url('../userguide.css');</style>
+<link rel='stylesheet' type='text/css' media='all' href='../userguide.css' />
+
+<script type="text/javascript" src="../nav/nav.js"></script>
+<script type="text/javascript" src="../nav/prototype.lite.js"></script>
+<script type="text/javascript" src="../nav/moo.fx.js"></script>
+<script type="text/javascript" src="../nav/user_guide_menu.js"></script>
+
+<meta http-equiv='expires' content='-1' />
+<meta http-equiv= 'pragma' content='no-cache' />
+<meta name='robots' content='all' />
+<meta name='author' content='ExpressionEngine Dev Team' />
+<meta name='description' content='CodeIgniter User Guide' />
+
+</head>
+<body>
+
+<!-- START NAVIGATION -->
+<div id="nav"><div id="nav_inner"><script type="text/javascript">create_menu('../');</script></div></div>
+<div id="nav2"><a name="top"></a><a href="javascript:void(0);" onclick="myHeight.toggle();"><img src="../images/nav_toggle_darker.jpg" width="154" height="43" border="0" title="Toggle Table of Contents" alt="Toggle Table of Contents" /></a></div>
+<div id="masthead">
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td><h1>CodeIgniter User Guide Version 2.0.2</h1></td>
+<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
+</tr>
+</table>
+</div>
+<!-- END NAVIGATION -->
+
+
+<!-- START BREADCRUMB -->
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td id="breadcrumb">
+<a href="http://codeigniter.com/">CodeIgniter Home</a> &nbsp;&#8250;&nbsp;
+<a href="../index.html">User Guide Home</a> &nbsp;&#8250;&nbsp;
+Getting Started
+</td>
+<td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="codeigniter.com/user_guide/" />Search User Guide&nbsp; <input type="text" class="input" style="width:200px;" name="q" id="q" size="31" maxlength="255" value="" />&nbsp;<input type="submit" class="submit" name="sa" value="Go" /></form></td>
+</tr>
+</table>
+<!-- END BREADCRUMB -->
+
+<br clear="all" />
+
+
+<!-- START CONTENT -->
+<div id="content">
+
+<h1>Getting Started With CodeIgniter</h1>
+
+<p>Any software application requires some effort to learn.  We've done our best to minimize the learning
+curve while making the process as enjoyable as possible.
+</p>
+
+<p>The first step is to <a href="../installation/index.html">install</a> CodeIgniter, then read
+all the topics in the <strong>Introduction</strong> section of the Table of Contents.</p>
+
+<p>Next, read each of the <strong>General Topics</strong> pages in order.
+Each topic builds on the previous one, and includes code examples that you are encouraged to try.</p>
+
+<p>Once you understand the basics you'll be ready to explore the <strong>Class Reference</strong> and
+<strong>Helper Reference</strong> pages to learn to utilize the native libraries and helper files.</p>
+
+<p>Feel free to take advantage of our <a href="http://codeigniter.com/forums/">Community Forums</a>
+if you have questions or problems, and
+our <a href="http://codeigniter.com/wiki/">Wiki</a> to see code examples posted by other users.</p>
+
+
+</div>
+<!-- END CONTENT -->
+
+
+<div id="footer">
+<p>
+<a href="#top">Top of Page</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+<a href="../index.html">User Guide Home</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+Next Topic:&nbsp;&nbsp;<a href="at_a_glance.html">CodeIgniter At a Glance</a>
+</p>
+<p><a href="http://codeigniter.com">CodeIgniter</a> &nbsp;&middot;&nbsp; Copyright &#169; 2006 - 2011 &nbsp;&middot;&nbsp; <a href="http://ellislab.com/">EllisLab, Inc.</a></p>
+</div>
+
+</body>
+</html>
\ No newline at end of file
diff --git a/user_guide/overview/goals.html b/user_guide/overview/goals.html
new file mode 100755 (executable)
index 0000000..754ecaa
--- /dev/null
@@ -0,0 +1,98 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head>
+
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+<title>Design and Architectural Goals : CodeIgniter User Guide</title>
+
+<style type='text/css' media='all'>@import url('../userguide.css');</style>
+<link rel='stylesheet' type='text/css' media='all' href='../userguide.css' />
+
+<script type="text/javascript" src="../nav/nav.js"></script>
+<script type="text/javascript" src="../nav/prototype.lite.js"></script>
+<script type="text/javascript" src="../nav/moo.fx.js"></script>
+<script type="text/javascript" src="../nav/user_guide_menu.js"></script>
+
+<meta http-equiv='expires' content='-1' />
+<meta http-equiv= 'pragma' content='no-cache' />
+<meta name='robots' content='all' />
+<meta name='author' content='ExpressionEngine Dev Team' />
+<meta name='description' content='CodeIgniter User Guide' />
+
+</head>
+<body>
+
+<!-- START NAVIGATION -->
+<div id="nav"><div id="nav_inner"><script type="text/javascript">create_menu('../');</script></div></div>
+<div id="nav2"><a name="top"></a><a href="javascript:void(0);" onclick="myHeight.toggle();"><img src="../images/nav_toggle_darker.jpg" width="154" height="43" border="0" title="Toggle Table of Contents" alt="Toggle Table of Contents" /></a></div>
+<div id="masthead">
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td><h1>CodeIgniter User Guide Version 2.0.2</h1></td>
+<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
+</tr>
+</table>
+</div>
+<!-- END NAVIGATION -->
+
+
+<!-- START BREADCRUMB -->
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td id="breadcrumb">
+<a href="http://codeigniter.com/">CodeIgniter Home</a> &nbsp;&#8250;&nbsp;
+<a href="../index.html">User Guide Home</a> &nbsp;&#8250;&nbsp;
+Goals
+</td>
+<td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="codeigniter.com/user_guide/" />Search User Guide&nbsp; <input type="text" class="input" style="width:200px;" name="q" id="q" size="31" maxlength="255" value="" />&nbsp;<input type="submit" class="submit" name="sa" value="Go" /></form></td>
+</tr>
+</table>
+<!-- END BREADCRUMB -->
+
+<br clear="all" />
+
+
+<!-- START CONTENT -->
+<div id="content">
+
+
+
+<h2>Design and Architectural Goals</h2>
+
+<p>Our goal for CodeIgniter is <dfn>maximum performance, capability, and flexibility in the smallest, lightest possible package</dfn>.</p>
+
+<p>To meet this goal we are committed to benchmarking, re-factoring, and simplifying at every step of the development process,
+rejecting anything that doesn't further the stated objective.</p>
+
+<p>From a technical and architectural standpoint, CodeIgniter was created with the following objectives:</p>
+
+<ul>
+<li><strong>Dynamic Instantiation.</strong>  In CodeIgniter, components are loaded and routines executed only when requested, rather than globally.  No assumptions are made by the system regarding what may be needed beyond the minimal core resources, so the system is very light-weight by default.  The events, as triggered by the HTTP request, and the controllers and views you design will determine what is invoked.</li>
+<li><strong>Loose Coupling.</strong>  Coupling is the degree to which components of a system rely on each other.  The less components depend on each other the more reusable and flexible the system becomes. Our goal was a very loosely coupled system.</li>
+<li><strong>Component Singularity.</strong>  Singularity is the degree to which components have a narrowly focused purpose.  In CodeIgniter, each class and its functions are highly autonomous in order to allow maximum usefulness.</li>
+</ul>
+
+<p>CodeIgniter is a dynamically instantiated, loosely coupled system with high component singularity. It strives for simplicity, flexibility, and high performance in a small footprint package.</p>
+
+
+
+
+
+
+</div>
+<!-- END CONTENT -->
+
+
+<div id="footer">
+<p>
+Previous Topic:&nbsp;&nbsp;<a href="mvc.html">Model-View-Controller</a>
+&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+<a href="#top">Top of Page</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+<a href="../index.html">User Guide Home</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+Next Topic:&nbsp;&nbsp;<a href="./getting_started.html">Getting Started</a>
+</p>
+<p><a href="http://codeigniter.com">CodeIgniter</a> &nbsp;&middot;&nbsp; Copyright &#169; 2006 - 2011 &nbsp;&middot;&nbsp; <a href="http://ellislab.com/">EllisLab, Inc.</a></p>
+</div>
+
+</body>
+</html>
\ No newline at end of file
diff --git a/user_guide/overview/index.html b/user_guide/overview/index.html
new file mode 100755 (executable)
index 0000000..bbe3e36
--- /dev/null
@@ -0,0 +1,84 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head>
+
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+<title>CodeIgniter Overview : CodeIgniter User Guide</title>
+
+<style type='text/css' media='all'>@import url('../userguide.css');</style>
+<link rel='stylesheet' type='text/css' media='all' href='../userguide.css' />
+
+<script type="text/javascript" src="../nav/nav.js"></script>
+<script type="text/javascript" src="../nav/prototype.lite.js"></script>
+<script type="text/javascript" src="../nav/moo.fx.js"></script>
+<script type="text/javascript" src="../nav/user_guide_menu.js"></script>
+
+<meta http-equiv='expires' content='-1' />
+<meta http-equiv= 'pragma' content='no-cache' />
+<meta name='robots' content='all' />
+<meta name='author' content='ExpressionEngine Dev Team' />
+<meta name='description' content='CodeIgniter User Guide' />
+
+</head>
+<body>
+
+<!-- START NAVIGATION -->
+<div id="nav"><div id="nav_inner"><script type="text/javascript">create_menu('../');</script></div></div>
+<div id="nav2"><a name="top"></a><a href="javascript:void(0);" onclick="myHeight.toggle();"><img src="../images/nav_toggle_darker.jpg" width="154" height="43" border="0" title="Toggle Table of Contents" alt="Toggle Table of Contents" /></a></div>
+<div id="masthead">
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td><h1>CodeIgniter User Guide Version 2.0.2</h1></td>
+<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
+</tr>
+</table>
+</div>
+<!-- END NAVIGATION -->
+
+
+<!-- START BREADCRUMB -->
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td id="breadcrumb">
+<a href="http://codeigniter.com/">CodeIgniter Home</a> &nbsp;&#8250;&nbsp;
+<a href="../index.html">User Guide Home</a> &nbsp;&#8250;&nbsp;
+Introduction
+</td>
+<td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="codeigniter.com/user_guide/" />Search User Guide&nbsp; <input type="text" class="input" style="width:200px;" name="q" id="q" size="31" maxlength="255" value="" />&nbsp;<input type="submit" class="submit" name="sa" value="Go" /></form></td>
+</tr>
+</table>
+<!-- END BREADCRUMB -->
+
+<br clear="all" />
+
+
+<!-- START CONTENT -->
+<div id="content">
+
+<h1>CodeIgniter Overview</h1>
+
+<p>The following pages describe the broad concepts behind CodeIgniter:</p>
+
+       <ul>
+               <li><a href="at_a_glance.html">CodeIgniter at a Glance</a></li>
+               <li><a href="features.html">Supported Features</a></li>
+               <li><a href="appflow.html">Application Flow Chart</a></li>
+               <li><a href="mvc.html">Introduction to the Model-View-Controller</a></li>
+               <li><a href="goals.html">Design and Architectural Goals</a></li>
+               <li><a href="package.html">Package Description</a></li>
+       </ul>
+
+
+
+
+</div>
+<!-- END CONTENT -->
+
+
+<div id="footer">
+<p><a href="#top">Top of Page</a> &nbsp;&middot;&nbsp; <a href="../index.html">User Guide Home</a></p>
+<p><a href="http://codeigniter.com">CodeIgniter</a> &nbsp;&middot;&nbsp; Copyright &#169; 2006 - 2011 &nbsp;&middot;&nbsp; <a href="http://ellislab.com/">EllisLab, Inc.</a></p>
+</div>
+
+</body>
+</html>
\ No newline at end of file
diff --git a/user_guide/overview/mvc.html b/user_guide/overview/mvc.html
new file mode 100755 (executable)
index 0000000..91cf649
--- /dev/null
@@ -0,0 +1,100 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head>
+
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+<title>Model-View-Controller : CodeIgniter User Guide</title>
+
+<style type='text/css' media='all'>@import url('../userguide.css');</style>
+<link rel='stylesheet' type='text/css' media='all' href='../userguide.css' />
+
+<script type="text/javascript" src="../nav/nav.js"></script>
+<script type="text/javascript" src="../nav/prototype.lite.js"></script>
+<script type="text/javascript" src="../nav/moo.fx.js"></script>
+<script type="text/javascript" src="../nav/user_guide_menu.js"></script>
+
+<meta http-equiv='expires' content='-1' />
+<meta http-equiv= 'pragma' content='no-cache' />
+<meta name='robots' content='all' />
+<meta name='author' content='ExpressionEngine Dev Team' />
+<meta name='description' content='CodeIgniter User Guide' />
+
+</head>
+<body>
+
+<!-- START NAVIGATION -->
+<div id="nav"><div id="nav_inner"><script type="text/javascript">create_menu('../');</script></div></div>
+<div id="nav2"><a name="top"></a><a href="javascript:void(0);" onclick="myHeight.toggle();"><img src="../images/nav_toggle_darker.jpg" width="154" height="43" border="0" title="Toggle Table of Contents" alt="Toggle Table of Contents" /></a></div>
+<div id="masthead">
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td><h1>CodeIgniter User Guide Version 2.0.2</h1></td>
+<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
+</tr>
+</table>
+</div>
+<!-- END NAVIGATION -->
+
+
+<!-- START BREADCRUMB -->
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td id="breadcrumb">
+<a href="http://codeigniter.com/">CodeIgniter Home</a> &nbsp;&#8250;&nbsp;
+<a href="../index.html">User Guide Home</a> &nbsp;&#8250;&nbsp;
+MVC
+</td>
+<td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="codeigniter.com/user_guide/" />Search User Guide&nbsp; <input type="text" class="input" style="width:200px;" name="q" id="q" size="31" maxlength="255" value="" />&nbsp;<input type="submit" class="submit" name="sa" value="Go" /></form></td>
+</tr>
+</table>
+<!-- END BREADCRUMB -->
+
+<br clear="all" />
+
+
+<!-- START CONTENT -->
+<div id="content">
+
+
+<h1>Model-View-Controller</h1>
+
+<p>CodeIgniter is based on the Model-View-Controller development pattern.
+
+MVC is a software approach that separates application logic from presentation.  In practice, it permits your web pages to contain minimal scripting since the presentation is separate from the PHP scripting.</p>
+
+<ul>
+<li>The <strong>Model</strong> represents your data structures. Typically your model classes will contain functions that help you
+retrieve, insert, and update information in your  database.</li>
+<li>The <strong>View</strong> is the information that is being presented to a user.  A View will normally be a web page, but
+in CodeIgniter, a view can also be a page fragment like a header or footer. It can also be an RSS page, or any other type of "page".</li>
+<li>The <strong>Controller</strong> serves as an <em>intermediary</em> between the Model, the View,
+and any other resources needed to process the HTTP request and generate a web page.</li>
+
+</ul>
+
+<p>CodeIgniter has a fairly loose approach to MVC since Models are not required.
+If you don't need the added separation, or find that maintaining models requires more complexity than you
+want, you can ignore them and build your application minimally using Controllers and Views. CodeIgniter also
+enables you to incorporate your own existing scripts, or even develop core libraries for the system,
+ enabling you to work in a way that makes the most sense to you.</p>
+
+
+
+
+</div>
+<!-- END CONTENT -->
+
+
+<div id="footer">
+<p>
+Previous Topic:&nbsp;&nbsp;<a href="appflow.html">Application Flow Chart</a>
+&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+<a href="#top">Top of Page</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+<a href="../index.html">User Guide Home</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+Next Topic:&nbsp;&nbsp;<a href="goals.html">Architectural Goals</a>
+</p>
+<p><a href="http://codeigniter.com">CodeIgniter</a> &nbsp;&middot;&nbsp; Copyright &#169; 2006 - 2011 &nbsp;&middot;&nbsp; <a href="http://ellislab.com/">EllisLab, Inc.</a></p>
+</div>
+
+</body>
+</html>
\ No newline at end of file
diff --git a/user_guide/toc.html b/user_guide/toc.html
new file mode 100755 (executable)
index 0000000..90442cb
--- /dev/null
@@ -0,0 +1,218 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head>
+
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+<title>Table of Contents : CodeIgniter User Guide</title>
+
+<style type='text/css' media='all'>@import url('userguide.css');</style>
+<link rel='stylesheet' type='text/css' media='all' href='userguide.css' />
+
+<script type="text/javascript" src="nav/nav.js"></script>
+<script type="text/javascript" src="nav/prototype.lite.js"></script>
+<script type="text/javascript" src="nav/moo.fx.js"></script>
+<script type="text/javascript" src="nav/user_guide_menu.js"></script>
+
+<meta http-equiv='expires' content='-1' />
+<meta http-equiv= 'pragma' content='no-cache' />
+<meta name='robots' content='all' />
+<meta name='author' content='ExpressionEngine Dev Team' />
+<meta name='description' content='CodeIgniter User Guide' />
+
+</head>
+<body>
+
+
+<!-- START NAVIGATION -->
+<div id="nav"><div id="nav_inner"><script type="text/javascript">create_menu('null');</script></div></div>
+<div id="nav2"><a name="top"></a><a href="javascript:void(0);" onclick="myHeight.toggle();"><img src="images/nav_toggle_darker.jpg" width="154" height="43" border="0" title="Toggle Table of Contents" alt="Toggle Table of Contents" /></a></div>
+<div id="masthead">
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td><h1>CodeIgniter User Guide Version 2.0.2</h1></td>
+</tr>
+</table>
+</div>
+<!-- END NAVIGATION -->
+
+
+<!-- START BREADCRUMB -->
+
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td id="breadcrumb">
+<a href="http://codeigniter.com/">CodeIgniter Home</a> &nbsp;&#8250;&nbsp;
+<a href="index.html">User Guide Home</a> &nbsp;&#8250;&nbsp;
+Table of Contents
+</td>
+<td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="codeigniter.com/user_guide/" />Search User Guide&nbsp; <input type="text" class="input" style="width:200px;" name="q" id="q" size="31" maxlength="255" value="" />&nbsp;<input type="submit" class="submit" name="sa" value="Go" /></form></td>
+</tr>
+</table>
+<!-- END BREADCRUMB -->
+
+<br clear="all" />
+
+<!-- START CONTENT -->
+<div id="content">
+
+
+<h1>Table of Contents</h1>
+
+<table cellpadding="0" cellspacing="10" border="0" width="100%">
+<tr>
+<td valign="top" width="25%">
+
+<h3>Basic Info</h3>
+<ul>
+       <li><a href="./general/requirements.html">Server Requirements</a></li>
+       <li><a href="license.html">License Agreement</a></li>
+       <li><a href="changelog.html">Change Log</a></li>
+       <li><a href="./general/credits.html">Credits</a></li>
+</ul>
+
+<h3>Installation</h3>
+<ul>
+       <li><a href="./installation/downloads.html">Downloading CodeIgniter </a></li>
+       <li><a href="./installation/index.html">Installation Instructions</a></li>
+       <li><a href="./installation/upgrading.html">Upgrading from a Previous Version</a></li>
+       <li><a href="./installation/troubleshooting.html">Troubleshooting</a></li>
+</ul>
+
+<h3>Introduction</h3>
+<ul>
+       <li><a href="./overview/getting_started.html">Getting Started</a></li>
+       <li><a href="./overview/at_a_glance.html">CodeIgniter at a Glance</a></li>
+       <li><a href="./overview/cheatsheets.html">CodeIgniter Cheatsheets</a></li>
+       <li><a href="./overview/features.html">Supported Features</a></li>
+       <li><a href="./overview/appflow.html">Application Flow Chart</a></li>
+       <li><a href="./overview/mvc.html">Model-View-Controller</a></li>
+       <li><a href="./overview/goals.html">Architectural Goals</a></li>
+</ul>
+
+
+</td>
+<td valign="top" width="25%">
+
+<h3>General Topics</h3>
+<ul>
+       <li><a href="./general/urls.html">CodeIgniter URLs</a></li>
+       <li><a href="./general/controllers.html">Controllers</a></li>
+       <li><a href="./general/reserved_names.html">Reserved Names</a></li>
+       <li><a href="./general/views.html">Views</a></li>
+       <li><a href="./general/models.html">Models</a></li>
+       <li><a href="./general/helpers.html">Helpers</a></li>
+       <li><a href="./general/libraries.html">Using CodeIgniter Libraries</a></li>
+       <li><a href="./general/creating_libraries.html">Creating Your Own Libraries</a></li>
+       <li><a href="./general/core_classes.html">Creating Core Classes</a></li>
+       <li><a href="./general/hooks.html">Hooks - Extending the Core</a></li>
+       <li><a href="./general/autoloader.html">Auto-loading Resources</a></li>
+       <li><a href="./general/common_functions.html">Common Functions</a></li>
+       <li><a href="./general/routing.html">URI Routing</a></li>
+       <li><a href="./general/errors.html">Error Handling</a></li>
+       <li><a href="./general/caching.html">Caching</a></li>
+       <li><a href="./general/profiling.html">Profiling Your Application</a></li>
+       <li><a href="./general/cli.html">Running via the CLI</a></li>
+       <li><a href="./general/managing_apps.html">Managing Applications</a></li>
+       <li><a href="'./general/environments.html">Handling Multiple Environments</a></li>
+       <li><a href="./general/alternative_php.html">Alternative PHP Syntax</a></li>
+       <li><a href="./general/security.html">Security</a></li>
+       <li><a href="./general/styleguide.html">PHP Style Guide</a></li>
+       <li><a href="./doc_style/index.html">Writing Documentation</a></li>
+</ul>
+
+<h3>Additional Resources</h3>
+
+<ul>
+<li><a href="http://codeigniter.com/forums/">Community Forums</a></li>
+<li><a href="http://codeigniter.com/wiki/">Community Wiki</a></li>
+</ul>
+
+</td>
+<td valign="top" width="25%">
+
+<h3>Class Reference</h3>
+<ul>
+<li><a href="./libraries/benchmark.html">Benchmarking Class</a></li>
+<li><a href="./libraries/calendar.html">Calendar Class</a></li>
+<li><a href="./libraries/cart.html">Cart Class</a></li>
+<li><a href="./libraries/config.html">Config Class</a></li>
+<li><a href="./libraries/email.html">Email Class</a></li>
+<li><a href="./libraries/encryption.html">Encryption Class</a></li>
+<li><a href="./libraries/file_uploading.html">File Uploading Class</a></li>
+<li><a href="./libraries/form_validation.html">Form Validation Class</a></li>
+<li><a href="./libraries/ftp.html">FTP Class</a></li>
+<li><a href="./libraries/table.html">HTML Table Class</a></li>
+<li><a href="./libraries/image_lib.html">Image Manipulation Class</a></li>
+<li><a href="./libraries/input.html">Input Class</a></li>
+<li><a href="./libraries/javascript.html">Javascript Class</a></li>
+<li><a href="./libraries/loader.html">Loader Class</a></li>
+<li><a href="./libraries/language.html">Language Class</a></li>
+<li><a href="./libraries/output.html">Output Class</a></li>
+<li><a href="./libraries/pagination.html">Pagination Class</a></li>
+<li><a href="./libraries/security.html">Security Class</a></li>
+<li><a href="./libraries/sessions.html">Session Class</a></li>
+<li><a href="./libraries/trackback.html">Trackback Class</a></li>
+<li><a href="./libraries/parser.html">Template Parser Class</a></li>
+<li><a href="./libraries/typography.html">Typography Class</a></li>
+<li><a href="./libraries/unit_testing.html">Unit Testing Class</a></li>
+<li><a href="./libraries/uri.html">URI Class</a></li>
+<li><a href="./libraries/user_agent.html">User Agent Class</a></li>
+<li><a href="./libraries/xmlrpc.html">XML-RPC Class</a></li>
+<li><a href="./libraries/zip.html">Zip Encoding Class</a></li>
+</ul>
+
+
+</td>
+<td valign="top" width="25%">
+
+<h3>Driver Reference</h3>
+<ul>
+<li><a href="./libraries/caching.html">Caching Class</a></li>
+<li><a href="./database/index.html">Database Class</a></li>
+<li><a href="./libraries/javascript.html">Javascript Class</a></li>
+</ul>
+
+<h3>Helper Reference</h3>
+<ul>
+<li><a href="./helpers/array_helper.html">Array Helper</a></li>
+<li><a href="./helpers/captcha_helper.html">CAPTCHA Helper</a></li>
+<li><a href="./helpers/cookie_helper.html">Cookie Helper</a></li>
+<li><a href="./helpers/date_helper.html">Date Helper</a></li>
+<li><a href="./helpers/directory_helper.html">Directory Helper</a></li>
+<li><a href="./helpers/download_helper.html">Download Helper</a></li>
+<li><a href="./helpers/email_helper.html">Email Helper</a></li>
+<li><a href="./helpers/file_helper.html">File Helper</a></li>
+<li><a href="./helpers/form_helper.html">Form Helper</a></li>
+<li><a href="./helpers/html_helper.html">HTML Helper</a></li>
+<li><a href="./helpers/inflector_helper.html">Inflector Helper</a></li>
+<li><a href="./helpers/language_helper.html">Language Helper</a></li>
+<li><a href="./helpers/number_helper.html">Number Helper</a></li>
+<li><a href="./helpers/path_helper.html">Path Helper</a></li>
+<li><a href="./helpers/security_helper.html">Security Helper</a></li>
+<li><a href="./helpers/smiley_helper.html">Smiley Helper</a></li>
+<li><a href="./helpers/string_helper.html">String Helper</a></li>
+<li><a href="./helpers/text_helper.html">Text Helper</a></li>
+<li><a href="./helpers/typography_helper.html">Typography Helper</a></li>
+<li><a href="./helpers/url_helper.html">URL Helper</a></li>
+<li><a href="./helpers/xml_helper.html">XML Helper</a></li>
+</ul>
+
+
+
+
+</td>
+</tr>
+</table>
+
+</div>
+<!-- END CONTENT -->
+
+
+<div id="footer">
+<p><a href="#top">Top of Page</a></p>
+<p><a href="http://codeigniter.com">CodeIgniter</a> &nbsp;&middot;&nbsp; Copyright &#169; 2006 - 2011 &nbsp;&middot;&nbsp; <a href="http://ellislab.com/">EllisLab, Inc.</a></p>
+</div>
+
+
+</body>
+</html>
\ No newline at end of file
diff --git a/user_guide/userguide.css b/user_guide/userguide.css
new file mode 100755 (executable)
index 0000000..f93ff0d
--- /dev/null
@@ -0,0 +1,415 @@
+body {
+ margin: 0;
+ padding: 0;
+ font-family: Lucida Grande, Verdana, Geneva, Sans-serif;
+ font-size: 14px;
+ color: #333;
+ background-color: #fff;
+}
+
+a {
+ color: #0134c5;
+ background-color: transparent;
+ text-decoration: none;
+ font-weight: normal;
+ outline-style: none;
+}
+a:visited {
+ color: #0134c5;
+ background-color: transparent;
+ text-decoration: none;
+ outline-style: none;
+}
+a:hover {
+ color: #000;
+ text-decoration: none;
+ background-color: transparent;
+ outline-style: none;
+}
+
+#breadcrumb {
+ float: left;
+ background-color: transparent;
+ margin: 10px 0 0 42px;
+ padding: 0;
+ font-size: 10px;
+ color: #666;
+}
+#breadcrumb_right {
+ float: right;
+ width: 175px;
+ background-color: transparent;
+ padding: 8px 8px 3px 0;
+ text-align: right;
+ font-size: 10px;
+ color: #666;
+}
+#nav {
+ background-color: #494949;
+ margin: 0;
+ padding: 0;
+}
+#nav2 {
+ background: #fff url(images/nav_bg_darker.jpg) repeat-x left top;
+ padding: 0 310px 0 0;
+ margin: 0;
+ text-align: right;
+}
+#nav_inner {
+ background-color: transparent;
+ padding: 8px 12px 0 20px;
+ margin: 0;
+ font-family: Lucida Grande, Verdana, Geneva, Sans-serif;
+ font-size: 11px;
+}
+
+#nav_inner h3 {
+ font-size: 12px;
+ color: #fff;
+ margin: 0;
+ padding: 0;
+}
+
+#nav_inner .td_sep {
+ background: transparent url(images/nav_separator_darker.jpg) repeat-y left top;
+ width: 25%;
+ padding: 0 0 0 20px;
+}
+#nav_inner .td {
+ width: 25%;
+}
+#nav_inner p {
+ color: #eee;
+ background-color: transparent;
+ padding:0;
+ margin: 0 0 10px 0;
+}
+#nav_inner ul {
+ list-style-image: url(images/arrow.gif);
+ padding: 0 0 0 18px;
+ margin: 8px 0 12px 0;
+}
+#nav_inner li {
+ padding: 0;
+ margin: 0 0 4px 0;
+}
+
+#nav_inner a {
+ color: #eee;
+ background-color: transparent;
+ text-decoration: none;
+ font-weight: normal;
+ outline-style: none;
+}
+
+#nav_inner a:visited {
+ color: #eee;
+ background-color: transparent;
+ text-decoration: none;
+ outline-style: none;
+}
+
+#nav_inner a:hover {
+ color: #ccc;
+ text-decoration: none;
+ background-color: transparent;
+ outline-style: none;
+}
+
+#masthead {
+ margin: 0 40px 0 35px;
+ padding: 0 0 0 6px;
+ border-bottom: 1px solid #999;
+}
+
+#masthead h1 {
+background-color: transparent;
+color: #e13300;
+font-size: 18px;
+font-weight: normal;
+margin: 0;
+padding: 0 0 6px 0;
+}
+
+#searchbox {
+ background-color: transparent;
+ padding: 6px 40px 0 0;
+ text-align: right;
+ font-size: 10px;
+ color: #666;
+}
+
+#img_welcome {
+ border-bottom: 1px solid #D0D0D0;
+ margin: 0 40px 0 40px;
+ padding: 0;
+ text-align: center;
+}
+
+#content {
+ margin: 20px 40px 0 40px;
+ padding: 0;
+}
+
+#content p {
+ margin: 12px 20px 12px 0;
+}
+
+#content h1 {
+color: #e13300;
+border-bottom: 1px solid #666;
+background-color: transparent;
+font-weight: normal;
+font-size: 24px;
+margin: 0 0 20px 0;
+padding: 3px 0 7px 3px;
+}
+
+#content h2 {
+ background-color: transparent;
+ border-bottom: 1px solid #999;
+ color: #000;
+ font-size: 18px;
+ font-weight: bold;
+ margin: 28px 0 16px 0;
+ padding: 5px 0 6px 0;
+}
+
+#content h3 {
+ background-color: transparent;
+ color: #333;
+ font-size: 16px;
+ font-weight: bold;
+ margin: 16px 0 15px 0;
+ padding: 0 0 0 0;
+}
+
+#content h4 {
+ background-color: transparent;
+ color: #444;
+ font-size: 14px;
+ font-weight: bold;
+ margin: 22px 0 0 0;
+ padding: 0 0 0 0;
+}
+
+#content img {
+ margin: auto;
+ padding: 0;
+}
+
+#content code {
+ font-family: Monaco, Verdana, Sans-serif;
+ font-size: 12px;
+ background-color: #f9f9f9;
+ border: 1px solid #D0D0D0;
+ color: #002166;
+ display: block;
+ margin: 14px 0 14px 0;
+ padding: 12px 10px 12px 10px;
+}
+
+#content pre {
+ font-family: Monaco, Verdana, Sans-serif;
+ font-size: 12px;
+ background-color: #f9f9f9;
+ border: 1px solid #D0D0D0;
+ color: #002166;
+ display: block;
+ margin: 14px 0 14px 0;
+ padding: 12px 10px 12px 10px;
+}
+
+#content .path {
+ background-color: #EBF3EC;
+ border: 1px solid #99BC99;
+ color: #005702;
+ text-align: center;
+ margin: 0 0 14px 0;
+ padding: 5px 10px 5px 8px;
+}
+
+#content dfn {
+ font-family: Lucida Grande, Verdana, Geneva, Sans-serif;
+ color: #00620C;
+ font-weight: bold;
+ font-style: normal;
+}
+#content var {
+ font-family: Lucida Grande, Verdana, Geneva, Sans-serif;
+ color: #8F5B00;
+ font-weight: bold;
+ font-style: normal;
+}
+#content samp {
+ font-family: Lucida Grande, Verdana, Geneva, Sans-serif;
+ color: #480091;
+ font-weight: bold;
+ font-style: normal;
+}
+#content kbd {
+ font-family: Lucida Grande, Verdana, Geneva, Sans-serif;
+ color: #A70000;
+ font-weight: bold;
+ font-style: normal;
+}
+
+#content ul {
+ list-style-image: url(images/arrow.gif);
+ margin: 10px 0 12px 0;
+}
+
+li.reactor {
+ list-style-image: url(images/reactor-bullet.png);
+}
+#content li {
+ margin-bottom: 9px;
+}
+
+#content li p {
+ margin-left: 0;
+ margin-right: 0;
+}
+
+#content .tableborder {
+ border: 1px solid #999;
+}
+#content th {
+ font-weight: bold;
+ text-align: left;
+ font-size: 12px;
+ background-color: #666;
+ color: #fff;
+ padding: 4px;
+}
+
+#content .td {
+ font-weight: normal;
+ font-size: 12px;
+ padding: 6px;
+ background-color: #f3f3f3;
+}
+
+#content .tdpackage {
+ font-weight: normal;
+ font-size: 12px;
+}
+
+#content .important {
+ background: #FBE6F2;
+ border: 1px solid #D893A1;
+ color: #333;
+ margin: 10px 0 5px 0;
+ padding: 10px;
+}
+
+#content .important p {
+ margin: 6px 0 8px 0;
+ padding: 0;
+}
+
+#content .important .leftpad {
+ margin: 6px 0 8px 0;
+ padding-left: 20px;
+}
+
+#content .critical {
+ background: #FBE6F2;
+ border: 1px solid #E68F8F;
+ color: #333;
+ margin: 10px 0 5px 0;
+ padding: 10px;
+}
+
+#content .critical p {
+ margin: 5px 0 6px 0;
+ padding: 0;
+}
+
+
+#footer {
+background-color: transparent;
+font-size: 10px;
+padding: 16px 0 15px 0;
+margin: 20px 0 0 0;
+text-align: center;
+}
+
+#footer p {
+ font-size: 10px;
+ color: #999;
+ text-align: center;
+}
+#footer address {
+ font-style: normal;
+}
+
+.center {
+ text-align: center;
+}
+
+img {
+ padding:0;
+ border: 0;
+ margin: 0;
+}
+
+.nopad {
+ padding:0;
+ border: 0;
+ margin: 0;
+}
+
+
+form {
+ margin: 0;
+ padding: 0;
+}
+
+.input {
+ font-family: Lucida Grande, Verdana, Geneva, Sans-serif;
+ font-size: 11px;
+ color: #333;
+ border: 1px solid #B3B4BD;
+ width: 100%;
+ font-size: 11px;
+ height: 1.5em;
+ padding: 0;
+ margin: 0;
+}
+
+.textarea {
+ font-family: Lucida Grande, Verdana, Geneva, Sans-serif;
+ font-size: 14px;
+ color: #143270;
+ background-color: #f9f9f9;
+ border: 1px solid #B3B4BD;
+ width: 100%;
+ padding: 6px;
+ margin: 0;
+}
+
+.select {
+ background-color: #fff;
+ font-size:  11px;
+ font-weight: normal;
+ color: #333;
+ padding: 0;
+ margin: 0 0 3px 0;
+}
+
+.checkbox {
+ background-color: transparent;
+ padding: 0;
+ border: 0;
+}
+
+.submit {
+ background-color: #000;
+ color: #fff;
+ font-weight: normal;
+ font-size: 10px;
+ border: 1px solid #fff;
+ margin: 0;
+ padding: 1px 5px 2px 5px;
+}
\ No newline at end of file