Permalink
Browse files

ci update

  • Loading branch information...
2 parents 9287139 + dc83e04 commit f4895cbcd90383e03a261bf594e71287d632dda5 @it-can committed Nov 6, 2012
Showing with 3,659 additions and 1,570 deletions.
  1. +42 −40 system/core/CodeIgniter.php
  2. +3 −7 system/core/Input.php
  3. +52 −31 system/core/Loader.php
  4. +22 −56 system/core/Router.php
  5. +572 −68 system/database/DB_forge.php
  6. +5 −6 system/database/DB_utility.php
  7. +12 −3 system/database/drivers/cubrid/cubrid_driver.php
  8. +78 −136 system/database/drivers/cubrid/cubrid_forge.php
  9. +122 −82 system/database/drivers/ibase/ibase_forge.php
  10. +64 −96 system/database/drivers/mssql/mssql_forge.php
  11. +15 −3 system/database/drivers/mysql/mysql_driver.php
  12. +92 −116 system/database/drivers/mysql/mysql_forge.php
  13. +10 −3 system/database/drivers/mysqli/mysqli_driver.php
  14. +92 −116 system/database/drivers/mysqli/mysqli_forge.php
  15. +15 −3 system/database/drivers/oci8/oci8_driver.php
  16. +43 −88 system/database/drivers/oci8/oci8_forge.php
  17. +17 −109 system/database/drivers/odbc/odbc_forge.php
  18. +4 −0 system/database/drivers/pdo/pdo_driver.php
  19. +5 −126 system/database/drivers/pdo/pdo_forge.php
  20. +209 −0 system/database/drivers/pdo/subdrivers/pdo_4d_forge.php
  21. +173 −0 system/database/drivers/pdo/subdrivers/pdo_cubrid_forge.php
  22. +136 −0 system/database/drivers/pdo/subdrivers/pdo_dblib_forge.php
  23. +228 −0 system/database/drivers/pdo/subdrivers/pdo_firebird_forge.php
  24. +146 −0 system/database/drivers/pdo/subdrivers/pdo_ibm_forge.php
  25. +155 −0 system/database/drivers/pdo/subdrivers/pdo_informix_forge.php
  26. +199 −0 system/database/drivers/pdo/subdrivers/pdo_mysql_forge.php
  27. +133 −0 system/database/drivers/pdo/subdrivers/pdo_oci_forge.php
  28. +62 −0 system/database/drivers/pdo/subdrivers/pdo_odbc_forge.php
  29. +194 −0 system/database/drivers/pdo/subdrivers/pdo_pgsql_forge.php
  30. +229 −0 system/database/drivers/pdo/subdrivers/pdo_sqlite_forge.php
  31. +136 −0 system/database/drivers/pdo/subdrivers/pdo_sqlsrv_forge.php
  32. +5 −1 system/database/drivers/postgre/postgre_driver.php
  33. +104 −142 system/database/drivers/postgre/postgre_forge.php
  34. +92 −100 system/database/drivers/sqlite/sqlite_forge.php
  35. +103 −99 system/database/drivers/sqlite3/sqlite3_forge.php
  36. +5 −1 system/database/drivers/sqlsrv/sqlsrv_driver.php
  37. +64 −96 system/database/drivers/sqlsrv/sqlsrv_forge.php
  38. +5 −12 system/helpers/date_helper.php
  39. +8 −3 system/libraries/Form_validation.php
  40. +1 −1 system/libraries/Log.php
  41. +1 −1 system/libraries/Session/Session.php
  42. +6 −25 system/libraries/Unit_test.php
