function thread_top_find($fid = 0) { if ($fid == 0) { $threadlist = db_find("SELECT * FROM `bbs_thread_top` WHERE top=3 ORDER BY tid DESC LIMIT 100", 'tid'); } else { $threadlist = db_find("SELECT * FROM `bbs_thread_top` WHERE fid='{$fid}' AND top=1 ORDER BY tid DESC LIMIT 100", 'tid'); } $tids = arrlist_values($threadlist, 'tid'); $threadlist = thread_find_by_tids($tids, 1, 100); return $threadlist; }
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; }
} elseif ($action == 'move') { $tids = param(2); $arr = explode('_', $tids); $tidarr = param_force($arr, array(0)); empty($tidarr) and message(-1, '请选择主题'); $header['title'] = '移动'; if ($method == 'GET') { // 选中第一个 $tid = $tidarr[0]; $thread = thread_read($tid); include './pc/view/mod_move.htm'; } else { if ($method == 'POST') { $newfid = param('newfid', 0); !forum_read($newfid) and message(1, '板块不存在'); $threadlist = thread_find_by_tids($tidarr, 1, 1000); // 设置置顶 foreach ($threadlist as &$thread) { $fid = $thread['fid']; $tid = $thread['tid']; if (forum_access_mod($fid, $gid, 'allowmove')) { thread_update($tid, array('fid' => $newfid)); $arr = array('uid' => $uid, 'tid' => $thread['tid'], 'pid' => $thread['firstpid'], 'subject' => $thread['subject'], 'comment' => '', 'create_date' => $time, 'action' => 'move'); modlog_create($arr); } } message(0, '移动完成'); } } } elseif ($action == 'deleteuser') { $_uid = param(2, 0);
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; }