xmlrpcerr['introspect_unknown'], $this->xmlrpcstr['introspect_unknown']);
+ }
+ return $r;
+ }
+
+ //-------------------------------------
+ // Server Function: Doc String for Method
+ //-------------------------------------
+
+ function methodHelp($m)
+ {
+ $methName = $m->getParam(0);
+ $method_name = $methName->scalarval();
+
+ $methods = ereg("^system\.", $method_name) ? $this->system_methods : $this->methods;
+
+ if (isset($methods[$methName]))
+ {
+ $docstring = isset($methods[$method_name]['docstring']) ? $methods[$method_name]['docstring'] : '';
+ $r = new XML_RPC_Response(new XML_RPC_Values($docstring, 'string'));
+ }
+ else
+ {
+ $r = new XML_RPC_Response(0, $this->xmlrpcerr['introspect_unknown'], $this->xmlrpcstr['introspect_unknown']);
+ }
+ return $r;
+ }
+
+ //-------------------------------------
+ // Server Function: Multi-call
+ //-------------------------------------
+
+ function multicall($m)
+ {
+ $calls = $m->getParam(0);
+ list($a,$b)=each($calls->me);
+ $result = array();
+
+ for ($i = 0; $i < sizeof($b); $i++)
+ {
+ $call = $calls->me['array'][$i];
+ $result[$i] = $this->do_multicall($call);
+ }
+
+ return new XML_RPC_Response(new XML_RPC_Values($result, 'array'));
+ }
+
+
+ //-------------------------------------
+ // Multi-call Function: Error Handling
+ //-------------------------------------
+
+ function multicall_error($err)
+ {
+ $str = is_string($err) ? $this->xmlrpcstr["multicall_${err}"] : $err->faultString();
+ $code = is_string($err) ? $this->xmlrpcerr["multicall_${err}"] : $err->faultCode();
+
+ $struct['faultCode'] = new XML_RPC_Values($code, 'int');
+ $struct['faultString'] = new XML_RPC_Values($str, 'string');
+
+ return new XML_RPC_Values($struct, 'struct');
+ }
+
+
+ //-------------------------------------
+ // Multi-call Function: Processes method
+ //-------------------------------------
+
+ function do_multicall($call)
+ {
+ if ($call->kindOf() != 'struct')
+ return $this->multicall_error('notstruct');
+ elseif (!$methName = $call->me['struct']['methodName'])
+ return $this->multicall_error('nomethod');
+
+ list($scalar_type,$scalar_value)=each($methName->me);
+ $scalar_type = $scalar_type == $this->xmlrpcI4 ? $this->xmlrpcInt : $scalar_type;
+
+ if ($methName->kindOf() != 'scalar' || $scalar_type != 'string')
+ return $this->multicall_error('notstring');
+ elseif ($scalar_value == 'system.multicall')
+ return $this->multicall_error('recursion');
+ elseif (!$params = $call->me['struct']['params'])
+ return $this->multicall_error('noparams');
+ elseif ($params->kindOf() != 'array')
+ return $this->multicall_error('notarray');
+
+ list($a,$b)=each($params->me);
+ $numParams = sizeof($b);
+
+ $msg = new XML_RPC_Message($scalar_value);
+ for ($i = 0; $i < $numParams; $i++)
+ {
+ $msg->params[] = $params->me['array'][$i];
+ }
+
+ $result = $this->execute($msg);
+
+ if ($result->faultCode() != 0)
+ {
+ return $this->multicall_error($result);
+ }
+
+ return new XML_RPC_Values(array($result->value()), 'array');
+ }
+
+}
+// END XML_RPC_Server class
+?>
\ No newline at end of file
diff --git a/system/libraries/index.html b/system/libraries/index.html
new file mode 100644
index 000000000..5a1f5d6ae
--- /dev/null
+++ b/system/libraries/index.html
@@ -0,0 +1,15 @@
+
+
+
+
+403 Forbidden
+
+
+
+
+
+Directory access is forbidden.
+
+
+
+
\ No newline at end of file
--
cgit v1.2.3-24-g4f1b
From d4e95072203a5cf4f1d50d16fe3e490f275a4307 Mon Sep 17 00:00:00 2001
From: admin
Date: Sat, 26 Aug 2006 01:15:06 +0000
Subject:
---
system/libraries/Router.php | 19 +++++++++++++++----
1 file changed, 15 insertions(+), 4 deletions(-)
(limited to 'system/libraries')
diff --git a/system/libraries/Router.php b/system/libraries/Router.php
index abc253eff..b61dfb79c 100644
--- a/system/libraries/Router.php
+++ b/system/libraries/Router.php
@@ -300,16 +300,27 @@ class CI_Router {
}
// Loop through the route array looking for wildcards
- foreach ($this->routes as $key => $val)
+ foreach (array_slice($this->routes, 1) as $key => $val)
{
if (count(explode('/', $key)) != $num)
continue;
-
- if (preg_match("|".str_replace(':any', '.+', str_replace(':num', '[0-9]+', $key))."$|", $uri))
- {
+
+ // Convert wildcards to RegEx
+ $key = str_replace(':any', '.+', str_replace(':num', '[0-9]+', $key));
+
+ // Does the regex match this URI ?
+ if (preg_match('|^'.$key.'$|', $uri))
+ {
+ // Do we have a replacemnt?
+ if (strpos($val, '$') !== FALSE AND strpos($key, '(') !== FALSE)
+ {
+ $val = preg_replace('|^'.$key.'$|', $val, $uri);
+ }
+
$this->_compile_segments(explode('/', $val), TRUE);
break;
}
+
}
}
// END set_method()
--
cgit v1.2.3-24-g4f1b
From 45c872b0ac215d590e785fe393241a06facd7e05 Mon Sep 17 00:00:00 2001
From: admin
Date: Sat, 26 Aug 2006 04:51:38 +0000
Subject:
---
system/libraries/Router.php | 211 +++++++++++++++++++++++++++++---------------
1 file changed, 142 insertions(+), 69 deletions(-)
(limited to 'system/libraries')
diff --git a/system/libraries/Router.php b/system/libraries/Router.php
index b61dfb79c..7839de2d9 100644
--- a/system/libraries/Router.php
+++ b/system/libraries/Router.php
@@ -34,6 +34,7 @@ class CI_Router {
var $routes = array();
var $class = '';
var $method = 'index';
+ var $directory = '';
var $uri_protocol = 'auto';
var $default_controller;
var $scaffolding_request = FALSE; // Must be set to FALSE
@@ -121,6 +122,7 @@ class CI_Router {
log_message('debug', "No URI present. Default controller set.");
return;
}
+ unset($this->routes['default_controller']);
// Do we need to remove the suffix specified in the config file?
if ($this->config->item('url_suffix') != "")
@@ -129,13 +131,20 @@ class CI_Router {
}
// Explode the URI Segments. The individual segments will
- // be stored in the $this->segments array.
- $this->_compile_segments(explode("/", preg_replace("|/*(.+?)/*$|", "\\1", $this->uri_string)));
-
-
- // Remap the class/method if a route exists
- unset($this->routes['default_controller']);
+ // be stored in the $this->segments array.
+ $i = 1;
+ foreach(explode("/", preg_replace("|/*(.+?)/*$|", "\\1", $this->uri_string)) as $val)
+ {
+ // Filter segments for security
+ $val = trim($this->_filter_uri($val));
+
+ if ($val != '')
+ $this->segments[$i++] = $val;
+ }
+ $this->_compile_segments($this->segments);
+
+ // Do we have any custom routing to deal with?
if (count($this->routes) > 0)
{
$this->_parse_routes();
@@ -157,19 +166,15 @@ class CI_Router {
* @param bool
* @return void
*/
- function _compile_segments($segs, $route = FALSE)
- {
- $segments = array();
-
- $i = 1;
- foreach($segs as $val)
+ function _compile_segments($segments = array())
+ {
+ $segments = $this->_validate_segments($segments);
+
+ if (count($segments) == 0)
{
- $val = trim($this->_filter_uri($val));
-
- if ($val != '')
- $segments[$i++] = $val;
+ return;
}
-
+
$this->set_class($segments['1']);
if (isset($segments['2']))
@@ -186,15 +191,54 @@ class CI_Router {
$this->set_method($segments['2']);
}
}
-
- if ($route == FALSE)
+ }
+ // END _compile_segments()
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Validates the supplied segments. Attempts to determine the path to
+ * the controller.
+ *
+ * @access private
+ * @param array
+ * @return array
+ */
+ function _validate_segments($segments)
+ {
+ // Does the requested controller exist?
+ if ( ! file_exists(APPPATH.'controllers/'.$segments['1'].EXT))
{
- $this->segments = $segments;
+ // Is it a directory? No? Smite them!
+ if ( ! is_dir(APPPATH.'controllers/'.$segments['1']))
+ {
+ show_404();
+ }
+ else
+ {
+ $this->set_directory($segments['1']);
+ $segs = array_slice($segments, 1);
+
+ if (count($segs) == 0)
+ {
+ $this->set_class($this->default_controller);
+ $this->set_method('index');
+ $this->directory = '';
+ return array();
+ }
+
+ $i = 1;
+ $segments = array();
+ foreach ($segs as $val)
+ {
+ $segments[$i++] = $val;
+ }
+ }
}
- unset($segments);
+ return $segments;
}
- // END _compile_segments()
+ // END _validate_segments()
// --------------------------------------------------------------------
@@ -218,6 +262,56 @@ class CI_Router {
// --------------------------------------------------------------------
+ /**
+ * Parse Routes
+ *
+ * This function matches any routes that may exist in
+ * the config/routes.php file against the URI to
+ * determine if the class/method need to be remapped.
+ *
+ * @access private
+ * @return void
+ */
+ function _parse_routes()
+ {
+ // Turn the segment array into a URI string
+ $uri = implode('/', $this->segments);
+ $num = count($this->segments);
+
+ // Is there a literal match? If so we're done
+ if (isset($this->routes[$uri]))
+ {
+ $this->_compile_segments(explode('/', $this->routes[$uri]));
+ return;
+ }
+
+ // Loop through the route array looking for wildcards
+ foreach (array_slice($this->routes, 1) as $key => $val)
+ {
+ if (count(explode('/', $key)) != $num)
+ continue;
+
+ // Convert wildcards to RegEx
+ $key = str_replace(':any', '.+', str_replace(':num', '[0-9]+', $key));
+
+ // Does the RegEx match?
+ if (preg_match('|^'.$key.'$|', $uri))
+ {
+ // Do we have a back-reference?
+ if (strpos($val, '$') !== FALSE AND strpos($key, '(') !== FALSE)
+ {
+ $val = preg_replace('|^'.$key.'$|', $val, $uri);
+ }
+
+ $this->_compile_segments(explode('/', $val));
+ return;
+ }
+ }
+ }
+ // END set_method()
+
+ // --------------------------------------------------------------------
+
/**
* Set the class name
*
@@ -229,7 +323,7 @@ class CI_Router {
{
$this->class = $class;
}
- // END _filter_uri()
+ // END set_class()
// --------------------------------------------------------------------
@@ -243,7 +337,7 @@ class CI_Router {
{
return $this->class;
}
- // END _filter_uri()
+ // END fetch_class()
// --------------------------------------------------------------------
@@ -259,7 +353,7 @@ class CI_Router {
$this->method = $method;
}
// END set_method()
-
+
// --------------------------------------------------------------------
/**
@@ -272,58 +366,37 @@ class CI_Router {
{
return $this->method;
}
- // END set_method()
-
+ // END fetch_method()
+
// --------------------------------------------------------------------
/**
- * Parse Routes
+ * Set the directory name
*
- * This function matches any routes that may exist in
- * the config/routes.php file against the URI to
- * determine if the class/method need to be remapped.
- *
- * @access private
+ * @access public
+ * @param string
* @return void
- */
- function _parse_routes()
+ */
+ function set_directory($dir)
{
- // Turn the segment array into a URI string
- $uri = implode('/', $this->segments);
- $num = count($this->segments);
+ $this->directory = $dir.'/';
+ }
+ // END set_directory()
- // Is there a literal match? If so we're done
- if (isset($this->routes[$uri]))
- {
- $this->_compile_segments(explode('/', $this->routes[$uri]), TRUE);
- return;
- }
-
- // Loop through the route array looking for wildcards
- foreach (array_slice($this->routes, 1) as $key => $val)
- {
- if (count(explode('/', $key)) != $num)
- continue;
-
- // Convert wildcards to RegEx
- $key = str_replace(':any', '.+', str_replace(':num', '[0-9]+', $key));
-
- // Does the regex match this URI ?
- if (preg_match('|^'.$key.'$|', $uri))
- {
- // Do we have a replacemnt?
- if (strpos($val, '$') !== FALSE AND strpos($key, '(') !== FALSE)
- {
- $val = preg_replace('|^'.$key.'$|', $val, $uri);
- }
-
- $this->_compile_segments(explode('/', $val), TRUE);
- break;
- }
-
- }
+ // --------------------------------------------------------------------
+
+ /**
+ * Fetch the sub-directory (if any) that contains the requested controller class
+ *
+ * @access public
+ * @return string
+ */
+ function fetch_directory()
+ {
+ return $this->directory;
}
- // END set_method()
+ // END fetch_directory()
+
}
// END Router Class
?>
\ No newline at end of file
--
cgit v1.2.3-24-g4f1b
From e07fbb376a741e21e69a182eada322c4d3b7e62e Mon Sep 17 00:00:00 2001
From: admin
Date: Sat, 26 Aug 2006 17:11:01 +0000
Subject:
---
system/libraries/Router.php | 84 +++++++++++++++++++++++++--------------------
1 file changed, 46 insertions(+), 38 deletions(-)
(limited to 'system/libraries')
diff --git a/system/libraries/Router.php b/system/libraries/Router.php
index 7839de2d9..678145458 100644
--- a/system/libraries/Router.php
+++ b/system/libraries/Router.php
@@ -132,23 +132,25 @@ class CI_Router {
// Explode the URI Segments. The individual segments will
// be stored in the $this->segments array.
- $i = 1;
foreach(explode("/", preg_replace("|/*(.+?)/*$|", "\\1", $this->uri_string)) as $val)
{
// Filter segments for security
$val = trim($this->_filter_uri($val));
if ($val != '')
- $this->segments[$i++] = $val;
+ $this->segments[] = $val;
}
- $this->_compile_segments($this->segments);
+ // Parse any custom routing that may exist
+ $this->_parse_routes();
- // Do we have any custom routing to deal with?
- if (count($this->routes) > 0)
+ // Re-index the segment array so that it starts with 1 rather than 0
+ $i = 1;
+ foreach ($this->segments as $val)
{
- $this->_parse_routes();
+ $this->segments[$i++] = $val;
}
+ unset($this->segments['0']);
}
// END _set_route_mapping()
@@ -175,12 +177,12 @@ class CI_Router {
return;
}
- $this->set_class($segments['1']);
+ $this->set_class($segments['0']);
- if (isset($segments['2']))
+ if (isset($segments['1']))
{
// A scaffolding request. No funny business with the URL
- if ($this->routes['scaffolding_trigger'] == $segments['2'] AND $segments['2'] != '_ci_scaffolding')
+ if ($this->routes['scaffolding_trigger'] == $segments['1'] AND $segments['1'] != '_ci_scaffolding')
{
$this->scaffolding_request = TRUE;
unset($this->routes['scaffolding_trigger']);
@@ -188,7 +190,7 @@ class CI_Router {
else
{
// A standard method request
- $this->set_method($segments['2']);
+ $this->set_method($segments['1']);
}
}
}
@@ -206,37 +208,32 @@ class CI_Router {
*/
function _validate_segments($segments)
{
- // Does the requested controller exist?
- if ( ! file_exists(APPPATH.'controllers/'.$segments['1'].EXT))
+ // Does the requested controller exist in the root folder?
+ if (file_exists(APPPATH.'controllers/'.$segments['0'].EXT))
{
- // Is it a directory? No? Smite them!
- if ( ! is_dir(APPPATH.'controllers/'.$segments['1']))
+ return $segments;
+ }
+
+ // Is the controller in a sub-folder?
+ if (is_dir(APPPATH.'controllers/'.$segments['0']))
+ {
+ // Set the directory and remove it from the segment array
+ $this->set_directory($segments['0']);
+ $segments = array_slice($segments, 1);
+
+ if (count($segments) == 0)
{
- show_404();
+ $this->set_class($this->default_controller);
+ $this->set_method('index');
+ $this->directory = '';
+ return array();
}
- else
- {
- $this->set_directory($segments['1']);
- $segs = array_slice($segments, 1);
- if (count($segs) == 0)
- {
- $this->set_class($this->default_controller);
- $this->set_method('index');
- $this->directory = '';
- return array();
- }
-
- $i = 1;
- $segments = array();
- foreach ($segs as $val)
- {
- $segments[$i++] = $val;
- }
- }
+ return $segments;
}
-
- return $segments;
+
+ // Can't find the requested controller...
+ show_404();
}
// END _validate_segments()
@@ -274,6 +271,13 @@ class CI_Router {
*/
function _parse_routes()
{
+ // Do we even have any custom routing to deal with?
+ if (count($this->routes) == 0)
+ {
+ $this->_compile_segments($this->segments);
+ return;
+ }
+
// Turn the segment array into a URI string
$uri = implode('/', $this->segments);
$num = count($this->segments);
@@ -284,7 +288,7 @@ class CI_Router {
$this->_compile_segments(explode('/', $this->routes[$uri]));
return;
}
-
+
// Loop through the route array looking for wildcards
foreach (array_slice($this->routes, 1) as $key => $val)
{
@@ -306,7 +310,11 @@ class CI_Router {
$this->_compile_segments(explode('/', $val));
return;
}
- }
+ }
+
+ // If we got this far it means we didn't encounter a
+ // matching route so we'll set the site default route
+ $this->_compile_segments($this->segments);
}
// END set_method()
--
cgit v1.2.3-24-g4f1b
From b071bb5a92aade551345a495fb13f5678f3978d0 Mon Sep 17 00:00:00 2001
From: admin
Date: Sat, 26 Aug 2006 19:28:37 +0000
Subject:
---
system/libraries/Calendar.php | 2 +-
system/libraries/Loader.php | 2 +-
system/libraries/Router.php | 45 +++++++++++++++++++++++--------------------
system/libraries/URI.php | 14 +++++++-------
4 files changed, 33 insertions(+), 30 deletions(-)
(limited to 'system/libraries')
diff --git a/system/libraries/Calendar.php b/system/libraries/Calendar.php
index 013f06796..b77dd1b6f 100644
--- a/system/libraries/Calendar.php
+++ b/system/libraries/Calendar.php
@@ -263,7 +263,7 @@ class CI_Calendar {
}
else
{
- $month_names = array('01' => 'cal_january', '02' => 'cal_february', '03' => 'cal_march', '04' => 'cal_april', '05' => 'cal_mayl', '06' => 'cal_june', '07' => 'cal_july', '08' => 'cal_august', '09' => 'cal_september', '10' => 'cal_october', '11' => 'cal_novermber', '12' => 'cal_december');
+ $month_names = array('01' => 'cal_january', '02' => 'cal_february', '03' => 'cal_march', '04' => 'cal_april', '05' => 'cal_mayl', '06' => 'cal_june', '07' => 'cal_july', '08' => 'cal_august', '09' => 'cal_september', '10' => 'cal_october', '11' => 'cal_november', '12' => 'cal_december');
}
$month = $month_names[$month];
diff --git a/system/libraries/Loader.php b/system/libraries/Loader.php
index e2467fa64..3d2501fc0 100644
--- a/system/libraries/Loader.php
+++ b/system/libraries/Loader.php
@@ -478,7 +478,7 @@ class CI_Loader {
if ($path == '')
{
$ext = pathinfo($view, PATHINFO_EXTENSION);
- $file = ($ext == '') ? $view.EXT : $view;
+ $file = ($ext != EXT) ? $view.EXT : $view;
$path = $this->view_path.$file;
}
else
diff --git a/system/libraries/Router.php b/system/libraries/Router.php
index 678145458..b28ead953 100644
--- a/system/libraries/Router.php
+++ b/system/libraries/Router.php
@@ -87,25 +87,31 @@ class CI_Router {
// Fetch the URI string Depending on the server,
// the URI will be available in one of two globals
- switch ($this->config->item('uri_protocol'))
+ if ($this->config->item('uri_protocol') == 'auto')
{
- case 'path_info' : $this->uri_string = (isset($_SERVER['PATH_INFO'])) ? $_SERVER['PATH_INFO'] : @getenv('PATH_INFO');
- break;
- case 'query_string' : $this->uri_string = (isset($_SERVER['QUERY_STRING'])) ? $_SERVER['QUERY_STRING'] : @getenv('QUERY_STRING');
- break;
- default :
- $path_info = (isset($_SERVER['PATH_INFO'])) ? $_SERVER['PATH_INFO'] : @getenv('PATH_INFO');
-
- if ($path_info != '' AND $path_info != "/".SELF)
- {
- $this->uri_string = $path_info;
- }
- else
- {
- $this->uri_string = (isset($_SERVER['QUERY_STRING'])) ? $_SERVER['QUERY_STRING'] : @getenv('QUERY_STRING');
- }
- break;
+ $path_info = getenv('PATH_INFO');
+ if ($path_info != '' AND $path_info != "/".SELF)
+ {
+ $this->uri_string = $path_info;
+ }
+ else
+ {
+ $path_info = getenv('ORIG_PATH_INFO');
+ if ($path_info != '' AND $path_info != "/".SELF)
+ {
+ $this->uri_string = $path_info;
+ }
+ else
+ {
+ $this->uri_string = getenv('QUERY_STRING');
+ }
+ }
+ }
+ else
+ {
+ $this->uri_string = getenv(strtoupper($this->config->item('uri_protocol')));
}
+
// Is there a URI string? If not, the default controller specified
// by the admin in the "routes" file will be shown.
@@ -291,10 +297,7 @@ class CI_Router {
// Loop through the route array looking for wildcards
foreach (array_slice($this->routes, 1) as $key => $val)
- {
- if (count(explode('/', $key)) != $num)
- continue;
-
+ {
// Convert wildcards to RegEx
$key = str_replace(':any', '.+', str_replace(':num', '[0-9]+', $key));
diff --git a/system/libraries/URI.php b/system/libraries/URI.php
index 4c2fa9c7f..c5fd4625b 100644
--- a/system/libraries/URI.php
+++ b/system/libraries/URI.php
@@ -28,7 +28,7 @@
*/
class CI_URI {
- var $uri;
+ var $router;
var $keyval = array();
/**
@@ -42,7 +42,7 @@ class CI_URI {
*/
function CI_URI()
{
- $this->uri =& _load_class('CI_Router');
+ $this->router =& _load_class('CI_Router');
log_message('debug', "URI Class Initialized");
}
@@ -60,7 +60,7 @@ class CI_URI {
*/
function segment($n, $no_result = FALSE)
{
- return ( ! isset($this->uri->segments[$n])) ? $no_result : $this->uri->segments[$n];
+ return ( ! isset($this->router->segments[$n])) ? $no_result : $this->router->segments[$n];
}
// --------------------------------------------------------------------
@@ -196,7 +196,7 @@ class CI_URI {
$leading = '/';
$trailing = '/';
}
- return ( ! isset($this->uri->segments[$n])) ? '' : $leading.$this->uri->segments[$n].$trailing;
+ return ( ! isset($this->router->segments[$n])) ? '' : $leading.$this->router->segments[$n].$trailing;
}
// --------------------------------------------------------------------
@@ -209,7 +209,7 @@ class CI_URI {
*/
function segment_array()
{
- return $this->uri->segments;
+ return $this->router->segments;
}
// --------------------------------------------------------------------
@@ -222,7 +222,7 @@ class CI_URI {
*/
function total_segments()
{
- return count($this->uri->segments);
+ return count($this->router->segments);
}
// --------------------------------------------------------------------
@@ -235,7 +235,7 @@ class CI_URI {
*/
function uri_string()
{
- return $this->uri->uri_string;
+ return $this->router->uri_string;
}
}
--
cgit v1.2.3-24-g4f1b
From 141808ad31d4eefad4c6c3dbaf8306fac2342668 Mon Sep 17 00:00:00 2001
From: admin
Date: Sun, 27 Aug 2006 01:52:51 +0000
Subject:
---
system/libraries/Encrypt.php | 2 +-
system/libraries/Language.php | 2 +-
system/libraries/Log.php | 2 +-
system/libraries/Validation.php | 8 ++++----
4 files changed, 7 insertions(+), 7 deletions(-)
(limited to 'system/libraries')
diff --git a/system/libraries/Encrypt.php b/system/libraries/Encrypt.php
index 532bfe1f1..bcffdf1ab 100644
--- a/system/libraries/Encrypt.php
+++ b/system/libraries/Encrypt.php
@@ -322,7 +322,7 @@ class CI_Encrypt {
*/
function set_hash($type = 'sha1')
{
- $this->_hash_type = ($type != 'sha1' OR $type != 'md5') ? 'sha1' : $type;
+ $this->_hash_type = ($type != 'sha1' AND $type != 'md5') ? 'sha1' : $type;
}
// END set_hash()
diff --git a/system/libraries/Language.php b/system/libraries/Language.php
index b668aa060..328d53e46 100644
--- a/system/libraries/Language.php
+++ b/system/libraries/Language.php
@@ -68,7 +68,7 @@ class CI_Language {
if ( ! file_exists(BASEPATH.'language/'.$idiom.'/'.$langfile))
{
- show_error('Unable to load the requested language file: language/'.$langfile.EXT);
+ show_error('Unable to load the requested language file: language/'.$langfile);
}
include_once(BASEPATH.'language/'.$idiom.'/'.$langfile);
diff --git a/system/libraries/Log.php b/system/libraries/Log.php
index 35e30b64c..17b96b2c2 100644
--- a/system/libraries/Log.php
+++ b/system/libraries/Log.php
@@ -88,7 +88,7 @@ class CI_Log {
return FALSE;
}
- $filepath = $this->log_path.'log-'.date('Y-m-d').'.php';
+ $filepath = $this->log_path.'log-'.date('Y-m-d').EXT;
$message = '';
if ( ! file_exists($filepath))
diff --git a/system/libraries/Validation.php b/system/libraries/Validation.php
index df8c70ee8..e037e69c5 100644
--- a/system/libraries/Validation.php
+++ b/system/libraries/Validation.php
@@ -252,12 +252,12 @@ class CI_Validation {
// Strip the parameter (if exists) from the rule
// Rules can contain a parameter: max_length[5]
$param = FALSE;
- if (preg_match("/.*?(\[.*?\]).*/", $rule, $match))
+ if (preg_match("/(.*?)\[(.*?)\]/", $rule, $match))
{
- $param = substr(substr($match['1'], 1), 0, -1);
- $rule = str_replace($match['1'], '', $rule);
+ $rule = $match[1];
+ $param = $match[2];
}
-
+
// Call the function that corresponds to the rule
if ($callback === TRUE)
{
--
cgit v1.2.3-24-g4f1b
From 57b3d39cb79bb3b8d193e0e345a62e3396e519f2 Mon Sep 17 00:00:00 2001
From: admin
Date: Sun, 27 Aug 2006 15:28:31 +0000
Subject:
---
system/libraries/Log.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
(limited to 'system/libraries')
diff --git a/system/libraries/Log.php b/system/libraries/Log.php
index 17b96b2c2..de5a9b836 100644
--- a/system/libraries/Log.php
+++ b/system/libraries/Log.php
@@ -40,7 +40,7 @@ class CI_Log {
* @param string the error threshold
* @param string the date formatting codes
*/
- function CI_Log($path = '', $threshold = '', $date_fmt = '')
+ function CI_Log($path = '', $threshold = 4, $date_fmt = '')
{
$this->log_path = ($path != '') ? $path : BASEPATH.'logs/';
--
cgit v1.2.3-24-g4f1b
From b4473d4407311cc5e4b2306cf5fa51221d5826f8 Mon Sep 17 00:00:00 2001
From: admin
Date: Sun, 27 Aug 2006 15:46:31 +0000
Subject:
---
system/libraries/Controller.php | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
(limited to 'system/libraries')
diff --git a/system/libraries/Controller.php b/system/libraries/Controller.php
index ec21f8d66..06e54b2d1 100644
--- a/system/libraries/Controller.php
+++ b/system/libraries/Controller.php
@@ -127,7 +127,12 @@ class Controller extends CI_Base {
{
$name = $model;
}
-
+
+ if (in_array($name, $this->_ci_models))
+ {
+ return;
+ }
+
if (isset($this->$name))
{
show_error('The model name you are loading is the name of a resource that is already being used: '.$name);
--
cgit v1.2.3-24-g4f1b
From 0d29605b1e774efd57ffd8f5ccc8eaec1e9ca576 Mon Sep 17 00:00:00 2001
From: admin
Date: Sun, 27 Aug 2006 15:48:38 +0000
Subject:
---
system/libraries/Controller.php | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
(limited to 'system/libraries')
diff --git a/system/libraries/Controller.php b/system/libraries/Controller.php
index 06e54b2d1..768b154e8 100644
--- a/system/libraries/Controller.php
+++ b/system/libraries/Controller.php
@@ -128,7 +128,8 @@ class Controller extends CI_Base {
$name = $model;
}
- if (in_array($name, $this->_ci_models))
+ $obj =& get_instance();
+ if (in_array($name, $obj->_ci_models))
{
return;
}
--
cgit v1.2.3-24-g4f1b
From 1082bddc0c065895a3b39607cb930f5a101f54fb Mon Sep 17 00:00:00 2001
From: admin
Date: Sun, 27 Aug 2006 19:32:02 +0000
Subject:
---
system/libraries/Config.php | 5 +++--
system/libraries/Router.php | 14 ++++++++------
2 files changed, 11 insertions(+), 8 deletions(-)
(limited to 'system/libraries')
diff --git a/system/libraries/Config.php b/system/libraries/Config.php
index 85b295796..bd138331f 100644
--- a/system/libraries/Config.php
+++ b/system/libraries/Config.php
@@ -53,7 +53,7 @@ class CI_Config {
*
* @access public
* @param string the config file name
- * @return void
+ * @return boolean if the file was loaded correctly
*/
function load($file = '')
{
@@ -61,7 +61,7 @@ class CI_Config {
if (in_array($file, $this->is_loaded))
{
- return;
+ return TRUE;
}
include_once(APPPATH.'config/'.$file.EXT);
@@ -77,6 +77,7 @@ class CI_Config {
unset($config);
log_message('debug', 'Config file loaded: config/'.$file.EXT);
+ return TRUE;
}
// END load()
diff --git a/system/libraries/Router.php b/system/libraries/Router.php
index b28ead953..2219f5739 100644
--- a/system/libraries/Router.php
+++ b/system/libraries/Router.php
@@ -254,12 +254,14 @@ class CI_Router {
*/
function _filter_uri($str)
{
- if ( ! preg_match("/^[a-z0-9~\s\%\.:_-]+$/i", $str))
- {
- exit('The URI you submitted has disallowed characters: '.$str);
- }
-
- return $str;
+ if ($this->config->item('permitted_uri_chars') != '')
+ {
+ if ( ! preg_match("|^[".preg_quote($this->config->item('permitted_uri_chars'))."]+$|i", $str))
+ {
+ exit('The URI you submitted has disallowed characters: '.$str);
+ }
+ }
+ return $str;
}
// END _filter_uri()
--
cgit v1.2.3-24-g4f1b
From 671dc754ef954eecf4c2e8301dde5b3aba6bfedc Mon Sep 17 00:00:00 2001
From: admin
Date: Sat, 2 Sep 2006 02:36:03 +0000
Subject:
---
system/libraries/Config.php | 99 +++++++++++++++++++++++++++++++++++++++------
1 file changed, 86 insertions(+), 13 deletions(-)
(limited to 'system/libraries')
diff --git a/system/libraries/Config.php b/system/libraries/Config.php
index bd138331f..f7f813f86 100644
--- a/system/libraries/Config.php
+++ b/system/libraries/Config.php
@@ -36,8 +36,12 @@ class CI_Config {
*
* Sets the $config data from the primary config.php file as a class variable
*
- * @access public
- */
+ * @access public
+ * @param string the config file name
+ * @param boolean if configuration values should be loaded into their own section
+ * @param boolean true if errors should just return false, false if an error message should be displayed
+ * @return boolean if the file was successfully loaded or not
+ */
function CI_Config()
{
$this->config =& _get_config();
@@ -55,7 +59,7 @@ class CI_Config {
* @param string the config file name
* @return boolean if the file was loaded correctly
*/
- function load($file = '')
+ function load($file = '', $use_sections = FALSE, $fail_gracefully = FALSE)
{
$file = ($file == '') ? 'config' : str_replace(EXT, '', $file);
@@ -63,15 +67,42 @@ class CI_Config {
{
return TRUE;
}
+
+ if ( ! file_exists(APPPATH.'config/'.$file.EXT))
+ {
+ if ($fail_gracefully === TRUE)
+ {
+ return FALSE;
+ }
+ show_error('The configuration file '.$file.EXT.' does not exist.');
+ }
include_once(APPPATH.'config/'.$file.EXT);
if ( ! isset($config) OR ! is_array($config))
{
+ if ($fail_gracefully === TRUE)
+ {
+ return FALSE;
+ }
show_error('Your '.$file.EXT.' file does not appear to contain a valid configuration array.');
}
- $this->config = array_merge($this->config, $config);
+ if ($use_sections === TRUE)
+ {
+ if (isset($this->config[$file]))
+ {
+ $this->config[$file] = array_merge($this->config[$file], $config);
+ }
+ else
+ {
+ $this->config[$file] = $config;
+ }
+ }
+ else
+ {
+ $this->config = array_merge($this->config, $config);
+ }
$this->is_loaded[] = $file;
unset($config);
@@ -86,6 +117,48 @@ class CI_Config {
/**
* Fetch a config file item
*
+ *
+ * @access public
+ * @param string the config item name
+ * @param string the index name
+ * @param bool
+ * @return string
+ */
+ function item($item, $index = '')
+ {
+ if ($index == '')
+ {
+ if ( ! isset($this->config[$item]))
+ {
+ return FALSE;
+ }
+
+ $pref = $this->config[$item];
+ }
+ else
+ {
+ if ( ! isset($this->config[$index]))
+ {
+ return FALSE;
+ }
+
+ if ( ! isset($this->config[$index][$item]))
+ {
+ return FALSE;
+ }
+
+ $pref = $this->config[$index][$item];
+ }
+
+ return $pref;
+ }
+ // END item()
+
+ // --------------------------------------------------------------------
+
+ /**
+ * 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.
*
@@ -94,7 +167,7 @@ class CI_Config {
* @param bool
* @return string
*/
- function item($item, $slash = FALSE)
+ function slash_item($item)
{
if ( ! isset($this->config[$item]))
{
@@ -103,20 +176,20 @@ class CI_Config {
$pref = $this->config[$item];
- if ($pref == '')
- {
- return $pref;
+ if ($pref != '')
+ {
+ if (ereg("/$", $pref) === FALSE)
+ {
+ $pref .= '/';
+ }
}
-
- if ($slash !== FALSE AND ereg("/$", $pref) === FALSE)
- {
- $pref .= '/';
- }
return $pref;
}
// END item()
+
+
// --------------------------------------------------------------------
/**
--
cgit v1.2.3-24-g4f1b
From eb6db84333c40ed8d15dec5014564120ee0c60e6 Mon Sep 17 00:00:00 2001
From: admin
Date: Sat, 2 Sep 2006 02:39:45 +0000
Subject:
---
system/libraries/Validation.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
(limited to 'system/libraries')
diff --git a/system/libraries/Validation.php b/system/libraries/Validation.php
index e037e69c5..30faa85ed 100644
--- a/system/libraries/Validation.php
+++ b/system/libraries/Validation.php
@@ -208,7 +208,7 @@ class CI_Validation {
{
if (in_array('isset', $ex) OR in_array('required', $ex))
{
- if ( ! isset($this->messages['isset']))
+ if ( ! isset($this->_error_messages['isset']))
{
if (FALSE === ($line = $this->obj->lang->line('isset')))
{
--
cgit v1.2.3-24-g4f1b
From 2ed76d5ac89ec7869dcb64c050360fb2f99e9326 Mon Sep 17 00:00:00 2001
From: admin
Date: Sat, 2 Sep 2006 17:34:52 +0000
Subject:
---
system/libraries/Output.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
(limited to 'system/libraries')
diff --git a/system/libraries/Output.php b/system/libraries/Output.php
index f5db3e0d0..73f03863e 100644
--- a/system/libraries/Output.php
+++ b/system/libraries/Output.php
@@ -147,7 +147,7 @@ class CI_Output {
return;
}
- $uri = $obj->config->item('base_url', 1).
+ $uri = $obj->config->slash_item('base_url').
$obj->config->item('index_page').
$obj->uri->uri_string();
--
cgit v1.2.3-24-g4f1b
From 337b270b6e566e81d3ee3b5575a3f274c000b459 Mon Sep 17 00:00:00 2001
From: admin
Date: Sat, 2 Sep 2006 17:43:16 +0000
Subject:
---
system/libraries/Loader.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
(limited to 'system/libraries')
diff --git a/system/libraries/Loader.php b/system/libraries/Loader.php
index 3d2501fc0..f005adcf0 100644
--- a/system/libraries/Loader.php
+++ b/system/libraries/Loader.php
@@ -478,7 +478,7 @@ class CI_Loader {
if ($path == '')
{
$ext = pathinfo($view, PATHINFO_EXTENSION);
- $file = ($ext != EXT) ? $view.EXT : $view;
+ $file = ($ext != '') ? $view.EXT : $view;
$path = $this->view_path.$file;
}
else
--
cgit v1.2.3-24-g4f1b
From 6ac4bea2da9e64fb0b434f52177353f6bd65b8e6 Mon Sep 17 00:00:00 2001
From: admin
Date: Sat, 2 Sep 2006 17:46:15 +0000
Subject:
---
system/libraries/Loader.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
(limited to 'system/libraries')
diff --git a/system/libraries/Loader.php b/system/libraries/Loader.php
index f005adcf0..e2467fa64 100644
--- a/system/libraries/Loader.php
+++ b/system/libraries/Loader.php
@@ -478,7 +478,7 @@ class CI_Loader {
if ($path == '')
{
$ext = pathinfo($view, PATHINFO_EXTENSION);
- $file = ($ext != '') ? $view.EXT : $view;
+ $file = ($ext == '') ? $view.EXT : $view;
$path = $this->view_path.$file;
}
else
--
cgit v1.2.3-24-g4f1b
From 1cf89aab5fff8c8068cbf0ed18038b6e4fd4f605 Mon Sep 17 00:00:00 2001
From: admin
Date: Sun, 3 Sep 2006 18:24:39 +0000
Subject:
---
system/libraries/Email.php | 4 ++--
system/libraries/Image_lib.php | 2 +-
system/libraries/Log.php | 6 +++---
system/libraries/Output.php | 2 +-
system/libraries/Pagination.php | 2 +-
system/libraries/Router.php | 14 +++++++++++---
system/libraries/Session.php | 2 +-
system/libraries/Trackback.php | 4 ++--
system/libraries/URI.php | 4 ++--
system/libraries/Validation.php | 8 ++++----
10 files changed, 28 insertions(+), 20 deletions(-)
(limited to 'system/libraries')
diff --git a/system/libraries/Email.php b/system/libraries/Email.php
index 96dc0014d..abc77a54d 100644
--- a/system/libraries/Email.php
+++ b/system/libraries/Email.php
@@ -275,7 +275,7 @@ class CI_Email {
*/
function bcc($bcc, $limit = '')
{
- if ($limit != '' && ctype_digit($limit))
+ if ($limit != '' && is_numeric($limit))
{
$this->bcc_batch_mode = true;
$this->bcc_batch_size = $limit;
@@ -475,7 +475,7 @@ class CI_Email {
*/
function set_priority($n = 3)
{
- if ( ! ctype_digit($n))
+ if ( ! is_numeric($n))
{
$this->priority = 3;
return;
diff --git a/system/libraries/Image_lib.php b/system/libraries/Image_lib.php
index 854f0484b..18e3253f7 100644
--- a/system/libraries/Image_lib.php
+++ b/system/libraries/Image_lib.php
@@ -291,7 +291,7 @@ class CI_Image_lib {
// Set the quality
$this->quality = trim(str_replace("%", "", $this->quality));
- if ($this->quality == '' OR $this->quality == 0 OR ! ctype_digit($this->quality))
+ if ($this->quality == '' OR $this->quality == 0 OR ! is_numeric($this->quality))
$this->quality = 90;
// Set the x/y coordinates
diff --git a/system/libraries/Log.php b/system/libraries/Log.php
index de5a9b836..6c78316f1 100644
--- a/system/libraries/Log.php
+++ b/system/libraries/Log.php
@@ -43,13 +43,13 @@ class CI_Log {
function CI_Log($path = '', $threshold = 4, $date_fmt = '')
{
$this->log_path = ($path != '') ? $path : BASEPATH.'logs/';
-
+
if ( ! is_dir($this->log_path) OR ! is_writable($this->log_path))
{
$this->_enabled = FALSE;
}
- if (ctype_digit($threshold))
+ if (is_numeric($threshold))
{
$this->_threshold = $threshold;
}
@@ -77,7 +77,7 @@ class CI_Log {
function write_log($level = 'error', $msg, $php_error = FALSE)
{
if ($this->_enabled === FALSE)
- {
+ {
return FALSE;
}
diff --git a/system/libraries/Output.php b/system/libraries/Output.php
index 73f03863e..7a03cf9c7 100644
--- a/system/libraries/Output.php
+++ b/system/libraries/Output.php
@@ -78,7 +78,7 @@ class CI_Output {
*/
function cache($time)
{
- $this->cache_expiration = ( ! ctype_digit($time)) ? 0 : $time;
+ $this->cache_expiration = ( ! is_numeric($time)) ? 0 : $time;
}
// --------------------------------------------------------------------
diff --git a/system/libraries/Pagination.php b/system/libraries/Pagination.php
index 0bbb577a3..9d558f00a 100644
--- a/system/libraries/Pagination.php
+++ b/system/libraries/Pagination.php
@@ -128,7 +128,7 @@ class CI_Pagination {
$this->cur_page = $obj->uri->segment($this->uri_segment);
}
- if ( ! ctype_digit($this->cur_page))
+ if ( ! is_numeric($this->cur_page))
{
$this->cur_page = 0;
}
diff --git a/system/libraries/Router.php b/system/libraries/Router.php
index 2219f5739..1c67113f6 100644
--- a/system/libraries/Router.php
+++ b/system/libraries/Router.php
@@ -219,15 +219,23 @@ class CI_Router {
{
return $segments;
}
-
+
// Is the controller in a sub-folder?
if (is_dir(APPPATH.'controllers/'.$segments['0']))
- {
+ {
// Set the directory and remove it from the segment array
$this->set_directory($segments['0']);
$segments = array_slice($segments, 1);
- if (count($segments) == 0)
+ if (count($segments) > 0)
+ {
+ // Does the requested controller exist in the sub-folder?
+ if ( ! file_exists(APPPATH.'controllers/'.$this->fetch_directory().$segments['0'].EXT))
+ {
+ show_404();
+ }
+ }
+ else
{
$this->set_class($this->default_controller);
$this->set_method('index');
diff --git a/system/libraries/Session.php b/system/libraries/Session.php
index 4f08cf692..94efee55c 100644
--- a/system/libraries/Session.php
+++ b/system/libraries/Session.php
@@ -99,7 +99,7 @@ class CI_Session {
*/
$expiration = $this->object->config->item('sess_expiration');
- if (ctype_digit($expiration))
+ if (is_numeric($expiration))
{
if ($expiration > 0)
{
diff --git a/system/libraries/Trackback.php b/system/libraries/Trackback.php
index 583c6d28d..8f9680d44 100644
--- a/system/libraries/Trackback.php
+++ b/system/libraries/Trackback.php
@@ -368,7 +368,7 @@ class CI_Trackback {
$tb_array = explode('/', $url);
$tb_end = $tb_array[count($tb_array)-1];
- if ( ! ctype_digit($tb_end))
+ if ( ! is_numeric($tb_end))
{
$tb_end = $tb_array[count($tb_array)-2];
}
@@ -386,7 +386,7 @@ class CI_Trackback {
$tb_array = explode('/', $url);
$tb_id = $tb_array[count($tb_array)-1];
- if ( ! ctype_digit($tb_id))
+ if ( ! is_numeric($tb_id))
{
$tb_id = $tb_array[count($tb_array)-2];
}
diff --git a/system/libraries/URI.php b/system/libraries/URI.php
index c5fd4625b..ba6279e88 100644
--- a/system/libraries/URI.php
+++ b/system/libraries/URI.php
@@ -88,7 +88,7 @@ class CI_URI {
*/
function uri_to_assoc($n = 3, $default = array())
{
- if ( ! ctype_digit($n))
+ if ( ! is_numeric($n))
{
return $default;
}
@@ -110,7 +110,7 @@ class CI_URI {
{
$retval[$val] = FALSE;
}
- return $default;
+ return $retval;
}
$segments = array_slice($this->segment_array(), ($n - 1));
diff --git a/system/libraries/Validation.php b/system/libraries/Validation.php
index 30faa85ed..44f49ff62 100644
--- a/system/libraries/Validation.php
+++ b/system/libraries/Validation.php
@@ -404,7 +404,7 @@ class CI_Validation {
*/
function min_length($str, $val)
{
- if ( ! ctype_digit($val))
+ if ( ! is_numeric($val))
{
return FALSE;
}
@@ -423,7 +423,7 @@ class CI_Validation {
*/
function max_length($str, $val)
{
- if ( ! ctype_digit($val))
+ if ( ! is_numeric($val))
{
return FALSE;
}
@@ -442,7 +442,7 @@ class CI_Validation {
*/
function exact_length($str, $val)
{
- if ( ! ctype_digit($val))
+ if ( ! is_numeric($val))
{
return FALSE;
}
@@ -517,7 +517,7 @@ class CI_Validation {
*/
function numeric($str)
{
- return ( ! ctype_digit($str)) ? FALSE : TRUE;
+ return ( ! is_numeric($str)) ? FALSE : TRUE;
}
// --------------------------------------------------------------------
--
cgit v1.2.3-24-g4f1b
From 6cd2ee9a7aa926b607922d933abc3f21b9e3868e Mon Sep 17 00:00:00 2001
From: admin
Date: Mon, 4 Sep 2006 07:11:16 +0000
Subject:
---
system/libraries/Config.php | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
(limited to 'system/libraries')
diff --git a/system/libraries/Config.php b/system/libraries/Config.php
index f7f813f86..532f70d42 100644
--- a/system/libraries/Config.php
+++ b/system/libraries/Config.php
@@ -208,12 +208,12 @@ class CI_Config {
if ($uri == '')
{
- return $this->item('base_url', 1).$this->item('index_page');
+ return $this->slash_item('base_url').$this->item('index_page');
}
else
{
$suffix = ($this->item('url_suffix') == FALSE) ? '' : $this->item('url_suffix');
- return $this->item('base_url', 1).$this->item('index_page', 1).preg_replace("|^/*(.+?)/*$|", "\\1", $uri).$suffix;
+ return $this->slash_item('base_url').$this->slash_item('index_page').preg_replace("|^/*(.+?)/*$|", "\\1", $uri).$suffix;
}
}
// END site_url()
--
cgit v1.2.3-24-g4f1b
From 813711e6ddfa347fd0d74c109c14fe10a919f668 Mon Sep 17 00:00:00 2001
From: admin
Date: Mon, 4 Sep 2006 07:13:57 +0000
Subject:
---
system/libraries/Config.php | 2 +-
system/libraries/Router.php | 4 ++--
2 files changed, 3 insertions(+), 3 deletions(-)
(limited to 'system/libraries')
diff --git a/system/libraries/Config.php b/system/libraries/Config.php
index 532f70d42..108c94ab7 100644
--- a/system/libraries/Config.php
+++ b/system/libraries/Config.php
@@ -229,7 +229,7 @@ class CI_Config {
function system_url()
{
$x = explode("/", preg_replace("|/*(.+?)/*$|", "\\1", BASEPATH));
- return $this->item('base_url', 1).end($x).'/';
+ return $this->slash_item('base_url').end($x).'/';
}
// END system_url()
diff --git a/system/libraries/Router.php b/system/libraries/Router.php
index 1c67113f6..c7e855a78 100644
--- a/system/libraries/Router.php
+++ b/system/libraries/Router.php
@@ -312,12 +312,12 @@ class CI_Router {
$key = str_replace(':any', '.+', str_replace(':num', '[0-9]+', $key));
// Does the RegEx match?
- if (preg_match('|^'.$key.'$|', $uri))
+ if (preg_match('#^'.preg_quote($key).'$#', $uri))
{
// Do we have a back-reference?
if (strpos($val, '$') !== FALSE AND strpos($key, '(') !== FALSE)
{
- $val = preg_replace('|^'.$key.'$|', $val, $uri);
+ $val = preg_replace('#^'.preg_quote($key).'$#', $val, $uri);
}
$this->_compile_segments(explode('/', $val));
--
cgit v1.2.3-24-g4f1b
From 27818494dca469e96709fd9c54ba8f8461d88714 Mon Sep 17 00:00:00 2001
From: admin
Date: Tue, 5 Sep 2006 03:31:28 +0000
Subject:
---
system/libraries/Router.php | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
(limited to 'system/libraries')
diff --git a/system/libraries/Router.php b/system/libraries/Router.php
index c7e855a78..de1a6e9a8 100644
--- a/system/libraries/Router.php
+++ b/system/libraries/Router.php
@@ -239,8 +239,14 @@ class CI_Router {
{
$this->set_class($this->default_controller);
$this->set_method('index');
- $this->directory = '';
- return array();
+
+ // Does the default controller exist in the sub-folder?
+ if ( ! file_exists(APPPATH.'controllers/'.$this->fetch_directory().$this->default_controller.EXT))
+ {
+ $this->directory = '';
+ return array();
+ }
+
}
return $segments;
--
cgit v1.2.3-24-g4f1b
From 2e5872ac0527c342e066bdc2e8facf452858dd39 Mon Sep 17 00:00:00 2001
From: admin
Date: Wed, 6 Sep 2006 02:32:55 +0000
Subject:
---
system/libraries/Loader.php | 25 +++----------------------
1 file changed, 3 insertions(+), 22 deletions(-)
(limited to 'system/libraries')
diff --git a/system/libraries/Loader.php b/system/libraries/Loader.php
index e2467fa64..a140fb5a2 100644
--- a/system/libraries/Loader.php
+++ b/system/libraries/Loader.php
@@ -565,15 +565,7 @@ class CI_Loader {
{
if (isset($autoload[$type]))
{
- if ( ! is_array($autoload[$type]))
- {
- $autoload[$type] = array($autoload[$type]);
- }
-
- foreach ($autoload[$type] as $item)
- {
- $this->$type($item);
- }
+ $this->$type($autoload[$type]);
}
}
}
@@ -592,20 +584,9 @@ class CI_Loader {
*/
function _ci_object_to_array($object)
{
- if ( ! is_object($object))
- {
- return $object;
- }
-
- $array = array();
- foreach (get_object_vars($object) as $key => $val)
- {
- $array[$key] = $val;
- }
-
- return $array;
+ return (is_object($object)) ? get_object_vars($object) : $object;
}
+ // END _ci_object_to_array()
}
-// END Loader Class
?>
\ No newline at end of file
--
cgit v1.2.3-24-g4f1b
From 764672b45108814fc643be65b53b18f0b6507112 Mon Sep 17 00:00:00 2001
From: admin
Date: Fri, 15 Sep 2006 20:02:05 +0000
Subject:
---
system/libraries/Hooks.php | 37 ++++++++-----------------------------
1 file changed, 8 insertions(+), 29 deletions(-)
(limited to 'system/libraries')
diff --git a/system/libraries/Hooks.php b/system/libraries/Hooks.php
index 389e7ac14..7ff0592ff 100644
--- a/system/libraries/Hooks.php
+++ b/system/libraries/Hooks.php
@@ -66,34 +66,6 @@ class CI_Hooks {
}
// END CI_Hooks()
- // --------------------------------------------------------------------
-
- /**
- * Does a given hook exist?
- *
- * Returns TRUE/FALSE based on whether a given hook exists
- *
- * @access private
- * @param string
- * @return bool
- */
- function _hook_exists($which = '')
- {
- if ( ! $this->enabled)
- {
- return FALSE;
- }
-
- if ( ! isset($this->hooks[$which]))
- {
- return FALSE;
- }
-
- return TRUE;
- }
- // END hook_exists()
-
-
// --------------------------------------------------------------------
/**
@@ -107,6 +79,11 @@ class CI_Hooks {
*/
function _call_hook($which = '')
{
+ if ( ! $this->enabled OR ! isset($this->hooks[$which]))
+ {
+ return FALSE;
+ }
+
if (isset($this->hooks[$which][0]) AND is_array($this->hooks[$which][0]))
{
foreach ($this->hooks[$which] as $val)
@@ -118,6 +95,8 @@ class CI_Hooks {
{
$this->_run_hook($this->hooks[$which]);
}
+
+ return TRUE;
}
// END hook_exists()
@@ -144,7 +123,7 @@ class CI_Hooks {
// -----------------------------------
// If the script being called happens to have the same
- // extension call within it a loop can happen
+ // hook call within it a loop can happen
if ($this->in_progress == TRUE)
{
--
cgit v1.2.3-24-g4f1b
From 71430b4c30f01c861abe379becc670748e3b4a19 Mon Sep 17 00:00:00 2001
From: admin
Date: Fri, 15 Sep 2006 20:29:25 +0000
Subject:
---
system/libraries/Router.php | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
(limited to 'system/libraries')
diff --git a/system/libraries/Router.php b/system/libraries/Router.php
index de1a6e9a8..1dd1e5426 100644
--- a/system/libraries/Router.php
+++ b/system/libraries/Router.php
@@ -318,12 +318,12 @@ class CI_Router {
$key = str_replace(':any', '.+', str_replace(':num', '[0-9]+', $key));
// Does the RegEx match?
- if (preg_match('#^'.preg_quote($key).'$#', $uri))
+ if (preg_match('#^'.$key.'$#', $uri))
{
// Do we have a back-reference?
if (strpos($val, '$') !== FALSE AND strpos($key, '(') !== FALSE)
{
- $val = preg_replace('#^'.preg_quote($key).'$#', $val, $uri);
+ $val = preg_replace('#^'.$key.'$#', $val, $uri);
}
$this->_compile_segments(explode('/', $val));
--
cgit v1.2.3-24-g4f1b
From 633ec3758910482863299c7122dda3c15d9758a8 Mon Sep 17 00:00:00 2001
From: admin
Date: Fri, 15 Sep 2006 20:43:32 +0000
Subject:
---
system/libraries/Log.php | 16 +++++++++-------
1 file changed, 9 insertions(+), 7 deletions(-)
(limited to 'system/libraries')
diff --git a/system/libraries/Log.php b/system/libraries/Log.php
index 6c78316f1..392742584 100644
--- a/system/libraries/Log.php
+++ b/system/libraries/Log.php
@@ -40,23 +40,25 @@ class CI_Log {
* @param string the error threshold
* @param string the date formatting codes
*/
- function CI_Log($path = '', $threshold = 4, $date_fmt = '')
- {
- $this->log_path = ($path != '') ? $path : BASEPATH.'logs/';
+ function CI_Log()
+ {
+ $config =& _get_config();
+
+ $this->log_path = ($config['log_path'] != '') ? $config['log_path'] : BASEPATH.'logs/';
if ( ! is_dir($this->log_path) OR ! is_writable($this->log_path))
{
$this->_enabled = FALSE;
}
- if (is_numeric($threshold))
+ if (is_numeric($config['log_threshold']))
{
- $this->_threshold = $threshold;
+ $this->_threshold = $config['log_threshold'];
}
- if ($date_fmt != '')
+ if ($config['log_date_format'] != '')
{
- $this->_date_fmt = $date_fmt;
+ $this->_date_fmt = $config['log_date_format'];
}
}
// END CI_Log()
--
cgit v1.2.3-24-g4f1b
From 1856f58a16da54f12414350f2e2a833d0cdd7d45 Mon Sep 17 00:00:00 2001
From: admin
Date: Fri, 15 Sep 2006 20:48:15 +0000
Subject:
---
system/libraries/Output.php | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
(limited to 'system/libraries')
diff --git a/system/libraries/Output.php b/system/libraries/Output.php
index 7a03cf9c7..9523599e7 100644
--- a/system/libraries/Output.php
+++ b/system/libraries/Output.php
@@ -147,7 +147,7 @@ class CI_Output {
return;
}
- $uri = $obj->config->slash_item('base_url').
+ $uri = $obj->config->item('base_url').
$obj->config->item('index_page').
$obj->uri->uri_string();
@@ -191,8 +191,10 @@ class CI_Output {
}
// Build the file path. The file name is an MD5 hash of the full URI
- $uri = $CFG->item('base_url', 1).$CFG->item('index_page').$RTR->uri_string;
-
+ $uri = $obj->config->item('base_url').
+ $obj->config->item('index_page').
+ $obj->uri->uri_string();
+
$filepath = $cache_path.md5($uri);
if ( ! @file_exists($filepath))
--
cgit v1.2.3-24-g4f1b
From dac65764e5ead0bcc9e7fcb2477926d7a2c1dc95 Mon Sep 17 00:00:00 2001
From: admin
Date: Sun, 17 Sep 2006 18:05:43 +0000
Subject:
---
system/libraries/Validation.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
(limited to 'system/libraries')
diff --git a/system/libraries/Validation.php b/system/libraries/Validation.php
index 44f49ff62..e4fd36698 100644
--- a/system/libraries/Validation.php
+++ b/system/libraries/Validation.php
@@ -187,7 +187,7 @@ class CI_Validation {
$ex = explode('|', $rules);
// Is the field required? If not, if the field is blank we'll move on to the next text
- if ( ! in_array('required', $ex))
+ if ( ! in_array('required', $ex) AND strpos($rules, 'callback_') === FALSE)
{
if ( ! isset($_POST[$field]) OR $_POST[$field] == '')
{
--
cgit v1.2.3-24-g4f1b
From f6d823ee041caab303a7aba6ecd8c358c6970113 Mon Sep 17 00:00:00 2001
From: admin
Date: Sun, 17 Sep 2006 18:10:57 +0000
Subject:
---
system/libraries/Unit_test.php | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
(limited to 'system/libraries')
diff --git a/system/libraries/Unit_test.php b/system/libraries/Unit_test.php
index bf50350ae..b2f4bf8cd 100644
--- a/system/libraries/Unit_test.php
+++ b/system/libraries/Unit_test.php
@@ -223,9 +223,9 @@ class CI_Unit_test {
* @params string
* @return void
*/
- function set_template($tempalte)
+ function set_template($template)
{
- $this->_template = $tempalte;
+ $this->_template = $template;
}
// --------------------------------------------------------------------
--
cgit v1.2.3-24-g4f1b
From c55b02bcee63c0ea4563583e54959b9f068ea9e9 Mon Sep 17 00:00:00 2001
From: admin
Date: Mon, 18 Sep 2006 07:44:58 +0000
Subject:
---
system/libraries/Output.php | 1 +
1 file changed, 1 insertion(+)
(limited to 'system/libraries')
diff --git a/system/libraries/Output.php b/system/libraries/Output.php
index 9523599e7..c5a9a6281 100644
--- a/system/libraries/Output.php
+++ b/system/libraries/Output.php
@@ -191,6 +191,7 @@ class CI_Output {
}
// Build the file path. The file name is an MD5 hash of the full URI
+ $obj =& get_instance();
$uri = $obj->config->item('base_url').
$obj->config->item('index_page').
$obj->uri->uri_string();
--
cgit v1.2.3-24-g4f1b
From 15c2bcc24c4b4f4999c5dc73eab57b9b3a6f942e Mon Sep 17 00:00:00 2001
From: admin
Date: Mon, 18 Sep 2006 08:17:56 +0000
Subject:
---
system/libraries/Output.php | 9 ++++-----
1 file changed, 4 insertions(+), 5 deletions(-)
(limited to 'system/libraries')
diff --git a/system/libraries/Output.php b/system/libraries/Output.php
index c5a9a6281..fd07a9f6e 100644
--- a/system/libraries/Output.php
+++ b/system/libraries/Output.php
@@ -178,7 +178,7 @@ class CI_Output {
* @access public
* @return void
*/
- function _display_cache()
+ function _display_cache(&$CFG, &$RTR)
{
$CFG =& _load_class('CI_Config');
$RTR =& _load_class('CI_Router');
@@ -191,10 +191,9 @@ class CI_Output {
}
// Build the file path. The file name is an MD5 hash of the full URI
- $obj =& get_instance();
- $uri = $obj->config->item('base_url').
- $obj->config->item('index_page').
- $obj->uri->uri_string();
+ $uri = $CFG->item('base_url').
+ $CFG->item('index_page').
+ $RTR->uri_string;
$filepath = $cache_path.md5($uri);
--
cgit v1.2.3-24-g4f1b
From 89a8b9700cd8b27da1f27a18ab5f9d4c5ca2cef4 Mon Sep 17 00:00:00 2001
From: admin
Date: Mon, 18 Sep 2006 15:46:28 +0000
Subject:
---
system/libraries/Validation.php | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
(limited to 'system/libraries')
diff --git a/system/libraries/Validation.php b/system/libraries/Validation.php
index e4fd36698..227cf9f9a 100644
--- a/system/libraries/Validation.php
+++ b/system/libraries/Validation.php
@@ -240,7 +240,6 @@ class CI_Validation {
// Cycle through the rules!
foreach ($ex As $rule)
{
-
// Is the rule a callback?
$callback = FALSE;
if (substr($rule, 0, 9) == 'callback_')
@@ -267,6 +266,12 @@ class CI_Validation {
}
$result = $this->obj->$rule($_POST[$field], $param);
+
+ // If the field isn't requires we'll move on...
+ if ( ! in_array('required', $ex))
+ {
+ continue;
+ }
}
else
{
--
cgit v1.2.3-24-g4f1b
From d183cb5255817dc431196964becef0db037f0620 Mon Sep 17 00:00:00 2001
From: admin
Date: Wed, 20 Sep 2006 21:06:32 +0000
Subject:
---
system/libraries/Language.php | 18 +++++++++++++++---
1 file changed, 15 insertions(+), 3 deletions(-)
(limited to 'system/libraries')
diff --git a/system/libraries/Language.php b/system/libraries/Language.php
index 328d53e46..41dab46f4 100644
--- a/system/libraries/Language.php
+++ b/system/libraries/Language.php
@@ -66,12 +66,24 @@ class CI_Language {
$idiom = ($deft_lang == '') ? 'english' : $deft_lang;
}
- if ( ! file_exists(BASEPATH.'language/'.$idiom.'/'.$langfile))
+ // Determine where the language file is and load it
+
+ if (file_exists(APPPATH.'language/'.$idiom.'/'.$langfile))
{
- show_error('Unable to load the requested language file: language/'.$langfile);
+ include_once(APPPATH.'language/'.$idiom.'/'.$langfile);
+ }
+ else
+ {
+ if (file_exists(BASEPATH.'language/'.$idiom.'/'.$langfile))
+ {
+ include_once(BASEPATH.'language/'.$idiom.'/'.$langfile);
+ }
+ else
+ {
+ show_error('Unable to load the requested language file: language/'.$langfile);
+ }
}
- include_once(BASEPATH.'language/'.$idiom.'/'.$langfile);
if ( ! isset($lang))
{
--
cgit v1.2.3-24-g4f1b
From 480da81d6111a5c1faf4433707ee8d3b3de8031e Mon Sep 17 00:00:00 2001
From: admin
Date: Wed, 20 Sep 2006 21:11:04 +0000
Subject:
---
system/libraries/Loader.php | 36 +++++++++++++++++++++++++++---------
1 file changed, 27 insertions(+), 9 deletions(-)
(limited to 'system/libraries')
diff --git a/system/libraries/Loader.php b/system/libraries/Loader.php
index a140fb5a2..ead55dff7 100644
--- a/system/libraries/Loader.php
+++ b/system/libraries/Loader.php
@@ -243,12 +243,21 @@ class CI_Loader {
$helper = strtolower(str_replace(EXT, '', str_replace('_helper', '', $helper)).'_helper');
- if ( ! file_exists(BASEPATH.'helpers/'.$helper.EXT))
+ if (file_exists(APPPATH.'helpers/'.$helper.EXT))
{
- show_error('Unable to load the requested file: helpers/'.$helper.EXT);
+ include_once(APPPATH.'helpers/'.$helper.EXT);
+ }
+ else
+ {
+ if (file_exists(BASEPATH.'helpers/'.$helper.EXT))
+ {
+ include_once(BASEPATH.'helpers/'.$helper.EXT);
+ }
+ else
+ {
+ show_error('Unable to load the requested file: helpers/'.$helper.EXT);
+ }
}
-
- include_once(BASEPATH.'helpers/'.$helper.EXT);
$this->helpers[$helper] = TRUE;
}
@@ -300,14 +309,23 @@ class CI_Loader {
continue;
}
- $plugin = strtolower(str_replace(EXT, '', str_replace('_plugin.', '', $plugin)).'_pi');
+ $plugin = strtolower(str_replace(EXT, '', str_replace('_plugin.', '', $plugin)).'_pi');
- if ( ! file_exists(BASEPATH.'plugins/'.$plugin.EXT))
+ if (file_exists(APPPATH.'plugins/'.$plugin.EXT))
{
- show_error('Unable to load the requested file: plugins/'.$plugin.EXT);
+ include_once(APPPATH.'plugins/'.$plugin.EXT);
+ }
+ else
+ {
+ if (file_exists(BASEPATH.'plugins/'.$plugin.EXT))
+ {
+ include_once(BASEPATH.'plugins/'.$plugin.EXT);
+ }
+ else
+ {
+ show_error('Unable to load the requested file: plugins/'.$plugin.EXT);
+ }
}
-
- include_once(BASEPATH.'plugins/'.$plugin.EXT);
$this->plugins[$plugin] = TRUE;
}
--
cgit v1.2.3-24-g4f1b
From e348efb92de213fcfbc312993d8b21a30eb280c0 Mon Sep 17 00:00:00 2001
From: admin
Date: Wed, 20 Sep 2006 21:13:26 +0000
Subject:
---
system/libraries/Validation.php | 18 ++++++++++--------
1 file changed, 10 insertions(+), 8 deletions(-)
(limited to 'system/libraries')
diff --git a/system/libraries/Validation.php b/system/libraries/Validation.php
index 227cf9f9a..065e7a2d5 100644
--- a/system/libraries/Validation.php
+++ b/system/libraries/Validation.php
@@ -246,8 +246,8 @@ class CI_Validation {
{
$rule = substr($rule, 9);
$callback = TRUE;
- }
-
+ }
+
// Strip the parameter (if exists) from the rule
// Rules can contain a parameter: max_length[5]
$param = FALSE;
@@ -265,13 +265,14 @@ class CI_Validation {
continue;
}
- $result = $this->obj->$rule($_POST[$field], $param);
+ $result = $this->obj->$rule($_POST[$field], $param);
- // If the field isn't requires we'll move on...
- if ( ! in_array('required', $ex))
+ // If the field isn't required and we just processed a callback we'll move on...
+ if ( ! in_array('required', $ex) AND $result !== FALSE)
{
- continue;
+ continue 2;
}
+
}
else
{
@@ -295,7 +296,7 @@ class CI_Validation {
$result = $this->$rule($_POST[$field], $param);
}
-
+
// Did the rule test negatively? If so, grab the error.
if ($result === FALSE)
{
@@ -323,8 +324,9 @@ class CI_Validation {
// Add the error to the error array
$this->_error_array[] = $message;
continue 2;
- }
+ }
}
+
}
$total_errors = count($this->_error_array);
--
cgit v1.2.3-24-g4f1b
From 0fce0f2fcf04db02a1633c155f9d6af3a95c5aa6 Mon Sep 17 00:00:00 2001
From: admin
Date: Wed, 20 Sep 2006 21:13:41 +0000
Subject:
---
system/libraries/Inflector.php | 160 +++++++++++++++++++++++++++++++++++++++++
1 file changed, 160 insertions(+)
create mode 100644 system/libraries/Inflector.php
(limited to 'system/libraries')
diff --git a/system/libraries/Inflector.php b/system/libraries/Inflector.php
new file mode 100644
index 000000000..b27228a54
--- /dev/null
+++ b/system/libraries/Inflector.php
@@ -0,0 +1,160 @@
+
\ No newline at end of file
--
cgit v1.2.3-24-g4f1b
From f9e890c755a414496930a3a6ff37ad75815e8a48 Mon Sep 17 00:00:00 2001
From: admin
Date: Wed, 20 Sep 2006 23:59:14 +0000
Subject:
---
system/libraries/Inflector.php | 160 -----------------------------------------
1 file changed, 160 deletions(-)
delete mode 100644 system/libraries/Inflector.php
(limited to 'system/libraries')
diff --git a/system/libraries/Inflector.php b/system/libraries/Inflector.php
deleted file mode 100644
index b27228a54..000000000
--- a/system/libraries/Inflector.php
+++ /dev/null
@@ -1,160 +0,0 @@
-
\ No newline at end of file
--
cgit v1.2.3-24-g4f1b
From d16d6c2055f119a4df9812548ed13449f6c806f9 Mon Sep 17 00:00:00 2001
From: admin
Date: Thu, 21 Sep 2006 00:45:12 +0000
Subject:
---
system/libraries/Email.php | 14 +++++++++++++-
1 file changed, 13 insertions(+), 1 deletion(-)
(limited to 'system/libraries')
diff --git a/system/libraries/Email.php b/system/libraries/Email.php
index abc77a54d..5b991d1fa 100644
--- a/system/libraries/Email.php
+++ b/system/libraries/Email.php
@@ -130,7 +130,7 @@ class CI_Email {
* @access public
* @return void
*/
- function clear()
+ function clear($clear_attachments = FALSE)
{
$this->_subject = "";
$this->_body = "";
@@ -143,6 +143,13 @@ class CI_Email {
$this->_set_header('User-Agent', $this->useragent);
$this->_set_header('Date', $this->_set_date());
+
+ if ($clear_attachments !== FALSE)
+ {
+ $this->_attach_name = array();
+ $this->_attach_type = array();
+ $this->_attach_disp = array();
+ }
}
// END clear()
@@ -735,6 +742,11 @@ class CI_Email {
*/
function _get_alt_message()
{
+ if ($this->alt_message != "")
+ {
+ return $this->word_wrap($this->alt_message, '76');
+ }
+
if (eregi( '\', $this->_body, $match))
{
$body = $match['1'];
--
cgit v1.2.3-24-g4f1b
From 460f2678d1ba46f231466232cf1352353d62d598 Mon Sep 17 00:00:00 2001
From: admin
Date: Thu, 21 Sep 2006 02:41:37 +0000
Subject:
---
system/libraries/Output.php | 34 ++++++++++++++++++++++++++++++++++
1 file changed, 34 insertions(+)
(limited to 'system/libraries')
diff --git a/system/libraries/Output.php b/system/libraries/Output.php
index fd07a9f6e..b09bf2a53 100644
--- a/system/libraries/Output.php
+++ b/system/libraries/Output.php
@@ -30,6 +30,7 @@ class CI_Output {
var $final_output;
var $cache_expiration = 0;
+ var $headers = array();
function CI_Output()
{
@@ -66,6 +67,26 @@ class CI_Output {
{
$this->final_output = $output;
}
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Set Header
+ *
+ * Lets you set a server header which will be outputted with the final display.
+ *
+ * Note: If a file is cached, headers will not be sent. We need to figure out
+ * how to permit header data to be saved with the cache data...
+ *
+ * @access public
+ * @param string
+ * @return void
+ */
+ function set_header($header)
+ {
+ $this->headers[] = $header;
+ }
+
// --------------------------------------------------------------------
@@ -110,17 +131,30 @@ class CI_Output {
$output =& $this->final_output;
}
+ // Do we need to write a cache file?
if ($this->cache_expiration > 0)
{
$this->_write_cache($output);
}
+ // Parse out the elapsed time and memory usage, and
+ // swap the pseudo-variables with the data
$elapsed = $BM->elapsed_time('code_igniter_start', 'code_igniter_end');
$memory = ( ! function_exists('memory_get_usage')) ? '0' : round(memory_get_usage()/1024/1024, 2).'MB';
$output = str_replace('{memory_usage}', $memory, $output);
$output = str_replace('{elapsed_time}', $elapsed, $output);
+ // Are there any server headers to send?
+ if (count($this->headers) > 0)
+ {
+ foreach ($this->headers as $header)
+ {
+ @header($header);
+ }
+ }
+
+ // Send it to the browser!
echo $output;
log_message('debug', "Final output sent to browser");
--
cgit v1.2.3-24-g4f1b
From bc042dd0692a6b4b89f11f88e6e3763162ce8048 Mon Sep 17 00:00:00 2001
From: admin
Date: Thu, 21 Sep 2006 02:46:59 +0000
Subject:
---
system/libraries/Exceptions.php | 2 +-
system/libraries/Input.php | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
(limited to 'system/libraries')
diff --git a/system/libraries/Exceptions.php b/system/libraries/Exceptions.php
index a72dbf841..c3af801ae 100644
--- a/system/libraries/Exceptions.php
+++ b/system/libraries/Exceptions.php
@@ -53,7 +53,7 @@ class CI_Exceptions {
*/
function CI_Exceptions()
{
- log_message('debug', "Output Class Initialized");
+ // Note: Do not log messages from this constructor.
}
// END CI_Exceptions()
diff --git a/system/libraries/Input.php b/system/libraries/Input.php
index 6aba5dd43..dbf939b18 100644
--- a/system/libraries/Input.php
+++ b/system/libraries/Input.php
@@ -430,7 +430,7 @@ class CI_Input {
* But it doesn't seem to pose a problem.
*
*/
- $str = str_replace(array(''), array('<?php', '<?PHP', '<?', '?>'), $str); // '), array('<?php', '<?PHP', '<?', '?>'), $str);
/*
* Compact any exploded words
--
cgit v1.2.3-24-g4f1b
From 9aaa75ed7cd7b2a95cff5b8a52a59c1e6dcf9da6 Mon Sep 17 00:00:00 2001
From: admin
Date: Thu, 21 Sep 2006 04:45:20 +0000
Subject:
---
system/libraries/Output.php | 14 +++++++++++++-
1 file changed, 13 insertions(+), 1 deletion(-)
(limited to 'system/libraries')
diff --git a/system/libraries/Output.php b/system/libraries/Output.php
index b09bf2a53..4a3adb858 100644
--- a/system/libraries/Output.php
+++ b/system/libraries/Output.php
@@ -86,7 +86,6 @@ class CI_Output {
{
$this->headers[] = $header;
}
-
// --------------------------------------------------------------------
@@ -145,6 +144,19 @@ class CI_Output {
$output = str_replace('{memory_usage}', $memory, $output);
$output = str_replace('{elapsed_time}', $elapsed, $output);
+ // Is compression requested?
+ $CFG =& _load_class('CI_Config');
+ if ($CFG->item('compress_output') === TRUE)
+ {
+ if (extension_loaded('zlib'))
+ {
+ if (isset($_SERVER['HTTP_ACCEPT_ENCODING']) AND strpos($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip') !== FALSE)
+ {
+ ob_start('ob_gzhandler');
+ }
+ }
+ }
+
// Are there any server headers to send?
if (count($this->headers) > 0)
{
--
cgit v1.2.3-24-g4f1b
From 885b0343036695ad673fc24ba7682fc155c54036 Mon Sep 17 00:00:00 2001
From: admin
Date: Thu, 21 Sep 2006 05:36:15 +0000
Subject:
---
system/libraries/Validation.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
(limited to 'system/libraries')
diff --git a/system/libraries/Validation.php b/system/libraries/Validation.php
index 065e7a2d5..f9b51d778 100644
--- a/system/libraries/Validation.php
+++ b/system/libraries/Validation.php
@@ -524,7 +524,7 @@ class CI_Validation {
*/
function numeric($str)
{
- return ( ! is_numeric($str)) ? FALSE : TRUE;
+ return ( ! ereg("^[0-9]+$", $str)) ? FALSE : TRUE;
}
// --------------------------------------------------------------------
--
cgit v1.2.3-24-g4f1b
From d48ef1c8e2e84067a58818291935593d70e491f8 Mon Sep 17 00:00:00 2001
From: admin
Date: Thu, 21 Sep 2006 06:22:05 +0000
Subject:
---
system/libraries/Controller.php | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
(limited to 'system/libraries')
diff --git a/system/libraries/Controller.php b/system/libraries/Controller.php
index 768b154e8..5a32e65c0 100644
--- a/system/libraries/Controller.php
+++ b/system/libraries/Controller.php
@@ -232,16 +232,20 @@ class Controller extends CI_Base {
}
unset($autoload['config']);
- if ( ! is_array($autoload['core']))
+ // A little tweak to remain backward compatible
+ // The $autoload['core'] item was deprecated
+ if ( ! isset($autoload['libraries']))
{
- $autoload['core'] = array($autoload['core']);
+ $autoload['libraries'] = $autoload['core'];
+
}
- foreach ($autoload['core'] as $item)
+ foreach ($autoload['libraries'] as $item)
{
$this->_ci_initialize($item);
}
-
+ unset($autoload['libraries']);
+
return $autoload;
}
// END _ci_autoload()
--
cgit v1.2.3-24-g4f1b
From bc4fffbc55d7d04a98a50f1aefa414f965d90644 Mon Sep 17 00:00:00 2001
From: admin
Date: Thu, 21 Sep 2006 15:30:56 +0000
Subject:
---
system/libraries/Upload.php | 20 ++++++++++----------
1 file changed, 10 insertions(+), 10 deletions(-)
(limited to 'system/libraries')
diff --git a/system/libraries/Upload.php b/system/libraries/Upload.php
index 6d12dbcd7..98edd654f 100644
--- a/system/libraries/Upload.php
+++ b/system/libraries/Upload.php
@@ -98,10 +98,10 @@ class CI_Upload {
* @access public
* @return bool
*/
- function do_upload()
+ function do_upload($field = 'userfile')
{
- // Is $_FILES['userfile'] set? If not, no reason to continue.
- if ( ! isset($_FILES['userfile']))
+ // Is $_FILES[$field] set? If not, no reason to continue.
+ if ( ! isset($_FILES[$field]))
{
$this->set_error('upload_userfile_not_set');
return FALSE;
@@ -114,9 +114,9 @@ class CI_Upload {
}
// Was the file able to be uploaded? If not, determine the reason why.
- if ( ! is_uploaded_file($_FILES['userfile']['tmp_name']))
+ if ( ! is_uploaded_file($_FILES[$field]['tmp_name']))
{
- $error = ( ! isset($_FILES['userfile']['error'])) ? 4 : $_FILES['userfile']['error'];
+ $error = ( ! isset($_FILES[$field]['error'])) ? 4 : $_FILES[$field]['error'];
switch($error)
{
@@ -134,12 +134,12 @@ class CI_Upload {
}
// Set the uploaded data as class variables
- $this->file_temp = $_FILES['userfile']['tmp_name'];
- $this->file_name = $_FILES['userfile']['name'];
- $this->file_size = $_FILES['userfile']['size'];
- $this->file_type = preg_replace("/^(.+?);.*$/", "\\1", $_FILES['userfile']['type']);
+ $this->file_temp = $_FILES[$field]['tmp_name'];
+ $this->file_name = $_FILES[$field]['name'];
+ $this->file_size = $_FILES[$field]['size'];
+ $this->file_type = preg_replace("/^(.+?);.*$/", "\\1", $_FILES[$field]['type']);
$this->file_type = strtolower($this->file_type);
- $this->file_ext = $this->get_extension($_FILES['userfile']['name']);
+ $this->file_ext = $this->get_extension($_FILES[$field]['name']);
// Convert the file size to kilobytes
if ($this->file_size > 0)
--
cgit v1.2.3-24-g4f1b
From daf454dabe983f621570bcef10d6d8babedfb8a8 Mon Sep 17 00:00:00 2001
From: admin
Date: Thu, 21 Sep 2006 17:01:27 +0000
Subject:
---
system/libraries/URI.php | 93 ++++++++++++++++++++++++++++++++++++++++++++++--
1 file changed, 91 insertions(+), 2 deletions(-)
(limited to 'system/libraries')
diff --git a/system/libraries/URI.php b/system/libraries/URI.php
index ba6279e88..11562eb29 100644
--- a/system/libraries/URI.php
+++ b/system/libraries/URI.php
@@ -65,6 +65,25 @@ class CI_URI {
// --------------------------------------------------------------------
+ /**
+ * Fetch a URI "routed" Segment
+ *
+ * This function returns the re-routed URI segment (assuming routing rules are used)
+ * based on the number provided. If there is no routing this function returns the
+ * same result as $this->segment()
+ *
+ * @access public
+ * @param integer
+ * @param bool
+ * @return string
+ */
+ function rsegment($n, $no_result = FALSE)
+ {
+ return ( ! isset($this->router->rsegments[$n])) ? $no_result : $this->router->rsegments[$n];
+ }
+
+ // --------------------------------------------------------------------
+
/**
* Generate a key value pair from the URI string
*
@@ -168,7 +187,6 @@ class CI_URI {
return implode('/', $temp);
}
-
// --------------------------------------------------------------------
/**
@@ -180,6 +198,37 @@ class CI_URI {
* @return string
*/
function slash_segment($n, $where = 'trailing')
+ {
+ return $this->_slash_segment($n, $where, 'segment');
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Fetch a URI Segment and add a trailing slash
+ *
+ * @access public
+ * @param integer
+ * @param string
+ * @return string
+ */
+ function slash_rsegment($n, $where = 'trailing')
+ {
+ return $this->_slash_segment($n, $where, 'rsegment');
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Fetch a URI Segment and add a trailing slash - helper function
+ *
+ * @access private
+ * @param integer
+ * @param string
+ * @param string
+ * @return string
+ */
+ function _slash_segment($n, $where = 'trailing', $which = 'segment')
{
if ($where == 'trailing')
{
@@ -196,7 +245,7 @@ class CI_URI {
$leading = '/';
$trailing = '/';
}
- return ( ! isset($this->router->segments[$n])) ? '' : $leading.$this->router->segments[$n].$trailing;
+ return ( ! isset($this->router->$which[$n])) ? '' : $leading.$this->router->$which[$n].$trailing;
}
// --------------------------------------------------------------------
@@ -211,6 +260,19 @@ class CI_URI {
{
return $this->router->segments;
}
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Routed Segment Array
+ *
+ * @access public
+ * @return array
+ */
+ function rsegment_array()
+ {
+ return $this->router->rsegments;
+ }
// --------------------------------------------------------------------
@@ -224,6 +286,19 @@ class CI_URI {
{
return count($this->router->segments);
}
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Total number of routed segments
+ *
+ * @access public
+ * @return integer
+ */
+ function total_rsegments()
+ {
+ return count($this->router->rsegments);
+ }
// --------------------------------------------------------------------
@@ -238,6 +313,20 @@ class CI_URI {
return $this->router->uri_string;
}
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Fetch the entire Re-routed URI string
+ *
+ * @access public
+ * @return string
+ */
+ function uri_rstring()
+ {
+ return '/'.implode('/', $this->rsegment_array()).'/';
+ }
+
}
// END URI Class
?>
\ No newline at end of file
--
cgit v1.2.3-24-g4f1b
From 99bccd6aea613901d7eaf74f141f78342e2ec333 Mon Sep 17 00:00:00 2001
From: admin
Date: Thu, 21 Sep 2006 17:05:40 +0000
Subject:
---
system/libraries/Router.php | 55 +++++++++++++++++++++++++++++++++++++++------
1 file changed, 48 insertions(+), 7 deletions(-)
(limited to 'system/libraries')
diff --git a/system/libraries/Router.php b/system/libraries/Router.php
index 1dd1e5426..868fd909e 100644
--- a/system/libraries/Router.php
+++ b/system/libraries/Router.php
@@ -31,6 +31,7 @@ class CI_Router {
var $config;
var $uri_string = '';
var $segments = array();
+ var $rsegments = array();
var $routes = array();
var $class = '';
var $method = 'index';
@@ -78,7 +79,7 @@ class CI_Router {
}
// Load the routes.php file
- include_once(APPPATH.'config/routes'.EXT);
+ @include_once(APPPATH.'config/routes'.EXT);
$this->routes = ( ! isset($route) OR ! is_array($route)) ? array() : $route;
unset($route);
@@ -151,12 +152,7 @@ class CI_Router {
$this->_parse_routes();
// Re-index the segment array so that it starts with 1 rather than 0
- $i = 1;
- foreach ($this->segments as $val)
- {
- $this->segments[$i++] = $val;
- }
- unset($this->segments['0']);
+ $this->_reindex_segments();
}
// END _set_route_mapping()
@@ -199,6 +195,11 @@ class CI_Router {
$this->set_method($segments['1']);
}
}
+
+ // Update our "routed" segment array to contain the segments.
+ // Note: If there is no custom routing, this array will be
+ // identical to $this->segments
+ $this->rsegments = $segments;
}
// END _compile_segments()
@@ -256,6 +257,46 @@ class CI_Router {
show_404();
}
// END _validate_segments()
+
+ // --------------------------------------------------------------------
+ /**
+ * Re-index Segments
+ *
+ * This function re-indexes the $this->segment array so that it
+ * starts at 1 rather then 0. Doing so makes it simpler to
+ * use functions like $this->uri->segment(n) since there is
+ * a 1:1 relationship between the segment array and the actual segments.
+ *
+ * @access private
+ * @return void
+ */
+ function _reindex_segments()
+ {
+ // Is the routed segment array different then the main segment array?
+ $diff = (count(array_diff($this->rsegments, $this->segments)) == 0) ? FALSE : TRUE;
+
+ $i = 1;
+ foreach ($this->segments as $val)
+ {
+ $this->segments[$i++] = $val;
+ }
+ unset($this->segments['0']);
+
+ if ($diff == FALSE)
+ {
+ $this->rsegments = $this->segments;
+ }
+ else
+ {
+ $i = 1;
+ foreach ($this->rsegments as $val)
+ {
+ $this->rsegments[$i++] = $val;
+ }
+ unset($this->rsegments['0']);
+ }
+ }
+ // END _reindex_segments()
// --------------------------------------------------------------------
--
cgit v1.2.3-24-g4f1b
From 05633d7348b85147a46a7396c3bee1928335fa7a Mon Sep 17 00:00:00 2001
From: admin
Date: Thu, 21 Sep 2006 17:22:21 +0000
Subject:
---
system/libraries/Parser.php | 2 +-
system/libraries/URI.php | 41 ++++++++++++++++++++++++++++++++++++++---
2 files changed, 39 insertions(+), 4 deletions(-)
(limited to 'system/libraries')
diff --git a/system/libraries/Parser.php b/system/libraries/Parser.php
index 9f6a814ae..b07b64fdd 100644
--- a/system/libraries/Parser.php
+++ b/system/libraries/Parser.php
@@ -47,7 +47,7 @@ class CI_Parser {
$OUT =& _load_class('CI_Output');
$obj =& get_instance();
- $template = $obj->load->view($template, '', TRUE);
+ $template = $obj->load->view($template, $data, TRUE);
if ($template == '')
{
diff --git a/system/libraries/URI.php b/system/libraries/URI.php
index 11562eb29..e831d9526 100644
--- a/system/libraries/URI.php
+++ b/system/libraries/URI.php
@@ -107,6 +107,41 @@ class CI_URI {
*/
function uri_to_assoc($n = 3, $default = array())
{
+ return $this->_uri_to_assoc($n, $default, 'segment');
+ }
+ /**
+ * Identical to above only it uses the re-routed segment array
+ *
+ */
+ function ruri_to_assoc($n = 3, $default = array())
+ {
+ return $this->_uri_to_assoc($n, $default, 'rsegment');
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Generate a key value pair from the URI string or Re-routed URI string
+ *
+ * @access private
+ * @param integer the starting segment number
+ * @param array an array of default values
+ * @param string which array we should use
+ * @return array
+ */
+ function _uri_to_assoc($n = 3, $default = array(), $which = 'segment')
+ {
+ if ($which == 'segment')
+ {
+ $total_segments = 'total_segments';
+ $segment_array = 'segment_array';
+ }
+ else
+ {
+ $total_segments = 'total_rsegments';
+ $segment_array = 'rsegment_array';
+ }
+
if ( ! is_numeric($n))
{
return $default;
@@ -117,7 +152,7 @@ class CI_URI {
return $this->keyval[$n];
}
- if ($this->total_segments() < $n)
+ if ($this->$total_segments() < $n)
{
if (count($default) == 0)
{
@@ -132,7 +167,7 @@ class CI_URI {
return $retval;
}
- $segments = array_slice($this->segment_array(), ($n - 1));
+ $segments = array_slice($this->$segment_array(), ($n - 1));
$i = 0;
$lastval = '';
@@ -322,7 +357,7 @@ class CI_URI {
* @access public
* @return string
*/
- function uri_rstring()
+ function ruri_string()
{
return '/'.implode('/', $this->rsegment_array()).'/';
}
--
cgit v1.2.3-24-g4f1b
From c1fa07415179d63762f1a22f0f74660a8034707f Mon Sep 17 00:00:00 2001
From: admin
Date: Thu, 21 Sep 2006 23:50:23 +0000
Subject:
---
system/libraries/Controller.php | 2 +-
system/libraries/Output.php | 22 +++++++++++++++-------
system/libraries/URI.php | 2 +-
3 files changed, 17 insertions(+), 9 deletions(-)
(limited to 'system/libraries')
diff --git a/system/libraries/Controller.php b/system/libraries/Controller.php
index 5a32e65c0..0dd6ee6a4 100644
--- a/system/libraries/Controller.php
+++ b/system/libraries/Controller.php
@@ -380,7 +380,7 @@ class Controller extends CI_Base {
eval('class CI_DB extends CI_DB_driver { }');
}
}
-
+
require_once(BASEPATH.'drivers/DB_'.$params['dbdriver'].EXT);
// Instantiate the DB adapter
diff --git a/system/libraries/Output.php b/system/libraries/Output.php
index 4a3adb858..ec3660c6c 100644
--- a/system/libraries/Output.php
+++ b/system/libraries/Output.php
@@ -123,8 +123,8 @@ class CI_Output {
*/
function _display($output = '')
{
- $BM =& _load_class('CI_Benchmark');
-
+ $obj =& get_instance();
+
if ($output == '')
{
$output =& $this->final_output;
@@ -138,15 +138,14 @@ class CI_Output {
// Parse out the elapsed time and memory usage, and
// swap the pseudo-variables with the data
- $elapsed = $BM->elapsed_time('code_igniter_start', 'code_igniter_end');
+ $elapsed = $obj->benchmark->elapsed_time('code_igniter_start', 'code_igniter_end');
$memory = ( ! function_exists('memory_get_usage')) ? '0' : round(memory_get_usage()/1024/1024, 2).'MB';
$output = str_replace('{memory_usage}', $memory, $output);
$output = str_replace('{elapsed_time}', $elapsed, $output);
// Is compression requested?
- $CFG =& _load_class('CI_Config');
- if ($CFG->item('compress_output') === TRUE)
+ if ($obj->config->item('compress_output') === TRUE)
{
if (extension_loaded('zlib'))
{
@@ -166,8 +165,17 @@ class CI_Output {
}
}
- // Send it to the browser!
- echo $output;
+ // Send the finalized output either directly
+ // to the browser or to the user's _output()
+ // function if it exists
+ if (method_exists($obj, '_output'))
+ {
+ $obj->_output($output);
+ }
+ else
+ {
+ echo $output; // Send it to the browser!
+ }
log_message('debug', "Final output sent to browser");
log_message('debug', "Total execution time: ".$elapsed);
diff --git a/system/libraries/URI.php b/system/libraries/URI.php
index e831d9526..89ca42e44 100644
--- a/system/libraries/URI.php
+++ b/system/libraries/URI.php
@@ -280,7 +280,7 @@ class CI_URI {
$leading = '/';
$trailing = '/';
}
- return ( ! isset($this->router->$which[$n])) ? '' : $leading.$this->router->$which[$n].$trailing;
+ return $leading.$this->$which($n).$trailing;
}
// --------------------------------------------------------------------
--
cgit v1.2.3-24-g4f1b
From 592cdcbc58963f0cf811aea59db9907943460770 Mon Sep 17 00:00:00 2001
From: admin
Date: Fri, 22 Sep 2006 18:45:42 +0000
Subject:
---
system/libraries/Router.php | 138 +++++++++++++++++++++++++++++++++-----------
1 file changed, 104 insertions(+), 34 deletions(-)
(limited to 'system/libraries')
diff --git a/system/libraries/Router.php b/system/libraries/Router.php
index 868fd909e..5bbf9e6ca 100644
--- a/system/libraries/Router.php
+++ b/system/libraries/Router.php
@@ -77,45 +77,18 @@ class CI_Router {
return;
}
-
- // Load the routes.php file
+
+ // Load the routes.php file and set the default controller
@include_once(APPPATH.'config/routes'.EXT);
$this->routes = ( ! isset($route) OR ! is_array($route)) ? array() : $route;
unset($route);
- // Set the default controller
- $this->default_controller = ( ! isset($this->routes['default_controller']) OR $this->routes['default_controller'] == '') ? FALSE : strtolower($this->routes['default_controller']);
-
- // Fetch the URI string Depending on the server,
- // the URI will be available in one of two globals
- if ($this->config->item('uri_protocol') == 'auto')
- {
- $path_info = getenv('PATH_INFO');
- if ($path_info != '' AND $path_info != "/".SELF)
- {
- $this->uri_string = $path_info;
- }
- else
- {
- $path_info = getenv('ORIG_PATH_INFO');
- if ($path_info != '' AND $path_info != "/".SELF)
- {
- $this->uri_string = $path_info;
- }
- else
- {
- $this->uri_string = getenv('QUERY_STRING');
- }
- }
- }
- else
- {
- $this->uri_string = getenv(strtoupper($this->config->item('uri_protocol')));
- }
-
+ $this->default_controller = ( ! isset($this->routes['default_controller']) OR $this->routes['default_controller'] == '') ? FALSE : strtolower($this->routes['default_controller']);
- // Is there a URI string? If not, the default controller specified
- // by the admin in the "routes" file will be shown.
+ // Get the URI string
+ $this->uri_string = $this->_get_uri_string();
+
+ // Is there a URI string? If not, the default controller specified in the "routes" file will be shown.
if ($this->uri_string == '')
{
if ($this->default_controller === FALSE)
@@ -300,6 +273,103 @@ class CI_Router {
// --------------------------------------------------------------------
+ /**
+ * Get the URI String
+ *
+ * @access private
+ * @return string
+ */
+ function _get_uri_string()
+ {
+ if (strtoupper($this->config->item('uri_protocol')) == 'AUTO')
+ {
+ $path_info = getenv('PATH_INFO');
+ if ($path_info != '' AND $path_info != "/".SELF)
+ {
+ return $path_info;
+ }
+ else
+ {
+ $req_uri = $this->_parse_request_uri();
+
+ if ($req_uri != "")
+ {
+ return $req_uri;
+ }
+ else
+ {
+ $path_info = getenv('ORIG_PATH_INFO');
+ if ($path_info != '' AND $path_info != "/".SELF)
+ {
+ return $path_info;
+ }
+ else
+ {
+ return getenv('QUERY_STRING');
+ }
+ }
+ }
+ }
+ else
+ {
+ $uri = strtoupper($this->config->item('uri_protocol'));
+
+ if ($uri == 'REQUEST_URI')
+ {
+ return $this->_parse_request_uri();
+ }
+
+ return getenv($uri);
+ }
+ }
+ // END _get_uri_string()
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Parse the REQUEST_URI
+ *
+ * Due to the way REQUEST_URI works it usually contains path info
+ * that makes it unusable as URI data. We'll trim off the unnecessary
+ * data, hopefully arriving at a valid URI that we can use.
+ *
+ * @access private
+ * @return string
+ */
+ function _parse_request_uri()
+ {
+ $request_uri = getenv('REQUEST_URI');
+ $fc_path = FCPATH;
+
+ if (strpos($request_uri, '?') !== FALSE)
+ {
+ $fc_path .= '?';
+ }
+
+ $parsed_uri = explode("/", preg_replace("|/(.*)|", "\\1", str_replace("\\", "/", $request_uri)));
+
+ $i = 0;
+ foreach(explode("/", $fc_path) as $segment)
+ {
+ if ($segment == $parsed_uri[$i])
+ {
+ $i++;
+ }
+ }
+
+ $parsed_uri = implode("/", array_slice($parsed_uri, $i));
+
+ if ($parsed_uri != '')
+ {
+ $parsed_uri = '/'.$parsed_uri;
+ }
+
+ return $parsed_uri;
+ }
+ // END _parse_request_uri()
+
+ // --------------------------------------------------------------------
+
/**
* Filter segments for malicious characters
*
--
cgit v1.2.3-24-g4f1b
From dbd8aec6121f1d0a295031c268964357ebcc84e0 Mon Sep 17 00:00:00 2001
From: admin
Date: Fri, 22 Sep 2006 19:20:09 +0000
Subject:
---
system/libraries/Router.php | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
(limited to 'system/libraries')
diff --git a/system/libraries/Router.php b/system/libraries/Router.php
index 5bbf9e6ca..d1751a0e9 100644
--- a/system/libraries/Router.php
+++ b/system/libraries/Router.php
@@ -85,11 +85,8 @@ class CI_Router {
$this->default_controller = ( ! isset($this->routes['default_controller']) OR $this->routes['default_controller'] == '') ? FALSE : strtolower($this->routes['default_controller']);
- // Get the URI string
- $this->uri_string = $this->_get_uri_string();
-
// Is there a URI string? If not, the default controller specified in the "routes" file will be shown.
- if ($this->uri_string == '')
+ if (($this->uri_string = $this->_get_uri_string()) == '')
{
if ($this->default_controller === FALSE)
{
@@ -338,7 +335,11 @@ class CI_Router {
*/
function _parse_request_uri()
{
- $request_uri = getenv('REQUEST_URI');
+ if (($request_uri = getenv('REQUEST_URI')) == '')
+ {
+ return '';
+ }
+
$fc_path = FCPATH;
if (strpos($request_uri, '?') !== FALSE)
--
cgit v1.2.3-24-g4f1b
From 212a3fa070a02c812b84ca937c5cb411400e6f3d Mon Sep 17 00:00:00 2001
From: admin
Date: Sat, 23 Sep 2006 04:22:39 +0000
Subject:
---
system/libraries/Loader.php | 24 ++++++++----------------
system/libraries/Parser.php | 4 +---
2 files changed, 9 insertions(+), 19 deletions(-)
(limited to 'system/libraries')
diff --git a/system/libraries/Loader.php b/system/libraries/Loader.php
index ead55dff7..d966e2862 100644
--- a/system/libraries/Loader.php
+++ b/system/libraries/Loader.php
@@ -454,9 +454,7 @@ class CI_Loader {
* @return void
*/
function _ci_load($data)
- {
- $OUT =& _load_class('CI_Output');
-
+ {
// This allows anything loaded using $this->load (viwes, files, etc.)
// to become accessible from within the Controller and Model functions.
$obj =& get_instance();
@@ -477,15 +475,11 @@ class CI_Loader {
/*
* Extract and cached variables
*
- * You can either set variables using the dedicated
- * $this->load_vars() function or via the second
- * parameter of this function. We'll
- * merge the two types and cache them so that
- * views that are embedded within other views
- * can have access to these variables.
- *
+ * You can either set variables using the dedicated $this->load_vars()
+ * function or via the second parameter of this function. We'll merge
+ * the two types and cache them so that views that are embedded within
+ * other views can have access to these variables.
*/
-
if (is_array($vars))
{
$this->cached_vars = array_merge($this->cached_vars, $vars);
@@ -515,10 +509,8 @@ class CI_Loader {
* need post processing? For one thing, in order to
* show the elapsed page load time. Unless we
* can intercept the content right before it's sent to
- * the browser and then stop the timer, it won't be acurate.
- *
+ * the browser and then stop the timer it won't be acurate.
*/
-
if ( ! file_exists($path))
{
show_error('Unable to load the requested file: '.$file);
@@ -541,7 +533,7 @@ class CI_Loader {
/*
* Flush the buffer... or buff the flusher?
*
- * In order to permit templates (views) to be nested within
+ * In order to permit views to be nested within
* other views, we need to flush the content back out whenever
* we are beyond the first level of output buffering so that
* it can be seen and included properly by the first included
@@ -554,7 +546,7 @@ class CI_Loader {
}
else
{
- $OUT->set_output(ob_get_contents());
+ $obj->output->set_output(ob_get_contents());
ob_end_clean();
}
}
diff --git a/system/libraries/Parser.php b/system/libraries/Parser.php
index b07b64fdd..17a985fd7 100644
--- a/system/libraries/Parser.php
+++ b/system/libraries/Parser.php
@@ -44,8 +44,6 @@ class CI_Parser {
*/
function parse($template, $data, $return = FALSE)
{
- $OUT =& _load_class('CI_Output');
-
$obj =& get_instance();
$template = $obj->load->view($template, $data, TRUE);
@@ -68,7 +66,7 @@ class CI_Parser {
if ($return == FALSE)
{
- $OUT->final_output = $template;
+ $obj->output->final_output = $template;
}
return $template;
--
cgit v1.2.3-24-g4f1b
From 4e9f3f90ed26a0dc4bcacf106d6421bf725b5ae3 Mon Sep 17 00:00:00 2001
From: admin
Date: Sat, 23 Sep 2006 17:39:20 +0000
Subject:
---
system/libraries/Parser.php | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
(limited to 'system/libraries')
diff --git a/system/libraries/Parser.php b/system/libraries/Parser.php
index 17a985fd7..63dc023a2 100644
--- a/system/libraries/Parser.php
+++ b/system/libraries/Parser.php
@@ -54,11 +54,11 @@ class CI_Parser {
foreach ($data as $key => $val)
{
- if ( ! is_array($val))
+ if (is_string($val))
{
$template = $this->_parse_single($key, $val, $template);
}
- else
+ elseif (is_array($val))
{
$template = $this->_parse_pair($key, $val, $template);
}
--
cgit v1.2.3-24-g4f1b
From b5a651cd710f7454425b9b94ff4a44fc4edacaba Mon Sep 17 00:00:00 2001
From: admin
Date: Sat, 23 Sep 2006 17:39:41 +0000
Subject:
---
system/libraries/Output.php | 11 +++++++----
1 file changed, 7 insertions(+), 4 deletions(-)
(limited to 'system/libraries')
diff --git a/system/libraries/Output.php b/system/libraries/Output.php
index ec3660c6c..5a158245f 100644
--- a/system/libraries/Output.php
+++ b/system/libraries/Output.php
@@ -123,7 +123,10 @@ class CI_Output {
*/
function _display($output = '')
{
- $obj =& get_instance();
+ // Note: We can't use $obj =& _get_instance() since this function
+ // is sometimes called by the caching mechanism, which happens before
+ // it's available. Instead we'll use globals...
+ global $BM, $CFG;
if ($output == '')
{
@@ -138,14 +141,14 @@ class CI_Output {
// Parse out the elapsed time and memory usage, and
// swap the pseudo-variables with the data
- $elapsed = $obj->benchmark->elapsed_time('code_igniter_start', 'code_igniter_end');
+ $elapsed = $BM->elapsed_time('code_igniter_start', 'code_igniter_end');
$memory = ( ! function_exists('memory_get_usage')) ? '0' : round(memory_get_usage()/1024/1024, 2).'MB';
$output = str_replace('{memory_usage}', $memory, $output);
$output = str_replace('{elapsed_time}', $elapsed, $output);
// Is compression requested?
- if ($obj->config->item('compress_output') === TRUE)
+ if ($CFG->item('compress_output') === TRUE)
{
if (extension_loaded('zlib'))
{
@@ -168,7 +171,7 @@ class CI_Output {
// Send the finalized output either directly
// to the browser or to the user's _output()
// function if it exists
- if (method_exists($obj, '_output'))
+ if (function_exists('_get_instance') AND method_exists($obj, '_output'))
{
$obj->_output($output);
}
--
cgit v1.2.3-24-g4f1b
From e885d787cde65d9ab003426bf79047de57c83ebe Mon Sep 17 00:00:00 2001
From: admin
Date: Sat, 23 Sep 2006 20:25:05 +0000
Subject:
---
system/libraries/Xmlrpcs.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
(limited to 'system/libraries')
diff --git a/system/libraries/Xmlrpcs.php b/system/libraries/Xmlrpcs.php
index eaec87a6d..0543c3b78 100644
--- a/system/libraries/Xmlrpcs.php
+++ b/system/libraries/Xmlrpcs.php
@@ -223,7 +223,7 @@ class CI_XML_RPC_Server extends CI_XML_RPC
// Executes the Method
//-------------------------------------
- function execute($m)
+ function _execute($m)
{
$methName = $m->method_name;
--
cgit v1.2.3-24-g4f1b
From 3c023b12c3d27f0e2773e671b854e52e2dc0d1d6 Mon Sep 17 00:00:00 2001
From: admin
Date: Sun, 24 Sep 2006 03:04:10 +0000
Subject:
---
system/libraries/Validation.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
(limited to 'system/libraries')
diff --git a/system/libraries/Validation.php b/system/libraries/Validation.php
index f9b51d778..153657e31 100644
--- a/system/libraries/Validation.php
+++ b/system/libraries/Validation.php
@@ -524,7 +524,7 @@ class CI_Validation {
*/
function numeric($str)
{
- return ( ! ereg("^[0-9]+$", $str)) ? FALSE : TRUE;
+ return ( ! ereg("^[0-9\.]+$", $str)) ? FALSE : TRUE;
}
// --------------------------------------------------------------------
--
cgit v1.2.3-24-g4f1b
From 5808346898ec9c602893fc54540958a8c556be29 Mon Sep 17 00:00:00 2001
From: admin
Date: Sun, 24 Sep 2006 17:58:27 +0000
Subject:
---
system/libraries/Controller.php | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
(limited to 'system/libraries')
diff --git a/system/libraries/Controller.php b/system/libraries/Controller.php
index 0dd6ee6a4..5be10500b 100644
--- a/system/libraries/Controller.php
+++ b/system/libraries/Controller.php
@@ -362,11 +362,11 @@ class Controller extends CI_Base {
$params['active_r'] = TRUE;
}
- require_once(BASEPATH.'drivers/DB_driver'.EXT);
+ require_once(BASEPATH.'database/DB_driver'.EXT);
if ( ! isset($params['active_r']) OR $params['active_r'] == TRUE)
{
- require_once(BASEPATH.'drivers/DB_active_record'.EXT);
+ require_once(BASEPATH.'database/DB_active_record'.EXT);
if ( ! class_exists('CI_DB'))
{
@@ -381,7 +381,7 @@ class Controller extends CI_Base {
}
}
- require_once(BASEPATH.'drivers/DB_'.$params['dbdriver'].EXT);
+ require_once(BASEPATH.'database/drivers/'.$params['dbdriver'].'/'.$params['dbdriver'].EXT);
// Instantiate the DB adapter
$driver = 'CI_DB_'. $params['dbdriver'];
--
cgit v1.2.3-24-g4f1b
From 46563d570944d6c5af8b4f46ba1eeca111eabaa4 Mon Sep 17 00:00:00 2001
From: admin
Date: Sun, 24 Sep 2006 18:14:22 +0000
Subject:
---
system/libraries/Controller.php | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
(limited to 'system/libraries')
diff --git a/system/libraries/Controller.php b/system/libraries/Controller.php
index 5be10500b..61c8363fa 100644
--- a/system/libraries/Controller.php
+++ b/system/libraries/Controller.php
@@ -381,10 +381,10 @@ class Controller extends CI_Base {
}
}
- require_once(BASEPATH.'database/drivers/'.$params['dbdriver'].'/'.$params['dbdriver'].EXT);
+ require_once(BASEPATH.'database/drivers/'.$params['dbdriver'].'/'.$params['dbdriver'].'_driver'.EXT);
// Instantiate the DB adapter
- $driver = 'CI_DB_'. $params['dbdriver'];
+ $driver = 'CI_DB_'. $params['dbdriver'].'_driver';
$DB = new $driver($params);
if ($return === TRUE)
--
cgit v1.2.3-24-g4f1b
From c9a8bab572388bbba541f1cf8f12a46e2103e447 Mon Sep 17 00:00:00 2001
From: admin
Date: Sun, 24 Sep 2006 20:28:33 +0000
Subject:
---
system/libraries/Controller.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
(limited to 'system/libraries')
diff --git a/system/libraries/Controller.php b/system/libraries/Controller.php
index 61c8363fa..b91cf3b07 100644
--- a/system/libraries/Controller.php
+++ b/system/libraries/Controller.php
@@ -366,7 +366,7 @@ class Controller extends CI_Base {
if ( ! isset($params['active_r']) OR $params['active_r'] == TRUE)
{
- require_once(BASEPATH.'database/DB_active_record'.EXT);
+ require_once(BASEPATH.'database/DB_active_rec'.EXT);
if ( ! class_exists('CI_DB'))
{
--
cgit v1.2.3-24-g4f1b
From a5e812c007b8dfbc4c117df379d63060f08b096a Mon Sep 17 00:00:00 2001
From: admin
Date: Mon, 25 Sep 2006 02:17:30 +0000
Subject:
---
system/libraries/Controller.php | 46 +++++++++++++++++++++++++++++++++++++++--
system/libraries/Loader.php | 25 +++++++++++++++++++++-
2 files changed, 68 insertions(+), 3 deletions(-)
(limited to 'system/libraries')
diff --git a/system/libraries/Controller.php b/system/libraries/Controller.php
index b91cf3b07..5fdbd9f9f 100644
--- a/system/libraries/Controller.php
+++ b/system/libraries/Controller.php
@@ -384,7 +384,7 @@ class Controller extends CI_Base {
require_once(BASEPATH.'database/drivers/'.$params['dbdriver'].'/'.$params['dbdriver'].'_driver'.EXT);
// Instantiate the DB adapter
- $driver = 'CI_DB_'. $params['dbdriver'].'_driver';
+ $driver = 'CI_DB_'.$params['dbdriver'].'_driver';
$DB = new $driver($params);
if ($return === TRUE)
@@ -397,7 +397,49 @@ class Controller extends CI_Base {
$obj->db =& $DB;
}
// END _ci_init_database()
-
+
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Initialize Database Utilities Class
+ *
+ * @access private
+ * @param mixed database platform
+ * @param bool whether to return the object
+ * @return void
+ */
+ function _ci_init_dbutils($db = '', $return = FALSE)
+ {
+ if ($this->_ci_is_loaded('dbutils') == TRUE AND $return == FALSE)
+ {
+ return;
+ }
+
+ if ($this->_ci_is_loaded('db') == FALSE)
+ {
+ $this->_ci_init_database();
+ }
+
+ require_once(BASEPATH.'database/DB_utility'.EXT);
+ require_once(BASEPATH.'database/drivers/'.$this->db->dbdriver.'/'.$this->db->dbdriver.'_utility'.EXT);
+
+
+ // Instantiate the DB adapter
+ $driver = 'CI_DB_'.$this->db->dbdriver.'_utility';
+ $DB = new $driver();
+
+ if ($return === TRUE)
+ {
+ return $DB;
+ }
+
+ $obj =& get_instance();
+ $obj->ci_is_loaded[] = 'dbutils';
+ $obj->dbutil =& $DB;
+ }
+ // END _ci_init_database()
+
// --------------------------------------------------------------------
/**
diff --git a/system/libraries/Loader.php b/system/libraries/Loader.php
index d966e2862..f4a9f821d 100644
--- a/system/libraries/Loader.php
+++ b/system/libraries/Loader.php
@@ -108,7 +108,7 @@ class CI_Loader {
* @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 mixed
+ * @return object
*/
function database($db = '', $return = FALSE, $active_record = FALSE)
{
@@ -125,6 +125,29 @@ class CI_Loader {
}
}
// END database()
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Database Utilities Loader
+ *
+ * @access public
+ * @param string the DB platform
+ * @param bool whether to return the DB object
+ * @return object
+ */
+ function dbutils($db = '', $return = FALSE)
+ {
+ $obj =& get_instance();
+
+ if ( ! is_bool($return))
+ {
+ $return = FALSE;
+ }
+
+ return $obj->_ci_init_dbutils($db, $return);
+ }
+ // END dbutils()
// --------------------------------------------------------------------
--
cgit v1.2.3-24-g4f1b
From 83b05a860a5f208d15942b517385848cfe4887bb Mon Sep 17 00:00:00 2001
From: admin
Date: Mon, 25 Sep 2006 21:06:46 +0000
Subject:
---
system/libraries/Loader.php | 7 +++++--
system/libraries/Router.php | 20 ++++++++++----------
system/libraries/Validation.php | 16 +++++++++++++++-
3 files changed, 30 insertions(+), 13 deletions(-)
(limited to 'system/libraries')
diff --git a/system/libraries/Loader.php b/system/libraries/Loader.php
index f4a9f821d..b69d3f049 100644
--- a/system/libraries/Loader.php
+++ b/system/libraries/Loader.php
@@ -363,7 +363,10 @@ class CI_Loader {
* Load Script
*
* This function loads the specified include file from the
- * application/scripts/ folder
+ * application/scripts/ folder.
+ *
+ * NOTE: This feature has been deprecated but it will remain available
+ * for legacy users.
*
* @access public
* @param array
@@ -496,7 +499,7 @@ class CI_Loader {
}
/*
- * Extract and cached variables
+ * Extract and cache variables
*
* You can either set variables using the dedicated $this->load_vars()
* function or via the second parameter of this function. We'll merge
diff --git a/system/libraries/Router.php b/system/libraries/Router.php
index d1751a0e9..d7740f5f3 100644
--- a/system/libraries/Router.php
+++ b/system/libraries/Router.php
@@ -149,12 +149,12 @@ class CI_Router {
return;
}
- $this->set_class($segments['0']);
+ $this->set_class($segments[0]);
- if (isset($segments['1']))
+ if (isset($segments[1]))
{
// A scaffolding request. No funny business with the URL
- if ($this->routes['scaffolding_trigger'] == $segments['1'] AND $segments['1'] != '_ci_scaffolding')
+ if ($this->routes['scaffolding_trigger'] == $segments[1] AND $segments[1] != '_ci_scaffolding')
{
$this->scaffolding_request = TRUE;
unset($this->routes['scaffolding_trigger']);
@@ -162,7 +162,7 @@ class CI_Router {
else
{
// A standard method request
- $this->set_method($segments['1']);
+ $this->set_method($segments[1]);
}
}
@@ -186,22 +186,22 @@ class CI_Router {
function _validate_segments($segments)
{
// Does the requested controller exist in the root folder?
- if (file_exists(APPPATH.'controllers/'.$segments['0'].EXT))
+ if (file_exists(APPPATH.'controllers/'.$segments[0].EXT))
{
return $segments;
}
// Is the controller in a sub-folder?
- if (is_dir(APPPATH.'controllers/'.$segments['0']))
+ if (is_dir(APPPATH.'controllers/'.$segments[0]))
{
// Set the directory and remove it from the segment array
- $this->set_directory($segments['0']);
+ $this->set_directory($segments[0]);
$segments = array_slice($segments, 1);
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].EXT))
{
show_404();
}
@@ -250,7 +250,7 @@ class CI_Router {
{
$this->segments[$i++] = $val;
}
- unset($this->segments['0']);
+ unset($this->segments[0]);
if ($diff == FALSE)
{
@@ -263,7 +263,7 @@ class CI_Router {
{
$this->rsegments[$i++] = $val;
}
- unset($this->rsegments['0']);
+ unset($this->rsegments[0]);
}
}
// END _reindex_segments()
diff --git a/system/libraries/Validation.php b/system/libraries/Validation.php
index 153657e31..b65b9be52 100644
--- a/system/libraries/Validation.php
+++ b/system/libraries/Validation.php
@@ -519,13 +519,27 @@ class CI_Validation {
* Numeric
*
* @access public
- * @param string
+ * @param int
* @return bool
*/
function numeric($str)
{
return ( ! ereg("^[0-9\.]+$", $str)) ? FALSE : TRUE;
}
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Is Numeric
+ *
+ * @access public
+ * @param string
+ * @return bool
+ */
+ function is_numeric($str)
+ {
+ return ( ! is_numeric($str)) ? FALSE : TRUE;
+ }
// --------------------------------------------------------------------
--
cgit v1.2.3-24-g4f1b
From 9cd4e8e639a1a09fd6ca426f1af94586f30d4a80 Mon Sep 17 00:00:00 2001
From: admin
Date: Mon, 25 Sep 2006 23:26:25 +0000
Subject:
---
system/libraries/Controller.php | 2 +-
system/libraries/Loader.php | 4 ++--
2 files changed, 3 insertions(+), 3 deletions(-)
(limited to 'system/libraries')
diff --git a/system/libraries/Controller.php b/system/libraries/Controller.php
index 5fdbd9f9f..da5f2e072 100644
--- a/system/libraries/Controller.php
+++ b/system/libraries/Controller.php
@@ -409,7 +409,7 @@ class Controller extends CI_Base {
* @param bool whether to return the object
* @return void
*/
- function _ci_init_dbutils($db = '', $return = FALSE)
+ function _ci_init_dbutil($db = '', $return = FALSE)
{
if ($this->_ci_is_loaded('dbutils') == TRUE AND $return == FALSE)
{
diff --git a/system/libraries/Loader.php b/system/libraries/Loader.php
index b69d3f049..833e37640 100644
--- a/system/libraries/Loader.php
+++ b/system/libraries/Loader.php
@@ -136,7 +136,7 @@ class CI_Loader {
* @param bool whether to return the DB object
* @return object
*/
- function dbutils($db = '', $return = FALSE)
+ function dbutil($db = '', $return = FALSE)
{
$obj =& get_instance();
@@ -145,7 +145,7 @@ class CI_Loader {
$return = FALSE;
}
- return $obj->_ci_init_dbutils($db, $return);
+ return $obj->_ci_init_dbutil($db, $return);
}
// END dbutils()
--
cgit v1.2.3-24-g4f1b
From 30c3b9709a12b7346c7057e656a491ffb9168f55 Mon Sep 17 00:00:00 2001
From: admin
Date: Tue, 26 Sep 2006 02:09:47 +0000
Subject:
---
system/libraries/Controller.php | 42 -----------------------------------------
1 file changed, 42 deletions(-)
(limited to 'system/libraries')
diff --git a/system/libraries/Controller.php b/system/libraries/Controller.php
index da5f2e072..afd963a7a 100644
--- a/system/libraries/Controller.php
+++ b/system/libraries/Controller.php
@@ -397,49 +397,7 @@ class Controller extends CI_Base {
$obj->db =& $DB;
}
// END _ci_init_database()
-
-
- // --------------------------------------------------------------------
-
- /**
- * Initialize Database Utilities Class
- *
- * @access private
- * @param mixed database platform
- * @param bool whether to return the object
- * @return void
- */
- function _ci_init_dbutil($db = '', $return = FALSE)
- {
- if ($this->_ci_is_loaded('dbutils') == TRUE AND $return == FALSE)
- {
- return;
- }
-
- if ($this->_ci_is_loaded('db') == FALSE)
- {
- $this->_ci_init_database();
- }
-
- require_once(BASEPATH.'database/DB_utility'.EXT);
- require_once(BASEPATH.'database/drivers/'.$this->db->dbdriver.'/'.$this->db->dbdriver.'_utility'.EXT);
-
- // Instantiate the DB adapter
- $driver = 'CI_DB_'.$this->db->dbdriver.'_utility';
- $DB = new $driver();
-
- if ($return === TRUE)
- {
- return $DB;
- }
-
- $obj =& get_instance();
- $obj->ci_is_loaded[] = 'dbutils';
- $obj->dbutil =& $DB;
- }
- // END _ci_init_database()
-
// --------------------------------------------------------------------
/**
--
cgit v1.2.3-24-g4f1b
From e79dc7130a0003a07833609487b8ebb5ebcf31c8 Mon Sep 17 00:00:00 2001
From: admin
Date: Tue, 26 Sep 2006 03:52:45 +0000
Subject:
---
system/libraries/Calendar.php | 7 ++++++-
system/libraries/Controller.php | 42 ++++++++++++++++++++---------------------
system/libraries/Email.php | 5 +++++
system/libraries/Encrypt.php | 5 +++++
system/libraries/Image_lib.php | 11 +++++++++++
system/libraries/Loader.php | 20 +++++++-------------
system/libraries/Model.php | 9 +++++----
system/libraries/Pagination.php | 11 +++++++++++
system/libraries/Parser.php | 5 +++++
system/libraries/Session.php | 5 +++++
system/libraries/Trackback.php | 5 +++++
system/libraries/Unit_test.php | 5 +++++
system/libraries/Upload.php | 11 +++++++++++
system/libraries/Validation.php | 5 +++++
system/libraries/Xmlrpc.php | 13 +++++++++++++
system/libraries/Xmlrpcs.php | 33 +++++++++++++++++++++++++++++++-
16 files changed, 151 insertions(+), 41 deletions(-)
(limited to 'system/libraries')
diff --git a/system/libraries/Calendar.php b/system/libraries/Calendar.php
index b77dd1b6f..a3c070390 100644
--- a/system/libraries/Calendar.php
+++ b/system/libraries/Calendar.php
@@ -13,6 +13,11 @@
* @filesource
*/
+// INITIALIZE THE CLASS ---------------------------------------------------
+
+$obj =& get_instance();
+$obj->calendar =& new CI_Calendar();
+
// ------------------------------------------------------------------------
/**
@@ -25,7 +30,7 @@
* @category Libraries
* @author Rick Ellis
* @link http://www.codeigniter.com/user_guide/libraries/calendar.html
- */
+ */
class CI_Calendar {
var $lang;
diff --git a/system/libraries/Controller.php b/system/libraries/Controller.php
index afd963a7a..97aa4b789 100644
--- a/system/libraries/Controller.php
+++ b/system/libraries/Controller.php
@@ -29,7 +29,6 @@
*/
class Controller extends CI_Base {
- var $ci_is_loaded = array();
var $_ci_models = array();
var $_ci_scaffolding = FALSE;
var $_ci_scaff_table = FALSE;
@@ -54,15 +53,18 @@ class Controller extends CI_Base {
// This allows anything loaded using $this->load (viwes, files, etc.)
// to become accessible from within the Controller class functions.
- foreach ($this->ci_is_loaded as $val)
+ foreach (get_object_vars($this) as $key => $var)
{
- $this->load->$val =& $this->$val;
+ if (is_object($var))
+ {
+ $this->load->$key =& $this->$key;
+ }
}
-
+
log_message('debug', "Controller Class Initialized");
}
// END Controller()
-
+
// --------------------------------------------------------------------
/**
@@ -75,27 +77,28 @@ class Controller extends CI_Base {
* @param mixed any additional parameters
* @return void
*/
- function _ci_initialize($what, $params = FALSE)
+ function _ci_initialize($class, $params = FALSE)
{
- $method = '_ci_init_'.strtolower(str_replace(EXT, '', $what));
+ $class = strtolower(str_replace(EXT, '', $class));
+ $method = '_ci_init_'.$class;
if ( ! method_exists($this, $method))
- {
- $method = substr($method, 4);
+ {
+ $class = ucfirst($class);
- if ( ! file_exists(APPPATH.'init/'.$method.EXT))
+ if ( ! file_exists(APPPATH.'libraries/'.$class.EXT))
{
- if ( ! file_exists(BASEPATH.'init/'.$method.EXT))
+ if ( ! file_exists(BASEPATH.'libraries/'.$class.EXT))
{
- log_message('error', "Unable to load the requested class: ".$what);
- show_error("Unable to load the class: ".$what);
+ log_message('error', "Unable to load the requested class: ".$class);
+ show_error("Unable to load the class: ".$class);
}
- include(BASEPATH.'init/'.$method.EXT);
+ include_once(BASEPATH.'libraries/'.$class.EXT);
}
else
{
- include(APPPATH.'init/'.$method.EXT);
+ include_once(APPPATH.'libraries/'.$class.EXT);
}
}
else
@@ -268,11 +271,9 @@ class Controller extends CI_Base {
{
$class = strtolower($val);
$this->$class =& _load_class('CI_'.$val);
- $this->ci_is_loaded[] = $class;
}
$this->lang =& _load_class('CI_Language');
- $this->ci_is_loaded[] = 'lang';
// In PHP 4 the Controller class is a child of CI_Loader.
// In PHP 5 we run it as its own class.
@@ -280,8 +281,6 @@ class Controller extends CI_Base {
{
$this->load = new CI_Loader();
}
-
- $this->ci_is_loaded[] = 'load';
}
// END _ci_assign_core()
@@ -393,7 +392,6 @@ class Controller extends CI_Base {
}
$obj =& get_instance();
- $obj->ci_is_loaded[] = 'db';
$obj->db =& $DB;
}
// END _ci_init_database()
@@ -409,10 +407,10 @@ class Controller extends CI_Base {
*/
function _ci_is_loaded($class)
{
- return ( ! in_array($class, $this->ci_is_loaded)) ? FALSE : TRUE;
+ return ( ! isset($this->$class) OR ! is_object($this->$class)) ? FALSE : TRUE;
}
// END _ci_is_loaded()
-
+
// --------------------------------------------------------------------
/**
diff --git a/system/libraries/Email.php b/system/libraries/Email.php
index 5b991d1fa..c153043d9 100644
--- a/system/libraries/Email.php
+++ b/system/libraries/Email.php
@@ -13,6 +13,11 @@
* @filesource
*/
+// INITIALIZE THE CLASS ---------------------------------------------------
+
+$obj =& get_instance();
+$obj->email =& new CI_Email();
+
// ------------------------------------------------------------------------
/**
diff --git a/system/libraries/Encrypt.php b/system/libraries/Encrypt.php
index bcffdf1ab..446f64aa6 100644
--- a/system/libraries/Encrypt.php
+++ b/system/libraries/Encrypt.php
@@ -13,6 +13,11 @@
* @filesource
*/
+// INITIALIZE THE CLASS ---------------------------------------------------
+
+$obj =& get_instance();
+$obj->encrypt =& new CI_Encrypt();
+
// ------------------------------------------------------------------------
/**
diff --git a/system/libraries/Image_lib.php b/system/libraries/Image_lib.php
index 18e3253f7..86ed05943 100644
--- a/system/libraries/Image_lib.php
+++ b/system/libraries/Image_lib.php
@@ -13,6 +13,17 @@
* @filesource
*/
+// INITIALIZE THE CLASS ---------------------------------------------------
+
+$config = array();
+if (file_exists(APPPATH.'config/image_lib'.EXT))
+{
+ include_once(APPPATH.'config/image_lib'.EXT);
+}
+
+$obj =& get_instance();
+$obj->image_lib =& new CI_Image_lib($config);
+
// ------------------------------------------------------------------------
/**
diff --git a/system/libraries/Loader.php b/system/libraries/Loader.php
index 833e37640..7449fa34a 100644
--- a/system/libraries/Loader.php
+++ b/system/libraries/Loader.php
@@ -136,15 +136,9 @@ class CI_Loader {
* @param bool whether to return the DB object
* @return object
*/
- function dbutil($db = '', $return = FALSE)
+ function dbutil()
{
$obj =& get_instance();
-
- if ( ! is_bool($return))
- {
- $return = FALSE;
- }
-
return $obj->_ci_init_dbutil($db, $return);
}
// END dbutils()
@@ -484,14 +478,14 @@ class CI_Loader {
// This allows anything loaded using $this->load (viwes, files, etc.)
// to become accessible from within the Controller and Model functions.
$obj =& get_instance();
- foreach ($obj->ci_is_loaded as $val)
+ foreach (get_object_vars($obj) as $key => $var)
{
- if ( ! isset($this->$val))
+ if (is_object($var))
{
- $this->$val =& $obj->$val;
- }
- }
-
+ $this->$key =& $obj->$key;
+ }
+ }
+
// Set the default data variables
foreach (array('view', 'vars', 'path', 'return') as $val)
{
diff --git a/system/libraries/Model.php b/system/libraries/Model.php
index 9834f8278..55c995636 100644
--- a/system/libraries/Model.php
+++ b/system/libraries/Model.php
@@ -50,20 +50,21 @@ class Model {
function _assign_libraries($use_reference = TRUE)
{
$obj =& get_instance();
- foreach ($obj->ci_is_loaded as $val)
+ foreach (get_object_vars($obj) as $key => $var)
{
- if ( ! isset($this->$val))
+ if (is_object($var) AND ! isset($this->$key))
{
if ($use_reference === TRUE)
{
- $this->$val =& $obj->$val;
+ $this->$key =& $obj->$key;
}
else
{
- $this->$val = $obj->$val;
+ $this->$key = $obj->$key;
}
}
}
+
}
// END _assign_libraries()
diff --git a/system/libraries/Pagination.php b/system/libraries/Pagination.php
index 9d558f00a..d83a2bd0f 100644
--- a/system/libraries/Pagination.php
+++ b/system/libraries/Pagination.php
@@ -13,6 +13,17 @@
* @filesource
*/
+// INITIALIZE THE CLASS ---------------------------------------------------
+
+$config = array();
+if (file_exists(APPPATH.'config/pagination'.EXT))
+{
+ include_once(APPPATH.'config/pagination'.EXT);
+}
+
+$obj =& get_instance();
+$obj->pagination =& new CI_Pagination($config);
+
// ------------------------------------------------------------------------
/**
diff --git a/system/libraries/Parser.php b/system/libraries/Parser.php
index 63dc023a2..5bc2eb5a3 100644
--- a/system/libraries/Parser.php
+++ b/system/libraries/Parser.php
@@ -13,6 +13,11 @@
* @filesource
*/
+// INITIALIZE THE CLASS ---------------------------------------------------
+
+$obj =& get_instance();
+$obj->parser =& new CI_Parser();
+
// ------------------------------------------------------------------------
/**
diff --git a/system/libraries/Session.php b/system/libraries/Session.php
index 94efee55c..bcd2e4d7e 100644
--- a/system/libraries/Session.php
+++ b/system/libraries/Session.php
@@ -13,6 +13,11 @@
* @filesource
*/
+// INITIALIZE THE CLASS ---------------------------------------------------
+
+$obj =& get_instance();
+$obj->session =& new CI_Session();
+
// ------------------------------------------------------------------------
/**
diff --git a/system/libraries/Trackback.php b/system/libraries/Trackback.php
index 8f9680d44..9b6138453 100644
--- a/system/libraries/Trackback.php
+++ b/system/libraries/Trackback.php
@@ -13,6 +13,11 @@
* @filesource
*/
+// INITIALIZE THE CLASS ---------------------------------------------------
+
+$obj =& get_instance();
+$obj->trackback =& new CI_Trackback();
+
// ------------------------------------------------------------------------
/**
diff --git a/system/libraries/Unit_test.php b/system/libraries/Unit_test.php
index b2f4bf8cd..19fac79a7 100644
--- a/system/libraries/Unit_test.php
+++ b/system/libraries/Unit_test.php
@@ -13,6 +13,11 @@
* @filesource
*/
+// INITIALIZE THE CLASS ---------------------------------------------------
+
+$obj =& get_instance();
+$obj->unit =& new CI_Unit_test();
+
// ------------------------------------------------------------------------
/**
diff --git a/system/libraries/Upload.php b/system/libraries/Upload.php
index 98edd654f..26f216544 100644
--- a/system/libraries/Upload.php
+++ b/system/libraries/Upload.php
@@ -13,6 +13,17 @@
* @filesource
*/
+// INITIALIZE THE CLASS ---------------------------------------------------
+
+$config = array();
+if (file_exists(APPPATH.'config/upload'.EXT))
+{
+ include_once(APPPATH.'config/upload'.EXT);
+}
+
+$obj =& get_instance();
+$obj->upload = new CI_Upload($config);
+
// ------------------------------------------------------------------------
/**
diff --git a/system/libraries/Validation.php b/system/libraries/Validation.php
index b65b9be52..6c755a991 100644
--- a/system/libraries/Validation.php
+++ b/system/libraries/Validation.php
@@ -13,6 +13,11 @@
* @filesource
*/
+// INITIALIZE THE CLASS ---------------------------------------------------
+
+$obj =& get_instance();
+$obj->validation =& new CI_Validation();
+
// ------------------------------------------------------------------------
/**
diff --git a/system/libraries/Xmlrpc.php b/system/libraries/Xmlrpc.php
index 9eeb46a15..b470f720a 100644
--- a/system/libraries/Xmlrpc.php
+++ b/system/libraries/Xmlrpc.php
@@ -18,6 +18,19 @@ if ( ! function_exists('xml_parser_create'))
show_error('Your PHP installation does not support XML');
}
+// INITIALIZE THE CLASS ---------------------------------------------------
+
+$config = array();
+if (file_exists(APPPATH.'config/xmlrpc'.EXT))
+{
+ include_once(APPPATH.'config/xmlrpc'.EXT);
+}
+
+$obj =& get_instance();
+$obj->xmlrpc = new CI_XML_RPC($config);
+
+// ------------------------------------------------------------------------
+
/**
* XML-RPC request handler class
*
diff --git a/system/libraries/Xmlrpcs.php b/system/libraries/Xmlrpcs.php
index 0543c3b78..4d50dfb96 100644
--- a/system/libraries/Xmlrpcs.php
+++ b/system/libraries/Xmlrpcs.php
@@ -12,7 +12,38 @@
* @since Version 1.0
* @filesource
*/
-
+
+
+// INITIALIZE THE CLASS ---------------------------------------------------
+
+$config = array();
+if (file_exists(APPPATH.'config/xmlrpcs'.EXT))
+{
+ include_once(APPPATH.'config/xmlrpcs'.EXT);
+}
+
+if ( ! class_exists('CI_XML_RPC'))
+{
+ if ( ! file_exists(BASEPATH.'libraries/Xmlrpc'.EXT))
+ {
+ if ( ! file_exists(APPPATH.'libraries/Xmlrpc'.EXT))
+ {
+ show_error('Unable to locate the Xmlrpc class');
+ }
+ else
+ {
+ require_once(APPPATH.'libraries/Xmlrpc'.EXT);
+ }
+ }
+ else
+ {
+ require_once(BASEPATH.'libraries/Xmlrpc'.EXT);
+ }
+}
+
+$obj =& get_instance();
+$obj->xmlrpcs = new CI_XML_RPC_Server($config);
+
// ------------------------------------------------------------------------
/**
--
cgit v1.2.3-24-g4f1b
From 7981a9a752c339611ae10a252469f9dbc266fb96 Mon Sep 17 00:00:00 2001
From: admin
Date: Tue, 26 Sep 2006 07:52:09 +0000
Subject:
---
system/libraries/Calendar.php | 2 +-
system/libraries/Controller.php | 137 +++++++++++++++++++++++++++-------------
system/libraries/Email.php | 2 +-
system/libraries/Encrypt.php | 2 +-
system/libraries/Image_lib.php | 2 +-
system/libraries/Loader.php | 23 +------
system/libraries/Pagination.php | 2 +-
system/libraries/Parser.php | 2 +-
system/libraries/Session.php | 2 +-
system/libraries/Unit_test.php | 2 +-
system/libraries/Upload.php | 2 +-
system/libraries/Validation.php | 2 +-
system/libraries/Xmlrpc.php | 26 +++-----
system/libraries/Xmlrpcs.php | 57 ++++++++---------
14 files changed, 142 insertions(+), 121 deletions(-)
(limited to 'system/libraries')
diff --git a/system/libraries/Calendar.php b/system/libraries/Calendar.php
index a3c070390..bde98113a 100644
--- a/system/libraries/Calendar.php
+++ b/system/libraries/Calendar.php
@@ -16,7 +16,7 @@
// INITIALIZE THE CLASS ---------------------------------------------------
$obj =& get_instance();
-$obj->calendar =& new CI_Calendar();
+$obj->init_class('CI_Calendar');
// ------------------------------------------------------------------------
diff --git a/system/libraries/Controller.php b/system/libraries/Controller.php
index 97aa4b789..74b233ef3 100644
--- a/system/libraries/Controller.php
+++ b/system/libraries/Controller.php
@@ -32,6 +32,8 @@ class Controller extends CI_Base {
var $_ci_models = array();
var $_ci_scaffolding = FALSE;
var $_ci_scaff_table = FALSE;
+ var $_ci_last_handle = NULL;
+ var $_ci_last_params = NULL;
/**
* Constructor
@@ -63,57 +65,117 @@ class Controller extends CI_Base {
log_message('debug', "Controller Class Initialized");
}
- // END Controller()
// --------------------------------------------------------------------
/**
* Initialization Handler
*
- * Looks for the existence of a handler method and calls it
+ * Designed to be called from the class files themselves.
+ * See: http://www.codeigniter.com/user_guide/general/creating_libraries.html
+ *
+ * @access public
+ * @param string class name
+ * @param string variable name
+ * @param mixed any additional parameters
+ * @return void
+ */
+ function init_class($class, $varname = '', $params = NULL)
+ {
+ // First figure out what variable we're going to
+ // use to instantiate the class to
+ if ($varname == '')
+ {
+ $varname = ( ! is_null($this->_ci_last_handle)) ? $this->_ci_last_handle : strtolower(str_replace('CI_', '', $class));
+ }
+
+ // Are there any parameters?
+ if ($params === NULL AND $this->_ci_last_params !== NULL)
+ {
+ $params = $this->_ci_last_params;
+ }
+
+ // Instantiate the class
+ if ( ! is_null($params))
+ {
+ $this->$varname = new $class($params);
+ }
+ else
+ {
+ $this->$varname = new $class;
+ }
+
+ $this->_ci_last_params = NULL;
+ $this->_ci_last_handle = NULL;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Initialization Handler
+ *
+ * This function loads the requested class.
*
* @access private
* @param string the item that is being loaded
* @param mixed any additional parameters
* @return void
*/
- function _ci_initialize($class, $params = FALSE)
- {
+ function _ci_init_class($class, $params = NULL)
+ {
+ // Prep the class name
$class = strtolower(str_replace(EXT, '', $class));
+
+ // These are used by $this->init_class() above.
+ // They lets us dynamically set the object name and pass parameters
+ $this->_ci_last_handle = $class;
+ $this->_ci_last_params = $params;
+
+ // Does THIS file (Controller.php) contain an initialization
+ // function that maps to the requested class?
+
$method = '_ci_init_'.$class;
-
- if ( ! method_exists($this, $method))
- {
- $class = ucfirst($class);
- if ( ! file_exists(APPPATH.'libraries/'.$class.EXT))
+ if (method_exists($this, $method))
+ {
+ if (is_null($params))
{
- if ( ! file_exists(BASEPATH.'libraries/'.$class.EXT))
- {
- log_message('error', "Unable to load the requested class: ".$class);
- show_error("Unable to load the class: ".$class);
- }
-
- include_once(BASEPATH.'libraries/'.$class.EXT);
+ $this->$method();
}
else
{
- include_once(APPPATH.'libraries/'.$class.EXT);
- }
+ $this->$method($params);
+ }
+
+ // We're done...
+ return TRUE;
}
- else
+
+ // Lets search for the requested library file and load it.
+ // We'll assume that the file we load contains a call to
+ // $obj->init_class() so that the class can get instantiated.
+ // For backward compatibility we'll test for filenames that are
+ // both uppercase and lower.
+
+ foreach (array(ucfirst($class), $class) as $filename)
{
- if ($params === FALSE)
+ for ($i = 1; $i < 3; $i++)
{
- $this->$method();
- }
- else
- {
- $this->$method($params);
+ $path = ($i % 2) ? APPPATH : BASEPATH;
+
+ if (file_exists($path.'libraries/'.$filename.EXT))
+ {
+ include_once($path.'libraries/'.$filename.EXT);
+ return TRUE;
+ }
}
+
}
+
+ // If we got this far we were unable to find the requested class
+ log_message('error', "Unable to load the requested class: ".$class);
+ show_error("Unable to load the class: ".$class);
}
- // END _ci_initialize()
// --------------------------------------------------------------------
@@ -124,7 +186,7 @@ class Controller extends CI_Base {
* @param string
* @return array
*/
- function _ci_load_model($model, $name = '', $db_conn = FALSE)
+ function _ci_init_model($model, $name = '', $db_conn = FALSE)
{
if ($name == '')
{
@@ -168,9 +230,7 @@ class Controller extends CI_Base {
$this->$name = new $model();
$this->_ci_models[] = $name;
$this->_ci_assign_to_models();
- }
- // END _ci_load_model()
-
+ }
// --------------------------------------------------------------------
@@ -195,9 +255,7 @@ class Controller extends CI_Base {
{
$obj->$model->_assign_libraries();
}
- }
- // END _ci_assign_to_models()
-
+ }
// --------------------------------------------------------------------
@@ -245,13 +303,12 @@ class Controller extends CI_Base {
foreach ($autoload['libraries'] as $item)
{
- $this->_ci_initialize($item);
+ $this->_ci_init_class($item);
}
unset($autoload['libraries']);
return $autoload;
}
- // END _ci_autoload()
// --------------------------------------------------------------------
@@ -282,7 +339,6 @@ class Controller extends CI_Base {
$this->load = new CI_Loader();
}
}
- // END _ci_assign_core()
// --------------------------------------------------------------------
@@ -311,7 +367,6 @@ class Controller extends CI_Base {
$this->_ci_scaffolding = TRUE;
$this->_ci_scaff_table = $table;
}
- // END _ci_init_scaffolding()
// --------------------------------------------------------------------
@@ -324,7 +379,7 @@ class Controller extends CI_Base {
* @return void
*/
function _ci_init_database($params = '', $return = FALSE, $active_record = FALSE)
- {
+ {
if ($this->_ci_is_loaded('db') == TRUE AND $return == FALSE AND $active_record == FALSE)
{
return;
@@ -394,7 +449,6 @@ class Controller extends CI_Base {
$obj =& get_instance();
$obj->db =& $DB;
}
- // END _ci_init_database()
// --------------------------------------------------------------------
@@ -409,7 +463,6 @@ class Controller extends CI_Base {
{
return ( ! isset($this->$class) OR ! is_object($this->$class)) ? FALSE : TRUE;
}
- // END _ci_is_loaded()
// --------------------------------------------------------------------
@@ -440,13 +493,11 @@ class Controller extends CI_Base {
}
$this->_ci_init_database("", FALSE, TRUE);
-
- $this->_ci_initialize('pagination');
+ $this->_ci_init_class('pagination');
require_once(BASEPATH.'scaffolding/Scaffolding'.EXT);
$this->scaff = new Scaffolding($this->_ci_scaff_table);
$this->scaff->$method();
}
- // END _ci_scaffolding()
}
// END _Controller class
diff --git a/system/libraries/Email.php b/system/libraries/Email.php
index c153043d9..c9b9365ec 100644
--- a/system/libraries/Email.php
+++ b/system/libraries/Email.php
@@ -16,7 +16,7 @@
// INITIALIZE THE CLASS ---------------------------------------------------
$obj =& get_instance();
-$obj->email =& new CI_Email();
+$obj->init_class('CI_Email');
// ------------------------------------------------------------------------
diff --git a/system/libraries/Encrypt.php b/system/libraries/Encrypt.php
index 446f64aa6..6a3ca17b0 100644
--- a/system/libraries/Encrypt.php
+++ b/system/libraries/Encrypt.php
@@ -16,7 +16,7 @@
// INITIALIZE THE CLASS ---------------------------------------------------
$obj =& get_instance();
-$obj->encrypt =& new CI_Encrypt();
+$obj->init_class('CI_Encrypt');
// ------------------------------------------------------------------------
diff --git a/system/libraries/Image_lib.php b/system/libraries/Image_lib.php
index 86ed05943..4962760eb 100644
--- a/system/libraries/Image_lib.php
+++ b/system/libraries/Image_lib.php
@@ -22,7 +22,7 @@ if (file_exists(APPPATH.'config/image_lib'.EXT))
}
$obj =& get_instance();
-$obj->image_lib =& new CI_Image_lib($config);
+$obj->init_class('CI_Image_lib', '', $config);
// ------------------------------------------------------------------------
diff --git a/system/libraries/Loader.php b/system/libraries/Loader.php
index 7449fa34a..df067cbc1 100644
--- a/system/libraries/Loader.php
+++ b/system/libraries/Loader.php
@@ -66,13 +66,13 @@ class CI_Loader {
* @param mixed any initialization parameters
* @return void
*/
- function library($class, $param = FALSE)
+ function library($class, $param = NULL)
{
if ($class == '')
return;
$obj =& get_instance();
- $obj->_ci_initialize($class, $param);
+ $obj->_ci_init_class($class, $param);
$obj->_ci_assign_to_models();
}
// END library()
@@ -95,7 +95,7 @@ class CI_Loader {
return;
$obj =& get_instance();
- $obj->_ci_load_model($model, $name, $db_conn);
+ $obj->_ci_init_model($model, $name, $db_conn);
}
// END library()
@@ -125,23 +125,6 @@ class CI_Loader {
}
}
// END database()
-
- // --------------------------------------------------------------------
-
- /**
- * Database Utilities Loader
- *
- * @access public
- * @param string the DB platform
- * @param bool whether to return the DB object
- * @return object
- */
- function dbutil()
- {
- $obj =& get_instance();
- return $obj->_ci_init_dbutil($db, $return);
- }
- // END dbutils()
// --------------------------------------------------------------------
diff --git a/system/libraries/Pagination.php b/system/libraries/Pagination.php
index d83a2bd0f..cd55d56e0 100644
--- a/system/libraries/Pagination.php
+++ b/system/libraries/Pagination.php
@@ -22,7 +22,7 @@ if (file_exists(APPPATH.'config/pagination'.EXT))
}
$obj =& get_instance();
-$obj->pagination =& new CI_Pagination($config);
+$obj->init_class('CI_Pagination', '', $config);
// ------------------------------------------------------------------------
diff --git a/system/libraries/Parser.php b/system/libraries/Parser.php
index 5bc2eb5a3..76182271f 100644
--- a/system/libraries/Parser.php
+++ b/system/libraries/Parser.php
@@ -16,7 +16,7 @@
// INITIALIZE THE CLASS ---------------------------------------------------
$obj =& get_instance();
-$obj->parser =& new CI_Parser();
+$obj->init_class('CI_Parser');
// ------------------------------------------------------------------------
diff --git a/system/libraries/Session.php b/system/libraries/Session.php
index bcd2e4d7e..76acbfea9 100644
--- a/system/libraries/Session.php
+++ b/system/libraries/Session.php
@@ -16,7 +16,7 @@
// INITIALIZE THE CLASS ---------------------------------------------------
$obj =& get_instance();
-$obj->session =& new CI_Session();
+$obj->init_class('CI_Session');
// ------------------------------------------------------------------------
diff --git a/system/libraries/Unit_test.php b/system/libraries/Unit_test.php
index 19fac79a7..04c3c199b 100644
--- a/system/libraries/Unit_test.php
+++ b/system/libraries/Unit_test.php
@@ -16,7 +16,7 @@
// INITIALIZE THE CLASS ---------------------------------------------------
$obj =& get_instance();
-$obj->unit =& new CI_Unit_test();
+$obj->init_class('CI_Unit_test');
// ------------------------------------------------------------------------
diff --git a/system/libraries/Upload.php b/system/libraries/Upload.php
index 26f216544..3a6a6fc34 100644
--- a/system/libraries/Upload.php
+++ b/system/libraries/Upload.php
@@ -22,7 +22,7 @@ if (file_exists(APPPATH.'config/upload'.EXT))
}
$obj =& get_instance();
-$obj->upload = new CI_Upload($config);
+$obj->init_class('CI_Upload', '', $config);
// ------------------------------------------------------------------------
diff --git a/system/libraries/Validation.php b/system/libraries/Validation.php
index 6c755a991..34cacd5d8 100644
--- a/system/libraries/Validation.php
+++ b/system/libraries/Validation.php
@@ -16,7 +16,7 @@
// INITIALIZE THE CLASS ---------------------------------------------------
$obj =& get_instance();
-$obj->validation =& new CI_Validation();
+$obj->init_class('CI_Validation');
// ------------------------------------------------------------------------
diff --git a/system/libraries/Xmlrpc.php b/system/libraries/Xmlrpc.php
index b470f720a..24f79f2ba 100644
--- a/system/libraries/Xmlrpc.php
+++ b/system/libraries/Xmlrpc.php
@@ -5,7 +5,7 @@
* An open source application development framework for PHP 4.3.2 or newer
*
* @package CodeIgniter
- * @author Rick Ellis
+ * @author Rick Ellis, Paul Burdick
* @copyright Copyright (c) 2006, pMachine, Inc.
* @license http://www.codeignitor.com/user_guide/license.html
* @link http://www.codeigniter.com
@@ -20,14 +20,8 @@ if ( ! function_exists('xml_parser_create'))
// INITIALIZE THE CLASS ---------------------------------------------------
-$config = array();
-if (file_exists(APPPATH.'config/xmlrpc'.EXT))
-{
- include_once(APPPATH.'config/xmlrpc'.EXT);
-}
-
$obj =& get_instance();
-$obj->xmlrpc = new CI_XML_RPC($config);
+$obj->init_class('CI_Xmlrpc');
// ------------------------------------------------------------------------
@@ -40,7 +34,7 @@ $obj->xmlrpc = new CI_XML_RPC($config);
* @author Paul Burdick
* @link http://www.codeigniter.com/user_guide/libraries/xmlrpc.html
*/
-class CI_XML_RPC {
+class CI_Xmlrpc {
var $debug = FALSE; // Debugging on or off
var $xmlrpcI4 = 'i4';
@@ -78,7 +72,7 @@ class CI_XML_RPC {
// VALUES THAT MULTIPLE CLASSES NEED
//-------------------------------------
- function CI_XML_RPC ($config = array())
+ function CI_Xmlrpc ($config = array())
{
$this->xmlrpcName = $this->xmlrpcName;
@@ -351,7 +345,7 @@ class CI_XML_RPC {
* @author Paul Burdick
* @link http://www.codeigniter.com/user_guide/libraries/xmlrpc.html
*/
-class XML_RPC_Client extends CI_XML_RPC
+class XML_RPC_Client extends CI_Xmlrpc
{
var $path = '';
var $server = '';
@@ -363,7 +357,7 @@ class XML_RPC_Client extends CI_XML_RPC
function XML_RPC_Client($path, $server, $port=80)
{
- parent::CI_XML_RPC();
+ parent::CI_Xmlrpc();
$this->port = $port;
$this->server = $server;
@@ -609,7 +603,7 @@ class XML_RPC_Response
* @author Paul Burdick
* @link http://www.codeigniter.com/user_guide/libraries/xmlrpc.html
*/
-class XML_RPC_Message extends CI_XML_RPC
+class XML_RPC_Message extends CI_Xmlrpc
{
var $payload;
var $method_name;
@@ -618,7 +612,7 @@ class XML_RPC_Message extends CI_XML_RPC
function XML_RPC_Message($method, $pars=0)
{
- parent::CI_XML_RPC();
+ parent::CI_Xmlrpc();
$this->method_name = $method;
if (is_array($pars) && sizeof($pars) > 0)
@@ -1206,14 +1200,14 @@ class XML_RPC_Message extends CI_XML_RPC
* @author Paul Burdick
* @link http://www.codeigniter.com/user_guide/libraries/xmlrpc.html
*/
-class XML_RPC_Values extends CI_XML_RPC
+class XML_RPC_Values extends CI_Xmlrpc
{
var $me = array();
var $mytype = 0;
function XML_RPC_Values($val=-1, $type='')
{
- parent::CI_XML_RPC();
+ parent::CI_Xmlrpc();
if ($val != -1 || $type != '')
{
diff --git a/system/libraries/Xmlrpcs.php b/system/libraries/Xmlrpcs.php
index 4d50dfb96..a95764a98 100644
--- a/system/libraries/Xmlrpcs.php
+++ b/system/libraries/Xmlrpcs.php
@@ -5,7 +5,7 @@
* An open source application development framework for PHP 4.3.2 or newer
*
* @package CodeIgniter
- * @author Rick Ellis
+ * @author Rick Ellis, Paul Burdick
* @copyright Copyright (c) 2006, pMachine, Inc.
* @license http://www.codeignitor.com/user_guide/license.html
* @link http://www.codeigniter.com
@@ -13,36 +13,18 @@
* @filesource
*/
+if ( ! function_exists('xml_parser_create'))
+{
+ show_error('Your PHP installation does not support XML');
+}
+
// INITIALIZE THE CLASS ---------------------------------------------------
-$config = array();
-if (file_exists(APPPATH.'config/xmlrpcs'.EXT))
-{
- include_once(APPPATH.'config/xmlrpcs'.EXT);
-}
+require_once(BASEPATH.'libraries/Xmlrpc'.EXT);
-if ( ! class_exists('CI_XML_RPC'))
-{
- if ( ! file_exists(BASEPATH.'libraries/Xmlrpc'.EXT))
- {
- if ( ! file_exists(APPPATH.'libraries/Xmlrpc'.EXT))
- {
- show_error('Unable to locate the Xmlrpc class');
- }
- else
- {
- require_once(APPPATH.'libraries/Xmlrpc'.EXT);
- }
- }
- else
- {
- require_once(BASEPATH.'libraries/Xmlrpc'.EXT);
- }
-}
-
-$obj =& get_instance();
-$obj->xmlrpcs = new CI_XML_RPC_Server($config);
+// The initialization code is at the bottom of this file. It seems to
+// cause an error to have it at the top
// ------------------------------------------------------------------------
@@ -55,7 +37,7 @@ $obj->xmlrpcs = new CI_XML_RPC_Server($config);
* @author Paul Burdick
* @link http://www.codeigniter.com/user_guide/libraries/xmlrpc.html
*/
-class CI_XML_RPC_Server extends CI_XML_RPC
+class CI_Xmlrpcs extends CI_Xmlrpc
{
var $methods = array(); //array of methods mapped to function names and signatures
var $debug_msg = ''; // Debug Message
@@ -67,9 +49,9 @@ class CI_XML_RPC_Server extends CI_XML_RPC
// Constructor, more or less
//-------------------------------------
- function CI_XML_RPC_Server($config=array())
+ function CI_Xmlrpcs($config=array())
{
- parent::CI_XML_RPC();
+ parent::CI_Xmlrpc();
$this->set_system_methods();
if (isset($config['functions']) && is_array($config['functions']))
@@ -235,7 +217,7 @@ class CI_XML_RPC_Server extends CI_XML_RPC
echo "";
}
- $r = $this->execute($m);
+ $r = $this->_execute($m);
}
//-------------------------------------
@@ -508,7 +490,7 @@ class CI_XML_RPC_Server extends CI_XML_RPC
$msg->params[] = $params->me['array'][$i];
}
- $result = $this->execute($msg);
+ $result = $this->_execute($msg);
if ($result->faultCode() != 0)
{
@@ -520,4 +502,15 @@ class CI_XML_RPC_Server extends CI_XML_RPC
}
// END XML_RPC_Server class
+
+
+// INITIALIZE THE CLASS ---------------------------------------------------
+
+$obj =& get_instance();
+$obj->init_class('CI_Xmlrpc');
+$obj->init_class('CI_Xmlrpcs');
+
+// ------------------------------------------------------------------------
+
+
?>
\ No newline at end of file
--
cgit v1.2.3-24-g4f1b
From 6e00bab0ecfbbdd35d135a297d54a4989a44e500 Mon Sep 17 00:00:00 2001
From: admin
Date: Tue, 26 Sep 2006 08:13:06 +0000
Subject:
---
system/libraries/Controller.php | 28 +++++++++++++++++++++++-
system/libraries/Loader.php | 47 ++++++++++++++++++++++++-----------------
2 files changed, 55 insertions(+), 20 deletions(-)
(limited to 'system/libraries')
diff --git a/system/libraries/Controller.php b/system/libraries/Controller.php
index 74b233ef3..9d858e6c2 100644
--- a/system/libraries/Controller.php
+++ b/system/libraries/Controller.php
@@ -301,9 +301,18 @@ class Controller extends CI_Base {
}
+ $exceptions = array('dbutil', 'dbexport');
+
foreach ($autoload['libraries'] as $item)
{
- $this->_ci_init_class($item);
+ if ( ! in_array($item, $exceptions))
+ {
+ $this->_ci_init_class($item);
+ }
+ else
+ {
+ $this->_ci_init_dbextra($item);
+ }
}
unset($autoload['libraries']);
@@ -452,6 +461,23 @@ class Controller extends CI_Base {
// --------------------------------------------------------------------
+ /**
+ * Initialize Database Ancillary Classes
+ *
+ * @access private
+ * @param str class name
+ * @return void
+ */
+ function _ci_init_dbextra($class)
+ {
+ $map = array('dbutil' => 'DB_utility', 'dbexport' => 'DB_export');
+ require_once(BASEPATH.'database/'.$map[$class].EXT);
+
+ $this->init_class('CI_'.$map[$class], $class);
+ }
+
+ // --------------------------------------------------------------------
+
/**
* Returns TRUE if a class is loaded, FALSE if not
*
diff --git a/system/libraries/Loader.php b/system/libraries/Loader.php
index df067cbc1..90d824049 100644
--- a/system/libraries/Loader.php
+++ b/system/libraries/Loader.php
@@ -51,7 +51,6 @@ class CI_Loader {
log_message('debug', "Loader Class Initialized");
}
- // END CI_Loader()
// --------------------------------------------------------------------
@@ -75,7 +74,6 @@ class CI_Loader {
$obj->_ci_init_class($class, $param);
$obj->_ci_assign_to_models();
}
- // END library()
// --------------------------------------------------------------------
@@ -97,7 +95,6 @@ class CI_Loader {
$obj =& get_instance();
$obj->_ci_init_model($model, $name, $db_conn);
}
- // END library()
// --------------------------------------------------------------------
@@ -124,10 +121,37 @@ class CI_Loader {
$obj->_ci_assign_to_models();
}
}
- // END database()
// --------------------------------------------------------------------
+ /**
+ * Database Utiliy Loader
+ *
+ * @access public
+ * @return object
+ */
+ function dbutil()
+ {
+ $obj =& get_instance();
+ $obj->_ci_init_dbextra('dbutil');
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Database Export Loader
+ *
+ * @access public
+ * @return object
+ */
+ function dbexport()
+ {
+ $obj =& get_instance();
+ $obj->_ci_init_dbextra('dbexport');
+ }
+
+ // --------------------------------------------------------------------
+
/**
* Scaffolding Loader
*
@@ -145,7 +169,6 @@ class CI_Loader {
$obj =& get_instance();
$obj->_ci_init_scaffolding($table);
}
- // END scaffolding()
// --------------------------------------------------------------------
@@ -170,7 +193,6 @@ class CI_Loader {
{
return $this->_ci_load(array('view' => $view, 'vars' => $this->_ci_object_to_array($vars), 'return' => $return));
}
- // END view()
// --------------------------------------------------------------------
@@ -188,7 +210,6 @@ class CI_Loader {
{
return $this->_ci_load(array('path' => $path, 'return' => $return));
}
- // END file()
// --------------------------------------------------------------------
@@ -214,7 +235,6 @@ class CI_Loader {
}
}
}
- // END vars()
// --------------------------------------------------------------------
@@ -264,7 +284,6 @@ class CI_Loader {
log_message('debug', 'Helpers loaded: '.implode(', ', $helpers));
}
- // END helper()
// --------------------------------------------------------------------
@@ -282,7 +301,6 @@ class CI_Loader {
{
$this->helper($helpers);
}
- // END helpers()
// --------------------------------------------------------------------
@@ -332,7 +350,6 @@ class CI_Loader {
log_message('debug', 'Plugins loaded: '.implode(', ', $plugins));
}
- // END plugin()
// --------------------------------------------------------------------
@@ -377,7 +394,6 @@ class CI_Loader {
log_message('debug', 'Scripts loaded: '.implode(', ', $scripts));
}
- // END script()
// --------------------------------------------------------------------
@@ -395,7 +411,6 @@ class CI_Loader {
{
$this->plugin($plugins);
}
- // END plugins()
// --------------------------------------------------------------------
@@ -411,7 +426,6 @@ class CI_Loader {
$obj =& get_instance();
return $obj->lang->load($file, $lang, $return);
}
- // END language()
// --------------------------------------------------------------------
@@ -427,7 +441,6 @@ class CI_Loader {
$obj =& get_instance();
$obj->config->load($file);
}
- // END config()
// --------------------------------------------------------------------
@@ -442,7 +455,6 @@ class CI_Loader {
{
$this->view_path = $path;
}
- // END _ci_set_view_path()
// --------------------------------------------------------------------
@@ -553,7 +565,6 @@ class CI_Loader {
ob_end_clean();
}
}
- // END _load()
// --------------------------------------------------------------------
@@ -582,7 +593,6 @@ class CI_Loader {
}
}
}
- // END _ci_autoloader()
// --------------------------------------------------------------------
@@ -599,7 +609,6 @@ class CI_Loader {
{
return (is_object($object)) ? get_object_vars($object) : $object;
}
- // END _ci_object_to_array()
}
?>
\ No newline at end of file
--
cgit v1.2.3-24-g4f1b
From 41a1685573aa0ede15a9bf7b373c36a0406fb19d Mon Sep 17 00:00:00 2001
From: admin
Date: Tue, 26 Sep 2006 18:17:19 +0000
Subject:
---
system/libraries/Controller.php | 4 +---
system/libraries/Email.php | 8 +++++++-
2 files changed, 8 insertions(+), 4 deletions(-)
(limited to 'system/libraries')
diff --git a/system/libraries/Controller.php b/system/libraries/Controller.php
index 9d858e6c2..23c050e18 100644
--- a/system/libraries/Controller.php
+++ b/system/libraries/Controller.php
@@ -82,8 +82,7 @@ class Controller extends CI_Base {
*/
function init_class($class, $varname = '', $params = NULL)
{
- // First figure out what variable we're going to
- // use to instantiate the class to
+ // First figure out what variable we're going to assign the class to
if ($varname == '')
{
$varname = ( ! is_null($this->_ci_last_handle)) ? $this->_ci_last_handle : strtolower(str_replace('CI_', '', $class));
@@ -156,7 +155,6 @@ class Controller extends CI_Base {
// $obj->init_class() so that the class can get instantiated.
// For backward compatibility we'll test for filenames that are
// both uppercase and lower.
-
foreach (array(ucfirst($class), $class) as $filename)
{
for ($i = 1; $i < 3; $i++)
diff --git a/system/libraries/Email.php b/system/libraries/Email.php
index c9b9365ec..fd3fb8f17 100644
--- a/system/libraries/Email.php
+++ b/system/libraries/Email.php
@@ -15,8 +15,14 @@
// INITIALIZE THE CLASS ---------------------------------------------------
+$config = array();
+if (file_exists(APPPATH.'config/email'.EXT))
+{
+ include_once(APPPATH.'config/email'.EXT);
+}
+
$obj =& get_instance();
-$obj->init_class('CI_Email');
+$obj->init_class('CI_Email', 'email', $config);
// ------------------------------------------------------------------------
--
cgit v1.2.3-24-g4f1b
From e5bb936f808bfd39a6ba8cbe1fc2ddbcf9bf502f Mon Sep 17 00:00:00 2001
From: admin
Date: Wed, 27 Sep 2006 00:31:22 +0000
Subject:
---
system/libraries/Controller.php | 20 ++++++++++++++++----
system/libraries/Xmlrpcs.php | 20 ++++++--------------
2 files changed, 22 insertions(+), 18 deletions(-)
(limited to 'system/libraries')
diff --git a/system/libraries/Controller.php b/system/libraries/Controller.php
index 23c050e18..56b4d6f90 100644
--- a/system/libraries/Controller.php
+++ b/system/libraries/Controller.php
@@ -468,10 +468,22 @@ class Controller extends CI_Base {
*/
function _ci_init_dbextra($class)
{
- $map = array('dbutil' => 'DB_utility', 'dbexport' => 'DB_export');
- require_once(BASEPATH.'database/'.$map[$class].EXT);
-
- $this->init_class('CI_'.$map[$class], $class);
+ if ( ! $this->_ci_is_loaded('db'))
+ {
+ $this->_init_database();
+ }
+
+ if ($class == 'dbutil')
+ {
+ require_once(BASEPATH.'database/DB_utility'.EXT);
+ require_once(BASEPATH.'database/drivers/'.$this->db->dbdriver.'/'.$this->db->dbdriver.'_utility'.EXT);
+ $this->init_class('CI_DB_'.$this->db->dbdriver.'_utility', 'dbutil');
+ }
+ elseif ($class == 'dbexport')
+ {
+ require_once(BASEPATH.'database/DB_export'.EXT);
+ $this->init_class('CI_DB_export', 'dbexport');
+ }
}
// --------------------------------------------------------------------
diff --git a/system/libraries/Xmlrpcs.php b/system/libraries/Xmlrpcs.php
index a95764a98..f41437342 100644
--- a/system/libraries/Xmlrpcs.php
+++ b/system/libraries/Xmlrpcs.php
@@ -18,13 +18,15 @@ if ( ! function_exists('xml_parser_create'))
show_error('Your PHP installation does not support XML');
}
+if ( ! class_exists('CI_Xmlrpc'))
+{
+ show_error('You must load the Xmlrpc class before loading the Xmlrpcs class in order to create a server.');
+}
// INITIALIZE THE CLASS ---------------------------------------------------
-require_once(BASEPATH.'libraries/Xmlrpc'.EXT);
-
-// The initialization code is at the bottom of this file. It seems to
-// cause an error to have it at the top
+$obj =& get_instance();
+$obj->init_class('CI_Xmlrpcs');
// ------------------------------------------------------------------------
@@ -503,14 +505,4 @@ class CI_Xmlrpcs extends CI_Xmlrpc
}
// END XML_RPC_Server class
-
-// INITIALIZE THE CLASS ---------------------------------------------------
-
-$obj =& get_instance();
-$obj->init_class('CI_Xmlrpc');
-$obj->init_class('CI_Xmlrpcs');
-
-// ------------------------------------------------------------------------
-
-
?>
\ No newline at end of file
--
cgit v1.2.3-24-g4f1b
From 17a890df20b56c8d82812f365f27bc590be009f3 Mon Sep 17 00:00:00 2001
From: admin
Date: Wed, 27 Sep 2006 20:42:42 +0000
Subject:
---
system/libraries/Router.php | 20 +++++++++++++++++---
1 file changed, 17 insertions(+), 3 deletions(-)
(limited to 'system/libraries')
diff --git a/system/libraries/Router.php b/system/libraries/Router.php
index d7740f5f3..34a2512a6 100644
--- a/system/libraries/Router.php
+++ b/system/libraries/Router.php
@@ -65,7 +65,9 @@ class CI_Router {
*/
function _set_route_mapping()
{
- // Are query strings enabled? If so we're done...
+
+ // Are query strings enabled in the config file?
+ // If so, we're done since segment based URIs are not used with query strings.
if ($this->config->item('enable_query_strings') === TRUE AND isset($_GET[$this->config->item('controller_trigger')]))
{
$this->set_class($_GET[$this->config->item('controller_trigger')]);
@@ -78,15 +80,26 @@ class CI_Router {
return;
}
- // Load the routes.php file and set the default controller
+ // Load the routes.php file.
@include_once(APPPATH.'config/routes'.EXT);
$this->routes = ( ! isset($route) OR ! is_array($route)) ? array() : $route;
unset($route);
+ // Set the default controller so we can display it in the event
+ // the URI doesn't correlated to a valid controller.
$this->default_controller = ( ! isset($this->routes['default_controller']) OR $this->routes['default_controller'] == '') ? FALSE : strtolower($this->routes['default_controller']);
+ // Fetch the complete URI string
+ $this->uri_string = $this->_get_uri_string();
+
+ // If the URI contains only a slash we'll kill it
+ if ($this->uri_string == '/')
+ {
+ $this->uri_string = '';
+ }
+
// Is there a URI string? If not, the default controller specified in the "routes" file will be shown.
- if (($this->uri_string = $this->_get_uri_string()) == '')
+ if ($this->uri_string == '')
{
if ($this->default_controller === FALSE)
{
@@ -107,6 +120,7 @@ class CI_Router {
$this->uri_string = preg_replace("|".preg_quote($this->config->item('url_suffix'))."$|", "", $this->uri_string);
}
+
// Explode the URI Segments. The individual segments will
// be stored in the $this->segments array.
foreach(explode("/", preg_replace("|/*(.+?)/*$|", "\\1", $this->uri_string)) as $val)
--
cgit v1.2.3-24-g4f1b
From 33de9a144aad28763405f8ae2d5c59df5e929b4f Mon Sep 17 00:00:00 2001
From: admin
Date: Thu, 28 Sep 2006 06:50:16 +0000
Subject:
---
system/libraries/Benchmark.php | 9 ---
system/libraries/Calendar.php | 5 --
system/libraries/Controller.php | 165 ++++++++++++++++++++++++----------------
system/libraries/Email.php | 11 ---
system/libraries/Encrypt.php | 5 --
system/libraries/Hooks.php | 2 +-
system/libraries/Image_lib.php | 11 ---
system/libraries/Input.php | 2 +-
system/libraries/Loader.php | 2 +-
system/libraries/Output.php | 4 +-
system/libraries/Pagination.php | 11 ---
system/libraries/Parser.php | 5 --
system/libraries/Router.php | 21 +----
system/libraries/Session.php | 5 --
system/libraries/Trackback.php | 5 --
system/libraries/URI.php | 2 +-
system/libraries/Unit_test.php | 5 --
system/libraries/Upload.php | 11 ---
system/libraries/Validation.php | 5 --
system/libraries/Xmlrpc.php | 4 -
system/libraries/Xmlrpcs.php | 5 --
21 files changed, 109 insertions(+), 186 deletions(-)
(limited to 'system/libraries')
diff --git a/system/libraries/Benchmark.php b/system/libraries/Benchmark.php
index 9dd9d4ac4..d8dd903e7 100644
--- a/system/libraries/Benchmark.php
+++ b/system/libraries/Benchmark.php
@@ -31,15 +31,6 @@ class CI_Benchmark {
var $marker = array();
- /**
- * Constructor
- *
- * @access public
- */
- function CI_Benchmark()
- {
- }
- // END CI_Benchmark()
// --------------------------------------------------------------------
diff --git a/system/libraries/Calendar.php b/system/libraries/Calendar.php
index bde98113a..8c7d95aa5 100644
--- a/system/libraries/Calendar.php
+++ b/system/libraries/Calendar.php
@@ -13,11 +13,6 @@
* @filesource
*/
-// INITIALIZE THE CLASS ---------------------------------------------------
-
-$obj =& get_instance();
-$obj->init_class('CI_Calendar');
-
// ------------------------------------------------------------------------
/**
diff --git a/system/libraries/Controller.php b/system/libraries/Controller.php
index 56b4d6f90..aa7b87b00 100644
--- a/system/libraries/Controller.php
+++ b/system/libraries/Controller.php
@@ -32,8 +32,6 @@ class Controller extends CI_Base {
var $_ci_models = array();
var $_ci_scaffolding = FALSE;
var $_ci_scaff_table = FALSE;
- var $_ci_last_handle = NULL;
- var $_ci_last_params = NULL;
/**
* Constructor
@@ -68,48 +66,6 @@ class Controller extends CI_Base {
// --------------------------------------------------------------------
- /**
- * Initialization Handler
- *
- * Designed to be called from the class files themselves.
- * See: http://www.codeigniter.com/user_guide/general/creating_libraries.html
- *
- * @access public
- * @param string class name
- * @param string variable name
- * @param mixed any additional parameters
- * @return void
- */
- function init_class($class, $varname = '', $params = NULL)
- {
- // First figure out what variable we're going to assign the class to
- if ($varname == '')
- {
- $varname = ( ! is_null($this->_ci_last_handle)) ? $this->_ci_last_handle : strtolower(str_replace('CI_', '', $class));
- }
-
- // Are there any parameters?
- if ($params === NULL AND $this->_ci_last_params !== NULL)
- {
- $params = $this->_ci_last_params;
- }
-
- // Instantiate the class
- if ( ! is_null($params))
- {
- $this->$varname = new $class($params);
- }
- else
- {
- $this->$varname = new $class;
- }
-
- $this->_ci_last_params = NULL;
- $this->_ci_last_handle = NULL;
- }
-
- // --------------------------------------------------------------------
-
/**
* Initialization Handler
*
@@ -120,15 +76,21 @@ class Controller extends CI_Base {
* @param mixed any additional parameters
* @return void
*/
- function _ci_init_class($class, $params = NULL)
+ function _ci_load_class($class, $params = NULL)
{
// Prep the class name
$class = strtolower(str_replace(EXT, '', $class));
-
- // These are used by $this->init_class() above.
- // They lets us dynamically set the object name and pass parameters
- $this->_ci_last_handle = $class;
- $this->_ci_last_params = $params;
+
+ // Is this a class extension request?
+ if (substr($class, 0, 3) == 'my_')
+ {
+ $class = preg_replace("/my_(.+)/", "\\1", $class);
+ $extend = TRUE;
+ }
+ else
+ {
+ $extend = FALSE;
+ }
// Does THIS file (Controller.php) contain an initialization
// function that maps to the requested class?
@@ -150,30 +112,101 @@ class Controller extends CI_Base {
return TRUE;
}
- // Lets search for the requested library file and load it.
- // We'll assume that the file we load contains a call to
- // $obj->init_class() so that the class can get instantiated.
- // For backward compatibility we'll test for filenames that are
- // both uppercase and lower.
- foreach (array(ucfirst($class), $class) as $filename)
+ // Are we extending one of the base classes?
+ if ($extend == TRUE)
{
- for ($i = 1; $i < 3; $i++)
+ // Load the requested library from the main system/libraries folder
+ if (file_exists(BASEPATH.'libraries/'.ucfirst($class).EXT))
{
- $path = ($i % 2) ? APPPATH : BASEPATH;
+ include_once(BASEPATH.'libraries/'.ucfirst($class).EXT);
+ }
- if (file_exists($path.'libraries/'.$filename.EXT))
+ // Now look for a matching library
+ foreach (array(ucfirst($class), $class) as $filename)
+ {
+ if (file_exists(APPPATH.'libraries/'.$filename.EXT))
{
- include_once($path.'libraries/'.$filename.EXT);
- return TRUE;
+ include_once(APPPATH.'libraries/'.$filename.EXT);
+ }
+ }
+
+ return $this->_ci_init_class($filename, 'MY_', $params);
+ }
+ else
+ {
+ // Lets search for the requested library file and load it.
+ // For backward compatibility we'll test for filenames that are
+ // both uppercase and lower.
+ foreach (array(ucfirst($class), $class) as $filename)
+ {
+ for ($i = 1; $i < 3; $i++)
+ {
+ $path = ($i % 2) ? APPPATH : BASEPATH;
+
+ if (file_exists($path.'libraries/'.$filename.EXT))
+ {
+ include_once($path.'libraries/'.$filename.EXT);
+ return $this->_ci_init_class($filename, '', $params);
+ }
}
}
-
}
// If we got this far we were unable to find the requested class
log_message('error', "Unable to load the requested class: ".$class);
show_error("Unable to load the class: ".$class);
}
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Instantiates a class
+ *
+ * @access private
+ * @param string
+ * @param string
+ * @return null
+ */
+ function _ci_init_class($class, $prefix = '', $config = NULL)
+ {
+ // Is there an associated config file for this class?
+
+ if ($config == NULL)
+ {
+ if (file_exists(APPPATH.'config/'.$class.EXT))
+ {
+ include_once(APPPATH.'config/'.$class.EXT);
+ }
+ }
+
+ if ($prefix == '')
+ {
+ $name = ( ! class_exists($class)) ? 'CI_'.$class : $class;
+ }
+ else
+ {
+ $name = $prefix.ucfirst($class);
+ }
+
+ $remap = array(
+ 'DB_export' => 'dbexport',
+ 'DB_utility' => 'dbutility',
+ 'Encryption' => 'encrypt',
+ 'Unit_test' => 'unit'
+ );
+
+ $varname = ( ! isset($remap[$class])) ? $class : $remap[$class];
+
+ // Instantiate the class
+ if ($config !== NULL)
+ {
+ $this->$varname = new $name($config);
+ }
+ else
+ {
+ $this->$varname = new $name;
+ }
+ }
// --------------------------------------------------------------------
@@ -305,7 +338,7 @@ class Controller extends CI_Base {
{
if ( ! in_array($item, $exceptions))
{
- $this->_ci_init_class($item);
+ $this->_ci_load_class($item);
}
else
{
@@ -334,10 +367,10 @@ class Controller extends CI_Base {
foreach (array('Config', 'Input', 'Benchmark', 'URI', 'Output') as $val)
{
$class = strtolower($val);
- $this->$class =& _load_class('CI_'.$val);
+ $this->$class =& _load_class($val);
}
- $this->lang =& _load_class('CI_Language');
+ $this->lang =& _load_class('Language');
// In PHP 4 the Controller class is a child of CI_Loader.
// In PHP 5 we run it as its own class.
@@ -529,7 +562,7 @@ class Controller extends CI_Base {
}
$this->_ci_init_database("", FALSE, TRUE);
- $this->_ci_init_class('pagination');
+ $this->_ci_load_class('pagination');
require_once(BASEPATH.'scaffolding/Scaffolding'.EXT);
$this->scaff = new Scaffolding($this->_ci_scaff_table);
$this->scaff->$method();
diff --git a/system/libraries/Email.php b/system/libraries/Email.php
index fd3fb8f17..5b991d1fa 100644
--- a/system/libraries/Email.php
+++ b/system/libraries/Email.php
@@ -13,17 +13,6 @@
* @filesource
*/
-// INITIALIZE THE CLASS ---------------------------------------------------
-
-$config = array();
-if (file_exists(APPPATH.'config/email'.EXT))
-{
- include_once(APPPATH.'config/email'.EXT);
-}
-
-$obj =& get_instance();
-$obj->init_class('CI_Email', 'email', $config);
-
// ------------------------------------------------------------------------
/**
diff --git a/system/libraries/Encrypt.php b/system/libraries/Encrypt.php
index 6a3ca17b0..abc769460 100644
--- a/system/libraries/Encrypt.php
+++ b/system/libraries/Encrypt.php
@@ -12,11 +12,6 @@
* @since Version 1.0
* @filesource
*/
-
-// INITIALIZE THE CLASS ---------------------------------------------------
-
-$obj =& get_instance();
-$obj->init_class('CI_Encrypt');
// ------------------------------------------------------------------------
diff --git a/system/libraries/Hooks.php b/system/libraries/Hooks.php
index 7ff0592ff..69ca1a9f1 100644
--- a/system/libraries/Hooks.php
+++ b/system/libraries/Hooks.php
@@ -41,7 +41,7 @@ class CI_Hooks {
{
log_message('debug', "Hooks Class Initialized");
- $CFG =& _load_class('CI_Config');
+ $CFG =& _load_class('Config');
// If hooks are not enabled in the config file
// there is nothing else to do
diff --git a/system/libraries/Image_lib.php b/system/libraries/Image_lib.php
index 4962760eb..18e3253f7 100644
--- a/system/libraries/Image_lib.php
+++ b/system/libraries/Image_lib.php
@@ -13,17 +13,6 @@
* @filesource
*/
-// INITIALIZE THE CLASS ---------------------------------------------------
-
-$config = array();
-if (file_exists(APPPATH.'config/image_lib'.EXT))
-{
- include_once(APPPATH.'config/image_lib'.EXT);
-}
-
-$obj =& get_instance();
-$obj->init_class('CI_Image_lib', '', $config);
-
// ------------------------------------------------------------------------
/**
diff --git a/system/libraries/Input.php b/system/libraries/Input.php
index dbf939b18..ad7b0c571 100644
--- a/system/libraries/Input.php
+++ b/system/libraries/Input.php
@@ -42,7 +42,7 @@ class CI_Input {
*/
function CI_Input()
{
- $CFG =& _load_class('CI_Config');
+ $CFG =& _load_class('Config');
$this->use_xss_clean = ($CFG->item('global_xss_filtering') === TRUE) ? TRUE : FALSE;
$this->allow_get_array = ($CFG->item('enable_query_strings') === TRUE) ? TRUE : FALSE;
diff --git a/system/libraries/Loader.php b/system/libraries/Loader.php
index 90d824049..fff9e78d3 100644
--- a/system/libraries/Loader.php
+++ b/system/libraries/Loader.php
@@ -71,7 +71,7 @@ class CI_Loader {
return;
$obj =& get_instance();
- $obj->_ci_init_class($class, $param);
+ $obj->_ci_load_class($class, $param);
$obj->_ci_assign_to_models();
}
diff --git a/system/libraries/Output.php b/system/libraries/Output.php
index 5a158245f..1c3f0d604 100644
--- a/system/libraries/Output.php
+++ b/system/libraries/Output.php
@@ -237,8 +237,8 @@ class CI_Output {
*/
function _display_cache(&$CFG, &$RTR)
{
- $CFG =& _load_class('CI_Config');
- $RTR =& _load_class('CI_Router');
+ $CFG =& _load_class('Config');
+ $RTR =& _load_class('Router');
$cache_path = ($CFG->item('cache_path') == '') ? BASEPATH.'cache/' : $CFG->item('cache_path');
diff --git a/system/libraries/Pagination.php b/system/libraries/Pagination.php
index cd55d56e0..867d214fc 100644
--- a/system/libraries/Pagination.php
+++ b/system/libraries/Pagination.php
@@ -12,17 +12,6 @@
* @since Version 1.0
* @filesource
*/
-
-// INITIALIZE THE CLASS ---------------------------------------------------
-
-$config = array();
-if (file_exists(APPPATH.'config/pagination'.EXT))
-{
- include_once(APPPATH.'config/pagination'.EXT);
-}
-
-$obj =& get_instance();
-$obj->init_class('CI_Pagination', '', $config);
// ------------------------------------------------------------------------
diff --git a/system/libraries/Parser.php b/system/libraries/Parser.php
index 76182271f..42e78b0ee 100644
--- a/system/libraries/Parser.php
+++ b/system/libraries/Parser.php
@@ -12,11 +12,6 @@
* @since Version 1.0
* @filesource
*/
-
-// INITIALIZE THE CLASS ---------------------------------------------------
-
-$obj =& get_instance();
-$obj->init_class('CI_Parser');
// ------------------------------------------------------------------------
diff --git a/system/libraries/Router.php b/system/libraries/Router.php
index 34a2512a6..c056530a3 100644
--- a/system/libraries/Router.php
+++ b/system/libraries/Router.php
@@ -33,6 +33,7 @@ class CI_Router {
var $segments = array();
var $rsegments = array();
var $routes = array();
+ var $error_routes = array();
var $class = '';
var $method = 'index';
var $directory = '';
@@ -47,7 +48,7 @@ class CI_Router {
*/
function CI_Router()
{
- $this->config =& _load_class('CI_Config');
+ $this->config =& _load_class('Config');
$this->_set_route_mapping();
log_message('debug', "Router Class Initialized");
}
@@ -87,8 +88,8 @@ class CI_Router {
// Set the default controller so we can display it in the event
// the URI doesn't correlated to a valid controller.
- $this->default_controller = ( ! isset($this->routes['default_controller']) OR $this->routes['default_controller'] == '') ? FALSE : strtolower($this->routes['default_controller']);
-
+ $this->default_controller = ( ! isset($this->routes['default_controller']) OR $this->routes['default_controller'] == '') ? FALSE : strtolower($this->routes['default_controller']);
+
// Fetch the complete URI string
$this->uri_string = $this->_get_uri_string();
@@ -138,7 +139,6 @@ class CI_Router {
// Re-index the segment array so that it starts with 1 rather than 0
$this->_reindex_segments();
}
- // END _set_route_mapping()
// --------------------------------------------------------------------
@@ -185,7 +185,6 @@ class CI_Router {
// identical to $this->segments
$this->rsegments = $segments;
}
- // END _compile_segments()
// --------------------------------------------------------------------
@@ -240,7 +239,6 @@ class CI_Router {
// Can't find the requested controller...
show_404();
}
- // END _validate_segments()
// --------------------------------------------------------------------
/**
@@ -280,7 +278,6 @@ class CI_Router {
unset($this->rsegments[0]);
}
}
- // END _reindex_segments()
// --------------------------------------------------------------------
@@ -333,7 +330,6 @@ class CI_Router {
return getenv($uri);
}
}
- // END _get_uri_string()
// --------------------------------------------------------------------
@@ -381,7 +377,6 @@ class CI_Router {
return $parsed_uri;
}
- // END _parse_request_uri()
// --------------------------------------------------------------------
@@ -403,7 +398,6 @@ class CI_Router {
}
return $str;
}
- // END _filter_uri()
// --------------------------------------------------------------------
@@ -461,7 +455,6 @@ class CI_Router {
// matching route so we'll set the site default route
$this->_compile_segments($this->segments);
}
- // END set_method()
// --------------------------------------------------------------------
@@ -476,7 +469,6 @@ class CI_Router {
{
$this->class = $class;
}
- // END set_class()
// --------------------------------------------------------------------
@@ -490,7 +482,6 @@ class CI_Router {
{
return $this->class;
}
- // END fetch_class()
// --------------------------------------------------------------------
@@ -505,7 +496,6 @@ class CI_Router {
{
$this->method = $method;
}
- // END set_method()
// --------------------------------------------------------------------
@@ -519,7 +509,6 @@ class CI_Router {
{
return $this->method;
}
- // END fetch_method()
// --------------------------------------------------------------------
@@ -534,7 +523,6 @@ class CI_Router {
{
$this->directory = $dir.'/';
}
- // END set_directory()
// --------------------------------------------------------------------
@@ -548,7 +536,6 @@ class CI_Router {
{
return $this->directory;
}
- // END fetch_directory()
}
// END Router Class
diff --git a/system/libraries/Session.php b/system/libraries/Session.php
index 76acbfea9..28e469da7 100644
--- a/system/libraries/Session.php
+++ b/system/libraries/Session.php
@@ -12,11 +12,6 @@
* @since Version 1.0
* @filesource
*/
-
-// INITIALIZE THE CLASS ---------------------------------------------------
-
-$obj =& get_instance();
-$obj->init_class('CI_Session');
// ------------------------------------------------------------------------
diff --git a/system/libraries/Trackback.php b/system/libraries/Trackback.php
index 9b6138453..8b6cce16d 100644
--- a/system/libraries/Trackback.php
+++ b/system/libraries/Trackback.php
@@ -12,11 +12,6 @@
* @since Version 1.0
* @filesource
*/
-
-// INITIALIZE THE CLASS ---------------------------------------------------
-
-$obj =& get_instance();
-$obj->trackback =& new CI_Trackback();
// ------------------------------------------------------------------------
diff --git a/system/libraries/URI.php b/system/libraries/URI.php
index 89ca42e44..80b112660 100644
--- a/system/libraries/URI.php
+++ b/system/libraries/URI.php
@@ -42,7 +42,7 @@ class CI_URI {
*/
function CI_URI()
{
- $this->router =& _load_class('CI_Router');
+ $this->router =& _load_class('Router');
log_message('debug', "URI Class Initialized");
}
diff --git a/system/libraries/Unit_test.php b/system/libraries/Unit_test.php
index 04c3c199b..b2f4bf8cd 100644
--- a/system/libraries/Unit_test.php
+++ b/system/libraries/Unit_test.php
@@ -13,11 +13,6 @@
* @filesource
*/
-// INITIALIZE THE CLASS ---------------------------------------------------
-
-$obj =& get_instance();
-$obj->init_class('CI_Unit_test');
-
// ------------------------------------------------------------------------
/**
diff --git a/system/libraries/Upload.php b/system/libraries/Upload.php
index 3a6a6fc34..091c6c30d 100644
--- a/system/libraries/Upload.php
+++ b/system/libraries/Upload.php
@@ -12,17 +12,6 @@
* @since Version 1.0
* @filesource
*/
-
-// INITIALIZE THE CLASS ---------------------------------------------------
-
-$config = array();
-if (file_exists(APPPATH.'config/upload'.EXT))
-{
- include_once(APPPATH.'config/upload'.EXT);
-}
-
-$obj =& get_instance();
-$obj->init_class('CI_Upload', '', $config);
// ------------------------------------------------------------------------
diff --git a/system/libraries/Validation.php b/system/libraries/Validation.php
index 34cacd5d8..80ee6a533 100644
--- a/system/libraries/Validation.php
+++ b/system/libraries/Validation.php
@@ -12,11 +12,6 @@
* @since Version 1.0
* @filesource
*/
-
-// INITIALIZE THE CLASS ---------------------------------------------------
-
-$obj =& get_instance();
-$obj->init_class('CI_Validation');
// ------------------------------------------------------------------------
diff --git a/system/libraries/Xmlrpc.php b/system/libraries/Xmlrpc.php
index 24f79f2ba..f90785430 100644
--- a/system/libraries/Xmlrpc.php
+++ b/system/libraries/Xmlrpc.php
@@ -18,10 +18,6 @@ if ( ! function_exists('xml_parser_create'))
show_error('Your PHP installation does not support XML');
}
-// INITIALIZE THE CLASS ---------------------------------------------------
-
-$obj =& get_instance();
-$obj->init_class('CI_Xmlrpc');
// ------------------------------------------------------------------------
diff --git a/system/libraries/Xmlrpcs.php b/system/libraries/Xmlrpcs.php
index f41437342..b47104857 100644
--- a/system/libraries/Xmlrpcs.php
+++ b/system/libraries/Xmlrpcs.php
@@ -23,11 +23,6 @@ if ( ! class_exists('CI_Xmlrpc'))
show_error('You must load the Xmlrpc class before loading the Xmlrpcs class in order to create a server.');
}
-// INITIALIZE THE CLASS ---------------------------------------------------
-
-$obj =& get_instance();
-$obj->init_class('CI_Xmlrpcs');
-
// ------------------------------------------------------------------------
/**
--
cgit v1.2.3-24-g4f1b
From 4ce59da7905eca21a6cc3be04adfbcab672a9969 Mon Sep 17 00:00:00 2001
From: admin
Date: Thu, 28 Sep 2006 07:45:59 +0000
Subject:
---
system/libraries/Controller.php | 20 +++++++++++++++++---
1 file changed, 17 insertions(+), 3 deletions(-)
(limited to 'system/libraries')
diff --git a/system/libraries/Controller.php b/system/libraries/Controller.php
index aa7b87b00..f00a7262b 100644
--- a/system/libraries/Controller.php
+++ b/system/libraries/Controller.php
@@ -219,6 +219,20 @@ class Controller extends CI_Base {
*/
function _ci_init_model($model, $name = '', $db_conn = FALSE)
{
+ // Is the model in a sub-folder?
+ // If so, parse out the filename and path.
+ if (strpos($model, '/') === FALSE)
+ {
+ $path = '';
+ }
+ else
+ {
+ $x = explode('/', $model);
+ $model = end($x);
+ unset($x[count($x)-1]);
+ $path = implode('/', $x).'/';
+ }
+
if ($name == '')
{
$name = $model;
@@ -237,11 +251,11 @@ class Controller extends CI_Base {
$model = strtolower($model);
- if ( ! file_exists(APPPATH.'models/'.$model.EXT))
+ if ( ! file_exists(APPPATH.'models/'.$path.$model.EXT))
{
show_error('Unable to locate the model you have specified: '.$model);
}
-
+
if ($db_conn !== FALSE)
{
if ($db_conn === TRUE)
@@ -255,7 +269,7 @@ class Controller extends CI_Base {
require_once(BASEPATH.'libraries/Model'.EXT);
}
- require_once(APPPATH.'models/'.$model.EXT);
+ require_once(APPPATH.'models/'.$path.$model.EXT);
$model = ucfirst($model);
$this->$name = new $model();
--
cgit v1.2.3-24-g4f1b
From e721cc7c81af84dcabce2992fa693ce36b605a19 Mon Sep 17 00:00:00 2001
From: admin
Date: Thu, 28 Sep 2006 16:47:05 +0000
Subject:
---
system/libraries/Unit_test.php | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
(limited to 'system/libraries')
diff --git a/system/libraries/Unit_test.php b/system/libraries/Unit_test.php
index b2f4bf8cd..d3e151328 100644
--- a/system/libraries/Unit_test.php
+++ b/system/libraries/Unit_test.php
@@ -57,8 +57,8 @@ class CI_Unit_test {
if ($this->active == FALSE)
return;
- if (in_array($expected, array('is_string', 'is_bool', 'is_true', 'is_false', 'is_int', 'is_numeric', 'is_float', 'is_double', 'is_array', 'is_null')))
- {
+ if ($expected !== 0 AND in_array($expected, array('is_string', 'is_bool', 'is_true', 'is_false', 'is_int', 'is_numeric', 'is_float', 'is_double', 'is_array', 'is_null')))
+ {
$expected = str_replace('is_float', 'is_double', $expected);
$result = ($expected($test)) ? TRUE : FALSE;
$extype = str_replace(array('true', 'false'), 'bool', str_replace('is_', '', $expected));
--
cgit v1.2.3-24-g4f1b
From ee54c112bfb488f833fa032758b817e1bb2c1d7d Mon Sep 17 00:00:00 2001
From: admin
Date: Thu, 28 Sep 2006 17:13:38 +0000
Subject:
---
system/libraries/Calendar.php | 4 ++--
system/libraries/Config.php | 2 +-
system/libraries/Controller.php | 6 +++---
system/libraries/Email.php | 6 +++---
system/libraries/Image_lib.php | 2 +-
system/libraries/Language.php | 2 +-
system/libraries/Unit_test.php | 2 +-
system/libraries/Upload.php | 4 ++--
system/libraries/Validation.php | 6 +++---
system/libraries/Xmlrpc.php | 2 +-
10 files changed, 18 insertions(+), 18 deletions(-)
(limited to 'system/libraries')
diff --git a/system/libraries/Calendar.php b/system/libraries/Calendar.php
index 8c7d95aa5..8cf151703 100644
--- a/system/libraries/Calendar.php
+++ b/system/libraries/Calendar.php
@@ -48,7 +48,7 @@ class CI_Calendar {
function CI_Calendar()
{
$this->obj =& get_instance();
- if ( ! in_array('calendar_lang'.EXT, $this->obj->lang->is_loaded))
+ if ( ! in_array('calendar_lang'.EXT, $this->obj->lang->is_loaded, TRUE))
{
$this->obj->lang->load('calendar');
}
@@ -458,7 +458,7 @@ class CI_Calendar {
}
else
{
- if (in_array($val, $today))
+ if (in_array($val, $today, TRUE))
{
$this->temp[$val] = $this->temp[str_replace('_today', '', $val)];
}
diff --git a/system/libraries/Config.php b/system/libraries/Config.php
index 108c94ab7..26770cc4f 100644
--- a/system/libraries/Config.php
+++ b/system/libraries/Config.php
@@ -63,7 +63,7 @@ class CI_Config {
{
$file = ($file == '') ? 'config' : str_replace(EXT, '', $file);
- if (in_array($file, $this->is_loaded))
+ if (in_array($file, $this->is_loaded, TRUE))
{
return TRUE;
}
diff --git a/system/libraries/Controller.php b/system/libraries/Controller.php
index f00a7262b..ff914d131 100644
--- a/system/libraries/Controller.php
+++ b/system/libraries/Controller.php
@@ -239,7 +239,7 @@ class Controller extends CI_Base {
}
$obj =& get_instance();
- if (in_array($name, $obj->_ci_models))
+ if (in_array($name, $obj->_ci_models, TRUE))
{
return;
}
@@ -350,7 +350,7 @@ class Controller extends CI_Base {
foreach ($autoload['libraries'] as $item)
{
- if ( ! in_array($item, $exceptions))
+ if ( ! in_array($item, $exceptions, TRUE))
{
$this->_ci_load_class($item);
}
@@ -566,7 +566,7 @@ class Controller extends CI_Base {
if (class_exists('Scaffolding')) return;
- if ( ! in_array($this->uri->segment(3), array('add', 'insert', 'edit', 'update', 'view', 'delete', 'do_delete')))
+ if ( ! in_array($this->uri->segment(3), array('add', 'insert', 'edit', 'update', 'view', 'delete', 'do_delete'), TRUE))
{
$method = 'view';
}
diff --git a/system/libraries/Email.php b/system/libraries/Email.php
index 5b991d1fa..55edd6216 100644
--- a/system/libraries/Email.php
+++ b/system/libraries/Email.php
@@ -467,7 +467,7 @@ class CI_Email {
*/
function set_protocol($protocol = 'mail')
{
- $this->protocol = ( ! in_array($protocol, $this->_protocols)) ? 'mail' : strtolower($protocol);
+ $this->protocol = ( ! in_array($protocol, $this->_protocols, TRUE)) ? 'mail' : strtolower($protocol);
}
// END set_protocol()
@@ -564,7 +564,7 @@ class CI_Email {
function _get_protocol($return = true)
{
$this->protocol = strtolower($this->protocol);
- $this->protocol = ( ! in_array($this->protocol, $this->_protocols)) ? 'mail' : $this->protocol;
+ $this->protocol = ( ! in_array($this->protocol, $this->_protocols, TRUE)) ? 'mail' : $this->protocol;
if ($return == true)
return $this->protocol;
@@ -584,7 +584,7 @@ class CI_Email {
{
$this->_encoding = ( ! in_array($this->_encoding, $this->_bit_depths)) ? '7bit' : $this->_encoding;
- if ( ! in_array($this->charset, $this->_base_charsets))
+ if ( ! in_array($this->charset, $this->_base_charsets, TRUE))
$this->_encoding = "8bit";
if ($return == true)
diff --git a/system/libraries/Image_lib.php b/system/libraries/Image_lib.php
index 18e3253f7..ca1d7478b 100644
--- a/system/libraries/Image_lib.php
+++ b/system/libraries/Image_lib.php
@@ -398,7 +398,7 @@ class CI_Image_lib {
// Allowed rotation values
$degs = array(90, 180, 270, 'vrt', 'hor');
- if ($this->rotation_angle == '' OR ! in_array($this->rotation_angle, $degs))
+ if ($this->rotation_angle == '' OR ! in_array($this->rotation_angle, $degs, TRUE))
{
$this->set_error('imglib_rotation_angle_required');
return FALSE;
diff --git a/system/libraries/Language.php b/system/libraries/Language.php
index 41dab46f4..dabfd4145 100644
--- a/system/libraries/Language.php
+++ b/system/libraries/Language.php
@@ -54,7 +54,7 @@ class CI_Language {
{
$langfile = str_replace(EXT, '', str_replace('_lang.', '', $langfile)).'_lang'.EXT;
- if (in_array($langfile, $this->is_loaded))
+ if (in_array($langfile, $this->is_loaded, TRUE))
{
return;
}
diff --git a/system/libraries/Unit_test.php b/system/libraries/Unit_test.php
index d3e151328..78b92edb2 100644
--- a/system/libraries/Unit_test.php
+++ b/system/libraries/Unit_test.php
@@ -57,7 +57,7 @@ class CI_Unit_test {
if ($this->active == FALSE)
return;
- if ($expected !== 0 AND in_array($expected, array('is_string', 'is_bool', 'is_true', 'is_false', 'is_int', 'is_numeric', 'is_float', 'is_double', 'is_array', 'is_null')))
+ if (in_array($expected, array('is_string', 'is_bool', 'is_true', 'is_false', 'is_int', 'is_numeric', 'is_float', 'is_double', 'is_array', 'is_null'), TRUE))
{
$expected = str_replace('is_float', 'is_double', $expected);
$result = ($expected($test)) ? TRUE : FALSE;
diff --git a/system/libraries/Upload.php b/system/libraries/Upload.php
index 091c6c30d..37fccdfd8 100644
--- a/system/libraries/Upload.php
+++ b/system/libraries/Upload.php
@@ -454,7 +454,7 @@ class CI_Upload {
);
- return (in_array($this->file_type, $img_mimes)) ? TRUE : FALSE;
+ return (in_array($this->file_type, $img_mimes, TRUE)) ? TRUE : FALSE;
}
// --------------------------------------------------------------------
@@ -479,7 +479,7 @@ class CI_Upload {
if (is_array($mime))
{
- if (in_array($this->file_type, $mime))
+ if (in_array($this->file_type, $mime, TRUE))
{
return TRUE;
}
diff --git a/system/libraries/Validation.php b/system/libraries/Validation.php
index 80ee6a533..7db67a3e1 100644
--- a/system/libraries/Validation.php
+++ b/system/libraries/Validation.php
@@ -187,7 +187,7 @@ class CI_Validation {
$ex = explode('|', $rules);
// Is the field required? If not, if the field is blank we'll move on to the next text
- if ( ! in_array('required', $ex) AND strpos($rules, 'callback_') === FALSE)
+ if ( ! in_array('required', $ex, TRUE) AND strpos($rules, 'callback_') === FALSE)
{
if ( ! isset($_POST[$field]) OR $_POST[$field] == '')
{
@@ -206,7 +206,7 @@ class CI_Validation {
*/
if ( ! isset($_POST[$field]))
{
- if (in_array('isset', $ex) OR in_array('required', $ex))
+ if (in_array('isset', $ex, TRUE) OR in_array('required', $ex))
{
if ( ! isset($this->_error_messages['isset']))
{
@@ -268,7 +268,7 @@ class CI_Validation {
$result = $this->obj->$rule($_POST[$field], $param);
// If the field isn't required and we just processed a callback we'll move on...
- if ( ! in_array('required', $ex) AND $result !== FALSE)
+ if ( ! in_array('required', $ex, TRUE) AND $result !== FALSE)
{
continue 2;
}
diff --git a/system/libraries/Xmlrpc.php b/system/libraries/Xmlrpc.php
index f90785430..4cb16f74e 100644
--- a/system/libraries/Xmlrpc.php
+++ b/system/libraries/Xmlrpc.php
@@ -854,7 +854,7 @@ class XML_RPC_Message extends CI_Xmlrpc
else
{
// not top level element: see if parent is OK
- if (!in_array($this->xh[$the_parser]['stack'][0], $this->valid_parents[$name]))
+ if (!in_array($this->xh[$the_parser]['stack'][0], $this->valid_parents[$name], TRUE))
{
$this->xh[$the_parser]['isf'] = 2;
$this->xh[$the_parser]['isf_reason'] = "XML-RPC element $name cannot be child of ".$this->xh[$the_parser]['stack'][0];
--
cgit v1.2.3-24-g4f1b
From 4a2ed69c3af500ca51bddcc9b6c54bebb2bfeae8 Mon Sep 17 00:00:00 2001
From: admin
Date: Fri, 29 Sep 2006 01:14:52 +0000
Subject:
---
system/libraries/Controller.php | 1 -
1 file changed, 1 deletion(-)
(limited to 'system/libraries')
diff --git a/system/libraries/Controller.php b/system/libraries/Controller.php
index ff914d131..be66b19b7 100644
--- a/system/libraries/Controller.php
+++ b/system/libraries/Controller.php
@@ -191,7 +191,6 @@ class Controller extends CI_Base {
$remap = array(
'DB_export' => 'dbexport',
'DB_utility' => 'dbutility',
- 'Encryption' => 'encrypt',
'Unit_test' => 'unit'
);
--
cgit v1.2.3-24-g4f1b
From 3ed8c51254a5b26d951fa675802fcf69adf9638e Mon Sep 17 00:00:00 2001
From: admin
Date: Fri, 29 Sep 2006 23:26:28 +0000
Subject:
---
system/libraries/Controller.php | 12 +++---------
system/libraries/Encrypt.php | 35 ++++++++++++++++++++---------------
system/libraries/Loader.php | 14 --------------
3 files changed, 23 insertions(+), 38 deletions(-)
(limited to 'system/libraries')
diff --git a/system/libraries/Controller.php b/system/libraries/Controller.php
index be66b19b7..51f455023 100644
--- a/system/libraries/Controller.php
+++ b/system/libraries/Controller.php
@@ -189,8 +189,6 @@ class Controller extends CI_Base {
}
$remap = array(
- 'DB_export' => 'dbexport',
- 'DB_utility' => 'dbutility',
'Unit_test' => 'unit'
);
@@ -516,19 +514,15 @@ class Controller extends CI_Base {
{
if ( ! $this->_ci_is_loaded('db'))
{
- $this->_init_database();
+ $this->_ci_init_database();
}
if ($class == 'dbutil')
{
require_once(BASEPATH.'database/DB_utility'.EXT);
require_once(BASEPATH.'database/drivers/'.$this->db->dbdriver.'/'.$this->db->dbdriver.'_utility'.EXT);
- $this->init_class('CI_DB_'.$this->db->dbdriver.'_utility', 'dbutil');
- }
- elseif ($class == 'dbexport')
- {
- require_once(BASEPATH.'database/DB_export'.EXT);
- $this->init_class('CI_DB_export', 'dbexport');
+ $class = 'CI_DB_'.$this->db->dbdriver.'_utility';
+ $this->dbutil = new $class();
}
}
diff --git a/system/libraries/Encrypt.php b/system/libraries/Encrypt.php
index abc769460..537b1ab20 100644
--- a/system/libraries/Encrypt.php
+++ b/system/libraries/Encrypt.php
@@ -27,6 +27,7 @@
* @link http://www.codeigniter.com/user_guide/libraries/encryption.html
*/
class CI_Encrypt {
+ var $encryption_key = '';
var $_hash_type = 'sha1';
var $_mcrypt_exists = FALSE;
var $_mcrypt_cipher;
@@ -43,7 +44,6 @@ class CI_Encrypt {
$this->_mcrypt_exists = ( ! function_exists('mcrypt_encrypt')) ? FALSE : TRUE;
log_message('debug', "Encrypt Class Initialized");
}
- // END CI_Encrypt()
// --------------------------------------------------------------------
@@ -61,6 +61,11 @@ class CI_Encrypt {
{
if ($key == '')
{
+ if ($this->encryption_key != '')
+ {
+ return $this->encryption_key;
+ }
+
$obj =& get_instance();
$key = $obj->config->item('encryption_key');
@@ -72,7 +77,20 @@ class CI_Encrypt {
return md5($key);
}
- // END get_key()
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Set the encryption key
+ *
+ * @access public
+ * @param string
+ * @return void
+ */
+ function set_key($key = '')
+ {
+ $this->encryption_key = $key;
+ }
// --------------------------------------------------------------------
@@ -103,7 +121,6 @@ class CI_Encrypt {
}
return base64_encode($enc);
}
- // END encode()
// --------------------------------------------------------------------
@@ -134,7 +151,6 @@ class CI_Encrypt {
return $this->_xor_decode($dec, $key);
}
- // END decode()
// --------------------------------------------------------------------
@@ -167,7 +183,6 @@ class CI_Encrypt {
return $this->_xor_merge($enc, $key);
}
- // END _xor_encode()
// --------------------------------------------------------------------
@@ -194,7 +209,6 @@ class CI_Encrypt {
return $dec;
}
- // END _xor_decode()
// --------------------------------------------------------------------
@@ -219,7 +233,6 @@ class CI_Encrypt {
return $str;
}
- // END _xor_merge()
// --------------------------------------------------------------------
@@ -238,7 +251,6 @@ class CI_Encrypt {
$init_vect = mcrypt_create_iv($init_size, MCRYPT_RAND);
return mcrypt_encrypt($this->_mcrypt_cipher, $key, $data, $this->_mcrypt_mode, $init_vect);
}
- // END mcrypt_encode()
// --------------------------------------------------------------------
@@ -257,7 +269,6 @@ class CI_Encrypt {
$init_vect = mcrypt_create_iv($init_size, MCRYPT_RAND);
return rtrim(mcrypt_decrypt($this->_mcrypt_cipher, $key, $data, $this->_mcrypt_mode, $init_vect), "\0");
}
- // END mcrypt_decode()
// --------------------------------------------------------------------
@@ -272,7 +283,6 @@ class CI_Encrypt {
{
$this->_mcrypt_cipher = $cypher;
}
- // END set_cypher()
// --------------------------------------------------------------------
@@ -287,7 +297,6 @@ class CI_Encrypt {
{
$this->_mcrypt_mode = $mode;
}
- // END set_mode()
// --------------------------------------------------------------------
@@ -309,7 +318,6 @@ class CI_Encrypt {
$this->_mcrypt_mode = MCRYPT_MODE_ECB;
}
}
- // END _get_mcrypt()
// --------------------------------------------------------------------
@@ -324,7 +332,6 @@ class CI_Encrypt {
{
$this->_hash_type = ($type != 'sha1' AND $type != 'md5') ? 'sha1' : $type;
}
- // END set_hash()
// --------------------------------------------------------------------
@@ -339,7 +346,6 @@ class CI_Encrypt {
{
return ($this->_hash_type == 'sha1') ? $this->sha1($str) : md5($str);
}
- // END hash()
// --------------------------------------------------------------------
@@ -370,7 +376,6 @@ class CI_Encrypt {
return sha1($str);
}
}
- // END sha1()
}
diff --git a/system/libraries/Loader.php b/system/libraries/Loader.php
index fff9e78d3..2534e6965 100644
--- a/system/libraries/Loader.php
+++ b/system/libraries/Loader.php
@@ -135,20 +135,6 @@ class CI_Loader {
$obj =& get_instance();
$obj->_ci_init_dbextra('dbutil');
}
-
- // --------------------------------------------------------------------
-
- /**
- * Database Export Loader
- *
- * @access public
- * @return object
- */
- function dbexport()
- {
- $obj =& get_instance();
- $obj->_ci_init_dbextra('dbexport');
- }
// --------------------------------------------------------------------
--
cgit v1.2.3-24-g4f1b
From ae58a5de4fc040847c43209173dbc7f1193f6c53 Mon Sep 17 00:00:00 2001
From: admin
Date: Sat, 30 Sep 2006 19:25:07 +0000
Subject:
---
system/libraries/Zip.php | 154 +++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 154 insertions(+)
create mode 100644 system/libraries/Zip.php
(limited to 'system/libraries')
diff --git a/system/libraries/Zip.php b/system/libraries/Zip.php
new file mode 100644
index 000000000..9cfe9593d
--- /dev/null
+++ b/system/libraries/Zip.php
@@ -0,0 +1,154 @@
+cdata[] = $fd;
+
+ $cd = "\x50\x4b\x01\x02\x00\x00\x0a\x00\x00\x00\x00\x00\x00\x00\x00\x00"
+ .pack("V", 0)
+ .pack("V", 0)
+ .pack("V", 0)
+ .pack("v", strlen ($name))
+ .pack("v", 0)
+ .pack("v", 0)
+ .pack("v", 0)
+ .pack("v", 0)
+ .pack("V", 16)
+ .pack("V", $this->offset)
+ .$name;
+
+ $this->offset = strlen(implode('', $this->cdata));
+
+ $this->cdir[] = $cd;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Add a File
+ *
+ * @access public
+ * @param string
+ * @return void
+ */
+ function add_file($data, $name)
+ {
+ $name = str_replace("\\", "/", $name);
+
+ $u_len = strlen($data);
+ $crc = crc32($data);
+ $data = gzcompress($data);
+ $data = substr(substr($data, 0,strlen ($data) - 4), 2);
+ $c_len = strlen($data);
+
+ $fd = "\x50\x4b\x03\x04\x14\x00\x00\x00\x08\x00\x00\x00\x00\x00"
+ .pack("V", $crc)
+ .pack("V", $c_len)
+ .pack("V", $u_len)
+ .pack("v", strlen($name))
+ .pack("v", 0)
+ .$name
+ .$data
+ .pack("V", $crc)
+ .pack("V", $c_len)
+ .pack("V", $u_len);
+
+ $this->zdata[] = $fd;
+
+ $cd = "\x50\x4b\x01\x02\x00\x00\x14\x00\x00\x00\x08\x00\x00\x00\x00\x00"
+ .pack("V", $crc)
+ .pack("V", $c_len)
+ .pack("V", $u_len)
+ .pack("v", strlen ($name))
+ .pack("v", 0)
+ .pack("v", 0)
+ .pack("v", 0)
+ .pack("v", 0)
+ .pack("V", 32 )
+ .pack("V", $this->offset)
+ .$name;
+
+ $this->offset = strlen(implode('', $this->zdata));
+
+ $this->cdir[] = $cd;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Output the zip file
+ *
+ * @access public
+ * @return string
+ */
+ function output_zipfile()
+ {
+ $data = implode("", $this->zdata);
+ $cdir = implode("", $this->cdir);
+
+ return $data
+ .$cdir
+ ."\x50\x4b\x05\x06\x00\x00\x00\x00"
+ .pack("v", sizeof($this->cdir))
+ .pack("v", sizeof($this->cdir))
+ .pack("V", strlen($cdir))
+ .pack("V", strlen($data))
+ ."\x00\x00";
+ }
+
+}
+// END CLASS
+?>
\ No newline at end of file
--
cgit v1.2.3-24-g4f1b
From c8b7bdab0d17319c4f4c7860c7d41bb6efcf17c1 Mon Sep 17 00:00:00 2001
From: admin
Date: Sat, 30 Sep 2006 19:26:08 +0000
Subject:
---
system/libraries/Zip.php | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
(limited to 'system/libraries')
diff --git a/system/libraries/Zip.php b/system/libraries/Zip.php
index 9cfe9593d..1fd0e7059 100644
--- a/system/libraries/Zip.php
+++ b/system/libraries/Zip.php
@@ -21,7 +21,8 @@
* This class is based on a library aquired at Zend:
* http://www.zend.com/codex.php?id=696&single=1
*
- * I'm not sure this library is all that reliable, but it's the only
+ * I'm not sure this library is all that reliable, and the
+ * directory feature doesn't seem to work right, but it's the only
* zip compressor I'm aware of -- Rick Ellis
*
* @package CodeIgniter
--
cgit v1.2.3-24-g4f1b
From 6ae57e09a1c9570a6d1f4b2410313715095a7e62 Mon Sep 17 00:00:00 2001
From: admin
Date: Sun, 1 Oct 2006 07:59:45 +0000
Subject:
---
system/libraries/Zip.php | 296 +++++++++++++++++++++++++++++++----------------
1 file changed, 196 insertions(+), 100 deletions(-)
(limited to 'system/libraries')
diff --git a/system/libraries/Zip.php b/system/libraries/Zip.php
index 1fd0e7059..aa264386d 100644
--- a/system/libraries/Zip.php
+++ b/system/libraries/Zip.php
@@ -21,9 +21,6 @@
* This class is based on a library aquired at Zend:
* http://www.zend.com/codex.php?id=696&single=1
*
- * I'm not sure this library is all that reliable, and the
- * directory feature doesn't seem to work right, but it's the only
- * zip compressor I'm aware of -- Rick Ellis
*
* @package CodeIgniter
* @subpackage Libraries
@@ -31,125 +28,224 @@
* @author Rick Ellis
* @link http://www.codeigniter.com/user_guide/general/encryption.html
*/
-class Zip {
-
- var $zdata = array();
- var $cdir = array();
- var $offset = 0;
+class Zip {
+
+ var $zipdata = array();
+ var $directory = array();
+ var $offset = 0;
+ var $zipfile = '';
/**
- * Add a Directory
+ * Add Directory
+ *
+ * Lets you add a virtual directory into which you can place files.
*
* @access public
- * @param string
+ * @param string the directory name
* @return void
- */
- function add_dir($name)
- {
- $name =str_replace ("\\", "/", $name);
-
- $fd = "\x50\x4b\x03\x04\x0a\x00\x00\x00\x00\x00\x00\x00\x00\x00"
- .pack("V", 0)
- .pack("V", 0)
- .pack("V", 0)
- .pack("v", strlen($name))
- .pack("v", 0)
- .$name;
-
- $this->cdata[] = $fd;
-
- $cd = "\x50\x4b\x01\x02\x00\x00\x0a\x00\x00\x00\x00\x00\x00\x00\x00\x00"
- .pack("V", 0)
- .pack("V", 0)
- .pack("V", 0)
- .pack("v", strlen ($name))
- .pack("v", 0)
- .pack("v", 0)
- .pack("v", 0)
- .pack("v", 0)
- .pack("V", 16)
- .pack("V", $this->offset)
- .$name;
-
- $this->offset = strlen(implode('', $this->cdata));
-
- $this->cdir[] = $cd;
- }
+ */
+ function add_dir($dir)
+ {
+ $this->zipfile = '';
+
+ $dir = str_replace("\\", "/", $dir);
+
+ $this->zipdata[] = "\x50\x4b\x03\x04\x0a\x00\x00\x00\x00\x00\x00\x00\x00\x00"
+ .pack('V', 0)
+ .pack('V', 0)
+ .pack('V', 0)
+ .pack('v', strlen($dir))
+ .pack('v', 0)
+ .$dir
+ .pack('V', 0)
+ .pack('V', 0)
+ .pack('V', 0);
+
+ $newoffset = strlen(implode('', $this->zipdata));
+
+ $record = "\x50\x4b\x01\x02\x00\x00\x0a\x00\x00\x00\x00\x00\x00\x00\x00\x00"
+ .pack('V',0)
+ .pack('V',0)
+ .pack('V',0)
+ .pack('v', strlen($dir))
+ .pack('v', 0)
+ .pack('v', 0)
+ .pack('v', 0)
+ .pack('v', 0)
+ .pack('V', 16)
+ .pack('V', $this->offset)
+ .$dir;
+
+ $this->offset = $newoffset;
+ $this->directory[] = $record;
+ }
// --------------------------------------------------------------------
/**
- * Add a File
+ * Add File
+ *
+ * Lets you add files to the archive. If the path is included
+ * in the filename it will be placed within a directory. Make
+ * sure you use add_dir() first to create the folder.
*
* @access public
- * @param string
+ * @param string the file name
+ * @param string the data to be encoded
* @return void
*/
- function add_file($data, $name)
- {
- $name = str_replace("\\", "/", $name);
-
- $u_len = strlen($data);
- $crc = crc32($data);
- $data = gzcompress($data);
- $data = substr(substr($data, 0,strlen ($data) - 4), 2);
- $c_len = strlen($data);
-
- $fd = "\x50\x4b\x03\x04\x14\x00\x00\x00\x08\x00\x00\x00\x00\x00"
- .pack("V", $crc)
- .pack("V", $c_len)
- .pack("V", $u_len)
- .pack("v", strlen($name))
- .pack("v", 0)
- .$name
- .$data
- .pack("V", $crc)
- .pack("V", $c_len)
- .pack("V", $u_len);
-
- $this->zdata[] = $fd;
-
- $cd = "\x50\x4b\x01\x02\x00\x00\x14\x00\x00\x00\x08\x00\x00\x00\x00\x00"
- .pack("V", $crc)
- .pack("V", $c_len)
- .pack("V", $u_len)
- .pack("v", strlen ($name))
- .pack("v", 0)
- .pack("v", 0)
- .pack("v", 0)
- .pack("v", 0)
- .pack("V", 32 )
- .pack("V", $this->offset)
- .$name;
-
- $this->offset = strlen(implode('', $this->zdata));
-
- $this->cdir[] = $cd;
- }
+ function add_file($filename, $data)
+ {
+ $this->zipfile = '';
+
+ $filename = str_replace("\\", "/", $filename);
+
+ $oldlen = strlen($data);
+ $crc32 = crc32($data);
+
+ $gzdata = gzcompress($data);
+ $gzdata = substr(substr($gzdata, 0, strlen($gzdata) - 4), 2);
+ $newlen = strlen($gzdata);
+
+ $this->zipdata[] = "\x50\x4b\x03\x04\x14\x00\x00\x00\x08\x00\x00\x00\x00\x00"
+ .pack('V', $crc32)
+ .pack('V', $newlen)
+ .pack('V', $oldlen)
+ .pack('v', strlen($filename))
+ .pack('v', 0)
+ .$filename
+ .$gzdata
+ .pack('V', $crc32)
+ .pack('V', $newlen)
+ .pack('V', $oldlen);
+
+ $newoffset = strlen(implode("", $this->zipdata));
+
+ $record = "\x50\x4b\x01\x02\x00\x00\x14\x00\x00\x00\x08\x00\x00\x00\x00\x00"
+ .pack('V', $crc32)
+ .pack('V', $newlen)
+ .pack('V', $oldlen)
+ .pack('v', strlen($filename))
+ .pack('v', 0)
+ .pack('v', 0)
+ .pack('v', 0)
+ .pack('v', 0)
+ .pack('V', 32)
+ .pack('V', $this->offset);
+
+ $this->offset = $newoffset;
+ $this->directory[] = $record.$filename;
+ }
// --------------------------------------------------------------------
/**
- * Output the zip file
+ * Read the content of a file
*
* @access public
+ * @param string the file path
* @return string
*/
- function output_zipfile()
- {
- $data = implode("", $this->zdata);
- $cdir = implode("", $this->cdir);
+ function read_file($filepath)
+ {
+ if ( ! file_exists($filepath))
+ {
+ return FALSE;
+ }
+
+ return file_get_contents($filepath);
+ }
+
+ // --------------------------------------------------------------------
- return $data
- .$cdir
- ."\x50\x4b\x05\x06\x00\x00\x00\x00"
- .pack("v", sizeof($this->cdir))
- .pack("v", sizeof($this->cdir))
- .pack("V", strlen($cdir))
- .pack("V", strlen($data))
- ."\x00\x00";
- }
+ /**
+ * Get the Zip file
+ *
+ * @access public
+ * @return binary string
+ */
+ function get_zip()
+ {
+ if ($this->zipfile != '')
+ {
+ return $this->zipfile;
+ }
+
+ $data = implode('', $this->zipdata);
+ $dir = implode('', $this->directory);
+
+ $this->zipfile = $data.$dir."\x50\x4b\x05\x06\x00\x00\x00\x00"
+ .pack('v', sizeof($this->directory))
+ .pack('v', sizeof($this->directory))
+ .pack('V', strlen($dir))
+ .pack('V', strlen($data))
+ ."\x00\x00";
+
+ return $this->zipfile;
+ }
+
+ // --------------------------------------------------------------------
+ /**
+ * Write File
+ *
+ * Lets you write a file
+ *
+ * @access public
+ * @param string the file name
+ * @param string the data to be encoded
+ * @return bool
+ */
+ function write_file($filename, $data)
+ {
+ if ( ! ($fp = fopen($filename, "wb")))
+ {
+ return FALSE;
+ }
+
+ flock($fp, LOCK_EX);
+ fwrite($fp, $data);
+ flock($fp, LOCK_UN);
+ fclose($fp);
+
+ return TRUE;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Download
+ *
+ *
+ * @access public
+ * @param string the file name
+ * @param string the data to be encoded
+ * @return bool
+ */
+ function download($filename, $data)
+ {
+ if (strstr($_SERVER['HTTP_USER_AGENT'], "MSIE"))
+ {
+ header('Content-Type: application/x-zip');
+ header('Content-Disposition: inline; filename="'.$filename.'"');
+ header('Expires: 0');
+ header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
+ header("Content-Transfer-Encoding: binary");
+ header('Pragma: public');
+ header("Content-Length: ".strlen($data));
+ }
+ else
+ {
+ header('Content-Type: application/x-zip');
+ header('Content-Disposition: attachment; filename="'.$filename.'"');
+ header("Content-Transfer-Encoding: binary");
+ header('Expires: 0');
+ header('Pragma: no-cache');
+ header("Content-Length: ".strlen($data));
+ }
+
+ echo $data;
+ }
+
}
-// END CLASS
?>
\ No newline at end of file
--
cgit v1.2.3-24-g4f1b
From 5dc8042015dbd25329ed1e0df8d4d34ee08dc22a Mon Sep 17 00:00:00 2001
From: admin
Date: Sun, 1 Oct 2006 18:53:35 +0000
Subject:
---
system/libraries/Unit.php | 331 ++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 331 insertions(+)
create mode 100644 system/libraries/Unit.php
(limited to 'system/libraries')
diff --git a/system/libraries/Unit.php b/system/libraries/Unit.php
new file mode 100644
index 000000000..0df78c253
--- /dev/null
+++ b/system/libraries/Unit.php
@@ -0,0 +1,331 @@
+active == FALSE)
+ return;
+
+ if (in_array($expected, array('is_string', 'is_bool', 'is_true', 'is_false', 'is_int', 'is_numeric', 'is_float', 'is_double', 'is_array', 'is_null'), TRUE))
+ {
+ $expected = str_replace('is_float', 'is_double', $expected);
+ $result = ($expected($test)) ? TRUE : FALSE;
+ $extype = str_replace(array('true', 'false'), 'bool', str_replace('is_', '', $expected));
+ }
+ else
+ {
+ if ($this->strict == TRUE)
+ $result = ($test === $expected) ? TRUE : FALSE;
+ else
+ $result = ($test == $expected) ? TRUE : FALSE;
+
+ $extype = gettype($expected);
+ }
+
+ $back = $this->_backtrace();
+
+ $report[] = array (
+ 'test_name' => $test_name,
+ 'test_datatype' => gettype($test),
+ 'res_datatype' => $extype,
+ 'result' => ($result === TRUE) ? 'passed' : 'failed',
+ 'file' => $back['file'],
+ 'line' => $back['line']
+ );
+
+ $this->results[] = $report;
+
+ return($this->report($this->result($report)));
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Generate a report
+ *
+ * Displays a table with the test data
+ *
+ * @access public
+ * @return string
+ */
+ function report($result = array())
+ {
+ if (count($result) == 0)
+ {
+ $result = $this->result();
+ }
+
+ $this->_parse_template();
+
+ $r = '';
+ foreach ($result as $res)
+ {
+ $table = '';
+
+ foreach ($res as $key => $val)
+ {
+ $temp = $this->_template_rows;
+ $temp = str_replace('{item}', $key, $temp);
+ $temp = str_replace('{result}', $val, $temp);
+ $table .= $temp;
+ }
+
+ $r .= str_replace('{rows}', $table, $this->_template);
+ }
+
+ return $r;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Use strict comparison
+ *
+ * Causes the evaluation to use === rather then ==
+ *
+ * @access public
+ * @param bool
+ * @return null
+ */
+ function use_strict($state = TRUE)
+ {
+ $this->strict = ($state == FALSE) ? FALSE : TRUE;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Make Unit testing active
+ *
+ * Enables/disables unit testing
+ *
+ * @access public
+ * @param bool
+ * @return null
+ */
+ function active($state = TRUE)
+ {
+ $this->active = ($state == FALSE) ? FALSE : TRUE;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Result Array
+ *
+ * Returns the raw result data
+ *
+ * @access public
+ * @return array
+ */
+ function result($results = array())
+ {
+ $obj =& get_instance();
+ $obj->load->language('unit_test');
+
+ if (count($results) == 0)
+ {
+ $results = $this->results;
+ }
+
+ $retval = array();
+ foreach ($results as $result)
+ {
+ $temp = array();
+ foreach ($result as $key => $val)
+ {
+ if (is_array($val))
+ {
+ foreach ($val as $k => $v)
+ {
+ if (FALSE !== ($line = $obj->lang->line(strtolower('ut_'.$v))))
+ {
+ $v = $line;
+ }
+ $temp[$obj->lang->line('ut_'.$k)] = $v;
+ }
+ }
+ else
+ {
+ if (FALSE !== ($line = $obj->lang->line(strtolower('ut_'.$val))))
+ {
+ $val = $line;
+ }
+ $temp[$obj->lang->line('ut_'.$key)] = $val;
+ }
+ }
+
+ $retval[] = $temp;
+ }
+
+ return $retval;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Set the template
+ *
+ * This lets us set the template to be used to display results
+ *
+ * @access public
+ * @params string
+ * @return void
+ */
+ function set_template($template)
+ {
+ $this->_template = $template;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Generate a backtrace
+ *
+ * This lets us show file names and line numbers
+ *
+ * @access private
+ * @return array
+ */
+ function _backtrace()
+ {
+ if (function_exists('debug_backtrace'))
+ {
+ $back = debug_backtrace();
+
+ $file = ( ! isset($back['1']['file'])) ? '' : $back['1']['file'];
+ $line = ( ! isset($back['1']['line'])) ? '' : $back['1']['line'];
+
+ return array('file' => $file, 'line' => $line);
+ }
+ return array('file' => 'Unknown', 'line' => 'Unknown');
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Get Default Template
+ *
+ * @access private
+ * @return string
+ */
+ function _default_template()
+ {
+ $this->_template = '
+ ';
+
+ $this->_template_rows = '
+
+ {item}
+ {result}
+
+ ';
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Parse Template
+ *
+ * Harvests the data within the template {pseudo-variables}
+ *
+ * @access private
+ * @return void
+ */
+ function _parse_template()
+ {
+ if ( ! is_null($this->_template_rows))
+ {
+ return;
+ }
+
+ if (is_null($this->_template))
+ {
+ $this->_default_template();
+ return;
+ }
+
+ if ( ! preg_match("/\{rows\}(.*?)\{\/rows\}/si", $this->_template, $match))
+ {
+ $this->_default_template();
+ return;
+ }
+
+ $this->_template_rows = $match['1'];
+ $this->_template = str_replace($match['0'], '{rows}', $this->_template);
+ }
+
+}
+// END Unit_test Class
+
+/**
+ * Helper functions to test boolean true/false
+ *
+ *
+ * @access private
+ * @return bool
+ */
+function is_true($test)
+{
+ return (is_bool($test) AND $test === TRUE) ? TRUE : FALSE;
+}
+function is_false($test)
+{
+ return (is_bool($test) AND $test === FALSE) ? TRUE : FALSE;
+}
+
+?>
\ No newline at end of file
--
cgit v1.2.3-24-g4f1b
From 844cdfd5294c2e252c1fa2a110be02dcce8f48a8 Mon Sep 17 00:00:00 2001
From: admin
Date: Sun, 1 Oct 2006 19:00:56 +0000
Subject:
---
system/libraries/Unit_test.php | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
(limited to 'system/libraries')
diff --git a/system/libraries/Unit_test.php b/system/libraries/Unit_test.php
index 78b92edb2..0df78c253 100644
--- a/system/libraries/Unit_test.php
+++ b/system/libraries/Unit_test.php
@@ -26,7 +26,7 @@
* @author Rick Ellis
* @link http://www.codeigniter.com/user_guide/libraries/uri.html
*/
-class CI_Unit_test {
+class CI_Unit {
var $active = TRUE;
var $results = array();
@@ -34,7 +34,7 @@ class CI_Unit_test {
var $_template = NULL;
var $_template_rows = NULL;
- function CI_Unit_test()
+ function CI_Unit()
{
log_message('debug', "Unit Testing Class Initialized");
}
--
cgit v1.2.3-24-g4f1b
From 24dd7e71d2587c4290c85bc85e0e181b29ab0539 Mon Sep 17 00:00:00 2001
From: admin
Date: Sun, 1 Oct 2006 19:02:29 +0000
Subject:
---
system/libraries/Controller.php | 21 +--
system/libraries/Unit_test.php | 331 ----------------------------------------
system/libraries/Zip.php | 152 ++++++++++++------
3 files changed, 117 insertions(+), 387 deletions(-)
delete mode 100644 system/libraries/Unit_test.php
(limited to 'system/libraries')
diff --git a/system/libraries/Controller.php b/system/libraries/Controller.php
index 51f455023..c02074fca 100644
--- a/system/libraries/Controller.php
+++ b/system/libraries/Controller.php
@@ -80,6 +80,13 @@ class Controller extends CI_Base {
{
// Prep the class name
$class = strtolower(str_replace(EXT, '', $class));
+
+ // Bug fix for backward compat.
+ // Kill this at some point in the future
+ if ($class == 'unit_test')
+ {
+ $class = 'unit';
+ }
// Is this a class extension request?
if (substr($class, 0, 3) == 'my_')
@@ -168,9 +175,8 @@ class Controller extends CI_Base {
* @return null
*/
function _ci_init_class($class, $prefix = '', $config = NULL)
- {
+ {
// Is there an associated config file for this class?
-
if ($config == NULL)
{
if (file_exists(APPPATH.'config/'.$class.EXT))
@@ -185,22 +191,19 @@ class Controller extends CI_Base {
}
else
{
- $name = $prefix.ucfirst($class);
+ $name = $prefix.$class;
}
-
- $remap = array(
- 'Unit_test' => 'unit'
- );
$varname = ( ! isset($remap[$class])) ? $class : $remap[$class];
-
+ $varname = strtolower($varname);
+
// Instantiate the class
if ($config !== NULL)
{
$this->$varname = new $name($config);
}
else
- {
+ {
$this->$varname = new $name;
}
}
diff --git a/system/libraries/Unit_test.php b/system/libraries/Unit_test.php
deleted file mode 100644
index 0df78c253..000000000
--- a/system/libraries/Unit_test.php
+++ /dev/null
@@ -1,331 +0,0 @@
-active == FALSE)
- return;
-
- if (in_array($expected, array('is_string', 'is_bool', 'is_true', 'is_false', 'is_int', 'is_numeric', 'is_float', 'is_double', 'is_array', 'is_null'), TRUE))
- {
- $expected = str_replace('is_float', 'is_double', $expected);
- $result = ($expected($test)) ? TRUE : FALSE;
- $extype = str_replace(array('true', 'false'), 'bool', str_replace('is_', '', $expected));
- }
- else
- {
- if ($this->strict == TRUE)
- $result = ($test === $expected) ? TRUE : FALSE;
- else
- $result = ($test == $expected) ? TRUE : FALSE;
-
- $extype = gettype($expected);
- }
-
- $back = $this->_backtrace();
-
- $report[] = array (
- 'test_name' => $test_name,
- 'test_datatype' => gettype($test),
- 'res_datatype' => $extype,
- 'result' => ($result === TRUE) ? 'passed' : 'failed',
- 'file' => $back['file'],
- 'line' => $back['line']
- );
-
- $this->results[] = $report;
-
- return($this->report($this->result($report)));
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Generate a report
- *
- * Displays a table with the test data
- *
- * @access public
- * @return string
- */
- function report($result = array())
- {
- if (count($result) == 0)
- {
- $result = $this->result();
- }
-
- $this->_parse_template();
-
- $r = '';
- foreach ($result as $res)
- {
- $table = '';
-
- foreach ($res as $key => $val)
- {
- $temp = $this->_template_rows;
- $temp = str_replace('{item}', $key, $temp);
- $temp = str_replace('{result}', $val, $temp);
- $table .= $temp;
- }
-
- $r .= str_replace('{rows}', $table, $this->_template);
- }
-
- return $r;
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Use strict comparison
- *
- * Causes the evaluation to use === rather then ==
- *
- * @access public
- * @param bool
- * @return null
- */
- function use_strict($state = TRUE)
- {
- $this->strict = ($state == FALSE) ? FALSE : TRUE;
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Make Unit testing active
- *
- * Enables/disables unit testing
- *
- * @access public
- * @param bool
- * @return null
- */
- function active($state = TRUE)
- {
- $this->active = ($state == FALSE) ? FALSE : TRUE;
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Result Array
- *
- * Returns the raw result data
- *
- * @access public
- * @return array
- */
- function result($results = array())
- {
- $obj =& get_instance();
- $obj->load->language('unit_test');
-
- if (count($results) == 0)
- {
- $results = $this->results;
- }
-
- $retval = array();
- foreach ($results as $result)
- {
- $temp = array();
- foreach ($result as $key => $val)
- {
- if (is_array($val))
- {
- foreach ($val as $k => $v)
- {
- if (FALSE !== ($line = $obj->lang->line(strtolower('ut_'.$v))))
- {
- $v = $line;
- }
- $temp[$obj->lang->line('ut_'.$k)] = $v;
- }
- }
- else
- {
- if (FALSE !== ($line = $obj->lang->line(strtolower('ut_'.$val))))
- {
- $val = $line;
- }
- $temp[$obj->lang->line('ut_'.$key)] = $val;
- }
- }
-
- $retval[] = $temp;
- }
-
- return $retval;
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Set the template
- *
- * This lets us set the template to be used to display results
- *
- * @access public
- * @params string
- * @return void
- */
- function set_template($template)
- {
- $this->_template = $template;
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Generate a backtrace
- *
- * This lets us show file names and line numbers
- *
- * @access private
- * @return array
- */
- function _backtrace()
- {
- if (function_exists('debug_backtrace'))
- {
- $back = debug_backtrace();
-
- $file = ( ! isset($back['1']['file'])) ? '' : $back['1']['file'];
- $line = ( ! isset($back['1']['line'])) ? '' : $back['1']['line'];
-
- return array('file' => $file, 'line' => $line);
- }
- return array('file' => 'Unknown', 'line' => 'Unknown');
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Get Default Template
- *
- * @access private
- * @return string
- */
- function _default_template()
- {
- $this->_template = '
- ';
-
- $this->_template_rows = '
-
- {item}
- {result}
-
- ';
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Parse Template
- *
- * Harvests the data within the template {pseudo-variables}
- *
- * @access private
- * @return void
- */
- function _parse_template()
- {
- if ( ! is_null($this->_template_rows))
- {
- return;
- }
-
- if (is_null($this->_template))
- {
- $this->_default_template();
- return;
- }
-
- if ( ! preg_match("/\{rows\}(.*?)\{\/rows\}/si", $this->_template, $match))
- {
- $this->_default_template();
- return;
- }
-
- $this->_template_rows = $match['1'];
- $this->_template = str_replace($match['0'], '{rows}', $this->_template);
- }
-
-}
-// END Unit_test Class
-
-/**
- * Helper functions to test boolean true/false
- *
- *
- * @access private
- * @return bool
- */
-function is_true($test)
-{
- return (is_bool($test) AND $test === TRUE) ? TRUE : FALSE;
-}
-function is_false($test)
-{
- return (is_bool($test) AND $test === FALSE) ? TRUE : FALSE;
-}
-
-?>
\ No newline at end of file
diff --git a/system/libraries/Zip.php b/system/libraries/Zip.php
index aa264386d..2ffed9fe2 100644
--- a/system/libraries/Zip.php
+++ b/system/libraries/Zip.php
@@ -18,9 +18,11 @@
/**
* Zip Compression Class
*
- * This class is based on a library aquired at Zend:
+ * This class is based on a library I found at Zend:
* http://www.zend.com/codex.php?id=696&single=1
*
+ * The original library is a little rough around the edges so I
+ * refactored it and added several additional methods -- Rick Ellis
*
* @package CodeIgniter
* @subpackage Libraries
@@ -28,12 +30,18 @@
* @author Rick Ellis
* @link http://www.codeigniter.com/user_guide/general/encryption.html
*/
-class Zip {
-
+class CI_Zip {
+
+ var $zipfile = '';
var $zipdata = array();
var $directory = array();
var $offset = 0;
- var $zipfile = '';
+
+ function CI_Zip()
+ {
+ log_message('debug', "Zip Compression Class Initialized");
+ }
+
/**
* Add Directory
@@ -41,13 +49,33 @@ class Zip {
* Lets you add a virtual directory into which you can place files.
*
* @access public
+ * @param mixed the directory name. Can be string or array
+ * @return void
+ */
+ function add_dir($directory)
+ {
+ foreach ((array)$directory as $dir)
+ {
+ if ( ! preg_match("|.+/$|", $dir))
+ {
+ $dir .= '/';
+ }
+
+ $this->_add_dir($dir);
+ }
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Add Directory
+ *
+ * @access private
* @param string the directory name
* @return void
*/
- function add_dir($dir)
+ function _add_dir($dir)
{
- $this->zipfile = '';
-
$dir = str_replace("\\", "/", $dir);
$this->zipdata[] = "\x50\x4b\x03\x04\x0a\x00\x00\x00\x00\x00\x00\x00\x00\x00"
@@ -78,27 +106,50 @@ class Zip {
$this->offset = $newoffset;
$this->directory[] = $record;
- }
-
+ }
+
// --------------------------------------------------------------------
/**
- * Add File
+ * Add Data to Zip
*
* Lets you add files to the archive. If the path is included
* in the filename it will be placed within a directory. Make
* sure you use add_dir() first to create the folder.
*
* @access public
- * @param string the file name
- * @param string the data to be encoded
+ * @param mixed
+ * @param string
* @return void
*/
- function add_file($filename, $data)
+ function add_data($filepath, $data = NULL)
{
- $this->zipfile = '';
+ if (is_array($filepath))
+ {
+ foreach ($filepath as $path => $data)
+ {
+ $this->_add_data($path, $data);
+ }
+ }
+ else
+ {
+ $this->_add_data($filepath, $data);
+ }
+ }
- $filename = str_replace("\\", "/", $filename);
+ // --------------------------------------------------------------------
+
+ /**
+ * Add Data to Zip
+ *
+ * @access private
+ * @param string the file name/path
+ * @param string the data to be encoded
+ * @return void
+ */
+ function _add_data($filepath, $data)
+ {
+ $filepath = str_replace("\\", "/", $filepath);
$oldlen = strlen($data);
$crc32 = crc32($data);
@@ -111,9 +162,9 @@ class Zip {
.pack('V', $crc32)
.pack('V', $newlen)
.pack('V', $oldlen)
- .pack('v', strlen($filename))
+ .pack('v', strlen($filepath))
.pack('v', 0)
- .$filename
+ .$filepath
.$gzdata
.pack('V', $crc32)
.pack('V', $newlen)
@@ -125,7 +176,7 @@ class Zip {
.pack('V', $crc32)
.pack('V', $newlen)
.pack('V', $oldlen)
- .pack('v', strlen($filename))
+ .pack('v', strlen($filepath))
.pack('v', 0)
.pack('v', 0)
.pack('v', 0)
@@ -134,26 +185,7 @@ class Zip {
.pack('V', $this->offset);
$this->offset = $newoffset;
- $this->directory[] = $record.$filename;
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Read the content of a file
- *
- * @access public
- * @param string the file path
- * @return string
- */
- function read_file($filepath)
- {
- if ( ! file_exists($filepath))
- {
- return FALSE;
- }
-
- return file_get_contents($filepath);
+ $this->directory[] = $record.$filepath;
}
// --------------------------------------------------------------------
@@ -166,11 +198,19 @@ class Zip {
*/
function get_zip()
{
+ // We cache the zip data so multiple calls
+ // do not require recompiling
if ($this->zipfile != '')
{
return $this->zipfile;
}
+ // Is there any data to return?
+ if (count($this->zipdata) == 0)
+ {
+ return FALSE;
+ }
+
$data = implode('', $this->zipdata);
$dir = implode('', $this->directory);
@@ -180,7 +220,7 @@ class Zip {
.pack('V', strlen($dir))
.pack('V', strlen($data))
."\x00\x00";
-
+
return $this->zipfile;
}
@@ -196,15 +236,15 @@ class Zip {
* @param string the data to be encoded
* @return bool
*/
- function write_file($filename, $data)
+ function write_zip($filepath)
{
- if ( ! ($fp = fopen($filename, "wb")))
+ if ( ! ($fp = fopen($filepath, "wb")))
{
return FALSE;
}
flock($fp, LOCK_EX);
- fwrite($fp, $data);
+ fwrite($fp, $this->get_zip());
flock($fp, LOCK_UN);
fclose($fp);
@@ -216,13 +256,12 @@ class Zip {
/**
* Download
*
- *
* @access public
* @param string the file name
* @param string the data to be encoded
* @return bool
*/
- function download($filename, $data)
+ function download($filename)
{
if (strstr($_SERVER['HTTP_USER_AGENT'], "MSIE"))
{
@@ -232,7 +271,7 @@ class Zip {
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header("Content-Transfer-Encoding: binary");
header('Pragma: public');
- header("Content-Length: ".strlen($data));
+ header("Content-Length: ".strlen($this->get_zip()));
}
else
{
@@ -241,10 +280,29 @@ class Zip {
header("Content-Transfer-Encoding: binary");
header('Expires: 0');
header('Pragma: no-cache');
- header("Content-Length: ".strlen($data));
+ header("Content-Length: ".strlen($this->get_zip()));
}
- echo $data;
+ echo $this->get_zip();
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Initialize Data
+ *
+ * Lets you clear current zip data. Useful if you need to create
+ * multiple zips with different data.
+ *
+ * @access public
+ * @return void
+ */
+ function clear_data()
+ {
+ $this->zipfile = '';
+ $this->zipdata = array();
+ $this->directory = array();
+ $this->offset = array();
}
}
--
cgit v1.2.3-24-g4f1b
From 33dd95d7cb8ac2f6b8da447966a750bdb064fc48 Mon Sep 17 00:00:00 2001
From: admin
Date: Sun, 1 Oct 2006 19:20:42 +0000
Subject:
---
system/libraries/Zip.php | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
(limited to 'system/libraries')
diff --git a/system/libraries/Zip.php b/system/libraries/Zip.php
index 2ffed9fe2..a11699956 100644
--- a/system/libraries/Zip.php
+++ b/system/libraries/Zip.php
@@ -261,8 +261,13 @@ class CI_Zip {
* @param string the data to be encoded
* @return bool
*/
- function download($filename)
+ function download($filename = 'backup.zip')
{
+ if ( ! preg_match("|.+?\.zip$|", $filename))
+ {
+ $filename .= '.zip';
+ }
+
if (strstr($_SERVER['HTTP_USER_AGENT'], "MSIE"))
{
header('Content-Type: application/x-zip');
--
cgit v1.2.3-24-g4f1b
From 813d0acb42ea9e367115ffc7da5b6036ab36ed98 Mon Sep 17 00:00:00 2001
From: admin
Date: Sun, 1 Oct 2006 20:36:39 +0000
Subject:
---
system/libraries/Router.php | 31 +++++++++++++++++++++++++++----
1 file changed, 27 insertions(+), 4 deletions(-)
(limited to 'system/libraries')
diff --git a/system/libraries/Router.php b/system/libraries/Router.php
index c056530a3..d62cf5090 100644
--- a/system/libraries/Router.php
+++ b/system/libraries/Router.php
@@ -291,13 +291,26 @@ class CI_Router {
{
if (strtoupper($this->config->item('uri_protocol')) == 'AUTO')
{
- $path_info = getenv('PATH_INFO');
+ // If the URL has a question mark then it's simplest to just
+ // build the URI string from the zero index of the $_GET array.
+ // This avoids having to deal with $_SERVER variables, which
+ // can be unreliable on some servers
+ if (is_array($_GET) AND count($_GET) == 1)
+ {
+ return current(array_keys($_GET));
+ }
+
+ // Is there a PATH_INFO variable?
+ // Note: some servers seem to have trouble with getenv() so we'll test it two ways
+ $path_info = (isset($_SERVER['PATH_INFO'])) ? $_SERVER['PATH_INFO'] : @getenv('PATH_INFO');
+
if ($path_info != '' AND $path_info != "/".SELF)
{
return $path_info;
}
else
{
+ // OK, how about REQUEST_URI?
$req_uri = $this->_parse_request_uri();
if ($req_uri != "")
@@ -306,14 +319,24 @@ class CI_Router {
}
else
{
- $path_info = getenv('ORIG_PATH_INFO');
+ // Hm... maybe the ORIG_PATH_INFO variable exists?
+ $path_info = (isset($_SERVER['ORIG_PATH_INFO'])) ? $_SERVER['ORIG_PATH_INFO'] : @getenv('ORIG_PATH_INFO');
if ($path_info != '' AND $path_info != "/".SELF)
{
return $path_info;
}
else
{
- return getenv('QUERY_STRING');
+ // At this point we've exhauseted all our options.
+ // Hopefully QUERY_STRING exists. If not, there's nothing else we can try.
+ $query_string = (isset($_SERVER['QUERY_STRING'])) ? $_SERVER['QUERY_STRING'] : @getenv('QUERY_STRING');
+
+ if ($query_string != '')
+ {
+ return $query_string;
+ }
+
+ return '';
}
}
}
@@ -327,7 +350,7 @@ class CI_Router {
return $this->_parse_request_uri();
}
- return getenv($uri);
+ return (isset($_SERVER[$uri])) ? $_SERVER[$uri] : @getenv($uri);
}
}
--
cgit v1.2.3-24-g4f1b
From 0f8015fcdc4eb7a2bedc6a04548e588b39914c60 Mon Sep 17 00:00:00 2001
From: admin
Date: Sun, 1 Oct 2006 22:08:34 +0000
Subject:
---
system/libraries/Zip.php | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
(limited to 'system/libraries')
diff --git a/system/libraries/Zip.php b/system/libraries/Zip.php
index a11699956..218388314 100644
--- a/system/libraries/Zip.php
+++ b/system/libraries/Zip.php
@@ -227,7 +227,7 @@ class CI_Zip {
// --------------------------------------------------------------------
/**
- * Write File
+ * Write File to the specified direcotry
*
* Lets you write a file
*
@@ -236,9 +236,9 @@ class CI_Zip {
* @param string the data to be encoded
* @return bool
*/
- function write_zip($filepath)
+ function archive($filepath)
{
- if ( ! ($fp = fopen($filepath, "wb")))
+ if ( ! ($fp = @fopen($filepath, "wb")))
{
return FALSE;
}
--
cgit v1.2.3-24-g4f1b
From e26611f93bfb21f5e143cc91ce529f6db52cdd88 Mon Sep 17 00:00:00 2001
From: admin
Date: Mon, 2 Oct 2006 21:59:12 +0000
Subject:
---
system/libraries/Benchmark.php | 32 +++++++++++++++++++
system/libraries/Output.php | 70 +++++++++++++++++++++++++++++++++++++++---
2 files changed, 97 insertions(+), 5 deletions(-)
(limited to 'system/libraries')
diff --git a/system/libraries/Benchmark.php b/system/libraries/Benchmark.php
index d8dd903e7..feedbf570 100644
--- a/system/libraries/Benchmark.php
+++ b/system/libraries/Benchmark.php
@@ -85,6 +85,38 @@ class CI_Benchmark {
// --------------------------------------------------------------------
+ /**
+ * Auto Profiler
+ *
+ * This function cycles through the entire array of mark points and
+ * matches any two points that are named identially (ending in "_start"
+ * and "_end" respectively). It then compiles the execution times for
+ * all points and returns it as an array
+ *
+ * @access public
+ * @return array
+ */
+ function auto_profiler()
+ {
+ $marker_keys = array_reverse(array_keys($this->marker));
+
+ $times = array();
+ foreach ($marker_keys as $val)
+ {
+ if (preg_match("/(.+?)_start/i", $val, $match))
+ {
+ if (isset($this->marker[$match[1].'_end']))
+ {
+ $times[$match[1]] = $this->elapsed_time($val, $match[1].'_end');
+ }
+ }
+ }
+
+ return $times;
+ }
+
+ // --------------------------------------------------------------------
+
/**
* Memory Usage
*
diff --git a/system/libraries/Output.php b/system/libraries/Output.php
index 1c3f0d604..b5b7c9e97 100644
--- a/system/libraries/Output.php
+++ b/system/libraries/Output.php
@@ -31,6 +31,7 @@ class CI_Output {
var $final_output;
var $cache_expiration = 0;
var $headers = array();
+ var $enable_profiler = FALSE;
function CI_Output()
{
@@ -89,6 +90,20 @@ class CI_Output {
// --------------------------------------------------------------------
+ /**
+ * Enable/disable Profiler
+ *
+ * @access public
+ * @param bool
+ * @return void
+ */
+ function enable_profiler($val = TRUE)
+ {
+ $this->enable_profiler = (is_bool($val)) ? $val : TRUE;
+ }
+
+ // --------------------------------------------------------------------
+
/**
* Set Cache
*
@@ -123,7 +138,7 @@ class CI_Output {
*/
function _display($output = '')
{
- // Note: We can't use $obj =& _get_instance() since this function
+ // Note: We can't use $obj =& get_instance() since this function
// is sometimes called by the caching mechanism, which happens before
// it's available. Instead we'll use globals...
global $BM, $CFG;
@@ -141,7 +156,7 @@ class CI_Output {
// Parse out the elapsed time and memory usage, and
// swap the pseudo-variables with the data
- $elapsed = $BM->elapsed_time('code_igniter_start', 'code_igniter_end');
+ $elapsed = $BM->elapsed_time('total_execution_time_start', 'total_execution_time_end');
$memory = ( ! function_exists('memory_get_usage')) ? '0' : round(memory_get_usage()/1024/1024, 2).'MB';
$output = str_replace('{memory_usage}', $memory, $output);
@@ -166,14 +181,28 @@ class CI_Output {
{
@header($header);
}
- }
+ }
// Send the finalized output either directly
// to the browser or to the user's _output()
// function if it exists
- if (function_exists('_get_instance') AND method_exists($obj, '_output'))
+ if (function_exists('get_instance'))
{
- $obj->_output($output);
+ $obj =& get_instance();
+
+ if ($this->enable_profiler == TRUE)
+ {
+ $output .= $this->_run_profiler();
+ }
+
+ if (method_exists($obj, '_output'))
+ {
+ $obj->_output($output);
+ }
+ else
+ {
+ echo $output; // Send it to the browser!
+ }
}
else
{
@@ -295,6 +324,37 @@ class CI_Output {
return TRUE;
}
+ // --------------------------------------------------------------------
+
+ /**
+ * Run the Auto-profiler
+ *
+ * @access private
+ * @return string
+ */
+ function _run_profiler()
+ {
+ $obj =& get_instance();
+
+ $profile = $obj->benchmark->auto_profiler();
+
+ $output = '';
+ if (count($profile) > 0)
+ {
+ $output .= "\n\n\n";
+
+ foreach ($profile as $key => $val)
+ {
+ $key = ucwords(str_replace(array('_', '-'), ' ', $key));
+ $output .= "".$key." ".$val." \n";
+ }
+
+ $output .= "
\n";
+ }
+
+ return $output;
+ }
+
}
// END Output Class
?>
\ No newline at end of file
--
cgit v1.2.3-24-g4f1b
From e95cd263f6991d99e0103fe858f034b76be6d672 Mon Sep 17 00:00:00 2001
From: admin
Date: Mon, 2 Oct 2006 23:17:20 +0000
Subject:
---
system/libraries/Hooks.php | 17 ++++++++++++++---
1 file changed, 14 insertions(+), 3 deletions(-)
(limited to 'system/libraries')
diff --git a/system/libraries/Hooks.php b/system/libraries/Hooks.php
index 69ca1a9f1..8767e10d0 100644
--- a/system/libraries/Hooks.php
+++ b/system/libraries/Hooks.php
@@ -40,7 +40,19 @@ class CI_Hooks {
function CI_Hooks()
{
log_message('debug', "Hooks Class Initialized");
-
+ $this->_initialize();
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Initialize the Hooks Preferences
+ *
+ * @access private
+ * @return void
+ */
+ function _initialize()
+ {
$CFG =& _load_class('Config');
// If hooks are not enabled in the config file
@@ -63,8 +75,7 @@ class CI_Hooks {
$this->hooks =& $hook;
$this->enabled = TRUE;
- }
- // END CI_Hooks()
+ }
// --------------------------------------------------------------------
--
cgit v1.2.3-24-g4f1b
From 243f5cc45f23436a1ed3f2fc1ac5f0388dc3d4f5 Mon Sep 17 00:00:00 2001
From: derek
Date: Tue, 3 Oct 2006 00:25:03 +0000
Subject:
---
system/libraries/Email.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
(limited to 'system/libraries')
diff --git a/system/libraries/Email.php b/system/libraries/Email.php
index 55edd6216..99de17414 100644
--- a/system/libraries/Email.php
+++ b/system/libraries/Email.php
@@ -1548,7 +1548,7 @@ class CI_Email {
*/
function _get_hostname()
{
- return ($this->smtp_host != '') ? $this->smtp_host : $this->_get_ip();
+ return (isset($_SERVER['SERVER_NAME'])) ? $_SERVER['SERVER_NAME'] : 'localhost.localdomain';
}
// END _get_hostname()
--
cgit v1.2.3-24-g4f1b
From d13ff07599e9ff114051f4823c4c0d13fd1c814d Mon Sep 17 00:00:00 2001
From: admin
Date: Tue, 3 Oct 2006 03:40:45 +0000
Subject:
---
system/libraries/Profiler.php | 72 +++++++++++++++++++++++++++++++++++++++++++
1 file changed, 72 insertions(+)
create mode 100644 system/libraries/Profiler.php
(limited to 'system/libraries')
diff --git a/system/libraries/Profiler.php b/system/libraries/Profiler.php
new file mode 100644
index 000000000..026bfac60
--- /dev/null
+++ b/system/libraries/Profiler.php
@@ -0,0 +1,72 @@
+benchmark->marker as $key => $val)
+ {
+ // We match the "end" marker so that the list ends
+ // up in the order that it was defined
+ if (preg_match("/(.+?)_end/i", $key, $match))
+ {
+ if (isset($obj->benchmark->marker[$match[1].'_end']))
+ {
+ $times[$match[1]] = $obj->benchmark->elapsed_time($match[1].'_start', $key);
+ }
+ }
+ }
+
+ return $times;
+ }
+
+ // --------------------------------------------------------------------
+
+}
+
+// END CI_Profiler class
+?>
\ No newline at end of file
--
cgit v1.2.3-24-g4f1b
From 90a7b9db21316122816e01d5e6459a4424940d1f Mon Sep 17 00:00:00 2001
From: admin
Date: Tue, 3 Oct 2006 04:48:39 +0000
Subject:
---
system/libraries/Profiler.php | 130 +++++++++++++++++++++++++++++++++++++++---
1 file changed, 122 insertions(+), 8 deletions(-)
(limited to 'system/libraries')
diff --git a/system/libraries/Profiler.php b/system/libraries/Profiler.php
index 026bfac60..265aaf031 100644
--- a/system/libraries/Profiler.php
+++ b/system/libraries/Profiler.php
@@ -29,6 +29,13 @@
*/
class CI_Profiler {
+ var $obj;
+
+ function CI_Profiler()
+ {
+ $this->obj =& get_instance();
+ $this->obj->load->language('profiler');
+ }
// --------------------------------------------------------------------
@@ -45,27 +52,134 @@ class CI_Profiler {
*/
function _compile_benchmarks()
{
- $obj =& get_instance();
-
- $times = array();
- foreach ($obj->benchmark->marker as $key => $val)
+ $profile = array();
+ foreach ($this->obj->benchmark->marker as $key => $val)
{
// We match the "end" marker so that the list ends
// up in the order that it was defined
if (preg_match("/(.+?)_end/i", $key, $match))
{
- if (isset($obj->benchmark->marker[$match[1].'_end']))
+ if (isset($this->obj->benchmark->marker[$match[1].'_end']))
{
- $times[$match[1]] = $obj->benchmark->elapsed_time($match[1].'_start', $key);
+ $profile[$match[1]] = $this->obj->benchmark->elapsed_time($match[1].'_start', $key);
}
}
}
-
- return $times;
+
+ // Build a table containing the profile data.
+ // Note: At some point we should turn this into a template that can
+ // be modified. We also might want to make this data available to be logged
+
+ $output = "\n\n";
+ $output .= '';
+ $output .= "\n";
+ $output .= ' '.$this->obj->lang->line('profiler_benchmarks').' ';
+ $output .= "\n";
+ $output .= "\n\n\n";
+
+ foreach ($profile as $key => $val)
+ {
+ $key = ucwords(str_replace(array('_', '-'), ' ', $key));
+ $output .= "".$key." ".$val." \n";
+ }
+
+ $output .= "
\n";
+ $output .= " \n\n";
+
+ return $output;
}
// --------------------------------------------------------------------
+
+ function _compile_queries()
+ {
+ $output = "\n\n";
+ $output .= '';
+ $output .= "\n";
+ $output .= ' '.$this->obj->lang->line('profiler_queries').' ';
+ $output .= "\n";
+
+ if ( ! class_exists('CI_DB_driver'))
+ {
+ $output .= "".$this->obj->lang->line('profiler_no_db')."
";
+ }
+ else
+ {
+ if (count($this->obj->db->queries) == 0)
+ {
+ $output .= "".$this->obj->lang->line('profiler_no_queries')."
";
+ }
+ else
+ {
+ foreach ($this->obj->db->queries as $val)
+ {
+ $output .= '';
+ $output .= $val;
+ $output .= "
\n";
+ }
+ }
+ }
+
+ $output .= " \n\n";
+
+ return $output;
+ }
+
+ // --------------------------------------------------------------------
+
+ function _compile_post()
+ {
+ $output = "\n\n";
+ $output .= '';
+ $output .= "\n";
+ $output .= ' '.$this->obj->lang->line('profiler_post_data').' ';
+ $output .= "\n";
+
+ if (count($_POST) == 0)
+ {
+ $output .= "".$this->obj->lang->line('profiler_no_post')."
";
+ }
+ else
+ {
+ $output .= "\n\n\n";
+
+ foreach ($_POST as $key => $val)
+ {
+ if ( ! is_numeric($key))
+ {
+ $key = "'".$key."'";
+ }
+
+ $output .= "$_POST[".$key."] ".htmlspecialchars(stripslashes($val))." \n";
+ }
+
+ $output .= "
\n";
+ }
+ $output .= " \n\n";
+
+ return $output;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Run the Auto-profiler
+ *
+ * @access private
+ * @return string
+ */
+ function run($output = '')
+ {
+ $output = ' ';
+
+ $output .= $this->_compile_benchmarks();
+ $output .= $this->_compile_post();
+ $output .= $this->_compile_queries();
+
+ return $output;
+ }
+
}
// END CI_Profiler class
--
cgit v1.2.3-24-g4f1b
From 1c5ef5e34a86c2d3aa0a2d7c61d143331802ae8d Mon Sep 17 00:00:00 2001
From: admin
Date: Tue, 3 Oct 2006 04:50:09 +0000
Subject:
---
system/libraries/Profiler.php | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
(limited to 'system/libraries')
diff --git a/system/libraries/Profiler.php b/system/libraries/Profiler.php
index 265aaf031..807a7a83f 100644
--- a/system/libraries/Profiler.php
+++ b/system/libraries/Profiler.php
@@ -19,7 +19,10 @@
* Code Igniter Profiler Class
*
* This class enables you to display benchmark, query, and other data
- * in order to help with debugging and optimization
+ * in order to help with debugging and optimization.
+ *
+ * Note: At some point it would be good to move all the HTML in this class
+ * into a set of template files in order to allow customization.
*
* @package CodeIgniter
* @subpackage Libraries
@@ -164,7 +167,7 @@ class CI_Profiler {
// --------------------------------------------------------------------
/**
- * Run the Auto-profiler
+ * Run the Profiler
*
* @access private
* @return string
--
cgit v1.2.3-24-g4f1b
From 08f6020b0085842d4ae81949a0f4886c94158a55 Mon Sep 17 00:00:00 2001
From: admin
Date: Tue, 3 Oct 2006 05:28:00 +0000
Subject:
---
system/libraries/Benchmark.php | 35 -----------
system/libraries/Output.php | 131 +++++++++++++++++++++--------------------
system/libraries/Router.php | 5 ++
3 files changed, 72 insertions(+), 99 deletions(-)
(limited to 'system/libraries')
diff --git a/system/libraries/Benchmark.php b/system/libraries/Benchmark.php
index feedbf570..d29e91798 100644
--- a/system/libraries/Benchmark.php
+++ b/system/libraries/Benchmark.php
@@ -48,7 +48,6 @@ class CI_Benchmark {
{
$this->marker[$name] = microtime();
}
- // END mark()
// --------------------------------------------------------------------
@@ -81,39 +80,6 @@ class CI_Benchmark {
return number_format(($em + $es) - ($sm + $ss), $decimals);
}
- // END elapsed_time()
-
- // --------------------------------------------------------------------
-
- /**
- * Auto Profiler
- *
- * This function cycles through the entire array of mark points and
- * matches any two points that are named identially (ending in "_start"
- * and "_end" respectively). It then compiles the execution times for
- * all points and returns it as an array
- *
- * @access public
- * @return array
- */
- function auto_profiler()
- {
- $marker_keys = array_reverse(array_keys($this->marker));
-
- $times = array();
- foreach ($marker_keys as $val)
- {
- if (preg_match("/(.+?)_start/i", $val, $match))
- {
- if (isset($this->marker[$match[1].'_end']))
- {
- $times[$match[1]] = $this->elapsed_time($val, $match[1].'_end');
- }
- }
- }
-
- return $times;
- }
// --------------------------------------------------------------------
@@ -132,7 +98,6 @@ class CI_Benchmark {
{
return '{memory_usage}';
}
- // END memory_usage()
}
diff --git a/system/libraries/Output.php b/system/libraries/Output.php
index b5b7c9e97..4ab5dd23c 100644
--- a/system/libraries/Output.php
+++ b/system/libraries/Output.php
@@ -29,9 +29,10 @@
class CI_Output {
var $final_output;
- var $cache_expiration = 0;
- var $headers = array();
- var $enable_profiler = FALSE;
+ var $cache_expiration = 0;
+ var $headers = array();
+ var $enable_profiler = FALSE;
+
function CI_Output()
{
@@ -121,46 +122,52 @@ class CI_Output {
/**
* Display Output
*
- * All "view" data is automatically put into this variable
- * by the controller class:
+ * All "view" data is automatically put into this variable by the controller class:
*
* $this->final_output
*
- * This function simply echos the variable out. It also does the following:
- *
- * Stops the benchmark timer so the page rendering speed can be shown.
- *
- * Determines if the "memory_get_usage' function is available so that
- * the memory usage can be shown.
+ * This function sends the finalized output data to the browser along
+ * with any server headers and profile data. It also stops the
+ * benchmark timer so the page rendering speed and memory usage can be shown.
*
* @access public
- * @return void
+ * @return mixed
*/
function _display($output = '')
{
- // Note: We can't use $obj =& get_instance() since this function
- // is sometimes called by the caching mechanism, which happens before
- // it's available. Instead we'll use globals...
+ // Note: We use globals because we can't use $obj =& get_instance()
+ // since this function is sometimes called by the caching mechanism,
+ // which happens before the CI super object is available.
global $BM, $CFG;
-
+
+ // --------------------------------------------------------------------
+
+ // Set the output data
if ($output == '')
{
$output =& $this->final_output;
}
+ // --------------------------------------------------------------------
+
// Do we need to write a cache file?
if ($this->cache_expiration > 0)
{
$this->_write_cache($output);
}
+
+ // --------------------------------------------------------------------
- // Parse out the elapsed time and memory usage, and
- // swap the pseudo-variables with the data
+ // Parse out the elapsed time and memory usage,
+ // then swap the pseudo-variables with the data
+
$elapsed = $BM->elapsed_time('total_execution_time_start', 'total_execution_time_end');
+ $output = str_replace('{elapsed_time}', $elapsed, $output);
+
$memory = ( ! function_exists('memory_get_usage')) ? '0' : round(memory_get_usage()/1024/1024, 2).'MB';
-
$output = str_replace('{memory_usage}', $memory, $output);
- $output = str_replace('{elapsed_time}', $elapsed, $output);
+
+ // --------------------------------------------------------------------
// Is compression requested?
if ($CFG->item('compress_output') === TRUE)
@@ -173,6 +180,8 @@ class CI_Output {
}
}
}
+
+ // --------------------------------------------------------------------
// Are there any server headers to send?
if (count($this->headers) > 0)
@@ -182,30 +191,54 @@ class CI_Output {
@header($header);
}
}
+
+ // --------------------------------------------------------------------
- // Send the finalized output either directly
- // to the browser or to the user's _output()
- // function if it exists
- if (function_exists('get_instance'))
+ // Does the get_instance() function exist?
+ // If not we know we are dealing with a cache file so we'll
+ // simply echo out the data and exit.
+ if ( ! function_exists('get_instance'))
{
- $obj =& get_instance();
-
- if ($this->enable_profiler == TRUE)
- {
- $output .= $this->_run_profiler();
- }
+ echo $output;
+ log_message('debug', "Final output sent to browser");
+ log_message('debug', "Total execution time: ".$elapsed);
+ }
+
+ // --------------------------------------------------------------------
+
+ // Grab the super object. We'll need it in a moment...
+ $obj =& get_instance();
- if (method_exists($obj, '_output'))
+ // Do we need to generate profile data?
+ // If so, load the Profile class and run it.
+ if ($this->enable_profiler == TRUE)
+ {
+ $obj->load->library('profiler');
+
+ // If the output data contains closing and tags
+ // we will remove them and add them back after we insert the profile data
+ if (preg_match("|