public function getSession($id)
 {
     $id = intval($id);
     //获取当前聊天
     $talk = $this->getTalk(0, $id);
     $uids = D('Talk')->getUids($talk['uids']);
     foreach ($uids as $uid) {
         if ($uid != is_login()) {
             $talk['first_user'] = query_user(array('avatar64', 'username'), $uid);
             $talk['ico'] = $talk['first_user']['avatar64'];
             break;
         }
     }
     $map['talk_id'] = $talk['id'];
     D('TalkPush')->where(array('uid' => get_uid(), 'source_id' => $id))->setField('status', -1);
     D('TalkMessagePush')->where(array('uid' => get_uid(), 'talk_id' => $id))->setField('status', -1);
     $messages = D('TalkMessage')->where($map)->order('create_time desc')->limit(20)->select();
     $messages = array_reverse($messages);
     foreach ($messages as &$mes) {
         $mes['user'] = query_user(array('avatar64', 'uid', 'username'), $mes['uid']);
         $mes['ctime'] = date('m-d h:i', $mes['create_time']);
         $mes['avatar64'] = $mes['user']['avatar64'];
         $mes['content'] = parse_expression($mes['content']);
     }
     unset($mes);
     $talk['messages'] = $messages;
     $talk['self'] = query_user(array('avatar128'), is_login());
     $talk['mid'] = is_login();
     echo json_encode($talk);
 }
 public function parseComment($content)
 {
     $content = shorten_white_space($content);
     $content = op_t($content, false);
     $content = parse_url_link($content);
     $content = parse_expression($content);
     //        $content = parseWeiboContent($content);
     return $content;
 }
