在 function_core.php
的 output()
函数中,相关代码为:
if(defined('CACHE_FILE') && CACHE_FILE && !defined('CACHE_FORBIDDEN') && !defined('IN_MOBILE') && !checkmobile()) {
if(diskfreespace(DISCUZ_ROOT.'./'.$_G['setting']['cachethreaddir']) > 1000000) {
if($fp = @fopen(CACHE_FILE, 'w')) {
flock($fp, LOCK_EX);
fwrite($fp, empty($content) ? ob_get_contents() : $content);
}
@fclose($fp);
chmod(CACHE_FILE, 0777);
}
}
output
函数在所有的 footer.htm
都有调用
所以之前要有定义 CACHE_FILE
这个全局常量。
定义 CACHE_FILE
的位置有两处:
1:
forum_index.php
的 get_index_page_guest_cache()
函数,相关代码:
if(TIMESTAMP - $indexcache['filemtime'] > $_G['setting']['cacheindexlife']) {
@unlink($indexcache['filename']);
define('CACHE_FILE', $indexcache['filename']);
2:
forum_viewthread.php
的 viewthread_loadcache()
函数,相关代码:
$_G['forum']['livedays'] = ceil((TIMESTAMP - $_G['forum']['dateline']) / 86400);
$_G['forum']['lastpostdays'] = ceil((TIMESTAMP - $_G['forum']['lastthreadpost']) / 86400);
$threadcachemark = 100 - (
$_G['forum']['displayorder'] * 15 +
$_G['thread']['digest'] * 10 +
min($_G['thread']['views'] / max($_G['forum']['livedays'], 10) * 2, 50) +
max(-10, (15 - $_G['forum']['lastpostdays'])) +
min($_G['thread']['replies'] / $_G['setting']['postperpage'] * 1.5, 15));
if($threadcachemark < $_G['forum']['threadcaches']) {
$threadcache = getcacheinfo($_G['tid']);
if(TIMESTAMP - $threadcache['filemtime'] > $_G['setting']['cachethreadlife']) {
@unlink($threadcache['filename']);
define('CACHE_FILE', $threadcache['filename']);