Ejemplo n.º 1
0
    $tid = $post['tid'];
    $thread = thread_read($tid);
    empty($thread) and message(-1, '主题不存在:' . $tid);
    $fid = $thread['fid'];
    $forum = forum_read($fid);
    empty($forum) and message(-1, '板块不存在:' . $fid);
    $isfirst = $post['isfirst'];
    !forum_access_user($fid, $gid, 'allowpost') and message(-1, '您(' . $user['groupname'] . ')无权限在此版块回帖');
    $allowdelete = forum_access_mod($fid, $gid, 'allowdelete');
    !$allowdelete and !$post['allowdelete'] and message(-1, '无权删除该帖');
    if ($isfirst) {
        // 清除所有的回复。喜欢。还有相关资源
        thread_delete($tid);
    } else {
        post_delete($pid);
        post_list_cache_delete($tid);
    }
    message(0, '删除成功');
    // 接受 base64 文件上传
} elseif ($action == 'upload') {
    // 允许的文件后缀名
    $types = (include './conf/attach.conf.php');
    $allowtypes = $types['all'];
    empty($uid) and message(-1, '游客不允许上传文件');
    empty($group['allowattach']) and $gid != 1 and message(-1, '您无权上传');
    $conf['ipaccess_on'] and !ipaccess_check($longip, 'attachs') and message(-1, '您的 IP 今日上传附件数达到上限,请明天再来。');
    $conf['ipaccess_on'] and !ipaccess_check($longip, 'attachsizes') and message(-1, '您的 IP 今日上传附件尺寸达到上限,请明天再来。');
    $isimage = param(2, 0);
    $tid = 0;
    $fid = 0;
    $upfile = param('upfile', '', FALSE);
Ejemplo n.º 2
0
function post_delete($pid)
{
    global $conf;
    $post = post_read_cache($pid);
    if (empty($post)) {
        return TRUE;
    }
    // 已经不存在了。
    $tid = $post['tid'];
    $uid = $post['uid'];
    $thread = thread_read_cache($tid);
    $fid = $thread['fid'];
    $r = post__delete($pid);
    if ($r === FALSE) {
        return FALSE;
    }
    !$post['isfirst'] and thread__update($tid, array('posts-' => 1));
    !$post['isfirst'] and $uid and user__update($uid, array('posts-' => 1));
    !$post['isfirst'] and runtime_set('posts-', 1);
    // 清理赞同
    $uid and myagree_delete($uid, $pid, $post['isfirst']);
    // 清理缓存
    $post['isfirst'] and post_list_cache_delete($tid);
    $post['images'] || $post['files'] and attach_delete_by_pid($pid);
    return $r;
}