Пример #1
0
 $fid = $thread['fid'];
 $forum = forum_read($fid);
 empty($forum) and message(3, '板块不存在' . $fid);
 $postlist = post_find_by_tid($tid);
 empty($postlist) and message(4, '帖子不存在');
 empty($postlist[$thread['firstpid']]) and message(-1, '数据有问题。');
 $first = $postlist[$thread['firstpid']];
 unset($postlist[$thread['firstpid']]);
 $header['title'] = $thread['subject'] . '-' . $forum['name'] . '-' . $conf['sitename'];
 // 网站标题
 $header['keywords'] = $header['title'];
 // 关键词
 $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'];
 // 模板需要
 // 升级需要查找附件
Пример #2
0
function thread_find_by_keyword($keyword)
{
    $threadlist = db_find("SELECT * FROM `bbs_thread` WHERE subject LIKE '%{$keyword}%' LIMIT 60");
    arrlist_multisort($threadlist, 'tid', FALSE);
    // 用 PHP 排序,mysql 排序消耗太大。
    if ($threadlist) {
        foreach ($threadlist as &$thread) {
            thread_format($thread);
            $thread['subject'] = post_highlight_keyword($thread['subject'], $keyword);
        }
    }
    return $threadlist;
}