<title>[(site_name)] | [*pagetitle*]</title> ... [*#content*]
function emptyCache() {
if(!isset($this->cachePath)) {
echo "Cache path not set.";
exit;
}
$filesincache = 0;
$deletedfilesincache = 0;
// if (function_exists('glob')) {
// // New and improved!
// $files = glob(realpath($this->cachePath).'/*');
// $filesincache = count($files);
//
// $deletedfiles = array();
// while ($file = array_shift($files)) {
// $name = basename($file);
// if (preg_match('/\.pageCache/',$name) && !in_array($name, $deletedfiles)) {
// $deletedfilesincache++;
// $deletedfiles[] = $name;
// unlink($file);
// }
// }
// } else {
// Old way of doing it (no glob function available)
if ($handle = opendir($this->cachePath)) {
// Initialize deleted per round counter
$deletedThisRound = 1;
while ($deletedThisRound){
if(!$handle) $handle = opendir($this->cachePath);
$deletedThisRound = 0;
while (false !== ($file = readdir($handle))) {
if ($file != "." && $file != "..") {
$filesincache += 1;
if ( preg_match("/\.pageCache/", $file) && (!is_array($deletedfiles) || !array_search($file,$deletedfiles)) ) {
$deletedfilesincache += 1;
$deletedThisRound++;
$deletedfiles[] = $file;
unlink($this->cachePath.$file);
} // End if
} // End if
} // End while
closedir($handle);
$handle = '';
} // End while ($deletedThisRound)
}
// }
<title>[(site_name)] | [*pagetitle*]</title>
...
[*#content*]
<title>[(site_name)] | [*pagetitle*]</title> ... [*content*]