From 6c5f751b5ae66800e7ef3f70306a6bcbcdeeabf1 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Wed, 10 Oct 2012 15:56:18 +0300 Subject: mbstring related changes --- system/core/Utf8.php | 37 ++++++++++++++++++------------------ system/libraries/Form_validation.php | 6 ------ 2 files changed, 19 insertions(+), 24 deletions(-) (limited to 'system') diff --git a/system/core/Utf8.php b/system/core/Utf8.php index 0a7ec501c..9e6a4eb1b 100644 --- a/system/core/Utf8.php +++ b/system/core/Utf8.php @@ -49,30 +49,31 @@ class CI_Utf8 { { log_message('debug', 'Utf8 Class Initialized'); - global $CFG; + $charset = strtoupper(config_item('charset')); + + // 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($charset); + } + else + { + define('MB_ENABLED', FALSE); + } + if ( - @preg_match('/./u', 'é') === 1 // PCRE must support UTF-8 - && function_exists('iconv') // iconv must be installed - && (bool) @ini_get('mbstring.func_overload') !== TRUE // Multibyte string function overloading cannot be enabled - && $CFG->item('charset') === 'UTF-8' // Application charset must be UTF-8 + @preg_match('/./u', 'é') === 1 // PCRE must support UTF-8 + && function_exists('iconv') // iconv must be installed + && MB_ENABLED === TRUE // mbstring must be enabled + && $charset === 'UTF-8' // Application charset must be UTF-8 ) { define('UTF8_ENABLED', TRUE); log_message('debug', 'UTF-8 Support Enabled'); - - // 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 { diff --git a/system/libraries/Form_validation.php b/system/libraries/Form_validation.php index b490a34ca..fccc12afa 100644 --- a/system/libraries/Form_validation.php +++ b/system/libraries/Form_validation.php @@ -134,12 +134,6 @@ class CI_Form_validation { // Automatically load the form helper $this->CI->load->helper('form'); - // Set the character encoding in MB. - if (MB_ENABLED === TRUE) - { - mb_internal_encoding($this->CI->config->item('charset')); - } - log_message('debug', 'Form Validation Class Initialized'); } -- cgit v1.2.3-24-g4f1b From 9f44c21a3c90e984becaea3948ebafe90d89ac56 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Wed, 10 Oct 2012 16:07:17 +0300 Subject: Changelog entry for previous commit and change default charset for the Email library to whatever the config array says --- system/core/Utf8.php | 2 +- system/libraries/Email.php | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) (limited to 'system') diff --git a/system/core/Utf8.php b/system/core/Utf8.php index 9e6a4eb1b..1ff02981b 100644 --- a/system/core/Utf8.php +++ b/system/core/Utf8.php @@ -136,7 +136,7 @@ class CI_Utf8 { { return @iconv($encoding, 'UTF-8', $str); } - elseif (function_exists('mb_convert_encoding')) + elseif (MB_ENABLED === TRUE) { return @mb_convert_encoding($str, 'UTF-8', $encoding); } diff --git a/system/libraries/Email.php b/system/libraries/Email.php index 1b457aee4..698cb7679 100644 --- a/system/libraries/Email.php +++ b/system/libraries/Email.php @@ -98,6 +98,8 @@ class CI_Email { */ public function __construct($config = array()) { + $this->charset = strtoupper(config_item('charset')); + if (count($config) > 0) { $this->initialize($config); -- cgit v1.2.3-24-g4f1b From c6f9a5da098ed9e27d88b7c271c4e1ba76fa79d6 Mon Sep 17 00:00:00 2001 From: lysenkobv Date: Wed, 10 Oct 2012 20:11:34 +0300 Subject: libraries/Encrypt.php decode improvement MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit if base64 string is NO valid the result of decoded string is something like this "23Y�����������S�� �����i��!q" (base64_encode(base64_decode($string)) !== $string) check is this base64 string valid --- system/libraries/Encrypt.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system') diff --git a/system/libraries/Encrypt.php b/system/libraries/Encrypt.php index 679609251..dbe16b096 100644 --- a/system/libraries/Encrypt.php +++ b/system/libraries/Encrypt.php @@ -165,7 +165,7 @@ class CI_Encrypt { */ public function decode($string, $key = '') { - if (preg_match('/[^a-zA-Z0-9\/\+=]/', $string)) + if (preg_match('/[^a-zA-Z0-9\/\+=]/', $string) || base64_encode(base64_decode($string)) !== $string) { return FALSE; } -- cgit v1.2.3-24-g4f1b From 9738668fd6b4078c7eb9df3372e5035791caaaf4 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Thu, 11 Oct 2012 10:24:51 +0300 Subject: Fix issue #1875 --- system/database/drivers/mssql/mssql_driver.php | 2 +- system/database/drivers/pdo/subdrivers/pdo_dblib_driver.php | 2 +- system/database/drivers/pdo/subdrivers/pdo_sqlsrv_driver.php | 2 +- system/database/drivers/sqlsrv/sqlsrv_driver.php | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) (limited to 'system') diff --git a/system/database/drivers/mssql/mssql_driver.php b/system/database/drivers/mssql/mssql_driver.php index a62ea94b3..a5ace02e6 100644 --- a/system/database/drivers/mssql/mssql_driver.php +++ b/system/database/drivers/mssql/mssql_driver.php @@ -465,7 +465,7 @@ class CI_DB_mssql_driver extends CI_DB { $orderby = 'ORDER BY '.implode(', ', $this->qb_orderby); // We have to strip the ORDER BY clause - $sql = trim(substr($sql, 0, strrpos($sql, 'ORDER BY '.$orderby))); + $sql = trim(substr($sql, 0, strrpos($sql, $orderby))); return 'SELECT '.(count($this->qb_select) === 0 ? '*' : implode(', ', $this->qb_select))." FROM (\n" .preg_replace('/^(SELECT( DISTINCT)?)/i', '\\1 ROW_NUMBER() OVER('.$orderby.') AS '.$this->escape_identifiers('CI_rownum').', ', $sql) diff --git a/system/database/drivers/pdo/subdrivers/pdo_dblib_driver.php b/system/database/drivers/pdo/subdrivers/pdo_dblib_driver.php index 2346e683e..7c4b008b2 100644 --- a/system/database/drivers/pdo/subdrivers/pdo_dblib_driver.php +++ b/system/database/drivers/pdo/subdrivers/pdo_dblib_driver.php @@ -232,7 +232,7 @@ class CI_DB_pdo_dblib_driver extends CI_DB_pdo_driver { $orderby = 'ORDER BY '.implode(', ', $this->qb_orderby); // We have to strip the ORDER BY clause - $sql = trim(substr($sql, 0, strrpos($sql, 'ORDER BY '.$orderby))); + $sql = trim(substr($sql, 0, strrpos($sql, $orderby))); return 'SELECT '.(count($this->qb_select) === 0 ? '*' : implode(', ', $this->qb_select))." FROM (\n" .preg_replace('/^(SELECT( DISTINCT)?)/i', '\\1 ROW_NUMBER() OVER('.$orderby.') AS '.$this->escape_identifiers('CI_rownum').', ', $sql) diff --git a/system/database/drivers/pdo/subdrivers/pdo_sqlsrv_driver.php b/system/database/drivers/pdo/subdrivers/pdo_sqlsrv_driver.php index ee7c1d15a..fd1c4b214 100644 --- a/system/database/drivers/pdo/subdrivers/pdo_sqlsrv_driver.php +++ b/system/database/drivers/pdo/subdrivers/pdo_sqlsrv_driver.php @@ -266,7 +266,7 @@ class CI_DB_pdo_sqlsrv_driver extends CI_DB_pdo_driver { $orderby = 'ORDER BY '.implode(', ', $this->qb_orderby); // We have to strip the ORDER BY clause - $sql = trim(substr($sql, 0, strrpos($sql, 'ORDER BY '.$orderby))); + $sql = trim(substr($sql, 0, strrpos($sql, $orderby))); return 'SELECT '.(count($this->qb_select) === 0 ? '*' : implode(', ', $this->qb_select))." FROM (\n" .preg_replace('/^(SELECT( DISTINCT)?)/i', '\\1 ROW_NUMBER() OVER('.$orderby.') AS '.$this->escape_identifiers('CI_rownum').', ', $sql) diff --git a/system/database/drivers/sqlsrv/sqlsrv_driver.php b/system/database/drivers/sqlsrv/sqlsrv_driver.php index a6739d192..3ffbd4c18 100644 --- a/system/database/drivers/sqlsrv/sqlsrv_driver.php +++ b/system/database/drivers/sqlsrv/sqlsrv_driver.php @@ -460,7 +460,7 @@ class CI_DB_sqlsrv_driver extends CI_DB { $orderby = 'ORDER BY '.implode(', ', $this->qb_orderby); // We have to strip the ORDER BY clause - $sql = trim(substr($sql, 0, strrpos($sql, 'ORDER BY '.$orderby))); + $sql = trim(substr($sql, 0, strrpos($sql, $orderby))); return 'SELECT '.(count($this->qb_select) === 0 ? '*' : implode(', ', $this->qb_select))." FROM (\n" .preg_replace('/^(SELECT( DISTINCT)?)/i', '\\1 ROW_NUMBER() OVER('.$orderby.') AS '.$this->escape_identifiers('CI_rownum').', ', $sql) -- cgit v1.2.3-24-g4f1b From a52c775d490fede2a0cb7f54f0dcc5010d7e0465 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Thu, 11 Oct 2012 10:54:02 +0300 Subject: Replace a few require() uses with require_once() (should fix issue #1872) --- system/core/CodeIgniter.php | 2 +- system/core/Common.php | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'system') diff --git a/system/core/CodeIgniter.php b/system/core/CodeIgniter.php index 8159b19f5..f3592eaf9 100644 --- a/system/core/CodeIgniter.php +++ b/system/core/CodeIgniter.php @@ -50,7 +50,7 @@ * Load the global functions * ------------------------------------------------------ */ - require(BASEPATH.'core/Common.php'); + require_once(BASEPATH.'core/Common.php'); /* * ------------------------------------------------------ diff --git a/system/core/Common.php b/system/core/Common.php index 981af4559..341402c6b 100644 --- a/system/core/Common.php +++ b/system/core/Common.php @@ -150,7 +150,7 @@ if ( ! function_exists('load_class')) if (class_exists($name) === FALSE) { - require($path.$directory.'/'.$class.'.php'); + require_once($path.$directory.'/'.$class.'.php'); } break; @@ -164,7 +164,7 @@ if ( ! function_exists('load_class')) if (class_exists($name) === FALSE) { - require(APPPATH.$directory.'/'.config_item('subclass_prefix').$class.'.php'); + require_once(APPPATH.$directory.'/'.config_item('subclass_prefix').$class.'.php'); } } -- cgit v1.2.3-24-g4f1b From c16b4f4164a4a26c48b823caf086a9777dc75beb Mon Sep 17 00:00:00 2001 From: Bogdan Lysenko Date: Thu, 11 Oct 2012 11:41:01 +0300 Subject: Update system/libraries/Encrypt.php --- system/libraries/Encrypt.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system') diff --git a/system/libraries/Encrypt.php b/system/libraries/Encrypt.php index dbe16b096..73ab8ca7d 100644 --- a/system/libraries/Encrypt.php +++ b/system/libraries/Encrypt.php @@ -165,7 +165,7 @@ class CI_Encrypt { */ public function decode($string, $key = '') { - if (preg_match('/[^a-zA-Z0-9\/\+=]/', $string) || base64_encode(base64_decode($string)) !== $string) + if (preg_match('/[^a-zA-Z0-9\/\+=]/', $string) OR base64_encode(base64_decode($string)) !== $string) { return FALSE; } -- cgit v1.2.3-24-g4f1b From 26f0cf9cf94869f9aed94f2a7f5bd4ad9180079e Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Thu, 11 Oct 2012 13:52:39 +0300 Subject: Add a fallback to imap_8bit() for CI_Email::_prep_quoted_printable() --- system/libraries/Email.php | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'system') diff --git a/system/libraries/Email.php b/system/libraries/Email.php index 698cb7679..fa1d5e9bf 100644 --- a/system/libraries/Email.php +++ b/system/libraries/Email.php @@ -1109,9 +1109,16 @@ class CI_Email { // However, many developers choose to override that and violate // the RFC rules due to (apparently) a bug in MS Exchange, // which only works with "\n". - if ($this->crlf === "\r\n" && is_php('5.3')) + if ($this->crlf === "\r\n") { - return quoted_printable_encode($str); + if (is_php('5.3')) + { + return quoted_printable_encode($str); + } + elseif (function_exists('imap_8bit')) + { + return imap_8bit($str); + } } // Reduce multiple spaces & remove nulls -- cgit v1.2.3-24-g4f1b From f38564d739455f46eb38bcbfaa8e255d0a50defe Mon Sep 17 00:00:00 2001 From: Raul Baldner Junior Date: Thu, 11 Oct 2012 11:32:23 -0300 Subject: New form_validation rule: 'differs' Added new validation rule 'differs'. It checks if the value of a field differs from the value of another field. --- system/language/english/form_validation_lang.php | 1 + system/libraries/Form_validation.php | 13 +++++++++++++ 2 files changed, 14 insertions(+) (limited to 'system') diff --git a/system/language/english/form_validation_lang.php b/system/language/english/form_validation_lang.php index cf1b3b503..6ff0cc2f4 100644 --- a/system/language/english/form_validation_lang.php +++ b/system/language/english/form_validation_lang.php @@ -42,6 +42,7 @@ $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['differs'] = 'The %s field must differ from the %s field.'; $lang['is_unique'] = 'The %s field must contain a unique value.'; $lang['is_natural'] = 'The %s field must only contain digits.'; $lang['is_natural_no_zero'] = 'The %s field must only contain digits and must be greater than zero.'; diff --git a/system/libraries/Form_validation.php b/system/libraries/Form_validation.php index fccc12afa..6db5bb495 100644 --- a/system/libraries/Form_validation.php +++ b/system/libraries/Form_validation.php @@ -970,6 +970,19 @@ class CI_Form_validation { // -------------------------------------------------------------------- + /** + * Differs from another field + * + * @param string + * @param string field + * @return bool + */ + public function differs($str, $field) + { + return ! (isset($this->_field_data[$field]) && $this->_field_data[$field]['postdata'] === $str); + } + + // -------------------------------------------------------------------- /** * Is Unique * -- cgit v1.2.3-24-g4f1b From 9ae82faaad2f6b07a050d79129652b74483d1da0 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Thu, 11 Oct 2012 20:58:45 +0300 Subject: [ci skip] Minor changes following PR #1871 --- system/libraries/Form_validation.php | 1 + 1 file changed, 1 insertion(+) (limited to 'system') diff --git a/system/libraries/Form_validation.php b/system/libraries/Form_validation.php index 6db5bb495..91f46b6de 100644 --- a/system/libraries/Form_validation.php +++ b/system/libraries/Form_validation.php @@ -983,6 +983,7 @@ class CI_Form_validation { } // -------------------------------------------------------------------- + /** * Is Unique * -- cgit v1.2.3-24-g4f1b From 2f8bf9b4c5ee9bc183e17fd36b54be12a1bf75bb Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Fri, 12 Oct 2012 20:37:52 +0300 Subject: Set MySQL client compression to FALSE by default (problems reported with it), fix some typos, add encrypted database connections support and fix SQLSRV CharacterSet setting --- system/database/DB_driver.php | 2 +- system/database/drivers/mysql/mysql_driver.php | 26 +++++------- system/database/drivers/mysqli/mysqli_driver.php | 49 +++++++--------------- .../drivers/pdo/subdrivers/pdo_mysql_driver.php | 7 ++++ .../drivers/pdo/subdrivers/pdo_sqlsrv_driver.php | 4 +- system/database/drivers/sqlsrv/sqlsrv_driver.php | 9 ++-- system/helpers/date_helper.php | 2 +- 7 files changed, 41 insertions(+), 58 deletions(-) (limited to 'system') diff --git a/system/database/DB_driver.php b/system/database/DB_driver.php index ea2a53eb2..fef388bbf 100644 --- a/system/database/DB_driver.php +++ b/system/database/DB_driver.php @@ -51,7 +51,7 @@ abstract class CI_DB_driver { public $char_set = 'utf8'; public $dbcollat = 'utf8_general_ci'; public $autoinit = TRUE; // Whether to automatically initialize the DB - public $compress = TRUE; + public $encrypt = FALSE; public $swap_pre = ''; public $port = ''; public $pconnect = FALSE; diff --git a/system/database/drivers/mysql/mysql_driver.php b/system/database/drivers/mysql/mysql_driver.php index 7262591ee..336db971d 100644 --- a/system/database/drivers/mysql/mysql_driver.php +++ b/system/database/drivers/mysql/mysql_driver.php @@ -41,6 +41,7 @@ class CI_DB_mysql_driver extends CI_DB { public $dbdriver = 'mysql'; + public $compress = FALSE; // The character used for escaping protected $_escape_char = '`'; @@ -75,18 +76,20 @@ class CI_DB_mysql_driver extends CI_DB { /** * Non-persistent database connection * + * @param bool * @return resource */ - public function db_connect() + public function db_connect($persistent = FALSE) { - if ($this->compress === TRUE) - { - return @mysql_connect($this->hostname, $this->username, $this->password, TRUE, MYSQL_CLIENT_COMPRESS); - } - else + $connect_func = ($persistent === TRUE) ? 'mysql_pconnect' : 'mysql_connect'; + $client_flags = ($this->compress === FALSE) ? 0 : MYSQL_CLIENT_COMPRESS; + + if ($this->encrypt === TRUE) { - return @mysql_connect($this->hostname, $this->username, $this->password, TRUE); + $client_flags = $client_flags | MYSQL_CLIENT_SSL; } + + return @$connect_func($this->hostname, $this->username, $this->password, TRUE, $client_flags); } // -------------------------------------------------------------------- @@ -98,14 +101,7 @@ class CI_DB_mysql_driver extends CI_DB { */ public function db_pconnect() { - if ($this->compress === TRUE) - { - return @mysql_pconnect($this->hostname, $this->username, $this->password, MYSQL_CLIENT_COMPRESS); - } - else - { - return @mysql_pconnect($this->hostname, $this->username, $this->password); - } + return $this->db_connect(TRUE); } // -------------------------------------------------------------------- diff --git a/system/database/drivers/mysqli/mysqli_driver.php b/system/database/drivers/mysqli/mysqli_driver.php index b5a1e26ed..f77176c16 100644 --- a/system/database/drivers/mysqli/mysqli_driver.php +++ b/system/database/drivers/mysqli/mysqli_driver.php @@ -41,6 +41,7 @@ class CI_DB_mysqli_driver extends CI_DB { public $dbdriver = 'mysqli'; + public $compress = FALSE; // The character used for escaping protected $_escape_char = '`'; @@ -57,24 +58,21 @@ class CI_DB_mysqli_driver extends CI_DB { /** * Non-persistent database connection * + * @param bool * @return object + * @todo SSL support */ - public function db_connect() + public function db_connect($persistent = FALSE) { - // Use MySQL client compression? - if ($this->compress === TRUE) - { - $port = empty($this->port) ? NULL : $this->port; - - $mysqli = new mysqli(); - @$mysqli->real_connect($this->hostname, $this->username, $this->password, $this->database, $port, NULL, MYSQLI_CLIENT_COMPRESS); - - return $mysqli; - } - - return empty($this->port) - ? @new mysqli($this->hostname, $this->username, $this->password, $this->database) - : @new mysqli($this->hostname, $this->username, $this->password, $this->database, $this->port); + // Persistent connection support was added in PHP 5.3.0 + $hostname = ($persistent === TRUE && is_php('5.3')) + ? 'p:'.$this->hostname : $this->hostname; + $port = empty($this->port) ? NULL : $this->port; + $client_flags = ($this->compress === TRUE) ? MYSQLI_CLIENT_COMPRESS : 0; + $mysqli = new mysqli(); + + return @$mysqli->real_connect($hostname, $this->username, $this->password, $this->database, $port, NULL, $client_flags) + ? $mysqli : FALSE; } // -------------------------------------------------------------------- @@ -86,26 +84,7 @@ class CI_DB_mysqli_driver extends CI_DB { */ public function db_pconnect() { - // Persistent connection support was added in PHP 5.3.0 - if ( ! is_php('5.3')) - { - return $this->db_connect(); - } - - // Use MySQL client compression? - if ($this->compress === TRUE) - { - $port = empty($this->port) ? NULL : $this->port; - - $mysqli = mysqli_init(); - $mysqli->real_connect('p:'.$this->hostname, $this->username, $this->password, $this->database, $port, NULL, MYSQLI_CLIENT_COMPRESS); - - return $mysqli; - } - - return empty($this->port) - ? @new mysqli('p:'.$this->hostname, $this->username, $this->password, $this->database) - : @new mysqli('p:'.$this->hostname, $this->username, $this->password, $this->database, $this->port); + return $this->db_connect(TRUE); } // -------------------------------------------------------------------- diff --git a/system/database/drivers/pdo/subdrivers/pdo_mysql_driver.php b/system/database/drivers/pdo/subdrivers/pdo_mysql_driver.php index 42446889a..a54311712 100644 --- a/system/database/drivers/pdo/subdrivers/pdo_mysql_driver.php +++ b/system/database/drivers/pdo/subdrivers/pdo_mysql_driver.php @@ -41,6 +41,7 @@ class CI_DB_pdo_mysql_driver extends CI_DB_pdo_driver { public $subdriver = 'mysql'; + public $compress = FALSE; protected $_escape_char = '`'; @@ -79,6 +80,7 @@ class CI_DB_pdo_mysql_driver extends CI_DB_pdo_driver { * * @param bool * @return object + * @todo SSL support */ public function db_connect($persistent = FALSE) { @@ -93,6 +95,11 @@ class CI_DB_pdo_mysql_driver extends CI_DB_pdo_driver { .(empty($this->dbcollat) ? '' : ' COLLATE '.$this->dbcollat); } + if ($this->compress === TRUE) + { + $this->options[PDO::MYSQL_ATTR_COMPRESS] = TRUE; + } + return parent::db_connect($persistent); } diff --git a/system/database/drivers/pdo/subdrivers/pdo_sqlsrv_driver.php b/system/database/drivers/pdo/subdrivers/pdo_sqlsrv_driver.php index fd1c4b214..3154fddb9 100644 --- a/system/database/drivers/pdo/subdrivers/pdo_sqlsrv_driver.php +++ b/system/database/drivers/pdo/subdrivers/pdo_sqlsrv_driver.php @@ -78,9 +78,9 @@ class CI_DB_pdo_sqlsrv_driver extends CI_DB_pdo_driver { $this->dsn .= ';ConnectionPooling='.$this->ConnectionPooling; } - if (isset($this->Encrypt)) + if ($this->encrypt === TRUE) { - $this->dsn .= ';Encrypt='.$this->Encrypt; + $this->dsn .= ';Encrypt=1'; } if (isset($this->TraceOn)) diff --git a/system/database/drivers/sqlsrv/sqlsrv_driver.php b/system/database/drivers/sqlsrv/sqlsrv_driver.php index 3ffbd4c18..be321ff11 100644 --- a/system/database/drivers/sqlsrv/sqlsrv_driver.php +++ b/system/database/drivers/sqlsrv/sqlsrv_driver.php @@ -57,15 +57,16 @@ class CI_DB_sqlsrv_driver extends CI_DB { */ public function db_connect($pooling = FALSE) { - // Check for a UTF-8 charset being passed as CI's default 'utf8'. - $character_set = (0 === strcasecmp('utf8', $this->char_set)) ? 'UTF-8' : $this->char_set; + $charset = in_array(strtolower($this->char_set), array('utf-8', 'utf8'), TRUE) + ? 'UTF-8' : SQLSRV_ENC_CHAR; $connection = array( 'UID' => empty($this->username) ? '' : $this->username, 'PWD' => empty($this->password) ? '' : $this->password, 'Database' => $this->database, - 'ConnectionPooling' => $pooling ? 1 : 0, - 'CharacterSet' => $character_set, + 'ConnectionPooling' => ($pooling === TRUE) ? 1 : 0, + 'CharacterSet' => $charset, + 'Encrypt' => ($this->encrypt === TRUE) ? 1 : 0, 'ReturnDatesAsStrings' => 1 ); diff --git a/system/helpers/date_helper.php b/system/helpers/date_helper.php index 955d74542..51b2b76db 100644 --- a/system/helpers/date_helper.php +++ b/system/helpers/date_helper.php @@ -669,7 +669,7 @@ if ( ! function_exists('date_range')) * @param int unix_start UNIX timestamp of period start date * @param int unix_end|days UNIX timestamp of period end date * or interval in days. - * @param mixed is_unix Specifies wether the second parameter + * @param mixed is_unix Specifies whether the second parameter * is a UNIX timestamp or a day interval * - TRUE or 'unix' for a timestamp * - FALSE or 'days' for an interval -- cgit v1.2.3-24-g4f1b From 98ebf4351f8aad58504cd7318ddd94faf0dec482 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Fri, 12 Oct 2012 20:44:03 +0300 Subject: Fix mysql's db_connect() --- system/database/drivers/mysql/mysql_driver.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'system') diff --git a/system/database/drivers/mysql/mysql_driver.php b/system/database/drivers/mysql/mysql_driver.php index 336db971d..99bf55942 100644 --- a/system/database/drivers/mysql/mysql_driver.php +++ b/system/database/drivers/mysql/mysql_driver.php @@ -81,7 +81,6 @@ class CI_DB_mysql_driver extends CI_DB { */ public function db_connect($persistent = FALSE) { - $connect_func = ($persistent === TRUE) ? 'mysql_pconnect' : 'mysql_connect'; $client_flags = ($this->compress === FALSE) ? 0 : MYSQL_CLIENT_COMPRESS; if ($this->encrypt === TRUE) @@ -89,7 +88,9 @@ class CI_DB_mysql_driver extends CI_DB { $client_flags = $client_flags | MYSQL_CLIENT_SSL; } - return @$connect_func($this->hostname, $this->username, $this->password, TRUE, $client_flags); + return ($persistent === TRUE) + ? @mysql_pconnect($this->hostname, $this->username, $this->password, $client_flags) + : @mysql_connect($this->hostname, $this->username, $this->password, TRUE, $client_flags); } // -------------------------------------------------------------------- -- cgit v1.2.3-24-g4f1b