Merge pull request #647 from tomcode/patch-1

Zip class checks file exists to prevent error warnings in the log
diff --git a/application/config/config.php b/application/config/config.php
index 808cc33..063c3d5 100644
--- a/application/config/config.php
+++ b/application/config/config.php
@@ -253,6 +253,9 @@
 |
 | If you use the Encryption class or the Session class you
 | MUST set an encryption key.  See the user guide for info.
+|  
+| http://codeigniter.com/user_guide/libraries/encryption.html
+| http://codeigniter.com/user_guide/libraries/sessions.html
 |
 */
 $config['encryption_key'] = '';
diff --git a/application/config/database.php b/application/config/database.php
index 28b792f..58eec4b 100644
--- a/application/config/database.php
+++ b/application/config/database.php
@@ -62,6 +62,7 @@
 |	['autoinit'] Whether or not to automatically initialize the database.
 |	['stricton'] TRUE/FALSE - forces 'Strict Mode' connections
 |							- good for ensuring strict SQL while developing
+|	['failover'] array - A array with 0 or more data for connections if the main should fail.
 |
 | The $active_group variable lets you choose which connection group to
 | make active.  By default there is only one group (the 'default' group).
@@ -88,7 +89,7 @@
 $db['default']['swap_pre'] = '';
 $db['default']['autoinit'] = TRUE;
 $db['default']['stricton'] = FALSE;
-
+$db['default']['failover'] = array();
 
 /* End of file database.php */
 /* Location: ./application/config/database.php */
\ No newline at end of file
diff --git a/application/config/migration.php b/application/config/migration.php
index 187a499..4fb027b 100644
--- a/application/config/migration.php
+++ b/application/config/migration.php
@@ -5,9 +5,9 @@
  * An open source application development framework for PHP 5.1.6 or newer
  *
  * NOTICE OF LICENSE
- * 
+ *
  * Licensed under the Academic Free License version 3.0
- * 
+ *
  * This source file is subject to the Academic Free License (AFL 3.0) that is
  * bundled with this package in the files license_afl.txt / license_afl.rst.
  * It is also available through the world wide web at this URL:
@@ -43,7 +43,7 @@
 |--------------------------------------------------------------------------
 |
 | This is the name of the table that will store the current migrations state.
-| When migrations runs it will store in a database table which migration 
+| When migrations runs it will store in a database table which migration
 | level the system is at. It then compares the migration level in the this
 | table to the $config['migration_version'] if they are not the same it
 | will migrate up. This must be set.
@@ -51,13 +51,12 @@
 */
 $config['migration_table'] = 'migrations';
 
-
 /*
 |--------------------------------------------------------------------------
 | Auto Migrate To Latest
 |--------------------------------------------------------------------------
 |
-| If this is set to TRUE when you load the migrations class and have 
+| If this is set to TRUE when you load the migrations class and have
 | $config['migration_enabled'] set to TRUE the system will auto migrate
 | to your latest migration (whatever $config['migration_version'] is
 | set to). This way you do not have to call migrations anywhere else
@@ -66,20 +65,18 @@
 */
 $config['migration_auto_latest'] = FALSE;
 
-
 /*
 |--------------------------------------------------------------------------
 | Migrations version
 |--------------------------------------------------------------------------
 |
 | This is used to set migration version that the file system should be on.
-| If you run $this->migration->latest() this is the version that schema will
+| If you run $this->migration->current() this is the version that schema will
 | be upgraded / downgraded to.
 |
 */
 $config['migration_version'] = 0;
 
-
 /*
 |--------------------------------------------------------------------------
 | Migrations Path
@@ -93,5 +90,4 @@
 $config['migration_path'] = APPPATH . 'migrations/';
 
 
-/* End of file migration.php */
-/* Location: ./application/config/migration.php */
\ No newline at end of file
+/* End of file migration.php */
\ No newline at end of file
diff --git a/application/config/mimes.php b/application/config/mimes.php
index ea01925..c43f1fc 100644
--- a/application/config/mimes.php
+++ b/application/config/mimes.php
@@ -57,6 +57,7 @@
 				'mif'	=>	'application/vnd.mif',
 				'xls'	=>	array('application/excel', 'application/vnd.ms-excel', 'application/msexcel'),
 				'ppt'	=>	array('application/powerpoint', 'application/vnd.ms-powerpoint'),
+				'pptx'	=> 	'application/vnd.openxmlformats-officedocument.presentationml.presentation',
 				'wbxml'	=>	'application/wbxml',
 				'wmlc'	=>	'application/wmlc',
 				'dcr'	=>	'application/x-director',
diff --git a/application/config/user_agents.php b/application/config/user_agents.php
index 721ce41..7f5fe81 100644
--- a/application/config/user_agents.php
+++ b/application/config/user_agents.php
@@ -5,9 +5,9 @@
  * An open source application development framework for PHP 5.1.6 or newer
  *
  * NOTICE OF LICENSE
- * 
+ *
  * Licensed under the Academic Free License version 3.0
- * 
+ *
  * This source file is subject to the Academic Free License (AFL 3.0) that is
  * bundled with this package in the files license_afl.txt / license_afl.rst.
  * It is also available through the world wide web at this URL:
@@ -37,173 +37,178 @@
 */
 
 $platforms = array (
-					'windows nt 6.1'	=> 'Windows 7',
-					'windows nt 6.0'	=> 'Windows Vista',
-					'windows nt 5.2'	=> 'Windows 2003',
-					'windows nt 5.1'	=> 'Windows XP',
-					'windows nt 5.0'	=> 'Windows 2000',
-					'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'
-				);
+	'windows nt 6.1'	=> 'Windows 7',
+	'windows nt 6.0'	=> 'Windows Vista',
+	'windows nt 5.2'	=> 'Windows 2003',
+	'windows nt 5.1'	=> 'Windows XP',
+	'windows nt 5.0'	=> 'Windows 2000',
+	'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'
-				);
+	'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'
+	// 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",
-					'dsi'                   => "Nintendo DSi",
-                                        'ds'                    => "Nintendo DS",
-                                        'wii'                   => "Nintendo Wii",
-                                        '3ds'                   => "Nintendo 3DS",
-// Operating Systems
-					'android'		=> "Android",
-					'symbian'		=> "Symbian",
-					'SymbianOS'		=> "SymbianOS",
-					'elaine'		=> "Palm",
-					'palm'			=> "Palm",
-					'series60'		=> "Symbian S60",
-					'windows ce'		=> "Windows CE",
+	// 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",
+	'dsi'			=> "Nintendo DSi",
+	'ds'			=> "Nintendo DS",
+	'wii'			=> "Nintendo Wii",
+	'3ds'			=> "Nintendo 3DS",
+	'open web'		=> "Open Web",
+	'openweb'		=> "OpenWeb",
 
-					// Browsers
-					'obigo'			=> "Obigo",
-					'netfront'		=> "Netfront Browser",
-					'openwave'		=> "Openwave Browser",
-					'mobilexplorer'		=> "Mobile Explorer",
-					'operamini'		=> "Opera Mini",
-					'opera mini'		=> "Opera Mini",
+	// Operating Systems
+	'android'		=> "Android",
+	'symbian'		=> "Symbian",
+	'SymbianOS'		=> "SymbianOS",
+	'elaine'		=> "Palm",
+	'palm'			=> "Palm",
+	'series60'		=> "Symbian S60",
+	'windows ce'	=> "Windows CE",
 
