This file is an extension to Triki Wiki. This extension is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This extension is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this extension. If not, see . */ require("default-db.php"); function isNodeInCache($title) { global $nodedir; // blacklist the title if (blacklistTitle($title)) { return false; } $wikiFile = $nodedir.$title.".wiki"; $cacheFile = $nodedir.$title.".cache"; if (file_exists($wikiFile) && file_exists($cacheFile) && filemtime($wikiFile) < filemtime($cacheFile)) { return TRUE; } return FALSE; } function saveNodeContentsInCache($title, $node) { global $nodedir; // open the file $file = fopen($nodedir.$title.".cache", "w"); if ($file === false) return false; // and lock it flock($file, LOCK_EX); // write content fwrite($file, $node); // finish flock($file, LOCK_UN); } function getNodeContentsFromCache($title) { global $nodedir; if (!isNodeInCache($title)) return false; // open the file $file = fopen($nodedir.$title.".cache", "r"); if ($file === false) return false; // and lock it flock($file, LOCK_SH); // read content $html = fread($file, 65535); $html = rtrim($html); // finish flock($file, LOCK_UN); fclose($file); return $html; } ?>