Merged CodeIgniter Core changes and integrated rob1's secure cookie change into my secure cookie change.
diff --git a/application/config/config.php b/application/config/config.php
index 26b31e3..1ec6543 100644
--- a/application/config/config.php
+++ b/application/config/config.php
@@ -10,8 +10,11 @@
 |
 |	http://example.com/
 |
+| If this is not set then CodeIgniter will guess the protocol, domain and
+| path to your installation.
+|
 */
-$config['base_url']	= "http://example.com/";
+$config['base_url']	= '';
 
 /*
 |--------------------------------------------------------------------------
@@ -23,7 +26,7 @@
 | variable so that it is blank.
 |
 */
-$config['index_page'] = "index.php";
+$config['index_page'] = 'index.php';
 
 /*
 |--------------------------------------------------------------------------
@@ -31,7 +34,7 @@
 |--------------------------------------------------------------------------
 |
 | This item determines which server global should be used to retrieve the
-| URI string.  The default setting of "AUTO" works for most servers.
+| 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
@@ -41,7 +44,7 @@
 | 'ORIG_PATH_INFO'	Uses the ORIG_PATH_INFO
 |
 */
-$config['uri_protocol']	= "AUTO";
+$config['uri_protocol']	= 'AUTO';
 
 /*
 |--------------------------------------------------------------------------
@@ -54,7 +57,7 @@
 | http://codeigniter.com/user_guide/general/urls.html
 */
 
-$config['url_suffix'] = "";
+$config['url_suffix'] = '';
 
 /*
 |--------------------------------------------------------------------------
@@ -66,7 +69,7 @@
 | than english.
 |
 */
-$config['language']	= "english";
+$config['language']	= 'english';
 
 /*
 |--------------------------------------------------------------------------
@@ -77,14 +80,14 @@
 | that require a character set to be provided.
 |
 */
-$config['charset'] = "UTF-8";
+$config['charset'] = 'UTF-8';
 
 /*
 |--------------------------------------------------------------------------
 | Enable/Disable System Hooks
 |--------------------------------------------------------------------------
 |
-| If you would like to use the "hooks" feature you must enable it by
+| 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.
 |
 */
@@ -134,12 +137,15 @@
 | 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
+| 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
 |
@@ -148,6 +154,7 @@
 | use segment based URLs.
 |
 */
+$config['allow_get_array']		= TRUE;
 $config['enable_query_strings'] = FALSE;
 $config['controller_trigger']	= 'c';
 $config['function_trigger']		= 'm';
@@ -181,7 +188,7 @@
 |--------------------------------------------------------------------------
 |
 | Leave this BLANK unless you would like to set something other than the default
-| system/logs/ folder.  Use a full server path with trailing slash.
+| application/logs/ folder. Use a full server path with trailing slash.
 |
 */
 $config['log_path'] = '';
@@ -217,7 +224,7 @@
 | MUST set an encryption key.  See the user guide for info.
 |
 */
-$config['encryption_key'] = "";
+$config['encryption_key'] = '';
 
 /*
 |--------------------------------------------------------------------------
@@ -281,9 +288,15 @@
 | Enables a CSRF cookie token to be set. When set to TRUE, token will be
 | checked on a submitted form. If you are accepting user data, it is strongly
 | recommended CSRF protection be enabled.
+|
+| 'csrf_token_name' = The token name
+| 'csrf_cookie_name' = The cookie name
+| 'csrf_expire' = The number in seconds the token should expire.
 */
 $config['csrf_protection'] = FALSE;
-
+$config['csrf_token_name'] = 'csrf_test_name';
+$config['csrf_cookie_name'] = 'csrf_cookie_name';
+$config['csrf_expire'] = 7200;
 
 /*
 |--------------------------------------------------------------------------
@@ -299,7 +312,7 @@
 | 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.
+| by the output class.  Do not 'echo' any values with compression enabled.
 |
 */
 $config['compress_output'] = FALSE;
@@ -309,9 +322,9 @@
 | 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
+| 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.
 |
 */
@@ -346,4 +359,4 @@
 
 
 /* End of file config.php */
-/* Location: ./application/config/config.php */
\ No newline at end of file
+/* Location: ./application/config/config.php */
diff --git a/application/config/foreign_chars.php b/application/config/foreign_chars.php
index e106ad8..14b0d73 100644
--- a/application/config/foreign_chars.php
+++ b/application/config/foreign_chars.php
@@ -7,58 +7,58 @@
 | conversion used by the Text helper
 |
 */