Esempio n. 3
0
function parse_weibo_content($content)
{
    $content = shorten_white_space($content);
    $content = op_t($content, false);
    $content = parse_url_link($content);
    $content = parse_expression($content);
    $content = parse_at_users($content);
    $content = parseWeiboContent($content);
    return $content;
}
function parse_weibo_content($content)
{
    $content = shorten_white_space($content);
    if (modC('WEIBO_BR', 0, 'Weibo')) {
        $content = str_replace('/br', '<br/>', $content);
        $content = str_replace('/nb', '&nbsp', $content);
    } else {
        $content = str_replace('/br', '', $content);
        $content = str_replace('/nb', '', $content);
    }
    $content = parse_url_link($content);
    $content = parse_expression($content);
    $content = parseWeiboContent($content);
    return $content;
}
 public function addMoreReply()
 {
     $aPage = I('post.page', 1, 'op_t');
     $aCount = I('post.count', 10, 'op_t');
     $aLzlPage = I('post.lzlpage', 1, 'op_t');
     $aLzlCount = I('post.lzlcount', 3, 'op_t');
     $aId = I('post.group_id', 10, 'op_t');
     //获取帖子评论信息
     $postComment = M('GroupPostReply')->where(array('post_id' => $aId, 'status' => 1))->page($aPage, $aCount)->select();
     foreach ($postComment as &$v) {
         $v['user'] = query_user(array('nickname', 'avatar32', 'space_mob_url'), $v['uid']);
         $v['content'] = parse_expression($v['content']);
         if ($postComment['uid'] == $v['uid']) {
             $v['floormaster'] = "楼主";
         }
         //楼中楼内容
         $v['lzllist'] = $list = M('GroupLzlReply')->getLZLReplyList($v['id'], 'create_time asc', $aLzlPage, $aLzlCount);
         $v['lzltotalCount'] = $totalCountLzl = M('GroupLzlReply')->where('status=1 and to_f_reply_id=' . $v['id'])->count();
         if ($totalCountLzl <= $aLzlPage * $aLzlCount) {
             $v['lzlcount'] = 0;
         } else {
             $v['lzlcount'] = 1;
         }
         $data['to_f_reply_id'] = $v['id'];
         $pageCount = ceil($totalCountLzl / $aLzlCount);
         $v['lzlhtml'] = $html = getPageHtml('changePage', $pageCount, $data, $aLzlPage);
         //楼中楼内容结束
     }
     if ($postComment) {
         $data['html'] = "";
         foreach ($postComment as $key => $val) {
             $this->assign("vl", $val);
             $this->assign("k", ($aPage - 1) * $aCount + $key + 1);
             $data['html'] .= $this->fetch("_postcomment");
             $data['status'] = 1;
         }
     } else {
         $data['stutus'] = 0;
     }
     $this->ajaxReturn($data);
 }
 public function postMessage($content, $talk_id)
 {
     $content = op_t($content);
     //空的内容不能发送
     if (!trim($content)) {
         $this->error(L('_ERROR_CHAT_CONTENT_EMPTY_'));
     }
     M('TalkMessage')->addMessage($content, is_login(), $talk_id);
     $talk = M('Talk')->find($talk_id);
     $message = M('Message')->find($talk['message_id']);
     if ($talk['appname'] != '') {
         $messageModel = $this->getMessageModel($message);
         $messageModel->postMessage($message, $talk, $content, is_login());
     }
     exit(json_encode(array('status' => 1, 'content' => parse_expression($content))));
     $this->success(L('_SUCCESS_SEND_'));
 }
 public function addMoreQuestionCommentList($id)
 {
     $aPage = I('post.page', 1, 'op_t');
     $aCount = I('post.count', 10, 'op_t');
     $questionDetail = M('Question')->where(array('status' => 1, 'id' => $id))->order('create_time desc')->find();
     $map['id'] = array('neq', $questionDetail['best_answer']);
     $questioncomment = M('QuestionAnswer')->where(array('status' => 1, 'question_id' => $id, $map))->order('support desc,create_time desc')->page($aPage, $aCount)->select();
     foreach ($questioncomment as &$v) {
         $v['user'] = query_user(array('nickname', 'avatar32', 'uid', 'space_mob_url'), $v['uid']);
         $v['content'] = parse_expression($v['content']);
         $v['support_user'] = M('QuestionSupport')->where(array('row' => $v['id'], 'type' => 1))->select();
         foreach ($v['support_user'] as &$a) {
             $a['user'] = query_user(array('nickname', 'avatar32', 'uid', 'space_mob_url'), $a['uid']);
         }
         $v['has_support'] = M('QuestionSupport')->where(array('uid' => is_login(), 'row' => $v['id']))->find();
         //判断是否支持过或者贬低过
     }
     if ($questioncomment) {
         $data['html'] = "";
         foreach ($questioncomment as $val) {
             $this->assign("vl", $val);
             $data['html'] .= $this->fetch("_commentlist");
             $data['status'] = 1;
         }
     } else {
         $data['stutus'] = 0;
     }
     $this->ajaxReturn($data);
 }
 public function postMessage($content, $talk_id)
 {
     $content = op_t($content);
     //空的内容不能发送
     if (!trim($content)) {
         $this->error('聊天内容不能为空');
     }
     D('TalkMessage')->addMessage($content, is_login(), $talk_id);
     $talk = D('Talk')->find($talk_id);
     $message = D('Message')->find($talk['message_id']);
     if ($talk['appname'] != '') {
         $messageModel = $this->getMessageModel($message);
         $messageModel->postMessage($message, $talk, $content, is_login());
     }
     exit(json_encode(array('status' => 1, 'content' => parse_expression($content))));
     $this->success("发送成功");
 }
 public function blogDetail($id)
 {
     $aPage = I('post.page', 1, 'op_t');
     $aCount = I('post.count', 10, 'op_t');
     $this->setTopTitle('资讯详情');
     $blog_detail = M('News')->where(array('id' => $id))->find();
     $blog_detail['meta']['description'] = mb_substr($blog_detail['description'], 0, 50, 'UTF-8');
     //取得前50个字符
     $blog_detail['meta']['keywords'] = M('NewsCategory')->where(array('id' => $blog_detail['category']))->field('title')->find();
     $blog_detail['user'] = query_user(array('nickname', 'avatar32', 'uid'), $blog_detail['uid']);
     //dump($blog_detail);exit;
     if ($blog_detail['cover'] == 0) {
         $blog_detail['cover_url'] = 'no_img';
     } else {
         //获得原图
         $bi = D('Picture')->where(array('status' => 1))->getById($blog_detail['cover']);
         if (!is_bool(strpos($bi['path'], 'http://'))) {
             $blog_detail['cover_url'] = $bi['path'];
         } else {
             $blog_detail['cover_url'] = getRootUrl() . substr($bi['path'], 1);
         }
     }
     M('News')->where(array('id' => $id))->setInc('view');
     //查看数加1
     $blog_content = M('NewsDetail')->where(array('news_id' => $id))->find();
     $blog_content['content'] = parse_expression($blog_content['content']);
     $blog_comment = M('LocalComment')->where(array('app' => 'News', 'mod' => 'index', 'status' => 1, 'row_id' => $id))->order('create_time desc')->page($aPage, $aCount)->select();
     $totalCount = M('LocalComment')->where(array('app' => 'News', 'mod' => 'index', 'status' => 1, 'row_id' => $id))->count();
     if ($totalCount <= $aPage * $aCount) {
         $pid['count'] = 0;
     } else {
         $pid['count'] = 1;
     }
     $blog_detail['count'] = count($blog_comment);
     foreach ($blog_comment as &$v) {
         $v['user'] = query_user(array('nickname', 'avatar32', 'uid'), $v['uid']);
         $v['cover_url'] = getThumbImageById($v['cover']);
         $v['content'] = parse_weibo_mobile_content($v['content']);
     }
     if ($blog_detail['status'] == 2 || $blog_detail['status'] == -1) {
         $blog_detail['can_edit'] = 1;
     }
     $this->setMobTitle($blog_detail['title']);
     $this->setMobDescription($blog_detail['meta']['description']);
     $this->setMobKeywords($blog_detail['user']['nickname']);
     //dump($blog_detail);exit;
     $this->assign('blogdetail', $blog_detail);
     $this->assign('blogcontent', $blog_content);
     $this->assign('blogcomment', $blog_comment);
     $this->assign('pid', $pid);
     //标识数据是否还有第二页。
     $this->display();
 }
