summaryrefslogtreecommitdiffstats
path: root/system/core/Output.php
diff options
context:
space:
mode:
Diffstat (limited to 'system/core/Output.php')
-rw-r--r--system/core/Output.php105
1 files changed, 49 insertions, 56 deletions
diff --git a/system/core/Output.php b/system/core/Output.php
index 349955cd2..a3155fece 100644
--- a/system/core/Output.php
+++ b/system/core/Output.php
@@ -123,11 +123,11 @@ class CI_Output {
public $parse_exec_vars = TRUE;
/**
- * mbstring.func_override flag
+ * mbstring.func_overload flag
*
* @var bool
*/
- protected static $func_override;
+ protected static $func_overload;
/**
* Class constructor
@@ -145,7 +145,7 @@ class CI_Output {
&& extension_loaded('zlib')
);
- isset(self::$func_override) OR self::$func_override = (extension_loaded('mbstring') && ini_get('mbstring.func_override'));
+ isset(self::$func_overload) OR self::$func_overload = (extension_loaded('mbstring') && ini_get('mbstring.func_overload'));
// Get mime types for later
$this->mimes =& get_mimes();
@@ -586,62 +586,59 @@ class CI_Output {
return;
}
- if (flock($fp, LOCK_EX))
+ if ( ! flock($fp, LOCK_EX))
{
- // If output compression is enabled, compress the cache
- // itself, so that we don't have to do that each time
- // we're serving it
- if ($this->_compress_output === TRUE)
- {
- $output = gzencode($output);
+ log_message('error', 'Unable to secure a file lock for file at: '.$cache_path);
+ fclose($fp);
+ return;
+ }
- if ($this->get_header('content-type') === NULL)
- {
- $this->set_content_type($this->mime_type);
- }
+ // If output compression is enabled, compress the cache
+ // itself, so that we don't have to do that each time
+ // we're serving it
+ if ($this->_compress_output === TRUE)
+ {
+ $output = gzencode($output);
+
+ if ($this->get_header('content-type') === NULL)
+ {
+ $this->set_content_type($this->mime_type);
}
+ }
- $expire = time() + ($this->cache_expiration * 60);
+ $expire = time() + ($this->cache_expiration * 60);
- // Put together our serialized info.
- $cache_info = serialize(array(
- 'expire' => $expire,
- 'headers' => $this->headers
- ));
+ // Put together our serialized info.
+ $cache_info = serialize(array(
+ 'expire' => $expire,
+ 'headers' => $this->headers
+ ));
- $output = $cache_info.'ENDCI--->'.$output;
+ $output = $cache_info.'ENDCI--->'.$output;
- for ($written = 0, $length = self::strlen($output); $written < $length; $written += $result)
+ for ($written = 0, $length = self::strlen($output); $written < $length; $written += $result)
+ {
+ if (($result = fwrite($fp, self::substr($output, $written))) === FALSE)
{
- if (($result = fwrite($fp, self::substr($output, $written))) === FALSE)
- {
- break;
- }
+ break;
}
-
- flock($fp, LOCK_UN);
- }
- else
- {
- log_message('error', 'Unable to secure a file lock for file at: '.$cache_path);
- return;
}
+ flock($fp, LOCK_UN);
fclose($fp);
- if (is_int($result))
- {
- chmod($cache_path, 0640);
- log_message('debug', 'Cache file written: '.$cache_path);
-
- // Send HTTP cache-control headers to browser to match file cache settings.
- $this->set_cache_header($_SERVER['REQUEST_TIME'], $expire);
- }
- else
+ if ( ! is_int($result))
{
@unlink($cache_path);
log_message('error', 'Unable to write the complete cache content at: '.$cache_path);
+ return;
}
+
+ chmod($cache_path, 0640);
+ log_message('debug', 'Cache file written: '.$cache_path);
+
+ // Send HTTP cache-control headers to browser to match file cache settings.
+ $this->set_cache_header($_SERVER['REQUEST_TIME'], $expire);
}
// --------------------------------------------------------------------
@@ -708,11 +705,9 @@ class CI_Output {
log_message('debug', 'Cache file has expired. File deleted.');
return FALSE;
}
- else
- {
- // Or else send the HTTP cache control headers.
- $this->set_cache_header($last_modified, $expire);
- }
+
+ // Send the HTTP cache control headers
+ $this->set_cache_header($last_modified, $expire);
// Add headers from cache file.
foreach ($cache_info['headers'] as $header)
@@ -798,13 +793,11 @@ class CI_Output {
$this->set_status_header(304);
exit;
}
- else
- {
- header('Pragma: public');
- header('Cache-Control: max-age='.$max_age.', public');
- header('Expires: '.gmdate('D, d M Y H:i:s', $expiration).' GMT');
- header('Last-modified: '.gmdate('D, d M Y H:i:s', $last_modified).' GMT');
- }
+
+ header('Pragma: public');
+ header('Cache-Control: max-age='.$max_age.', public');
+ header('Expires: '.gmdate('D, d M Y H:i:s', $expiration).' GMT');
+ header('Last-modified: '.gmdate('D, d M Y H:i:s', $last_modified).' GMT');
}
// --------------------------------------------------------------------
@@ -817,7 +810,7 @@ class CI_Output {
*/
protected static function strlen($str)
{
- return (self::$func_override)
+ return (self::$func_overload)
? mb_strlen($str, '8bit')
: strlen($str);
}
@@ -834,7 +827,7 @@ class CI_Output {
*/
protected static function substr($str, $start, $length = NULL)
{
- if (self::$func_override)
+ if (self::$func_overload)
{
// mb_substr($str, $start, null, '8bit') returns an empty
// string on PHP 5.3