-$foreign_characters = array('223'	=>	"ss", // ß
-							'224'	=>	"a",
-							'225'	=>	"a",
-							'226'	=>	"a",
-							'229'	=>	"a",
-							'227'	=>	"ae",
-							'230'	=>	"ae",
-							'228'	=>	"ae",
-							'231'	=>	"c",
-							'232'	=>	"e",  // è
-							'233'	=>	"e",  // é
-							'234'	=>	"e",  // ê
-							'235'	=>	"e",  // ë
-							'236'	=>	"i",
-							'237'	=>	"i",
-							'238'	=>	"i",
-							'239'	=>	"i",
-							'241'	=>	"n",
-							'242'	=>	"o",
-							'243'	=>	"o",
-							'244'	=>	"o",
-							'245'	=>	"o",
-							'246'	=>	"oe", // ö
-							'249'	=>	"u",
-							'250'	=>	"u",
-							'251'	=>	"u",
-							'252'	=>	"ue", // ü
-							'255'	=>	"y",
-							'257'	=>	"aa",
-							'269'	=>	"ch",
-							'275'	=>	"ee",
-							'291'	=>	"gj",
-							'299'	=>	"ii",
-							'311'	=>	"kj",
-							'316'	=>	"lj",
-							'326'	=>	"nj",
-							'353'	=>	"sh",
-							'363'	=>	"uu",
-							'382'	=>	"zh",
-							'256'	=>	"aa",
-							'268'	=>	"ch",
-							'274'	=>	"ee",
-							'290'	=>	"gj",
-							'298'	=>	"ii",
-							'310'	=>	"kj",
-							'315'	=>	"lj",
-							'325'	=>	"nj",
-							'352'	=>	"sh",
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	'/ś|ŝ|ş|š|ſ/' => '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/mimes.php b/application/config/mimes.php
index 146d3f9..58eea5f 100644
--- a/application/config/mimes.php
+++ b/application/config/mimes.php
@@ -10,7 +10,7 @@
 
 $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/csv', 'application/csv', 'application/excel', 'application/vnd.msexcel'),
+				'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',
@@ -56,7 +56,7 @@
 				'midi'	=>	'audio/midi',
 				'mpga'	=>	'audio/mpeg',
 				'mp2'	=>	'audio/mpeg',
-				'mp3'	=>	array('audio/mpeg', 'audio/mpg', 'audio/mpeg3'),
+				'mp3'	=>	array('audio/mpeg', 'audio/mpg', 'audio/mpeg3', 'audio/mp3'),
 				'aif'	=>	'audio/x-aiff',
 				'aiff'	=>	'audio/x-aiff',
 				'aifc'	=>	'audio/x-aiff',
diff --git a/application/config/routes.php b/application/config/routes.php
index 614462f..5f9a583 100644
--- a/application/config/routes.php
+++ b/application/config/routes.php
@@ -23,16 +23,23 @@
 | RESERVED ROUTES
 | -------------------------------------------------------------------------
 |
-| There is one 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 */
diff --git a/application/config/user_agents.php b/application/config/user_agents.php
index 985deed..e2d3c3a 100644
--- a/application/config/user_agents.php
+++ b/application/config/user_agents.php
@@ -94,6 +94,7 @@
 					'nokia'				=> "Nokia",
 					'palm'				=> "Palm",
 					'iphone'			=> "Apple iPhone",
+					'ipad'				=> "iPad",
 					'ipod'				=> "Apple iPod Touch",
 					'sony'				=> "Sony Ericsson",
 					'ericsson'			=> "Sony Ericsson",
diff --git a/application/controllers/migrate.php b/application/controllers/migrate.php
new file mode 100644
index 0000000..e5442e7
--- /dev/null
+++ b/application/controllers/migrate.php
@@ -0,0 +1,40 @@
+<?php
+class Migrate extends CI_Controller
+{
+	function __construct()
+	{
+		parent::__construct();
+		
+		$this->load->library('migration');
+
+		/** VERY IMPORTANT - only turn this on when you need it. */
+//		show_error('Access to this controller is blocked, turn me on when you need me.');
+	}
+
+	// Install up to the most up-to-date version.
+	function install()
+	{
+		if ( ! $this->migration->current())
+		{
+			show_error($this->migration->error);
+			exit;
+		}
+
+		echo "<br />Migration Successful<br />";
+	}
+
+	// This will migrate up to the configed migration version
+	function version($id = NULL)
+	{
+		// No $id supplied? Use the config version
+		$id OR $id = $this->config->item('migration_version');
+
+		if ( ! $this->migration->version($id))
+		{
+			show_error($this->migration->error);
+			exit;
+		}
+
+		echo "<br />Migration Successful<br />";
+	}
+}
diff --git a/application/migrations/001_Create_accounts.php b/application/migrations/001_Create_accounts.php
new file mode 100644
index 0000000..4b2fc93
--- /dev/null
+++ b/application/migrations/001_Create_accounts.php
@@ -0,0 +1,32 @@
+<?php defined('BASEPATH') OR exit('No direct script access allowed');

+

+class Migration_Create_accounts extends	CI_Migration {

+	

+	function up() 

+	{	

+		if ( ! $this->db->table_exists('accounts'))

+		{

+			// Setup Keys

+			$this->dbforge->add_key('id', TRUE);

+			

+			$this->dbforge->add_field(array(

+				'id' => array('type' => 'INT', 'constraint' => 5, 'unsigned' => TRUE, 'auto_increment' => TRUE),

+				'company_name' => array('type' => 'VARCHAR', 'constraint' => '200', 'null' => FALSE),

+				'first_name' => array('type' => 'VARCHAR', 'constraint' => '200', 'null' => FALSE),

+				'last_name' => array('type' => 'VARCHAR', 'constraint' => '200', 'null' => FALSE),

+				'phone' => array('type' => 'TEXT', 'null' => FALSE),

+				'email' => array('type' => 'TEXT', 'null' => FALSE),

+				'address' => array('type' => 'TEXT', 'null' => FALSE),

+				'Last_Update' => array('type' => 'DATETIME', 'null' => FALSE)

+			));

+			

+			$this->dbforge->add_field("Created_At TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP");

+			$this->dbforge->create_table('accounts', TRUE);

+		}

+	}

+

+	function down() 

+	{

+		$this->dbforge->drop_table('accounts');

+	}

+}