-					// Other
-					'digital paths'		=> "Digital Paths",
-					'avantgo'		=> "AvantGo",
-					'xiino'			=> "Xiino",
-					'novarra'		=> "Novarra Transcoder",
-					'vodafone'		=> "Vodafone",
-					'docomo'		=> "NTT DoCoMo",
-					'o2'			=> "O2",
+	// Browsers
+	'obigo'			=> "Obigo",
+	'netfront'		=> "Netfront Browser",
+	'openwave'		=> "Openwave Browser",
+	'mobilexplorer'	=> "Mobile Explorer",
+	'operamini'		=> "Opera Mini",
+	'opera mini'	=> "Opera Mini",
+	'opera mobi'	=> "Opera Mobile",
 
-					// 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"
-				);
+	// 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'
-				);
+	'googlebot'		=> 'Googlebot',
+	'msnbot'		=> 'MSNBot',
+	'bingbot'		=> 'Bing',
+	'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
+/* Location: ./application/config/user_agents.php */
diff --git a/readme.rst b/readme.rst
index eff6b00..26e04ce 100644
--- a/readme.rst
+++ b/readme.rst
@@ -132,17 +132,17 @@
 means "making a copy of that repo to your account" and "cloning" means
 "copying that code to your environment so you can work on it".
 
-# Set up Git (Windows, Mac & Linux)
-# Go to the CodeIgniter repo
-# Fork it
-# Clone your CodeIgniter repo: git@github.com:<your-name>/CodeIgniter.git
-# Checkout the "develop" branch At this point you are ready to start making
-  changes. 
-# Fix existing bugs on the Issue tracker after taking a look to see nobody
-  else is working on them.
-# Commit the files
-# Push your develop branch to your fork
-# Send a pull request http://help.github.com/send-pull-requests/
+#. Set up Git (Windows, Mac & Linux)
+#. Go to the CodeIgniter repo
+#. Fork it
+#. Clone your CodeIgniter repo: git@github.com:<your-name>/CodeIgniter.git
+#. Checkout the "develop" branch At this point you are ready to start making
+   changes. 
+#. Fix existing bugs on the Issue tracker after taking a look to see nobody
+   else is working on them.
+#. Commit the files
+#. Push your develop branch to your fork
+#. Send a pull request http://help.github.com/send-pull-requests/
 
 The Reactor Engineers will now be alerted about the change and at least one of
 the team will respond. If your change fails to meet the guidelines it will be
@@ -163,9 +163,9 @@
 
 If you are using command-line you can do the following:
 
-# git remote add codeigniter git://github.com/EllisLab/CodeIgniter.git
-# git pull codeigniter develop
-# git push origin develop
+#. git remote add codeigniter git://github.com/EllisLab/CodeIgniter.git
+#. git pull codeigniter develop
+#. git push origin develop
 
 Now your fork is up to date. This should be done regularly, or before you send
 a pull request at least.
diff --git a/system/core/CodeIgniter.php b/system/core/CodeIgniter.php
index 4d76a55..97527e5 100755
--- a/system/core/CodeIgniter.php
+++ b/system/core/CodeIgniter.php
@@ -106,9 +106,13 @@
  *  Set a liberal script execution time limit
  * ------------------------------------------------------
  */
-	if (function_exists("set_time_limit") == TRUE AND @ini_get("safe_mode") == 0)
+	if (function_exists("set_time_limit") AND @ini_get("safe_mode") == 0)
 	{
-		@set_time_limit(300);
+		// Do not override the Time Limit value if running from Command Line
+		if(php_sapi_name() != 'cli')
+		{
+			@set_time_limit(300);
+		}
 	}
 
 /*
diff --git a/system/core/Common.php b/system/core/Common.php
index e43bb8d..b0921fe 100644
--- a/system/core/Common.php
+++ b/system/core/Common.php
@@ -419,6 +419,7 @@
 							415	=> 'Unsupported Media Type',
 							416	=> 'Requested Range Not Satisfiable',
 							417	=> 'Expectation Failed',
+							422	=> 'Unprocessable Entity',
 
 							500	=> 'Internal Server Error',
 							501	=> 'Not Implemented',
diff --git a/system/core/Input.php b/system/core/Input.php
index 946d929..3cbbe78 100755
--- a/system/core/Input.php
+++ b/system/core/Input.php
@@ -740,7 +740,6 @@
 	}
 
 }
-// END Input class
 
 /* End of file Input.php */
 /* Location: ./system/core/Input.php */
diff --git a/system/core/Security.php b/system/core/Security.php
index ee4f0a0..ce3f7d3 100755
--- a/system/core/Security.php
+++ b/system/core/Security.php
@@ -95,7 +95,8 @@
 					'-moz-binding'		=> '[removed]',
 					'<!--'				=> '&lt;!--',
 					'-->'				=> '--&gt;',
-					'<![CDATA['			=> '&lt;![CDATA['
+					'<![CDATA['			=> '&lt;![CDATA[',
+					'<comment>'			=> '&lt;comment&gt;'
 	);
 
 	/**
@@ -498,15 +499,7 @@
 	{
 		if ($this->_xss_hash == '')
 		{
-			if (phpversion() >= 4.2)
-			{
-				mt_srand();
-			}
-			else
-			{
-				mt_srand(hexdec(substr(md5(microtime()), -8)) & 0x7fffffff);
-			}
-
+			mt_srand();
 			$this->_xss_hash = md5(time() + mt_rand(0, 1999999999));
 		}
 
@@ -520,6 +513,12 @@
 	 *
 	 * This function is a replacement for html_entity_decode()
 	 *
+	 * 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.
+	 *
 	 * @param	string
 	 * @param	string
 	 * @return	string
@@ -536,11 +535,6 @@
 			$charset = config_item('charset');
 		}
 
-		// 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.
 		$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);
@@ -637,25 +631,45 @@
 	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');
+		$evil_attributes = array('on\w*', 'style', 'xmlns', 'formaction');
 
 		if ($is_image === TRUE)
 		{
 			/*
-			 * Adobe Photoshop puts XML metadata into JFIF images,
+			 * 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);
+			$count = 0;
+			$attribs = array();
+			
+			// find occurrences of illegal attribute strings without quotes
+			preg_match_all("/(".implode('|', $evil_attributes).")\s*=\s*([^\s]*)/is",  $str, $matches, PREG_SET_ORDER);
+			
+			foreach ($matches as $attr)
+			{
+				$attribs[] = preg_quote($attr[0], '/');
+			}
+			
+			// find occurrences of illegal attribute strings with quotes (042 and 047 are octal quotes)
+			preg_match_all("/(".implode('|', $evil_attributes).")\s*=\s*(\042|\047)([^\\2]*?)(\\2)/is",  $str, $matches, PREG_SET_ORDER);
 
+			foreach ($matches as $attr)
+			{
+				$attribs[] = preg_quote($attr[0], '/');
+			}
+
+			// replace illegal attribute strings that are inside an html tag
+			if (count($attribs) > 0)
+			{
+				$str = preg_replace("/<(\/?[^><]+?)([^A-Za-z\-])(".implode('|', $attribs).")([\s><])([><]*)/i", '<$1$2$4$5', $str, -1, $count);
+			}
+			
+		} while ($count);
+		
 		return $str;
 	}
 
@@ -877,4 +891,4 @@
 }
 
 /* End of file Security.php */
