Permalink
Browse files

Merge branch 'develop' of git://github.com/EllisLab/CodeIgniter into …

…load_config_units
  • Loading branch information...
2 parents cf99aac + f5f898f commit c2f59ef2d5d3ef28a113a11c24bee25eb03eeb56 @dchill42 committed Oct 23, 2012
Showing with 651 additions and 798 deletions.
  1. +18 −0 system/core/Common.php
  2. +1 −1 system/core/Config.php
  3. +1 −1 system/core/Security.php
  4. +2 −5 system/core/URI.php
  5. +29 −18 system/database/DB_driver.php
  6. +280 −199 system/database/DB_query_builder.php
  7. +8 −11 system/database/DB_result.php
  8. +5 −5 system/database/drivers/cubrid/cubrid_driver.php
  9. +14 −37 system/database/drivers/ibase/ibase_driver.php
  10. +16 −45 system/database/drivers/mssql/mssql_driver.php
  11. +5 −5 system/database/drivers/mysql/mysql_driver.php
  12. +4 −6 system/database/drivers/mysqli/mysqli_driver.php
  13. +10 −15 system/database/drivers/oci8/oci8_driver.php
  14. +34 −0 system/database/drivers/odbc/odbc_driver.php
  15. +4 −9 system/database/drivers/pdo/pdo_driver.php
  16. +9 −34 system/database/drivers/pdo/subdrivers/pdo_4d_driver.php
  17. +5 −5 system/database/drivers/pdo/subdrivers/pdo_cubrid_driver.php
  18. +16 −39 system/database/drivers/pdo/subdrivers/pdo_dblib_driver.php
  19. +10 −36 system/database/drivers/pdo/subdrivers/pdo_firebird_driver.php
  20. +7 −30 system/database/drivers/pdo/subdrivers/pdo_ibm_driver.php
  21. +9 −34 system/database/drivers/pdo/subdrivers/pdo_informix_driver.php
  22. +5 −5 system/database/drivers/pdo/subdrivers/pdo_mysql_driver.php
  23. +10 −15 system/database/drivers/pdo/subdrivers/pdo_oci_driver.php
  24. +9 −34 system/database/drivers/pdo/subdrivers/pdo_odbc_driver.php
  25. +30 −53 system/database/drivers/pdo/subdrivers/pdo_pgsql_driver.php
  26. +17 −40 system/database/drivers/pdo/subdrivers/pdo_sqlsrv_driver.php
  27. +29 −56 system/database/drivers/postgre/postgre_driver.php
  28. +17 −40 system/database/drivers/sqlsrv/sqlsrv_driver.php
  29. +2 −2 system/libraries/Pagination.php
  30. +6 −6 tests/codeigniter/core/URI_test.php
  31. +16 −0 tests/codeigniter/database/query_builder/like_test.php
  32. +2 −1 tests/mocks/database/schema/skeleton.php
  33. +5 −1 user_guide_src/source/changelog.rst
  34. +16 −10 user_guide_src/source/general/common_functions.rst
