Example #1
0
 /**
  * 新回复
  */
 public function newReply($reply_id, $content)
 {
     $this->checkLogin();
     $data = $this->topicContent($reply_id, 'topic_id');
     if (!$data) {
         throw new bbsException('帖子内容 id=' . $reply_id . ' 不存在!', 404);
     }
     $topic_id = $data['topic_id'];
     //内容处理
     $ubb = new ubbparser();
     $data = $ubb->parse($content, true);
     //写回复数据
     $time = $_SERVER['REQUEST_TIME'];
     $floor = $this->db->query('SELECT max(floor) FROM ' . DB_A . 'bbs_topic_content WHERE topic_id=?', $topic_id);
     $floor = $floor->fetch(db::num);
     $rs = $this->db->insert('bbs_topic_content', 'ctime,mtime,content,uid,topic_id,reply_id,floor', $time, $time, $data, $this->user->uid, $topic_id, $reply_id, $floor[0] + 1);
     return $rs ? true : false;
 }
Example #2
0
$tpl = $PAGE->start();
$USER->start();
$user = $USER;
$chat = new chat();
if ($PAGE->ext[0]) {
    $roomname = $PAGE->ext[0];
    $tpl->assign('roomname', $roomname);
    $chat->checkroom($roomname);
    if ($_POST['go']) {
        if (!$user->islogin) {
            $err_msg = '你必须要<a href="user.login">登录</a>才能发言';
        } else {
            if ($_POST['neirong'] == '') {
                $err_msg = '内容不能为空';
            } else {
                $ubb = new ubbparser();
                $content = $ubb->parse($_POST['neirong'], true);
                $chat->chatsay($roomname, $user->uid, $user->name, $content, time());
            }
        }
    }
    $ubbs = new ubbdisplay();
    $tpl->assign('ubbs', $ubbs);
    $tpl->assign('err_msg', $err_msg);
    $chatlist = $chat->chatlist($roomname);
    $tpl->assign('chatlist', $chatlist);
    $tpl->display("tpl:chat");
} else {
    //聊天室列表
    $list = $chat->roomlist();
    $tpl->assign('list', $list);