-/* Location: ./system/core/Security.php */
+/* Location: ./system/core/Security.php */
\ No newline at end of file
diff --git a/system/database/DB_driver.php b/system/database/DB_driver.php
index dd1b567..9d92f2f 100644
--- a/system/database/DB_driver.php
+++ b/system/database/DB_driver.php
@@ -126,16 +126,43 @@
 		// 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
+		// No connection resource?  Check if there is a failover else throw an error
 		if ( ! $this->conn_id)
 		{
-			log_message('error', 'Unable to connect to the database');
-
-			if ($this->db_debug)
+			// Check if there is a failover set
+			if ( ! empty($this->failover) && is_array($this->failover))
 			{
-				$this->display_error('db_unable_to_connect');
+				// Go over all the failovers
+				foreach ($this->failover as $failover)
+				{
+					// Replace the current settings with those of the failover
+					foreach ($failover as $key => $val)
+					{
+						$this->$key = $val;
+					}
+
+					// Try to connect
+					$this->conn_id = ($this->pconnect == FALSE) ? $this->db_connect() : $this->db_pconnect();
+
+					// If a connection is made break the foreach loop
+					if ($this->conn_id)
+					{
+						break;
+					}
+				}
 			}
-			return FALSE;
+
+			// We still don't have a connection?
+			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;
+			}
 		}
 
 		// ----------------------------------------------------------------
@@ -522,6 +549,7 @@
 		}
 
 		$this->trans_begin($test_mode);
+		$this->_trans_depth += 1;
 	}
 
 	// --------------------------------------------------------------------
@@ -545,6 +573,10 @@
 			$this->_trans_depth -= 1;
 			return TRUE;
 		}
+		else
+		{
+			$this->_trans_depth = 0;
+		}
 
 		// The query() function will set this flag to FALSE in the event that a query failed
 		if ($this->_trans_status === FALSE)
@@ -1032,7 +1064,14 @@
 		{
 			$args = (func_num_args() > 1) ? array_splice(func_get_args(), 1) : null;
 
-			return call_user_func_array($function, $args);
+			if (is_null($args))
+			{
+				return call_user_func($function);
+			}
+			else
+			{
+				return call_user_func_array($function, $args);
+			}
 		}
 	}
 