View
@@ -330,6 +330,24 @@ function &get_mimes()
// ------------------------------------------------------------------------
+if ( ! function_exists('is_https'))
+{
+ /**
+ * Is HTTPS?
+ *
+ * Determines if the application is accessed via an encrypted
+ * (HTTPS) connection.
+ *
+ * @return bool
+ */
+ function is_https()
+ {
+ return ( ! empty($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) !== 'off');
+ }
+}
+
+// ------------------------------------------------------------------------
+
if ( ! function_exists('show_error'))
{
/**
View
@@ -75,7 +75,7 @@ public function __construct()
{
if (isset($_SERVER['HTTP_HOST']))
{
- $base_url = ( ! empty($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) !== 'off') ? 'https' : 'http';
+ $base_url = is_https() ? 'https' : 'http';
$base_url .= '://'.$_SERVER['HTTP_HOST']
.str_replace(basename($_SERVER['SCRIPT_NAME']), '', $_SERVER['SCRIPT_NAME']);
}
View
@@ -198,7 +198,7 @@ public function csrf_set_cookie()
$expire = time() + $this->_csrf_expire;
$secure_cookie = (bool) config_item('cookie_secure');
- if ($secure_cookie && (empty($_SERVER['HTTPS']) OR strtolower($_SERVER['HTTPS']) === 'off'))
+ if ($secure_cookie && ! is_https())
{
return FALSE;
}
View
@@ -165,11 +165,8 @@ public function _fetch_uri_string()
*/
protected function _set_uri_string($str)
{
- // Filter out control characters
- $str = remove_invisible_characters($str, FALSE);
-
- // If the URI contains only a slash we'll kill it
- $this->uri_string = ($str === '/') ? '' : $str;
+ // Filter out control characters and trim slashes
+ $this->uri_string = trim(remove_invisible_characters($str, FALSE), '/');
}
// --------------------------------------------------------------------
@@ -1124,30 +1124,19 @@ public function update_string($table, $data, $where)
*
* @param string the table name
* @param array the update data
- * @param array the where clause
- * @param array the orderby clause
- * @param array the limit clause
- * @param array the like clause
* @return string
*/
- protected function _update($table, $values, $where, $orderby = array(), $limit = FALSE, $like = array())
+ protected function _update($table, $values)
{
foreach ($values as $key => $val)
{
$valstr[] = $key.' = '.$val;
}
- $where = empty($where) ? '' : ' WHERE '.implode(' ', $where);
-
- if ( ! empty($like))
- {
- $where .= ($where === '' ? ' WHERE ' : ' AND ').implode(' ', $like);
- }
-
return 'UPDATE '.$table.' SET '.implode(', ', $valstr)
- .$where
- .(count($orderby) > 0 ? ' ORDER BY '.implode(', ', $orderby) : '')
- .($limit ? ' LIMIT '.$limit : '');
+ .$this->_compile_wh('qb_where')
+ .$this->_compile_order_by()
+ .($this->qb_limit ? ' LIMIT '.$this->qb_limit : '');
}
// --------------------------------------------------------------------
@@ -1160,7 +1149,7 @@ protected function _update($table, $values, $where, $orderby = array(), $limit =
*/
protected function _has_operator($str)
{
- return (bool) preg_match('/(\s|<|>|!|=|IS NULL|IS NOT NULL|BETWEEN)/i', trim($str));
+ return (bool) preg_match('/(<|>|!|=|\sIS NULL|\sIS NOT NULL|\sBETWEEN|\sLIKE|\sIN\s*\(|\s)/i', trim($str));
}
// --------------------------------------------------------------------
@@ -1173,8 +1162,30 @@ protected function _has_operator($str)
*/
protected function _get_operator($str)
{
- return preg_match('/(=|!|<|>| IS NULL| IS NOT NULL| BETWEEN)/i', $str, $match)
- ? $match[1] : FALSE;
+ static $_operators;
+
+ if (empty($_operators))
+ {
+ $_les = ($this->_like_escape_str !== '')
+ ? '\s+'.preg_quote(trim(sprintf($this->_like_escape_str, $this->_like_escape_chr)))
+ : '';
+ $_operators = array(
+ '\s*(?:<|>|!)?=\s*', // =, <=, >=, !=
+ '\s*<>?\s*', // <, <>
+ '\s*>\s*', // >
+ '\s+IS NULL', // IS NULL
+ '\s+IS NOT NULL', // IS NOT NULL
+ '\s+BETWEEN\s+\S+\s+AND\s+\S+', // BETWEEN value AND value
+ '\s+IN\s*\([^\)]+\)', // IN(list)
+ '\s+NOT IN\s*\([^\)]+\)', // NOT IN (list)
+ '\s+LIKE\s+\S+'.$_les, // LIKE 'expr'[ ESCAPE '%s']
+ '\s+NOT LIKE\s+\S+'.$_les // NOT LIKE 'expr'[ ESCAPE '%s']
+ );
+
+ }
+
+ return preg_match('/'.implode('|', $_operators).'/i', $str, $match)
+ ? $match[0] : FALSE;
}
// --------------------------------------------------------------------
Oops, something went wrong.

0 comments on commit c2f59ef

Please sign in to comment.