summaryrefslogtreecommitdiffstats
path: root/system
diff options
context:
space:
mode:
authorFlorian Pritz <bluewind@xinu.at>2011-08-21 17:09:54 +0200
committerFlorian Pritz <bluewind@xinu.at>2011-08-21 17:09:54 +0200
commit9f52b09abe8dd2919cf9b5d22d12abb0203eb8a8 (patch)
treefd94ba9616ccc4cfbdb3ecfddece0ce2fa1bba24 /system
parentcaec47b75d132b98a1b251448a46d3756d05c7b8 (diff)
parentc09370bebb08082ab0655a964a6e6e1331ed47fb (diff)
Merge branch 'working'
Diffstat (limited to 'system')
-rwxr-xr-xsystem/core/CodeIgniter.php24
-rwxr-xr-xsystem/core/Common.php75
-rwxr-xr-xsystem/core/Config.php67
-rwxr-xr-xsystem/core/Controller.php7
-rwxr-xr-xsystem/core/Exceptions.php4
-rwxr-xr-xsystem/core/Hooks.php8
-rwxr-xr-xsystem/core/Input.php2
-rwxr-xr-xsystem/core/Lang.php12
-rwxr-xr-xsystem/core/Loader.php270
-rwxr-xr-xsystem/core/Output.php6
-rwxr-xr-xsystem/core/Router.php14
-rwxr-xr-xsystem/core/Security.php18
-rwxr-xr-xsystem/core/URI.php12
-rwxr-xr-xsystem/database/DB.php12
-rwxr-xr-xsystem/database/DB_active_rec.php300
-rwxr-xr-xsystem/database/DB_driver.php6
-rwxr-xr-xsystem/database/DB_result.php97
-rwxr-xr-xsystem/database/drivers/mysql/mysql_driver.php17
-rwxr-xr-xsystem/database/drivers/mysql/mysql_forge.php8
-rwxr-xr-xsystem/database/drivers/mysqli/mysqli_driver.php17
-rwxr-xr-xsystem/database/drivers/mysqli/mysqli_forge.php8
-rwxr-xr-xsystem/database/drivers/postgre/postgre_driver.php18
-rw-r--r--system/database/drivers/sqlsrv/index.html10
-rw-r--r--system/database/drivers/sqlsrv/sqlsrv_driver.php598
-rw-r--r--system/database/drivers/sqlsrv/sqlsrv_forge.php248
-rw-r--r--system/database/drivers/sqlsrv/sqlsrv_result.php169
-rw-r--r--system/database/drivers/sqlsrv/sqlsrv_utility.php88
-rwxr-xr-xsystem/fonts/texb.ttfbin152992 -> 143830 bytes
-rwxr-xr-xsystem/helpers/download_helper.php8
-rwxr-xr-xsystem/helpers/file_helper.php8
-rwxr-xr-xsystem/helpers/form_helper.php28
-rwxr-xr-xsystem/helpers/html_helper.php17
-rwxr-xr-xsystem/helpers/inflector_helper.php115
-rwxr-xr-xsystem/helpers/smiley_helper.php8
-rwxr-xr-xsystem/helpers/text_helper.php8
-rwxr-xr-xsystem/helpers/url_helper.php11
-rwxr-xr-xsystem/language/english/profiler_lang.php3
-rwxr-xr-xsystem/libraries/Cache/drivers/Cache_dummy.php24
-rwxr-xr-xsystem/libraries/Calendar.php2
-rwxr-xr-xsystem/libraries/Cart.php4
-rwxr-xr-xsystem/libraries/Driver.php12
-rwxr-xr-xsystem/libraries/Email.php46
-rwxr-xr-xsystem/libraries/Encrypt.php2
-rwxr-xr-xsystem/libraries/Form_validation.php6
-rwxr-xr-xsystem/libraries/Log.php2
-rwxr-xr-xsystem/libraries/Pagination.php2
-rwxr-xr-xsystem/libraries/Profiler.php78
-rwxr-xr-xsystem/libraries/Session.php8
-rwxr-xr-xsystem/libraries/Upload.php8
-rwxr-xr-xsystem/libraries/User_agent.php8
50 files changed, 1946 insertions, 577 deletions
diff --git a/system/core/CodeIgniter.php b/system/core/CodeIgniter.php
index e022e1b46..94fecb5c0 100755
--- a/system/core/CodeIgniter.php
+++ b/system/core/CodeIgniter.php
@@ -32,7 +32,7 @@
* Define the CodeIgniter Version
* ------------------------------------------------------
*/
- define('CI_VERSION', '2.0.2');
+ define('CI_VERSION', '2.0.3');
/*
* ------------------------------------------------------
@@ -46,20 +46,20 @@
* Load the global functions
* ------------------------------------------------------
*/
- require(BASEPATH.'core/Common'.EXT);
+ require(BASEPATH.'core/Common.php');
/*
* ------------------------------------------------------
* Load the framework constants
* ------------------------------------------------------
*/
- if (defined('ENVIRONMENT') AND file_exists(APPPATH.'config/'.ENVIRONMENT.'/constants'.EXT))
+ if (defined('ENVIRONMENT') AND file_exists(APPPATH.'config/'.ENVIRONMENT.'/constants.php'))
{
- require(APPPATH.'config/'.ENVIRONMENT.'/constants'.EXT);
+ require(APPPATH.'config/'.ENVIRONMENT.'/constants.php');
}
else
{
- require(APPPATH.'config/constants'.EXT);
+ require(APPPATH.'config/constants.php');
}
/*
@@ -224,7 +224,7 @@
*
*/
// Load the base controller class
- require BASEPATH.'core/Controller'.EXT;
+ require BASEPATH.'core/Controller.php';
function &get_instance()
{
@@ -232,20 +232,20 @@
}
- if (file_exists(APPPATH.'core/'.$CFG->config['subclass_prefix'].'Controller'.EXT))
+ if (file_exists(APPPATH.'core/'.$CFG->config['subclass_prefix'].'Controller.php'))
{
- require APPPATH.'core/'.$CFG->config['subclass_prefix'].'Controller'.EXT;
+ require APPPATH.'core/'.$CFG->config['subclass_prefix'].'Controller.php';
}
// Load the local application controller
// Note: The Router class automatically validates the controller path using the router->_validate_request().
// If this include fails it means that the default controller in the Routes.php file is not resolving to something valid.
- if ( ! file_exists(APPPATH.'controllers/'.$RTR->fetch_directory().$RTR->fetch_class().EXT))
+ if ( ! file_exists(APPPATH.'controllers/'.$RTR->fetch_directory().$RTR->fetch_class().'.php'))
{
show_error('Unable to load your default controller. Please make sure the controller specified in your Routes.php file is valid.');
}
- include(APPPATH.'controllers/'.$RTR->fetch_directory().$RTR->fetch_class().EXT);
+ include(APPPATH.'controllers/'.$RTR->fetch_directory().$RTR->fetch_class().'.php');
// Set a mark point for benchmarking
$BM->mark('loading_time:_base_classes_end');
@@ -318,12 +318,12 @@
$method = (isset($x[1]) ? $x[1] : 'index');
if ( ! class_exists($class))
{
- if ( ! file_exists(APPPATH.'controllers/'.$class.EXT))
+ if ( ! file_exists(APPPATH.'controllers/'.$class.'.php'))
{
show_404("{$class}/{$method}");
}
- include_once(APPPATH.'controllers/'.$class.EXT);
+ include_once(APPPATH.'controllers/'.$class.'.php');
unset($CI);
$CI = new $class();
}
diff --git a/system/core/Common.php b/system/core/Common.php
index 1aca809ab..db9fbeb9f 100755
--- a/system/core/Common.php
+++ b/system/core/Common.php
@@ -39,6 +39,8 @@
* @param string
* @return bool TRUE if the current version is $version or higher
*/
+if ( ! function_exists('is_php'))
+{
function is_php($version = '5.0.0')
{
static $_is_php;
@@ -51,6 +53,7 @@
return $_is_php[$version];
}
+}
// ------------------------------------------------------------------------
@@ -64,6 +67,8 @@
* @access private
* @return void
*/
+if ( ! function_exists('is_really_writable'))
+{
function is_really_writable($file)
{
// If we're on a Unix server with safe_mode off we call is_writable
@@ -96,6 +101,7 @@
fclose($fp);
return TRUE;
}
+}
// ------------------------------------------------------------------------
@@ -112,6 +118,8 @@
* @param string the class name prefix
* @return object
*/
+if ( ! function_exists('load_class'))
+{
function &load_class($class, $directory = 'libraries', $prefix = 'CI_')
{
static $_classes = array();
@@ -128,13 +136,13 @@
// thenin the local application/libraries folder
foreach (array(BASEPATH, APPPATH) as $path)
{
- if (file_exists($path.$directory.'/'.$class.EXT))
+ if (file_exists($path.$directory.'/'.$class.'.php'))
{
$name = $prefix.$class;
if (class_exists($name) === FALSE)
{
- require($path.$directory.'/'.$class.EXT);
+ require($path.$directory.'/'.$class.'.php');
}
break;
@@ -142,13 +150,13 @@
}
// Is the request a class extension? If so we load it too
- if (file_exists(APPPATH.$directory.'/'.config_item('subclass_prefix').$class.EXT))
+ if (file_exists(APPPATH.$directory.'/'.config_item('subclass_prefix').$class.'.php'))
{
$name = config_item('subclass_prefix').$class;
if (class_exists($name) === FALSE)
{
- require(APPPATH.$directory.'/'.config_item('subclass_prefix').$class.EXT);
+ require(APPPATH.$directory.'/'.config_item('subclass_prefix').$class.'.php');
}
}
@@ -157,7 +165,7 @@
{
// Note: We use exit() rather then show_error() in order to avoid a
// self-referencing loop with the Excptions class
- exit('Unable to locate the specified class: '.$class.EXT);
+ exit('Unable to locate the specified class: '.$class.'.php');
}
// Keep track of what we just loaded
@@ -166,6 +174,7 @@
$_classes[$class] = new $name();
return $_classes[$class];
}
+}
// --------------------------------------------------------------------
@@ -176,6 +185,8 @@
* @access public
* @return array
*/
+if ( ! function_exists('is_loaded'))
+{
function is_loaded($class = '')
{
static $_is_loaded = array();
@@ -187,6 +198,7 @@
return $_is_loaded;
}
+}
// ------------------------------------------------------------------------
@@ -199,6 +211,8 @@
* @access private
* @return array
*/
+if ( ! function_exists('get_config'))
+{
function &get_config($replace = array())
{
static $_config;
@@ -209,9 +223,9 @@
}
// Is the config file in the environment folder?
- if ( ! defined('ENVIRONMENT') OR ! file_exists($file_path = APPPATH.'config/'.ENVIRONMENT.'/config'.EXT))
+ if ( ! defined('ENVIRONMENT') OR ! file_exists($file_path = APPPATH.'config/'.ENVIRONMENT.'/config.php'))
{
- $file_path = APPPATH.'config/config'.EXT;
+ $file_path = APPPATH.'config/config.php';
}
// Fetch the config file
@@ -242,6 +256,7 @@
return $_config[0] =& $config;
}
+}
// ------------------------------------------------------------------------
@@ -251,6 +266,8 @@
* @access public
* @return mixed
*/
+if ( ! function_exists('config_item'))
+{
function config_item($item)
{
static $_config_item = array();
@@ -268,6 +285,7 @@
return $_config_item[$item];
}
+}
// ------------------------------------------------------------------------
@@ -283,12 +301,15 @@
* @access public
* @return void
*/
+if ( ! function_exists('show_error'))
+{
function show_error($message, $status_code = 500, $heading = 'An Error Was Encountered')
{
$_error =& load_class('Exceptions', 'core');
echo $_error->show_error($heading, $message, 'error_general', $status_code);
exit;
}
+}
// ------------------------------------------------------------------------
@@ -302,12 +323,15 @@
* @access public
* @return void
*/
+if ( ! function_exists('show_404'))
+{
function show_404($page = '', $log_error = TRUE)
{
$_error =& load_class('Exceptions', 'core');
$_error->show_404($page, $log_error);
exit;
}
+}
// ------------------------------------------------------------------------
@@ -320,6 +344,8 @@
* @access public
* @return void
*/
+if ( ! function_exists('log_message'))
+{
function log_message($level = 'error', $message, $php_error = FALSE)
{
static $_log;
@@ -332,6 +358,7 @@
$_log =& load_class('Log');
$_log->write_log($level, $message, $php_error);
}
+}
// ------------------------------------------------------------------------
@@ -343,6 +370,8 @@
* @param string
* @return void
*/
+if ( ! function_exists('set_status_header'))
+{
function set_status_header($code = 200, $text = '')
{
$stati = array(
@@ -417,6 +446,7 @@
header("HTTP/1.1 {$code} {$text}", TRUE, $code);
}
}
+}
// --------------------------------------------------------------------
@@ -434,6 +464,8 @@
* @access private
* @return void
*/
+if ( ! function_exists('_exception_handler'))
+{
function _exception_handler($severity, $message, $filepath, $line)
{
// We don't bother with "strict" notices since they tend to fill up
@@ -463,19 +495,22 @@
$_error->log_exception($severity, $message, $filepath, $line);
}
+}
- // --------------------------------------------------------------------
-
- /**
- * Remove Invisible Characters
- *
- * This prevents sandwiching null characters
- * between ascii characters, like Java\0script.
- *
- * @access public
- * @param string
- * @return string
- */
+// --------------------------------------------------------------------
+
+/**
+ * Remove Invisible Characters
+ *
+ * This prevents sandwiching null characters
+ * between ascii characters, like Java\0script.
+ *
+ * @access public
+ * @param string
+ * @return string
+ */
+if ( ! function_exists('remove_invisible_characters'))
+{
function remove_invisible_characters($str, $url_encoded = TRUE)
{
$non_displayables = array();
@@ -499,7 +534,7 @@
return $str;
}
-
+}
/* End of file Common.php */
/* Location: ./system/core/Common.php */ \ No newline at end of file
diff --git a/system/core/Config.php b/system/core/Config.php
index 863c5ef4b..0e6f10e07 100755
--- a/system/core/Config.php
+++ b/system/core/Config.php
@@ -80,7 +80,7 @@ class CI_Config {
*/
function load($file = '', $use_sections = FALSE, $fail_gracefully = FALSE)
{
- $file = ($file == '') ? 'config' : str_replace(EXT, '', $file);
+ $file = ($file == '') ? 'config' : str_replace('.php', '', $file);
$found = FALSE;
$loaded = FALSE;
@@ -92,7 +92,7 @@ class CI_Config {
foreach ($check_locations as $location)
{
- $file_path = $path.'config/'.$location.EXT;
+ $file_path = $path.'config/'.$location.'.php';
if (in_array($file_path, $this->is_loaded, TRUE))
{
@@ -144,6 +144,7 @@ class CI_Config {
$loaded = TRUE;
log_message('debug', 'Config file loaded: '.$file_path);
+ break;
}
if ($loaded === FALSE)
@@ -152,7 +153,7 @@ class CI_Config {
{
return FALSE;
}
- show_error('The configuration file '.$file.EXT.' does not exist.');
+ show_error('The configuration file '.$file.'.php'.' does not exist.');
}
return TRUE;
@@ -202,10 +203,7 @@ class CI_Config {
// --------------------------------------------------------------------
/**
- * Fetch a config file item - adds slash after item
- *
- * The second parameter allows a slash to be added to the end of
- * the item, in the case of a path.
+ * Fetch a config file item - adds slash after item (if item is not empty)
*
* @access public
* @param string the config item name
@@ -218,6 +216,10 @@ class CI_Config {
{
return FALSE;
}
+ if( trim($this->config[$item]) == '')
+ {
+ return '';
+ }
return rtrim($this->config[$item], '/').'/';
}
@@ -226,6 +228,7 @@ class CI_Config {
/**
* Site URL
+ * Returns base_url . index_page [. uri_string]
*
* @access public
* @param string the URI string
@@ -240,14 +243,48 @@ class CI_Config {
if ($this->item('enable_query_strings') == FALSE)
{
+ $suffix = ($this->item('url_suffix') == FALSE) ? '' : $this->item('url_suffix');
+ return $this->slash_item('base_url').$this->slash_item('index_page').$this->_uri_string($uri).$suffix;
+ }
+ else
+ {
+ return $this->slash_item('base_url').$this->item('index_page').'?'.$this->_uri_string($uri);
+ }
+ }
+
+ // -------------------------------------------------------------
+
+ /**
+ * Base URL
+ * Returns base_url [. uri_string]
+ *
+ * @access public
+ * @param string $uri
+ * @return string
+ */
+ function base_url($uri = '')
+ {
+ return $this->slash_item('base_url').ltrim($this->_uri_string($uri),'/');
+ }
+
+ // -------------------------------------------------------------
+
+ /**
+ * Build URI string for use in Config::site_url() and Config::base_url()
+ *
+ * @access protected
+ * @param $uri
+ * @return string
+ */
+ protected function _uri_string($uri)
+ {
+ if ($this->item('enable_query_strings') == FALSE)
+ {
if (is_array($uri))
{
$uri = implode('/', $uri);
}
-
- $index = $this->item('index_page') == '' ? '' : $this->slash_item('index_page');
- $suffix = ($this->item('url_suffix') == FALSE) ? '' : $this->item('url_suffix');
- return $this->slash_item('base_url').$index.trim($uri, '/').$suffix;
+ $uri = trim($uri, '/');
}
else
{
@@ -261,16 +298,14 @@ class CI_Config {
$str .= $prefix.$key.'='.$val;
$i++;
}
-
$uri = $str;
}
-
- return $this->slash_item('base_url').$this->item('index_page').'?'.$uri;
}
+ return $uri;
}
// --------------------------------------------------------------------
-
+
/**
* System URL
*
@@ -326,4 +361,4 @@ class CI_Config {
// END CI_Config class
/* End of file Config.php */
-/* Location: ./system/core/Config.php */ \ No newline at end of file
+/* Location: ./system/core/Config.php */
diff --git a/system/core/Controller.php b/system/core/Controller.php
index 469663f09..ec86b7920 100755
--- a/system/core/Controller.php
+++ b/system/core/Controller.php
@@ -48,12 +48,9 @@ class CI_Controller {
$this->load =& load_class('Loader', 'core');
- $this->load->_base_classes =& is_loaded();
-
- $this->load->_ci_autoloader();
-
+ $this->load->set_base_classes()->ci_autoloader();
+
log_message('debug', "Controller Class Initialized");
-
}
public static function &get_instance()
diff --git a/system/core/Exceptions.php b/system/core/Exceptions.php
index f5659561c..bff86a92f 100755
--- a/system/core/Exceptions.php
+++ b/system/core/Exceptions.php
@@ -128,7 +128,7 @@ class CI_Exceptions {
ob_end_flush();
}
ob_start();
- include(APPPATH.'errors/'.$template.EXT);
+ include(APPPATH.'errors/'.$template.'.php');
$buffer = ob_get_contents();
ob_end_clean();
return $buffer;
@@ -164,7 +164,7 @@ class CI_Exceptions {
ob_end_flush();
}
ob_start();
- include(APPPATH.'errors/error_php'.EXT);
+ include(APPPATH.'errors/error_php.php');
$buffer = ob_get_contents();
ob_end_clean();
echo $buffer;
diff --git a/system/core/Hooks.php b/system/core/Hooks.php
index 24fa1055b..fd6380f0a 100755
--- a/system/core/Hooks.php
+++ b/system/core/Hooks.php
@@ -65,13 +65,13 @@ class CI_Hooks {
// Grab the "hooks" definition file.
// If there are no hooks, we're done.
- if (defined('ENVIRONMENT') AND is_file(APPPATH.'config/'.ENVIRONMENT.'/hooks'.EXT))
+ if (defined('ENVIRONMENT') AND is_file(APPPATH.'config/'.ENVIRONMENT.'/hooks.php'))
{
- include(APPPATH.'config/'.ENVIRONMENT.'/hooks'.EXT);
+ include(APPPATH.'config/'.ENVIRONMENT.'/hooks.php');
}
- elseif (is_file(APPPATH.'config/hooks'.EXT))
+ elseif (is_file(APPPATH.'config/hooks.php'))
{
- include(APPPATH.'config/hooks'.EXT);
+ include(APPPATH.'config/hooks.php');
}
diff --git a/system/core/Input.php b/system/core/Input.php
index dc7612e64..cfbef942d 100755
--- a/system/core/Input.php
+++ b/system/core/Input.php
@@ -672,7 +672,7 @@ class CI_Input {
*/
public function is_cli_request()
{
- return (bool) defined('STDIN');
+ return (php_sapi_name() == 'cli') or defined('STDIN');
}
}
diff --git a/system/core/Lang.php b/system/core/Lang.php
index 0b926a303..170e6c725 100755
--- a/system/core/Lang.php
+++ b/system/core/Lang.php
@@ -51,14 +51,14 @@ class CI_Lang {
*/
function load($langfile = '', $idiom = '', $return = FALSE, $add_suffix = TRUE, $alt_path = '')
{
- $langfile = str_replace(EXT, '', $langfile);
+ $langfile = str_replace('.php', '', $langfile);
if ($add_suffix == TRUE)
{
$langfile = str_replace('_lang.', '', $langfile).'_lang';
}
- $langfile .= EXT;
+ $langfile .= '.php';
if (in_array($langfile, $this->is_loaded, TRUE))
{
@@ -129,19 +129,19 @@ class CI_Lang {
*/
function line($line = '')
{
- $line = ($line == '' OR ! isset($this->language[$line])) ? FALSE : $this->language[$line];
+ $value = ($line == '' OR ! isset($this->language[$line])) ? FALSE : $this->language[$line];
// Because killer robots like unicorns!
- if ($line === FALSE)
+ if ($value === FALSE)
{
log_message('error', 'Could not find the language line "'.$line.'"');
}
- return $line;
+ return $value;
}
}
// END Language Class
/* End of file Lang.php */
-/* Location: ./system/core/Lang.php */ \ No newline at end of file
+/* Location: ./system/core/Lang.php */
diff --git a/system/core/Loader.php b/system/core/Loader.php
index e75805d0e..7c8b298ac 100755
--- a/system/core/Loader.php
+++ b/system/core/Loader.php
@@ -29,39 +29,78 @@
class CI_Loader {
// All these are set automatically. Don't mess with them.
- var $_ci_ob_level;
- var $_ci_view_path = '';
- var $_ci_library_paths = array();
- var $_ci_model_paths = array();
- var $_ci_helper_paths = array();
- var $_base_classes = array(); // Set by the controller class
- var $_ci_cached_vars = array();
- var $_ci_classes = array();
- var $_ci_loaded_files = array();
- var $_ci_models = array();
- var $_ci_helpers = array();
- var $_ci_varmap = array('unit_test' => 'unit', 'user_agent' => 'agent');
-
+ protected $_ci_ob_level;
+ protected $_ci_view_paths = array();
+ protected $_ci_library_paths = array();
+ protected $_ci_model_paths = array();
+ protected $_ci_helper_paths = array();
+ protected $_base_classes = array(); // Set by the controller class
+ protected $_ci_cached_vars = array();
+ protected $_ci_classes = array();
+ protected $_ci_loaded_files = array();
+ protected $_ci_models = array();
+ protected $_ci_helpers = array();
+ protected $_ci_varmap = array('unit_test' => 'unit',
+ 'user_agent' => 'agent');
/**
* Constructor
*
* Sets the path to the view files and gets the initial output buffering level
- *
- * @access public
*/
- function __construct()
+ public function __construct()
{
- $this->_ci_view_path = APPPATH.'views/';
$this->_ci_ob_level = ob_get_level();
$this->_ci_library_paths = array(APPPATH, BASEPATH);
$this->_ci_helper_paths = array(APPPATH, BASEPATH);
$this->_ci_model_paths = array(APPPATH);
-
+ $this->_ci_view_paths = array(APPPATH.'views/' => TRUE);
+
log_message('debug', "Loader Class Initialized");
}
// --------------------------------------------------------------------
+
+ /**
+ * Set _base_classes variable
+ *
+ * This method is called once in CI_Controller.
+ *
+ * @param array
+ * @return object
+ */
+ public function set_base_classes()
+ {
+ $this->_base_classes =& is_loaded();
+
+ return $this;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Is Loaded
+ *
+ * A utility function to test if a class is in the self::$_ci_classes array.
+ * This function returns the object name if the class tested for is loaded,
+ * and returns FALSE if it isn't.
+ *
+ * It is mainly used in the form_helper -> _get_validation_object()
+ *
+ * @param string class being checked for
+ * @return mixed class object name on the CI SuperObject or FALSE
+ */
+ public function is_loaded($class)
+ {
+ if (isset($this->_ci_classes[$class]))
+ {
+ return $this->_ci_classes[$class];
+ }
+
+ return FALSE;
+ }
+
+ // --------------------------------------------------------------------
/**
* Class Loader
@@ -69,13 +108,12 @@ class CI_Loader {
* This function lets users load and instantiate classes.
* It is designed to be called from a user's app controllers.
*
- * @access public
* @param string the name of the class
* @param mixed the optional parameters
* @param string an optional object name
* @return void
*/
- function library($library = '', $params = NULL, $object_name = NULL)
+ public function library($library = '', $params = NULL, $object_name = NULL)
{
if (is_array($library))
{
@@ -107,13 +145,12 @@ class CI_Loader {
*
* This function lets users load and instantiate models.
*
- * @access public
* @param string the name of the class
* @param string name for the model
* @param bool database connection
* @return void
*/
- function model($model, $name = '', $db_conn = FALSE)
+ public function model($model, $name = '', $db_conn = FALSE)
{
if (is_array($model))
{
@@ -161,7 +198,7 @@ class CI_Loader {
foreach ($this->_ci_model_paths as $mod_path)
{
- if ( ! file_exists($mod_path.'models/'.$path.$model.EXT))
+ if ( ! file_exists($mod_path.'models/'.$path.$model.'.php'))
{
continue;
}
@@ -181,7 +218,7 @@ class CI_Loader {
load_class('Model', 'core');
}
- require_once($mod_path.'models/'.$path.$model.EXT);
+ require_once($mod_path.'models/'.$path.$model.'.php');
$model = ucfirst($model);
@@ -200,13 +237,12 @@ class CI_Loader {
/**
* Database Loader
*
- * @access public
* @param string the DB credentials
* @param bool whether to return the DB object
* @param bool whether to enable active record (this allows us to override the config setting)
* @return object
*/
- function database($params = '', $return = FALSE, $active_record = NULL)
+ public function database($params = '', $return = FALSE, $active_record = NULL)
{
// Grab the super object
$CI =& get_instance();
@@ -217,7 +253,7 @@ class CI_Loader {
return FALSE;
}
- require_once(BASEPATH.'database/DB'.EXT);
+ require_once(BASEPATH.'database/DB.php');
if ($return === TRUE)
{
@@ -237,10 +273,9 @@ class CI_Loader {
/**
* Load the Utilities Class
*
- * @access public
* @return string
*/
- function dbutil()
+ public function dbutil()
{
if ( ! class_exists('CI_DB'))
{
@@ -253,8 +288,8 @@ class CI_Loader {
// this use is deprecated and strongly discouraged
$CI->load->dbforge();
- require_once(BASEPATH.'database/DB_utility'.EXT);
- require_once(BASEPATH.'database/drivers/'.$CI->db->dbdriver.'/'.$CI->db->dbdriver.'_utility'.EXT);
+ 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';
$CI->dbutil = new $class();
@@ -265,10 +300,9 @@ class CI_Loader {
/**
* Load the Database Forge Class
*
- * @access public
* @return string
*/
- function dbforge()
+ public function dbforge()
{
if ( ! class_exists('CI_DB'))
{
@@ -277,8 +311,8 @@ class CI_Loader {
$CI =& get_instance();
- require_once(BASEPATH.'database/DB_forge'.EXT);
- require_once(BASEPATH.'database/drivers/'.$CI->db->dbdriver.'/'.$CI->db->dbdriver.'_forge'.EXT);
+ 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';
$CI->dbforge = new $class();
@@ -297,13 +331,12 @@ class CI_Loader {
* some cases it's advantageous to be able to return data so that
* a developer can process it in some way.
*
- * @access public
* @param string
* @param array
* @param bool
* @return void
*/
- function view($view, $vars = array(), $return = FALSE)
+ public function view($view, $vars = array(), $return = FALSE)
{
return $this->_ci_load(array('_ci_view' => $view, '_ci_vars' => $this->_ci_object_to_array($vars), '_ci_return' => $return));
}
@@ -315,12 +348,11 @@ class CI_Loader {
*
* This is a generic file loader
*
- * @access public
* @param string
* @param bool
* @return string
*/
- function file($path, $return = FALSE)
+ public function file($path, $return = FALSE)
{
return $this->_ci_load(array('_ci_path' => $path, '_ci_return' => $return));
}
@@ -333,11 +365,10 @@ class CI_Loader {
* Once variables are set they become available within
* the controller class and its "view" files.
*
- * @access public
* @param array
* @return void
*/
- function vars($vars = array(), $val = '')
+ public function vars($vars = array(), $val = '')
{
if ($val != '' AND is_string($vars))
{
@@ -358,15 +389,29 @@ class CI_Loader {
// --------------------------------------------------------------------
/**
+ * Get Variable
+ *
+ * Check if a variable is set and retrieve it.
+ *
+ * @param array
+ * @return void
+ */
+ public function get_var($key)
+ {
+ return isset($this->_ci_cached_vars[$key]) ? $this->_ci_cached_vars[$key] : NULL;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
* Load Helper
*
* This function loads the specified helper file.
*
- * @access public
* @param mixed
* @return void
*/
- function helper($helpers = array())
+ public function helper($helpers = array())
{
foreach ($this->_ci_prep_filename($helpers, '_helper') as $helper)
{
@@ -375,16 +420,16 @@ class CI_Loader {
continue;
}
- $ext_helper = APPPATH.'helpers/'.config_item('subclass_prefix').$helper.EXT;
+ $ext_helper = APPPATH.'helpers/'.config_item('subclass_prefix').$helper.'.php';
// Is this a helper extension request?
if (file_exists($ext_helper))
{
- $base_helper = BASEPATH.'helpers/'.$helper.EXT;
+ $base_helper = BASEPATH.'helpers/'.$helper.'.php';
if ( ! file_exists($base_helper))
{
- show_error('Unable to load the requested file: helpers/'.$helper.EXT);
+ show_error('Unable to load the requested file: helpers/'.$helper.'.php');
}
include_once($ext_helper);
@@ -398,9 +443,9 @@ class CI_Loader {
// Try to load the helper
foreach ($this->_ci_helper_paths as $path)
{
- if (file_exists($path.'helpers/'.$helper.EXT))
+ if (file_exists($path.'helpers/'.$helper.'.php'))
{
- include_once($path.'helpers/'.$helper.EXT);
+ include_once($path.'helpers/'.$helper.'.php');
$this->_ci_helpers[$helper] = TRUE;
log_message('debug', 'Helper loaded: '.$helper);
@@ -411,7 +456,7 @@ class CI_Loader {
// unable to load the helper
if ( ! isset($this->_ci_helpers[$helper]))
{
- show_error('Unable to load the requested file: helpers/'.$helper.EXT);
+ show_error('Unable to load the requested file: helpers/'.$helper.'.php');
}
}
}
@@ -424,11 +469,10 @@ class CI_Loader {
* This is simply an alias to the above function in case the
* user has written the plural form of this function.
*
- * @access public
* @param array
* @return void
*/
- function helpers($helpers = array())
+ public function helpers($helpers = array())
{
$this->helper($helpers);
}
@@ -438,12 +482,11 @@ class CI_Loader {
/**
* Loads a language file
*
- * @access public
* @param array
* @param string
* @return void
*/
- function language($file = array(), $lang = '')
+ public function language($file = array(), $lang = '')
{
$CI =& get_instance();
@@ -463,11 +506,10 @@ class CI_Loader {
/**
* Loads a config file
*
- * @access public
* @param string
* @return void
*/
- function config($file = '', $use_sections = FALSE, $fail_gracefully = FALSE)
+ public function config($file = '', $use_sections = FALSE, $fail_gracefully = FALSE)
{
$CI =& get_instance();
$CI->config->load($file, $use_sections, $fail_gracefully);
@@ -485,12 +527,12 @@ class CI_Loader {
* @param string an optional object name
* @return void
*/
- function driver($library = '', $params = NULL, $object_name = NULL)
+ public function driver($library = '', $params = NULL, $object_name = NULL)
{
if ( ! class_exists('CI_Driver_Library'))
{
// we aren't instantiating an object here, that'll be done by the Library itself
- require BASEPATH.'libraries/Driver'.EXT;
+ require BASEPATH.'libraries/Driver.php';
}
// We can save the loader some time since Drivers will *always* be in a subfolder,
@@ -510,18 +552,20 @@ class CI_Loader {
*
* Prepends a parent path to the library, model, helper, and config path arrays
*
- * @access public
* @param string
+ * @param boolean
* @return void
*/
- function add_package_path($path)
+ public function add_package_path($path, $view_cascade=TRUE)
{
$path = rtrim($path, '/').'/';
-
+
array_unshift($this->_ci_library_paths, $path);
array_unshift($this->_ci_model_paths, $path);
array_unshift($this->_ci_helper_paths, $path);
+ $this->_ci_view_paths = array($path.'views/' => $view_cascade) + $this->_ci_view_paths;
+
// Add config file path
$config =& $this->_ci_get_component('config');
array_unshift($config->_config_paths, $path);
@@ -534,11 +578,10 @@ class CI_Loader {
*
* Return a list of all package paths, by default it will ignore BASEPATH.
*
- * @access public
* @param string
* @return void
*/
- function get_package_paths($include_base = FALSE)
+ public function get_package_paths($include_base = FALSE)
{
return $include_base === TRUE ? $this->_ci_library_paths : $this->_ci_model_paths;
}
@@ -551,11 +594,10 @@ class CI_Loader {
* Remove a path from the library, model, and helper path arrays if it exists
* If no path is provided, the most recently added path is removed.
*
- * @access public
* @param type
* @return type
*/
- function remove_package_path($path = '', $remove_config_path = TRUE)
+ public function remove_package_path($path = '', $remove_config_path = TRUE)
{
$config =& $this->_ci_get_component('config');
@@ -564,12 +606,12 @@ class CI_Loader {
$void = array_shift($this->_ci_library_paths);
$void = array_shift($this->_ci_model_paths);
$void = array_shift($this->_ci_helper_paths);
+ $void = array_shift($this->_ci_view_paths);
$void = array_shift($config->_config_paths);
}
else
{
$path = rtrim($path, '/').'/';
-
foreach (array('_ci_library_paths', '_ci_model_paths', '_ci_helper_paths') as $var)
{
if (($key = array_search($path, $this->{$var})) !== FALSE)
@@ -577,6 +619,11 @@ class CI_Loader {
unset($this->{$var}[$key]);
}
}
+
+ if (isset($this->_ci_view_paths[$path.'views/']))
+ {
+ unset($this->_ci_view_paths[$path.'views/']);
+ }
if (($key = array_search($path, $config->_config_paths)) !== FALSE)
{
@@ -588,6 +635,7 @@ class CI_Loader {
$this->_ci_library_paths = array_unique(array_merge($this->_ci_library_paths, array(APPPATH, BASEPATH)));
$this->_ci_helper_paths = array_unique(array_merge($this->_ci_helper_paths, array(APPPATH, BASEPATH)));
$this->_ci_model_paths = array_unique(array_merge($this->_ci_model_paths, array(APPPATH)));
+ $this->_ci_view_paths = array_merge($this->_ci_view_paths, array(APPPATH.'views/' => TRUE));
$config->_config_paths = array_unique(array_merge($config->_config_paths, array(APPPATH)));
}
@@ -600,32 +648,47 @@ class CI_Loader {
* Variables are prefixed with _ci_ to avoid symbol collision with
* variables made available to view files
*
- * @access private
* @param array
* @return void
*/
- function _ci_load($_ci_data)
+ protected function _ci_load($_ci_data)
{
// Set the default data variables
foreach (array('_ci_view', '_ci_vars', '_ci_path', '_ci_return') as $_ci_val)
{
$$_ci_val = ( ! isset($_ci_data[$_ci_val])) ? FALSE : $_ci_data[$_ci_val];
}
+
+ $file_exists = FALSE;
// Set the path to the requested file
- if ($_ci_path == '')
+ if ($_ci_path != '')
{
- $_ci_ext = pathinfo($_ci_view, PATHINFO_EXTENSION);
- $_ci_file = ($_ci_ext == '') ? $_ci_view.EXT : $_ci_view;
- $_ci_path = $this->_ci_view_path.$_ci_file;
+ $_ci_x = explode('/', $_ci_path);
+ $_ci_file = end($_ci_x);
}
else
{
- $_ci_x = explode('/', $_ci_path);
- $_ci_file = end($_ci_x);
+ $_ci_ext = pathinfo($_ci_view, PATHINFO_EXTENSION);
+ $_ci_file = ($_ci_ext == '') ? $_ci_view.'.php' : $_ci_view;
+
+ foreach ($this->_ci_view_paths as $view_file => $cascade)
+ {
+ if (file_exists($view_file.$_ci_file))
+ {
+ $_ci_path = $view_file.$_ci_file;
+ $file_exists = TRUE;
+ break;
+ }
+
+ if ( ! $cascade)
+ {
+ break;
+ }
+ }
}
- if ( ! file_exists($_ci_path))
+ if ( ! $file_exists && ! file_exists($_ci_path))
{
show_error('Unable to load the requested file: '.$_ci_file);
}
@@ -721,18 +784,17 @@ class CI_Loader {
*
* This function loads the requested class.
*
- * @access private
* @param string the item that is being loaded
* @param mixed any additional parameters
* @param string an optional object name
* @return void
*/
- function _ci_load_class($class, $params = NULL, $object_name = NULL)
+ protected function _ci_load_class($class, $params = NULL, $object_name = NULL)
{
// Get the class name, and while we're at it trim any slashes.
// The directory path can be included as part of the class name,
// but we don't want a leading slash
- $class = str_replace(EXT, '', trim($class, '/'));
+ $class = str_replace('.php', '', trim($class, '/'));
// Was the path included with the class name?
// We look for a slash to determine this
@@ -749,12 +811,12 @@ class CI_Loader {
// We'll test for both lowercase and capitalized versions of the file name
foreach (array(ucfirst($class), strtolower($class)) as $class)
{
- $subclass = APPPATH.'libraries/'.$subdir.config_item('subclass_prefix').$class.EXT;
+ $subclass = APPPATH.'libraries/'.$subdir.config_item('subclass_prefix').$class.'.php';
// Is this a class extension request?
if (file_exists($subclass))
{
- $baseclass = BASEPATH.'libraries/'.ucfirst($class).EXT;
+ $baseclass = BASEPATH.'libraries/'.ucfirst($class).'.php';
if ( ! file_exists($baseclass))
{
@@ -793,7 +855,7 @@ class CI_Loader {
$is_duplicate = FALSE;
foreach ($this->_ci_library_paths as $path)
{
- $filepath = $path.'libraries/'.$subdir.$class.EXT;
+ $filepath = $path.'libraries/'.$subdir.$class.'.php';
// Does the file exist? No? Bummer...
if ( ! file_exists($filepath))
@@ -849,13 +911,12 @@ class CI_Loader {
/**
* Instantiates a class
*
- * @access private
* @param string
* @param string
* @param string an optional object name
* @return null
*/
- function _ci_init_class($class, $prefix = '', $config = FALSE, $object_name = NULL)
+ protected function _ci_init_class($class, $prefix = '', $config = FALSE, $object_name = NULL)
{
// Is there an associated config file for this class? Note: these should always be lowercase
if ($config === NULL)
@@ -872,24 +933,24 @@ class CI_Loader {
// We test for both uppercase and lowercase, for servers that
// are case-sensitive with regard to file names. Check for environment
// first, global next
- if (defined('ENVIRONMENT') AND file_exists($path .'config/'.ENVIRONMENT.'/'.strtolower($class).EXT))
+ if (defined('ENVIRONMENT') AND file_exists($path .'config/'.ENVIRONMENT.'/'.strtolower($class).'.php'))
{
- include_once($path .'config/'.ENVIRONMENT.'/'.strtolower($class).EXT);
+ include_once($path .'config/'.ENVIRONMENT.'/'.strtolower($class).'.php');
break;
}
- elseif (defined('ENVIRONMENT') AND file_exists($path .'config/'.ENVIRONMENT.'/'.ucfirst(strtolower($class)).EXT))
+ elseif (defined('ENVIRONMENT') AND file_exists($path .'config/'.ENVIRONMENT.'/'.ucfirst(strtolower($class)).'.php'))
{
- include_once($path .'config/'.ENVIRONMENT.'/'.ucfirst(strtolower($class)).EXT);
+ include_once($path .'config/'.ENVIRONMENT.'/'.ucfirst(strtolower($class)).'.php');
break;
}
- elseif (file_exists($path .'config/'.strtolower($class).EXT))
+ elseif (file_exists($path .'config/'.strtolower($class).'.php'))
{
- include_once($path .'config/'.strtolower($class).EXT);
+ include_once($path .'config/'.strtolower($class).'.php');
break;
}
- elseif (file_exists($path .'config/'.ucfirst(strtolower($class)).EXT))
+ elseif (file_exists($path .'config/'.ucfirst(strtolower($class)).'.php'))
{
- include_once($path .'config/'.ucfirst(strtolower($class)).EXT);
+ include_once($path .'config/'.ucfirst(strtolower($class)).'.php');
break;
}
}
@@ -959,19 +1020,21 @@ class CI_Loader {
* The config/autoload.php file contains an array that permits sub-systems,
* libraries, and helpers to be loaded automatically.
*
- * @access private
+ * This function is public, as it's used in the CI_Controller class.
+ * However, there is no reason you should ever needs to use it.
+ *
* @param array
* @return void
*/
- function _ci_autoloader()
+ public function ci_autoloader()
{
- if (defined('ENVIRONMENT') AND file_exists(APPPATH.'config/'.ENVIRONMENT.'/autoload'.EXT))
+ if (defined('ENVIRONMENT') AND file_exists(APPPATH.'config/'.ENVIRONMENT.'/autoload.php'))
{
- include_once(APPPATH.'config/'.ENVIRONMENT.'/autoload'.EXT);
+ include_once(APPPATH.'config/'.ENVIRONMENT.'/autoload.php');
}
else
{
- include_once(APPPATH.'config/autoload'.EXT);
+ include_once(APPPATH.'config/autoload.php');
}
@@ -1046,11 +1109,10 @@ class CI_Loader {
*
* Takes an object as input and converts the class variables to array key/vals
*
- * @access private
* @param object
* @return array
*/
- function _ci_object_to_array($object)
+ protected function _ci_object_to_array($object)
{
return (is_object($object)) ? get_object_vars($object) : $object;
}
@@ -1060,10 +1122,9 @@ class CI_Loader {
/**
* Get a reference to a specific library or model
*
- * @access private
* @return bool
*/
- function &_ci_get_component($component)
+ protected function &_ci_get_component($component)
{
$CI =& get_instance();
return $CI->$component;
@@ -1076,29 +1137,26 @@ class CI_Loader {
*
* This function preps the name of various items to make loading them more reliable.
*
- * @access private
* @param mixed
* @return array
*/
- function _ci_prep_filename($filename, $extension)
+ protected function _ci_prep_filename($filename, $extension)
{
if ( ! is_array($filename))
{
- return array(strtolower(str_replace(EXT, '', str_replace($extension, '', $filename)).$extension));
+ return array(strtolower(str_replace('.php', '', str_replace($extension, '', $filename)).$extension));
}
else
{
foreach ($filename as $key => $val)
{
- $filename[$key] = strtolower(str_replace(EXT, '', str_replace($extension, '', $val)).$extension);
+ $filename[$key] = strtolower(str_replace('.php', '', str_replace($extension, '', $val)).$extension);
}
return $filename;
}
}
-
-
}
/* End of file Loader.php */
-/* Location: ./system/core/Loader.php */
+/* Location: ./system/core/Loader.php */ \ No newline at end of file
diff --git a/system/core/Output.php b/system/core/Output.php
index 45a82f3cb..05ace919c 100755
--- a/system/core/Output.php
+++ b/system/core/Output.php
@@ -42,13 +42,13 @@ class CI_Output {
$this->_zlib_oc = @ini_get('zlib.output_compression');
// Get mime types for later
- if (defined('ENVIRONMENT') AND file_exists(APPPATH.'config/'.ENVIRONMENT.'/mimes'.EXT))
+ if (defined('ENVIRONMENT') AND file_exists(APPPATH.'config/'.ENVIRONMENT.'/mimes.php'))
{
- include APPPATH.'config/'.ENVIRONMENT.'/mimes'.EXT;
+ include APPPATH.'config/'.ENVIRONMENT.'/mimes.php';
}
else
{
- include APPPATH.'config/mimes'.EXT;
+ include APPPATH.'config/mimes.php';
}
diff --git a/system/core/Router.php b/system/core/Router.php
index d451aab68..5e92a04b1 100755
--- a/system/core/Router.php
+++ b/system/core/Router.php
@@ -87,13 +87,13 @@ class CI_Router {
}
// Load the routes.php file.
- if (defined('ENVIRONMENT') AND is_file(APPPATH.'config/'.ENVIRONMENT.'/routes'.EXT))
+ if (defined('ENVIRONMENT') AND is_file(APPPATH.'config/'.ENVIRONMENT.'/routes.php'))
{
- include(APPPATH.'config/'.ENVIRONMENT.'/routes'.EXT);
+ include(APPPATH.'config/'.ENVIRONMENT.'/routes.php');
}
- elseif (is_file(APPPATH.'config/routes'.EXT))
+ elseif (is_file(APPPATH.'config/routes.php'))
{
- include(APPPATH.'config/routes'.EXT);
+ include(APPPATH.'config/routes.php');
}
$this->routes = ( ! isset($route) OR ! is_array($route)) ? array() : $route;
@@ -227,7 +227,7 @@ class CI_Router {
}
// Does the requested controller exist in the root folder?
- if (file_exists(APPPATH.'controllers/'.$segments[0].EXT))
+ if (file_exists(APPPATH.'controllers/'.$segments[0].'.php'))
{
return $segments;
}
@@ -242,7 +242,7 @@ class CI_Router {
if (count($segments) > 0)
{
// Does the requested controller exist in the sub-folder?
- if ( ! file_exists(APPPATH.'controllers/'.$this->fetch_directory().$segments[0].EXT))
+ if ( ! file_exists(APPPATH.'controllers/'.$this->fetch_directory().$segments[0].'.php'))
{
show_404($this->fetch_directory().$segments[0]);
}
@@ -264,7 +264,7 @@ class CI_Router {
}
// Does the default controller exist in the sub-folder?
- if ( ! file_exists(APPPATH.'controllers/'.$this->fetch_directory().$this->default_controller.EXT))
+ if ( ! file_exists(APPPATH.'controllers/'.$this->fetch_directory().$this->default_controller.'.php'))
{
$this->directory = '';
return array();
diff --git a/system/core/Security.php b/system/core/Security.php
index ceef9779c..3617cadcc 100755
--- a/system/core/Security.php
+++ b/system/core/Security.php
@@ -58,8 +58,20 @@ class CI_Security {
*/
public function __construct()
{
- // Append application specific cookie prefix to token name
- $this->_csrf_cookie_name = (config_item('cookie_prefix')) ? config_item('cookie_prefix').$this->_csrf_token_name : $this->_csrf_token_name;
+ // CSRF config
+ foreach(array('csrf_expire', 'csrf_token_name', 'csrf_cookie_name') as $key)
+ {
+ if (FALSE !== ($val = config_item($key)))
+ {
+ $this->{'_'.$key} = $val;
+ }
+ }
+
+ // Append application specific cookie prefix
+ if (config_item('cookie_prefix'))
+ {
+ $this->_csrf_cookie_name = config_item('cookie_prefix').$this->_csrf_cookie_name;
+ }
// Set the CSRF hash
$this->_csrf_set_hash();
@@ -817,4 +829,4 @@ class CI_Security {
// END Security Class
/* End of file Security.php */
-/* Location: ./system/libraries/Security.php */ \ No newline at end of file
+/* Location: ./system/libraries/Security.php */
diff --git a/system/core/URI.php b/system/core/URI.php
index b34260836..80572ddd1 100755
--- a/system/core/URI.php
+++ b/system/core/URI.php
@@ -62,7 +62,7 @@ class CI_URI {
if (strtoupper($this->config->item('uri_protocol')) == 'AUTO')
{
// Is the request coming from the command line?
- if (defined('STDIN'))
+ if (php_sapi_name() == 'cli' or defined('STDIN'))
{
$this->_set_uri_string($this->_parse_cli_args());
return;
@@ -120,7 +120,7 @@ class CI_URI {
$path = (isset($_SERVER[$uri])) ? $_SERVER[$uri] : @getenv($uri);
$this->_set_uri_string($path);
}
-
+
// --------------------------------------------------------------------
/**
@@ -133,7 +133,7 @@ class CI_URI {
{
// 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;
}
@@ -151,7 +151,7 @@ class CI_URI {
*/
private function _detect_uri()
{
- if ( ! isset($_SERVER['REQUEST_URI']))
+ if ( ! isset($_SERVER['REQUEST_URI']) OR ! isset($_SERVER['SCRIPT_NAME']))
{
return '';
}
@@ -184,12 +184,12 @@ class CI_URI {
$_SERVER['QUERY_STRING'] = '';
$_GET = array();
}
-
+
if ($uri == '/' || empty($uri))
{
return '/';
}
-
+
$uri = parse_url($uri, PHP_URL_PATH);
// Do some final cleaning of the URI and return it
diff --git a/system/database/DB.php b/system/database/DB.php
index 8bf1ba8ba..33207d885 100755
--- a/system/database/DB.php
+++ b/system/database/DB.php
@@ -28,11 +28,11 @@ function &DB($params = '', $active_record_override = NULL)
if (is_string($params) AND strpos($params, '://') === FALSE)
{
// Is the config file in the environment folder?
- if ( ! defined('ENVIRONMENT') OR ! file_exists($file_path = APPPATH.'config/'.ENVIRONMENT.'/database'.EXT))
+ if ( ! defined('ENVIRONMENT') OR ! file_exists($file_path = APPPATH.'config/'.ENVIRONMENT.'/database.php'))
{
- if ( ! file_exists($file_path = APPPATH.'config/database'.EXT))
+ if ( ! file_exists($file_path = APPPATH.'config/database.php'))
{
- show_error('The configuration file database'.EXT.' does not exist.');
+ show_error('The configuration file database.php does not exist.');
}
}
@@ -116,11 +116,11 @@ function &DB($params = '', $active_record_override = NULL)
$active_record = $active_record_override;
}
- require_once(BASEPATH.'database/DB_driver'.EXT);
+ require_once(BASEPATH.'database/DB_driver.php');
if ( ! isset($active_record) OR $active_record == TRUE)
{
- require_once(BASEPATH.'database/DB_active_rec'.EXT);
+ require_once(BASEPATH.'database/DB_active_rec.php');
if ( ! class_exists('CI_DB'))
{
@@ -135,7 +135,7 @@ function &DB($params = '', $active_record_override = NULL)
}
}
- require_once(BASEPATH.'database/drivers/'.$params['dbdriver'].'/'.$params['dbdriver'].'_driver'.EXT);
+ require_once(BASEPATH.'database/drivers/'.$params['dbdriver'].'/'.$params['dbdriver'].'_driver.php');
// Instantiate the DB adapter
$driver = 'CI_DB_'.$params['dbdriver'].'_driver';
diff --git a/system/database/DB_active_rec.php b/system/database/DB_active_rec.php
index db8471364..2af3553ed 100755
--- a/system/database/DB_active_rec.php
+++ b/system/database/DB_active_rec.php
@@ -58,7 +58,9 @@ class CI_DB_active_record extends CI_DB_driver {
var $ar_cache_having = array();
var $ar_cache_orderby = array();
var $ar_cache_set = array();
-
+
+ var $ar_no_escape = array();
+ var $ar_cache_no_escape = array();
// --------------------------------------------------------------------
@@ -67,18 +69,11 @@ class CI_DB_active_record extends CI_DB_driver {
*
* Generates the SELECT portion of the query
*
- * @access public
* @param string
* @return object
*/
- function select($select = '*', $escape = NULL)
+ public function select($select = '*', $escape = NULL)
{
- // Set the global value if this was sepecified
- if (is_bool($escape))
- {
- $this->_protect_identifiers = $escape;
- }
-
if (is_string($select))
{
$select = explode(',', $select);
@@ -91,11 +86,13 @@ class CI_DB_active_record extends CI_DB_driver {
if ($val != '')
{
$this->ar_select[] = $val;
+ $this->ar_no_escape[] = $escape;
if ($this->ar_caching === TRUE)
{
$this->ar_cache_select[] = $val;
$this->ar_cache_exists[] = 'select';
+ $this->ar_cache_no_escape[] = $escape;
}
}
}
@@ -109,12 +106,11 @@ class CI_DB_active_record extends CI_DB_driver {
*
* Generates a SELECT MAX(field) portion of a query
*
- * @access public
* @param string the field
* @param string an alias
* @return object
*/
- function select_max($select = '', $alias = '')
+ public function select_max($select = '', $alias = '')
{
return $this->_max_min_avg_sum($select, $alias, 'MAX');
}
@@ -126,12 +122,11 @@ class CI_DB_active_record extends CI_DB_driver {
*
* Generates a SELECT MIN(field) portion of a query
*
- * @access public
* @param string the field
* @param string an alias
* @return object
*/
- function select_min($select = '', $alias = '')
+ public function select_min($select = '', $alias = '')
{
return $this->_max_min_avg_sum($select, $alias, 'MIN');
}
@@ -143,12 +138,11 @@ class CI_DB_active_record extends CI_DB_driver {
*
* Generates a SELECT AVG(field) portion of a query
*
- * @access public
* @param string the field
* @param string an alias
* @return object
*/
- function select_avg($select = '', $alias = '')
+ public function select_avg($select = '', $alias = '')
{
return $this->_max_min_avg_sum($select, $alias, 'AVG');
}
@@ -160,12 +154,11 @@ class CI_DB_active_record extends CI_DB_driver {
*
* Generates a SELECT SUM(field) portion of a query
*
- * @access public
* @param string the field
* @param string an alias
* @return object
*/
- function select_sum($select = '', $alias = '')
+ public function select_sum($select = '', $alias = '')
{
return $this->_max_min_avg_sum($select, $alias, 'SUM');
}
@@ -180,12 +173,11 @@ class CI_DB_active_record extends CI_DB_driver {
* select_avg()
* select_sum()
*
- * @access public
* @param string the field
* @param string an alias
* @return object
*/
- function _max_min_avg_sum($select = '', $alias = '', $type = 'MAX')
+ protected function _max_min_avg_sum($select = '', $alias = '', $type = 'MAX')
{
if ( ! is_string($select) OR $select == '')
{
@@ -222,11 +214,10 @@ class CI_DB_active_record extends CI_DB_driver {
/**
* Determines the alias name based on the table
*
- * @access private
* @param string
* @return string
*/
- function _create_alias_from_table($item)
+ protected function _create_alias_from_table($item)
{
if (strpos($item, '.') !== FALSE)
{
@@ -243,11 +234,10 @@ class CI_DB_active_record extends CI_DB_driver {
*
* Sets a flag which tells the query string compiler to add DISTINCT
*
- * @access public
* @param bool
* @return object
*/
- function distinct($val = TRUE)
+ public function distinct($val = TRUE)
{
$this->ar_distinct = (is_bool($val)) ? $val : TRUE;
return $this;
@@ -260,11 +250,10 @@ class CI_DB_active_record extends CI_DB_driver {
*
* Generates the FROM portion of the query
*
- * @access public
* @param mixed can be a string or array
* @return object
*/
- function from($from)
+ public function from($from)
{
foreach ((array)$from as $val)
{
@@ -313,13 +302,12 @@ class CI_DB_active_record extends CI_DB_driver {
*
* Generates the JOIN portion of the query
*
- * @access public
* @param string
* @param string the join condition
* @param string the type of join
* @return object
*/
- function join($table, $cond, $type = '')
+ public function join($table, $cond, $type = '')
{
if ($type != '')
{
@@ -369,12 +357,11 @@ class CI_DB_active_record extends CI_DB_driver {
* Generates the WHERE portion of the query. Separates
* multiple calls with AND
*
- * @access public
* @param mixed
* @param mixed
* @return object
*/
- function where($key, $value = NULL, $escape = TRUE)
+ public function where($key, $value = NULL, $escape = TRUE)
{
return $this->_where($key, $value, 'AND ', $escape);
}
@@ -387,12 +374,11 @@ class CI_DB_active_record extends CI_DB_driver {
* Generates the WHERE portion of the query. Separates
* multiple calls with OR
*
- * @access public
* @param mixed
* @param mixed
* @return object
*/
- function or_where($key, $value = NULL, $escape = TRUE)
+ public function or_where($key, $value = NULL, $escape = TRUE)
{
return $this->_where($key, $value, 'OR ', $escape);
}
@@ -402,15 +388,14 @@ class CI_DB_active_record extends CI_DB_driver {
/**
* Where
*
- * Called by where() or orwhere()
+ * Called by where() or or_where()
*
- * @access private
* @param mixed
* @param mixed
* @param string
* @return object
*/
- function _where($key, $value = NULL, $type = 'AND ', $escape = NULL)
+ protected function _where($key, $value = NULL, $type = 'AND ', $escape = NULL)
{
if ( ! is_array($key))
{
@@ -441,10 +426,10 @@ class CI_DB_active_record extends CI_DB_driver {
$v = ' '.$this->escape($v);
}
-
+
if ( ! $this->_has_operator($k))
{
- $k .= ' =';
+ $k .= ' = ';
}
}
else
@@ -473,12 +458,11 @@ class CI_DB_active_record extends CI_DB_driver {
* Generates a WHERE field IN ('item', 'item') SQL query joined with
* AND if appropriate
*
- * @access public
* @param string The field to search
* @param array The values searched on
* @return object
*/
- function where_in($key = NULL, $values = NULL)
+ public function where_in($key = NULL, $values = NULL)
{
return $this->_where_in($key, $values);
}
@@ -491,12 +475,11 @@ class CI_DB_active_record extends CI_DB_driver {
* Generates a WHERE field IN ('item', 'item') SQL query joined with
* OR if appropriate
*
- * @access public
* @param string The field to search
* @param array The values searched on
* @return object
*/
- function or_where_in($key = NULL, $values = NULL)
+ public function or_where_in($key = NULL, $values = NULL)
{
return $this->_where_in($key, $values, FALSE, 'OR ');
}
@@ -509,12 +492,11 @@ class CI_DB_active_record extends CI_DB_driver {
* Generates a WHERE field NOT IN ('item', 'item') SQL query joined
* with AND if appropriate
*
- * @access public
* @param string The field to search
* @param array The values searched on
* @return object
*/
- function where_not_in($key = NULL, $values = NULL)
+ public function where_not_in($key = NULL, $values = NULL)
{
return $this->_where_in($key, $values, TRUE);
}
@@ -527,12 +509,11 @@ class CI_DB_active_record extends CI_DB_driver {
* Generates a WHERE field NOT IN ('item', 'item') SQL query joined
* with OR if appropriate
*
- * @access public
* @param string The field to search
* @param array The values searched on
* @return object
*/
- function or_where_not_in($key = NULL, $values = NULL)
+ public function or_where_not_in($key = NULL, $values = NULL)
{
return $this->_where_in($key, $values, TRUE, 'OR ');
}
@@ -544,14 +525,13 @@ class CI_DB_active_record extends CI_DB_driver {
*
* Called by where_in, where_in_or, where_not_in, where_not_in_or
*
- * @access public
* @param string The field to search
* @param array The values searched on
* @param boolean If the statement would be IN or NOT IN
* @param string
* @return object
*/
- function _where_in($key = NULL, $values = NULL, $not = FALSE, $type = 'AND ')
+ protected function _where_in($key = NULL, $values = NULL, $not = FALSE, $type = 'AND ')
{
if ($key === NULL OR $values === NULL)
{
@@ -594,12 +574,11 @@ class CI_DB_active_record extends CI_DB_driver {
* Generates a %LIKE% portion of the query. Separates
* multiple calls with AND
*
- * @access public
* @param mixed
* @param mixed
* @return object
*/
- function like($field, $match = '', $side = 'both')
+ public function like($field, $match = '', $side = 'both')
{
return $this->_like($field, $match, 'AND ', $side);
}
@@ -612,12 +591,11 @@ class CI_DB_active_record extends CI_DB_driver {
* Generates a NOT LIKE portion of the query. Separates
* multiple calls with AND
*
- * @access public
* @param mixed
* @param mixed
* @return object
*/
- function not_like($field, $match = '', $side = 'both')
+ public function not_like($field, $match = '', $side = 'both')
{
return $this->_like($field, $match, 'AND ', $side, 'NOT');
}
@@ -630,12 +608,11 @@ class CI_DB_active_record extends CI_DB_driver {
* Generates a %LIKE% portion of the query. Separates
* multiple calls with OR
*
- * @access public
* @param mixed
* @param mixed
* @return object
*/
- function or_like($field, $match = '', $side = 'both')
+ public function or_like($field, $match = '', $side = 'both')
{
return $this->_like($field, $match, 'OR ', $side);
}
@@ -648,12 +625,11 @@ class CI_DB_active_record extends CI_DB_driver {
* Generates a NOT LIKE portion of the query. Separates
* multiple calls with OR
*
- * @access public
* @param mixed
* @param mixed
* @return object
*/
- function or_not_like($field, $match = '', $side = 'both')
+ public function or_not_like($field, $match = '', $side = 'both')
{
return $this->_like($field, $match, 'OR ', $side, 'NOT');
}
@@ -665,13 +641,12 @@ class CI_DB_active_record extends CI_DB_driver {
*
* Called by like() or orlike()
*
- * @access private
* @param mixed
* @param mixed
* @param string
* @return object
*/
- function _like($field, $match = '', $type = 'AND ', $side = 'both', $not = '')
+ protected function _like($field, $match = '', $type = 'AND ', $side = 'both', $not = '')
{
if ( ! is_array($field))
{
@@ -721,11 +696,10 @@ class CI_DB_active_record extends CI_DB_driver {
/**
* GROUP BY
*
- * @access public
* @param string
* @return object
*/
- function group_by($by)
+ public function group_by($by)
{
if (is_string($by))
{
@@ -757,12 +731,11 @@ class CI_DB_active_record extends CI_DB_driver {
*
* Separates multiple calls with AND
*
- * @access public
* @param string
* @param string
* @return object
*/
- function having($key, $value = '', $escape = TRUE)
+ public function having($key, $value = '', $escape = TRUE)
{
return $this->_having($key, $value, 'AND ', $escape);
}
@@ -774,12 +747,11 @@ class CI_DB_active_record extends CI_DB_driver {
*
* Separates multiple calls with OR
*
- * @access public
* @param string
* @param string
* @return object
*/
- function or_having($key, $value = '', $escape = TRUE)
+ public function or_having($key, $value = '', $escape = TRUE)
{
return $this->_having($key, $value, 'OR ', $escape);
}
@@ -791,12 +763,11 @@ class CI_DB_active_record extends CI_DB_driver {
*
* Called by having() or or_having()
*
- * @access private
* @param string
* @param string
* @return object
*/
- function _having($key, $value = '', $type = 'AND ', $escape = TRUE)
+ protected function _having($key, $value = '', $type = 'AND ', $escape = TRUE)
{
if ( ! is_array($key))
{
@@ -819,7 +790,7 @@ class CI_DB_active_record extends CI_DB_driver {
if ($v != '')
{
- $v = ' '.$this->escape_str($v);
+ $v = ' '.$this->escape($v);
}
$this->ar_having[] = $prefix.$k.$v;
@@ -838,12 +809,11 @@ class CI_DB_active_record extends CI_DB_driver {
/**
* Sets the ORDER BY value
*
- * @access public
* @param string
* @param string direction: asc or desc
* @return object
*/
- function order_by($orderby, $direction = '')
+ public function order_by($orderby, $direction = '')
{
if (strtolower($direction) == 'random')
{
@@ -894,12 +864,11 @@ class CI_DB_active_record extends CI_DB_driver {
/**
* Sets the LIMIT value
*
- * @access public
* @param integer the limit value
* @param integer the offset value
* @return object
*/
- function limit($value, $offset = '')
+ public function limit($value, $offset = '')
{
$this->ar_limit = $value;
@@ -916,11 +885,10 @@ class CI_DB_active_record extends CI_DB_driver {
/**
* Sets the OFFSET value
*
- * @access public
* @param integer the offset value
* @return object
*/
- function offset($offset)
+ public function offset($offset)
{
$this->ar_offset = $offset;
return $this;
@@ -931,13 +899,12 @@ class CI_DB_active_record extends CI_DB_driver {
/**
* The "set" function. Allows key/value pairs to be set for inserting or updating
*
- * @access public
* @param mixed
* @param string
* @param boolean
* @return object
*/
- function set($key, $value = '', $escape = TRUE)
+ public function set($key, $value = '', $escape = TRUE)
{
$key = $this->_object_to_array($key);
@@ -969,13 +936,12 @@ class CI_DB_active_record extends CI_DB_driver {
* Compiles the select statement based on the other functions called
* and runs the query
*
- * @access public
* @param string the table
* @param string the limit clause
* @param string the offset clause
* @return object
*/
- function get($table = '', $limit = null, $offset = null)
+ public function get($table = '', $limit = null, $offset = null)
{
if ($table != '')
{
@@ -1001,11 +967,10 @@ class CI_DB_active_record extends CI_DB_driver {
* Generates a platform-specific query string that counts all records
* returned by an Active Record query.
*
- * @access public
* @param string
* @return string
*/
- function count_all_results($table = '')
+ public function count_all_results($table = '')
{
if ($table != '')
{
@@ -1034,13 +999,12 @@ class CI_DB_active_record extends CI_DB_driver {
*
* Allows the where clause, limit and offset to be added directly
*
- * @access public
* @param string the where clause
* @param string the limit clause
* @param string the offset clause
* @return object
*/
- function get_where($table = '', $where = null, $limit = null, $offset = null)
+ public function get_where($table = '', $where = null, $limit = null, $offset = null)
{
if ($table != '')
{
@@ -1071,12 +1035,11 @@ class CI_DB_active_record extends CI_DB_driver {
*
* Compiles batch insert strings and runs the queries
*
- * @access public
* @param string the table to retrieve the results from
* @param array an associative array of insert values
* @return object
*/
- function insert_batch($table = '', $set = NULL)
+ public function insert_batch($table = '', $set = NULL)
{
if ( ! is_null($set))
{
@@ -1129,14 +1092,12 @@ class CI_DB_active_record extends CI_DB_driver {
/**
* The "set_insert_batch" function. Allows key/value pairs to be set for batch inserts
*
- * @access public
* @param mixed
* @param string
* @param boolean
* @return object
*/
-
- function set_insert_batch($key, $value = '', $escape = TRUE)
+ public function set_insert_batch($key, $value = '', $escape = TRUE)
{
$key = $this->_object_to_array_batch($key);
@@ -1191,8 +1152,7 @@ class CI_DB_active_record extends CI_DB_driver {
*
* Compiles an insert string and runs the query
*
- * @access public
- * @param string the table to retrieve the results from
+ * @param string the table to insert data into
* @param array an associative array of insert values
* @return object
*/
@@ -1232,7 +1192,18 @@ class CI_DB_active_record extends CI_DB_driver {
return $this->query($sql);
}
- function replace($table = '', $set = NULL)
+ // --------------------------------------------------------------------
+
+ /**
+ * Replace
+ *
+ * Compiles an replace into string and runs the query
+ *
+ * @param string the table to replace data into
+ * @param array an associative array of insert values
+ * @return object
+ */
+ public function replace($table = '', $set = NULL)
{
if ( ! is_null($set))
{
@@ -1275,13 +1246,12 @@ class CI_DB_active_record extends CI_DB_driver {
*
* Compiles an update string and runs the query
*
- * @access public
* @param string the table to retrieve the results from
* @param array an associative array of update values
* @param mixed the where clause
* @return object
*/
- function update($table = '', $set = NULL, $where = NULL, $limit = NULL)
+ public function update($table = '', $set = NULL, $where = NULL, $limit = NULL)
{
// Combine any cached components with the current statements
$this->_merge_cache();
@@ -1338,13 +1308,12 @@ class CI_DB_active_record extends CI_DB_driver {
*
* Compiles an update string and runs the query
*
- * @access public
* @param string the table to retrieve the results from
* @param array an associative array of update values
* @param string the where key
* @return object
*/
- function update_batch($table = '', $set = NULL, $index = NULL)
+ public function update_batch($table = '', $set = NULL, $index = NULL)
{
// Combine any cached components with the current statements
$this->_merge_cache();
@@ -1404,14 +1373,12 @@ class CI_DB_active_record extends CI_DB_driver {
/**
* The "set_update_batch" function. Allows key/value pairs to be set for batch updating
*
- * @access public
* @param array
* @param string
* @param boolean
* @return object
*/
-
- function set_update_batch($key, $index = '', $escape = TRUE)
+ public function set_update_batch($key, $index = '', $escape = TRUE)
{
$key = $this->_object_to_array_batch($key);
@@ -1464,11 +1431,10 @@ class CI_DB_active_record extends CI_DB_driver {
*
* Compiles a delete string and runs "DELETE FROM table"
*
- * @access public
* @param string the table to empty
* @return object
*/
- function empty_table($table = '')
+ public function empty_table($table = '')
{
if ($table == '')
{
@@ -1504,11 +1470,10 @@ class CI_DB_active_record extends CI_DB_driver {
* If the database does not support the truncate() command
* This function maps to "DELETE FROM table"
*
- * @access public
* @param string the table to truncate
* @return object
*/
- function truncate($table = '')
+ public function truncate($table = '')
{
if ($table == '')
{
@@ -1542,14 +1507,13 @@ class CI_DB_active_record extends CI_DB_driver {
*
* Compiles a delete string and runs the query
*
- * @access public
* @param mixed the table(s) to delete from. String or array
* @param mixed the where clause
* @param mixed the limit clause
* @param boolean
* @return object
*/
- function delete($table = '', $where = '', $limit = NULL, $reset_data = TRUE)
+ public function delete($table = '', $where = '', $limit = NULL, $reset_data = TRUE)
{
// Combine any cached components with the current statements
$this->_merge_cache();
@@ -1619,11 +1583,10 @@ class CI_DB_active_record extends CI_DB_driver {
*
* Prepends a database prefix if one exists in configuration
*
- * @access public
* @param string the table
* @return string
*/
- function dbprefix($table = '')
+ public function dbprefix($table = '')
{
if ($table == '')
{
@@ -1636,15 +1599,29 @@ class CI_DB_active_record extends CI_DB_driver {
// --------------------------------------------------------------------
/**
+ * Set DB Prefix
+ *
+ * Set's the DB Prefix to something new without needing to reconnect
+ *
+ * @param string the prefix
+ * @return string
+ */
+ public function set_dbprefix($prefix = '')
+ {
+ return $this->dbprefix = $prefix;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
* Track Aliases
*
* Used to track SQL statements written with aliased tables.
*
- * @access private
* @param string The table to inspect
* @return string
*/
- function _track_aliases($table)
+ protected function _track_aliases($table)
{
if (is_array($table))
{
@@ -1687,10 +1664,9 @@ class CI_DB_active_record extends CI_DB_driver {
* Generates a query string based on which functions were used.
* Should not be called directly. The get() function calls it.
*
- * @access private
* @return string
*/
- function _compile_select($select_override = FALSE)
+ protected function _compile_select($select_override = FALSE)
{
// Combine any cached components with the current statements
$this->_merge_cache();
@@ -1718,7 +1694,8 @@ class CI_DB_active_record extends CI_DB_driver {
// is because until the user calls the from() function we don't know if there are aliases
foreach ($this->ar_select as $key => $val)
{
- $this->ar_select[$key] = $this->_protect_identifiers($val);
+ $no_escape = isset($this->ar_no_escape[$key]) ? $this->ar_no_escape[$key] : NULL;
+ $this->ar_select[$key] = $this->_protect_identifiers($val, FALSE, $no_escape);
}
$sql .= implode(', ', $this->ar_select);
@@ -1753,9 +1730,7 @@ class CI_DB_active_record extends CI_DB_driver {
if (count($this->ar_where) > 0 OR count($this->ar_like) > 0)
{
- $sql .= "\n";
-
- $sql .= "WHERE ";
+ $sql .= "\nWHERE ";
}
$sql .= implode("\n", $this->ar_where);
@@ -1830,11 +1805,10 @@ class CI_DB_active_record extends CI_DB_driver {
*
* Takes an object as input and converts the class variables to array key/vals
*
- * @access public
* @param object
* @return array
*/
- function _object_to_array($object)
+ public function _object_to_array($object)
{
if ( ! is_object($object))
{
@@ -1861,11 +1835,10 @@ class CI_DB_active_record extends CI_DB_driver {
*
* Takes an object as input and converts the class variables to array key/vals
*
- * @access public
* @param object
* @return array
*/
- function _object_to_array_batch($object)
+ public function _object_to_array_batch($object)
{
if ( ! is_object($object))
{
@@ -1901,10 +1874,9 @@ class CI_DB_active_record extends CI_DB_driver {
*
* Starts AR caching
*
- * @access public
* @return void
*/
- function start_cache()
+ public function start_cache()
{
$this->ar_caching = TRUE;
}
@@ -1916,10 +1888,9 @@ class CI_DB_active_record extends CI_DB_driver {
*
* Stops AR caching
*
- * @access public
* @return void
*/
- function stop_cache()
+ public function stop_cache()
{
$this->ar_caching = FALSE;
}
@@ -1934,22 +1905,21 @@ class CI_DB_active_record extends CI_DB_driver {
* @access public
* @return void
*/
- function flush_cache()
+ public function flush_cache()
{
- $this->_reset_run(
- array(
- 'ar_cache_select' => array(),
- 'ar_cache_from' => array(),
- 'ar_cache_join' => array(),
- 'ar_cache_where' => array(),
- 'ar_cache_like' => array(),
- 'ar_cache_groupby' => array(),
- 'ar_cache_having' => array(),
- 'ar_cache_orderby' => array(),
- 'ar_cache_set' => array(),
- 'ar_cache_exists' => array()
- )
- );
+ $this->_reset_run(array(
+ 'ar_cache_select' => array(),
+ 'ar_cache_from' => array(),
+ 'ar_cache_join' => array(),
+ 'ar_cache_where' => array(),
+ 'ar_cache_like' => array(),
+ 'ar_cache_groupby' => array(),
+ 'ar_cache_having' => array(),
+ 'ar_cache_orderby' => array(),
+ 'ar_cache_set' => array(),
+ 'ar_cache_exists' => array(),
+ 'ar_cache_no_escape' => array()
+ ));
}
// --------------------------------------------------------------------
@@ -1960,10 +1930,9 @@ class CI_DB_active_record extends CI_DB_driver {
* When called, this function merges any cached AR arrays with
* locally called ones.
*
- * @access private
* @return void
*/
- function _merge_cache()
+ protected function _merge_cache()
{
if (count($this->ar_cache_exists) == 0)
{
@@ -1989,6 +1958,8 @@ class CI_DB_active_record extends CI_DB_driver {
{
$this->_track_aliases($this->ar_from);
}
+
+ $this->ar_no_escape = $this->ar_cache_no_escape;
}
// --------------------------------------------------------------------
@@ -1996,11 +1967,10 @@ class CI_DB_active_record extends CI_DB_driver {
/**
* Resets the active record values. Called by the get() function
*
- * @access private
* @param array An array of fields to reset
* @return void
*/
- function _reset_run($ar_reset_items)
+ protected function _reset_run($ar_reset_items)
{
foreach ($ar_reset_items as $item => $default_value)
{
@@ -2016,27 +1986,27 @@ class CI_DB_active_record extends CI_DB_driver {
/**
* Resets the active record values. Called by the get() function
*
- * @access private
* @return void
*/
- function _reset_select()
+ protected function _reset_select()
{
$ar_reset_items = array(
- 'ar_select' => array(),
- 'ar_from' => array(),
- 'ar_join' => array(),
- 'ar_where' => array(),
- 'ar_like' => array(),
- 'ar_groupby' => array(),
- 'ar_having' => array(),
- 'ar_orderby' => array(),
- 'ar_wherein' => array(),
- 'ar_aliased_tables' => array(),
- 'ar_distinct' => FALSE,
- 'ar_limit' => FALSE,
- 'ar_offset' => FALSE,
- 'ar_order' => FALSE,
- );
+ 'ar_select' => array(),
+ 'ar_from' => array(),
+ 'ar_join' => array(),
+ 'ar_where' => array(),
+ 'ar_like' => array(),
+ 'ar_groupby' => array(),
+ 'ar_having' => array(),
+ 'ar_orderby' => array(),
+ 'ar_wherein' => array(),
+ 'ar_aliased_tables' => array(),
+ 'ar_no_escape' => array(),
+ 'ar_distinct' => FALSE,
+ 'ar_limit' => FALSE,
+ 'ar_offset' => FALSE,
+ 'ar_order' => FALSE,
+ );
$this->_reset_run($ar_reset_items);
}
@@ -2048,25 +2018,23 @@ class CI_DB_active_record extends CI_DB_driver {
*
* Called by the insert() update() insert_batch() update_batch() and delete() functions
*
- * @access private
* @return void
*/
- function _reset_write()
+ protected function _reset_write()
{
$ar_reset_items = array(
- 'ar_set' => array(),
- 'ar_from' => array(),
- 'ar_where' => array(),
- 'ar_like' => array(),
- 'ar_orderby' => array(),
- 'ar_keys' => array(),
- 'ar_limit' => FALSE,
- 'ar_order' => FALSE
- );
+ 'ar_set' => array(),
+ 'ar_from' => array(),
+ 'ar_where' => array(),
+ 'ar_like' => array(),
+ 'ar_orderby' => array(),
+ 'ar_keys' => array(),
+ 'ar_limit' => FALSE,
+ 'ar_order' => FALSE
+ );
$this->_reset_run($ar_reset_items);
}
-
}
/* End of file DB_active_rec.php */
diff --git a/system/database/DB_driver.php b/system/database/DB_driver.php
index e7a9de475..10e8ed0c0 100755
--- a/system/database/DB_driver.php
+++ b/system/database/DB_driver.php
@@ -424,8 +424,8 @@ class CI_DB_driver {
if ( ! class_exists($driver))
{
- include_once(BASEPATH.'database/DB_result'.EXT);
- include_once(BASEPATH.'database/drivers/'.$this->dbdriver.'/'.$this->dbdriver.'_result'.EXT);
+ include_once(BASEPATH.'database/DB_result.php');
+ include_once(BASEPATH.'database/drivers/'.$this->dbdriver.'/'.$this->dbdriver.'_result.php');
}
return $driver;
@@ -1115,7 +1115,7 @@ class CI_DB_driver {
if ( ! class_exists('CI_DB_Cache'))
{
- if ( ! @include(BASEPATH.'database/DB_cache'.EXT))
+ if ( ! @include(BASEPATH.'database/DB_cache.php'))
{
return $this->cache_off();
}
diff --git a/system/database/DB_result.php b/system/database/DB_result.php
index 76e1d6abb..0c4e78105 100755
--- a/system/database/DB_result.php
+++ b/system/database/DB_result.php
@@ -28,14 +28,14 @@
*/
class CI_DB_result {
- var $conn_id = NULL;
- var $result_id = NULL;
- var $result_array = array();
- var $result_object = array();
- var $custom_result_object = array();
- var $current_row = 0;
- var $num_rows = 0;
- var $row_data = NULL;
+ var $conn_id = NULL;
+ var $result_id = NULL;
+ var $result_array = array();
+ var $result_object = array();
+ var $custom_result_object = array();
+ var $current_row = 0;
+ var $num_rows = 0;
+ var $row_data = NULL;
/**
@@ -47,47 +47,52 @@ class CI_DB_result {
*/
function result($type = 'object')
{
- if ($type == 'array') return $this->result_array();
- else if ($type == 'object') return $this->result_object();
- else return $this->custom_result_object($type);
+ if ($type == 'array') return $this->result_array();
+ else if ($type == 'object') return $this->result_object();
+ else return $this->custom_result_object($type);
}
// --------------------------------------------------------------------
- /**
- * Custom query result.
- *
- * @param class_name A string that represents the type of object you want back
- * @return array of objects
- */
- function custom_result_object($class_name)
- {
- if (array_key_exists($class_name, $this->custom_result_object))
- {
- return $this->custom_result_object[$class_name];
- }
-
- if ($this->result_id === FALSE OR $this->num_rows() == 0)
- {
- return array();
- }
-
- // add the data to the object
- $this->_data_seek(0);
- $result_object = array();
+ /**
+ * Custom query result.
+ *
+ * @param class_name A string that represents the type of object you want back
+ * @return array of objects
+ */
+ function custom_result_object($class_name)
+ {
+ if (array_key_exists($class_name, $this->custom_result_object))
+ {
+ return $this->custom_result_object[$class_name];
+ }
+
+ if ($this->result_id === FALSE OR $this->num_rows() == 0)
+ {
+ return array();
+ }
+
+ // add the data to the object
+ $this->_data_seek(0);
+ $result_object = array();
+
while ($row = $this->_fetch_object())
- {
- $object = new $class_name();
- foreach ($row as $key => $value)
- {
- $object->$key = $value;
- }
+ {
+ $object = new $class_name();
+
+ foreach ($row as $key => $value)
+ {
+ $object->$key = $value;
+ }
+
$result_object[] = $object;
}
- // return the array
- return $this->custom_result_object[$class_name] = $result_object;
- }
+ // return the array
+ return $this->custom_result_object[$class_name] = $result_object;
+ }
+
+ // --------------------------------------------------------------------
/**
* Query result. "object" version.
@@ -180,9 +185,9 @@ class CI_DB_result {
$n = 0;
}
- if ($type == 'object') return $this->row_object($n);
- else if ($type == 'array') return $this->row_array($n);
- else return $this->custom_row_object($n, $type);
+ if ($type == 'object') return $this->row_object($n);
+ else if ($type == 'array') return $this->row_array($n);
+ else return $this->custom_row_object($n, $type);
}
// --------------------------------------------------------------------
@@ -219,7 +224,7 @@ class CI_DB_result {
// --------------------------------------------------------------------
- /**
+ /**
* Returns a single result row - custom object version
*
* @access public
@@ -242,7 +247,7 @@ class CI_DB_result {
return $result[$this->current_row];
}
- /**
+ /**
* Returns a single result row - object version
*
* @access public
diff --git a/system/database/drivers/mysql/mysql_driver.php b/system/database/drivers/mysql/mysql_driver.php
index 4ff9b0a11..b7d547cc0 100755
--- a/system/database/drivers/mysql/mysql_driver.php
+++ b/system/database/drivers/mysql/mysql_driver.php
@@ -132,7 +132,22 @@ class CI_DB_mysql_driver extends CI_DB {
*/
function db_set_charset($charset, $collation)
{
- return @mysql_query("SET NAMES '".$this->escape_str($charset)."' COLLATE '".$this->escape_str($collation)."'", $this->conn_id);
+ static $use_set_names;
+
+ if ( ! isset($use_set_names))
+ {
+ // mysql_set_charset() requires PHP >= 5.2.3 and MySQL >= 5.0.7, use SET NAMES as fallback
+ $use_set_names = (version_compare(PHP_VERSION, '5.2.3', '>=') && version_compare(mysql_get_server_info(), '5.0.7', '>=')) ? FALSE : TRUE;
+ }
+
+ if ($use_set_names)
+ {
+ return @mysql_query("SET NAMES '".$this->escape_str($charset)."' COLLATE '".$this->escape_str($collation)."'", $this->conn_id);
+ }
+ else
+ {
+ return @mysql_set_charset($charset, $this->conn_id);
+ }
}
// --------------------------------------------------------------------
diff --git a/system/database/drivers/mysql/mysql_forge.php b/system/database/drivers/mysql/mysql_forge.php
index 529ec980d..c1cae136c 100755
--- a/system/database/drivers/mysql/mysql_forge.php
+++ b/system/database/drivers/mysql/mysql_forge.php
@@ -119,9 +119,13 @@ class CI_DB_mysql_forge extends CI_DB_forge {
$sql .= ' DEFAULT \''.$attributes['DEFAULT'].'\'';
}
- if (array_key_exists('NULL', $attributes))
+ if (array_key_exists('NULL', $attributes) && $attributes['NULL'] === TRUE)
{
- $sql .= ($attributes['NULL'] === TRUE) ? ' NULL' : ' NOT NULL';
+ $sql .= ' NULL';
+ }
+ else
+ {
+ $sql .= ' NOT NULL';
}
if (array_key_exists('AUTO_INCREMENT', $attributes) && $attributes['AUTO_INCREMENT'] === TRUE)
diff --git a/system/database/drivers/mysqli/mysqli_driver.php b/system/database/drivers/mysqli/mysqli_driver.php
index ccdabce1a..b8586c21d 100755
--- a/system/database/drivers/mysqli/mysqli_driver.php
+++ b/system/database/drivers/mysqli/mysqli_driver.php
@@ -132,7 +132,22 @@ class CI_DB_mysqli_driver extends CI_DB {
*/
function _db_set_charset($charset, $collation)
{
- return @mysqli_query($this->conn_id, "SET NAMES '".$this->escape_str($charset)."' COLLATE '".$this->escape_str($collation)."'");
+ static $use_set_names;
+
+ if ( ! isset($use_set_names))
+ {
+ // mysqli_set_charset() requires MySQL >= 5.0.7, use SET NAMES as fallback
+ $use_set_names = (version_compare(mysqli_get_server_info($this->conn_id), '5.0.7', '>=')) ? FALSE : TRUE;
+ }
+
+ if ($use_set_names)
+ {
+ return @mysqli_query($this->conn_id, "SET NAMES '".$this->escape_str($charset)."' COLLATE '".$this->escape_str($collation)."'");
+ }
+ else
+ {
+ return @mysqli_set_charset($this->conn_id, $charset);
+ }
}
// --------------------------------------------------------------------
diff --git a/system/database/drivers/mysqli/mysqli_forge.php b/system/database/drivers/mysqli/mysqli_forge.php
index d5097335e..260549457 100755
--- a/system/database/drivers/mysqli/mysqli_forge.php
+++ b/system/database/drivers/mysqli/mysqli_forge.php
@@ -104,9 +104,13 @@ class CI_DB_mysqli_forge extends CI_DB_forge {
$sql .= ' DEFAULT \''.$attributes['DEFAULT'].'\'';
}
- if (array_key_exists('NULL', $attributes))
+ if (array_key_exists('NULL', $attributes) && $attributes['NULL'] === TRUE)
{
- $sql .= ($attributes['NULL'] === TRUE) ? ' NULL' : ' NOT NULL';
+ $sql .= ' NULL';
+ }
+ else
+ {
+ $sql .= ' NOT NULL';
}
if (array_key_exists('AUTO_INCREMENT', $attributes) && $attributes['AUTO_INCREMENT'] === TRUE)
diff --git a/system/database/drivers/postgre/postgre_driver.php b/system/database/drivers/postgre/postgre_driver.php
index 47ff36246..140396885 100755
--- a/system/database/drivers/postgre/postgre_driver.php
+++ b/system/database/drivers/postgre/postgre_driver.php
@@ -554,6 +554,24 @@ class CI_DB_postgre_driver extends CI_DB {
// --------------------------------------------------------------------
/**
+ * Insert_batch statement
+ *
+ * Generates a platform-specific insert 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 _insert_batch($table, $keys, $values)
+ {
+ return "INSERT INTO ".$table." (".implode(', ', $keys).") VALUES ".implode(', ', $values);
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
* Update statement
*
* Generates a platform-specific update string from the supplied data
diff --git a/system/database/drivers/sqlsrv/index.html b/system/database/drivers/sqlsrv/index.html
new file mode 100644
index 000000000..c942a79ce
--- /dev/null
+++ b/system/database/drivers/sqlsrv/index.html
@@ -0,0 +1,10 @@
+<html>
+<head>
+ <title>403 Forbidden</title>
+</head>
+<body>
+
+<p>Directory access is forbidden.</p>
+
+</body>
+</html> \ No newline at end of file
diff --git a/system/database/drivers/sqlsrv/sqlsrv_driver.php b/system/database/drivers/sqlsrv/sqlsrv_driver.php
new file mode 100644
index 000000000..1d32792ce
--- /dev/null
+++ b/system/database/drivers/sqlsrv/sqlsrv_driver.php
@@ -0,0 +1,598 @@
+<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+/**
+ * CodeIgniter
+ *
+ * An open source application development framework for PHP 5.1.6 or newer
+ *
+ * @package CodeIgniter
+ * @author ExpressionEngine Dev Team
+ * @copyright Copyright (c) 2008 - 2011, EllisLab, Inc.
+ * @license http://codeigniter.com/user_guide/license.html
+ * @link http://codeigniter.com
+ * @since Version 1.0
+ * @filesource
+ */
+
+// ------------------------------------------------------------------------
+
+/**
+ * SQLSRV Database Adapter Class
+ *
+ * Note: _DB is an extender class that the app controller
+ * creates dynamically based on whether the active record
+ * class is being used or not.
+ *
+ * @package CodeIgniter
+ * @subpackage Drivers
+ * @category Database
+ * @author ExpressionEngine Dev Team
+ * @link http://codeigniter.com/user_guide/database/
+ */
+class CI_DB_sqlsrv_driver extends CI_DB {
+
+ var $dbdriver = 'sqlsrv';
+
+ // The character used for escaping
+ var $_escape_char = '';
+
+ // clause and character used for LIKE escape sequences
+ var $_like_escape_str = " ESCAPE '%s' ";
+ var $_like_escape_chr = '!';
+
+ /**
+ * The syntax to count rows is slightly different across different
+ * database engines, so this string appears in each driver and is
+ * used for the count_all() and count_all_results() functions.
+ */
+ var $_count_string = "SELECT COUNT(*) AS ";
+ var $_random_keyword = ' ASC'; // not currently supported
+
+ /**
+ * Non-persistent database connection
+ *
+ * @access private called by the base class
+ * @return resource
+ */
+ 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;
+
+ $connection = array(
+ 'UID' => empty($this->username) ? '' : $this->username,
+ 'PWD' => empty($this->password) ? '' : $this->password,
+ 'Database' => $this->database,
+ 'ConnectionPooling' => $pooling ? 1 : 0,
+ 'CharacterSet' => $character_set,
+ 'ReturnDatesAsStrings' => 1
+ );
+
+ // If the username and password are both empty, assume this is a
+ // 'Windows Authentication Mode' connection.
+ if(empty($connection['UID']) && empty($connection['PWD'])) {
+ unset($connection['UID'], $connection['PWD']);
+ }
+
+ return sqlsrv_connect($this->hostname, $connection);
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Persistent database connection
+ *
+ * @access private called by the base class
+ * @return resource
+ */
+ function db_pconnect()
+ {
+ $this->db_connect(TRUE);
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Reconnect
+ *
+ * Keep / reestablish the db connection if no queries have been
+ * sent for a length of time exceeding the server's idle timeout
+ *
+ * @access public
+ * @return void
+ */
+ function reconnect()
+ {
+ // not implemented in MSSQL
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Select the database
+ *
+ * @access private called by the base class
+ * @return resource
+ */
+ function db_select()
+ {
+ return $this->_execute('USE ' . $this->database);
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Set client character set
+ *
+ * @access public
+ * @param string
+ * @param string
+ * @return resource
+ */
+ function db_set_charset($charset, $collation)
+ {
+ // @todo - add support if needed
+ return TRUE;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Execute the query
+ *
+ * @access private called by the base class
+ * @param string an SQL query
+ * @return resource
+ */
+ function _execute($sql)
+ {
+ $sql = $this->_prep_query($sql);
+ return sqlsrv_query($this->conn_id, $sql, null, array(
+ 'Scrollable' => SQLSRV_CURSOR_STATIC,
+ 'SendStreamParamsAtExec' => true
+ ));
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Prep the query
+ *
+ * If needed, each database adapter can prep the query string
+ *
+ * @access private called by execute()
+ * @param string an SQL query
+ * @return string
+ */
+ function _prep_query($sql)
+ {
+ return $sql;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Begin Transaction
+ *
+ * @access public
+ * @return bool
+ */
+ function trans_begin($test_mode = FALSE)
+ {
+ if ( ! $this->trans_enabled)
+ {
+ return TRUE;
+ }
+
+ // When transactions are nested we only begin/commit/rollback the outermost ones
+ if ($this->_trans_depth > 0)
+ {
+ return TRUE;
+ }
+
+ // Reset the transaction failure flag.
+ // If the $test_mode flag is set to TRUE transactions will be rolled back
+ // even if the queries produce a successful result.
+ $this->_trans_failure = ($test_mode === TRUE) ? TRUE : FALSE;
+
+ return sqlsrv_begin_transaction($this->conn_id);
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Commit Transaction
+ *
+ * @access public
+ * @return bool
+ */
+ function trans_commit()
+ {
+ if ( ! $this->trans_enabled)
+ {
+ return TRUE;
+ }
+
+ // When transactions are nested we only begin/commit/rollback the outermost ones
+ if ($this->_trans_depth > 0)
+ {
+ return TRUE;
+ }
+
+ return sqlsrv_commit($this->conn_id);
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Rollback Transaction
+ *
+ * @access public
+ * @return bool
+ */
+ function trans_rollback()
+ {
+ if ( ! $this->trans_enabled)
+ {
+ return TRUE;
+ }
+
+ // When transactions are nested we only begin/commit/rollback the outermost ones
+ if ($this->_trans_depth > 0)
+ {
+ return TRUE;
+ }
+
+ return sqlsrv_rollback($this->conn_id);
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Escape String
+ *
+ * @access public
+ * @param string
+ * @param bool whether or not the string will be used in a LIKE condition
+ * @return string
+ */
+ function escape_str($str, $like = FALSE)
+ {
+ // Escape single quotes
+ return str_replace("'", "''", $str);
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Affected Rows
+ *
+ * @access public
+ * @return integer
+ */
+ function affected_rows()
+ {
+ return @sqlrv_rows_affected($this->conn_id);
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Insert ID
+ *
+ * Returns the last id created in the Identity column.
+ *
+ * @access public
+ * @return integer
+ */
+ function insert_id()
+ {
+ return $this->query('select @@IDENTITY as insert_id')->row('insert_id');
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Parse major version
+ *
+ * Grabs the major version number from the
+ * database server version string passed in.
+ *
+ * @access private
+ * @param string $version
+ * @return int16 major version number
+ */
+ function _parse_major_version($version)
+ {
+ preg_match('/([0-9]+)\.([0-9]+)\.([0-9]+)/', $version, $ver_info);
+ return $ver_info[1]; // return the major version b/c that's all we're interested in.
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Version number query string
+ *
+ * @access public
+ * @return string
+ */
+ function _version()
+ {
+ $info = sqlsrv_server_info($this->conn_id);
+ return sprintf("select '%s' as ver", $info['SQLServerVersion']);
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * "Count All" query
+ *
+ * Generates a platform-specific query string that counts all records in
+ * the specified database
+ *
+ * @access public
+ * @param string
+ * @return string
+ */
+ function count_all($table = '')
+ {
+ if ($table == '')
+ return '0';
+
+ $query = $this->query("SELECT COUNT(*) AS numrows FROM " . $this->dbprefix . $table);
+
+ if ($query->num_rows() == 0)
+ return '0';
+
+ $row = $query->row();
+ return $row->numrows;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * List table query
+ *
+ * Generates a platform-specific query string so that the table names can be fetched
+ *
+ * @access private
+ * @param boolean
+ * @return string
+ */
+ function _list_tables($prefix_limit = FALSE)
+ {
+ return "SELECT name FROM sysobjects WHERE type = 'U' ORDER BY name";
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * List column query
+ *
+ * Generates a platform-specific query string so that the column names can be fetched
+ *
+ * @access private
+ * @param string the table name
+ * @return string
+ */
+ function _list_columns($table = '')
+ {
+ return "SELECT * FROM INFORMATION_SCHEMA.Columns WHERE TABLE_NAME = '".$this->_escape_table($table)."'";
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Field data query
+ *
+ * Generates a platform-specific query so that the column data can be retrieved
+ *
+ * @access public
+ * @param string the table name
+ * @return object
+ */
+ function _field_data($table)
+ {
+ return "SELECT TOP 1 * FROM " . $this->_escape_table($table);
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * The error message string
+ *
+ * @access private
+ * @return string
+ */
+ function _error_message()
+ {
+ $error = array_shift(sqlsrv_errors());
+ return !empty($error['message']) ? $error['message'] : null;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * The error message number
+ *
+ * @access private
+ * @return integer
+ */
+ function _error_number()
+ {
+ $error = array_shift(sqlsrv_errors());
+ return isset($error['SQLSTATE']) ? $error['SQLSTATE'] : null;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Escape Table Name
+ *
+ * This function adds backticks if the table name has a period
+ * in it. Some DBs will get cranky unless periods are escaped
+ *
+ * @access private
+ * @param string the table name
+ * @return string
+ */
+ function _escape_table($table)
+ {
+ return $table;
+ }
+
+
+ /**
+ * Escape the SQL Identifiers
+ *
+ * This function escapes column and table names
+ *
+ * @access private
+ * @param string
+ * @return string
+ */
+ function _escape_identifiers($item)
+ {
+ return $item;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * From Tables
+ *
+ * This function implicitly groups FROM tables so there is no confusion
+ * about operator precedence in harmony with SQL standards
+ *
+ * @access public
+ * @param type
+ * @return type
+ */
+ function _from_tables($tables)
+ {
+ if ( ! is_array($tables))
+ {
+ $tables = array($tables);
+ }
+
+ return implode(', ', $tables);
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Insert statement
+ *
+ * Generates a platform-specific insert 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 _insert($table, $keys, $values)
+ {
+ return "INSERT INTO ".$this->_escape_table($table)." (".implode(', ', $keys).") VALUES (".implode(', ', $values).")";
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Update statement
+ *
+ * Generates a platform-specific update string from the supplied data
+ *
+ * @access public
+ * @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
+ * @return string
+ */
+ function _update($table, $values, $where)
+ {
+ foreach($values as $key => $val)
+ {
+ $valstr[] = $key." = ".$val;
+ }
+
+ return "UPDATE ".$this->_escape_table($table)." SET ".implode(', ', $valstr)." WHERE ".implode(" ", $where);
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Truncate statement
+ *
+ * Generates a platform-specific truncate string from the supplied data
+ * If the database does not support the truncate() command
+ * This function maps to "DELETE FROM table"
+ *
+ * @access public
+ * @param string the table name
+ * @return string
+ */
+ function _truncate($table)
+ {
+ return "TRUNCATE ".$table;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Delete statement
+ *
+ * Generates a platform-specific delete string from the supplied data
+ *
+ * @access public
+ * @param string the table name
+ * @param array the where clause
+ * @param string the limit clause
+ * @return string
+ */
+ function _delete($table, $where)
+ {
+ return "DELETE FROM ".$this->_escape_table($table)." WHERE ".implode(" ", $where);
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Limit string
+ *
+ * Generates a platform-specific LIMIT clause
+ *
+ * @access public
+ * @param string the sql query string
+ * @param integer the number of rows to limit the query to
+ * @param integer the offset value
+ * @return string
+ */
+ function _limit($sql, $limit, $offset)
+ {
+ $i = $limit + $offset;
+
+ return preg_replace('/(^\SELECT (DISTINCT)?)/i','\\1 TOP '.$i.' ', $sql);
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Close DB Connection
+ *
+ * @access public
+ * @param resource
+ * @return void
+ */
+ function _close($conn_id)
+ {
+ @sqlsrv_close($conn_id);
+ }
+
+}
+
+
+
+/* End of file mssql_driver.php */
+/* Location: ./system/database/drivers/mssql/mssql_driver.php */ \ No newline at end of file
diff --git a/system/database/drivers/sqlsrv/sqlsrv_forge.php b/system/database/drivers/sqlsrv/sqlsrv_forge.php
new file mode 100644
index 000000000..cc88ec5ca
--- /dev/null
+++ b/system/database/drivers/sqlsrv/sqlsrv_forge.php
@@ -0,0 +1,248 @@
+<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+/**
+ * CodeIgniter
+ *
+ * An open source application development framework for PHP 5.1.6 or newer
+ *
+ * @package CodeIgniter
+ * @author ExpressionEngine Dev Team
+ * @copyright Copyright (c) 2008 - 2011, EllisLab, Inc.
+ * @license http://codeigniter.com/user_guide/license.html
+ * @link http://codeigniter.com
+ * @since Version 1.0
+ * @filesource
+ */
+
+// ------------------------------------------------------------------------
+
+/**
+ * SQLSRV Forge Class
+ *
+ * @category Database
+ * @author ExpressionEngine Dev Team
+ * @link http://codeigniter.com/user_guide/database/
+ */
+class CI_DB_sqlsrv_forge extends CI_DB_forge {
+
+ /**
+ * Create database
+ *
+ * @access private
+ * @param string the database name
+ * @return bool
+ */
+ function _create_database($name)
+ {
+ return "CREATE DATABASE ".$name;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Drop database
+ *
+ * @access private
+ * @param string the database name
+ * @return bool
+ */
+ function _drop_database($name)
+ {
+ return "DROP DATABASE ".$name;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Drop Table
+ *
+ * @access private
+ * @return bool
+ */
+ function _drop_table($table)
+ {
+ return "DROP TABLE ".$this->db->_escape_identifiers($table);
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Create Table
+ *
+ * @access private
+ * @param string the table name
+ * @param array the fields
+ * @param mixed primary key(s)
+ * @param mixed key(s)
+ * @param boolean should 'IF NOT EXISTS' be added to the SQL
+ * @return bool
+ */
+ function _create_table($table, $fields, $primary_keys, $keys, $if_not_exists)
+ {
+ $sql = 'CREATE TABLE ';
+
+ if ($if_not_exists === TRUE)
+ {
+ $sql .= 'IF NOT EXISTS ';
+ }
+
+ $sql .= $this->db->_escape_identifiers($table)." (";
+ $current_field_count = 0;
+
+ foreach ($fields as $field=>$attributes)
+ {
+ // Numeric field names aren't allowed in databases, so if the key is
+ // numeric, we know it was assigned by PHP and the developer manually
+ // entered the field information, so we'll simply add it to the list
+ if (is_numeric($field))
+ {
+ $sql .= "\n\t$attributes";
+ }
+ else
+ {
+ $attributes = array_change_key_case($attributes, CASE_UPPER);
+
+ $sql .= "\n\t".$this->db->_protect_identifiers($field);
+
+ $sql .= ' '.$attributes['TYPE'];
+
+ if (array_key_exists('CONSTRAINT', $attributes))
+ {
+ $sql .= '('.$attributes['CONSTRAINT'].')';
+ }
+
+ if (array_key_exists('UNSIGNED', $attributes) && $attributes['UNSIGNED'] === TRUE)
+ {
+ $sql .= ' UNSIGNED';
+ }
+
+ if (array_key_exists('DEFAULT', $attributes))
+ {
+ $sql .= ' DEFAULT \''.$attributes['DEFAULT'].'\'';
+ }
+
+ if (array_key_exists('NULL', $attributes) && $attributes['NULL'] === TRUE)
+ {
+ $sql .= ' NULL';
+ }
+ else
+ {
+ $sql .= ' NOT NULL';
+ }
+
+ if (array_key_exists('AUTO_INCREMENT', $attributes) && $attributes['AUTO_INCREMENT'] === TRUE)
+ {
+ $sql .= ' AUTO_INCREMENT';
+ }
+ }
+
+ // don't add a comma on the end of the last field
+ if (++$current_field_count < count($fields))
+ {
+ $sql .= ',';
+ }
+ }
+
+ if (count($primary_keys) > 0)
+ {
+ $primary_keys = $this->db->_protect_identifiers($primary_keys);
+ $sql .= ",\n\tPRIMARY KEY (" . implode(', ', $primary_keys) . ")";
+ }
+
+ if (is_array($keys) && count($keys) > 0)
+ {
+ foreach ($keys as $key)
+ {
+ if (is_array($key))
+ {
+ $key = $this->db->_protect_identifiers($key);
+ }
+ else
+ {
+ $key = array($this->db->_protect_identifiers($key));
+ }
+
+ $sql .= ",\n\tFOREIGN KEY (" . implode(', ', $key) . ")";
+ }
+ }
+
+ $sql .= "\n)";
+
+ return $sql;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Alter table query
+ *
+ * Generates a platform-specific query so that a table can be altered
+ * Called by add_column(), drop_column(), and column_alter(),
+ *
+ * @access private
+ * @param string the ALTER type (ADD, DROP, CHANGE)
+ * @param string the column name
+ * @param string the table name
+ * @param string the column definition
+ * @param string the default value
+ * @param boolean should 'NOT NULL' be added
+ * @param string the field after which we should add the new field
+ * @return object
+ */
+ function _alter_table($alter_type, $table, $column_name, $column_definition = '', $default_value = '', $null = '', $after_field = '')
+ {
+ $sql = 'ALTER TABLE '.$this->db->_protect_identifiers($table)." $alter_type ".$this->db->_protect_identifiers($column_name);
+
+ // DROP has everything it needs now.
+ if ($alter_type == 'DROP')
+ {
+ return $sql;
+ }
+
+ $sql .= " $column_definition";
+
+ if ($default_value != '')
+ {
+ $sql .= " DEFAULT \"$default_value\"";
+ }
+
+ if ($null === NULL)
+ {
+ $sql .= ' NULL';
+ }
+ else
+ {
+ $sql .= ' NOT NULL';
+ }
+
+ if ($after_field != '')
+ {
+ $sql .= ' AFTER ' . $this->db->_protect_identifiers($after_field);
+ }
+
+ return $sql;
+
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Rename a table
+ *
+ * Generates a platform-specific query so that a table can be renamed
+ *
+ * @access private
+ * @param string the old table name
+ * @param string the new table name
+ * @return string
+ */
+ function _rename_table($table_name, $new_table_name)
+ {
+ // I think this syntax will work, but can find little documentation on renaming tables in MSSQL
+ $sql = 'ALTER TABLE '.$this->db->_protect_identifiers($table_name)." RENAME TO ".$this->db->_protect_identifiers($new_table_name);
+ return $sql;
+ }
+
+}
+
+/* End of file mssql_forge.php */
+/* Location: ./system/database/drivers/mssql/mssql_forge.php */ \ No newline at end of file
diff --git a/system/database/drivers/sqlsrv/sqlsrv_result.php b/system/database/drivers/sqlsrv/sqlsrv_result.php
new file mode 100644
index 000000000..bf0abd1c6
--- /dev/null
+++ b/system/database/drivers/sqlsrv/sqlsrv_result.php
@@ -0,0 +1,169 @@
+<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+/**
+ * CodeIgniter
+ *
+ * An open source application development framework for PHP 5.1.6 or newer
+ *
+ * @package CodeIgniter
+ * @author ExpressionEngine Dev Team
+ * @copyright Copyright (c) 2008 - 2011, EllisLab, Inc.
+ * @license http://codeigniter.com/user_guide/license.html
+ * @link http://codeigniter.com
+ * @since Version 1.0
+ * @filesource
+ */
+
+// ------------------------------------------------------------------------
+
+/**
+ * SQLSRV Result Class
+ *
+ * This class extends the parent result class: CI_DB_result
+ *
+ * @category Database
+ * @author ExpressionEngine Dev Team
+ * @link http://codeigniter.com/user_guide/database/
+ */
+class CI_DB_sqlsrv_result extends CI_DB_result {
+
+ /**
+ * Number of rows in the result set
+ *
+ * @access public
+ * @return integer
+ */
+ function num_rows()
+ {
+ return @sqlsrv_num_rows($this->result_id);
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Number of fields in the result set
+ *
+ * @access public
+ * @return integer
+ */
+ function num_fields()
+ {
+ return @sqlsrv_num_fields($this->result_id);
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Fetch Field Names
+ *
+ * Generates an array of column names
+ *
+ * @access public
+ * @return array
+ */
+ function list_fields()
+ {
+ $field_names = array();
+ foreach(sqlsrv_field_metadata($this->result_id) as $offset => $field)
+ {
+ $field_names[] = $field['Name'];
+ }
+
+ return $field_names;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Field data
+ *
+ * Generates an array of objects containing field meta-data
+ *
+ * @access public
+ * @return array
+ */
+ function field_data()
+ {
+ $retval = array();
+ foreach(sqlsrv_field_metadata($this->result_id) as $offset => $field)
+ {
+ $F = new stdClass();
+ $F->name = $field['Name'];
+ $F->type = $field['Type'];
+ $F->max_length = $field['Size'];
+ $F->primary_key = 0;
+ $F->default = '';
+
+ $retval[] = $F;
+ }
+
+ return $retval;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Free the result
+ *
+ * @return null
+ */
+ function free_result()
+ {
+ if (is_resource($this->result_id))
+ {
+ sqlsrv_free_stmt($this->result_id);
+ $this->result_id = FALSE;
+ }
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Data Seek
+ *
+ * Moves the internal pointer to the desired offset. We call
+ * this internally before fetching results to make sure the
+ * result set starts at zero
+ *
+ * @access private
+ * @return array
+ */
+ function _data_seek($n = 0)
+ {
+ // Not implemented
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Result - associative array
+ *
+ * Returns the result set as an array
+ *
+ * @access private
+ * @return array
+ */
+ function _fetch_assoc()
+ {
+ return sqlsrv_fetch_array($this->result_id, SQLSRV_FETCH_ASSOC);
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Result - object
+ *
+ * Returns the result set as an object
+ *
+ * @access private
+ * @return object
+ */
+ function _fetch_object()
+ {
+ return sqlsrv_fetch_object($this->result_id);
+ }
+
+}
+
+
+/* End of file mssql_result.php */
+/* Location: ./system/database/drivers/mssql/mssql_result.php */ \ No newline at end of file
diff --git a/system/database/drivers/sqlsrv/sqlsrv_utility.php b/system/database/drivers/sqlsrv/sqlsrv_utility.php
new file mode 100644
index 000000000..13a1850c4
--- /dev/null
+++ b/system/database/drivers/sqlsrv/sqlsrv_utility.php
@@ -0,0 +1,88 @@
+<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+/**
+ * CodeIgniter
+ *
+ * An open source application development framework for PHP 5.1.6 or newer
+ *
+ * @package CodeIgniter
+ * @author ExpressionEngine Dev Team
+ * @copyright Copyright (c) 2008 - 2011, EllisLab, Inc.
+ * @license http://codeigniter.com/user_guide/license.html
+ * @link http://codeigniter.com
+ * @since Version 1.0
+ * @filesource
+ */
+
+// ------------------------------------------------------------------------
+
+/**
+ * SQLSRV Utility Class
+ *
+ * @category Database
+ * @author ExpressionEngine Dev Team
+ * @link http://codeigniter.com/user_guide/database/
+ */
+class CI_DB_sqlsrv_utility extends CI_DB_utility {
+
+ /**
+ * List databases
+ *
+ * @access private
+ * @return bool
+ */
+ function _list_databases()
+ {
+ return "EXEC sp_helpdb"; // Can also be: EXEC sp_databases
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Optimize table query
+ *
+ * Generates a platform-specific query so that a table can be optimized
+ *
+ * @access private
+ * @param string the table name
+ * @return object
+ */
+ function _optimize_table($table)
+ {
+ return FALSE; // Is this supported in MS SQL?
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Repair table query
+ *
+ * Generates a platform-specific query so that a table can be repaired
+ *
+ * @access private
+ * @param string the table name
+ * @return object
+ */
+ function _repair_table($table)
+ {
+ return FALSE; // Is this supported in MS SQL?
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * MSSQL Export
+ *
+ * @access private
+ * @param array Preferences
+ * @return mixed
+ */
+ function _backup($params = array())
+ {
+ // Currently unsupported
+ return $this->db->display_error('db_unsuported_feature');
+ }
+
+}
+
+/* End of file mssql_utility.php */
+/* Location: ./system/database/drivers/mssql/mssql_utility.php */ \ No newline at end of file
diff --git a/system/fonts/texb.ttf b/system/fonts/texb.ttf
index 6792342a3..383c88b86 100755
--- a/system/fonts/texb.ttf
+++ b/system/fonts/texb.ttf
Binary files differ
diff --git a/system/helpers/download_helper.php b/system/helpers/download_helper.php
index f8073d238..1145688ae 100755
--- a/system/helpers/download_helper.php
+++ b/system/helpers/download_helper.php
@@ -58,13 +58,13 @@ if ( ! function_exists('force_download'))
$extension = end($x);
// Load the mime types
- if (defined('ENVIRONMENT') AND is_file(APPPATH.'config/'.ENVIRONMENT.'/mimes'.EXT))
+ if (defined('ENVIRONMENT') AND is_file(APPPATH.'config/'.ENVIRONMENT.'/mimes.php'))
{
- include(APPPATH.'config/'.ENVIRONMENT.'/mimes'.EXT);
+ include(APPPATH.'config/'.ENVIRONMENT.'/mimes.php');
}
- elseif (is_file(APPPATH.'config/mimes'.EXT))
+ elseif (is_file(APPPATH.'config/mimes.php'))
{
- include(APPPATH.'config/mimes'.EXT);
+ include(APPPATH.'config/mimes.php');
}
// Set a default mime if we can't find it
diff --git a/system/helpers/file_helper.php b/system/helpers/file_helper.php
index 44344947e..3931667fd 100755
--- a/system/helpers/file_helper.php
+++ b/system/helpers/file_helper.php
@@ -352,13 +352,13 @@ if ( ! function_exists('get_mime_by_extension'))
if ( ! is_array($mimes))
{
- if (defined('ENVIRONMENT') AND is_file(APPPATH.'config/'.ENVIRONMENT.'/mimes'.EXT))
+ if (defined('ENVIRONMENT') AND is_file(APPPATH.'config/'.ENVIRONMENT.'/mimes.php'))
{
- include(APPPATH.'config/'.ENVIRONMENT.'/mimes'.EXT);
+ include(APPPATH.'config/'.ENVIRONMENT.'/mimes.php');
}
- elseif (is_file(APPPATH.'config/mimes'.EXT))
+ elseif (is_file(APPPATH.'config/mimes.php'))
{
- include(APPPATH.'config/mimes'.EXT);
+ include(APPPATH.'config/mimes.php');
}
if ( ! is_array($mimes))
diff --git a/system/helpers/form_helper.php b/system/helpers/form_helper.php
index acd75c239..2925d3c7c 100755
--- a/system/helpers/form_helper.php
+++ b/system/helpers/form_helper.php
@@ -72,7 +72,7 @@ if ( ! function_exists('form_open'))
if (is_array($hidden) AND count($hidden) > 0)
{
- $form .= sprintf("\n<div class=\"hidden\">%s</div>", form_hidden($hidden));
+ $form .= sprintf("<div style=\"display:none\">%s</div>", form_hidden($hidden));
}
return $form;
@@ -1032,25 +1032,23 @@ if ( ! function_exists('_get_validation_object'))
{
$CI =& get_instance();
- // We set this as a variable since we're returning by reference
+ // We set this as a variable since we're returning by reference.
$return = FALSE;
-
- if ( ! isset($CI->load->_ci_classes) OR ! isset($CI->load->_ci_classes['form_validation']))
- {
- return $return;
- }
-
- $object = $CI->load->_ci_classes['form_validation'];
-
- if ( ! isset($CI->$object) OR ! is_object($CI->$object))
+
+ if (FALSE !== ($object = $CI->load->is_loaded('form_validation')))
{
- return $return;
+ if ( ! isset($CI->$object) OR ! is_object($CI->$object))
+ {
+ return $return;
+ }
+
+ return $CI->$object;
}
-
- return $CI->$object;
+
+ return $return;
}
}
/* End of file form_helper.php */
-/* Location: ./system/helpers/form_helper.php */ \ No newline at end of file
+/* Location: ./system/helpers/form_helper.php */
diff --git a/system/helpers/html_helper.php b/system/helpers/html_helper.php
index c6103ab6f..b64b60650 100755
--- a/system/helpers/html_helper.php
+++ b/system/helpers/html_helper.php
@@ -40,9 +40,10 @@
*/
if ( ! function_exists('heading'))
{
- function heading($data = '', $h = '1')
+ function heading($data = '', $h = '1', $attributes = '')
{
- return "<h".$h.">".$data."</h".$h.">";
+ $attributes = ($attributes != '') ? ' '.$attributes : $attributes;
+ return "<h".$h.$attributes.">".$data."</h".$h.">";
}
}
@@ -123,6 +124,10 @@ if ( ! function_exists('_list'))
}
$attributes = $atts;
}
+ elseif (is_string($attributes) AND strlen($attributes) > 0)
+ {
+ $attributes = ' '. $attributes;
+ }
// Write the opening list tag
$out .= "<".$type.$attributes.">\n";
@@ -258,13 +263,13 @@ if ( ! function_exists('doctype'))
if ( ! is_array($_doctypes))
{
- if (defined('ENVIRONMENT') AND is_file(APPPATH.'config/'.ENVIRONMENT.'/doctypes'.EXT))
+ if (defined('ENVIRONMENT') AND is_file(APPPATH.'config/'.ENVIRONMENT.'/doctypes.php'))
{
- include(APPPATH.'config/'.ENVIRONMENT.'/doctypes'.EXT);
+ include(APPPATH.'config/'.ENVIRONMENT.'/doctypes.php');
}
- elseif (is_file(APPPATH.'config/doctypes'.EXT))
+ elseif (is_file(APPPATH.'config/doctypes.php'))
{
- include(APPPATH.'config/doctypes'.EXT);
+ include(APPPATH.'config/doctypes.php');
}
if ( ! is_array($_doctypes))
diff --git a/system/helpers/inflector_helper.php b/system/helpers/inflector_helper.php
index c7c113b8a..7b99bc5b4 100755
--- a/system/helpers/inflector_helper.php
+++ b/system/helpers/inflector_helper.php
@@ -41,30 +41,48 @@ if ( ! function_exists('singular'))
{
function singular($str)
{
- $str = trim($str);
- $end = substr($str, -3);
-
- $str = preg_replace('/(.*)?([s|c]h)es/i','$1$2',$str);
-
- if (strtolower($end) == 'ies')
+ $result = strval($str);
+
+ $singular_rules = array(
+ '/(matr)ices$/' => '\1ix',
+ '/(vert|ind)ices$/' => '\1ex',
+ '/^(ox)en/' => '\1',
+ '/(alias)es$/' => '\1',
+ '/([octop|vir])i$/' => '\1us',
+ '/(cris|ax|test)es$/' => '\1is',
+ '/(shoe)s$/' => '\1',
+ '/(o)es$/' => '\1',
+ '/(bus|campus)es$/' => '\1',
+ '/([m|l])ice$/' => '\1ouse',
+ '/(x|ch|ss|sh)es$/' => '\1',
+ '/(m)ovies$/' => '\1\2ovie',
+ '/(s)eries$/' => '\1\2eries',
+ '/([^aeiouy]|qu)ies$/' => '\1y',
+ '/([lr])ves$/' => '\1f',
+ '/(tive)s$/' => '\1',
+ '/(hive)s$/' => '\1',
+ '/([^f])ves$/' => '\1fe',
+ '/(^analy)ses$/' => '\1sis',
+ '/((a)naly|(b)a|(d)iagno|(p)arenthe|(p)rogno|(s)ynop|(t)he)ses$/' => '\1\2sis',
+ '/([ti])a$/' => '\1um',
+ '/(p)eople$/' => '\1\2erson',
+ '/(m)en$/' => '\1an',
+ '/(s)tatuses$/' => '\1\2tatus',
+ '/(c)hildren$/' => '\1\2hild',
+ '/(n)ews$/' => '\1\2ews',
+ '/([^u])s$/' => '\1',
+ );
+
+ foreach ($singular_rules as $rule => $replacement)
{
- $str = substr($str, 0, strlen($str)-3).(preg_match('/[a-z]/',$end) ? 'y' : 'Y');
- }
- elseif (strtolower($end) == 'ses')
- {
- $str = substr($str, 0, strlen($str)-2);
- }
- else
- {
- $end = strtolower(substr($str, -1));
-
- if ($end == 's')
+ if (preg_match($rule, $result))
{
- $str = substr($str, 0, strlen($str)-1);
+ $result = preg_replace($rule, $replacement, $result);
+ break;
}
}
- return $str;
+ return $result;
}
}
@@ -83,40 +101,41 @@ if ( ! function_exists('singular'))
if ( ! function_exists('plural'))
{
function plural($str, $force = FALSE)
- {
- $str = trim($str);
- $end = substr($str, -1);
-
- if (preg_match('/y/i',$end))
- {
- // Y preceded by vowel => regular plural
- $vowels = array('a', 'e', 'i', 'o', 'u', 'A', 'E', 'I', 'O', 'U');
- $str = in_array(substr($str, -2, 1), $vowels) ? $str.'s' : substr($str, 0, -1).'ies';
- }
- elseif (preg_match('/h/i',$end))
- {
- if(preg_match('/^[c|s]h$/i',substr($str, -2)))
- {
- $str .= 'es';
- }
- else
- {
- $str .= 's';
- }
- }
- elseif (preg_match('/s/i',$end))
+ {
+ $result = strval($str);
+
+ $plural_rules = array(
+ '/^(ox)$/' => '\1\2en', // ox
+ '/([m|l])ouse$/' => '\1ice', // mouse, louse
+ '/(matr|vert|ind)ix|ex$/' => '\1ices', // matrix, vertex, index
+ '/(x|ch|ss|sh)$/' => '\1es', // search, switch, fix, box, process, address
+ '/([^aeiouy]|qu)y$/' => '\1ies', // query, ability, agency
+ '/(hive)$/' => '\1s', // archive, hive
+ '/(?:([^f])fe|([lr])f)$/' => '\1\2ves', // half, safe, wife
+ '/sis$/' => 'ses', // basis, diagnosis
+ '/([ti])um$/' => '\1a', // datum, medium
+ '/(p)erson$/' => '\1eople', // person, salesperson
+ '/(m)an$/' => '\1en', // man, woman, spokesman
+ '/(c)hild$/' => '\1hildren', // child
+ '/(buffal|tomat)o$/' => '\1\2oes', // buffalo, tomato
+ '/(bu|campu)s$/' => '\1\2ses', // bus, campus
+ '/(alias|status|virus)/' => '\1es', // alias
+ '/(octop)us$/' => '\1i', // octopus
+ '/(ax|cris|test)is$/' => '\1es', // axis, crisis
+ '/s$/' => 's', // no change (compatibility)
+ '/$/' => 's',
+ );
+
+ foreach ($plural_rules as $rule => $replacement)
{
- if ($force == TRUE)
+ if (preg_match($rule, $result))
{
- $str .= 'es';
+ $result = preg_replace($rule, $replacement, $result);
+ break;
}
}
- else
- {
- $str .= 's';
- }
- return $str;
+ return $result;
}
}
diff --git a/system/helpers/smiley_helper.php b/system/helpers/smiley_helper.php
index a2d1031b3..6d8889354 100755
--- a/system/helpers/smiley_helper.php
+++ b/system/helpers/smiley_helper.php
@@ -229,13 +229,13 @@ if ( ! function_exists('_get_smiley_array'))
{
function _get_smiley_array()
{
- if (defined('ENVIRONMENT') AND file_exists(APPPATH.'config/'.ENVIRONMENT.'/smileys'.EXT))
+ if (defined('ENVIRONMENT') AND file_exists(APPPATH.'config/'.ENVIRONMENT.'/smileys.php'))
{
- include(APPPATH.'config/'.ENVIRONMENT.'/smileys'.EXT);
+ include(APPPATH.'config/'.ENVIRONMENT.'/smileys.php');
}
- elseif (file_exists(APPPATH.'config/smileys'.EXT))
+ elseif (file_exists(APPPATH.'config/smileys.php'))
{
- include(APPPATH.'config/smileys'.EXT);
+ include(APPPATH.'config/smileys.php');
}
if (isset($smileys) AND is_array($smileys))
diff --git a/system/helpers/text_helper.php b/system/helpers/text_helper.php
index cca093976..33d7fa2fd 100755
--- a/system/helpers/text_helper.php
+++ b/system/helpers/text_helper.php
@@ -366,13 +366,13 @@ if ( ! function_exists('convert_accented_characters'))
{
function convert_accented_characters($str)
{
- if (defined('ENVIRONMENT') AND is_file(APPPATH.'config/'.ENVIRONMENT.'/foreign_chars'.EXT))
+ if (defined('ENVIRONMENT') AND is_file(APPPATH.'config/'.ENVIRONMENT.'/foreign_chars.php'))
{
- include(APPPATH.'config/'.ENVIRONMENT.'/foreign_chars'.EXT);
+ include(APPPATH.'config/'.ENVIRONMENT.'/foreign_chars.php');
}
- elseif (is_file(APPPATH.'config/foreign_chars'.EXT))
+ elseif (is_file(APPPATH.'config/foreign_chars.php'))
{
- include(APPPATH.'config/foreign_chars'.EXT);
+ include(APPPATH.'config/foreign_chars.php');
}
if ( ! isset($foreign_characters))
diff --git a/system/helpers/url_helper.php b/system/helpers/url_helper.php
index d0516cee6..9f4b85248 100755
--- a/system/helpers/url_helper.php
+++ b/system/helpers/url_helper.php
@@ -50,18 +50,21 @@ if ( ! function_exists('site_url'))
/**
* Base URL
- *
- * Returns the "base_url" item from your config file
+ *
+ * Create a local URL based on your basepath.
+ * Segments can be passed in as a string or an array, same as site_url
+ * or a URL to a file can be passed in, e.g. to an image file.
*
* @access public
+ * @param string
* @return string
*/
if ( ! function_exists('base_url'))
{
- function base_url()
+ function base_url($uri = '')
{
$CI =& get_instance();
- return $CI->config->slash_item('base_url');
+ return $CI->config->base_url($uri);
}
}
diff --git a/system/language/english/profiler_lang.php b/system/language/english/profiler_lang.php
index b6460fb83..1111158c8 100755
--- a/system/language/english/profiler_lang.php
+++ b/system/language/english/profiler_lang.php
@@ -9,6 +9,7 @@ $lang['profiler_post_data'] = 'POST DATA';
$lang['profiler_uri_string'] = 'URI STRING';
$lang['profiler_memory_usage'] = 'MEMORY USAGE';
$lang['profiler_config'] = 'CONFIG VARIABLES';
+$lang['profiler_session_data'] = 'SESSION DATA';
$lang['profiler_headers'] = 'HTTP HEADERS';
$lang['profiler_no_db'] = 'Database driver is not currently loaded';
$lang['profiler_no_queries'] = 'No queries were run';
@@ -17,6 +18,8 @@ $lang['profiler_no_get'] = 'No GET data exists';
$lang['profiler_no_uri'] = 'No URI data exists';
$lang['profiler_no_memory'] = 'Memory Usage Unavailable';
$lang['profiler_no_profiles'] = 'No Profile data - all Profiler sections have been disabled.';
+$lang['profiler_section_hide'] = 'Hide';
+$lang['profiler_section_show'] = 'Show';
/* End of file profiler_lang.php */
/* Location: ./system/language/english/profiler_lang.php */ \ No newline at end of file
diff --git a/system/libraries/Cache/drivers/Cache_dummy.php b/system/libraries/Cache/drivers/Cache_dummy.php
index de47acb43..f96a68e27 100755
--- a/system/libraries/Cache/drivers/Cache_dummy.php
+++ b/system/libraries/Cache/drivers/Cache_dummy.php
@@ -10,29 +10,29 @@
* @license http://codeigniter.com/user_guide/license.html
* @link http://codeigniter.com
* @since Version 2.0
- * @filesource
+ * @filesource
*/
// ------------------------------------------------------------------------
/**
- * CodeIgniter Dummy Caching Class
+ * CodeIgniter Dummy Caching Class
*
* @package CodeIgniter
* @subpackage Libraries
* @category Core
* @author ExpressionEngine Dev Team
- * @link
+ * @link
*/
class CI_Cache_dummy extends CI_Driver {
/**
- * Get
+ * Get
*
* Since this is the dummy class, it's always going to return FALSE.
*
- * @param string
+ * @param string
* @return Boolean FALSE
*/
public function get($id)
@@ -40,8 +40,8 @@ class CI_Cache_dummy extends CI_Driver {
return FALSE;
}
- // ------------------------------------------------------------------------
-
+ // ------------------------------------------------------------------------
+
/**
* Cache Save
*
@@ -55,7 +55,7 @@ class CI_Cache_dummy extends CI_Driver {
{
return TRUE;
}
-
+
// ------------------------------------------------------------------------
/**
@@ -112,7 +112,7 @@ class CI_Cache_dummy extends CI_Driver {
/**
* Is this caching driver supported on the system?
* Of course this one is.
- *
+ *
* @return TRUE;
*/
public function is_supported()
@@ -121,9 +121,9 @@ class CI_Cache_dummy extends CI_Driver {
}
// ------------------------------------------------------------------------
-
+
}
// End Class
-/* End of file Cache_apc.php */
-/* Location: ./system/libraries/Cache/drivers/Cache_apc.php */ \ No newline at end of file
+/* End of file Cache_dummy.php */
+/* Location: ./system/libraries/Cache/drivers/Cache_dummy.php */ \ No newline at end of file
diff --git a/system/libraries/Calendar.php b/system/libraries/Calendar.php
index 72d228e73..df0fd6eeb 100755
--- a/system/libraries/Calendar.php
+++ b/system/libraries/Calendar.php
@@ -47,7 +47,7 @@ class CI_Calendar {
{
$this->CI =& get_instance();
- if ( ! in_array('calendar_lang'.EXT, $this->CI->lang->is_loaded, TRUE))
+ if ( ! in_array('calendar_lang.php', $this->CI->lang->is_loaded, TRUE))
{
$this->CI->lang->load('calendar');
}
diff --git a/system/libraries/Cart.php b/system/libraries/Cart.php
index 7f65b48b9..b2eaa9ad7 100755
--- a/system/libraries/Cart.php
+++ b/system/libraries/Cart.php
@@ -374,6 +374,7 @@ class CI_Cart {
// Lets add up the individual prices and set the cart sub-total
$total = 0;
+ $items = 0;
foreach ($this->_cart_contents as $key => $val)
{
// We make sure the array contains the proper indexes
@@ -383,13 +384,14 @@ class CI_Cart {
}
$total += ($val['price'] * $val['qty']);
+ $items += $val['qty'];
// Set the subtotal
$this->_cart_contents[$key]['subtotal'] = ($this->_cart_contents[$key]['price'] * $this->_cart_contents[$key]['qty']);
}
// Set the cart total and total items.
- $this->_cart_contents['total_items'] = count($this->_cart_contents);
+ $this->_cart_contents['total_items'] = $items;
$this->_cart_contents['cart_total'] = $total;
// Is our cart empty? If so we delete it from the session
diff --git a/system/libraries/Driver.php b/system/libraries/Driver.php
index d1838f2c1..c32f2c1eb 100755
--- a/system/libraries/Driver.php
+++ b/system/libraries/Driver.php
@@ -43,11 +43,11 @@ class CI_Driver_Library {
// The class will be prefixed with the parent lib
$child_class = $this->lib_name.'_'.$child;
-
+
// Remove the CI_ prefix and lowercase
- $lib_name = strtolower(preg_replace('/^CI_/', '', $this->lib_name));
- $driver_name = strtolower(preg_replace('/^CI_/', '', $child_class));
-
+ $lib_name = ucfirst(strtolower(str_replace('CI_', '', $this->lib_name)));
+ $driver_name = strtolower(str_replace('CI_', '', $child_class));
+
if (in_array($driver_name, array_map('strtolower', $this->valid_drivers)))
{
// check and see if the driver is in a separate file
@@ -59,7 +59,7 @@ class CI_Driver_Library {
// loves me some nesting!
foreach (array(ucfirst($driver_name), $driver_name) as $class)
{
- $filepath = $path.'libraries/'.$lib_name.'/drivers/'.$class.EXT;
+ $filepath = $path.'libraries/'.$lib_name.'/drivers/'.$class.'.php';
if (file_exists($filepath))
{
@@ -226,4 +226,4 @@ class CI_Driver {
// END CI_Driver CLASS
/* End of file Driver.php */
-/* Location: ./system/libraries/Driver.php */ \ No newline at end of file
+/* Location: ./system/libraries/Driver.php */
diff --git a/system/libraries/Email.php b/system/libraries/Email.php
index 6c21f114d..03eccea09 100755
--- a/system/libraries/Email.php
+++ b/system/libraries/Email.php
@@ -395,7 +395,7 @@ class CI_Email {
public function attach($filename, $disposition = 'attachment')
{
$this->_attach_name[] = $filename;
- $this->_attach_type[] = $this->_mime_types(next(explode('.', basename($filename))));
+ $this->_attach_type[] = $this->_mime_types(pathinfo($filename, PATHINFO_EXTENSION));
$this->_attach_disp[] = $disposition; // Can also be 'inline' Not sure if it matters
return $this;
}
@@ -722,7 +722,7 @@ class CI_Email {
{
if ( ! is_array($email))
{
- $this->_set_error_message('email_must_be_array');
+ $this->_set_error_message('lang:email_must_be_array');
return FALSE;
}
@@ -730,7 +730,7 @@ class CI_Email {
{
if ( ! $this->valid_email($val))
{
- $this->_set_error_message('email_invalid_address', $val);
+ $this->_set_error_message('lang:email_invalid_address', $val);
return FALSE;
}
}
@@ -1131,7 +1131,7 @@ class CI_Email {
if ( ! file_exists($filename))
{
- $this->_set_error_message('email_attachment_missing', $filename);
+ $this->_set_error_message('lang:email_attachment_missing', $filename);
return FALSE;
}
@@ -1146,7 +1146,7 @@ class CI_Email {
if ( ! $fp = fopen($filename, FOPEN_READ))
{
- $this->_set_error_message('email_attachment_unreadable', $filename);
+ $this->_set_error_message('lang:email_attachment_unreadable', $filename);
return FALSE;
}
@@ -1353,7 +1353,7 @@ class CI_Email {
( ! isset($this->_bcc_array) AND ! isset($this->_headers['Bcc'])) AND
( ! isset($this->_headers['Cc'])))
{
- $this->_set_error_message('email_no_recipients');
+ $this->_set_error_message('lang:email_no_recipients');
return FALSE;
}
@@ -1484,7 +1484,7 @@ class CI_Email {
if ( ! $this->_send_with_mail())
{
- $this->_set_error_message('email_send_failure_phpmail');
+ $this->_set_error_message('lang:email_send_failure_phpmail');
return FALSE;
}
break;
@@ -1492,7 +1492,7 @@ class CI_Email {
if ( ! $this->_send_with_sendmail())
{
- $this->_set_error_message('email_send_failure_sendmail');
+ $this->_set_error_message('lang:email_send_failure_sendmail');
return FALSE;
}
break;
@@ -1500,14 +1500,14 @@ class CI_Email {
if ( ! $this->_send_with_smtp())
{
- $this->_set_error_message('email_send_failure_smtp');
+ $this->_set_error_message('lang:email_send_failure_smtp');
return FALSE;
}
break;
}
- $this->_set_error_message('email_sent', $this->_get_protocol());
+ $this->_set_error_message('lang:email_sent', $this->_get_protocol());
return TRUE;
}
@@ -1578,8 +1578,8 @@ class CI_Email {
if ($status != 0)
{
- $this->_set_error_message('email_exit_status', $status);
- $this->_set_error_message('email_no_socket');
+ $this->_set_error_message('lang:email_exit_status', $status);
+ $this->_set_error_message('lang:email_no_socket');
return FALSE;
}
@@ -1598,7 +1598,7 @@ class CI_Email {
{
if ($this->smtp_host == '')
{
- $this->_set_error_message('email_no_hostname');
+ $this->_set_error_message('lang:email_no_hostname');
return FALSE;
}
@@ -1647,7 +1647,7 @@ class CI_Email {
if (strncmp($reply, '250', 3) != 0)
{
- $this->_set_error_message('email_smtp_error', $reply);
+ $this->_set_error_message('lang:email_smtp_error', $reply);
return FALSE;
}
@@ -1674,7 +1674,7 @@ class CI_Email {
if ( ! is_resource($this->_smtp_connect))
{
- $this->_set_error_message('email_smtp_error', $errno." ".$errstr);
+ $this->_set_error_message('lang:email_smtp_error', $errno." ".$errstr);
return FALSE;
}
@@ -1737,7 +1737,7 @@ class CI_Email {
if (substr($reply, 0, 3) != $resp)
{
- $this->_set_error_message('email_smtp_error', $reply);
+ $this->_set_error_message('lang:email_smtp_error', $reply);
return FALSE;
}
@@ -1766,7 +1766,7 @@ class CI_Email {
if ($this->smtp_user == "" AND $this->smtp_pass == "")
{
- $this->_set_error_message('email_no_smtp_unpw');
+ $this->_set_error_message('lang:email_no_smtp_unpw');
return FALSE;
}
@@ -1776,7 +1776,7 @@ class CI_Email {
if (strncmp($reply, '334', 3) != 0)
{
- $this->_set_error_message('email_failed_smtp_login', $reply);
+ $this->_set_error_message('lang:email_failed_smtp_login', $reply);
return FALSE;
}
@@ -1786,7 +1786,7 @@ class CI_Email {
if (strncmp($reply, '334', 3) != 0)
{
- $this->_set_error_message('email_smtp_auth_un', $reply);
+ $this->_set_error_message('lang:email_smtp_auth_un', $reply);
return FALSE;
}
@@ -1796,7 +1796,7 @@ class CI_Email {
if (strncmp($reply, '235', 3) != 0)
{
- $this->_set_error_message('email_smtp_auth_pw', $reply);
+ $this->_set_error_message('lang:email_smtp_auth_pw', $reply);
return FALSE;
}
@@ -1815,7 +1815,7 @@ class CI_Email {
{
if ( ! fwrite($this->_smtp_connect, $data . $this->newline))
{
- $this->_set_error_message('email_smtp_data_failure', $data);
+ $this->_set_error_message('lang:email_smtp_data_failure', $data);
return FALSE;
}
else
@@ -1942,7 +1942,7 @@ class CI_Email {
$CI =& get_instance();
$CI->lang->load('email');
- if (FALSE === ($line = $CI->lang->line($msg)))
+ if (substr($msg, 0, 5) != 'lang:' || FALSE === ($line = $CI->lang->line(substr($msg, 5))))
{
$this->_debug_msg[] = str_replace('%s', $val, $msg)."<br />";
}
@@ -2059,4 +2059,4 @@ class CI_Email {
// END CI_Email class
/* End of file Email.php */
-/* Location: ./system/libraries/Email.php */ \ No newline at end of file
+/* Location: ./system/libraries/Email.php */
diff --git a/system/libraries/Encrypt.php b/system/libraries/Encrypt.php
index e5f65878a..b30a8cf0b 100755
--- a/system/libraries/Encrypt.php
+++ b/system/libraries/Encrypt.php
@@ -524,7 +524,7 @@ class CI_Encrypt {
{
if ( ! function_exists('mhash'))
{
- require_once(BASEPATH.'libraries/Sha1'.EXT);
+ require_once(BASEPATH.'libraries/Sha1.php');
$SH = new CI_SHA;
return $SH->generate($str);
}
diff --git a/system/libraries/Form_validation.php b/system/libraries/Form_validation.php
index cfc02eda9..6f79a554a 100755
--- a/system/libraries/Form_validation.php
+++ b/system/libraries/Form_validation.php
@@ -628,6 +628,10 @@ class CI_Form_validation {
$this->_field_data[$row['field']]['postdata'] = (is_bool($result)) ? $postdata : $result;
}
}
+ else
+ {
+ log_message('debug', "Unable to find validation rule: ".$rule);
+ }
continue;
}
@@ -1357,4 +1361,4 @@ class CI_Form_validation {
// END Form Validation Class
/* End of file Form_validation.php */
-/* Location: ./system/libraries/Form_validation.php */ \ No newline at end of file
+/* Location: ./system/libraries/Form_validation.php */
diff --git a/system/libraries/Log.php b/system/libraries/Log.php
index fb2c5a49b..9f1db76ba 100755
--- a/system/libraries/Log.php
+++ b/system/libraries/Log.php
@@ -83,7 +83,7 @@ class CI_Log {
return FALSE;
}
- $filepath = $this->_log_path.'log-'.date('Y-m-d').EXT;
+ $filepath = $this->_log_path.'log-'.date('Y-m-d').'.php';
$message = '';
if ( ! file_exists($filepath))
diff --git a/system/libraries/Pagination.php b/system/libraries/Pagination.php
index 1113f862f..cc62e660b 100755
--- a/system/libraries/Pagination.php
+++ b/system/libraries/Pagination.php
@@ -30,7 +30,7 @@ class CI_Pagination {
var $prefix = ''; // A custom prefix added to the path.
var $suffix = ''; // A custom suffix added to the path.
- var $total_rows = ''; // Total number of items (database results)
+ var $total_rows = 0; // Total number of items (database results)
var $per_page = 10; // Max number of items you want shown per page
var $num_links = 2; // Number of "digit" links to show before/after the currently viewed page
var $cur_page = 0; // The current page being viewed
diff --git a/system/libraries/Profiler.php b/system/libraries/Profiler.php
index 8a1f18ced..082a5ee1d 100755
--- a/system/libraries/Profiler.php
+++ b/system/libraries/Profiler.php
@@ -32,8 +32,6 @@
*/
class CI_Profiler {
- var $CI;
-
protected $_available_sections = array(
'benchmarks',
'get',
@@ -43,14 +41,27 @@ class CI_Profiler {
'controller_info',
'queries',
'http_headers',
+ 'session_data',
'config'
);
+ protected $_query_toggle_count = 25;
+
+ protected $CI;
+
+ // --------------------------------------------------------------------
+
public function __construct($config = array())
{
$this->CI =& get_instance();
$this->CI->load->language('profiler');
+ if (isset($config['query_toggle_count']))
+ {
+ $this->_query_toggle_count = (int) $config['query_toggle_count'];
+ unset($config['query_toggle_count']);
+ }
+
// default all sections to display
foreach ($this->_available_sections as $section)
{
@@ -162,7 +173,7 @@ class CI_Profiler {
$output .= "\n";
$output .= '<legend style="color:#0000FF;">&nbsp;&nbsp;'.$this->CI->lang->line('profiler_queries').'&nbsp;&nbsp;</legend>';
$output .= "\n";
- $output .= "\n\n<table style='border:none; width:100%'>\n";
+ $output .= "\n\n<table style='border:none; width:100%;'>\n";
$output .="<tr><td style='width:100%;color:#0000FF;font-weight:normal;background-color:#eee;padding:5px'>".$this->CI->lang->line('profiler_no_db')."</td></tr>\n";
$output .= "</table>\n";
$output .= "</fieldset>";
@@ -178,13 +189,26 @@ class CI_Profiler {
$output = "\n\n";
+ $count = 0;
+
foreach ($dbs as $db)
{
+ $count++;
+
+ $hide_queries = (count($db->queries) > $this->_query_toggle_count) ? ' display:none' : '';
+
+ $show_hide_js = '(<span style="cursor: pointer;" onclick="var s=document.getElementById(\'ci_profiler_queries_db_'.$count.'\').style;s.display=s.display==\'none\'?\'\':\'none\';this.innerHTML=this.innerHTML==\''.$this->CI->lang->line('profiler_section_hide').'\'?\''.$this->CI->lang->line('profiler_section_show').'\':\''.$this->CI->lang->line('profiler_section_hide').'\';">'.$this->CI->lang->line('profiler_section_hide').'</span>)';
+
+ if ($hide_queries != '')
+ {
+ $show_hide_js = '(<span style="cursor: pointer;" onclick="var s=document.getElementById(\'ci_profiler_queries_db_'.$count.'\').style;s.display=s.display==\'none\'?\'\':\'none\';this.innerHTML=this.innerHTML==\''.$this->CI->lang->line('profiler_section_show').'\'?\''.$this->CI->lang->line('profiler_section_hide').'\':\''.$this->CI->lang->line('profiler_section_show').'\';">'.$this->CI->lang->line('profiler_section_show').'</span>)';
+ }
+
$output .= '<fieldset style="border:1px solid #0000FF;padding:6px 10px 10px 10px;margin:20px 0 20px 0;background-color:#eee">';
$output .= "\n";
- $output .= '<legend style="color:#0000FF;">&nbsp;&nbsp;'.$this->CI->lang->line('profiler_database').':&nbsp; '.$db->database.'&nbsp;&nbsp;&nbsp;'.$this->CI->lang->line('profiler_queries').': '.count($db->queries).'&nbsp;&nbsp;&nbsp;</legend>';
+ $output .= '<legend style="color:#0000FF;">&nbsp;&nbsp;'.$this->CI->lang->line('profiler_database').':&nbsp; '.$db->database.'&nbsp;&nbsp;&nbsp;'.$this->CI->lang->line('profiler_queries').': '.count($db->queries).'&nbsp;&nbsp;'.$show_hide_js.'</legend>';
$output .= "\n";
- $output .= "\n\n<table style='width:100%;'>\n";
+ $output .= "\n\n<table style='width:100%;{$hide_queries}' id='ci_profiler_queries_db_{$count}'>\n";
if (count($db->queries) == 0)
{
@@ -388,7 +412,7 @@ class CI_Profiler {
}
else
{
- $output .= "<div style='color:#5a0099;font-weight:normal;padding:4px 0 4px 0'>".$this->CI->lang->line('profiler_no_memory_usage')."</div>";
+ $output .= "<div style='color:#5a0099;font-weight:normal;padding:4px 0 4px 0'>".$this->CI->lang->line('profiler_no_memory')."</div>";
}
$output .= "</fieldset>";
@@ -410,10 +434,10 @@ class CI_Profiler {
$output = "\n\n";
$output .= '<fieldset id="ci_profiler_http_headers" style="border:1px solid #000;padding:6px 10px 10px 10px;margin:20px 0 20px 0;background-color:#eee">';
$output .= "\n";
- $output .= '<legend style="color:#000;">&nbsp;&nbsp;'.$this->CI->lang->line('profiler_headers').'&nbsp;&nbsp;</legend>';
+ $output .= '<legend style="color:#000;">&nbsp;&nbsp;'.$this->CI->lang->line('profiler_headers').'&nbsp;&nbsp;(<span style="cursor: pointer;" onclick="var s=document.getElementById(\'ci_profiler_httpheaders_table\').style;s.display=s.display==\'none\'?\'\':\'none\';this.innerHTML=this.innerHTML==\''.$this->CI->lang->line('profiler_section_show').'\'?\''.$this->CI->lang->line('profiler_section_hide').'\':\''.$this->CI->lang->line('profiler_section_show').'\';">'.$this->CI->lang->line('profiler_section_show').'</span>)</legend>';
$output .= "\n";
- $output .= "\n\n<table style='width:100%'>\n";
+ $output .= "\n\n<table style='width:100%;display:none' id='ci_profiler_httpheaders_table'>\n";
foreach (array('HTTP_ACCEPT', 'HTTP_USER_AGENT', 'HTTP_CONNECTION', 'SERVER_PORT', 'SERVER_NAME', 'REMOTE_ADDR', 'SERVER_SOFTWARE', 'HTTP_ACCEPT_LANGUAGE', 'SCRIPT_NAME', 'REQUEST_METHOD',' HTTP_HOST', 'REMOTE_HOST', 'CONTENT_TYPE', 'SERVER_PROTOCOL', 'QUERY_STRING', 'HTTP_ACCEPT_ENCODING', 'HTTP_X_FORWARDED_FOR') as $header)
{
@@ -441,10 +465,10 @@ class CI_Profiler {
$output = "\n\n";
$output .= '<fieldset id="ci_profiler_config" style="border:1px solid #000;padding:6px 10px 10px 10px;margin:20px 0 20px 0;background-color:#eee">';
$output .= "\n";
- $output .= '<legend style="color:#000;">&nbsp;&nbsp;'.$this->CI->lang->line('profiler_config').'&nbsp;&nbsp;</legend>';
+ $output .= '<legend style="color:#000;">&nbsp;&nbsp;'.$this->CI->lang->line('profiler_config').'&nbsp;&nbsp;(<span style="cursor: pointer;" onclick="var s=document.getElementById(\'ci_profiler_config_table\').style;s.display=s.display==\'none\'?\'\':\'none\';this.innerHTML=this.innerHTML==\''.$this->CI->lang->line('profiler_section_show').'\'?\''.$this->CI->lang->line('profiler_section_hide').'\':\''.$this->CI->lang->line('profiler_section_show').'\';">'.$this->CI->lang->line('profiler_section_show').'</span>)</legend>';
$output .= "\n";
- $output .= "\n\n<table style='width:100%'>\n";
+ $output .= "\n\n<table style='width:100%; display:none' id='ci_profiler_config_table'>\n";
foreach ($this->CI->config->config as $config=>$val)
{
@@ -465,6 +489,39 @@ class CI_Profiler {
// --------------------------------------------------------------------
/**
+ * Compile session userdata
+ *
+ * @return string
+ */
+ private function _compile_session_data()
+ {
+ if ( ! isset($this->CI->session))
+ {
+ return;
+ }
+
+ $output = '<fieldset id="ci_profiler_csession" style="border:1px solid #000;padding:6px 10px 10px 10px;margin:20px 0 20px 0;background-color:#eee">';
+ $output .= '<legend style="color:#000;">&nbsp;&nbsp;'.$this->CI->lang->line('profiler_session_data').'&nbsp;&nbsp;(<span style="cursor: pointer;" onclick="var s=document.getElementById(\'ci_profiler_session_data\').style;s.display=s.display==\'none\'?\'\':\'none\';this.innerHTML=this.innerHTML==\''.$this->CI->lang->line('profiler_section_show').'\'?\''.$this->CI->lang->line('profiler_section_hide').'\':\''.$this->CI->lang->line('profiler_section_show').'\';">'.$this->CI->lang->line('profiler_section_show').'</span>)</legend>';
+ $output .= "<table style='width:100%;display:none' id='ci_profiler_session_data'>";
+
+ foreach ($this->CI->session->all_userdata() as $key => $val)
+ {
+ if (is_array($val))
+ {
+ $val = print_r($val, TRUE);
+ }
+
+ $output .= "<tr><td style='padding:5px; vertical-align: top;color:#900;background-color:#ddd;'>".$key."&nbsp;&nbsp;</td><td style='padding:5px; color:#000;background-color:#ddd;'>".htmlspecialchars($val)."</td></tr>\n";
+ }
+
+ $output .= '</table>';
+ $output .= "</fieldset>";
+ return $output;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
* Run the Profiler
*
* @return string
@@ -493,7 +550,6 @@ class CI_Profiler {
return $output;
}
-
}
// END CI_Profiler class
diff --git a/system/libraries/Session.php b/system/libraries/Session.php
index 182294059..2c8a80163 100755
--- a/system/libraries/Session.php
+++ b/system/libraries/Session.php
@@ -189,7 +189,7 @@ class CI_Session {
}
// Does the User Agent Match?
- if ($this->sess_match_useragent == TRUE AND trim($session['user_agent']) != trim(substr($this->CI->input->user_agent(), 0, 50)))
+ if ($this->sess_match_useragent == TRUE AND trim($session['user_agent']) != trim(substr($this->CI->input->user_agent(), 0, 120)))
{
$this->sess_destroy();
return FALSE;
@@ -316,7 +316,7 @@ class CI_Session {
$this->userdata = array(
'session_id' => md5(uniqid($sessid, TRUE)),
'ip_address' => $this->CI->input->ip_address(),
- 'user_agent' => substr($this->CI->input->user_agent(), 0, 50),
+ 'user_agent' => substr($this->CI->input->user_agent(), 0, 120),
'last_activity' => $this->now
);
@@ -435,11 +435,11 @@ class CI_Session {
* Fetch all session data
*
* @access public
- * @return mixed
+ * @return array
*/
function all_userdata()
{
- return ( ! isset($this->userdata)) ? FALSE : $this->userdata;
+ return $this->userdata;
}
// --------------------------------------------------------------------
diff --git a/system/libraries/Upload.php b/system/libraries/Upload.php
index e80049fa4..3177424c4 100755
--- a/system/libraries/Upload.php
+++ b/system/libraries/Upload.php
@@ -945,13 +945,13 @@ class CI_Upload {
if (count($this->mimes) == 0)
{
- if (defined('ENVIRONMENT') AND is_file(APPPATH.'config/'.ENVIRONMENT.'/mimes'.EXT))
+ if (defined('ENVIRONMENT') AND is_file(APPPATH.'config/'.ENVIRONMENT.'/mimes.php'))
{
- include(APPPATH.'config/'.ENVIRONMENT.'/mimes'.EXT);
+ include(APPPATH.'config/'.ENVIRONMENT.'/mimes.php');
}
- elseif (is_file(APPPATH.'config/mimes'.EXT))
+ elseif (is_file(APPPATH.'config/mimes.php'))
{
- include(APPPATH.'config//mimes'.EXT);
+ include(APPPATH.'config//mimes.php');
}
else
{
diff --git a/system/libraries/User_agent.php b/system/libraries/User_agent.php
index 04cda7312..016102a2a 100755
--- a/system/libraries/User_agent.php
+++ b/system/libraries/User_agent.php
@@ -84,13 +84,13 @@ class CI_User_agent {
*/
private function _load_agent_file()
{
- if (defined('ENVIRONMENT') AND is_file(APPPATH.'config/'.ENVIRONMENT.'/user_agents'.EXT))
+ if (defined('ENVIRONMENT') AND is_file(APPPATH.'config/'.ENVIRONMENT.'/user_agents.php'))
{
- include(APPPATH.'config/'.ENVIRONMENT.'/user_agents'.EXT);
+ include(APPPATH.'config/'.ENVIRONMENT.'/user_agents.php');
}
- elseif (is_file(APPPATH.'config/user_agents'.EXT))
+ elseif (is_file(APPPATH.'config/user_agents.php'))
{
- include(APPPATH.'config/user_agents'.EXT);
+ include(APPPATH.'config/user_agents.php');
}
else
{