function loadnew()
 {
     // 每120秒刷新一次!
     if (!lockSubmit('120')) {
         exit('<TSAJAX>');
     }
     $data['showfeed'] = intval($_REQUEST['showfeed']);
     $data['list'] = D('Operate')->loadNew($this->mid, $_POST['since'], $_POST['limit'], $data['showfeed']);
     $this->assign($data);
     // NO unlockSubmit(); !!!
     $this->display('loadmore');
 }
 public function doPost()
 {
     if (!lockSubmit(10)) {
         echo -1;
         exit;
     }
     if (empty($_POST['to']) || empty($_POST['content'])) {
         echo 0;
         exit;
     }
     $to_num = explode(',', $_POST['to']);
     if (sizeof($to_num) > 10) {
         echo '-2';
         exit;
     }
     $res = model('Message')->postMessage($_POST, $this->mid);
     if ($res) {
         echo 1;
     } else {
         echo 0;
     }
     // NO unlockSubmit(); !!!
 }
 /**
  * 添加评论操作
  * @param array $data 评论数据
  * @param boolean $forApi 是否用于API,默认为false
  * @param boolean $notCount 是否统计到未读评论
  * @param array $lessUids 除去@用户ID
  * @return boolean 是否添加评论成功 
  */
 public function addComment($data, $forApi = false, $notCount = false, $lessUids = null)
 {
     // 判断用户是否登录
     if (!$GLOBALS['ts']['mid']) {
         $this->error = L('PUBLIC_REGISTER_REQUIRED');
         // 请先登录
         return false;
     }
     if (isSubmitLocked()) {
         $this->error = '发布内容过于频繁,请稍后再试!';
         return false;
     }
     /* # 将Emoji编码 */
     $data['content'] = formatEmoji(true, $data['content']);
     // 检测数据安全性
     $add = $this->_escapeData($data);
     if ($add['content'] === '') {
         $this->error = L('PUBLIC_COMMENT_CONTENT_REQUIRED');
         // 评论内容不可为空
         return false;
     }
     $add['is_del'] = 0;
     //判断是否先审后发
     $filterStatus = filter_words($add['content']);
     $weiboSet = model('Xdata')->get('admin_Config:feed');
     $weibo_premission = $weiboSet['weibo_premission'];
     if (in_array('audit', $weibo_premission) || CheckPermission('core_normal', 'feed_audit') || $filterStatus['type'] == 2) {
         $add['is_audit'] = 0;
     } else {
         $add['is_audit'] = 1;
     }
     $add['client_ip'] = get_client_ip();
     $add['client_port'] = get_client_port();
     if ($res = $this->add($add)) {
         //锁定发布
         lockSubmit();
         //添加楼层信息 弃用 20130607
         /*             $storeyCount = $this->where("table='".$add['table']."' and row_id=".$data['row_id'].' and comment_id<'.$res)->count();
                     $this->where('comment_id='.$res)->setField('storey',$storeyCount+1); */
         if (!$add['is_audit']) {
             $touid = D('user_group_link')->where('user_group_id=1')->field('uid')->findAll();
             $touidArr = getSubByKey($touid, 'uid');
             model('Notify')->sendNotify($touidArr, 'comment_audit');
         }
         // 获取排除@用户ID
         $lessUids[] = intval($data['app_uid']);
         !empty($data['to_uid']) && ($lessUids[] = intval($data['to_uid']));
         // 获取用户发送的内容,仅仅以//进行分割
         $scream = explode('//', $data['content']);
         model('Atme')->setAppName('Public')->setAppTable('comment')->addAtme(trim($scream[0]), $res, null, $lessUids);
         // 被评论内容的“评论统计数”加1,同时可检测出app,table,row_id的有效性
         $pk = D($add['table'])->getPk();
         $where = "`{$pk}`={$add['row_id']}";
         D($add['table'])->setInc('comment_count', $where);
         //兼容旧版本app
         //            D($add['table'])->setInc('commentCount', $where);
         //            D($add['table'])->setInc('comment_all_count', $where);
         D($add['app'])->setInc('commentCount', $where);
         D($add['app'])->setInc('comment_all_count', $where);
         //评论时间
         M($add['app'])->where('feed_id=' . $add['row_id'])->setField('rTime', time());
         // 给应用UID添加一个未读的评论数 原作者
         if ($GLOBALS['ts']['mid'] != $add['app_uid'] && $add['app_uid'] != '' && $add['app_uid'] != $add['to_uid']) {
             !$notCount && model('UserData')->updateKey('unread_comment', 1, true, $add['app_uid']);
         }
         // 回复发送提示信息
         if (!empty($add['to_uid']) && $add['to_uid'] != $GLOBALS['ts']['mid']) {
             !$notCount && model('UserData')->updateKey('unread_comment', 1, true, $add['to_uid']);
         }
         // 加积分操作
         if ($add['table'] == 'feed') {
             model('Credit')->setUserCredit($GLOBALS['ts']['mid'], 'comment_weibo');
             model('Credit')->setUserCredit($data['app_uid'], 'commented_weibo');
             model('Feed')->cleanCache($add['row_id']);
         }
         // 发邮件
         if ($add['to_uid'] != $GLOBALS['ts']['mid'] || $add['app_uid'] != $GLOBALS['ts']['mid'] && $add['app_uid'] != '') {
             $author = model('User')->getUserInfo($GLOBALS['ts']['mid']);
             $config['name'] = $author['uname'];
             $config['space_url'] = $author['space_url'];
             $config['face'] = $author['avatar_small'];
             $sourceInfo = model('Source')->getCommentSource($add, $forApi);
             $config['content'] = parse_html($add['content']);
             $config['ctime'] = date('Y-m-d H:i:s', time());
             $config['sourceurl'] = $sourceInfo['source_url'];
             $config['source_content'] = parse_html($sourceInfo['source_content']);
             $config['source_ctime'] = isset($sourceInfo['ctime']) ? date('Y-m-d H:i:s', $sourceInfo['ctime']) : date('Y-m-d H:i:s');
             if (!empty($add['to_uid'])) {
                 // 回复
                 $config['comment_type'] = '回复 我 的评论:';
                 model('Notify')->sendNotify($add['to_uid'], 'comment', $config);
             } else {
                 // 评论
                 $config['comment_type'] = '评论 我 的分享:';
                 if (!empty($add['app_uid'])) {
                     model('Notify')->sendNotify($add['app_uid'], 'comment', $config);
                 }
             }
         }
     }
     $this->error = $res ? L('PUBLIC_CONCENT_IS_OK') : L('PUBLIC_CONCENT_IS_ERROR');
     // 评论成功,评论失败
     return $res;
 }
