From a107a0fd79d0ee5f6292138a76398ed390041710 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Fri, 15 Feb 2013 22:30:31 +0200 Subject: Fix some stuff from recent pull requests --- application/config/config.php | 7 +++++-- system/core/Common.php | 6 +++--- system/core/Log.php | 24 +++++++++++++++++------- system/libraries/Profiler.php | 3 +-- user_guide_src/source/changelog.rst | 6 +++--- 5 files changed, 29 insertions(+), 17 deletions(-) diff --git a/application/config/config.php b/application/config/config.php index 6f597b1e2..0608348c6 100644 --- a/application/config/config.php +++ b/application/config/config.php @@ -229,8 +229,11 @@ $config['log_path'] = ''; | Log File Extension |-------------------------------------------------------------------------- | -| Leave this BLANK unless you would like to set something other than the default -| 'php'. For example you could change it to 'log'. +| The default filename extension for log files. The default 'php' allows for +| protecting the log files via basic scripting, when they are to be stored +| under a publicly accessible directory. +| +| Note: Leaving it blank will default to 'php'. | */ $config['log_file_extension'] = ''; diff --git a/system/core/Common.php b/system/core/Common.php index 136dd521c..f8c1290f5 100644 --- a/system/core/Common.php +++ b/system/core/Common.php @@ -414,7 +414,7 @@ if ( ! function_exists('log_message')) function log_message($level = 'error', $message, $php_error = FALSE) { static $_log, $_log_threshold; - + if ($_log_threshold === NULL) { $_log_threshold = config_item('log_threshold'); @@ -429,7 +429,7 @@ if ( ! function_exists('log_message')) { $_log =& load_class('Log', 'core'); } - + $_log->write_log($level, $message, $php_error); } } @@ -713,4 +713,4 @@ if ( ! function_exists('function_usable')) } /* End of file Common.php */ -/* Location: ./system/core/Common.php */ +/* Location: ./system/core/Common.php */ \ No newline at end of file diff --git a/system/core/Log.php b/system/core/Log.php index 0749de8ba..a84d3dc22 100644 --- a/system/core/Log.php +++ b/system/core/Log.php @@ -72,6 +72,13 @@ class CI_Log { */ protected $_date_fmt = 'Y-m-d H:i:s'; + /** + * Filename extension + * + * @var string + */ + protected $_file_ext; + /** * Whether or not the logger can write to the log files * @@ -86,8 +93,10 @@ class CI_Log { */ protected $_levels = array('ERROR' => 1, 'DEBUG' => 2, 'INFO' => 3, 'ALL' => 4); + // -------------------------------------------------------------------- + /** - * Initialize Logging class + * Class constructor * * @return void */ @@ -96,8 +105,8 @@ class CI_Log { $config =& get_config(); $this->_log_path = ($config['log_path'] !== '') ? $config['log_path'] : APPPATH.'logs/'; - - $this->_log_ext = ($config['log_file_extension'] !== '') ? ltrim($config['log_file_extension'], '.') : $this->_log_ext; + $this->_file_ext = (isset($config['log_file_extension']) && $config['log_file_extension'] !== '') + ? ltrim($config['log_file_extension'], '.') : 'php'; file_exists($this->_log_path) OR mkdir($this->_log_path, DIR_WRITE_MODE, TRUE); @@ -149,15 +158,16 @@ class CI_Log { return FALSE; } - $filepath = $this->_log_path.'log-'.date('Y-m-d').'.php'; - $message = ''; + $filepath = $this->_log_path.'log-'.date('Y-m-d').'.'.$this->_file_ext; + $message = ''; if ( ! file_exists($filepath)) { $newfile = TRUE; - if($this->_log_ext === 'php') + // Only add protection to php files + if ($this->_file_ext === 'php') { - $message .= '<'."?php defined('BASEPATH') OR exit('No direct script access allowed'); ?".">\n\n"; + $message .= "\n\n"; } } diff --git a/system/libraries/Profiler.php b/system/libraries/Profiler.php index 36e0431b2..470688fdc 100644 --- a/system/libraries/Profiler.php +++ b/system/libraries/Profiler.php @@ -238,7 +238,6 @@ class CI_Profiler { foreach ($dbs as $name => $db) { $hide_queries = (count($db->queries) > $this->_query_toggle_count) ? ' display:none' : ''; - $total_time = number_format(array_sum($db->query_times), 4).' '.$this->CI->lang->line('profiler_seconds'); $show_hide_js = '('.$this->CI->lang->line('profiler_section_hide').')'; @@ -252,7 +251,7 @@ class CI_Profiler { ."\n" .'  '.$this->CI->lang->line('profiler_database') .':  '.$db->database.' ('.$name.')   '.$this->CI->lang->line('profiler_queries') - .': '.count($db->queries).'('.$total_time.')'.'  '.$show_hide_js."\n\n\n" + .': '.count($db->queries).' ('.$total_time.')  '.$show_hide_js."\n\n\n" .'\n"; if (count($db->queries) === 0) diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst index 140fda8e7..8d3f3705d 100644 --- a/user_guide_src/source/changelog.rst +++ b/user_guide_src/source/changelog.rst @@ -55,7 +55,7 @@ Release Date: Not Released - Updated *ip_address* database field lengths from 16 to 45 for supporting IPv6 address on :doc:`Trackback Library ` and :doc:`Captcha Helper `. - Removed *cheatsheets* and *quick_reference* PDFs from the documentation. - Added availability checks where usage of dangerous functions like ``eval()`` and ``exec()`` is required. - - Added support for changing the file extension of CodeIgniter log files using $config['log_file_extension']. + - Added support for changing the file extension of log files using ``$config['log_file_extension']``. - Helpers @@ -273,8 +273,8 @@ Release Date: Not Released - Added support for hashing algorithms other than SHA1 and MD5. - Removed previously deprecated ``sha1()`` method. - :doc:`Profiler Library ` changes include: - - Database object names displayed. - - The sum of all queries running times in seconds displayed. + - Database object names are now being displayed. + - The sum of all queries running times in seconds is now being displayed. - :doc:`Migration Library ` changes include: - Added support for timestamp-based migrations (enabled by default). - Added ``$config['migration_type']`` to allow switching between *sequential* and *timestamp* migrations. -- cgit v1.2.3-24-g4f1b