function thread_new_find()
{
    $threadlist = db_find("SELECT * FROM `bbs_thread_new` ORDER BY tid DESC LIMIT 100");
    if (empty($threadlist)) {
        $threadlist = thread_find(array(), array('tid' => -1), 1, 100);
        foreach ($threadlist as $thread) {
            thread_new_create($thread['tid']);
        }
    } else {
        $tids = arrlist_values($threadlist, 'tid');
        $threadlist = thread_find_by_tids($tids, 1, 100, 'tid');
    }
    return $threadlist;
}
function thread_lastpid_find()
{
    $threadlist = db_find("SELECT * FROM `bbs_thread_lastpid` ORDER BY lastpid DESC LIMIT 100");
    if (empty($threadlist)) {
        // 此处特殊情况,一般不会执行到此处,无须索引
        $threadlist = thread_find(array(), array('lastpid' => -1), 1, 100);
        foreach ($threadlist as $thread) {
            thread_lastpid_create($thread['tid'], $thread['lastpid']);
        }
    } else {
        $tids = arrlist_values($threadlist, 'tid');
        $threadlist = thread_find_by_tids($tids, 1, 100, 'lastpid');
    }
    return $threadlist;
}
示例#3
0
文件: thread.php 项目: xiuno/xiunobbs
 $keyword = param('keyword');
 // 可能有关键字需要高亮显示
 if ($keyword) {
     $thread['subject'] = post_highlight_keyword($thread['subject'], $keyword);
     //$first['message'] = post_highlight_keyword($first['subject']);
 }
 $allowpost = forum_access_user($fid, $gid, 'allowpost') ? 1 : 0;
 $allowupdate = forum_access_mod($fid, $gid, 'allowupdate') ? 1 : 0;
 $allowdelete = forum_access_mod($fid, $gid, 'allowdelete') ? 1 : 0;
 forum_access_user($fid, $gid, 'allowread') or message(-1, '您所在的用户组无权访问该板块。');
 // ajax 不需要以下数据
 // threadlist
 $page = 1;
 $pagesize = $conf['pagesize'];
 $pages = pages("forum-{$fid}-{page}.htm", $forum['threads'], $page, $pagesize);
 $threadlist = thread_find(array('fid' => $fid), array('tid' => -1), $page = 1, $pagesize);
 $seo_url = $thread['seo_url'];
 // 模板需要
 // 升级需要查找附件
 $attachlist = $imagelist = $filelist = array();
 if ($first['images'] || $first['files']) {
     $attachlist = attach_find_by_pid($first['pid']);
     list($imagelist, $filelist) = attach_list_not_in_message($attachlist, $first['message']);
 }
 thread_inc_views($tid);
 // 如果是大站,可以用单独的点击服务,减少 db 压力
 $header['navs'][] = "<a href=\"forum-{$fid}.htm\">{$forum['name']}</a>";
 $header['navs'][] = "<a href=\"{$thread['url']}\">{$thread['subject']}</a>";
 if (!$group['allowviewip']) {
     unset($thread['userip']);
     unset($thread['sid']);
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;
}