cache: check if cache folder exists
This commit is contained in:
parent
40fdb17280
commit
c13c7a1d25
1 changed files with 13 additions and 11 deletions
24
index.php
24
index.php
|
@ -26,17 +26,19 @@ ini_set('user_agent', 'Mozilla/5.0 (X11; Linux x86_64; rv:30.0) Gecko/20121202 F
|
||||||
// cache file purge - delete cache files older than 24 hours
|
// cache file purge - delete cache files older than 24 hours
|
||||||
$cacheTimeLimit = time() - 60*60*24 ;
|
$cacheTimeLimit = time() - 60*60*24 ;
|
||||||
$cachePath = 'cache';
|
$cachePath = 'cache';
|
||||||
$cacheIterator = new RecursiveIteratorIterator(
|
if(file_exists($cachePath)) {
|
||||||
new RecursiveDirectoryIterator($cachePath),
|
$cacheIterator = new RecursiveIteratorIterator(
|
||||||
RecursiveIteratorIterator::CHILD_FIRST
|
new RecursiveDirectoryIterator($cachePath),
|
||||||
);
|
RecursiveIteratorIterator::CHILD_FIRST
|
||||||
foreach ($cacheIterator as $cacheFile) {
|
);
|
||||||
if (in_array($cacheFile->getBasename(), array('.', '..')))
|
foreach ($cacheIterator as $cacheFile) {
|
||||||
continue;
|
if (in_array($cacheFile->getBasename(), array('.', '..')))
|
||||||
elseif ($cacheFile->isFile()) {
|
continue;
|
||||||
if( filemtime($cacheFile->getPathname()) < $cacheTimeLimit )
|
elseif ($cacheFile->isFile()) {
|
||||||
unlink( $cacheFile->getPathname() );
|
if( filemtime($cacheFile->getPathname()) < $cacheTimeLimit )
|
||||||
}
|
unlink( $cacheFile->getPathname() );
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// default whitelist
|
// default whitelist
|
||||||
|
|
Loading…
Reference in a new issue