Exemple #4
0
 /**
  * 添加微博
  * @param integer $uid 操作用户ID
  * @param string $app 微博应用类型,默认为public
  * @param string $type 微博类型,
  * @param array $data 微博相关数据
  * @param integer $app_id 应用资源ID,默认为0
  * @param string $app_table 应用资源表名,默认为feed
  * @param array  $extUid 额外用户ID,默认为null
  * @param array $lessUids 去除的用户ID,默认为null
  * @param boolean $isAtMe 是否为进行发送,默认为true
  * @return mix 添加失败返回false,成功返回新的微博ID
  */
 public function put($uid, $app = 'public', $type = '', $data = array(), $app_id = 0, $app_table = 'feed', $extUid = null, $lessUids = null, $isAtMe = true, $is_repost = 0)
 {
     if (isSubmitLocked()) {
         $this->error = '发布内容过于频繁,请稍后再试';
         return false;
     }
     // 判断数据的正确性
     if (!$uid || $type == '') {
         $this->error = L('PUBLIC_ADMIN_OPRETING_ERROR');
         return false;
     }
     if (strpos($type, 'postvideo') !== false) {
         $type = 'postvideo';
     }
     //微博类型合法性验证 - 临时解决方案
     if (!in_array($type, array('post', 'repost', 'postvideo', 'postfile', 'postimage', 'weiba_post', 'weiba_repost'))) {
         $type = 'post';
     }
     //应用类型验证 用于分享框 - 临时解决方案
     if (!in_array($app, array('w3g', 'public', 'weiba', 'tipoff'))) {
         $app = 'public';
         $type = 'post';
         $app_table = 'feed';
     }
     $app_table = strtolower($app_table);
     // 添加feed表记录
     $data['uid'] = $uid;
     $data['app'] = $app;
     $data['type'] = $type;
     $data['app_row_id'] = $app_id;
     $data['app_row_table'] = $app_table;
     $data['publish_time'] = time();
     $data['from'] = isset($data['from']) ? intval($data['from']) : getVisitorClient();
     $data['is_del'] = $data['comment_count'] = $data['repost_count'] = 0;
     $data['is_repost'] = $is_repost;
     //判断是否先审后发
     $weiboSet = model('Xdata')->get('admin_Config:feed');
     $weibo_premission = $weiboSet['weibo_premission'];
     if (in_array('audit', $weibo_premission) || CheckPermission('core_normal', 'feed_audit')) {
         $data['is_audit'] = 0;
     } else {
         $data['is_audit'] = 1;
     }
     // 微博内容处理
     if (Addons::requireHooks('weibo_publish_content')) {
         Addons::hook("weibo_publish_content", array(&$data));
     } else {
         $content = $this->formatFeedContent($data['body']);
         $data['body'] = $content['body'];
         $data['content'] = $content['content'];
     }
     //分享到微博的应用资源,加入原资源链接
     $data['body'] .= $data['source_url'];
     $data['content'] .= $data['source_url'];
     // 微博类型插件钩子
     // if($type){
     // 	$addonsData = array();
     // 	Addons::hook("weibo_type",array("typeId"=>$type,"typeData"=>$type_data,"result"=>&$addonsData));
     // 	$data = array_merge($data,$addonsData);
     // }
     if ($type == 'postvideo') {
         $typedata = model('Video')->_weiboTypePublish($_POST['videourl']);
         if ($typedata && $typedata['flashvar'] && $typedata['flashimg']) {
             $data = array_merge($data, $typedata);
         } else {
             $data['type'] = 'post';
         }
     }
     // 添加微博信息
     $feed_id = $this->data($data)->add();
     if (!$feed_id) {
         return false;
     }
     if (!$data['is_audit']) {
         $touid = D('user_group_link')->where('user_group_id=1')->field('uid')->findAll();
         foreach ($touid as $k => $v) {
             model('Notify')->sendNotify($v['uid'], 'feed_audit');
         }
     }
     // 目前处理方案格式化数据
     $data['content'] = str_replace(chr(31), '', $data['content']);
     $data['body'] = str_replace(chr(31), '', $data['body']);
     // 添加关联数据
     $feed_data = D('FeedData')->data(array('feed_id' => $feed_id, 'feed_data' => serialize($data), 'client_ip' => get_client_ip(), 'feed_content' => $data['body']))->add();
     // 添加微博成功后
     if ($feed_id && $feed_data) {
         //锁定发布
         lockSubmit();
         //微博发布成功后的钩子
         //Addons::hook("weibo_publish_after",array('weibo_id'=>$feed_id,'post'=>$data));
         // 发送通知消息 - 重点 - 需要简化把上节点的信息去掉.
         if ($data['is_repost'] == 1) {
             // 转发微博
             $isAtMe && ($content = $data['content']);
             // 内容用户
             $extUid[] = $data['sourceInfo']['transpond_data']['uid'];
             // 资源作者用户
             if ($isAtMe && !empty($data['curid'])) {
                 // 上节点用户
                 $appRowData = $this->get($data['curid']);
                 $extUid[] = $appRowData['uid'];
             }
         } else {
             // 其他微博
             $content = $data['content'];
             //更新最近@的人
             model('Atme')->updateRecentAt($content);
             // 内容用户
         }
         // 发送@消息
         model('Atme')->setAppName('Public')->setAppTable('feed')->addAtme($content, $feed_id, $extUid, $lessUids);
         $data['client_ip'] = get_client_ip();
         $data['feed_id'] = $feed_id;
         $data['feed_data'] = serialize($data);
         // 主动创建渲染后的缓存
         $return = $this->setFeedCache($data);
         $return['user_info'] = model('User')->getUserInfo($uid);
         $return['GroupData'] = model('UserGroupLink')->getUserGroupData($uid);
         //获取用户组信息
         $return['feed_id'] = $feed_id;
         $return['app_row_id'] = $data['app_row_id'];
         $return['is_audit'] = $data['is_audit'];
         // 统计数修改
         model('UserData')->setUid($uid)->updateKey('feed_count', 1);
         // if($app =='public'){ //TODO 微博验证条件
         model('UserData')->setUid($uid)->updateKey('weibo_count', 1);
         // }
         if (!$return) {
             $this->error = L('PUBLIC_CACHE_FAIL');
             // Feed缓存写入失败
         }
         return $return;
     } else {
         $this->error = L('PUBLIC_ADMIN_OPRETING_ERROR');
         // 操作失败
         return false;
     }
 }
 /**
  * 添加帖子回复的操作
  * @return array 评论添加状态和提示信息
  */
 public function addReply()
 {
     //   echo $_POST['post_id'];exit;
     if (!$this->mid || !CheckPermission('weiba_normal', 'weiba_reply')) {
         return;
     }
     $return = array('status' => 0, 'data' => L('PUBLIC_CONCENT_IS_ERROR'));
     $type = intval($_POST['type']);
     $data['weiba_id'] = intval($_POST['weiba_id']);
     $data['post_id'] = intval($_POST['post_id']);
     $data['post_uid'] = intval($_POST['post_uid']);
     $data['to_reply_id'] = intval($_POST['to_reply_id']);
     $data['to_uid'] = intval($_POST['to_uid']);
     $data['uid'] = $this->mid;
     $data['ctime'] = time();
     $data['content'] = h($_POST['content']);
     if (isSubmitLocked()) {
         $return['status'] = 0;
         $return['data'] = '发布内容过于频繁,请稍后再试!';
         exit(json_encode($return));
     }
     if ($data['reply_id'] = D('weiba_reply')->add($data)) {
         // 锁定发布
         lockSubmit();
         //添加积分
         model('Credit')->setUserCredit(intval($_POST['post_uid']), 'comment_topic');
         model('Credit')->setUserCredit($data['to_uid'], 'commented_topic');
         $map['last_reply_uid'] = $this->mid;
         $map['last_reply_time'] = $data['ctime'];
         if ($data['to_reply_id'] == 0) {
             $map['reply_count'] = array('exp', "reply_count+1");
         }
         $map['reply_all_count'] = array('exp', "reply_all_count+1");
         D('weiba_post')->where('post_id=' . $data['post_id'])->save($map);
         //同步到微博评论
         //$feed_id = intval($_POST['feed_id']);
         $datas['app'] = 'weiba';
         $datas['table'] = 'feed';
         $datas['content'] = h($data['content']);
         $datas['app_uid'] = intval($_POST['post_uid']);
         $datas['row_id'] = intval($_POST['feed_id']);
         $datas['to_comment_id'] = $data['to_reply_id'] ? D('weiba_reply')->where('reply_id=' . $data['to_reply_id'])->getField('comment_id') : 0;
         $datas['to_uid'] = intval($_POST['to_uid']);
         $datas['uid'] = $this->mid;
         $datas['ctime'] = time();
         $datas['client_type'] = getVisitorClient();
         // 解锁
         unlockSubmit();
         if ($comment_id = model('Comment')->addComment($datas)) {
             $data1['comment_id'] = $comment_id;
             // $data1['storey'] = model('Comment')->where('comment_id='.$comment_id)->getField('storey');
             D('weiba_reply')->where('reply_id=' . $data['reply_id'])->save($data1);
             // 给应用UID添加一个未读的评论数
             if ($GLOBALS['ts']['mid'] != $datas['app_uid'] && $datas['app_uid'] != '') {
                 !$notCount && model('UserData')->updateKey('unread_comment', 1, true, $datas['app_uid']);
             }
             model('Feed')->cleanCache($datas['row_id']);
         }
         //转发到我的微博
         if ($_POST['ifShareFeed'] == 1) {
             $commentInfo = model('Source')->getSourceInfo($datas['table'], $datas['row_id'], false, $datas['app']);
             $oldInfo = isset($commentInfo['sourceInfo']) ? $commentInfo['sourceInfo'] : $commentInfo;
             // 根据评论的对象获取原来的内容
             $s['sid'] = $data['post_id'];
             $s['app_name'] = 'weiba';
             if (!empty($data['to_comment_id'])) {
                 $replyInfo = model('Comment')->init($data['app'], $data['table'])->getCommentInfo($data['to_comment_id'], false);
                 $data['content'] .= $replyInfo['content'];
             }
             $s['body'] = $data['content'];
             $s['type'] = 'weiba_post';
             $s['comment'] = $data['comment_old'];
             // 去掉回复用户@
             $lessUids = array();
             if (!empty($data['to_uid'])) {
                 $lessUids[] = $data['to_uid'];
             }
             // 如果为原创微博,不给原创用户发送@信息
             if ($oldInfo['feedtype'] == 'post' && empty($data['to_uid'])) {
                 $lessUids[] = $oldInfo['uid'];
             }
             unlockSubmit();
             model('Share')->shareFeed($s, 'comment', $lessUids);
         }
         $data['feed_id'] = $datas['row_id'];
         $data['comment_id'] = $comment_id;
         $data['storey'] = $data1['storey'];
         $return['status'] = 1;
         if ($type == 2) {
             $return['data'] = $this->parseRightReply($data);
         } else {
             $return['data'] = $this->parseReply($data);
         }
     }
     echo json_encode($return);
     exit;
 }
 /**
  * 添加分享
  * @param integer $uid 操作用户ID
  * @param string $app 分享应用类型,默认为public
  * @param string $type 分享类型,
  * @param array $data 分享相关数据
  * @param integer $app_id 应用资源ID,默认为0
  * @param string $app_table 应用资源表名,默认为feed
  * @param array  $extUid 额外用户ID,默认为null
  * @param array $lessUids 去除的用户ID,默认为null
  * @param boolean $isAtMe 是否为进行发送,默认为true
  * @return mix 添加失败返回false,成功返回新的分享ID
  */
 public function put($uid, $app = 'public', $type = '', $data = array(), $app_id = 0, $app_table = 'feed', $extUid = null, $lessUids = null, $isAtMe = true, $is_repost = 0)
 {
     if (isSubmitLocked()) {
         $this->error = '发布内容过于频繁,请稍后再试';
         return false;
     }
     // 判断数据的正确性
     if (!$uid || $type == '') {
         $this->error = L('PUBLIC_ADMIN_OPRETING_ERROR');
         return false;
     }
     if (strpos($type, 'postvideo') !== false) {
         $type = 'postvideo';
     }
     //分享类型合法性验证 - 临时解决方案
     $checkType = array('post', 'repost', 'postvideo', 'postfile', 'postimage', 'weiba_post', 'weiba_repost', 'long_post', 'photo_post', 'photo_repost', 'vote_post', 'vote_repost', 'event_post', 'event_repost', 'blog_post', 'blog_repost', 'poster_post', 'poster_repost');
     if (!in_array($type, $checkType)) {
         $type = 'post';
     }
     //应用类型验证 用于分享框 - 临时解决方案
     $checkApp = array('w3g', 'public', 'weiba', 'tipoff', 'photo', 'vote', 'event', 'blog', 'poster');
     if (!in_array($app, $checkApp)) {
         $app = 'public';
         $type = 'post';
         $app_table = 'feed';
     }
     $app_table = strtolower($app_table);
     // 添加feed表记录
     $data['uid'] = $uid;
     $data['app'] = $app;
     $data['type'] = $type;
     $data['app_row_id'] = $app_id;
     $data['app_row_table'] = $app_table;
     $data['publish_time'] = time();
     $data['from'] = isset($data['from']) ? intval($data['from']) : getVisitorClient();
     $data['is_del'] = $data['comment_count'] = $data['repost_count'] = 0;
     $data['is_repost'] = $is_repost;
     //判断是否先审后发
     $filterStatus = filter_words($data['body']);
     $weiboSet = model('Xdata')->get('admin_Config:feed');
     $weibo_premission = $weiboSet['weibo_premission'];
     if (in_array('audit', $weibo_premission) || CheckPermission('core_normal', 'feed_audit') || $filterStatus['type'] == 2) {
         $data['is_audit'] = 0;
     } else {
         $data['is_audit'] = 1;
     }
     // 分享内容处理
     if (Addons::requireHooks('weibo_publish_content')) {
         Addons::hook("weibo_publish_content", array(&$data));
     } else {
         // 截取内容信息为分享内容字数 - 长分享
         //$feedConf = model('Xdata')->get('admin_Config:feed');
         //$feedNums = $feedConf['weibo_nums'];
         //if(Addons::requireHooks('show_longtext_button')){
         //	$feedNums = 20000;
         //	$data['body'] = str_replace(SITE_URL, '[SITE_URL]', $data['body']);
         //}else{
         //	$data['body'] = str_replace(SITE_URL, '[SITE_URL]', preg_html($data['body']));
         //}
         $content = $this->formatFeedContent($data['body']);
         $data['body'] = $content['body'];
         $data['content'] = $content['content'];
     }
     //分享到分享的应用资源,加入原资源链接
     $data['body'] .= $data['source_url'];
     $data['content'] .= $data['source_url'];
     // 分享类型插件钩子
     // if($type){
     // 	$addonsData = array();
     // 	Addons::hook("weibo_type",array("typeId"=>$type,"typeData"=>$type_data,"result"=>&$addonsData));
     // 	$data = array_merge($data,$addonsData);
     // }
     if ($type == 'postvideo') {
         if ($_POST['video_id']) {
             $video_info = D('video')->where('video_id=' . $data['video_id'])->find();
             $data['transfer_id'] = $video_info['transfer_id'];
             $data['video_path'] = $video_info['video_path'];
             $data['video_mobile_path'] = $video_info['video_mobile_path'];
             $data['video_part_path'] = $video_info['video_part_path'];
             $data['image_path'] = $video_info['image_path'];
             $data['image_width'] = $video_info['image_width'];
             $data['image_height'] = $video_info['image_height'];
         } else {
             $typedata = model('Video')->_weiboTypePublish($_POST['videourl']);
             if ($typedata && $typedata['flashvar'] && $typedata['flashimg']) {
                 $data = array_merge($data, $typedata);
             } else {
                 $data['type'] = 'post';
             }
         }
     }
     // 添加分享信息
     $feed_id = $this->data($data)->add();
     if (!$feed_id) {
         return false;
     }
     if ($data['video_id']) {
         D('video')->where('video_id=' . $data['video_id'])->setField('feed_id', $feed_id);
         //如果有的话
         if (D('video_transfer')->where('video_id=' . $data['video_id'])->count()) {
             D('video_transfer')->where('video_id=' . $data['video_id'])->setField('feed_id', $feed_id);
         }
     }
     if (!$data['is_audit']) {
         $touid = D('user_group_link')->where('user_group_id=1')->field('uid')->findAll();
         foreach ($touid as $k => $v) {
             model('Notify')->sendNotify($v['uid'], 'feed_audit');
         }
     }
     // 目前处理方案格式化数据
     $data['content'] = str_replace(chr(31), '', $data['content']);
     $data['body'] = str_replace(chr(31), '', $data['body']);
     // 添加关联数据
     $feed_data = D('FeedData')->data(array('feed_id' => $feed_id, 'feed_data' => serialize($data), 'client_ip' => get_client_ip(), 'client_port' => get_client_port(), 'feed_content' => $data['body']))->add();
     // 添加分享成功后
     if ($feed_id && $feed_data) {
         //锁定发布
         lockSubmit();
         //分享发布成功后的钩子
         //Addons::hook("weibo_publish_after",array('weibo_id'=>$feed_id,'post'=>$data));
         // 发送通知消息 - 重点 - 需要简化把上节点的信息去掉.
         if ($data['is_repost'] == 1) {
             // 转发分享
             $isAtMe && ($content = $data['content']);
             // 内容用户
             $extUid[] = $data['sourceInfo']['transpond_data']['uid'];
             // 资源作者用户
             if ($isAtMe && !empty($data['curid'])) {
                 // 上节点用户
                 $appRowData = $this->get($data['curid']);
                 $extUid[] = $appRowData['uid'];
             }
         } else {
             // 其他分享
             $content = $data['content'];
             //更新最近@的人
             model('Atme')->updateRecentAt($content);
             // 内容用户
         }
         // 发送@消息
         model('Atme')->setAppName('Public')->setAppTable('feed')->addAtme($content, $feed_id, $extUid, $lessUids);
         $data['client_ip'] = get_client_ip();
         $data['feed_id'] = $feed_id;
         $data['feed_data'] = serialize($data);
         // 主动创建渲染后的缓存
         $return = $this->setFeedCache($data);
         $return['user_info'] = model('User')->getUserInfo($uid);
         $return['GroupData'] = model('UserGroupLink')->getUserGroupData($uid);
         //获取用户组信息
         $return['feed_id'] = $feed_id;
         $return['app_row_id'] = $data['app_row_id'];
         $return['is_audit'] = $data['is_audit'];
         // 统计数修改
         model('UserData')->setUid($uid)->updateKey('feed_count', 1);
         // if($app =='public'){ //TODO 分享验证条件
         model('UserData')->setUid($uid)->updateKey('weibo_count', 1);
         // }
         //更新附件信息
         $attach_info['app_name'] = 'public';
         $attach_info['table'] = 'feed';
         $attach_info['row_id'] = $feed_id;
         $attach_map['attach_id'] = array('IN', $data['attach_id']);
         model('Attach')->where($attach_map)->save($attach_info);
         if (!$return) {
             $this->error = L('PUBLIC_CACHE_FAIL');
             // Feed缓存写入失败
         }
         return $return;
     } else {
         $this->error = L('PUBLIC_ADMIN_OPRETING_ERROR');
         // 操作失败
         return false;
     }
 }
 public function doPost()
 {
     if (!lockSubmit(10)) {
         echo -1;
         exit;
     }
     $res = model('Message')->postMessage($_POST, $this->mid);
     if ($res) {
         echo 1;
     } else {
         echo 0;
     }
     // NO unlockSubmit(); !!!
 }