diff --git a/system/database/drivers/mysql/mysql_result.php b/system/database/drivers/mysql/mysql_result.php
index 66f782d..29297b6 100644
--- a/system/database/drivers/mysql/mysql_result.php
+++ b/system/database/drivers/mysql/mysql_result.php
@@ -98,10 +98,10 @@
 		$retval = array();
 		while ($field = mysql_fetch_object($this->result_id))
 		{
-			preg_match('/([a-zA-Z]+)(\((\d+)\))?/i', $field->Type, $matches);
+			preg_match('/([a-zA-Z]+)(\(\d+\))?/', $field->Type, $matches);
 
-			$type = $matches[1];
-			$length = isset($matches[3]) ? (int) $matches[3] : NULL;
+			$type = (array_key_exists(1, $matches)) ? $matches[1] : NULL;
+			$length = (array_key_exists(2, $matches)) ? preg_replace('/[^\d]/', '', $matches[2]) : NULL;
 
 			$F				= new stdClass();
 			$F->name		= $field->Field;
diff --git a/system/database/drivers/mysqli/mysqli_driver.php b/system/database/drivers/mysqli/mysqli_driver.php
index 4af08c8..fb5953b 100644
--- a/system/database/drivers/mysqli/mysqli_driver.php
+++ b/system/database/drivers/mysqli/mysqli_driver.php
@@ -574,6 +574,25 @@
 
 	// --------------------------------------------------------------------
 
+
+	/**
+	 * 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).")";
+	}
+	
+	// --------------------------------------------------------------------
+
 	/**
 	 * Update statement
 	 *
diff --git a/system/database/drivers/mysqli/mysqli_result.php b/system/database/drivers/mysqli/mysqli_result.php
index bfe500e..163788b 100644
--- a/system/database/drivers/mysqli/mysqli_result.php
+++ b/system/database/drivers/mysqli/mysqli_result.php
@@ -98,10 +98,10 @@
 		$retval = array();
 		while ($field = mysqli_fetch_object($this->result_id))
 		{
-			preg_match('/([a-zA-Z]+)(\((\d+)\))?/i', $field->Type, $matches);
+			preg_match('/([a-zA-Z]+)(\(\d+\))?/', $field->Type, $matches);
 
-			$type = $matches[1];
-			$length = isset($matches[3]) ? (int) $matches[3] : NULL;
+			$type = (array_key_exists(1, $matches)) ? $matches[1] : NULL;
+			$length = (array_key_exists(2, $matches)) ? preg_replace('/[^\d]/', '', $matches[2]) : NULL;
 
 			$F				= new stdClass();
 			$F->name		= $field->Field;
diff --git a/system/database/drivers/pdo/pdo_driver.php b/system/database/drivers/pdo/pdo_driver.php
index a66a16e..18a508b 100644
--- a/system/database/drivers/pdo/pdo_driver.php
+++ b/system/database/drivers/pdo/pdo_driver.php
@@ -255,7 +255,7 @@
 		// 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->_trans_failure = (bool) ($test_mode === TRUE);
 
 		return $this->conn_id->beginTransaction();
 	}
diff --git a/system/helpers/date_helper.php b/system/helpers/date_helper.php
index 447bf55..8c92fdc 100644
--- a/system/helpers/date_helper.php
+++ b/system/helpers/date_helper.php
@@ -132,7 +132,7 @@
 						'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_RFC850'	=>	'%l, %d-%M-%y %H:%i:%s 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',
diff --git a/system/helpers/url_helper.php b/system/helpers/url_helper.php
index bfed96c..5d9afe4 100755
--- a/system/helpers/url_helper.php
+++ b/system/helpers/url_helper.php
@@ -393,7 +393,7 @@
 	{
 		if ($type != 'email')
 		{
-			if (preg_match_all("#(^|\s|\()((http(s?)://)|(www\.))(\w+[^\s\)\<]+)#i", $str, $matches))
+			if (preg_match_all("#(^|\s|\(|\b)((http(s?)://)|(www\.))(\w+[^\s\)\<]+)#i", $str, $matches))
 			{
 				$pop = ($popup == TRUE) ? " target=\"_blank\" " : "";
 
@@ -544,13 +544,19 @@
  */
 if ( ! function_exists('redirect'))
 {
-	function redirect($uri = '', $method = 'location', $http_response_code = 302)
+	function redirect($uri = '', $method = 'auto', $http_response_code = 302)
 	{
 		if ( ! preg_match('#^https?://#i', $uri))
 		{
 			$uri = site_url($uri);
 		}
 
+		// IIS environment likely? Use 'refresh' for better compatibility
+		if (DIRECTORY_SEPARATOR != '/' && $method == 'auto')
+		{
+			$method = 'refresh';
+		}
+
 		switch($method)
 		{
 			case 'refresh'	: header("Refresh:0;url=".$uri);
diff --git a/system/libraries/Email.php b/system/libraries/Email.php
index 6739db3..631b62e 100644
--- a/system/libraries/Email.php
+++ b/system/libraries/Email.php
@@ -418,11 +418,11 @@
 	 * @param	string
 	 * @return	void
 	 */
-	public function attach($filename, $disposition = 'attachment')
+	public function attach($filename, $disposition = '', $newname = NULL)
 	{
-		$this->_attach_name[] = $filename;
+		$this->_attach_name[] = array($filename, $newname);
 		$this->_attach_type[] = $this->_mime_types(pathinfo($filename, PATHINFO_EXTENSION));
-		$this->_attach_disp[] = $disposition; // Can also be 'inline'  Not sure if it matters
+		$this->_attach_disp[] = empty($disposition) ? 'attachment' : $disposition; // Can also be 'inline'  Not sure if it matters
 		return $this;
 	}
 
@@ -1151,8 +1151,9 @@
 
 		for ($i=0; $i < count($this->_attach_name); $i++)
 		{
-			$filename = $this->_attach_name[$i];
-			$basename = basename($filename);
+			$filename = $this->_attach_name[$i][0];
+			$basename = ( is_null($this->_attach_name[$i][1]) ? basename($filename) : $this->_attach_name[$i][1] );
+				
 			$ctype = $this->_attach_type[$i];
 
 			if ( ! file_exists($filename))
@@ -1692,12 +1693,7 @@
 	 */
 	protected function _smtp_connect()
 	{
-		$ssl = NULL;
-
-		if ($this->smtp_crypto == 'ssl')
-		{
-			$ssl = 'ssl://';
-		}
+		$ssl = ($this->smtp_crypto == 'ssl') ? 'ssl://' : NULL;
 
 		$this->_smtp_connect = fsockopen($ssl.$this->smtp_host,
 										$this->smtp_port,
@@ -1717,6 +1713,7 @@
 		{
 			$this->_send_command('hello');
 			$this->_send_command('starttls');
+
 			$crypto = stream_socket_enable_crypto($this->_smtp_connect, TRUE, STREAM_CRYPTO_METHOD_TLS_CLIENT);
 
 			if ($crypto !== TRUE)
@@ -2112,4 +2109,4 @@
 // END CI_Email class
 
 /* End of file Email.php */
-/* Location: ./system/libraries/Email.php */
+/* Location: ./system/libraries/Email.php */
\ No newline at end of file
diff --git a/system/libraries/Form_validation.php b/system/libraries/Form_validation.php
index 5663da9..918f690 100644
--- a/system/libraries/Form_validation.php
+++ b/system/libraries/Form_validation.php
@@ -5,9 +5,9 @@
  * An open source application development framework for PHP 5.1.6 or newer
  *
  * NOTICE OF LICENSE
- * 
+ *
  * Licensed under the Open Software License version 3.0
- * 
+ *
  * This source file is subject to the Open Software License (OSL 3.0) that is
  * bundled with this package in the files license.txt / license.rst.  It is
  * also available through the world wide web at this URL:
@@ -949,7 +949,7 @@
 
 		return ($str !== $field) ? FALSE : TRUE;
 	}
-	
+
 	// --------------------------------------------------------------------
 
 	/**
@@ -962,10 +962,13 @@
 	 */
 	public function is_unique($str, $field)
 	{
-		list($table, $field)=explode('.', $field);
-		$query = $this->CI->db->limit(1)->get_where($table, array($field => $str));
-		
-		return $query->num_rows() === 0;
+		list($table, $field) = explode('.', $field);
+		if (isset($this->CI->db))
+		{
+			$query = $this->CI->db->limit(1)->get_where($table, array($field => $str));
+			return $query->num_rows() === 0;
+		}
+		return FALSE;
     }
 
 	// --------------------------------------------------------------------
diff --git a/system/libraries/Image_lib.php b/system/libraries/Image_lib.php
index beb463b..2ed488c 100644
--- a/system/libraries/Image_lib.php
+++ b/system/libraries/Image_lib.php
@@ -5,9 +5,9 @@
  * An open source application development framework for PHP 5.1.6 or newer
  *
  * NOTICE OF LICENSE
- * 
+ *
  * Licensed under the Open Software License version 3.0
- * 
+ *
  * This source file is subject to the Open Software License (OSL 3.0) that is
  * bundled with this package in the files license.txt / license.rst.  It is
  * also available through the world wide web at this URL:
@@ -116,15 +116,37 @@
 	 */
 	function clear()
 	{
-		$props = array('source_folder', 'dest_folder', 'source_image', 'full_src_path', 'full_dst_path', 'new_image', 'image_type', 'size_str', 'quality', 'orig_width', 'orig_height', 'rotation_angle', 'x_axis', 'y_axis', 'create_fnc', 'copy_fnc', 'wm_overlay_path', 'wm_use_truetype', 'dynamic_output', 'wm_font_size', 'wm_text', 'wm_vrt_alignment', 'wm_hor_alignment', 'wm_padding', 'wm_hor_offset', 'wm_vrt_offset', 'wm_font_color', 'wm_use_drop_shadow', 'wm_shadow_color', 'wm_shadow_distance', 'wm_opacity');
+		$props = array('library_path', 'source_image', 'new_image', 'width', 'height', 'rotation_angle', 'x_axis', 'y_axis', 'wm_text', 'wm_overlay_path', 'wm_font_path', 'wm_shadow_color', 'source_folder', 'dest_folder', 'mime_type', 'orig_width', 'orig_height', 'image_type', 'size_str', 'full_src_path', 'full_dst_path');
 
 		foreach ($props as $val)
 		{
 			$this->$val = '';
 		}
 
-		// special consideration for master_dim
-		$this->master_dim = 'auto';
+		$this->image_library 		= 'gd2';
+		$this->dynamic_output 		= FALSE;
+		$this->quality 				= '90';
+		$this->create_thumb 		= FALSE;
+		$this->thumb_marker 		= '_thumb';
+		$this->maintain_ratio 		= TRUE;
+		$this->master_dim 			= 'auto';
+		$this->wm_type 				= 'text';
+		$this->wm_x_transp 			= 4;
+		$this->wm_y_transp 			= 4;
+		$this->wm_font_size 		= 17;
+		$this->wm_vrt_alignment 	= 'B';
+		$this->wm_hor_alignment 	= 'C';
+		$this->wm_padding 			= 0;
+		$this->wm_hor_offset 		= 0;
+		$this->wm_vrt_offset 		= 0;
+		$this->wm_font_color		= '#ffffff';
+		$this->wm_shadow_distance 	= 2;
+		$this->wm_opacity 			= 50;
+		$this->create_fnc 			= 'imagecreatetruecolor';
+		$this->copy_fnc 			= 'imagecopyresampled';
+		$this->error_msg 			= array();
+		$this->wm_use_drop_shadow 	= FALSE;
+		$this->wm_use_truetype 		= FALSE;
 	}
 
 	// --------------------------------------------------------------------
@@ -158,7 +180,7 @@
 		if ($this->source_image == '')
 		{
 			$this->set_error('imglib_source_image_required');
-			return FALSE;	
+			return FALSE;
 		}
 
 		/*
@@ -201,7 +223,7 @@
 		// Set the Image Properties
 		if ( ! $this->get_image_properties($this->source_folder.$this->source_image))
 		{
-			return FALSE;	
+			return FALSE;
 		}
 
 		/*
@@ -411,7 +433,7 @@
 		if ($this->rotation_angle == '' OR ! in_array($this->rotation_angle, $degs))
 		{
 			$this->set_error('imglib_rotation_angle_required');
-			return FALSE;	
+			return FALSE;
 		}
 
 		// Reassign the width and height
diff --git a/system/libraries/Log.php b/system/libraries/Log.php
index 6ea905f..46c5b6e 100644
--- a/system/libraries/Log.php
+++ b/system/libraries/Log.php
@@ -111,6 +111,7 @@
 
 		if ( ! file_exists($filepath))
 		{
+			$newfile = TRUE;
 			$message .= "<"."?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed'); ?".">\n\n";
 		}
 
@@ -126,7 +127,10 @@
 		flock($fp, LOCK_UN);
 		fclose($fp);
 
-		@chmod($filepath, FILE_WRITE_MODE);
+		if (isset($newfile) AND $newfile === TRUE)
+		{
+			@chmod($filepath, FILE_WRITE_MODE);
+		}
 		return TRUE;
 	}
 
@@ -134,4 +138,4 @@
 // END Log Class
 
 /* End of file Log.php */
-/* Location: ./system/libraries/Log.php */
\ No newline at end of file
+/* Location: ./system/libraries/Log.php */
diff --git a/system/libraries/Migration.php b/system/libraries/Migration.php
index b7edf71..94961b5 100644
--- a/system/libraries/Migration.php
+++ b/system/libraries/Migration.php
@@ -5,9 +5,9 @@
  * An open source application development framework for PHP 5.1.6 or newer
  *
  * NOTICE OF LICENSE
- * 
+ *
  * Licensed under the Open Software License version 3.0
- * 
+ *
  * This source file is subject to the Open Software License (OSL 3.0) that is
  * bundled with this package in the files license.txt / license.rst.  It is
  * also available through the world wide web at this URL:
@@ -46,7 +46,7 @@
 	protected $_migration_version = 0;
 	protected $_migration_table = 'migrations';
 	protected $_migration_auto_latest = FALSE;
-	
+
 	protected $_error_string = '';
 
 	public function __construct($config = array())
@@ -71,7 +71,7 @@
 		}
 
 		// If not set, set it
-		$this->_migration_path == '' AND $this->_migration_path = APPPATH . 'migrations/';
+		$this->_migration_path == '' AND $this->_migration_path = APPPATH.'migrations/';
 
 		// Add trailing slash if not set
 		$this->_migration_path = rtrim($this->_migration_path, '/').'/';
@@ -85,7 +85,7 @@
 		// Make sure the migration table name was set.
 		if (empty($this->_migration_table))
 		{
-			show_error('Migrations configuration file (migration.php) must have "migration_table" set.');			
+			show_error('Migrations configuration file (migration.php) must have "migration_table" set.');
 		}
 
 		// If the migrations table is missing, make it
@@ -99,9 +99,9 @@
 
 			$this->db->insert($this->_migration_table, array('version' => 0));
 		}
-		
+
 		// Do we auto migrate to the latest migration?
-		if ( $this->_migration_auto_latest == TRUE )
+		if ($this->_migration_auto_latest == TRUE)
 		{
 			if ( ! $this->latest() )
 			{
@@ -140,7 +140,7 @@
 			// Moving Down
 			$step = -1;
 		}
-		
+
 		$method = $step === 1 ? 'up' : 'down';
 		$migrations = array();
 
@@ -148,7 +148,7 @@
 		// But first let's make sure that everything is the way it should be
 		for ($i = $start; $i != $stop; $i += $step)
 		{
-			$f = glob(sprintf($this->_migration_path . '%03d_*.php', $i));
+			$f = glob(sprintf($this->_migration_path.'%03d_*.php', $i));
 
 			// Only one migration per step is permitted
 			if (count($f) > 1)
@@ -189,7 +189,7 @@
 				}
 
 				include $f[0];
-				$class = 'Migration_' . ucfirst($match[1]);
+				$class = 'Migration_'.ucfirst($match[1]);
 
 				if ( ! class_exists($class))
 				{
@@ -212,7 +212,7 @@
 			}
 		}
 
-		log_message('debug', 'Current migration: ' . $current_version);
+		log_message('debug', 'Current migration: '.$current_version);
 
 		$version = $i + ($step == 1 ? -1 : 0);
 
@@ -222,13 +222,13 @@
 			return TRUE;
 		}
 
-		log_message('debug', 'Migrating from ' . $method . ' to version ' . $version);
+		log_message('debug', 'Migrating from '.$method.' to version '.$version);
 
 		// Loop through the migrations
 		foreach ($migrations AS $migration)
 		{
 			// Run the migration class
-			$class = 'Migration_' . ucfirst(strtolower($migration));
+			$class = 'Migration_'.ucfirst(strtolower($migration));
 			call_user_func(array(new $class, $method));
 
 			$current_version += $step;
@@ -252,12 +252,12 @@
 	{
 		if ( ! $migrations = $this->find_migrations())
 		{
-			$this->_error_string = $this->line->lang('migration_none_found');
+			$this->_error_string = $this->lang->line('migration_none_found');
 			return false;
 		}
 
 		$last_migration = basename(end($migrations));
-		
+
 		// Calculate the last migration step from existing migration
 		// filenames and procceed to the standard version migration
 		return $this->version((int) substr($last_migration, 0, 3));
@@ -300,9 +300,9 @@
 	protected function find_migrations()
 	{
 		// Load all *_*.php files in the migrations path
-		$files = glob($this->_migration_path . '*_*.php');
+		$files = glob($this->_migration_path.'*_*.php');
 		$file_count = count($files);
-		
+
 		for ($i = 0; $i < $file_count; $i++)
 		{
 			// Mark wrongly formatted files as false for later filtering
@@ -312,7 +312,7 @@
 				$files[$i] = FALSE;
 			}
 		}
-		
+
 		sort($files);
 
 		return $files;
diff --git a/system/libraries/Pagination.php b/system/libraries/Pagination.php
index 7398c29..eea953a 100644
--- a/system/libraries/Pagination.php
+++ b/system/libraries/Pagination.php
@@ -5,9 +5,9 @@
  * An open source application development framework for PHP 5.1.6 or newer
  *
  * NOTICE OF LICENSE
- * 
+ *
  * Licensed under the Open Software License version 3.0
- * 
+ *
  * This source file is subject to the Open Software License (OSL 3.0) that is
  * bundled with this package in the files license.txt / license.rst.  It is
  * also available through the world wide web at this URL:
@@ -38,39 +38,38 @@
  */
 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			=  0; // Total number of items (database results)
-	var $per_page			= 10; // Max number of items you want shown per page
-	var $num_links			=  2; // Number of "digit" links to show before/after the currently viewed page
-	var $cur_page			=  0; // The current page being viewed
-	var $use_page_numbers	= FALSE; // Use page number for segment instead of offset
-	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		= '';
+	protected $base_url				= ''; // The page we are linking to
+	protected $prefix				= ''; // A custom prefix added to the path.
+	protected $suffix				= ''; // A custom suffix added to the path.
+	protected $total_rows			= 0; // Total number of items (database results)
+	protected $per_page				= 10; // Max number of items you want shown per page
+	protected $num_links			= 2; // Number of "digit" links to show before/after the currently viewed page
+	protected $cur_page				= 0; // The current page being viewed
+	protected $use_page_numbers		= FALSE; // Use page number for segment instead of offset
+	protected $first_link			= '&lsaquo; First';
+	protected $next_link			= '&gt;';
+	protected $prev_link			= '&lt;';
+	protected $last_link			= 'Last &rsaquo;';
+	protected $uri_segment			= 3;
+	protected $full_tag_open		= '';
+	protected $full_tag_close		= '';
+	protected $first_tag_open		= '';
+	protected $first_tag_close		= '&nbsp;';
+	protected $last_tag_open		= '&nbsp;';
+	protected $last_tag_close		= '';
+	protected $first_url			= ''; // Alternative URL for the First Page.
+	protected $cur_tag_open			= '&nbsp;<strong>';
+	protected $cur_tag_close		= '</strong>';
+	protected $next_tag_open		= '&nbsp;';
+	protected $next_tag_close		= '&nbsp;';
+	protected $prev_tag_open		= '&nbsp;';
+	protected $prev_tag_close		= '';
+	protected $num_tag_open			= '&nbsp;';
+	protected $num_tag_close		= '';
+	protected $page_query_string	= FALSE;
+	protected $query_string_segment = 'per_page';
+	protected $display_pages		= TRUE;
+	protected $anchor_class			= '';
 
 	/**
 	 * Constructor
@@ -80,16 +79,7 @@
 	 */
 	public function __construct($params = array())
 	{
-		if (count($params) > 0)
-		{
-			$this->initialize($params);
-		}
-
-		if ($this->anchor_class != '')
-		{
-			$this->anchor_class = 'class="'.$this->anchor_class.'" ';
-		}
-
+		$this->initialize($params);
 		log_message('debug', "Pagination Class Initialized");
 	}
 
@@ -102,7 +92,7 @@
 	 * @param	array	initialization parameters
 	 * @return	void
 	 */
-	function initialize($params = array())
+	public function initialize($params = array())
 	{
 		if (count($params) > 0)
 		{
@@ -114,6 +104,11 @@
 				}
 			}
 		}
+
+		if ($this->anchor_class != '')
+		{
+			$this->anchor_class = 'class="'.$this->anchor_class.'" ';
+		}
 	}
 
 	// --------------------------------------------------------------------
@@ -124,7 +119,7 @@
 	 * @access	public
 	 * @return	string
 	 */
-	function create_links()
+	public 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)
@@ -167,7 +162,7 @@
 				$this->cur_page = (int) $this->cur_page;
 			}
 		}
-		
+
 		// Set current page to 1 if using page numbers instead of offset
 		if ($this->use_page_numbers AND $this->cur_page == 0)
 		{
@@ -204,7 +199,7 @@
 		}
 
 		$uri_page_number = $this->cur_page;
-		
+
 		if ( ! $this->use_page_numbers)
 		{
 			$this->cur_page = floor(($this->cur_page/$this->per_page) + 1);
@@ -298,11 +293,11 @@
 		if ($this->last_link !== FALSE AND ($this->cur_page + $this->num_links) < $num_pages)
 		{
 			$i = ($this->use_page_numbers) ? $num_pages : ($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
+		// 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);
 
diff --git a/system/libraries/Upload.php b/system/libraries/Upload.php
index 56062be..66e91c5 100644
--- a/system/libraries/Upload.php
+++ b/system/libraries/Upload.php
@@ -1033,7 +1033,7 @@
 	protected function _file_mime_type($file)
 	{
 		// Use if the Fileinfo extension, if available (only versions above 5.3 support the FILEINFO_MIME_TYPE flag)
-		if (is_php('5.3') && function_exists('finfo_file'))
+		if ( (float) substr(phpversion(), 0, 3) >= 5.3 && function_exists('finfo_file'))
 		{
 			$finfo = new finfo(FILEINFO_MIME_TYPE);
 			if ($finfo !== FALSE) // This is possible, if there is no magic MIME database file found on the system
@@ -1086,4 +1086,4 @@
 // END Upload Class
 
 /* End of file Upload.php */
-/* Location: ./system/libraries/Upload.php */
+/* Location: ./system/libraries/Upload.php */
\ No newline at end of file
diff --git a/system/libraries/Xmlrpc.php b/system/libraries/Xmlrpc.php
index 2f66ef0..7b1e3fa 100644
--- a/system/libraries/Xmlrpc.php
+++ b/system/libraries/Xmlrpc.php
@@ -1416,14 +1416,14 @@
 	{
 		if ($utc == 1)
 		{
-			$t = strftime("%Y%m%dT%H:%M:%S", $time);
+			$t = strftime("%Y%m%dT%H:%i:%s", $time);
 		}
 		else
 		{
 			if (function_exists('gmstrftime'))
-				$t = gmstrftime("%Y%m%dT%H:%M:%S", $time);
+				$t = gmstrftime("%Y%m%dT%H:%i:%s", $time);
 			else
-				$t = strftime("%Y%m%dT%H:%M:%S", $time - date('Z'));
+				$t = strftime("%Y%m%dT%H:%i:%s", $time - date('Z'));
 		}
 		return $t;
 	}
diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst
index 3a2990b..8dfe249 100644
--- a/user_guide_src/source/changelog.rst
+++ b/user_guide_src/source/changelog.rst
@@ -22,16 +22,63 @@
    -  Added an optional backtrace to php-error template.
    -  Added Android to the list of user agents.
    -  Added Windows 7 to the list of user platforms.
+   -  Ability to log certain error types, not all under a threshold.
+   -  Added support for pem, p10, p12, p7a, p7c, p7m, p7r, p7s, crt, crl, der, kdb, rsa, cer, sst, csr Certs to mimes.php.
+   -  Added support pgp and gpg to mimes.php.
+   -  Added support 3gp, 3g2, mp4, wmv, f4v, vlc Video files to mimes.php.
+   -  Added support m4a, aac, m4u, xspf, au, ac3, flac, ogg Audio files to mimes.php.
+   -  Changed logger to only chmod when file is first created.
+
+-  Helpers
+
+   -  url_title() will now trim extra dashes from beginning and end.
+   -  Added XHTML Basic 1.1 doctype to :doc:`HTML Helper <helpers/html_helper>`.
+
+-  Database
+
+   -  Added new :doc:`Active Record <database/active_record>` methods that return
+      the SQL string of queries without executing them: get_compiled_select(),
+      get_compiled_insert(), get_compiled_update(), get_compiled_delete().
+
+-  Libraries
+
+   -  Added max_filename_increment config setting for Upload library.
+   -  CI_Loader::_ci_autoloader() is now a protected method.
+   -  Modified valid_ip() to use PHP's filter_var() when possible (>= PHP 5.2) in the :doc:`Form Validation library <libraries/form_validation>`.
+	 -  Added custom filename to Email::attach() as $this->email->attach($filename, $disposition, $newname)
+
+-  Core
+
+   -  Changed private functions in CI_URI to protected so MY_URI can
+      override them.
+   -  Removed CI_CORE boolean constant from CodeIgniter.php (no longer Reactor and Core versions).
+
+Bug fixes for 3.0
+------------------
+
+-  Unlink raised an error if cache file did not exist when you try to delete it.
+-  Fixed a bug (#181) where a mis-spelling was in the form validation
+   language file.
+-  Fixed a bug (#159, #163) that mishandled Active Record nested transactions because _trans_depth was not getting incremented.
+-  Fixed a bug (#737, #75) where pagination anchor class was not set properly when using initialize method.
+-  Bug #419 - auto_link() now recognizes URLs that come after a word boundary.
+-  Bug #724 - is_unique in form validation now checks that you are connected to a database.
+-  Bug #647 - _get_mod_time() in Zip library no longer generates stat failed errors
+-  Bug #608 - Fixes an issue with the Image_lib class not clearing properties completely
+-  Fixed bugs (#157 and #174) - the Image_lib clear() function now resets all variables to their default values.
+
+Version 2.1.0
+=============
+
+Release Date: Not Released
+
+-  General Changes
+
    -  Callback validation rules can now accept parameters like any other
       validation rule.
-   -  Ability to log certain error types, not all under a threshold.
    -  Added html_escape() to :doc:`Common
       functions <general/common_functions>` to escape HTML output
       for preventing XSS.
-   -  Added support for pem,p10,p12,p7a,p7c,p7m,p7r,p7s,crt,crl,der,kdb,rsa,cer,sst,csr Certs to mimes.php.
-   -  Added support pgp,gpg to mimes.php.
-   -  Added support 3gp, 3g2, mp4, wmv, f4v, vlc Video files to mimes.php.
-   -  Added support m4a, aac, m4u, xspf, au, ac3, flac, ogg Audio files to mimes.php.
 
 -  Helpers
 
@@ -42,7 +89,6 @@
       function call optional. Fixes (#65)
    -  url_title() will now trim extra dashes from beginning and end.
    -  Improved speed of :doc:`String Helper <helpers/string_helper>`'s random_string() method
-   -  Added XHTML Basic 1.1 doctype to :doc:`HTML Helper <helpers/html_helper>`.
 
 -  Database
 
@@ -57,9 +103,7 @@
       $this->db->like() in the :doc:`Database
       Driver <database/active_record>`.
    -  Added $this->db->insert_batch() support to the OCI8 (Oracle) driver.
-   -  Added new :doc:`Active Record <database/active_record>` methods that return 
-      the SQL string of queries without executing them: get_compiled_select(), 
-      get_compiled_insert(), get_compiled_update(), get_compiled_delete().
+   -  Added failover if the main connections in the config should fail
 
 -  Libraries
 
@@ -69,14 +113,12 @@
    -  Added support to set an optional parameter in your callback rules
       of validation using the :doc:`Form Validation
       Library <libraries/form_validation>`.
-   -  Added a :doc:`Migration Library <libraries/migration>` to assist with applying
+   -  Added a :doc:`Migration library <libraries/migration>` to assist with applying
       incremental updates to your database schema.
    -  Driver children can be located in any package path.
    -  Added max_filename_increment config setting for Upload library.
-   -  CI_Loader::_ci_autoloader() is now a protected method.
    -  Added is_unique to the :doc:`Form Validation
       library <libraries/form_validation>`.
-   -  Modified valid_ip() to use PHP's filter_var() when possible (>= PHP 5.2) in the :doc:`Form Validation library <libraries/form_validation>`.
    -  Added $config['use_page_numbers'] to the :doc:`Pagination library <libraries/pagination>`, which enables real page numbers in the URI.
    -  Added TLS and SSL Encryption for SMTP.
 
@@ -86,10 +128,11 @@
       override them.
    -  Removed CI_CORE boolean constant from CodeIgniter.php (no longer Reactor and Core versions).
 
+
 Bug fixes for 2.1.0
 -------------------
 
--  Unlink raised an error if cache file did not exist when you try to delete it.
+
 -  Fixed #378 Robots identified as regular browsers by the User Agent
    class.
 -  If a config class was loaded first then a library with the same name
@@ -100,21 +143,16 @@
    but the requested method did not.
 -  Fixed a bug (Reactor #89) where MySQL export would fail if the table
    had hyphens or other non alphanumeric/underscore characters.
--  Fixed a bug (#200) where MySQL queries would be malformed after
-   calling count_all() then db->get()
--  Fixed bug #105 that stopped query errors from being logged unless database debugging was enabled
--  Fixed a bug (#181) where a mis-spelling was in the form validation
-   language file.
+-  Fixed a bug (#200) where MySQL queries would be malformed after calling $this->db->count_all() then $this->db->get()
+-  Fixed a bug (#105) that stopped query errors from being logged unless database debugging was enabled
 -  Fixed a bug (#160) - Removed unneeded array copy in the file cache
    driver.
 -  Fixed a bug (#150) - field_data() now correctly returns column
    length.
 -  Fixed a bug (#8) - load_class() now looks for core classes in
    APPPATH first, allowing them to be replaced.
--  Fixed a bug (#24) - ODBC database driver called incorrect parent in
-   __construct().
--  Fixed a bug (#85) - OCI8 (Oracle) database escape_str() function did
-   not escape correct.
+-  Fixed a bug (#24) - ODBC database driver called incorrect parent in __construct().
+-  Fixed a bug (#85) - OCI8 (Oracle) database escape_str() function did not escape correct.
 -  Fixed a bug (#344) - Using schema found in :doc:`Saving Session Data to a Database <libraries/sessions>`, system would throw error "user_data does not have a default value" when deleting then creating a session.
 -  Fixed a bug (#112) - OCI8 (Oracle) driver didn't pass the configured database character set when connecting.
 -  Fixed a bug (#182) - OCI8 (Oracle) driver used to re-execute the statement whenever num_rows() is called.
@@ -125,6 +163,7 @@
 -  Fixed a bug (#60) - Added _file_mime_type() method to the :doc:`File Uploading Library <libraries/file_uploading>` in order to fix a possible MIME-type injection.
 -  Fixed a bug (#537) - Support for all wav type in browser.
 -  Fixed a bug (#576) - Using ini_get() function to detect if apc is enabled or not.
+-  Fixed invalid date time format in :doc:`Date helper <helpers/date_helper>` and :doc:`XMLRPC library <libraries/xmlrpc>`.
 
 Version 2.0.3
 =============
diff --git a/user_guide_src/source/database/configuration.rst b/user_guide_src/source/database/configuration.rst
index 687f0d9..433c671 100644
--- a/user_guide_src/source/database/configuration.rst
+++ b/user_guide_src/source/database/configuration.rst
@@ -28,6 +28,48 @@
 	$db['default']['autoinit'] = TRUE;
 	$db['default']['stricton'] = FALSE;
 
+You can also specify failovers for the situation when the main connection cannot connect for some reason.
+These failovers can be specified by setting the failover for a connection like this::
+
+	$db['default']['failover'] = array(
+			array(
+				'hostname' => 'localhost1',
+				'username' => '',
+				'password' => '',
+				'database' => '',
+				'dbdriver' => 'mysql',
+				'dbprefix' => '',
+				'pconnect' => TRUE,
+				'db_debug' => TRUE,
+				'cache_on' => FALSE,
+				'cachedir' => '',
+				'char_set' => 'utf8',
+				'dbcollat' => 'utf8_general_ci',
+				'swap_pre' => '',
+				'autoinit' => TRUE,
+				'stricton' => FALSE
+			),
+			array(
+				'hostname' => 'localhost2',
+				'username' => '',
+				'password' => '',
+				'database' => '',
+				'dbdriver' => 'mysql',
+				'dbprefix' => '',
+				'pconnect' => TRUE,
+				'db_debug' => TRUE,
+				'cache_on' => FALSE,
+				'cachedir' => '',
+				'char_set' => 'utf8',
+				'dbcollat' => 'utf8_general_ci',
+				'swap_pre' => '',
+				'autoinit' => TRUE,
+				'stricton' => FALSE
+			)
+		);
+
+You can specify as many failovers as you like.
+
 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,
diff --git a/user_guide_src/source/database/connecting.rst b/user_guide_src/source/database/connecting.rst
index 64adc30..a834cc0 100644
--- a/user_guide_src/source/database/connecting.rst
+++ b/user_guide_src/source/database/connecting.rst
@@ -57,7 +57,19 @@
 To connect manually to a desired database you can pass an array of
 values::
 
-	$config['hostname'] = "localhost"; $config['username'] = "myusername"; $config['password'] = "mypassword"; $config['database'] = "mydatabase"; $config['dbdriver'] = "mysql"; $config['dbprefix'] = ""; $config['pconnect'] = FALSE; $config['db_debug'] = TRUE; $config['cache_on'] = FALSE; $config['cachedir'] = ""; $config['char_set'] = "utf8"; $config['dbcollat'] = "utf8_general_ci";  $this->load->database($config);
+	$config['hostname'] = "localhost"; 
+	$config['username'] = "myusername"; 
+	$config['password'] = "mypassword"; 
+	$config['database'] = "mydatabase"; 
+	$config['dbdriver'] = "mysql"; 
+	$config['dbprefix'] = ""; 
+	$config['pconnect'] = FALSE; 
+	$config['db_debug'] = TRUE; 
+	$config['cache_on'] = FALSE; 
+	$config['cachedir'] = ""; 
+	$config['char_set'] = "utf8"; 
+	$config['dbcollat'] = "utf8_general_ci";  
+	$this->load->database($config);
 
 For information on each of these values please see the :doc:`configuration
 page <configuration>`.
@@ -68,14 +80,16 @@
 Or you can submit your database values as a Data Source Name. DSNs must
 have this prototype::
 
-	$dsn = 'dbdriver://username:password@hostname/database';  $this->load->database($dsn);
+	$dsn = 'dbdriver://username:password@hostname/database';  
+	$this->load->database($dsn);
 
 To override default config values when connecting with a DSN string, add
 the config variables as a query string.
 
 ::
 
-	$dsn = 'dbdriver://username:password@hostname/database?char_set=utf8&dbcollat=utf8_general_ci&cache_on=true&cachedir=/path/to/cache';  $this->load->database($dsn);
+	$dsn = 'dbdriver://username:password@hostname/database?char_set=utf8&dbcollat=utf8_general_ci&cache_on=true&cachedir=/path/to/cache';  
+	$this->load->database($dsn);
 
 Connecting to Multiple Databases
 ================================
@@ -83,7 +97,8 @@
 If you need to connect to more than one database simultaneously you can
 do so as follows::
 
-	$DB1 = $this->load->database('group_one', TRUE); $DB2 = $this->load->database('group_two', TRUE);
+	$DB1 = $this->load->database('group_one', TRUE); 
+	$DB2 = $this->load->database('group_two', TRUE);
 
 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
diff --git a/user_guide_src/source/general/urls.rst b/user_guide_src/source/general/urls.rst
index 2115376..3126fcf 100644
--- a/user_guide_src/source/general/urls.rst
+++ b/user_guide_src/source/general/urls.rst
@@ -45,12 +45,13 @@
 
 ::
 	
-	RewriteEngine on
-	RewriteCond $1 !^(index\.php|images|robots\.txt)
+	RewriteEngine On
+	RewriteCond %{REQUEST_FILENAME} !-f
+	RewriteCond %{REQUEST_FILENAME} !-d
 	RewriteRule ^(.*)$ /index.php/$1 [L]
 
-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.
+In the above example, any HTTP request other than those for existing
+directories and existing files is treated as a request for your index.php file.
 
 Adding a URL Suffix
 ===================
diff --git a/user_guide_src/source/helpers/string_helper.rst b/user_guide_src/source/helpers/string_helper.rst
index b8a69e0..dc70e46 100644
--- a/user_guide_src/source/helpers/string_helper.rst
+++ b/user_guide_src/source/helpers/string_helper.rst
@@ -58,7 +58,7 @@
 
 	echo increment_string('file', '_'); // "file_1"
 	echo increment_string('file', '-', 2); // "file-2"
-	echo increment_string('file-4'); // "file-5"
+	echo increment_string('file_4'); // "file_5"
 
 alternator()
 ============
diff --git a/user_guide_src/source/helpers/url_helper.rst b/user_guide_src/source/helpers/url_helper.rst
index c725587..e6d51b2 100644
--- a/user_guide_src/source/helpers/url_helper.rst
+++ b/user_guide_src/source/helpers/url_helper.rst
@@ -284,23 +284,24 @@
 ==========
 
 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
+site URL that link will be built, 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.
 
-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 *only*
-available with 'location' redirects, and not 'refresh'. Examples
+The optional second parameter allows you to force a particular redirection
+method. The available methods are "location" or "refresh", with location
+being faster but less reliable on Windows servers. The default is "auto",
+which will attempt to intelligently choose the method based on the server
+environment.
 
-::
+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
+*only* available with 'location' redirects, and not 'refresh'. Examples::
 
 	if ($logged_in == FALSE)
 	{      
-		redirect('/login/form/', 'refresh');
+		redirect('/login/form/');
 	}
 
 	// with 301 redirect
diff --git a/user_guide_src/source/libraries/email.rst b/user_guide_src/source/libraries/email.rst
index 7598992..27b704d 100644
--- a/user_guide_src/source/libraries/email.rst
+++ b/user_guide_src/source/libraries/email.rst
@@ -228,7 +228,11 @@
 	$this->email->attach('/path/to/photo2.jpg');
 	$this->email->attach('/path/to/photo3.jpg');
 
-	$this->email->send();
+If you'd like to change the disposition or add a custom file name, you can use the second and third paramaters. To use the default disposition (attachment), leave the second parameter blank. Here's an example::
+  
+	$this->email->attach('/path/to/photo1.jpg', 'inline');
+	$this->email->attach('/path/to/photo1.jpg', '', 'birthday.jpg');
+	
 
 $this->email->print_debugger()
 -------------------------------
diff --git a/user_guide_src/source/libraries/image_lib.rst b/user_guide_src/source/libraries/image_lib.rst
index 300cbef..14bd128 100644
--- a/user_guide_src/source/libraries/image_lib.rst
+++ b/user_guide_src/source/libraries/image_lib.rst
@@ -360,7 +360,7 @@
                                                                     image headers.
 **quality**             90%                 1 - 100%                Sets the quality of the image. The higher the quality the larger the
                                                                     file size.
-**padding**             None                A number                The amount of padding, set in pixels, that will be applied to the
+**wm_padding**          None                A number                The amount of padding, set in pixels, that will be applied to the
                                                                     watermark to set it away from the edge of your images.
 **wm_vrt_alignment**    bottom              top, middle, bottom     Sets the vertical alignment for the watermark image.
 **wm_hor_alignment**    center              left, center, right     Sets the horizontal alignment for the watermark image.
diff --git a/user_guide_src/source/tutorial/static_pages.rst b/user_guide_src/source/tutorial/static_pages.rst
index 0bbf51b..82de2a8 100644
--- a/user_guide_src/source/tutorial/static_pages.rst
+++ b/user_guide_src/source/tutorial/static_pages.rst
@@ -28,7 +28,7 @@
     <?php 
     class Pages extends CI_Controller { 
 
-        public function view($page == 'home') 
+        public function view($page = 'home') 
         {
 	
         }
@@ -62,7 +62,7 @@
         </head>
         <body>
 
-            <h1>CodeIgniter 2 Tutorial<h1>
+            <h1>CodeIgniter 2 Tutorial</h1>
 
 The header contains the basic HTML code that you'll want to display
 before loading the main view, together with a heading. It will also