From 8310595f0e80f72ac790478b8a7dfc6470051639 Mon Sep 17 00:00:00 2001 From: Iban Eguia Date: Tue, 27 Mar 2012 18:18:15 +0200 Subject: Changed Date helper to return time() based on the timezone parameter. --- system/helpers/date_helper.php | 24 +++++++++--------------- 1 file changed, 9 insertions(+), 15 deletions(-) (limited to 'system') diff --git a/system/helpers/date_helper.php b/system/helpers/date_helper.php index f1ba364f5..aecc7d90f 100644 --- a/system/helpers/date_helper.php +++ b/system/helpers/date_helper.php @@ -46,25 +46,19 @@ */ if ( ! function_exists('now')) { - function now() + function now($timezone = NULL) { - $CI =& get_instance(); + $CI =& get_instance(); - if (strtolower($CI->config->item('time_reference')) == 'gmt') - { - $now = time(); - $system_time = mktime(gmdate("H", $now), gmdate("i", $now), gmdate("s", $now), gmdate("m", $now), gmdate("d", $now), gmdate("Y", $now)); + if (is_null($timezone)) + $timezone = $CI->config->item('timezone'); - if (strlen($system_time) < 10) - { - $system_time = time(); - log_message('error', 'The Date class could not set a proper GMT timestamp so the local time() value was used.'); - } + $timezone = new DateTimeZone($timezone); + $now = new DateTime('now', $timezone); + $offset = $timezone->getOffset($now); + $time = time() + $offset; - return $system_time; - } - - return time(); + return $time; } } -- cgit v1.2.3-24-g4f1b From 7bf0a4ff35efc758ef43b3a848e655285946b8b6 Mon Sep 17 00:00:00 2001 From: Iban Eguia Date: Tue, 27 Mar 2012 18:36:15 +0200 Subject: Added doccumentation for the new date helper. --- system/helpers/date_helper.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'system') diff --git a/system/helpers/date_helper.php b/system/helpers/date_helper.php index aecc7d90f..7ff7444e5 100644 --- a/system/helpers/date_helper.php +++ b/system/helpers/date_helper.php @@ -40,8 +40,10 @@ /** * Get "now" time * - * Returns time() or its GMT equivalent based on the config file preference + * Returns time() based on the timezone parameter or on the "timezone" + * setting * + * @param string * @return int */ if ( ! function_exists('now')) -- cgit v1.2.3-24-g4f1b From 16760bb0d812b951564bd1742af6e622490ca05c Mon Sep 17 00:00:00 2001 From: Iban Eguia Date: Tue, 27 Mar 2012 18:51:52 +0200 Subject: Added braces as requested. --- system/helpers/date_helper.php | 2 ++ 1 file changed, 2 insertions(+) (limited to 'system') diff --git a/system/helpers/date_helper.php b/system/helpers/date_helper.php index 7ff7444e5..14d973f65 100644 --- a/system/helpers/date_helper.php +++ b/system/helpers/date_helper.php @@ -53,7 +53,9 @@ if ( ! function_exists('now')) $CI =& get_instance(); if (is_null($timezone)) + { $timezone = $CI->config->item('timezone'); + } $timezone = new DateTimeZone($timezone); $now = new DateTime('now', $timezone); -- cgit v1.2.3-24-g4f1b From e15e3dde9dca15e2d65f098010d3fb7004cef5e7 Mon Sep 17 00:00:00 2001 From: Iban Eguia Date: Sat, 9 Jun 2012 23:52:27 +0200 Subject: Fixed timezone change in index.php Now it does not ever change the local timezone, and it adds the option to get the 'local' time() --- system/helpers/date_helper.php | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'system') diff --git a/system/helpers/date_helper.php b/system/helpers/date_helper.php index 3b0c3289d..d5acec23f 100644 --- a/system/helpers/date_helper.php +++ b/system/helpers/date_helper.php @@ -57,10 +57,16 @@ if ( ! function_exists('now')) $timezone = $CI->config->item('timezone'); } - $timezone = new DateTimeZone($timezone); - $now = new DateTime('now', $timezone); - $offset = $timezone->getOffset($now); - $time = time() + $offset; + $time = time(); + if(strtolower($timezone) != 'local') + { + $local = new DateTime(NULL, new DateTimeZone(date_default_timezone_get())); + $now = new DateTime(NULL, new DateTimeZone($timezone)); + $lcl_offset = $local->getOffset(); + $tz_offset = $now->getOffset(); + $offset = $tz_offset - $lcl_offset; + $time = $time + $offset; + } return $time; } -- cgit v1.2.3-24-g4f1b From c88daba688d309150a7dce43817ab76ec7834bda Mon Sep 17 00:00:00 2001 From: Iban Eguia Date: Mon, 11 Jun 2012 13:58:30 +0200 Subject: Optimized now() function. Thanks to @narfbg --- system/helpers/date_helper.php | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) (limited to 'system') diff --git a/system/helpers/date_helper.php b/system/helpers/date_helper.php index d5acec23f..b818da9d8 100644 --- a/system/helpers/date_helper.php +++ b/system/helpers/date_helper.php @@ -50,25 +50,20 @@ if ( ! function_exists('now')) */ function now($timezone = NULL) { - $CI =& get_instance(); - - if (is_null($timezone)) + if (empty($timezone)) { - $timezone = $CI->config->item('timezone'); + $timezone = config_item('timezone'); } - $time = time(); - if(strtolower($timezone) != 'local') + if ($timezone === 'local' OR $timezone === date_default_timezone_get()) { - $local = new DateTime(NULL, new DateTimeZone(date_default_timezone_get())); - $now = new DateTime(NULL, new DateTimeZone($timezone)); - $lcl_offset = $local->getOffset(); - $tz_offset = $now->getOffset(); - $offset = $tz_offset - $lcl_offset; - $time = $time + $offset; + return time(); } - return $time; + $datetime = new DateTime('now', new DateTimeZone($timezone)); + sscanf($datetime->format('j-n-Y G:i:s'), '%d-%d-%d %d:%d:%d', $day, $month, $year, $hour, $minute, $second); + + return mktime($hour, $minute, $second, $month, $day, $year); } } -- cgit v1.2.3-24-g4f1b From 6a56d50cc03ec74a905718e711b48253cc267f00 Mon Sep 17 00:00:00 2001 From: Kevin Wood-Friend Date: Tue, 12 Jun 2012 09:54:01 -0400 Subject: Modified Form Validation class's set_rules() so it can now handle an array of rules, instead of just a string --- system/libraries/Form_validation.php | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'system') diff --git a/system/libraries/Form_validation.php b/system/libraries/Form_validation.php index 77c968e7c..6cbe032c7 100644 --- a/system/libraries/Form_validation.php +++ b/system/libraries/Form_validation.php @@ -187,6 +187,12 @@ class CI_Form_validation { return $this; } + // Convert an array of rules to a string + if (is_array($rules)) + { + $rules = implode('|', $rules); + } + // No fields? Nothing to do... if ( ! is_string($field) OR ! is_string($rules) OR $field === '') { -- cgit v1.2.3-24-g4f1b From feb14dac4e7a417a48344a5188a8ad8074871df4 Mon Sep 17 00:00:00 2001 From: Iban Eguia Date: Tue, 12 Jun 2012 16:09:36 +0200 Subject: Changed the config parameter. The session's _get_time() function has also changed. --- system/helpers/date_helper.php | 2 +- system/libraries/Session.php | 14 +++++++++++--- 2 files changed, 12 insertions(+), 4 deletions(-) (limited to 'system') diff --git a/system/helpers/date_helper.php b/system/helpers/date_helper.php index b818da9d8..131508f69 100644 --- a/system/helpers/date_helper.php +++ b/system/helpers/date_helper.php @@ -52,7 +52,7 @@ if ( ! function_exists('now')) { if (empty($timezone)) { - $timezone = config_item('timezone'); + $timezone = config_item('time_reference'); } if ($timezone === 'local' OR $timezone === date_default_timezone_get()) diff --git a/system/libraries/Session.php b/system/libraries/Session.php index 7beedd96b..9fdf744c3 100644 --- a/system/libraries/Session.php +++ b/system/libraries/Session.php @@ -786,9 +786,17 @@ class CI_Session { */ protected function _get_time() { - return (strtolower($this->time_reference) === 'gmt') - ? mktime(gmdate('H'), gmdate('i'), gmdate('s'), gmdate('m'), gmdate('d'), gmdate('Y')) - : time(); + $timezone = config_item('time_reference'); + + if ($timezone === 'local' OR $timezone === date_default_timezone_get()) + { + return time(); + } + + $datetime = new DateTime('now', new DateTimeZone($timezone)); + sscanf($datetime->format('j-n-Y G:i:s'), '%d-%d-%d %d:%d:%d', $day, $month, $year, $hour, $minute, $second); + + return mktime($hour, $minute, $second, $month, $day, $year); } // -------------------------------------------------------------------- -- cgit v1.2.3-24-g4f1b From 97827bc9ddad61f51ceb595e8b8b5441d4d991c2 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Tue, 12 Jun 2012 21:20:05 +0300 Subject: Fix issue #1460 --- system/database/DB_driver.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system') diff --git a/system/database/DB_driver.php b/system/database/DB_driver.php index 88a3b388f..63d3372cf 100644 --- a/system/database/DB_driver.php +++ b/system/database/DB_driver.php @@ -596,7 +596,7 @@ abstract class CI_DB_driver { */ public function compile_binds($sql, $binds) { - if (preg_match_all('/(>|<|=|!)\s*('.preg_quote($this->bind_marker).')/i', $sql, $matches, PREG_SET_ORDER | PREG_OFFSET_CAPTURE) !== count($binds)) + if (preg_match_all('/(>|<|=|!|BETWEEN\s|AND\s)\s*('.preg_quote($this->bind_marker).')/i', $sql, $matches, PREG_SET_ORDER | PREG_OFFSET_CAPTURE) !== count($binds)) { return $sql; } -- cgit v1.2.3-24-g4f1b From 29953ddc989e2ae26afedefd99e347f2d692d0ec Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Tue, 12 Jun 2012 21:48:13 +0300 Subject: Additional improvements to compile_binds() --- system/database/DB_driver.php | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'system') diff --git a/system/database/DB_driver.php b/system/database/DB_driver.php index 63d3372cf..e0266b2b6 100644 --- a/system/database/DB_driver.php +++ b/system/database/DB_driver.php @@ -596,7 +596,12 @@ abstract class CI_DB_driver { */ public function compile_binds($sql, $binds) { - if (preg_match_all('/(>|<|=|!|BETWEEN\s|AND\s)\s*('.preg_quote($this->bind_marker).')/i', $sql, $matches, PREG_SET_ORDER | PREG_OFFSET_CAPTURE) !== count($binds)) + if (empty($binds)) OR empty($this->bind_marker)) + { + return $sql; + } + elseif (preg_match_all('/(>|<|=|!|BETWEEN\s|AND\s)\s*('.preg_quote($this->bind_marker).')/i', + $sql, $matches, PREG_SET_ORDER | PREG_OFFSET_CAPTURE) !== count($binds)) { return $sql; } @@ -610,10 +615,9 @@ abstract class CI_DB_driver { $binds = array_values($binds); } - - for ($i = count($matches) - 1; $i >= 0; $i--) + for ($i = count($matches) - 1, $l = strlen($this->bind_marker); $i >= 0; $i--) { - $sql = substr_replace($sql, $this->escape($binds[$i]), $matches[$i][2][1], 1); + $sql = substr_replace($sql, $this->escape($binds[$i]), $matches[$i][2][1], $l); } return $sql; -- cgit v1.2.3-24-g4f1b From 63779194b6788edfa8899ed3c86c653d0933ce3b Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Wed, 13 Jun 2012 10:04:49 +0300 Subject: Fix a syntax error --- system/database/DB_driver.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system') diff --git a/system/database/DB_driver.php b/system/database/DB_driver.php index e0266b2b6..e04463429 100644 --- a/system/database/DB_driver.php +++ b/system/database/DB_driver.php @@ -596,7 +596,7 @@ abstract class CI_DB_driver { */ public function compile_binds($sql, $binds) { - if (empty($binds)) OR empty($this->bind_marker)) + if (empty($binds) OR empty($this->bind_marker)) { return $sql; } -- cgit v1.2.3-24-g4f1b From 10cbdf091b3cdbc72847dad28a1dce03a92119b6 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Wed, 13 Jun 2012 13:32:30 +0300 Subject: Really fix compile_binds() --- system/database/DB_driver.php | 44 ++++++++++++++++++++++++++++++++++--------- 1 file changed, 35 insertions(+), 9 deletions(-) (limited to 'system') diff --git a/system/database/DB_driver.php b/system/database/DB_driver.php index e04463429..1fece5cf7 100644 --- a/system/database/DB_driver.php +++ b/system/database/DB_driver.php @@ -596,28 +596,54 @@ abstract class CI_DB_driver { */ public function compile_binds($sql, $binds) { - if (empty($binds) OR empty($this->bind_marker)) - { - return $sql; - } - elseif (preg_match_all('/(>|<|=|!|BETWEEN\s|AND\s)\s*('.preg_quote($this->bind_marker).')/i', - $sql, $matches, PREG_SET_ORDER | PREG_OFFSET_CAPTURE) !== count($binds)) + if (empty($binds) OR empty($this->bind_marker) OR strpos($sql, $this->bind_marker) === FALSE) { return $sql; } elseif ( ! is_array($binds)) { - $binds = array($binds); + $binds = array($this->escape($binds)); + $bind_count = 1; } else { // Make sure we're using numeric keys $binds = array_values($binds); + $bind_count = count($binds); + + // Escape the bind values + for ($i = 0; $i < $bind_count; $i++) + { + $binds[$i] = $this->escape($binds[$i]); + } } - for ($i = count($matches) - 1, $l = strlen($this->bind_marker); $i >= 0; $i--) + // Make sure not to replace a chunk inside a string that happens to match the bind marker + if ($c = preg_match_all("/'[^']*'/i", $sql, $matches)) + { + $ml = strlen($this->bind_marker); + $c = preg_match_all('/'.preg_quote($this->bind_marker).'/i', + str_replace($matches[0], + str_replace($this->bind_marker, str_repeat(' ', $ml), $matches[0]), + $sql, $c), + $matches, PREG_OFFSET_CAPTURE); + + // Bind values' count must match the count of markers in the query + if ($bind_count !== $c) + { + return $sql; + } + + do + { + $c--; + $sql = substr_replace($sql, $binds[$c], $matches[0][$c][1], $ml); + } + while ($c !== 0); + } + elseif (substr_count($sql, $this->bind_marker) === count($binds)) { - $sql = substr_replace($sql, $this->escape($binds[$i]), $matches[$i][2][1], $l); + return str_replace($this->bind_marker, $binds, $sql, $bind_count); } return $sql; -- cgit v1.2.3-24-g4f1b From af915ce01e4e5424a7a4ea67e4e3018a40752a89 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Wed, 13 Jun 2012 19:03:06 +0300 Subject: Switch compile_binds() to use substr_replace() instead of str_replace() --- system/database/DB_driver.php | 30 +++++++++++++----------------- 1 file changed, 13 insertions(+), 17 deletions(-) (limited to 'system') diff --git a/system/database/DB_driver.php b/system/database/DB_driver.php index 1fece5cf7..d056bdb90 100644 --- a/system/database/DB_driver.php +++ b/system/database/DB_driver.php @@ -602,7 +602,7 @@ abstract class CI_DB_driver { } elseif ( ! is_array($binds)) { - $binds = array($this->escape($binds)); + $binds = array($binds); $bind_count = 1; } else @@ -610,18 +610,14 @@ abstract class CI_DB_driver { // Make sure we're using numeric keys $binds = array_values($binds); $bind_count = count($binds); - - // Escape the bind values - for ($i = 0; $i < $bind_count; $i++) - { - $binds[$i] = $this->escape($binds[$i]); - } } + // We'll need the marker length later + $ml = strlen($this->bind_marker); + // Make sure not to replace a chunk inside a string that happens to match the bind marker if ($c = preg_match_all("/'[^']*'/i", $sql, $matches)) { - $ml = strlen($this->bind_marker); $c = preg_match_all('/'.preg_quote($this->bind_marker).'/i', str_replace($matches[0], str_replace($this->bind_marker, str_repeat(' ', $ml), $matches[0]), @@ -633,18 +629,18 @@ abstract class CI_DB_driver { { return $sql; } - - do - { - $c--; - $sql = substr_replace($sql, $binds[$c], $matches[0][$c][1], $ml); - } - while ($c !== 0); } - elseif (substr_count($sql, $this->bind_marker) === count($binds)) + elseif (($c = preg_match_all('/'.preg_quote($this->bind_marker).'/i', $sql, $matches, PREG_OFFSET_CAPTURE)) !== $bind_count) + { + return $sql; + } + + do { - return str_replace($this->bind_marker, $binds, $sql, $bind_count); + $c--; + $sql = substr_replace($sql, $this->escape($binds[$c]), $matches[0][$c][1], $ml); } + while ($c !== 0); return $sql; } -- cgit v1.2.3-24-g4f1b From 7400965017f87c3aba18bf75ed7d732359fd577d Mon Sep 17 00:00:00 2001 From: Iban Eguia Date: Wed, 13 Jun 2012 22:57:50 +0200 Subject: Fixed some stuff in documentation. --- system/helpers/date_helper.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'system') diff --git a/system/helpers/date_helper.php b/system/helpers/date_helper.php index 131508f69..a5c46e47b 100644 --- a/system/helpers/date_helper.php +++ b/system/helpers/date_helper.php @@ -42,8 +42,8 @@ if ( ! function_exists('now')) /** * Get "now" time * - * Returns time() based on the timezone parameter or on the "timezone" - * setting + * Returns time() based on the timezone parameter or on the + * "time_reference" setting * * @param string * @return int -- cgit v1.2.3-24-g4f1b From d461934184d95b0cfb2feec93f27b621ef72a5c2 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Thu, 14 Jun 2012 02:27:25 +0300 Subject: Fix issue #10 + URI class speed improvements --- system/core/URI.php | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) (limited to 'system') diff --git a/system/core/URI.php b/system/core/URI.php index a575bc36e..2e661ed4c 100644 --- a/system/core/URI.php +++ b/system/core/URI.php @@ -119,7 +119,7 @@ class CI_URI { } // No PATH_INFO?... What about QUERY_STRING? - $path = (isset($_SERVER['QUERY_STRING'])) ? $_SERVER['QUERY_STRING'] : @getenv('QUERY_STRING'); + $path = isset($_SERVER['QUERY_STRING']) ? $_SERVER['QUERY_STRING'] : @getenv('QUERY_STRING'); if (trim($path, '/') !== '') { $this->_set_uri_string($path); @@ -163,7 +163,7 @@ class CI_URI { * @param string * @return void */ - public function _set_uri_string($str) + protected function _set_uri_string($str) { // Filter out control characters $str = remove_invisible_characters($str, FALSE); @@ -177,8 +177,8 @@ class CI_URI { /** * Detects the URI * - * This function will detect the URI automatically and fix the query string - * if necessary. + * This function will detect the URI automatically + * and fix the query string if necessary. * * @return string */ @@ -189,7 +189,6 @@ class CI_URI { return ''; } - $uri = $_SERVER['REQUEST_URI']; if (strpos($uri, $_SERVER['SCRIPT_NAME']) === 0) { $uri = substr($uri, strlen($_SERVER['SCRIPT_NAME'])); @@ -198,14 +197,19 @@ class CI_URI { { $uri = substr($uri, strlen(dirname($_SERVER['SCRIPT_NAME']))); } + else + { + $uri = $_SERVER['REQUEST_URI']; + } // 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 (strncmp($uri, '?/', 2) === 0) + if (strpos($uri, '?/') === 0) { $uri = substr($uri, 2); } - $parts = preg_split('#\?#i', $uri, 2); + + $parts = explode('?', $uri, 2); $uri = $parts[0]; if (isset($parts[1])) { @@ -223,7 +227,7 @@ class CI_URI { return '/'; } - $uri = parse_url($uri, PHP_URL_PATH); + $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 d163e0b219b8afacea3cd0d1d7c2ce5bb6f8a933 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Thu, 14 Jun 2012 03:09:53 +0300 Subject: Polish changes from pull #1233 - Session class already has the time_reference setting - 'GMT' is a valid timezone, so nothing needs to be changed in order to work properly (upgrade notes) - Altered some description text --- system/libraries/Session.php | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) (limited to 'system') diff --git a/system/libraries/Session.php b/system/libraries/Session.php index 9fdf744c3..72a942b8a 100644 --- a/system/libraries/Session.php +++ b/system/libraries/Session.php @@ -149,11 +149,11 @@ class CI_Session { public $flashdata_key = 'flash'; /** - * Function to use to get the current time + * Timezone to use for the current time * * @var string */ - public $time_reference = 'time'; + public $time_reference = 'local'; /** * Probablity level of garbage collection of old sessions @@ -203,7 +203,7 @@ class CI_Session { // manually via the $params array above or via the config file foreach (array('sess_encrypt_cookie', 'sess_use_database', 'sess_table_name', 'sess_expiration', 'sess_expire_on_close', 'sess_match_ip', 'sess_match_useragent', 'sess_cookie_name', 'cookie_path', 'cookie_domain', 'cookie_secure', 'cookie_httponly', 'sess_time_to_update', 'time_reference', 'cookie_prefix', 'encryption_key') as $key) { - $this->$key = (isset($params[$key])) ? $params[$key] : $this->CI->config->item($key); + $this->$key = isset($params[$key]) ? $params[$key] : $this->CI->config->item($key); } if ($this->encryption_key === '') @@ -786,14 +786,12 @@ class CI_Session { */ protected function _get_time() { - $timezone = config_item('time_reference'); - - if ($timezone === 'local' OR $timezone === date_default_timezone_get()) + if ($this->time_reference === 'local' OR $this->time_reference === date_default_timezone_get()) { return time(); } - $datetime = new DateTime('now', new DateTimeZone($timezone)); + $datetime = new DateTime('now', new DateTimeZone($this->time_reference)); sscanf($datetime->format('j-n-Y G:i:s'), '%d-%d-%d %d:%d:%d', $day, $month, $year, $hour, $minute, $second); return mktime($hour, $minute, $second, $month, $day, $year); -- cgit v1.2.3-24-g4f1b From a8262ba2fe0e11302b8d81e1afba71d4f96cd6d7 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Thu, 14 Jun 2012 03:16:44 +0300 Subject: Fix an issue from d461934184d95b0cfb2feec93f27b621ef72a5c2 --- system/core/URI.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'system') diff --git a/system/core/URI.php b/system/core/URI.php index 2e661ed4c..ef1a12650 100644 --- a/system/core/URI.php +++ b/system/core/URI.php @@ -189,11 +189,11 @@ class CI_URI { return ''; } - if (strpos($uri, $_SERVER['SCRIPT_NAME']) === 0) + if (strpos($_SERVER['REQUEST_URI'], $_SERVER['SCRIPT_NAME']) === 0) { - $uri = substr($uri, strlen($_SERVER['SCRIPT_NAME'])); + $uri = substr($_SERVER['REQUEST_URI'], strlen($_SERVER['SCRIPT_NAME'])); } - elseif (strpos($uri, dirname($_SERVER['SCRIPT_NAME'])) === 0) + elseif (strpos($_SERVER['REQUEST_URI'], dirname($_SERVER['SCRIPT_NAME'])) === 0) { $uri = substr($uri, strlen(dirname($_SERVER['SCRIPT_NAME']))); } -- cgit v1.2.3-24-g4f1b From fb859791182edd2f46479cd69ea4615daebed655 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Thu, 14 Jun 2012 03:32:19 +0300 Subject: And yet another missed line from the last one --- 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 ef1a12650..a997525ee 100644 --- a/system/core/URI.php +++ b/system/core/URI.php @@ -195,7 +195,7 @@ class CI_URI { } elseif (strpos($_SERVER['REQUEST_URI'], dirname($_SERVER['SCRIPT_NAME'])) === 0) { - $uri = substr($uri, strlen(dirname($_SERVER['SCRIPT_NAME']))); + $uri = substr($_SERVER['REQUEST_URI'], strlen(dirname($_SERVER['SCRIPT_NAME']))); } else { -- cgit v1.2.3-24-g4f1b From 3bbbd26ecb60966b07c597310ae241c432bce198 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Thu, 14 Jun 2012 13:35:32 +0300 Subject: Some optimizations to the date helper --- system/helpers/date_helper.php | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) (limited to 'system') diff --git a/system/helpers/date_helper.php b/system/helpers/date_helper.php index a5c46e47b..d5036f645 100644 --- a/system/helpers/date_helper.php +++ b/system/helpers/date_helper.php @@ -314,13 +314,13 @@ if ( ! function_exists('local_to_gmt')) $time = time(); } - return mktime( - gmdate('H', $time), - gmdate('i', $time), - gmdate('s', $time), - gmdate('m', $time), - gmdate('d', $time), - gmdate('Y', $time) + return gmmktime( + date('H', $time), + date('i', $time), + date('s', $time), + date('m', $time), + date('d', $time), + date('Y', $time) ); } } @@ -375,9 +375,7 @@ if ( ! function_exists('mysql_to_unix')) // since the formatting changed with MySQL 4.1 // YYYY-MM-DD HH:MM:SS - $time = str_replace('-', '', $time); - $time = str_replace(':', '', $time); - $time = str_replace(' ', '', $time); + $time = str_replace(array('-', ':', ' '), '', $time); // YYYYMMDDHHMMSS return mktime( -- cgit v1.2.3-24-g4f1b