diff options
Diffstat (limited to 'system')
-rw-r--r-- | system/core/Log.php | 2 | ||||
-rw-r--r-- | system/core/Output.php | 26 |
2 files changed, 22 insertions, 6 deletions
diff --git a/system/core/Log.php b/system/core/Log.php index 9dabfe6f2..cd3c17e1e 100644 --- a/system/core/Log.php +++ b/system/core/Log.php @@ -97,6 +97,8 @@ class CI_Log { $this->_log_path = ($config['log_path'] !== '') ? $config['log_path'] : APPPATH.'logs/'; + file_exists($this->_log_path) OR mkdir($this->_log_path, DIR_WRITE_MODE, TRUE); + if ( ! is_dir($this->_log_path) OR ! is_really_writable($this->_log_path)) { $this->_enabled = FALSE; diff --git a/system/core/Output.php b/system/core/Output.php index 27e711783..a20841463 100644 --- a/system/core/Output.php +++ b/system/core/Output.php @@ -544,9 +544,15 @@ class CI_Output { $expire = time() + ($this->cache_expiration * 60); + // Put together our serialized info. + $cache_info = serialize(array( + 'expire' => $expire, + 'headers' => $this->headers + )); + if (flock($fp, LOCK_EX)) { - fwrite($fp, $expire.'TS--->'.$output); + fwrite($fp, $cache_info.'ENDCI--->'.$output); flock($fp, LOCK_UN); } else @@ -595,14 +601,16 @@ class CI_Output { flock($fp, LOCK_UN); fclose($fp); - // Strip out the embedded timestamp - if ( ! preg_match('/^(\d+)TS--->/', $cache, $match)) + // Look for embedded serialized file info. + if ( ! preg_match('/^(.*)ENDCI--->/', $cache, $match)) { return FALSE; } + $cache_info = unserialize($match[1]); + $expire = $cache_info['expire']; + $last_modified = filemtime($cache_path); - $expire = $match[1]; // Has the file expired? if ($_SERVER['REQUEST_TIME'] >= $expire && is_really_writable($cache_path)) @@ -618,6 +626,12 @@ class CI_Output { $this->set_cache_header($last_modified, $expire); } + // Add headers from cache file. + foreach ($cache_info['headers'] as $header) + { + $this->set_header($header[0], $header[1]); + } + // Display the cache $this->_display(substr($cache, strlen($match[0]))); log_message('debug', 'Cache file is current. Sending it to browser.'); @@ -742,7 +756,7 @@ class CI_Output { $output = preg_replace('{\s*<!--[^\[<>].*(?<!!)-->\s*}msU', '', $output); // Remove spaces around block-level elements. - $output = preg_replace('/\s*(<\/?(html|head|title|meta|script|link|style|body|h[1-6]|div|p|br)[^>]*>)\s*/is', '$1', $output); + $output = preg_replace('/\s*(<\/?(html|head|title|meta|script|link|style|body|table|thead|tbody|tfoot|tr|th|td|h[1-6]|div|p|br)[^>]*>)\s*/is', '$1', $output); // Replace mangled <pre> etc. tags with unprocessed ones. @@ -758,7 +772,7 @@ class CI_Output { $output = str_replace($codes_messed[0], $codes_clean[0], $output); } - if ( ! empty($codes_clean)) + if ( ! empty($textareas_clean)) { preg_match_all('{<textarea.+</textarea>}msU', $output, $textareas_messed); $output = str_replace($textareas_messed[0], $textareas_clean[0], $output); |