/** * Clean Table of Contents Cache Files */ function clean_cache() { set_time_limit(0); global $vars; $page = isset($vars['page']) ? $vars['page'] : ''; if ($page != '') { $toc = new PluginSonotsToc(); $file = $toc->syntax['cachefile']($page); @unlink($file); if (exec_page($page, '/^#contentsx/')) { $body = 'Recreated a cache of '; } else { $body = 'No #contentsx in '; } $body .= make_pagelink($page); } else { $toc = new PluginSonotsToc(); $file = $toc->syntax['cachefile']('hoge'); $suffix = substr($file, strrpos($file, '.')); // remove all files $files = sonots::get_existfiles(CACHE_DIR, $suffix); foreach ($files as $file) { unlink($file); } // execute all pages $exec_pages = sonots::exec_existpages('', '/^#contentsx/'); $links = array_map('make_pagelink', $exec_pages); $body = '<p>Following pages were executed to assure:</p>' . '<p>' . implode("<br />\n", $links) . '</p>'; } return $body; }