function cleanCache() { $files = dirList(getcwd() . '/cache/'); foreach ($files as $key => $value) { #echo "$value - last update:". intToTime(getLastUpdate($value)).' -- next update in '.intToTime(getNextUpdate($value)).'<br>'; if (stripos($value, 'current-ranking.cache') || stripos($value, 'home.cache')) { // this is the ranking -> update this more often! 600 = every 10 minutes if (getNextUpdate($value, RANKING_REFRESH_TIME) < -1) { // file is out of date -> delete (will be renewed when next user requests...) unlink($value); } // file deleted! } else { if (getNextUpdate($value) < -1) { // file is out of date -> delete (will be renewed when next user requests...) unlink($value); } } // file deleted! } }
#echo $template; } elseif (strcasecmp($GO, 'search') == 0) { $SEARCHVALUE = isset($_POST["searchvalue"]) ? $_POST["searchvalue"] : "0"; if ($SEARCHVALUE) { $searchresults = getSearchResults($SEARCHVALUE); } include_once './template/search.php'; #echo $template; } else { // show the top ten $LASTUPDATE = 0; $NEXTUPDATE = 0; if (isCached('home')) { $template = getCache('home'); $LASTUPDATE = intToTime(getLastUpdate(getcwd() . '/cache/home.cache')); $NEXTUPDATE = intToTime(getNextUpdate(getcwd() . '/cache/home.cache', RANKING_REFRESH_TIME)); } else { $topten = getTopTen(); include_once './template/home.php'; // write cache file writeCache('home', $template); $LASTUPDATE = intToTime(0); $NEXTUPDATE = intToTime(RANKING_REFRESH_TIME); } $template = str_replace('{:LASTUPDATE:}', $LASTUPDATE, $template); $template = str_replace('{:NEXTUPDATE:}', $NEXTUPDATE, $template); } /*************************************************************** * CLOSE DATABASE CONNECTION AND PROCESS PAGE LOAD TIME ***************************************************************/ mysql_close($link);