function thread_top_change($tid, $top = 0)
{
    $thread = thread__read($tid);
    if (empty($thread)) {
        return FALSE;
    }
    if ($top != $thread['top']) {
        thread__update($tid, array('top' => $top));
        $fid = $thread['fid'];
        $tid = $thread['tid'];
        thread_top_cache_delete();
        thread_tids_cache_delete($fid);
        thread_new_cache_delete();
        return db_exec("REPLACE INTO `bbs_thread_top` SET fid='{$fid}', tid='{$tid}', top='{$top}'");
    }
    return FALSE;
}
Exemple #2
0
     check_standard_browser();
     include './flarum/view/post_create.htm';
 } else {
     $agree = param('agree', 0);
     $message = param('message', '', FALSE);
     !trim(str_replace(array(' ', '&nbsp;', '<br>', '<br/>', '<br />'), '', $message)) and message(2, '内容不能为空');
     $gid != 1 and $message = xn_html_safe($message);
     $gid != 1 and $message = badword_filter($message, $badword);
     $message === FALSE and message(2, '内容中包含敏感关键词: ' . $badword);
     mb_strlen($message, 'UTF-8') > 2048000 and message('内容太长');
     $quick and $message = nl2br(str_replace("\t", "&nbsp; &nbsp; &nbsp; &nbsp; ", $message));
     // 检测是否灌水
     post_check_flood($gid, $tid, $message) and message(2, '系统检测到您可能在灌水');
     // 检测是否超过最大回复数
     $thread['posts'] >= 1000 and message(-1, '该主题已经达到最大回复数 1000,不能再回复,请另起主题。');
     $thread['top'] > 0 and thread_top_cache_delete();
     # 论坛帖子数据,一页显示,不分页。
     $post = array('tid' => $tid, 'uid' => $uid, 'create_date' => $time, 'userip' => $longip, 'sid' => $sid, 'isfirst' => 0, 'message' => $message);
     $pid = post_create($post, $fid);
     empty($pid) and message(1, '创建帖子失败');
     // 喜欢,不通过服务端,客户端 ajax 发起请求更简洁
     //if($agree) {
     //	$r = agree_update($thread['uid'], $thread['firstpid'], $tid, $fid, 1);
     //}
     // 最新发帖
     // thread_top_create($fid, $tid);
     $post = post_read($pid);
     $post['floor'] = $thread['posts'] + 1;
     $postlist = array($post);
     $allowpost = forum_access_user($fid, $gid, 'allowpost');
     $allowupdate = forum_access_mod($fid, $gid, 'allowupdate');
function thread_delete($tid)
{
    global $conf;
    $thread = thread__read($tid);
    if (empty($thread)) {
        return TRUE;
    }
    $fid = $thread['fid'];
    $uid = $thread['uid'];
    $r = thread__delete($tid);
    if ($r === FALSE) {
        return FALSE;
    }
    // 删除所有回帖,同时更新 posts 统计数
    $n = post_delete_by_tid($tid);
    // 删除我的主题
    $uid and mythread_delete($uid, $tid);
    // 删除附件
    // 更新统计
    forum__update($fid, array('threads-' => 1));
    user__update($uid, array('threads-' => 1));
    // 删除 SEO URL
    thread_url_delete($tid);
    // 全站统计
    runtime_set('threads-', 1);
    // 清除相关缓存
    thread_tids_cache_delete($fid);
    forum_list_cache_delete();
    // 最新和置顶也清理
    thread_new_delete($tid);
    thread_top_delete($tid);
    thread_lastpid_delete($tid);
    thread_new_cache_delete();
    thread_top_cache_delete();
    thread_lastpid_cache_delete();
    return $r;
}