function thread_top_find_cache()
{
    global $conf;
    $threadlist = cache_get('thread_top_list');
    if ($threadlist === NULL) {
        $threadlist = thread_top_find();
        cache_set('thread_top_list', $threadlist);
    }
    return $threadlist;
}
Example #2
0
function thread_top_find_cache()
{
    global $conf;
    $threadlist = cache_get('thread_top_list');
    if ($threadlist === NULL) {
        $threadlist = thread_top_find();
        cache_set('thread_top_list', $threadlist);
    } else {
        // 重新格式化时间
        foreach ($threadlist as &$thread) {
            thread_format_last_date($thread);
        }
    }
    return $threadlist;
}
function thread_find_by_fid($fid, $page = 1, $pagesize = 20, $order = 'tid')
{
    global $conf, $forumlist;
    $key = "forum_tids_{$order}_{$fid}";
    if ($page <= $conf['cache_thread_list_pages']) {
        $tids = cache_get($key);
        if ($tids === NULL) {
            $tids = thread_find_tids($fid, $pagesize, $order);
            cache_set($key, $tids);
        }
        $threadlist = thread_find_by_tids($tids, $page, $pagesize, $order);
        // 对数组分页
    } else {
        $desc = TRUE;
        $limitpage = 50000;
        // 如果需要防止 CC 攻击,可以调整为 5000
        if ($page > 100) {
            $forum = $forumlist[$fid];
            $totalpage = ceil($forum['threads'] / $pagesize);
            $halfpage = ceil($totalpage / 2);
            if ($halfpage > $limitpage && $page > $limitpage && $page < $totalpage - $limitpage) {
                $page = $limitpage;
            }
            if ($page > $halfpage) {
                $page = max(1, $totalpage - $page);
                $threadlist = thread_find(array('fid' => $fid), array($order => 1), $page, $pagesize);
                $threadlist = array_reverse($threadlist, TRUE);
                $desc = FALSE;
            }
        }
        if ($desc) {
            $threadlist = thread_find(array('fid' => $fid), array($order => -1), $page, $pagesize);
        }
    }
    // 查找置顶帖
    if ($order == $conf['order_default'] && $page == 1) {
        //$toplist3 = thread_top_find(0);
        $toplist3 = array();
        $toplist1 = thread_top_find($fid);
        $threadlist = $toplist3 + $toplist1 + $threadlist;
    }
    return $threadlist;
}