예제 #1
0
        $title = $_POST['title'];
        $content = $_POST['content'];
        if (trim($title) == '') {
            throw new Exception('标题不能为空');
        }
        if (trim($content) == '') {
            throw new Exception('内容不能为空');
        }
        $token = new token($USER);
        $ok = $token->check($_POST['token']);
        if (!$ok) {
            throw new EXception('会话已过期,请重新发布');
        }
        $token->delete();
        $bbs = new bbs($USER);
        $ok = $bbs->newtopic($fid, $title, $content);
        if (!$ok) {
            throw new Exception('未知原因发帖失败,请重试或联系管理员');
        }
        $tpl->assign('tid', $ok);
        $tpl->display('tpl:topicsuccess');
    } else {
        throw new Exception('');
    }
} catch (Exception $err) {
    $tpl->assign('err', $err);
    if ($USER->islogin) {
        $token = new token($USER);
        $token->create();
        $tpl->assign('token', $token);
    }