public function purge() { $this->language->load('module/pagecache'); $which = $this->request->get['which']; if ($which != "all" && $which != "expired") { $this->response->setOutput(json_encode(array('error' => 'invalid value for which'))); return; } require_once DIR_SYSTEM . 'library/pagecache.php'; $pagecache = new PageCache(); $vals = $pagecache->Settings(); $expire = $vals['expire']; $cachefolder = $vals['cachefolder']; $range = array('0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'); $count = 0; foreach ($range as $f) { foreach ($range as $s) { $dname = $cachefolder . $f . '/' . $s; if (is_dir($dname) && @($dir = opendir($dname))) { while (false !== ($file = readdir($dir))) { // only purge files that end in .cache if (substr($file, -6) == '.cache') { $fpath = $dname . '/' . $file; if ($which == 'all') { unlink($fpath); $count++; } elseif ($which == 'expired') { if (filectime($fpath) + $expire < time()) { unlink($fpath); $count++; } } } } } } } $message = sprintf($this->language->get('pc_purged'), $count); $this->response->setOutput(json_encode(array('success' => $message))); }