@@ -267,9 +267,11 @@ function &get_instance()
{
if ( ! empty($RTR->routes['404_override']))
{
- $x = explode('/', $RTR->routes['404_override'], 2);
- $class = $x[0];
- $method = isset($x[1]) ? $x[1] : 'index';
+ if (sscanf($RTR->routes['404_override'], '%[^/]/%s', $class, $method) !== 2)
+ {
+ $method = 'index';
+ }
+
if ( ! class_exists($class))
{
if ( ! file_exists(APPPATH.'controllers/'.$class.'.php'))
@@ -286,6 +288,42 @@ function &get_instance()
}
}
+ if (method_exists($class, '_remap'))
+ {
+ $params = array($method, array_slice($URI->rsegments, 2));
+ $method = '_remap';
+ }
+ else
+ {
+ // WARNING: It appears that there are issues with is_callable() even in PHP 5.2!
+ // Furthermore, there are bug reports and feature/change requests related to it
+ // that make it unreliable to use in this context. Please, DO NOT change this
+ // work-around until a better alternative is available.
+ if ( ! in_array(strtolower($method), array_map('strtolower', get_class_methods($class)), TRUE))
+ {
+ if (empty($RTR->routes['404_override']))
+ {
+ show_404($class.'/'.$method);
+ }
+ elseif (sscanf($RTR->routes['404_override'], '%[^/]/%s', $class, $method) !== 2)
+ {
+ $method = 'index';
+ }
+
+ if ( ! class_exists($class))
+ {
+ if ( ! file_exists(APPPATH.'controllers/'.$class.'.php'))
+ {
+ show_404($class.'/'.$method);
+ }
+
+ include_once(APPPATH.'controllers/'.$class.'.php');
+ }
+ }
+
+ $params = array_slice($URI->rsegments, 2);
+ }
+
/*
* ------------------------------------------------------
* Is there a "pre_controller" hook?
@@ -315,43 +353,7 @@ function &get_instance()
* Call the requested method
* ------------------------------------------------------
*/
- // Is there a "remap" function? If so, we call it instead
- if (method_exists($CI, '_remap'))
- {
- $CI->_remap($method, array_slice($URI->rsegments, 2));
- }
- else
- {
- if ( ! is_callable(array($CI, $method)))
- {
- // Check and see if we are using a 404 override and use it.
- if ( ! empty($RTR->routes['404_override']))
- {
- $x = explode('/', $RTR->routes['404_override'], 2);
- $class = $x[0];
- $method = isset($x[1]) ? $x[1] : 'index';
- if ( ! class_exists($class))
- {
- if ( ! file_exists(APPPATH.'controllers/'.$class.'.php'))
- {
- show_404($class.'/'.$method);
- }
-
- include_once(APPPATH.'controllers/'.$class.'.php');
- unset($CI);
- $CI = new $class();
- }
- }
- else
- {
- show_404($class.'/'.$method);
- }
- }
-
- // Call the requested method.
- // Any URI segments present (besides the class/function) will be passed to the method for convenience
- call_user_func_array(array(&$CI, $method), array_slice($URI->rsegments, 2));
- }
+ call_user_func_array(array(&$CI, $method), $params);
// Mark a benchmark end point
$BM->mark('controller_execution_time_( '.$class.' / '.$method.' )_end');
View
@@ -356,11 +356,7 @@ public function ip_address()
// Some proxies typically list the whole chain of IP
// addresses through which the client has reached us.
// e.g. client_ip, proxy_ip1, proxy_ip2, etc.
- if (strpos($spoof, ',') !== FALSE)
- {
- $spoof = explode(',', $spoof, 2);
- $spoof = $spoof[0];
- }
+ sscanf($spoof, '%[^,]', $spoof);
if ( ! $this->valid_ip($spoof))
{
@@ -430,7 +426,7 @@ public function ip_address()
}
// Split the netmask length off the network address
- list($netaddr, $masklen) = explode('/', $proxy_ips[$i], 2);
+ sscanf($proxy_ips[$i], '%[^/]/%d', $netaddr, $masklen);
// Again, an IPv6 address is most likely in a compressed form
if ($separator === ':')
@@ -695,7 +691,7 @@ protected function _clean_input_data($str)
*/
protected function _clean_input_keys($str)
{
- if ( ! preg_match('/^[a-z0-9:_\/-]+$/i', $str))
+ if ( ! preg_match('/^[a-z0-9:_\/|-]+$/i', $str))
{
set_status_header(503);
exit('Disallowed Key Characters.');
View
@@ -130,7 +130,7 @@ class CI_Loader {
/**
* Class constructor
*
- * Sets component load paths gets the initial output buffering level.
+ * Sets component load paths, gets the initial output buffering level.
*
* @return void
*/
@@ -148,21 +148,18 @@ public function __construct()
// --------------------------------------------------------------------
/**
- * Initialize the Loader
+ * Initializer
*
- * @used-by CI_Controller
+ * @todo Figure out a way to move this to the constructor
+ * without breaking *package_path*() methods.
* @uses CI_Loader::_ci_autoloader()
- * @return object $this
+ * @used-by CI_Controller::__construct()
+ * @return void
*/
public function initialize()
{
- $this->_ci_classes = array();
- $this->_ci_loaded_files = array();
- $this->_ci_models = array();
$this->_base_classes =& is_loaded();
-
$this->_ci_autoloader();
- return $this;
}
// --------------------------------------------------------------------
@@ -355,49 +352,73 @@ public function database($params = '', $return = FALSE, $query_builder = NULL)
/**
* Load the Database Utilities Class
*
- * @return void
+ * @param object $db Database object
+ * @param bool $return Whether to return the DB Forge class object or not
+ * @return void|object
*/
- public function dbutil()
+ public function dbutil($db = NULL, $return = FALSE)
{
- if ( ! class_exists('CI_DB'))
- {
- $this->database();
- }
-
$CI =& get_instance();
- // for backwards compatibility, load dbforge so we can extend dbutils off it
- // this use is deprecated and strongly discouraged
- $CI->load->dbforge();
+ if ( ! is_object($db) OR ! ($db instanceof CI_DB))
+ {
+ class_exists('CI_DB', FALSE) OR $this->database();
+ $db =& $CI->db;
+ }
require_once(BASEPATH.'database/DB_utility.php');
- require_once(BASEPATH.'database/drivers/'.$CI->db->dbdriver.'/'.$CI->db->dbdriver.'_utility.php');
- $class = 'CI_DB_'.$CI->db->dbdriver.'_utility';
+ require_once(BASEPATH.'database/drivers/'.$db->dbdriver.'/'.$db->dbdriver.'_utility.php');
+ $class = 'CI_DB_'.$db->dbdriver.'_utility';
- $CI->dbutil = new $class();
+ if ($return === TRUE)
+ {
+ return new $class($db);
+ }
+
+ $CI->dbutil = new $class($db);
}
// --------------------------------------------------------------------
/**
* Load the Database Forge Class
*
- * @return void
+ * @param object $db Database object
+ * @param bool $return Whether to return the DB Forge class object or not
+ * @return void|object
*/
- public function dbforge()
+ public function dbforge($db = NULL, $return = FALSE)
{
- if ( ! class_exists('CI_DB'))
+ $CI =& get_instance();
+ if ( ! is_object($db) OR ! ($db instanceof CI_DB))
{
- $this->database();
+ class_exists('CI_DB', FALSE) OR $this->database();
+ $db =& $CI->db;
}
- $CI =& get_instance();
-
require_once(BASEPATH.'database/DB_forge.php');
- require_once(BASEPATH.'database/drivers/'.$CI->db->dbdriver.'/'.$CI->db->dbdriver.'_forge.php');
- $class = 'CI_DB_'.$CI->db->dbdriver.'_forge';
+ require_once(BASEPATH.'database/drivers/'.$db->dbdriver.'/'.$db->dbdriver.'_forge.php');
+
+ if ( ! empty($db->subdriver))
+ {
+ $driver_path = BASEPATH.'database/drivers/'.$db->dbdriver.'/subdrivers/'.$db->dbdriver.'_'.$db->subdriver.'_forge.php';
+ if (file_exists($driver_path))
+ {
+ require_once($driver_path);
+ $class = 'CI_DB_'.$db->dbdriver.'_'.$db->subdriver.'_forge';
+ }
+ }
+ else
+ {
+ $class = 'CI_DB_'.$db->dbdriver.'_forge';
+ }
+
+ if ($return === TRUE)
+ {
+ return new $class($db);
+ }
- $CI->dbforge = new $class();
+ $CI->dbforge = new $class($db);
}
// --------------------------------------------------------------------
Oops, something went wrong.

0 comments on commit f4895cb

Please sign in to comment.