summaryrefslogtreecommitdiffstats
path: root/system
diff options
context:
space:
mode:
Diffstat (limited to 'system')
-rw-r--r--system/core/Input.php21
-rw-r--r--system/core/Output.php18
-rw-r--r--system/database/DB_driver.php5
-rw-r--r--system/database/DB_forge.php59
-rw-r--r--system/database/DB_query_builder.php2
-rw-r--r--system/database/drivers/pdo/subdrivers/pdo_sqlsrv_driver.php3
-rw-r--r--system/database/drivers/postgre/postgre_driver.php27
-rw-r--r--system/database/drivers/sqlsrv/sqlsrv_driver.php3
-rw-r--r--system/helpers/captcha_helper.php5
-rw-r--r--system/helpers/smiley_helper.php3
-rw-r--r--system/language/english/email_lang.php1
-rw-r--r--system/libraries/Cart.php1
-rw-r--r--system/libraries/Email.php6
-rw-r--r--system/libraries/Session/drivers/Session_cookie.php2
-rw-r--r--system/libraries/Zip.php11
15 files changed, 85 insertions, 82 deletions
diff --git a/system/core/Input.php b/system/core/Input.php
index 81555df9a..0c6025d1e 100644
--- a/system/core/Input.php
+++ b/system/core/Input.php
@@ -150,17 +150,22 @@ class CI_Input {
* Internal method used to retrieve values from global arrays.
*
* @param array &$array $_GET, $_POST, $_COOKIE, $_SERVER, etc.
- * @param string $index Index for item to be fetched from $array
+ * @param mixed $index Index for item to be fetched from $array
* @param bool $xss_clean Whether to apply XSS filtering
* @return mixed
*/
protected function _fetch_from_array(&$array, $index = NULL, $xss_clean = NULL)
{
+ is_bool($xss_clean) OR $xss_clean = $this->_enable_xss;
+
// If $index is NULL, it means that the whole $array is requested
- if ($index === NULL)
+ isset($index) OR $index = array_keys($array);
+
+ // allow fetching multiple keys at once
+ if (is_array($index))
{
$output = array();
- foreach (array_keys($array) as $key)
+ foreach ($index as $key)
{
$output[$key] = $this->_fetch_from_array($array, $key, $xss_clean);
}
@@ -168,8 +173,6 @@ class CI_Input {
return $output;
}
- is_bool($xss_clean) OR $xss_clean = $this->_enable_xss;
-
if (isset($array[$index]))
{
$value = $array[$index];
@@ -210,7 +213,7 @@ class CI_Input {
/**
* Fetch an item from the GET array
*
- * @param string $index Index for item to be fetched from $_GET
+ * @param mixed $index Index for item to be fetched from $_GET
* @param bool $xss_clean Whether to apply XSS filtering
* @return mixed
*/
@@ -224,7 +227,7 @@ class CI_Input {
/**
* Fetch an item from the POST array
*
- * @param string $index Index for item to be fetched from $_POST
+ * @param mixed $index Index for item to be fetched from $_POST
* @param bool $xss_clean Whether to apply XSS filtering
* @return mixed
*/
@@ -270,7 +273,7 @@ class CI_Input {
/**
* Fetch an item from the COOKIE array
*
- * @param string $index Index for item to be fetched from $_COOKIE
+ * @param mixed $index Index for item to be fetched from $_COOKIE
* @param bool $xss_clean Whether to apply XSS filtering
* @return mixed
*/
@@ -284,7 +287,7 @@ class CI_Input {
/**
* Fetch an item from the SERVER array
*
- * @param string $index Index for item to be fetched from $_SERVER
+ * @param mixed $index Index for item to be fetched from $_SERVER
* @param bool $xss_clean Whether to apply XSS filtering
* @return mixed
*/
diff --git a/system/core/Output.php b/system/core/Output.php
index 8b7d6efbd..e8f0b1590 100644
--- a/system/core/Output.php
+++ b/system/core/Output.php
@@ -564,6 +564,11 @@ class CI_Output {
.$CI->config->item('index_page')
.$CI->uri->uri_string();
+ if ($CI->config->item('cache_query_string') && ! empty($_SERVER['QUERY_STRING']))
+ {
+ $uri .= '?'.$_SERVER['QUERY_STRING'];
+ }
+
$cache_path .= md5($uri);
if ( ! $fp = @fopen($cache_path, 'w+b'))
@@ -647,7 +652,13 @@ class CI_Output {
$cache_path = ($CFG->item('cache_path') === '') ? APPPATH.'cache/' : $CFG->item('cache_path');
// Build the file path. The file name is an MD5 hash of the full URI
- $uri = $CFG->item('base_url').$CFG->item('index_page').$URI->uri_string;
+ $uri = $CFG->item('base_url').$CFG->item('index_page').$URI->uri_string;
+
+ if ($CFG->item('cache_query_string') && ! empty($_SERVER['QUERY_STRING']))
+ {
+ $uri .= '?'.$_SERVER['QUERY_STRING'];
+ }
+
$filepath = $cache_path.md5($uri);
if ( ! file_exists($filepath) OR ! $fp = @fopen($filepath, 'rb'))
@@ -725,6 +736,11 @@ class CI_Output {
if (empty($uri))
{
$uri = $CI->uri->uri_string();
+
+ if ($CI->config->item('cache_query_string') && ! empty($_SERVER['QUERY_STRING']))
+ {
+ $uri .= '?'.$_SERVER['QUERY_STRING'];
+ }
}
$cache_path .= md5($CI->config->item('base_url').$CI->config->item('index_page').$uri);
diff --git a/system/database/DB_driver.php b/system/database/DB_driver.php
index 0b4707370..7c3df42b8 100644
--- a/system/database/DB_driver.php
+++ b/system/database/DB_driver.php
@@ -1461,7 +1461,7 @@ abstract class CI_DB_driver {
*/
protected function _has_operator($str)
{
- return (bool) preg_match('/(<|>|!|=|\sIS\s|\sEXISTS|\sBETWEEN|\sLIKE|\sIN\s*\(|\s)/i', trim($str));
+ return (bool) preg_match('/(<|>|!|=|\sIS NULL|\sIS NOT NULL|\sEXISTS|\sBETWEEN|\sLIKE|\sIN\s*\(|\s)/i', trim($str));
}
// --------------------------------------------------------------------
@@ -1485,7 +1485,8 @@ abstract class CI_DB_driver {
'\s*(?:<|>|!)?=\s*', // =, <=, >=, !=
'\s*<>?\s*', // <, <>
'\s*>\s*', // >
- '\s+IS(?:\sNOT)?(?:\sNULL)?', // IS[ NOT] NULL
+ '\s+IS NULL', // IS NULL
+ '\s+IS NOT NULL', // IS NOT NULL
'\s+EXISTS\s*\([^\)]+\)', // EXISTS(sql)
'\s+NOT EXISTS\s*\([^\)]+\)', // NOT EXISTS(sql)
'\s+BETWEEN\s+\S+\s+AND\s+\S+', // BETWEEN value AND value
diff --git a/system/database/DB_forge.php b/system/database/DB_forge.php
index 85505ce41..4238e37ee 100644
--- a/system/database/DB_forge.php
+++ b/system/database/DB_forge.php
@@ -207,12 +207,7 @@ abstract class CI_DB_forge {
*/
public function drop_database($db_name)
{
- if ($db_name === '')
- {
- show_error('A table name is required for that operation.');
- return FALSE;
- }
- elseif ($this->_drop_database === FALSE)
+ if ($this->_drop_database === FALSE)
{
return ($this->db->db_debug) ? $this->db->display_error('db_unsupported_feature') : FALSE;
}
@@ -242,13 +237,8 @@ abstract class CI_DB_forge {
* @param bool $primary
* @return CI_DB_forge
*/
- public function add_key($key = '', $primary = FALSE)
+ public function add_key($key, $primary = FALSE)
{
- if (empty($key))
- {
- show_error('Key information is required for that operation.');
- }
-
if ($primary === TRUE && is_array($key))
{
foreach ($key as $one)
@@ -279,13 +269,8 @@ abstract class CI_DB_forge {
* @param array $field
* @return CI_DB_forge
*/
- public function add_field($field = '')
+ public function add_field($field)
{
- if (empty($field))
- {
- show_error('Field information is required.');
- }
-
if (is_string($field))
{
if ($field === 'id')
@@ -328,7 +313,7 @@ abstract class CI_DB_forge {
* @param array $attributes Associative array of table attributes
* @return bool
*/
- public function create_table($table = '', $if_not_exists = FALSE, array $attributes = array())
+ public function create_table($table, $if_not_exists = FALSE, array $attributes = array())
{
if ($table === '')
{
@@ -575,18 +560,10 @@ abstract class CI_DB_forge {
* @param string $_after Column for AFTER clause (deprecated)
* @return bool
*/
- public function add_column($table = '', $field = array(), $_after = NULL)
+ public function add_column($table, $field, $_after = NULL)
{
- if ($table === '')
- {
- show_error('A table name is required for that operation.');
- }
-
// Work-around for literal column definitions
- if ( ! is_array($field))
- {
- $field = array($field);
- }
+ is_array($field) OR $field = array($field);
foreach (array_keys($field) as $k)
{
@@ -626,18 +603,8 @@ abstract class CI_DB_forge {
* @param string $column_name Column name
* @return bool
*/
- public function drop_column($table = '', $column_name = '')
+ public function drop_column($table, $column_name)
{
- if ($table === '')
- {
- show_error('A table name is required for that operation.');
- }
-
- if ($column_name === '')
- {
- show_error('A column name is required for that operation.');
- }
-
$sql = $this->_alter_table('DROP', $this->db->dbprefix.$table, $column_name);
if ($sql === FALSE)
{
@@ -656,18 +623,10 @@ abstract class CI_DB_forge {
* @param string $field Column definition
* @return bool
*/
- public function modify_column($table = '', $field = array())
+ public function modify_column($table, $field)
{
- if ($table === '')
- {
- show_error('A table name is required for that operation.');
- }
-
// Work-around for literal column definitions
- if ( ! is_array($field))
- {
- $field = array($field);
- }
+ is_array($field) OR $field = array($field);
foreach (array_keys($field) as $k)
{
diff --git a/system/database/DB_query_builder.php b/system/database/DB_query_builder.php
index c7326cd35..1c0aed693 100644
--- a/system/database/DB_query_builder.php
+++ b/system/database/DB_query_builder.php
@@ -672,7 +672,7 @@ abstract class CI_DB_query_builder extends CI_DB_driver {
// value appears not to have been set, assign the test to IS NULL
$k .= ' IS NULL';
}
- elseif (preg_match('/\s*(!?=|<>)\s*$/i', $k, $match, PREG_OFFSET_CAPTURE))
+ elseif (preg_match('/\s*(!?=|<>|IS(?:\s+NOT)?)\s*$/i', $k, $match, PREG_OFFSET_CAPTURE))
{
$k = substr($k, 0, $match[0][1]).($match[1][0] === '=' ? ' IS NULL' : ' IS NOT NULL');
}
diff --git a/system/database/drivers/pdo/subdrivers/pdo_sqlsrv_driver.php b/system/database/drivers/pdo/subdrivers/pdo_sqlsrv_driver.php
index 78591755a..42627139b 100644
--- a/system/database/drivers/pdo/subdrivers/pdo_sqlsrv_driver.php
+++ b/system/database/drivers/pdo/subdrivers/pdo_sqlsrv_driver.php
@@ -304,6 +304,9 @@ class CI_DB_pdo_sqlsrv_driver extends CI_DB_pdo_driver {
// As of SQL Server 2012 (11.0.*) OFFSET is supported
if (version_compare($this->version(), '11', '>='))
{
+ // SQL Server OFFSET-FETCH can be used only with the ORDER BY clause
+ empty($this->qb_orderby) && $sql .= ' ORDER BY 1';
+
return $sql.' OFFSET '.(int) $this->qb_offset.' ROWS FETCH NEXT '.$this->qb_limit.' ROWS ONLY';
}
diff --git a/system/database/drivers/postgre/postgre_driver.php b/system/database/drivers/postgre/postgre_driver.php
index bdb8a7127..18a218104 100644
--- a/system/database/drivers/postgre/postgre_driver.php
+++ b/system/database/drivers/postgre/postgre_driver.php
@@ -149,22 +149,21 @@ class CI_DB_postgre_driver extends CI_DB {
*/
public function db_connect($persistent = FALSE)
{
- if ($persistent === TRUE
- && ($this->conn_id = pg_pconnect($this->dsn))
- && pg_connection_status($this->conn_id) === PGSQL_CONNECTION_BAD
- && pg_ping($this->conn_id) === FALSE
- )
- {
- return FALSE;
- }
- else
- {
- $this->conn_id = pg_connect($this->dsn);
- }
+ $this->conn_id = ($persistent === TRUE)
+ ? pg_pconnect($this->dsn)
+ : pg_connect($this->dsn);
- if ($this->conn_id && ! empty($this->schema))
+ if ($this->conn_id !== FALSE)
{
- $this->simple_query('SET search_path TO '.$this->schema.',public');
+ if ($persistent === TRUE
+ && pg_connection_status($this->conn_id) === PGSQL_CONNECTION_BAD
+ && pg_ping($this->conn_id) === FALSE
+ )
+ {
+ return FALSE;
+ }
+
+ empty($this->schema) OR $this->simple_query('SET search_path TO '.$this->schema.',public');
}
return $this->conn_id;
diff --git a/system/database/drivers/sqlsrv/sqlsrv_driver.php b/system/database/drivers/sqlsrv/sqlsrv_driver.php
index 6afde6153..130271115 100644
--- a/system/database/drivers/sqlsrv/sqlsrv_driver.php
+++ b/system/database/drivers/sqlsrv/sqlsrv_driver.php
@@ -494,6 +494,9 @@ class CI_DB_sqlsrv_driver extends CI_DB {
// As of SQL Server 2012 (11.0.*) OFFSET is supported
if (version_compare($this->version(), '11', '>='))
{
+ // SQL Server OFFSET-FETCH can be used only with the ORDER BY clause
+ empty($this->qb_orderby) && $sql .= ' ORDER BY 1';
+
return $sql.' OFFSET '.(int) $this->qb_offset.' ROWS FETCH NEXT '.$this->qb_limit.' ROWS ONLY';
}
diff --git a/system/helpers/captcha_helper.php b/system/helpers/captcha_helper.php
index 5d023b28c..2ffa86d97 100644
--- a/system/helpers/captcha_helper.php
+++ b/system/helpers/captcha_helper.php
@@ -71,6 +71,7 @@ if ( ! function_exists('create_captcha'))
'font_path' => '',
'expiration' => 7200,
'word_length' => 8,
+ 'font_size' => 16,
'pool' => '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ',
'colors' => array(
'background' => array(255,255,255),
@@ -193,13 +194,13 @@ if ( ! function_exists('create_captcha'))
$use_font = ($font_path !== '' && file_exists($font_path) && function_exists('imagettftext'));
if ($use_font === FALSE)
{
- $font_size = 5;
+ ($font_size > 5) && $font_size = 5;
$x = mt_rand(0, $img_width / ($length / 3));
$y = 0;
}
else
{
- $font_size = 16;
+ ($font_size > 30) && $font_size = 30;
$x = mt_rand(0, $img_width / ($length / 1.5));
$y = $font_size + 2;
}
diff --git a/system/helpers/smiley_helper.php b/system/helpers/smiley_helper.php
index a529c4537..dc8406818 100644
--- a/system/helpers/smiley_helper.php
+++ b/system/helpers/smiley_helper.php
@@ -45,6 +45,7 @@ defined('BASEPATH') OR exit('No direct script access allowed');
* @category Helpers
* @author EllisLab Dev Team
* @link http://codeigniter.com/user_guide/helpers/smiley_helper.html
+ * @deprecated 3.0.0 This helper is too specific for CI.
*/
// ------------------------------------------------------------------------
@@ -228,7 +229,7 @@ if ( ! function_exists('_get_smiley_array'))
{
static $_smileys;
- if ( ! is_array($smileys))
+ if ( ! is_array($_smileys))
{
if (file_exists(APPPATH.'config/smileys.php'))
{
diff --git a/system/language/english/email_lang.php b/system/language/english/email_lang.php
index fdd823bc8..b6f03c71c 100644
--- a/system/language/english/email_lang.php
+++ b/system/language/english/email_lang.php
@@ -41,6 +41,7 @@ $lang['email_must_be_array'] = 'The email validation method must be passed an ar
$lang['email_invalid_address'] = 'Invalid email address: %s';
$lang['email_attachment_missing'] = 'Unable to locate the following email attachment: %s';
$lang['email_attachment_unreadable'] = 'Unable to open this attachment: %s';
+$lang['email_no_from'] = 'Cannot send mail with no "From" header.';
$lang['email_no_recipients'] = 'You must include recipients: To, Cc, or Bcc';
$lang['email_send_failure_phpmail'] = 'Unable to send email using PHP mail(). Your server might not be configured to send mail using this method.';
$lang['email_send_failure_sendmail'] = 'Unable to send email using PHP Sendmail. Your server might not be configured to send mail using this method.';
diff --git a/system/libraries/Cart.php b/system/libraries/Cart.php
index 14f08a8c3..72ef5e8b5 100644
--- a/system/libraries/Cart.php
+++ b/system/libraries/Cart.php
@@ -45,6 +45,7 @@ defined('BASEPATH') OR exit('No direct script access allowed');
* @category Shopping Cart
* @author EllisLab Dev Team
* @link http://codeigniter.com/user_guide/libraries/cart.html
+ * @deprecated 3.0.0 This class is too specific for CI.
*/
class CI_Cart {
diff --git a/system/libraries/Email.php b/system/libraries/Email.php
index a55d2ffea..5cb16896f 100644
--- a/system/libraries/Email.php
+++ b/system/libraries/Email.php
@@ -1630,6 +1630,12 @@ class CI_Email {
*/
public function send($auto_clear = TRUE)
{
+ if ( ! isset($this->_headers['From']))
+ {
+ $this->_set_error_message('lang:email_no_from');
+ return FALSE;
+ }
+
if ($this->_replyto_flag === FALSE)
{
$this->reply_to($this->_headers['From']);
diff --git a/system/libraries/Session/drivers/Session_cookie.php b/system/libraries/Session/drivers/Session_cookie.php
index 0001dc2d8..21ded899a 100644
--- a/system/libraries/Session/drivers/Session_cookie.php
+++ b/system/libraries/Session/drivers/Session_cookie.php
@@ -486,7 +486,7 @@ class CI_Session_cookie extends CI_Session_driver {
$db_cache = $this->CI->db->cache_on;
$this->CI->db->cache_off();
- $query = $this->CI->db->limit(1)->get($this->sess_table_name);
+ $query = $this->CI->db->get($this->sess_table_name);
// Was caching in effect?
if ($db_cache)
diff --git a/system/libraries/Zip.php b/system/libraries/Zip.php
index 434229471..2f6ab8b68 100644
--- a/system/libraries/Zip.php
+++ b/system/libraries/Zip.php
@@ -97,6 +97,15 @@ class CI_Zip {
public $now;
/**
+ * The level of compression
+ *
+ * Ranges from 0 to 9, with 9 being the highest level.
+ *
+ * @var int
+ */
+ public $compression_level = 2;
+
+ /**
* Initialize zip compression class
*
* @return void
@@ -248,7 +257,7 @@ class CI_Zip {
$uncompressed_size = strlen($data);
$crc32 = crc32($data);
- $gzdata = substr(gzcompress($data), 2, -4);
+ $gzdata = substr(gzcompress($data, $this->compression_level), 2, -4);
$compressed_size = strlen($gzdata);
$this->zipdata .=