Exemple #8
0
 /**
  * 评论帖子 --using
  *
  * @param
  *        	integer post_id 帖子ID
  * @param
  *        	integer to_comment_id 评论ID
  * @param
  *        	string content 评论内容
  * @param
  *        	integer from 来源(2-android 3-iPhone)
  * @return array 状态+提示
  */
 public function comment_post()
 {
     $return['status'] = 0;
     $return['msg'] = '发布失败';
     //检测用户是否被禁言
     if ($isDisabled = model('DisableUser')->isDisableUser($this->mid, 'post')) {
         return array('status' => 0, 'msg' => '您已经被禁言了');
     }
     if (!t($this->data['content'])) {
         $return['msg'] = '评论内容不能为空';
         return $return;
     }
     if (!intval($this->data['post_id'])) {
         $return['msg'] = '参数非法';
         return $return;
     }
     if (!$this->mid || !CheckPermission('weiba_normal', 'weiba_reply')) {
         $return['msg'] = '你无权发布';
         return $return;
     }
     $feed_detail = M('weiba_post')->where('post_id=' . intval($this->data['post_id']))->find();
     $data['weiba_id'] = intval($feed_detail['weiba_id']);
     $data['post_id'] = intval($this->data['post_id']);
     $data['post_uid'] = intval($feed_detail['post_uid']);
     if (!empty($this->data['to_comment_id'])) {
         $data['to_reply_id'] = intval($this->data['to_comment_id']);
         $data['to_uid'] = model('Comment')->where('comment_id=' . intval($this->data['to_comment_id']))->getField('uid');
     }
     $data['uid'] = $this->mid;
     $data['ctime'] = time();
     $data['content'] = preg_html(h($this->data['content']));
     /* # 格式化emoji */
     $data['content'] = formatEmoji(true, $data['content']);
     $data['attach_id'] = intval($this->data['attach_id']);
     $filterContentStatus = filter_words($data['content']);
     if (!$filterContentStatus['status']) {
         return array('status' => 0, 'msg' => $filterContentStatus['data']);
     }
     $data['content'] = $filterContentStatus['data'];
     if (isSubmitLocked()) {
         $return['msg'] = '发布内容过于频繁,请稍后再试!';
         return $return;
     }
     if ($data['reply_id'] = D('weiba_reply')->add($data)) {
         // 锁定发布
         lockSubmit();
         // 添加积分
         model('Credit')->setUserCredit(intval($data['post_uid']), 'comment_topic');
         model('Credit')->setUserCredit($data['to_uid'], 'commented_topic');
         $map['last_reply_uid'] = $this->mid;
         $map['last_reply_time'] = $data['ctime'];
         $map['reply_count'] = array('exp', 'reply_count+1');
         $map['reply_all_count'] = array('exp', 'reply_all_count+1');
         D('weiba_post')->where('post_id=' . $data['post_id'])->save($map);
         // 同步到微博评论
         $datas['app'] = 'weiba';
         $datas['table'] = 'feed';
         $datas['content'] = preg_html($data['content']);
         $datas['app_uid'] = intval($feed_detail['post_uid']);
         $datas['row_id'] = intval($feed_detail['feed_id']);
         $datas['to_comment_id'] = $data['to_reply_id'] ? D('weiba_reply')->where('reply_id=' . $data['to_reply_id'])->getField('comment_id') : 0;
         $datas['to_uid'] = intval($data['to_uid']);
         $datas['uid'] = $this->mid;
         $datas['ctime'] = time();
         $datas['client_type'] = getVisitorClient();
         // $datas ['from'] = 'weiba';
         $data['cancomment'] = 1;
         // 解锁
         unlockSubmit();
         if ($comment_id = model('Comment')->addComment($datas)) {
             $data1['comment_id'] = $comment_id;
             // $data1['storey'] = model('Comment')->where('comment_id='.$comment_id)->getField('storey');
             D('weiba_reply')->where('reply_id=' . $data['reply_id'])->save($data1);
             // 给应用UID添加一个未读的评论数
             // if ($GLOBALS ['ts'] ['mid'] != $datas ['app_uid'] && $datas ['app_uid'] != '') {
             //     ! $notCount && model('UserData')->updateKey('unread_comment_weiba', 1, true, $datas ['app_uid']);
             // }
             model('Feed')->cleanCache($datas['row_id']);
         }
         // 转发到我的微博
         if ($this->data['ifShareFeed'] == 1) {
             $commentInfo = model('Source')->getSourceInfo($datas['table'], $datas['row_id'], false, $datas['app']);
             $oldInfo = isset($commentInfo['sourceInfo']) ? $commentInfo['sourceInfo'] : $commentInfo;
             // 根据评论的对象获取原来的内容
             $s['sid'] = $data['post_id'];
             $s['app_name'] = 'weiba';
             if (!empty($data['to_comment_id'])) {
                 $replyInfo = model('Comment')->init($data['app'], $data['table'])->getCommentInfo($data['to_comment_id'], false);
                 $data['content'] .= $replyInfo['content'];
             }
             $s['body'] = $data['content'];
             $s['type'] = 'weiba_post';
             $s['comment'] = $data['comment_old'];
             // 去掉回复用户@
             $lessUids = array();
             if (!empty($data['to_uid'])) {
                 $lessUids[] = $data['to_uid'];
             }
             // 如果为原创微博,不给原创用户发送@信息
             if ($oldInfo['feedtype'] == 'post' && empty($data['to_uid'])) {
                 $lessUids[] = $oldInfo['uid'];
             }
             unlockSubmit();
             model('Share')->shareFeed($s, 'comment', $lessUids);
         }
         $data['feed_id'] = $datas['row_id'];
         $data['comment_id'] = $comment_id;
         $data['storey'] = $data1['storey'];
         $data['attach_info'] = model('Attach')->getAttachById($data['attach_id']);
         if ($data['attach_info']['attach_type'] == 'weiba_comment_image' || $data['attach_info']['attach_type'] == 'feed_image') {
             $data['attach_info']['attach_url'] = getImageUrl($data['attach_info']['save_path'] . $data['attach_info']['save_name'], 200, 200);
         }
         $return['status'] = 1;
         $return['msg'] = '发布成功';
     }
     return $return;
 }
 /**
  * 添加帖子回复的操作
  * @return array 评论添加状态和提示信息
  */
 public function addReply()
 {
     //   echo $_POST['post_id'];exit;
     if (!$this->mid || !CheckPermission('weiba_normal', 'weiba_reply')) {
         return;
     }
     $is_lock = M('weiba_blacklist')->where('weiba_id=' . intval($_POST['weiba_id']) . ' and uid=' . intval($_POST['post_uid']))->find();
     if ($is_lock) {
         $return['status'] = 0;
         $return['data'] = '您是黑名单用户没有发帖权限!';
         exit(json_encode($return));
     }
     $return = array('status' => 0, 'data' => L('PUBLIC_CONCENT_IS_ERROR'));
     $data['weiba_id'] = intval($_POST['weiba_id']);
     $data['post_id'] = intval($_POST['post_id']);
     $data['post_uid'] = intval($_POST['post_uid']);
     $data['to_reply_id'] = intval($_POST['to_reply_id']);
     $data['to_uid'] = intval($_POST['to_uid']);
     $data['uid'] = $this->mid;
     $data['ctime'] = time();
     $data['content'] = preg_html(h($_POST['content']));
     $data['attach_id'] = intval($_POST['attach_id']);
     $filterContentStatus = filter_words($data['content']);
     if (!$filterContentStatus['status']) {
         exit(json_encode(array('status' => 0, 'data' => $filterContentStatus['data'])));
     }
     $data['content'] = $filterContentStatus['data'];
     if (isSubmitLocked()) {
         $return['status'] = 0;
         $return['data'] = '发布内容过于频繁,请稍后再试!';
         exit(json_encode($return));
     }
     if ($data['reply_id'] = D('weiba_reply')->add($data)) {
         // 锁定发布
         lockSubmit();
         // 更新微吧今日新帖
         D('Weiba')->setNewcount($data['weiba_id']);
         //添加积分
         model('Credit')->setUserCredit(intval($_POST['post_uid']), 'comment_topic');
         model('Credit')->setUserCredit($data['to_uid'], 'commented_topic');
         $map['last_reply_uid'] = $this->mid;
         $map['last_reply_time'] = $data['ctime'];
         $map['reply_count'] = array('exp', "reply_count+1");
         $map['reply_all_count'] = array('exp', "reply_all_count+1");
         D('weiba_post', 'weiba')->where('post_id=' . $data['post_id'])->save($map);
         //同步到分享评论
         //$feed_id = intval($_POST['feed_id']);
         $datas['app'] = 'weiba';
         $datas['table'] = 'feed';
         $datas['content'] = preg_html($data['content']);
         $datas['app_uid'] = intval($_POST['post_uid']);
         $datas['row_id'] = intval($_POST['feed_id']);
         $datas['to_comment_id'] = $data['to_reply_id'] ? D('weiba_reply', 'weiba')->where('reply_id=' . $data['to_reply_id'])->getField('comment_id') : 0;
         $datas['to_uid'] = intval($_POST['to_uid']);
         $datas['uid'] = $this->mid;
         $datas['ctime'] = time();
         $datas['client_type'] = getVisitorClient();
         $data['cancomment'] = 1;
         $data['list_count'] = intval($_POST['list_count']);
         // 解锁
         unlockSubmit();
         if ($comment_id = model('Comment')->addComment($datas)) {
             $data1['comment_id'] = $comment_id;
             // $data1['storey'] = model('Comment')->where('comment_id='.$comment_id)->getField('storey');
             D('weiba_reply', 'weiba')->where('reply_id=' . $data['reply_id'])->save($data1);
             // 给应用UID添加一个未读的评论数
             if ($GLOBALS['ts']['mid'] != $datas['app_uid'] && $datas['app_uid'] != '') {
                 !$notCount && model('UserData')->updateKey('unread_comment', 1, true, $datas['app_uid']);
             }
             model('Feed')->cleanCache($datas['row_id']);
         }
         //转发到我的分享
         if ($_POST['ifShareFeed'] == 1) {
             $commentInfo = model('Source')->getSourceInfo($datas['table'], $datas['row_id'], false, $datas['app']);
             $oldInfo = isset($commentInfo['sourceInfo']) ? $commentInfo['sourceInfo'] : $commentInfo;
             // 根据评论的对象获取原来的内容
             $s['sid'] = $data['post_id'];
             $s['app_name'] = 'weiba';
             if (!empty($data['to_comment_id'])) {
                 $replyInfo = model('Comment')->init($data['app'], $data['table'])->getCommentInfo($data['to_comment_id'], false);
                 $data['content'] .= $replyInfo['content'];
             }
             $s['body'] = $data['content'];
             $s['type'] = 'weiba_post';
             $s['comment'] = $data['comment_old'];
             // 去掉回复用户@
             $lessUids = array();
             if (!empty($data['to_uid'])) {
                 $lessUids[] = $data['to_uid'];
             }
             // 如果为原创分享,不给原创用户发送@信息
             if ($oldInfo['feedtype'] == 'post' && empty($data['to_uid'])) {
                 $lessUids[] = $oldInfo['uid'];
             }
             unlockSubmit();
             model('Share')->shareFeed($s, 'comment', $lessUids);
         }
         $data['feed_id'] = $datas['row_id'];
         $data['comment_id'] = $comment_id;
         $data['storey'] = $data1['storey'];
         $data['attach_info'] = model('Attach')->getAttachById($data['attach_id']);
         if ($data['attach_info']['attach_type'] == 'weiba_comment_image' || $data['attach_info']['attach_type'] == 'feed_image') {
             $data['attach_info']['attach_url'] = getImageUrl($data['attach_info']['save_path'] . $data['attach_info']['save_name'], 590);
         }
         $return['status'] = 1;
         $return['data'] = $this->parseReply($data);
     }
     echo json_encode($return);
     exit;
 }