Merge pull request #639 from timw4mail/patch-3

Fixed one-liner code on Database Connection page of userguide
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 cddb01d..721ce41 100644
--- a/application/config/user_agents.php
+++ b/application/config/user_agents.php
@@ -151,7 +151,10 @@
 					'spv'			=> "SPV",
 					'zte'			=> "ZTE",
 					'sendo'			=> "Sendo",
-
+					'dsi'                   => "Nintendo DSi",
+                                        'ds'                    => "Nintendo DS",
+                                        'wii'                   => "Nintendo Wii",
+                                        '3ds'                   => "Nintendo 3DS",
 // Operating Systems
 					'android'		=> "Android",
 					'symbian'		=> "Symbian",
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/pdo/pdo_driver.php b/system/database/drivers/pdo/pdo_driver.php
index 10ef00c..a66a16e 100644
--- a/system/database/drivers/pdo/pdo_driver.php
+++ b/system/database/drivers/pdo/pdo_driver.php
@@ -57,7 +57,8 @@
 	 */
 	var $_count_string = "SELECT COUNT(*) AS ";
 	var $_random_keyword;
-
+	
+	var $options = array();
 
 	function __construct($params)
 	{
@@ -68,6 +69,15 @@
 		{
 			$this->_like_escape_str = '';
 			$this->_like_escape_chr = '';
+			
+			//Prior to this version, the charset can't be set in the dsn
+			if(is_php('5.3.6'))
+			{
+				$this->hostname .= ";charset={$this->char_set}";
+			}
+			
+			//Set the charset with the connection options
+			$this->options['PDO::MYSQL_ATTR_INIT_COMMAND'] = "SET NAMES {$this->char_set}";
 		}
 		else if (strpos($this->hostname, 'odbc') !== FALSE)
 		{
@@ -80,7 +90,8 @@
 			$this->_like_escape_chr = '!';
 		}
 		
-		$this->hostname = $this->hostname . ";dbname=".$this->database;
+		$this->hostname .= ";dbname=".$this->database;
+		
 		$this->trans_enabled = FALSE;
 
 		$this->_random_keyword = ' RND('.time().')'; // database specific random keyword
@@ -94,9 +105,9 @@
 	 */
 	function db_connect()
 	{
-		return new PDO($this->hostname,$this->username,$this->password, array(
-			PDO::ATTR_ERRMODE => PDO::ERRMODE_SILENT
-		));
+		$this->options['PDO::ATTR_ERRMODE'] = PDO::ERRMODE_SILENT;
+		
+		return new PDO($this->hostname, $this->username, $this->password, $this->options);
 	}
 
 	// --------------------------------------------------------------------
@@ -109,10 +120,10 @@
 	 */
 	function db_pconnect()
 	{
-		return new PDO($this->hostname,$this->username,$this->password, array(
-			PDO::ATTR_ERRMODE => PDO::ERRMODE_SILENT,
-			PDO::ATTR_PERSISTENT => true
-		));
+		$this->options['PDO::ATTR_ERRMODE'] = PDO::ERRMODE_SILENT;
+		$this->options['PDO::ATTR_PERSISTENT'] = TRUE;
+	
+		return new PDO($this->hostname, $this->username, $this->password, $this->options);
 	}
 
 	// --------------------------------------------------------------------
diff --git a/system/helpers/url_helper.php b/system/helpers/url_helper.php
index bfed96c..5d907d0 100755
--- a/system/helpers/url_helper.php
+++ b/system/helpers/url_helper.php
@@ -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 db6ea8f..6739db3 100644
--- a/system/libraries/Email.php
+++ b/system/libraries/Email.php
@@ -1718,12 +1718,12 @@
 			$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)
-		{
-			$this->_set_error_message('lang:email_smtp_error', $this->_get_smtp_data());
-			return FALSE;
+			if ($crypto !== TRUE)
+			{
+				$this->_set_error_message('lang:email_smtp_error', $this->_get_smtp_data());
+				return FALSE;
+			}
 		}
 
 		return $this->_send_command('hello');
diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst
index 3a2990b..3ddd1ec 100644
--- a/user_guide_src/source/changelog.rst
+++ b/user_guide_src/source/changelog.rst
@@ -32,6 +32,7 @@
    -  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.
+   -  Added support pptx office files to mimes.php.
 
 -  Helpers
 
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/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