Esempio n. 10
0
function parse_expression($expression, $variables)
{
    $expression = trim($expression);
    //echo "E: ".$expression."\n";
    if ($expression[0] == '&') {
        $result = true;
        $expression = trim(substr($expression, 2, strlen($expression) - 3));
        while ($result && strlen($expression) > 0) {
            if ($expression[0] == '|' || $expression[0] == '&') {
                $subexpression = subexpression($expression);
                $result &= parse_expression($subexpression, $variables);
                $expression = trim(substr($expression, strlen($subexpression) + 1));
            } else {
                $atom = substr($expression, 0, strpos($expression, ")") + 1);
                $expression = trim(substr($expression, strlen($atom) + 1));
                $result &= parse_atom($atom, $variables);
            }
            if (strlen($expression) && $expression[0] == ',') {
                //echo "C: ".$expression."\n";
                $expression = trim(substr($expression, 1));
                //echo "D: ".$expression."\n";
            }
        }
        return $result;
    } else {
        if ($expression[0] == '|') {
            $result = false;
            $expression = trim(substr($expression, 2, strlen($expression) - 3));
            while (!$result && strlen($expression) > 0) {
                if ($expression[0] == '|' || $expression[0] == '&') {
                    $subexpression = subexpression($expression);
                    $result |= parse_expression($subexpression, $variables);
                    $expression = trim(substr($expression, strlen($subexpression) + 1));
                } else {
                    $atom = substr($expression, 0, strpos($expression, ")") + 1);
                    $expression = trim(substr($expression, strlen($atom) + 1));
                    $result |= parse_atom($atom, $variables);
                }
                if (strlen($expression) && $expression[0] == ',') {
                    $expression = trim(substr($expression, 1));
                }
            }
            return $result;
        } else {
            return parse_atom($expression, $variables);
            //echo "\n".$expression."\n";
        }
    }
}
 /**
  * 发的帖子内容渲染
  * 判断是否是编辑请求
  * (标题内容渲染)
  */
 public function addPost($isedit = 0, $postid = 0)
 {
     if ($isedit == 0) {
         $this->setTopTitle('发帖子');
         $forum_list = M('Forum/Forum')->getForumList();
         //判断板块能否发帖
         foreach ($forum_list as &$e) {
             $e['allow_publish'] = $this->isForumAllowPublish($e['id']);
         }
         unset($e);
         $myInfo = query_user(array('avatar128', 'avatar64', 'nickname', 'uid', 'space_url', 'icons_html'), is_login());
     } else {
         $this->setTopTitle('编辑帖子');
         $forum_list = M('Forum/Forum')->getForumList();
         //判断板块能否发帖
         foreach ($forum_list as &$e) {
             $e['allow_publish'] = $this->isForumAllowPublish($e['id']);
         }
         unset($e);
         $myInfo = query_user(array('avatar128', 'avatar64', 'nickname', 'uid', 'space_url', 'icons_html'), is_login());
         $map['id'] = array('eq', $postid);
         $forum_detail = M('ForumPost')->where($map)->find();
         $forum_detail['user'] = query_user(array('nickname', 'avatar128'), $forum_detail['uid']);
         $forum_detail['content'] = $content = parse_expression($forum_detail['content']);
         $forum_detail['is_edit'] = 1;
         $this->assign('forum_detail', $forum_detail);
     }
     $this->assign('myInfo', $myInfo);
     //赋予论坛列表
     $this->assign('forum_list', $forum_list);
     $types = M('Forum/Forum')->getAllForumsSortByTypes();
     $this->assign('types', $types);
     $this->display();
 }