forked from blallo/rss-bridge
Implement basic cache purge (issue #178)
This commit is contained in:
parent
10c3dfa60e
commit
40fdb17280
1 changed files with 16 additions and 0 deletions
16
index.php
16
index.php
|
@ -23,6 +23,22 @@ if (!extension_loaded('openssl'))
|
||||||
ini_set('user_agent', 'Mozilla/5.0 (X11; Linux x86_64; rv:30.0) Gecko/20121202 Firefox/30.0 (rss-bridge/0.1; +https://github.com/sebsauvage/rss-bridge)');
|
ini_set('user_agent', 'Mozilla/5.0 (X11; Linux x86_64; rv:30.0) Gecko/20121202 Firefox/30.0 (rss-bridge/0.1; +https://github.com/sebsauvage/rss-bridge)');
|
||||||
// -------
|
// -------
|
||||||
|
|
||||||
|
// cache file purge - delete cache files older than 24 hours
|
||||||
|
$cacheTimeLimit = time() - 60*60*24 ;
|
||||||
|
$cachePath = 'cache';
|
||||||
|
$cacheIterator = new RecursiveIteratorIterator(
|
||||||
|
new RecursiveDirectoryIterator($cachePath),
|
||||||
|
RecursiveIteratorIterator::CHILD_FIRST
|
||||||
|
);
|
||||||
|
foreach ($cacheIterator as $cacheFile) {
|
||||||
|
if (in_array($cacheFile->getBasename(), array('.', '..')))
|
||||||
|
continue;
|
||||||
|
elseif ($cacheFile->isFile()) {
|
||||||
|
if( filemtime($cacheFile->getPathname()) < $cacheTimeLimit )
|
||||||
|
unlink( $cacheFile->getPathname() );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// default whitelist
|
// default whitelist
|
||||||
$whitelist_file = './whitelist.txt';
|
$whitelist_file = './whitelist.txt';
|
||||||
$whitelist_default = array(
|
$whitelist_default = array(
|
||||||
|
|
Loading…
Reference in a new issue