From a101c93b93b43ac98370bb0a1378a82ff44e4e1a Mon Sep 17 00:00:00 2001 From: Jonatas Miguel Date: Fri, 20 Jul 2012 12:23:43 +0200 Subject: allow for routes that can be processed with php, ex: $route['([^/]+)/([^/]+)(/:any)?'] = 'php:"$1" . "/do" . ucfirst("$2") . "$3"'; --- system/core/Router.php | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'system') diff --git a/system/core/Router.php b/system/core/Router.php index 5bc053045..cb7df5320 100644 --- a/system/core/Router.php +++ b/system/core/Router.php @@ -86,6 +86,13 @@ class CI_Router { * @var string */ public $default_controller; + + /** + * Prepend used in php processed routes + * + * @var string + */ + public $route_prepend = 'php:'; /** * Constructor @@ -373,10 +380,16 @@ class CI_Router { // Does the RegEx match? if (preg_match('#^'.$key.'$#', $uri)) { + // Are we using php functions to process matches? + $modifier = strpos($val, $this->route_prepend) === 0? 'e': ''; + + // If we have the 'e' modifier, remove the prepend from the route value. + $val = $modifier === 'e'? substr($val, strlen($this->route_prepend)): $val; + // Do we have a back-reference? if (strpos($val, '$') !== FALSE && strpos($key, '(') !== FALSE) { - $val = preg_replace('#^'.$key.'$#', $val, $uri); + $val = preg_replace('#^'.$key.'$#'.$modifier, $val, $uri); } return $this->_set_request(explode('/', $val)); -- cgit v1.2.3-24-g4f1b From 80275c7ee050ed42678d68a752e0c282f0240752 Mon Sep 17 00:00:00 2001 From: Jonatas Miguel Date: Wed, 1 Aug 2012 19:15:48 +0200 Subject: Added possibility of using callbacks. --- system/core/Router.php | 31 +++++++++++++++++++++++++------ 1 file changed, 25 insertions(+), 6 deletions(-) (limited to 'system') diff --git a/system/core/Router.php b/system/core/Router.php index cb7df5320..727e85f7e 100644 --- a/system/core/Router.php +++ b/system/core/Router.php @@ -380,16 +380,35 @@ class CI_Router { // Does the RegEx match? if (preg_match('#^'.$key.'$#', $uri)) { - // Are we using php functions to process matches? - $modifier = strpos($val, $this->route_prepend) === 0? 'e': ''; + // Are we using a callback? + $callable = is_callable($val); + + // Determine the appropriate preg_replace to use. + $preg_replace_type = $callable? 'preg_replace_callback': 'preg_replace'; + + // Are we using the route_prepend to change how we process the matches? + $modifier = (is_string($val) AND strpos($val, $this->route_prepend) === 0)? 'e': ''; - // If we have the 'e' modifier, remove the prepend from the route value. - $val = $modifier === 'e'? substr($val, strlen($this->route_prepend)): $val; + // Are we using callbacks to process the matches? + if($callable){ + $val = function($matches)use($val){ + // Remove the string we are matching against from the matches array. + array_shift($matches); + + // Distribute the matches to the arguments of the user's callback. + return call_user_func_array($val, $matches); + }; + } + else + { + // Remove the "php:" portion of the string if it exists. + $val = $modifier === 'e'? substr($val, strlen($this->route_prepend)): $val; + } // Do we have a back-reference? - if (strpos($val, '$') !== FALSE && strpos($key, '(') !== FALSE) + if ($callable OR (strpos($val, '$') !== FALSE && strpos($key, '(') !== FALSE)) { - $val = preg_replace('#^'.$key.'$#'.$modifier, $val, $uri); + $val = call_user_func($preg_replace_type, '#^'.$key.'$#'.$modifier, $val, $uri); } return $this->_set_request(explode('/', $val)); -- cgit v1.2.3-24-g4f1b From 0af2d4ffd1735e24dd4f5ee9b17ac6a90508c1e9 Mon Sep 17 00:00:00 2001 From: Jonatas Miguel Date: Mon, 6 Aug 2012 13:05:15 +0200 Subject: revert changes to routing system - part 1 --- system/core/Router.php | 36 ++---------------------------------- 1 file changed, 2 insertions(+), 34 deletions(-) (limited to 'system') diff --git a/system/core/Router.php b/system/core/Router.php index 727e85f7e..5bc053045 100644 --- a/system/core/Router.php +++ b/system/core/Router.php @@ -86,13 +86,6 @@ class CI_Router { * @var string */ public $default_controller; - - /** - * Prepend used in php processed routes - * - * @var string - */ - public $route_prepend = 'php:'; /** * Constructor @@ -380,35 +373,10 @@ class CI_Router { // Does the RegEx match? if (preg_match('#^'.$key.'$#', $uri)) { - // Are we using a callback? - $callable = is_callable($val); - - // Determine the appropriate preg_replace to use. - $preg_replace_type = $callable? 'preg_replace_callback': 'preg_replace'; - - // Are we using the route_prepend to change how we process the matches? - $modifier = (is_string($val) AND strpos($val, $this->route_prepend) === 0)? 'e': ''; - - // Are we using callbacks to process the matches? - if($callable){ - $val = function($matches)use($val){ - // Remove the string we are matching against from the matches array. - array_shift($matches); - - // Distribute the matches to the arguments of the user's callback. - return call_user_func_array($val, $matches); - }; - } - else - { - // Remove the "php:" portion of the string if it exists. - $val = $modifier === 'e'? substr($val, strlen($this->route_prepend)): $val; - } - // Do we have a back-reference? - if ($callable OR (strpos($val, '$') !== FALSE && strpos($key, '(') !== FALSE)) + if (strpos($val, '$') !== FALSE && strpos($key, '(') !== FALSE) { - $val = call_user_func($preg_replace_type, '#^'.$key.'$#'.$modifier, $val, $uri); + $val = preg_replace('#^'.$key.'$#', $val, $uri); } return $this->_set_request(explode('/', $val)); -- cgit v1.2.3-24-g4f1b From c0d98b296186e6206dfa88476199559e630d06d0 Mon Sep 17 00:00:00 2001 From: Jonatas Miguel Date: Mon, 6 Aug 2012 15:42:50 +0100 Subject: New optional routing system, v3 --- system/core/Router.php | 90 ++++++++++++++++++++++++++++++++------------------ 1 file changed, 57 insertions(+), 33 deletions(-) (limited to 'system') diff --git a/system/core/Router.php b/system/core/Router.php index 5bc053045..a5d01b1ee 100644 --- a/system/core/Router.php +++ b/system/core/Router.php @@ -354,39 +354,63 @@ class CI_Router { * @return void */ protected function _parse_routes() - { - // Turn the segment array into a URI string - $uri = implode('/', $this->uri->segments); - - // Is there a literal match? If so we're done - if (isset($this->routes[$uri])) - { - return $this->_set_request(explode('/', $this->routes[$uri])); - } - - // Loop through the route array looking for wild-cards - foreach ($this->routes as $key => $val) - { - // Convert wild-cards to RegEx - $key = str_replace(array(':any', ':num'), array('.+', '[0-9]+'), $key); - - // Does the RegEx match? - if (preg_match('#^'.$key.'$#', $uri)) - { - // Do we have a back-reference? - if (strpos($val, '$') !== FALSE && strpos($key, '(') !== FALSE) - { - $val = preg_replace('#^'.$key.'$#', $val, $uri); - } - - return $this->_set_request(explode('/', $val)); - } - } - - // If we got this far it means we didn't encounter a - // matching route so we'll set the site default route - $this->_set_request($this->uri->segments); - } + { + // Turn the segment array into a URI string + $uri = implode('/', $this->uri->segments); + + // Is there a literal match? If so we're done + if (isset($this->routes[$uri])) + { + return $this->_set_request(explode('/', $this->routes[$uri])); + } + + // Loop through the route array looking for wild-cards + foreach ($this->routes as $key => $val) + { + // Convert wild-cards to RegEx + $key = str_replace(':any', '.+', str_replace(':num', '[0-9]+', $key)); + + // Does the RegEx match? + if (preg_match('#^'.$key.'$#', $uri, $matches)) + { + // Are we using a callback? + $callable = is_callable($val); + + // Are we using callbacks to process back-references? + if($callable){ + // Remove the original string from the matches array. + array_shift($matches); + + // Get the match count. + $matchCount = count($matches); + + // Determine how many parameters the callback has. + $reflection = new ReflectionFunction($val); + $paramCount = count($reflection->getParameters()); + + // Are there more parameters than matches? + if($paramCount > $matchCount){ + // Set any extra params to empty string. + $matches = array_merge($matches, array_fill($matchCount, $paramCount - $matchCount, '')); + } + + // execute callback using matches as its parameters. + $val = call_user_func_array($val, $matches); + } + // Are we using the default routing method for back-references? + else if (strpos($val, '$') !== FALSE AND strpos($key, '(') !== FALSE) + { + $val = preg_replace('#^'.$key.'$#', $val, $uri); + } + + return $this->_set_request(explode('/', $val)); + } + } + + // If we got this far it means we didn't encounter a + // matching route so we'll set the site default route + $this->_set_request($this->uri->segments); + } // -------------------------------------------------------------------- -- cgit v1.2.3-24-g4f1b From 3b45cf62bec6684f35207a1bfb2193f1adc9cd2b Mon Sep 17 00:00:00 2001 From: Jonatas Miguel Date: Mon, 6 Aug 2012 15:47:24 +0100 Subject: Fixed a bug when detecting if the user used a callback. --- system/core/Router.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system') diff --git a/system/core/Router.php b/system/core/Router.php index a5d01b1ee..d6788c314 100644 --- a/system/core/Router.php +++ b/system/core/Router.php @@ -374,7 +374,7 @@ class CI_Router { if (preg_match('#^'.$key.'$#', $uri, $matches)) { // Are we using a callback? - $callable = is_callable($val); + $callable = ! is_string($val) && is_callable($val); // Are we using callbacks to process back-references? if($callable){ -- cgit v1.2.3-24-g4f1b From 07264381020d730ebba9ae95688b73c25e523e54 Mon Sep 17 00:00:00 2001 From: Jonatas Miguel Date: Mon, 6 Aug 2012 16:37:26 +0100 Subject: Corrected code style to be inline with project conventions. --- system/core/Router.php | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'system') diff --git a/system/core/Router.php b/system/core/Router.php index d6788c314..081468944 100644 --- a/system/core/Router.php +++ b/system/core/Router.php @@ -377,24 +377,26 @@ class CI_Router { $callable = ! is_string($val) && is_callable($val); // Are we using callbacks to process back-references? - if($callable){ + if($callable) + { // Remove the original string from the matches array. array_shift($matches); // Get the match count. - $matchCount = count($matches); + $match_count = count($matches); // Determine how many parameters the callback has. $reflection = new ReflectionFunction($val); - $paramCount = count($reflection->getParameters()); + $param_count = count($reflection->getParameters()); // Are there more parameters than matches? - if($paramCount > $matchCount){ - // Set any extra params to empty string. - $matches = array_merge($matches, array_fill($matchCount, $paramCount - $matchCount, '')); + if($param_count > $match_count) + { + // Any params without matches will be set to an empty string. + $matches = array_merge($matches, array_fill($match_count, $param_count - $match_count, '')); } - // execute callback using matches as its parameters. + // Execute the callback using the values in matches as its parameters. $val = call_user_func_array($val, $matches); } // Are we using the default routing method for back-references? -- cgit v1.2.3-24-g4f1b From cf168303ead21d1c8ad89af01458806e6be197fd Mon Sep 17 00:00:00 2001 From: Jonatas Miguel Date: Mon, 6 Aug 2012 17:10:17 +0100 Subject: Updated documentation --- system/core/Router.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system') diff --git a/system/core/Router.php b/system/core/Router.php index 081468944..b11aa9ba5 100644 --- a/system/core/Router.php +++ b/system/core/Router.php @@ -387,7 +387,7 @@ class CI_Router { // Determine how many parameters the callback has. $reflection = new ReflectionFunction($val); - $param_count = count($reflection->getParameters()); + $param_count = $reflection->getNumberOfParameters(); // Are there more parameters than matches? if($param_count > $match_count) -- cgit v1.2.3-24-g4f1b From 59dbe859ffea8159932f6d28b765de615d430cf4 Mon Sep 17 00:00:00 2001 From: Jonatas Miguel Date: Tue, 7 Aug 2012 12:13:32 +0100 Subject: Changed spaces to tabs where necessary. --- system/core/Router.php | 118 ++++++++++++++++++++++++------------------------- 1 file changed, 59 insertions(+), 59 deletions(-) (limited to 'system') diff --git a/system/core/Router.php b/system/core/Router.php index b11aa9ba5..1d566c56f 100644 --- a/system/core/Router.php +++ b/system/core/Router.php @@ -354,65 +354,65 @@ class CI_Router { * @return void */ protected function _parse_routes() - { - // Turn the segment array into a URI string - $uri = implode('/', $this->uri->segments); - - // Is there a literal match? If so we're done - if (isset($this->routes[$uri])) - { - return $this->_set_request(explode('/', $this->routes[$uri])); - } - - // Loop through the route array looking for wild-cards - foreach ($this->routes as $key => $val) - { - // Convert wild-cards to RegEx - $key = str_replace(':any', '.+', str_replace(':num', '[0-9]+', $key)); - - // Does the RegEx match? - if (preg_match('#^'.$key.'$#', $uri, $matches)) - { - // Are we using a callback? - $callable = ! is_string($val) && is_callable($val); - - // Are we using callbacks to process back-references? - if($callable) - { - // Remove the original string from the matches array. - array_shift($matches); - - // Get the match count. - $match_count = count($matches); - - // Determine how many parameters the callback has. - $reflection = new ReflectionFunction($val); - $param_count = $reflection->getNumberOfParameters(); - - // Are there more parameters than matches? - if($param_count > $match_count) - { - // Any params without matches will be set to an empty string. - $matches = array_merge($matches, array_fill($match_count, $param_count - $match_count, '')); - } - - // Execute the callback using the values in matches as its parameters. - $val = call_user_func_array($val, $matches); - } - // Are we using the default routing method for back-references? - else if (strpos($val, '$') !== FALSE AND strpos($key, '(') !== FALSE) - { - $val = preg_replace('#^'.$key.'$#', $val, $uri); - } - - return $this->_set_request(explode('/', $val)); - } - } - - // If we got this far it means we didn't encounter a - // matching route so we'll set the site default route - $this->_set_request($this->uri->segments); - } + { + // Turn the segment array into a URI string + $uri = implode('/', $this->uri->segments); + + // Is there a literal match? If so we're done + if (isset($this->routes[$uri])) + { + return $this->_set_request(explode('/', $this->routes[$uri])); + } + + // Loop through the route array looking for wild-cards + foreach ($this->routes as $key => $val) + { + // Convert wild-cards to RegEx + $key = str_replace(':any', '.+', str_replace(':num', '[0-9]+', $key)); + + // Does the RegEx match? + if (preg_match('#^'.$key.'$#', $uri, $matches)) + { + // Are we using a callback? + $callable = ! is_string($val) && is_callable($val); + + // Are we using callbacks to process back-references? + if($callable) + { + // Remove the original string from the matches array. + array_shift($matches); + + // Get the match count. + $match_count = count($matches); + + // Determine how many parameters the callback has. + $reflection = new ReflectionFunction($val); + $param_count = $reflection->getNumberOfParameters(); + + // Are there more parameters than matches? + if($param_count > $match_count) + { + // Any params without matches will be set to an empty string. + $matches = array_merge($matches, array_fill($match_count, $param_count - $match_count, '')); + } + + // Execute the callback using the values in matches as its parameters. + $val = call_user_func_array($val, $matches); + } + // Are we using the default routing method for back-references? + else if (strpos($val, '$') !== FALSE AND strpos($key, '(') !== FALSE) + { + $val = preg_replace('#^'.$key.'$#', $val, $uri); + } + + return $this->_set_request(explode('/', $val)); + } + } + + // If we got this far it means we didn't encounter a + // matching route so we'll set the site default route + $this->_set_request($this->uri->segments); + } // -------------------------------------------------------------------- -- cgit v1.2.3-24-g4f1b From 3c0846b019ed533852a148eb68c62a02c03d27a8 Mon Sep 17 00:00:00 2001 From: bigCat Date: Tue, 21 Aug 2012 00:20:20 +0800 Subject: China's biggest ICP China Telecom will hijack user and leave a cookie contains | . such as "1345466626|7601294|43373|0|0|0" it's impossible to fix this shit... --- system/core/Input.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system') diff --git a/system/core/Input.php b/system/core/Input.php index 968a42a9a..d7bfed3f8 100644 --- a/system/core/Input.php +++ b/system/core/Input.php @@ -620,7 +620,7 @@ class CI_Input { */ protected function _clean_input_keys($str) { - if ( ! preg_match('/^[a-z0-9:_\/-]+$/i', $str)) + if ( ! preg_match('/^[a-z0-9:_\/|-]+$/i', $str)) { set_status_header(503); exit('Disallowed Key Characters.'); -- cgit v1.2.3-24-g4f1b From f950e5c18d7a36408e33cb11bb67a254362607cc Mon Sep 17 00:00:00 2001 From: Jonatas Miguel Date: Thu, 27 Sep 2012 11:39:33 +0100 Subject: made some corrections to the code --- system/core/Router.php | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) (limited to 'system') diff --git a/system/core/Router.php b/system/core/Router.php index 1d566c56f..0e915521d 100644 --- a/system/core/Router.php +++ b/system/core/Router.php @@ -368,16 +368,13 @@ class CI_Router { foreach ($this->routes as $key => $val) { // Convert wild-cards to RegEx - $key = str_replace(':any', '.+', str_replace(':num', '[0-9]+', $key)); + $key = str_replace(array(':any', ':num'), array('.+', '[0-9]+'), $key); // Does the RegEx match? if (preg_match('#^'.$key.'$#', $uri, $matches)) { - // Are we using a callback? - $callable = ! is_string($val) && is_callable($val); - // Are we using callbacks to process back-references? - if($callable) + if(! is_string($val) && is_callable($val)) { // Remove the original string from the matches array. array_shift($matches); @@ -400,7 +397,7 @@ class CI_Router { $val = call_user_func_array($val, $matches); } // Are we using the default routing method for back-references? - else if (strpos($val, '$') !== FALSE AND strpos($key, '(') !== FALSE) + elseif (strpos($val, '$') !== FALSE && strpos($key, '(') !== FALSE) { $val = preg_replace('#^'.$key.'$#', $val, $uri); } -- cgit v1.2.3-24-g4f1b From 24296ca1e940ac32841cc24a5fdc2f49a0f8ec8a Mon Sep 17 00:00:00 2001 From: Jonatas Miguel Date: Thu, 27 Sep 2012 12:10:01 +0100 Subject: corrected a few more style problems --- system/core/Router.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'system') diff --git a/system/core/Router.php b/system/core/Router.php index 0e915521d..3428ff07b 100644 --- a/system/core/Router.php +++ b/system/core/Router.php @@ -374,7 +374,7 @@ class CI_Router { if (preg_match('#^'.$key.'$#', $uri, $matches)) { // Are we using callbacks to process back-references? - if(! is_string($val) && is_callable($val)) + if ( ! is_string($val) && is_callable($val)) { // Remove the original string from the matches array. array_shift($matches); @@ -387,7 +387,7 @@ class CI_Router { $param_count = $reflection->getNumberOfParameters(); // Are there more parameters than matches? - if($param_count > $match_count) + if ($param_count > $match_count) { // Any params without matches will be set to an empty string. $matches = array_merge($matches, array_fill($match_count, $param_count - $match_count, '')); -- cgit v1.2.3-24-g4f1b From efb81669b8f90352fdabd109e14fdec25bbce8fe Mon Sep 17 00:00:00 2001 From: Jonatas Miguel Date: Tue, 23 Oct 2012 19:52:46 +0100 Subject: users' default values are now respected in callback routes --- system/core/Router.php | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'system') diff --git a/system/core/Router.php b/system/core/Router.php index 3428ff07b..e8addf962 100644 --- a/system/core/Router.php +++ b/system/core/Router.php @@ -391,6 +391,21 @@ class CI_Router { { // Any params without matches will be set to an empty string. $matches = array_merge($matches, array_fill($match_count, $param_count - $match_count, '')); + + $match_count = $param_count; + } + + // Get the parameters so we can use their default values. + $params = $reflection->getParameters(); + + for ($m = 0; $m < $match_count; $m++) + { + // Is the match empty and does a default value exist? + if (empty($matches[$m]) && $params[$m]->isDefaultValueAvailable()) + { + // Substitute the empty match for the default value. + $matches[$m] = $params[$m]->getDefaultValue(); + } } // Execute the callback using the values in matches as its parameters. -- cgit v1.2.3-24-g4f1b From d4516e3562b1c412d7c3edea874eaa6e6922ad0e Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Wed, 31 Oct 2012 14:44:38 +0200 Subject: CI_URI::_detect_uri() to accept absolute URIs (thanks to @sourcejedi, PR #1326) For HTTP/1.1 compliance, RFC2616 specifies that both relative and absolute URI formats must be accepted: - http://localhost/path/ (absolute) - /path/ (relative) --- system/core/URI.php | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) (limited to 'system') diff --git a/system/core/URI.php b/system/core/URI.php index d67a35d4b..3d942eda7 100644 --- a/system/core/URI.php +++ b/system/core/URI.php @@ -185,37 +185,39 @@ class CI_URI { return ''; } - if (strpos($_SERVER['REQUEST_URI'], $_SERVER['SCRIPT_NAME']) === 0) - { - $uri = substr($_SERVER['REQUEST_URI'], strlen($_SERVER['SCRIPT_NAME'])); - } - elseif (strpos($_SERVER['REQUEST_URI'], dirname($_SERVER['SCRIPT_NAME'])) === 0) + $uri = parse_url($_SERVER['REQUEST_URI']); + $query = isset($uri['query']) ? $uri['query'] : ''; + $uri = isset($uri['path']) ? $uri['path'] : ''; + + if (strpos($uri, $_SERVER['SCRIPT_NAME']) === 0) { - $uri = substr($_SERVER['REQUEST_URI'], strlen(dirname($_SERVER['SCRIPT_NAME']))); + $uri = (string) substr($uri, strlen($_SERVER['SCRIPT_NAME'])); } - else + elseif (strpos($uri, dirname($_SERVER['SCRIPT_NAME'])) === 0) { - $uri = $_SERVER['REQUEST_URI']; + $uri = (string) substr($uri, strlen(dirname($_SERVER['SCRIPT_NAME']))); } - // This section ensures that even on servers that require the URI to be in the query string (Nginx) a correct // URI is found, and also fixes the QUERY_STRING server var and $_GET array. - if (strpos($uri, '?/') === 0) + + if ($uri === '' && strncmp($query, '/', 1) === 0) + { + $query = explode('?', $query, 2); + $uri = $query[0]; + $_SERVER['QUERY_STRING'] = isset($query[1]) ? $query[1] : ''; + } + else { - $uri = substr($uri, 2); + $_SERVER['QUERY_STRING'] = $query; } - $parts = explode('?', $uri, 2); - $uri = $parts[0]; - if (isset($parts[1])) + if ($_SERVER['QUERY_STRING'] === '') { - $_SERVER['QUERY_STRING'] = $parts[1]; - parse_str($_SERVER['QUERY_STRING'], $_GET); + $_GET = array(); } else { - $_SERVER['QUERY_STRING'] = ''; - $_GET = array(); + parse_str($_SERVER['QUERY_STRING'], $_GET); } if ($uri === '/' OR $uri === '') @@ -223,8 +225,6 @@ class CI_URI { return '/'; } - $uri = parse_url('pseudo://hostname/'.$uri, PHP_URL_PATH); - // Do some final cleaning of the URI and return it return str_replace(array('//', '../'), '/', trim($uri, '/')); } -- cgit v1.2.3-24-g4f1b From f2b19fee7876708c7a7bb5cba6b7df682a9d2a53 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Wed, 31 Oct 2012 16:16:24 +0200 Subject: Multiple improvements to the URI class (thanks to @sourcejedi, PR #1326 for most of the ideas) - Renamed _detect_uri() and _parse_cli_args() to _parse_request_uri() and _parse_argv() respectively. - Added _parse_query_string() which allows us to detect the URI path from QUERY_STRING much like it is done in _parse_request_uri(). (the above changes also allow for a simpler logic in the case where the *uri_protocol* setting is not set to 'AUTO') - Updated application/config/config.php with a better list of the *uri_protocol* options. - Added _reset_query_string() to aid in re-processing from the QUERY_STRING (utilized in _parse_request_uri() and _parse_query_string()). --- system/core/URI.php | 103 ++++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 75 insertions(+), 28 deletions(-) (limited to 'system') diff --git a/system/core/URI.php b/system/core/URI.php index 3d942eda7..6692d07a6 100644 --- a/system/core/URI.php +++ b/system/core/URI.php @@ -98,12 +98,12 @@ class CI_URI { // Is the request coming from the command line? if ($this->_is_cli_request()) { - $this->_set_uri_string($this->_parse_cli_args()); + $this->_set_uri_string($this->_parse_argv()); return; } // Let's try the REQUEST_URI first, this will work in most situations - if ($uri = $this->_detect_uri()) + if (($uri = $this->_parse_request_uri()) !== '') { $this->_set_uri_string($uri); return; @@ -111,18 +111,17 @@ class CI_URI { // Is there a PATH_INFO variable? // Note: some servers seem to have trouble with getenv() so we'll test it two ways - $path = isset($_SERVER['PATH_INFO']) ? $_SERVER['PATH_INFO'] : @getenv('PATH_INFO'); - if (trim($path, '/') !== '' && $path !== '/'.SELF) + $uri = isset($_SERVER['PATH_INFO']) ? $_SERVER['PATH_INFO'] : @getenv('PATH_INFO'); + if (trim($uri, '/') !== '' && $uri !== '/'.SELF) { $this->_set_uri_string($path); return; } // No PATH_INFO?... What about QUERY_STRING? - $path = isset($_SERVER['QUERY_STRING']) ? $_SERVER['QUERY_STRING'] : @getenv('QUERY_STRING'); - if (trim($path, '/') !== '') + if (($uri = $this->_parse_query_string()) !== '') { - $this->_set_uri_string($path); + $this->_set_uri_string($uri); return; } @@ -140,19 +139,19 @@ class CI_URI { $uri = strtoupper($this->config->item('uri_protocol')); - if ($uri === 'REQUEST_URI') + if ($uri === 'CLI') { - $this->_set_uri_string($this->_detect_uri()); + $this->_set_uri_string($this->_parse_argv()); return; } - elseif ($uri === 'CLI') + elseif (method_exists($this, ($method = '_parse_'.strtolower($uri)))) { - $this->_set_uri_string($this->_parse_cli_args()); + $this->_set_uri_string($this->$method()); return; } - $path = isset($_SERVER[$uri]) ? $_SERVER[$uri] : @getenv($uri); - $this->_set_uri_string($path); + $uri = isset($_SERVER[$uri]) ? $_SERVER[$uri] : @getenv($uri); + $this->_set_uri_string($uri); } // -------------------------------------------------------------------- @@ -172,13 +171,15 @@ class CI_URI { // -------------------------------------------------------------------- /** - * Detects URI + * Parse REQUEST_URI * - * Will detect the URI automatically and fix the query string if necessary. + * Will parse REQUEST_URI and automatically detect the URI from it, + * while fixing the query string if necessary. * + * @used-by CI_URI::_fetch_uri_string() * @return string */ - protected function _detect_uri() + protected function _parse_request_uri() { if ( ! isset($_SERVER['REQUEST_URI'], $_SERVER['SCRIPT_NAME'])) { @@ -197,10 +198,10 @@ class CI_URI { { $uri = (string) substr($uri, strlen(dirname($_SERVER['SCRIPT_NAME']))); } + // This section ensures that even on servers that require the URI to be in the query string (Nginx) a correct // URI is found, and also fixes the QUERY_STRING server var and $_GET array. - - if ($uri === '' && strncmp($query, '/', 1) === 0) + if (trim($uri, '/') === '' && strncmp($query, '/', 1) === 0) { $query = explode('?', $query, 2); $uri = $query[0]; @@ -211,14 +212,7 @@ class CI_URI { $_SERVER['QUERY_STRING'] = $query; } - if ($_SERVER['QUERY_STRING'] === '') - { - $_GET = array(); - } - else - { - parse_str($_SERVER['QUERY_STRING'], $_GET); - } + $this->_reset_query_string(); if ($uri === '/' OR $uri === '') { @@ -231,6 +225,59 @@ class CI_URI { // -------------------------------------------------------------------- + /** + * Parse QUERY_STRING + * + * Will parse QUERY_STRING and automatically detect the URI from it. + * + * @used-by CI_URI::_fetch_uri_string() + * @return string + */ + protected function _parse_query_string() + { + $uri = isset($_SERVER['QUERY_STRING']) ? $_SERVER['QUERY_STRING'] : @getenv('QUERY_STRING'); + + if (trim($uri, '/') === '') + { + return ''; + } + elseif (strncmp($uri, '/', 1) === 0) + { + $uri = explode('?', $uri, 2); + $_SERVER['QUERY_STRING'] = isset($uri[1]) ? $uri[1] : ''; + $uri = $uri[0]; + } + $this->_reset_query_string(); + + return str_replace(array('//', '../'), '/', trim($uri, '/')); + } + + // -------------------------------------------------------------------- + + /** + * Reset QUERY_STRING + * + * Re-processes QUERY_STRING to and fetches the real GET values from it. + * Useful for cases where we got the URI path from it's query string. + * + * @used-by CI_URI::_parse_request_uri() + * @used-by CI_URI::_parse_query_string() + * @return void + */ + protected function _reset_query_string() + { + if ($_SERVER['QUERY_STRING'] === '') + { + $_GET = array(); + } + else + { + parse_str($_SERVER['QUERY_STRING']); + } + } + + // -------------------------------------------------------------------- + /** * Is CLI Request? * @@ -255,10 +302,10 @@ class CI_URI { * * @return string */ - protected function _parse_cli_args() + protected function _parse_argv() { $args = array_slice($_SERVER['argv'], 1); - return $args ? '/'.implode('/', $args) : ''; + return $args ? implode('/', $args) : ''; } // -------------------------------------------------------------------- -- cgit v1.2.3-24-g4f1b From 704f3f5223637dd6008106b1d04a68668458590e Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Wed, 31 Oct 2012 16:50:13 +0200 Subject: Fix an erroneous variable name --- system/core/URI.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system') diff --git a/system/core/URI.php b/system/core/URI.php index 6692d07a6..407a6ce88 100644 --- a/system/core/URI.php +++ b/system/core/URI.php @@ -114,7 +114,7 @@ class CI_URI { $uri = isset($_SERVER['PATH_INFO']) ? $_SERVER['PATH_INFO'] : @getenv('PATH_INFO'); if (trim($uri, '/') !== '' && $uri !== '/'.SELF) { - $this->_set_uri_string($path); + $this->_set_uri_string($uri); return; } -- cgit v1.2.3-24-g4f1b From 9dd2dbb8b9a3edecddcb3907b65a402fd1ae71b4 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Wed, 31 Oct 2012 17:54:56 +0200 Subject: Fix issues #388 & #705 (thanks to @sourcejedi, PR #1326 for pointing inconsistencies with RFC2616 --- system/core/URI.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'system') diff --git a/system/core/URI.php b/system/core/URI.php index 407a6ce88..4a8d33e88 100644 --- a/system/core/URI.php +++ b/system/core/URI.php @@ -188,7 +188,7 @@ class CI_URI { $uri = parse_url($_SERVER['REQUEST_URI']); $query = isset($uri['query']) ? $uri['query'] : ''; - $uri = isset($uri['path']) ? $uri['path'] : ''; + $uri = isset($uri['path']) ? rawurldecode($uri['path']) : ''; if (strpos($uri, $_SERVER['SCRIPT_NAME']) === 0) { @@ -204,7 +204,7 @@ class CI_URI { if (trim($uri, '/') === '' && strncmp($query, '/', 1) === 0) { $query = explode('?', $query, 2); - $uri = $query[0]; + $uri = rawurldecode($query[0]); $_SERVER['QUERY_STRING'] = isset($query[1]) ? $query[1] : ''; } else @@ -245,8 +245,9 @@ class CI_URI { { $uri = explode('?', $uri, 2); $_SERVER['QUERY_STRING'] = isset($uri[1]) ? $uri[1] : ''; - $uri = $uri[0]; + $uri = rawurldecode($uri[0]); } + $this->_reset_query_string(); return str_replace(array('//', '../'), '/', trim($uri, '/')); @@ -325,7 +326,7 @@ class CI_URI { { // preg_quote() in PHP 5.3 escapes -, so the str_replace() and addition of - to preg_quote() is to maintain backwards // compatibility as many are unaware of how characters in the permitted_uri_chars will be parsed as a regex pattern - if ( ! preg_match('|^['.str_replace(array('\\-', '\-'), '-', preg_quote($this->config->item('permitted_uri_chars'), '-')).']+$|i', urldecode($str))) + if ( ! preg_match('|^['.str_replace(array('\\-', '\-'), '-', preg_quote($this->config->item('permitted_uri_chars'), '|')).']+$|i', $str)) { show_error('The URI you submitted has disallowed characters.', 400); } -- cgit v1.2.3-24-g4f1b From ea6688b3b9a7a208d1c44439c4f01801fd3b8c65 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Wed, 31 Oct 2012 21:52:11 +0200 Subject: Fix issue in resetting QUERY_STRING, GET vars introduced in f2b19fee7876708c7a7bb5cba6b7df682a9d2a53 --- system/core/URI.php | 28 ++-------------------------- 1 file changed, 2 insertions(+), 26 deletions(-) (limited to 'system') diff --git a/system/core/URI.php b/system/core/URI.php index 4a8d33e88..3b7718fff 100644 --- a/system/core/URI.php +++ b/system/core/URI.php @@ -212,7 +212,7 @@ class CI_URI { $_SERVER['QUERY_STRING'] = $query; } - $this->_reset_query_string(); + parse_str($_SERVER['QUERY_STRING'], $_GET); if ($uri === '/' OR $uri === '') { @@ -248,37 +248,13 @@ class CI_URI { $uri = rawurldecode($uri[0]); } - $this->_reset_query_string(); + parse_str($_SERVER['QUERY_STRING'], $_GET); return str_replace(array('//', '../'), '/', trim($uri, '/')); } // -------------------------------------------------------------------- - /** - * Reset QUERY_STRING - * - * Re-processes QUERY_STRING to and fetches the real GET values from it. - * Useful for cases where we got the URI path from it's query string. - * - * @used-by CI_URI::_parse_request_uri() - * @used-by CI_URI::_parse_query_string() - * @return void - */ - protected function _reset_query_string() - { - if ($_SERVER['QUERY_STRING'] === '') - { - $_GET = array(); - } - else - { - parse_str($_SERVER['QUERY_STRING']); - } - } - - // -------------------------------------------------------------------- - /** * Is CLI Request? * -- cgit v1.2.3-24-g4f1b From dc6fba5492a215b40c254ed6f704c580427cdfea Mon Sep 17 00:00:00 2001 From: GDmac Date: Wed, 31 Oct 2012 16:53:15 +0100 Subject: Fix #1946 dbforge add_key add_key not setting multiple-column keys when given array Signed-off-by: GDmac --- system/database/DB_forge.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system') diff --git a/system/database/DB_forge.php b/system/database/DB_forge.php index 119d78d38..2be2790dd 100644 --- a/system/database/DB_forge.php +++ b/system/database/DB_forge.php @@ -132,7 +132,7 @@ abstract class CI_DB_forge { */ public function add_key($key = '', $primary = FALSE) { - if (is_array($key)) + if ($primary && is_array($key)) { foreach ($key as $one) { -- cgit v1.2.3-24-g4f1b From 3b72eb58e61581b7e92012a322be48e216491d7c Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Thu, 1 Nov 2012 00:45:26 +0200 Subject: Changed URI auto-detection to try PATH_INFO first (thanks to @sourcejedi, PR #1326) Up until PHP 5.2.4 (which is our new lowest requirement), there was a bug related to PATH_INFO which made REQUEST_URI a more reliable choice. This is now no longer the case, see https://bugs.php.net/bug.php?id=31892 for more details. Also removed ORIG_PATH_INFO from the suggested alternatives for uri_protocol in application/config/config.php as it will not exist in most of PHP's recent versions and is pointless when you can use PATH_INFO anyway. --- system/core/URI.php | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) (limited to 'system') diff --git a/system/core/URI.php b/system/core/URI.php index 3b7718fff..309c77630 100644 --- a/system/core/URI.php +++ b/system/core/URI.php @@ -102,23 +102,21 @@ class CI_URI { return; } - // Let's try the REQUEST_URI first, this will work in most situations - if (($uri = $this->_parse_request_uri()) !== '') + // Is there a PATH_INFO variable? This should be the easiest solution. + if (isset($_SERVER['PATH_INFO'])) { - $this->_set_uri_string($uri); + $this->_set_uri_string($_SERVER['PATH_INFO']); return; } - // Is there a PATH_INFO variable? - // Note: some servers seem to have trouble with getenv() so we'll test it two ways - $uri = isset($_SERVER['PATH_INFO']) ? $_SERVER['PATH_INFO'] : @getenv('PATH_INFO'); - if (trim($uri, '/') !== '' && $uri !== '/'.SELF) + // Let's try REQUEST_URI then, this will work in most situations + if (($uri = $this->_parse_request_uri()) !== '') { $this->_set_uri_string($uri); return; } - // No PATH_INFO?... What about QUERY_STRING? + // No REQUEST_URI either?... What about QUERY_STRING? if (($uri = $this->_parse_query_string()) !== '') { $this->_set_uri_string($uri); -- cgit v1.2.3-24-g4f1b From 87f4dc27230debc0af281c9780f2ba939fe07608 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Thu, 1 Nov 2012 01:11:22 +0200 Subject: Fix an update_string() bug --- system/database/DB_driver.php | 30 +++--------------------------- system/database/DB_query_builder.php | 2 +- 2 files changed, 4 insertions(+), 28 deletions(-) (limited to 'system') diff --git a/system/database/DB_driver.php b/system/database/DB_driver.php index e8286aaa1..795ed6711 100644 --- a/system/database/DB_driver.php +++ b/system/database/DB_driver.php @@ -1080,43 +1080,19 @@ abstract class CI_DB_driver { */ public function update_string($table, $data, $where) { - if ($where === '') + if (empty($where)) { return FALSE; } + $this->where($where); + $fields = array(); foreach ($data as $key => $val) { $fields[$this->protect_identifiers($key)] = $this->escape($val); } - if ( ! is_array($where)) - { - $dest = array($where); - } - else - { - $dest = array(); - foreach ($where as $key => $val) - { - $prefix = (count($dest) === 0) ? '' : ' AND '; - $key = $this->protect_identifiers($key); - - if ($val !== '') - { - if ( ! $this->_has_operator($key)) - { - $key .= ' ='; - } - - $val = ' '.$this->escape($val); - } - - $dest[] = $prefix.$key.$val; - } - } - return $this->_update($this->protect_identifiers($table, TRUE, NULL, FALSE), $fields, $dest); } diff --git a/system/database/DB_query_builder.php b/system/database/DB_query_builder.php index a3585586e..cc43d834c 100644 --- a/system/database/DB_query_builder.php +++ b/system/database/DB_query_builder.php @@ -1575,7 +1575,7 @@ abstract class CI_DB_query_builder extends CI_DB_driver { } $sql = $this->_update($this->protect_identifiers($this->qb_from[0], TRUE, NULL, FALSE), $this->qb_set); - +var_dump($sql); $this->_reset_write(); return $this->query($sql); } -- cgit v1.2.3-24-g4f1b From e2afc886d5e7fe1d55a467c9bc46fe40c1a2bbf6 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Thu, 1 Nov 2012 01:35:34 +0200 Subject: Session cookie driver changes - Changed docs CREATE TABLE ci_sessions example to have the PRIMARY KEY of session_id, ip_address and user_agent combined. - Changed DB updates to add WHERE clauses for the ip_address and/or user_agent strings if sess_match_ip and/or sess_match_useragent are set to TRUE. --- .../libraries/Session/drivers/Session_cookie.php | 36 +++++++++++++++++++--- 1 file changed, 31 insertions(+), 5 deletions(-) (limited to 'system') diff --git a/system/libraries/Session/drivers/Session_cookie.php b/system/libraries/Session/drivers/Session_cookie.php index 2f1bf3531..8f527ace7 100755 --- a/system/libraries/Session/drivers/Session_cookie.php +++ b/system/libraries/Session/drivers/Session_cookie.php @@ -540,11 +540,25 @@ class CI_Session_cookie extends CI_Session_driver { // Check for database if ($this->sess_use_database === TRUE) { + $this->CI->db->where('session_id', $old_sessid); + + if ($this->sess_match_ip === TRUE) + { + $this->CI->db->where('ip_address', $this->CI->input->ip_address()); + } + + if ($this->sess_match_useragent === TRUE) + { + $this->CI->db->where('user_agent', trim(substr($this->CI->input->user_agent(), 0, 120))); + } + // Update the session ID and last_activity field in the DB - $this->CI->db->update($this->sess_table_name, array( - 'last_activity' => $this->now, - 'session_id' => $this->userdata['session_id'] - ), array('session_id' => $old_sessid)); + $this->CI->db->update($this->sess_table_name, + array( + 'last_activity' => $this->now, + 'session_id' => $this->userdata['session_id'] + ) + ); } // Write the cookie @@ -590,7 +604,19 @@ class CI_Session_cookie extends CI_Session_driver { // Run the update query // Any time we change the session id, it gets updated immediately, // so our where clause below is always safe - $this->CI->db->update($this->sess_table_name, $set, array('session_id' => $this->userdata['session_id'])); + $this->CI->db->where('session_id', $this->userdata['session_id']); + + if ($this->sess_match_ip === TRUE) + { + $this->CI->db->where('ip_address', $this->CI->input->ip_address()); + } + + if ($this->sess_match_useragent === TRUE) + { + $this->CI->db->where('user_agent', trim(substr($this->CI->input->user_agent(), 0, 120))); + } + + $this->CI->db->update($this->sess_table_name, $set); // Clear dirty flag to prevent double updates $this->data_dirty = FALSE; -- cgit v1.2.3-24-g4f1b From b107e5728ad867e860d2d4469c1ec523bd3ffac1 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Thu, 1 Nov 2012 11:50:21 +0200 Subject: Remove var_dump() missed in a previous commit --- system/database/DB_query_builder.php | 1 - 1 file changed, 1 deletion(-) (limited to 'system') diff --git a/system/database/DB_query_builder.php b/system/database/DB_query_builder.php index cc43d834c..8a3d3b198 100644 --- a/system/database/DB_query_builder.php +++ b/system/database/DB_query_builder.php @@ -1575,7 +1575,6 @@ abstract class CI_DB_query_builder extends CI_DB_driver { } $sql = $this->_update($this->protect_identifiers($this->qb_from[0], TRUE, NULL, FALSE), $this->qb_set); -var_dump($sql); $this->_reset_write(); return $this->query($sql); } -- cgit v1.2.3-24-g4f1b From 7c4d10660a0a47446474bf97e3cb65f80693f1ee Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Thu, 1 Nov 2012 15:14:34 +0200 Subject: Fix issue #1953 (form values being escaped twice) Re-instaing an improved form_prep() function, reverting most of the changes from 74ffd17ab06327ca62ddfe28a186cae7ba6bd459. --- system/helpers/form_helper.php | 83 ++++++++++++++++++++---------------- system/libraries/Form_validation.php | 10 ++--- 2 files changed, 51 insertions(+), 42 deletions(-) (limited to 'system') diff --git a/system/helpers/form_helper.php b/system/helpers/form_helper.php index 622622c0e..9c4c4dae6 100644 --- a/system/helpers/form_helper.php +++ b/system/helpers/form_helper.php @@ -124,9 +124,9 @@ if ( ! function_exists('form_hidden')) * Generates hidden fields. You can pass a simple key/value string or * an associative array with multiple values. * - * @param mixed - * @param string - * @param bool + * @param mixed $name Field name + * @param string $value Field value + * @param bool $recursing * @return string */ function form_hidden($name, $value = '', $recursing = FALSE) @@ -149,7 +149,7 @@ if ( ! function_exists('form_hidden')) if ( ! is_array($value)) { - $form .= '\n"; + $form .= '\n"; } else { @@ -243,9 +243,9 @@ if ( ! function_exists('form_textarea')) /** * Textarea field * - * @param mixed - * @param string - * @param string + * @param mixed $data + * @param string $value + * @param string $extra * @return string */ function form_textarea($data = '', $value = '', $extra = '') @@ -263,7 +263,7 @@ if ( ! function_exists('form_textarea')) } $name = is_array($data) ? $data['name'] : $data; - return '\n"; + return '\n"; } } @@ -298,10 +298,10 @@ if ( ! function_exists('form_dropdown')) /** * Drop-down Menu * - * @param mixed $name = '' - * @param mixed $options = array() - * @param mixed $selected = array() - * @param mixed $extra = array() + * @param mixed $name + * @param mixed $options + * @param mixed $selected + * @param mixed $extra * @return string */ function form_dropdown($name = '', $options = array(), $selected = array(), $extra = '') @@ -349,7 +349,7 @@ if ( ! function_exists('form_dropdown')) foreach ($val as $optgroup_key => $optgroup_val) { $sel = in_array($optgroup_key, $selected) ? ' selected="selected"' : ''; - $form .= '\n"; } @@ -357,7 +357,7 @@ if ( ! function_exists('form_dropdown')) } else { - $form .= '\n"; } @@ -600,17 +600,28 @@ if ( ! function_exists('form_prep')) * * Formats text so that it can be safely placed in a form field in the event it has HTML tags. * - * @todo Remove in version 3.1+. - * @deprecated 3.0.0 This function has been broken for a long time - * and is now just an alias for html_escape(). It's - * second argument is ignored. - * @param string $str = '' - * @param string $field_name = '' - * @return string + * @param string|string[] $str Value to escape + * @param bool $is_textarea Whether we're escaping for a textarea element + * @return string|string[] Escaped values */ - function form_prep($str = '', $field_name = '') + function form_prep($str = '', $is_textarea = FALSE) { - return html_escape($str); + if (is_array($str)) + { + foreach (array_keys($str) as $key) + { + $str[$key] = form_prep($str[$key], $is_textarea); + } + + return $str; + } + + if ($is_textarea === TRUE) + { + return str_replace(array('<', '>'), array('<', '>'), stripslashes($str)); + } + + return str_replace(array("'", '"'), array(''', '"'), stripslashes($data)); } } @@ -625,23 +636,21 @@ if ( ! function_exists('set_value')) * re-populate an input field or textarea. If Form Validation * is active it retrieves the info from the validation class * - * @param string - * @param string - * @return mixed + * @param string $field Field name + * @param string $default Default value + * @param bool $is_textarea Whether the field is a textarea element + * @return string */ - function set_value($field = '', $default = '') + function set_value($field = '', $default = '', $is_textarea = FALSE) { if (FALSE === ($OBJ =& _get_validation_object())) { - if ( ! isset($_POST[$field])) - { - return html_escape($default); - } - - return html_escape($_POST[$field]); + return isset($_POST[$field]) + ? form_prep($_POST[$field], $is_textarea) + : form_prep($default, $is_textarea); } - return html_escape($OBJ->set_value($field, $default)); + return form_prep($OBJ->set_value($field, $default), $is_textarea); } } @@ -862,8 +871,8 @@ if ( ! function_exists('_parse_form_attributes')) * * Helper function used by some of the form helpers * - * @param array - * @param array + * @param array $attributes List of attributes + * @param array $default Default values * @return string */ function _parse_form_attributes($attributes, $default) @@ -891,7 +900,7 @@ if ( ! function_exists('_parse_form_attributes')) { if ($key === 'value') { - $val = html_escape($val); + $val = form_prep($val); } elseif ($key === 'name' && ! strlen($default['name'])) { diff --git a/system/libraries/Form_validation.php b/system/libraries/Form_validation.php index c1bf51935..74dac7d29 100644 --- a/system/libraries/Form_validation.php +++ b/system/libraries/Form_validation.php @@ -1323,6 +1323,11 @@ class CI_Form_validation { */ public function prep_for_form($data = '') { + if ($this->_safe_form_data === FALSE OR empty($data)) + { + return $data; + } + if (is_array($data)) { foreach ($data as $key => $val) @@ -1333,11 +1338,6 @@ class CI_Form_validation { return $data; } - if ($this->_safe_form_data === FALSE OR $data === '') - { - return $data; - } - return str_replace(array("'", '"', '<', '>'), array(''', '"', '<', '>'), stripslashes($data)); } -- cgit v1.2.3-24-g4f1b From 075f6fa31aab069aaa21a4d6f13e3ca850012d05 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Thu, 1 Nov 2012 15:18:44 +0200 Subject: Fix an erroneous variable name --- system/helpers/form_helper.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system') diff --git a/system/helpers/form_helper.php b/system/helpers/form_helper.php index 9c4c4dae6..2f451b402 100644 --- a/system/helpers/form_helper.php +++ b/system/helpers/form_helper.php @@ -621,7 +621,7 @@ if ( ! function_exists('form_prep')) return str_replace(array('<', '>'), array('<', '>'), stripslashes($str)); } - return str_replace(array("'", '"'), array(''', '"'), stripslashes($data)); + return str_replace(array("'", '"'), array(''', '"'), stripslashes($str)); } } -- cgit v1.2.3-24-g4f1b From 1a9b7e0d1f96b3cee5692f582d860dca4978dee5 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Thu, 1 Nov 2012 16:23:47 +0200 Subject: Remove is_numeric() checks from Cart library (superseded by casts to float) --- system/libraries/Cart.php | 17 +---------------- 1 file changed, 1 insertion(+), 16 deletions(-) (limited to 'system') diff --git a/system/libraries/Cart.php b/system/libraries/Cart.php index d4b17fa36..6cc7ee230 100644 --- a/system/libraries/Cart.php +++ b/system/libraries/Cart.php @@ -193,7 +193,7 @@ class CI_Cart { $items['qty'] = (float) $items['qty']; // If the quantity is zero or blank there's nothing for us to do - if ( ! is_numeric($items['qty']) OR $items['qty'] == 0) + if ($items['qty'] == 0) { return FALSE; } @@ -224,15 +224,6 @@ class CI_Cart { // Prep the price. Remove leading zeros and anything that isn't a number or decimal point. $items['price'] = (float) $items['price']; - // Is the price a valid number? - if ( ! is_numeric($items['price'])) - { - log_message('error', 'An invalid price was submitted for product ID: '.$items['id']); - return FALSE; - } - - // -------------------------------------------------------------------- - // We now need to create a unique identifier for the item being inserted into the cart. // Every time something is added to the cart it is stored in the master cart array. // Each row in the cart array, however, must have a unique index that identifies not only @@ -350,12 +341,6 @@ class CI_Cart { // Prep the quantity $items['qty'] = (float) $items['qty']; - // Is the quantity a number? - if ( ! is_numeric($items['qty'])) - { - return FALSE; - } - // Is the quantity zero? If so we will remove the item from the cart. // If the quantity is greater than zero we are updating if ($items['qty'] == 0) -- cgit v1.2.3-24-g4f1b From c5536aac5752054f7f76e448d58b86407d8f574e Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Thu, 1 Nov 2012 17:33:58 +0200 Subject: Manually apply PR #1594 (fixing phpdoc page-level generation/warnings) Also partially fixes issue #1295, fixes inconsistencies in some page-level docblocks and adds include checks in language files. --- system/core/Benchmark.php | 3 ++- system/core/CodeIgniter.php | 3 ++- system/core/Common.php | 3 ++- system/core/Config.php | 3 ++- system/core/Controller.php | 3 ++- system/core/Exceptions.php | 3 ++- system/core/Hooks.php | 3 ++- system/core/Input.php | 3 ++- system/core/Lang.php | 3 ++- system/core/Loader.php | 3 ++- system/core/Model.php | 3 ++- system/core/Output.php | 3 ++- system/core/Router.php | 3 ++- system/core/Security.php | 3 ++- system/core/URI.php | 3 ++- system/core/Utf8.php | 3 ++- system/database/DB.php | 3 ++- system/database/DB_cache.php | 3 ++- system/database/DB_driver.php | 3 ++- system/database/DB_forge.php | 3 ++- system/database/DB_query_builder.php | 3 ++- system/database/DB_result.php | 3 ++- system/database/DB_utility.php | 3 ++- system/database/drivers/cubrid/cubrid_driver.php | 3 ++- system/database/drivers/cubrid/cubrid_forge.php | 3 ++- system/database/drivers/cubrid/cubrid_result.php | 3 ++- system/database/drivers/cubrid/cubrid_utility.php | 3 ++- system/database/drivers/ibase/ibase_driver.php | 3 ++- system/database/drivers/ibase/ibase_forge.php | 3 ++- system/database/drivers/ibase/ibase_result.php | 3 ++- system/database/drivers/ibase/ibase_utility.php | 3 ++- system/database/drivers/mssql/mssql_driver.php | 3 ++- system/database/drivers/mssql/mssql_forge.php | 3 ++- system/database/drivers/mssql/mssql_result.php | 3 ++- system/database/drivers/mssql/mssql_utility.php | 3 ++- system/database/drivers/mysql/mysql_driver.php | 3 ++- system/database/drivers/mysql/mysql_forge.php | 3 ++- system/database/drivers/mysql/mysql_result.php | 3 ++- system/database/drivers/mysql/mysql_utility.php | 3 ++- system/database/drivers/mysqli/mysqli_driver.php | 3 ++- system/database/drivers/mysqli/mysqli_forge.php | 3 ++- system/database/drivers/mysqli/mysqli_result.php | 3 ++- system/database/drivers/mysqli/mysqli_utility.php | 3 ++- system/database/drivers/oci8/oci8_driver.php | 3 ++- system/database/drivers/oci8/oci8_forge.php | 3 ++- system/database/drivers/oci8/oci8_result.php | 3 ++- system/database/drivers/oci8/oci8_utility.php | 3 ++- system/database/drivers/odbc/odbc_driver.php | 3 ++- system/database/drivers/odbc/odbc_forge.php | 3 ++- system/database/drivers/odbc/odbc_result.php | 3 ++- system/database/drivers/odbc/odbc_utility.php | 3 ++- system/database/drivers/pdo/pdo_driver.php | 3 ++- system/database/drivers/pdo/pdo_forge.php | 3 ++- system/database/drivers/pdo/pdo_result.php | 3 ++- system/database/drivers/pdo/pdo_utility.php | 3 ++- system/database/drivers/pdo/subdrivers/pdo_4d_driver.php | 3 ++- system/database/drivers/pdo/subdrivers/pdo_cubrid_driver.php | 3 ++- system/database/drivers/pdo/subdrivers/pdo_dblib_driver.php | 3 ++- system/database/drivers/pdo/subdrivers/pdo_firebird_driver.php | 3 ++- system/database/drivers/pdo/subdrivers/pdo_ibm_driver.php | 3 ++- system/database/drivers/pdo/subdrivers/pdo_informix_driver.php | 3 ++- system/database/drivers/pdo/subdrivers/pdo_mysql_driver.php | 3 ++- system/database/drivers/pdo/subdrivers/pdo_oci_driver.php | 3 ++- system/database/drivers/pdo/subdrivers/pdo_odbc_driver.php | 3 ++- system/database/drivers/pdo/subdrivers/pdo_pgsql_driver.php | 3 ++- system/database/drivers/pdo/subdrivers/pdo_sqlite_driver.php | 3 ++- system/database/drivers/pdo/subdrivers/pdo_sqlsrv_driver.php | 3 ++- system/database/drivers/postgre/postgre_driver.php | 3 ++- system/database/drivers/postgre/postgre_forge.php | 3 ++- system/database/drivers/postgre/postgre_result.php | 3 ++- system/database/drivers/postgre/postgre_utility.php | 3 ++- system/database/drivers/sqlite/sqlite_driver.php | 3 ++- system/database/drivers/sqlite/sqlite_forge.php | 3 ++- system/database/drivers/sqlite/sqlite_result.php | 3 ++- system/database/drivers/sqlite/sqlite_utility.php | 3 ++- system/database/drivers/sqlite3/sqlite3_driver.php | 3 ++- system/database/drivers/sqlite3/sqlite3_forge.php | 3 ++- system/database/drivers/sqlite3/sqlite3_result.php | 3 ++- system/database/drivers/sqlite3/sqlite3_utility.php | 3 ++- system/database/drivers/sqlsrv/sqlsrv_driver.php | 3 ++- system/database/drivers/sqlsrv/sqlsrv_forge.php | 3 ++- system/database/drivers/sqlsrv/sqlsrv_result.php | 3 ++- system/database/drivers/sqlsrv/sqlsrv_utility.php | 3 ++- system/helpers/array_helper.php | 3 ++- system/helpers/captcha_helper.php | 3 ++- system/helpers/cookie_helper.php | 3 ++- system/helpers/date_helper.php | 3 ++- system/helpers/directory_helper.php | 3 ++- system/helpers/download_helper.php | 3 ++- system/helpers/email_helper.php | 3 ++- system/helpers/file_helper.php | 3 ++- system/helpers/form_helper.php | 4 +++- system/helpers/html_helper.php | 3 ++- system/helpers/inflector_helper.php | 3 ++- system/helpers/language_helper.php | 3 ++- system/helpers/number_helper.php | 3 ++- system/helpers/path_helper.php | 3 ++- system/helpers/security_helper.php | 3 ++- system/helpers/smiley_helper.php | 3 ++- system/helpers/string_helper.php | 3 ++- system/helpers/text_helper.php | 3 ++- system/helpers/typography_helper.php | 3 ++- system/helpers/url_helper.php | 3 ++- system/helpers/xml_helper.php | 3 ++- system/language/english/calendar_lang.php | 1 + system/language/english/date_lang.php | 1 + system/language/english/db_lang.php | 1 + system/language/english/email_lang.php | 1 + system/language/english/form_validation_lang.php | 1 + system/language/english/ftp_lang.php | 1 + system/language/english/imglib_lang.php | 1 + system/language/english/migration_lang.php | 2 +- system/language/english/number_lang.php | 1 + system/language/english/profiler_lang.php | 1 + system/language/english/unit_test_lang.php | 1 + system/language/english/upload_lang.php | 1 + system/libraries/Cache/Cache.php | 5 +++-- system/libraries/Cache/drivers/Cache_apc.php | 5 +++-- system/libraries/Cache/drivers/Cache_dummy.php | 5 +++-- system/libraries/Cache/drivers/Cache_file.php | 5 +++-- system/libraries/Cache/drivers/Cache_memcached.php | 5 +++-- system/libraries/Cache/drivers/Cache_redis.php | 5 +++-- system/libraries/Cache/drivers/Cache_wincache.php | 5 +++-- system/libraries/Calendar.php | 3 ++- system/libraries/Cart.php | 3 ++- system/libraries/Driver.php | 3 ++- system/libraries/Email.php | 3 ++- system/libraries/Encrypt.php | 3 ++- system/libraries/Form_validation.php | 3 ++- system/libraries/Ftp.php | 3 ++- system/libraries/Image_lib.php | 3 ++- system/libraries/Javascript.php | 3 ++- system/libraries/Log.php | 5 +++-- system/libraries/Migration.php | 3 ++- system/libraries/Pagination.php | 3 ++- system/libraries/Parser.php | 3 ++- system/libraries/Profiler.php | 3 ++- system/libraries/Session/Session.php | 5 +++-- system/libraries/Session/drivers/Session_cookie.php | 5 +++-- system/libraries/Session/drivers/Session_native.php | 5 +++-- system/libraries/Table.php | 3 ++- system/libraries/Trackback.php | 3 ++- system/libraries/Typography.php | 3 ++- system/libraries/Unit_test.php | 3 ++- system/libraries/Upload.php | 3 ++- system/libraries/User_agent.php | 3 ++- system/libraries/Xmlrpc.php | 3 ++- system/libraries/Xmlrpcs.php | 3 ++- system/libraries/Zip.php | 3 ++- system/libraries/javascript/Jquery.php | 3 ++- 150 files changed, 300 insertions(+), 150 deletions(-) (limited to 'system') diff --git a/system/core/Benchmark.php b/system/core/Benchmark.php index f94db2721..e80ee54dd 100644 --- a/system/core/Benchmark.php +++ b/system/core/Benchmark.php @@ -1,4 +1,4 @@ -\n\n"; + $message .= '<'."?php if defined('BASEPATH') OR exit('No direct script access allowed'); ?".">\n\n"; } if ( ! $fp = @fopen($filepath, FOPEN_WRITE_CREATE)) diff --git a/system/libraries/Migration.php b/system/libraries/Migration.php index 5d637d44a..06f2f562c 100644 --- a/system/libraries/Migration.php +++ b/system/libraries/Migration.php @@ -1,4 +1,4 @@ - Date: Thu, 1 Nov 2012 19:55:42 +0200 Subject: Allow use of dashes in controller/method URI segments Supersedes PR #642 --- system/core/Router.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'system') diff --git a/system/core/Router.php b/system/core/Router.php index 87f3e9e63..89fb74f2f 100644 --- a/system/core/Router.php +++ b/system/core/Router.php @@ -190,6 +190,7 @@ class CI_Router { { show_error('Unable to determine what should be displayed. A default route has not been specified in the routing file.'); } + // Is the method being specified? if (strpos($this->default_controller, '/') !== FALSE) { @@ -268,9 +269,13 @@ class CI_Router { return $segments; } + $temp = str_replace('-', '_', $segments[0]); + // Does the requested controller exist in the root folder? - if (file_exists(APPPATH.'controllers/'.$segments[0].'.php')) + if (file_exists(APPPATH.'controllers/'.$temp.'.php')) { + $segments[0] = $temp; + empty($segments[1]) OR $segments[1] = str_replace('-', '_', $segments[1]); return $segments; } @@ -283,6 +288,9 @@ class CI_Router { if (count($segments) > 0) { + $segments[0] = str_replace('-', '_', $segments[0]); + empty($segments[1]) OR $segments[1] = str_replace('-', '_', $segments[1]); + // Does the requested controller exist in the sub-folder? if ( ! file_exists(APPPATH.'controllers/'.$this->fetch_directory().$segments[0].'.php')) { -- cgit v1.2.3-24-g4f1b From 254735ee011d99f5c7fe3825849d7ec0b54bd4e1 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Thu, 1 Nov 2012 21:21:20 +0200 Subject: Fix issue #122 --- system/core/URI.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'system') diff --git a/system/core/URI.php b/system/core/URI.php index 2f6cade34..e2cac8d89 100644 --- a/system/core/URI.php +++ b/system/core/URI.php @@ -696,7 +696,14 @@ class CI_URI { */ public function ruri_string() { - return implode('/', $this->rsegment_array()); + global $RTR; + + if (($dir = $RTR->fetch_directory()) === '/') + { + $dir = ''; + } + + return $dir.implode('/', $this->rsegment_array()); } } -- cgit v1.2.3-24-g4f1b From 597ea27a0660bdf72f84d74566cc842e4da37efd Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Thu, 1 Nov 2012 22:56:26 +0200 Subject: [ci skip] DocBlocks for Email, Ftp, Unit_test and Javascript libraries Partially fixes issue #1295 --- system/libraries/Email.php | 327 +++++++++++++++++++++++++++++++++++++--- system/libraries/Ftp.php | 103 +++++++++---- system/libraries/Javascript.php | 17 ++- system/libraries/Unit_test.php | 51 ++++++- 4 files changed, 437 insertions(+), 61 deletions(-) (limited to 'system') diff --git a/system/libraries/Email.php b/system/libraries/Email.php index 0109e2890..62f196c05 100644 --- a/system/libraries/Email.php +++ b/system/libraries/Email.php @@ -39,55 +39,340 @@ defined('BASEPATH') OR exit('No direct script access allowed'); */ class CI_Email { + /** + * Used as the User-Agent and X-Mailer headers' value. + * + * @var string + */ public $useragent = 'CodeIgniter'; + + /** + * Path to the Sendmail binary. + * + * @var string + */ public $mailpath = '/usr/sbin/sendmail'; // Sendmail path + + /** + * Which method to use for sending e-mails. + * + * @var string 'mail', 'sendmail' or 'smtp' + */ public $protocol = 'mail'; // mail/sendmail/smtp - public $smtp_host = ''; // SMTP Server. Example: mail.earthlink.net - public $smtp_user = ''; // SMTP Username - public $smtp_pass = ''; // SMTP Password - public $smtp_port = 25; // SMTP Port - public $smtp_timeout = 5; // SMTP Timeout in seconds - public $smtp_crypto = ''; // SMTP Encryption. Can be null, tls or ssl. - public $wordwrap = TRUE; // TRUE/FALSE - Turns word-wrap on/off - public $wrapchars = 76; // Number of characters to wrap at. - public $mailtype = 'text'; // text/html - Defines email formatting - public $charset = 'utf-8'; // Default char set: iso-8859-1 or us-ascii + + /** + * STMP Server host + * + * @var string + */ + public $smtp_host = ''; + + /** + * SMTP Username + * + * @var string + */ + public $smtp_user = ''; + + /** + * SMTP Password + * + * @var string + */ + public $smtp_pass = ''; + + /** + * SMTP Server port + * + * @var int + */ + public $smtp_port = 25; + + /** + * SMTP connection timeout in seconds + * + * @var int + */ + public $smtp_timeout = 5; + + /** + * SMTP Encryption + * + * @var string NULL, 'tls' or 'ssl' + */ + public $smtp_crypto = NULL; + + /** + * Whether to apply word-wrapping to the message body. + * + * @var bool + */ + public $wordwrap = TRUE; + + /** + * Number of characters to wrap at. + * + * @see CI_Email::$wordwrap + * @var int + */ + public $wrapchars = 76; + + /** + * Message format. + * + * @var string 'text' or 'html' + */ + public $mailtype = 'text'; + + /** + * Character set (default: utf-8) + * + * @var string + */ + public $charset = 'utf-8'; + + /** + * Multipart message + * + * @var string 'mixed' (in the body) or 'related' (separate) + */ public $multipart = 'mixed'; // "mixed" (in the body) or "related" (separate) - public $alt_message = ''; // Alternative message for HTML emails - public $validate = FALSE; // TRUE/FALSE - Enables email validation + + /** + * Alternative message (for HTML messages only) + * + * @var string + */ + public $alt_message = ''; + + /** + * Whether to validate e-mail addresses. + * + * @var bool + */ + public $validate = FALSE; + + /** + * X-Priority header value. + * + * @var int 1-5 + */ public $priority = 3; // Default priority (1 - 5) + + /** + * Newline character sequence. + * Use "\r\n" to comply with RFC 822. + * + * @link http://www.ietf.org/rfc/rfc822.txt + * @var string "\r\n" or "\n" + */ public $newline = "\n"; // Default newline. "\r\n" or "\n" (Use "\r\n" to comply with RFC 822) - public $crlf = "\n"; // The RFC 2045 compliant CRLF for quoted-printable is "\r\n". Apparently some servers, - // even on the receiving end think they need to muck with CRLFs, so using "\n", while - // distasteful, is the only thing that seems to work for all environments. - public $dsn = FALSE; // Delivery Status Notification - public $send_multipart = TRUE; // TRUE/FALSE - Yahoo does not like multipart alternative, so this is an override. Set to FALSE for Yahoo. - public $bcc_batch_mode = FALSE; // TRUE/FALSE - Turns on/off Bcc batch feature - public $bcc_batch_size = 200; // If bcc_batch_mode = TRUE, sets max number of Bccs in each batch + /** + * CRLF character sequence + * + * RFC 2045 specifies that for 'quoted-printable' encoding, + * "\r\n" must be used. However, it appears that some servers + * (even on the receiving end) don't handle it properly and + * switching to "\n", while improper, is the only solution + * that seems to work for all environments. + * + * @link http://www.ietf.org/rfc/rfc822.txt + * @var string + */ + public $crlf = "\n"; + + /** + * Whether to use Delivery Status Notification. + * + * @var bool + */ + public $dsn = FALSE; + + /** + * Whether to send multipart alternatives. + * Yahoo! doesn't seem to like these. + * + * @var bool + */ + public $send_multipart = TRUE; + + /** + * Whether to send messages to BCC recipients in batches. + * + * @var bool + */ + public $bcc_batch_mode = FALSE; + + /** + * BCC Batch max number size. + * + * @see CI_Email::$bcc_batch_mode + * @var int + */ + public $bcc_batch_size = 200; + + // -------------------------------------------------------------------- + + /** + * Whether PHP is running in safe mode. Initialized by the class constructor. + * + * @var bool + */ protected $_safe_mode = FALSE; + + /** + * Subject header + * + * @var string + */ protected $_subject = ''; + + /** + * Message body + * + * @var string + */ protected $_body = ''; + + /** + * Final message body to be sent. + * + * @var string + */ protected $_finalbody = ''; + + /** + * multipart/alternative boundary + * + * @var string + */ protected $_alt_boundary = ''; + + /** + * Attachment boundary + * + * @var string + */ protected $_atc_boundary = ''; + + /** + * Final headers to send + * + * @var string + */ protected $_header_str = ''; + + /** + * SMTP Connection socket placeholder + * + * @var resource + */ protected $_smtp_connect = ''; + + /** + * Mail encoding + * + * @var string '8bit' or '7bit' + */ protected $_encoding = '8bit'; - protected $_IP = FALSE; + + /** + * Whether to perform SMTP authentication + * + * @var bool + */ protected $_smtp_auth = FALSE; + + /** + * Whether to send a Reply-To header + * + * @var bool + */ protected $_replyto_flag = FALSE; + + /** + * Debug messages + * + * @see CI_Email::print_debugger() + * @var string + */ protected $_debug_msg = array(); + + /** + * Recipients + * + * @var string[] + */ protected $_recipients = array(); + + /** + * CC Recipients + * + * @var string[] + */ protected $_cc_array = array(); + + /** + * BCC Recipients + * + * @var string[] + */ protected $_bcc_array = array(); + + /** + * Message headers + * + * @var string[] + */ protected $_headers = array(); + + /** + * Attachment data + * + * @var array + */ protected $_attachments = array(); + + /** + * Valid $protocol values + * + * @see CI_Email::$protocol + * @var string[] + */ protected $_protocols = array('mail', 'sendmail', 'smtp'); - protected $_base_charsets = array('us-ascii', 'iso-2022-'); // 7-bit charsets (excluding language suffix) + + /** + * Base charsets + * + * Character sets valid for 7-bit encoding, + * excluding language suffix. + * + * @var string[] + */ + protected $_base_charsets = array('us-ascii', 'iso-2022-'); + + /** + * Bit depths + * + * Valid mail encodings + * + * @see CI_Email::$_encoding + * @var string[] + */ protected $_bit_depths = array('7bit', '8bit'); + + /** + * $priority translations + * + * Actual values to send with the X-Priority header + * + * @var string[] + */ protected $_priorities = array('1 (Highest)', '2 (High)', '3 (Normal)', '4 (Low)', '5 (Lowest)'); + // -------------------------------------------------------------------- + /** * Constructor - Sets Email Preferences * diff --git a/system/libraries/Ftp.php b/system/libraries/Ftp.php index b9954c7f2..60c03b5ad 100644 --- a/system/libraries/Ftp.php +++ b/system/libraries/Ftp.php @@ -37,18 +37,63 @@ defined('BASEPATH') OR exit('No direct script access allowed'); */ class CI_FTP { + /** + * FTP Server hostname + * + * @var string + */ public $hostname = ''; + + /** + * FTP Username + * + * @var string + */ public $username = ''; + + /** + * FTP Password + * + * @var string + */ public $password = ''; + + /** + * FTP Server port + * + * @var int + */ public $port = 21; + + /** + * Passive mode flag + * + * @var bool + */ public $passive = TRUE; + + /** + * Debug flag + * + * Specifies whether to display error messages. + * + * @var bool + */ public $debug = FALSE; + + /** + * Connection + * + * @var resource + */ public $conn_id = FALSE; + // -------------------------------------------------------------------- + /** * Constructor * - * @param array $config = array() + * @param array $config * @return void */ public function __construct($config = array()) @@ -66,7 +111,7 @@ class CI_FTP { /** * Initialize preferences * - * @param array + * @param array $config * @return void */ public function initialize($config = array()) @@ -88,7 +133,7 @@ class CI_FTP { /** * FTP Connect * - * @param array the connection values + * @param array $config Connection values * @return bool */ public function connect($config = array()) @@ -168,8 +213,8 @@ class CI_FTP { * so we do it by trying to change to a particular directory. * Internally, this parameter is only used by the "mirror" function below. * - * @param string - * @param bool + * @param string $path + * @param bool $supress_debug * @return bool */ public function changedir($path = '', $supress_debug = FALSE) @@ -198,8 +243,8 @@ class CI_FTP { /** * Create a directory * - * @param string - * @param int + * @param string $path + * @param int $permissions * @return bool */ public function mkdir($path = '', $permissions = NULL) @@ -234,10 +279,10 @@ class CI_FTP { /** * Upload a file to the server * - * @param string - * @param string - * @param string - * @param int + * @param string $locpath + * @param string $rempath + * @param string $mode + * @param int $permissions * @return bool */ public function upload($locpath, $rempath, $mode = 'auto', $permissions = NULL) @@ -288,9 +333,9 @@ class CI_FTP { /** * Download a file from a remote server to the local server * - * @param string - * @param string - * @param string + * @param string $rempath + * @param string $locpath + * @param string $mode * @return bool */ public function download($rempath, $locpath, $mode = 'auto') @@ -329,9 +374,9 @@ class CI_FTP { /** * Rename (or move) a file * - * @param string - * @param string - * @param bool + * @param string $old_file + * @param string $new_file + * @param bool $move * @return bool */ public function rename($old_file, $new_file, $move = FALSE) @@ -360,8 +405,8 @@ class CI_FTP { /** * Move a file * - * @param string - * @param string + * @param string $old_file + * @param string $new_file * @return bool */ public function move($old_file, $new_file) @@ -374,7 +419,7 @@ class CI_FTP { /** * Rename (or move) a file * - * @param string + * @param string $filepath * @return bool */ public function delete_file($filepath) @@ -404,7 +449,7 @@ class CI_FTP { * Delete a folder and recursively delete everything (including sub-folders) * containted within it. * - * @param string + * @param string $filepath * @return bool */ public function delete_dir($filepath) @@ -451,8 +496,8 @@ class CI_FTP { /** * Set file permissions * - * @param string the file path - * @param int the permissions + * @param string $path File path + * @param int $perm Permissions * @return bool */ public function chmod($path, $perm) @@ -481,7 +526,7 @@ class CI_FTP { /** * FTP List files in the specified directory * - * @param string $path = '.' + * @param string $path * @return array */ public function list_files($path = '.') @@ -504,8 +549,8 @@ class CI_FTP { * Whatever the directory structure of the original file path will be * recreated on the server. * - * @param string path to source with trailing slash - * @param string path to destination - include the base folder with trailing slash + * @param string $locpath Path to source with trailing slash + * @param string $rempath Path to destination - include the base folder with trailing slash * @return bool */ public function mirror($locpath, $rempath) @@ -551,7 +596,7 @@ class CI_FTP { /** * Extract the file extension * - * @param string + * @param string $filename * @return string */ protected function _getext($filename) @@ -570,7 +615,7 @@ class CI_FTP { /** * Set the upload type * - * @param string + * @param string $ext Filename extension * @return string */ protected function _settype($ext) @@ -617,7 +662,7 @@ class CI_FTP { /** * Display error message * - * @param string + * @param string $line * @return void */ protected function _error($line) diff --git a/system/libraries/Javascript.php b/system/libraries/Javascript.php index c2f458de8..9a15cddaa 100644 --- a/system/libraries/Javascript.php +++ b/system/libraries/Javascript.php @@ -37,12 +37,19 @@ defined('BASEPATH') OR exit('No direct script access allowed'); */ class CI_Javascript { + /** + * JavaScript location + * + * @var string + */ protected $_javascript_location = 'js'; + // -------------------------------------------------------------------- + /** * Constructor * - * @param array $params = array() + * @param array $params * @return void */ public function __construct($params = array()) @@ -587,8 +594,8 @@ class CI_Javascript { * * gather together all script needing to be output * - * @param string $view_var = 'script_foot' - * @param bool $script_tags = TRUE + * @param string $view_var + * @param bool $script_tags * @return string */ public function compile($view_var = 'script_foot', $script_tags = TRUE) @@ -617,8 +624,8 @@ class CI_Javascript { * * Outputs a