Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'upstream/master'
- Loading branch information
Showing
1,136 changed files
with
44,686 additions
and
17,640 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
# Serendipity - a PHP Weblog/Blog software | ||
|
||
[Serendipity](http://s9y.org) is a PHP-powered weblog application which gives the user an easy way to maintain an online diary, weblog or even a complete homepage. While the default package is designed for the casual blogger, Serendipity offers a flexible, expandable and easy-to-use framework with the power for professional applications. | ||
# Serendipity - A reliable, secure & extensible PHP blog | ||
|
||
[Serendipity](https://s9y.org) is a PHP-powered weblog engine which gives the user an easy way to maintain a blog. While the default package is designed for the casual blogger, Serendipity offers an expandable framework with the power for professional applications. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
<?php | ||
|
||
/** | ||
* This class extends Cache_Lite and offers a cache system driven by a master file | ||
* | ||
* With this class, cache validity is only dependent of a given file. Cache files | ||
* are valid only if they are older than the master file. It's a perfect way for | ||
* caching templates results (if the template file is newer than the cache, cache | ||
* must be rebuild...) or for config classes... | ||
* There are some examples in the 'docs/examples' file | ||
* Technical choices are described in the 'docs/technical' file | ||
* | ||
* @package Cache_Lite | ||
* @author Fabien MARTY <fab@php.net> | ||
*/ | ||
|
||
require_once('Cache/Lite.php'); | ||
|
||
class Cache_Lite_File extends Cache_Lite | ||
{ | ||
|
||
// --- Private properties --- | ||
|
||
/** | ||
* Complete path of the file used for controlling the cache lifetime | ||
* | ||
* @var string $_masterFile | ||
*/ | ||
var $_masterFile = ''; | ||
|
||
/** | ||
* Masterfile mtime | ||
* | ||
* @var int $_masterFile_mtime | ||
*/ | ||
var $_masterFile_mtime = 0; | ||
|
||
// --- Public methods ---- | ||
|
||
/** | ||
* Constructor | ||
* | ||
* $options is an assoc. To have a look at availables options, | ||
* see the constructor of the Cache_Lite class in 'Cache_Lite.php' | ||
* | ||
* Comparing to Cache_Lite constructor, there is another option : | ||
* $options = array( | ||
* (...) see Cache_Lite constructor | ||
* 'masterFile' => complete path of the file used for controlling the cache lifetime(string) | ||
* ); | ||
* | ||
* @param array $options options | ||
* @access public | ||
*/ | ||
function __construct($options = array(NULL)) | ||
{ | ||
$options['lifetime'] = 0; | ||
parent::__construct($options); | ||
if (isset($options['masterFile'])) { | ||
$this->_masterFile = $options['masterFile']; | ||
} else { | ||
return $this->raiseError('Cache_Lite_File : masterFile option must be set !'); | ||
} | ||
if (!($this->_masterFile_mtime = @filemtime($this->_masterFile))) { | ||
return $this->raiseError('Cache_Lite_File : Unable to read masterFile : '.$this->_masterFile, -3); | ||
} | ||
} | ||
|
||
/** | ||
* Test if a cache is available and (if yes) return it | ||
* | ||
* @param string $id cache id | ||
* @param string $group name of the cache group | ||
* @param boolean $doNotTestCacheValidity if set to true, the cache validity won't be tested | ||
* @return string data of the cache (else : false) | ||
* @access public | ||
*/ | ||
function get($id, $group = 'default', $doNotTestCacheValidity = false) | ||
{ | ||
if ($data = parent::get($id, $group, true)) { | ||
if ($filemtime = $this->lastModified()) { | ||
if ($filemtime > $this->_masterFile_mtime) { | ||
return $data; | ||
} | ||
} | ||
} | ||
return false; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.