Пример #1
0
function m__commentadd()
{
    global $dbm, $c;
    $fields = array();
    if (isset($_SESSION['postdata']['comment']) && time() - $_SESSION['postdata']['comment'] < 60) {
        die('{"code":"101","msg":"歇会再评论吧"}');
    }
    if (trim($_POST['comment']) == '') {
        die('{"code":"1","msg":"发表内容不能为空"}');
    }
    $code = md5(strtoupper($_POST['code']));
    if ($code != $_SESSION['feedback']) {
        die('{"code":"140","msg":"验证码错误"}');
    }
    if (!isset($_POST['id']) || !is_numeric($_POST['id'])) {
        die('{"code":"202","msg":"id号出错"}');
    }
    if (!isset($_POST['parent_id']) || !is_numeric($_POST['parent_id'])) {
        die('{"code","203","msg":"上级ID出错"}');
    }
    $fields['info_id'] = intval($_POST['id']);
    $fields['parent_id'] = intval($_POST['parent_id']);
    $content = filter_words($_POST['comment']);
    $fields['content'] = helper::utf8_substr($content, 0, 300);
    $user = filter_words($_POST['user'], 'user');
    // 匿名用户名存cookie
    if (!isset($_COOKIE['uname']) && empty($_COOKIE['uname'])) {
        $_COOKIE['uname'] = $user;
        setcookie('uname', $user, time() + 3600, '/');
    }
    $fields['uname'] = helper::utf8_substr($user, 0, 10);
    $fields['date_add'] = time();
    $fields['ip'] = helper::getip();
    if ($fields['parent_id'] != 0) {
        $ress = $dbm->query_update("UPDATE " . TB_PREFIX . "comment SET son = son + 1 WHERE comment_id = '{$fields['parent_id']}'");
    }
    $res = $dbm->single_insert(TB_PREFIX . 'comment', $fields);
    if (empty($res['error']) && empty($ress['error'])) {
        $_SESSION['postdata']['comment'] = time();
        die('{"code":"0","msg":"发表成功"}');
    }
    die('{"code":"1","msg":"发表失败:' . $ress['error'] . '"}');
}
Пример #2
0
 /**
  * 添加评论操作
  * @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;
 }
Пример #3
0
/**
 *
 *
 * @global string $db_url
 * @global dom $dom
 * @param boolean $parse_smileys Defaults to TRUE
 * @param boolean $filter_words Defaults to FALSE
 * @param boolean $processUsername Defaults to FALSE
 * @param boolean $processTime Defaults to FALSE
 * @param boolean $apply_filter Defaults to TRUE
 * @return array
 */
function get_all_data($parse_smileys = true, $filter_words = false, $processUsername = false, $processTime = false, $apply_filter = true)
{
    global $db_url;
    global $dom;
    $db = YDB::factory($db_url);
    $data = array();
    $data = $db->queryAll(parse_tbprefix("SELECT p.pid AS id, p.ip AS ip , p.uid AS uid ,p.uname AS uname,p.content AS post_content,p.post_time AS time,r.content AS reply_content,r.r_time AS reply_time ,u.username AS b_username FROM <post> AS p LEFT JOIN <reply> AS r ON p.pid=r.pid LEFT JOIN <sysuser> AS u ON p.uid=u.uid ORDER BY p.post_time DESC"));
    foreach ($data as &$_data) {
        if ($apply_filter && ZFramework::app()->filter_type == ConfigController::FILTER_TRIPTAGS) {
            if (strstr(ZFramework::app()->allowed_tags, 'code')) {
                $_data['post_content'] = preg_replace_callback('|<code>(.*)</code>|sU', create_function('$matches', 'return "<pre class=\'prettyprint\'>".str_replace(">","&gt;",str_replace("<","&lt;",$matches[1]))."</pre>";'), $_data['post_content']);
                $_data['reply_content'] = preg_replace_callback('|<code>(.*)</code>|sU', create_function('$matches', 'return "<pre class=\'prettyprint\'>".str_replace(">","&gt;",str_replace("<","&lt;",$matches[1]))."</pre>";'), $_data['reply_content']);
                if (!strstr(ZFramework::app()->allowed_tags, 'pre')) {
                    ZFramework::app()->allowed_tags .= "<pre>";
                }
            }
            $_data['post_content'] = strip_tags($_data['post_content'], ZFramework::app()->allowed_tags);
            $_data['reply_content'] = strip_tags($_data['reply_content'], ZFramework::app()->allowed_tags);
        } else {
            $_data['post_content'] = htmlentities($_data['post_content'], ENT_COMPAT, 'UTF-8');
            $_data['reply_content'] = htmlentities($_data['reply_content'], ENT_COMPAT, 'UTF-8');
        }
        if ($parse_smileys) {
            $dom->loadHTML($_data['post_content']);
            $_data['post_content'] = html_entity_decode(parse_smileys($_data['post_content'], SMILEYDIR, getSmileys()));
            if ($_data['reply_content']) {
                $dom->loadHTML($_data['reply_content']);
                $_data['reply_content'] = html_entity_decode(parse_smileys($_data['reply_content'], SMILEYDIR, getSmileys()));
            }
        }
        if ($filter_words) {
            $_data['post_content'] = filter_words($_data['post_content']);
        }
        if ($processUsername) {
            $_data['user'] = $_data['uname'] == ZFramework::app()->admin ? "<font color='red'>{$_data['uname']}</font>" : $_data['uname'];
        }
        if ($processTime) {
            $_data['time'] = date('m-d H:i', $_data['time'] + ZFramework::app()->timezone * 60 * 60);
            $_data['reply_time'] = date('m-d H:i', $_data['reply_time'] + ZFramework::app()->timezone * 60 * 60);
        }
    }
    return $data;
}
Пример #4
0
 /**
  * 执行发布帖子
  * @return void
  */
 public function doPost()
 {
     if ($_GET['post_type'] == 'index') {
         $type = false;
     } else {
         $type = true;
     }
     $weibaid = intval($_POST['weiba_id']);
     if (!CheckPermission('weiba_normal', 'weiba_post')) {
         $this->error('对不起,您没有权限进行该操作!', $type);
     }
     $is_lock = M('weiba_blacklist')->where('weiba_id=' . $weibaid . ' and uid=' . $this->mid)->find();
     if ($is_lock) {
         $this->error('您是黑名单用户没有发帖权限', $type);
     }
     $weibaid = intval($_POST['weiba_id']);
     if (!$weibaid) {
         $this->error('请选择微吧,等待返回选择微吧', $type);
     }
     $weiba = D('weiba')->where('weiba_id=' . $weibaid)->find();
     //黑名单功能添加
     if (!CheckPermission('core_admin', 'admin_login')) {
         switch ($weiba['who_can_post']) {
             case 1:
                 $map['weiba_id'] = $weibaid;
                 $map['follower_uid'] = $this->mid;
                 $res = D('weiba_follow')->where($map)->find();
                 if (!$res && !CheckPermission('core_admin', 'admin_login')) {
                     $this->error('对不起,您没有发帖权限,请关注该微吧!', $type);
                 }
                 break;
             case 2:
                 $map['weiba_id'] = $weibaid;
                 $map['level'] = array('in', '2,3');
                 $weiba_admin = D('weiba_follow')->where($map)->order('level desc')->field('follower_uid')->findAll();
                 if (!in_array($this->mid, getSubByKey($weiba_admin, 'follower_uid')) && !CheckPermission('core_admin', 'admin_login')) {
                     $this->error('对不起,您没有发帖权限,仅限该吧管理员发帖!', $type);
                 }
                 break;
             case 3:
                 $map['weiba_id'] = $weibaid;
                 $map['level'] = 3;
                 $weiba_admin = D('weiba_follow')->where($map)->order('level desc')->field('follower_uid')->find();
                 if ($this->mid != $weiba_admin['follower_uid'] && !CheckPermission('core_admin', 'admin_login')) {
                     $this->error('对不起,您没有发帖权限,仅限该吧吧主发帖!', $type);
                 }
                 break;
         }
     }
     $checkContent = str_replace('&nbsp;', '', $_POST['content']);
     $checkContent = str_replace('<br />', '', $checkContent);
     $checkContent = str_replace('<p>', '', $checkContent);
     $checkContent = str_replace('</p>', '', $checkContent);
     $checkContents = preg_replace('/<img(.*?)src=/i', 'img', $checkContent);
     $checkContents = preg_replace('/<embed(.*?)src=/i', 'img', $checkContents);
     if (strlen(t($_POST['title'])) == 0) {
         $this->error('帖子标题不能为空,等待返回添加标题', $type);
     }
     if (strlen(t($checkContents)) == 0) {
         $this->error('帖子内容不能为空,等待返回添加内容', $type);
     }
     preg_match_all('/./us', t($_POST['title']), $match);
     if (count($match[0]) > 25) {
         //汉字和字母都为一个字
         $this->error('帖子标题不能超过25个字,等待返回修改标题', $type);
     }
     /* # 帖子内容 */
     $content = h($_POST['content']);
     if (get_str_length($content) >= 20000) {
         $this->error('帖子内容过长!无法发布!');
     }
     unset($content);
     if ($_POST['attach_ids']) {
         $attach = explode('|', $_POST['attach_ids']);
         foreach ($attach as $k => $a) {
             if (!$a) {
                 unset($attach[$k]);
             }
         }
         $attach = array_map('intval', $attach);
         $data['attach'] = serialize($attach);
     }
     $data['weiba_id'] = $weibaid;
     $data['title'] = t($_POST['title']);
     $data['content'] = h($_POST['content']);
     $data['post_uid'] = $this->mid;
     $data['post_time'] = time();
     $data['last_reply_uid'] = $this->mid;
     $data['last_reply_time'] = $data['post_time'];
     $filterTitleStatus = filter_words($data['title']);
     if (!$filterTitleStatus['status']) {
         $this->error($filterTitleStatus['data'], $type);
     }
     $data['title'] = $filterTitleStatus['data'];
     $filterContentStatus = filter_words($data['content']);
     if (!$filterContentStatus['status']) {
         $this->error($filterContentStatus['data'], $type);
     }
     $data['content'] = $filterContentStatus['data'];
     if ($_FILES['video']) {
         $this->up();
         if ($_SESSION['up_oss_path']) {
             $data['weiba_id'] = $weibaid;
             if (isset($_POST['title'])) {
                 $data['title'] = t($_POST['title']);
             }
             $info = pathinfo($_SESSION['up_oss_path']);
             $extension = $info['extension'];
             /*echo '<br/>-------------';
               var_dump($extension);echo '----------------<br/>';exit();*/
             if (strtolower($extension) == 'mp3') {
                 $data['content'] = '<img src="__THEME__/image/video.png" style="width:320px; height:180px;" onclick="playMusic()" tag="1"/><br/>' . $data['content'];
             } else {
                 if (strtolower($extension) == 'mp4') {
                     $data['content'] = '<img src="__THEME__/image/video.png" style="width:320px; height:180px; position:relative;" onclick="playVideo()" tag="1"/><img src="__THEME__/image/1@2x.png" style="width:135px; height:110px; left:-223px;bottom:0px;position:relative;" onclick="playVideo()" tag="1"/><br/>' . $data['content'];
                 } else {
                     $data['content'] = $data['content'];
                 }
             }
             //                $data ['post_uid'] = $this->mid;
             $data['post_time'] = time();
             //                $data ['last_reply_uid'] = $this->mid;
             $data['last_reply_time'] = $data['post_time'];
             // $post_id=D('weiba_post')->where($data)->field('post_id')->find();
             $res = D('weiba_post')->add($data);
             // $this->error($res);
             if ($_SESSION['videoImage'] && strtolower($extension) == 'mp4') {
                 $videoImage = $_SESSION['videoImage'];
                 /*$flag = $this->multiupload($weibaid, $post_id, $videoImage);
                   var_dump($flag);*/
             } else {
                 $videoImage = null;
             }
             unset($_SESSION['videoImage']);
             //$upload=$this->video_path($_REQUEST['uploadFile']);
             //var_dump($upload);
             //$flag=$this->multiupload($weibaid,$post_id,$upload['video_path'],$videoImage);
             if ($_SESSION['up_oss_path']) {
                 $upload_path = $_SESSION['up_oss_path'];
                 if (file_exists($_SESSION['up_oss_path'])) {
                     unset($_SESSION['up_oss_path']);
                 }
             } else {
                 $upload_path = null;
             }
             $flag = $this->multiupload($weibaid, $res, $upload_path, $videoImage);
             //print_r($flag);
             // $this->error($flag['status']);
             if ($flag['status'] == 0) {
                 D('weiba_post')->where(array('post_id' => $res))->delete();
                 $res = 0;
                 $this->error($flag['message']);
             } else {
                 //var_dump($flag);
                 if ($flag['videoImage'] != null) {
                     M('up_oss')->where(array('up_oss_id' => $flag['up_oss_id']))->save(array('up_oss_image' => $flag['videoImage']));
                     //$content = str_replace('<img src="__THEME__/image/video.png" style="width:144px; height:81px;" onclick="playVideo()" tag="1"/>','<img src="'.$flag['videoImage'].'" style="width:144px; height:81px;" onclick="playVideo()" tag="1"/>',$data['content']);
                     $content = $this->str_replace_once('<img src="__THEME__/image/video.png" style="width:320px; height:180px; position:relative;" onclick="playVideo()" tag="1"/>', '<img src="' . $flag['videoImage'] . '" style="width:320px; height:135px; position:relative;" onclick="playVideo()" tag="1"/>', $data['content']);
                     D('weiba_post')->where(array('post_id' => $res))->save(array('content' => $content));
                     //echo '========'.var_dump($t);exit();
                 }
                 unlink($upload_path);
                 //删除文件
             }
         }
     } else {
         //print_r($data);
         $res = D('weiba_post')->add($data);
         if (!$res) {
             $this->error('发布失败-.-');
         }
     }
     if ($res) {
         D('Weiba')->setNewcount($weibaid);
         D('weiba')->where('weiba_id=' . $data['weiba_id'])->setInc('thread_count');
         //同步到分享
         // $feed_id = D('weibaPost')->syncToFeed($res,$data['title'],t($checkContent),$this->mid);
         $feed_id = model('Feed')->syncToFeed('weiba', $this->mid, $res);
         D('weiba_post')->where('post_id=' . $res)->setField('feed_id', $feed_id);
         //$this->assign('jumpUrl', U('weiba/Index/postDetail',array('post_id'=>$res)));
         //$this->success('发布成功');
         $result['id'] = $res;
         $result['feed_id'] = $feed_id;
         //添加积分
         model('Credit')->setUserCredit($this->mid, 'publish_topic');
         //更新发帖数
         D('UserData')->updateKey('weiba_topic_count', 1);
         if ($_GET['post_type'] == 'index') {
             $this->success("发布成功");
         } else {
             return $this->ajaxReturn($result, '发布成功', 1);
         }
     } else {
         $this->error('发布失败,等待返回修改发布', $type);
     }
 }
Пример #5
0
 public function doForward()
 {
     // 获取传入的值
     $post = $_POST;
     // 安全过滤
     foreach ($post as $key => $val) {
         $post[$key] = t($post[$key]);
     }
     // 过滤内容值
     // $post['body'] = filter_keyword($post['body']);
     $filterBodyStatus = filter_words($post['body']);
     if (!$filterBodyStatus['status']) {
         echo $filterBodyStatus['data'];
         exit;
         // $return = array('status'=>0,'data'=>$filterBodyStatus['data']);
         // exit(json_encode($return));
     }
     $post['body'] = $filterBodyStatus['data'];
     // 判断资源是否删除
     if (empty($post['curid'])) {
         $map['feed_id'] = intval($post['sid']);
     } else {
         $map['feed_id'] = intval($post['curid']);
     }
     $map['is_del'] = 0;
     $isExist = model('Feed')->where($map)->count();
     if ($isExist == 0) {
         // $return['status'] = 0;
         echo $return['data'] = '内容已被删除,转发失败';
         exit;
         // exit(json_encode($return));
     }
     // 进行分享操作
     $return = model('Share')->shareFeed($post, 'share');
     if ($return['status'] == 1) {
         $app_name = $post['app_name'];
         // 添加积分
         if ($app_name == 'public') {
             model('Credit')->setUserCredit($this->uid, 'forward_weibo');
             // 分享被转发
             $suid = model('Feed')->where($map)->getField('uid');
             model('Credit')->setUserCredit($suid, 'forwarded_weibo');
         }
         if ($app_name == 'weiba') {
             model('Credit')->setUserCredit($this->uid, 'forward_topic');
             // 分享被转发
             $suid = D('Feed')->where('feed_id=' . $map['feed_id'])->getField('uid');
             model('Credit')->setUserCredit($suid, 'forwarded_topic');
         }
         $this->assign($return['data']);
         // 分享配置
         $weiboSet = model('Xdata')->get('admin_Config:feed');
         $this->assign('weibo_premission', $weiboSet['weibo_premission']);
         $return['data'] = $this->fetch('PostFeed');
         $this->doForwardTrue();
         exit;
     } else {
         echo '0';
         exit;
     }
     // exit(json_encode($return));
     // $r=array();
     // $weibo_id = intval($_POST['feed_id']);
     // if ($weibo_id <= 0) {
     // echo '参数错误';
     // exit();
     // }
     // if (empty($_POST['content'])) {
     // echo '内容不能为空';
     // exit();
     // }
     //
     // $data['id'] = $weibo_id;
     // $weibo = api('WeiboStatuses')->data($data)->show();
     // unset($data);
     // if ( empty($weibo) ) {
     // // redirect(U('wap/Index/index'), 3, '参数错误');
     // echo '参数错误';
     // exit();
     // }
     // $p['comment'] = $_POST['comment'];
     // // 整合被转发的内容
     // if ( $weibo['is_repost'] == 1 ) {
     // $_POST['content'] .= "//@{$weibo['uname']}:{$weibo['feed_content']}";
     // }
     //
     // // 仅取前140字
     // $admin_Config = model('Xdata')->lget('admin_Config');
     // $weibo_nums = $admin_Config['feed']['weibo_nums'];
     // $_POST['content'] = mb_substr($_POST['content'], 0,$weibo_nums , 'UTF8');
     //
     // $data['content'] = $_POST['content'];
     // $data['from'] = $this->_type_wap;
     // $data['transpond_id'] = $weibo['transpond_id'] ? $weibo['transpond_id'] : $weibo_id;
     // if (intval($_POST['isComment']) == 1) {
     // $weibo = api('WeiboStatuses')->data(array('id'=>$weibo_id))->show();
     // // $weibo = $this->__formatByContent($weibo);
     // $data['reply_data'] = $weibo['weibo_id'];
     // if ( !empty($weibo['transpond_data']) ) {
     // $data['reply_data'] .= ',' . $weibo['transpond_data']['weibo_id'];
     // }
     // }
     // // 组装接口数据
     // $p['app_name'] = $weibo['app'];
     // $p['body'] = $_POST['content'];
     // $p['content'] = $_POST['content'];
     // if(!in_array($weibo['type'], array('repost', 'weiba_post', 'weiba_repost'))) {
     // $p['id'] = $weibo['feed_id'];
     // $weibo['type'] = 'feed';
     // } elseif ($weibo['type'] == 'weiba_post' || $weibo['type'] == 'weiba_repost'){
     // $p['id'] = $weibo['app_row_id'];
     // $weibo['type'] = 'weiba_post';
     // $weibo['app_row_table'] = 'feed';
     // } else {
     // $p['id'] = $weibo['app_row_id'];
     // $weibo['type'] = 'feed';
     // }
     // $p['type'] = $weibo['type'];
     // $p['from'] = $data['from'] ? intval($data['from']) : '0';
     // $p['forApi'] = true;
     // $p['curid'] = $weibo_id;
     // $p['curtable'] = $weibo['app_row_table'];
     // $p['sid'] = $p['id'];
     // $p['comment_touid'] = intval($_POST['comment_touid']);
     // $res = api('WeiboStatuses')->data($p)->repost();
     // if ($res) {
     // // redirect(U('wap/Index/detail', array('weibo_id'=>$weibo_id,'type'=>$weibo['type'])), 1, '转发成功');
     // // redirect(U('wap/Index/index'), 1, '转发成功');
     // //添加积分
     // X('Credit')->setUserCredit($this->mid,'add_weibo');
     // model('Credit')->setUserCredit($this->mid, 'forum_post');
     // // $this->redirect(U('w3g/Index/doPostTrue'), 3, '发布成功');
     // // header("location:".U('w3g/Index/doForwardTrue'));
     // $this->doForwardTrue();
     // }else {
     // // redirect(U('wap/Index/detail', array('weibo_id'=>$weibo_id)), 3, '转发失败, 请稍后重试');
     // echo '0';
     // }
 }
Пример #6
0
 /**
  * 分享/转发分享操作,需要传入POST的值
  *
  * @return json 分享/转发分享后的结果信息JSON数据
  */
 public function shareFeed()
 {
     // 获取传入的值
     $post = $this->data;
     // 安全过滤
     foreach ($post as $key => $val) {
         $post[$key] = t($post[$key]);
     }
     // 过滤内容值
     // $post['body'] = filter_keyword($post['body']);
     $filterBodyStatus = filter_words($post['content']);
     if (!$filterBodyStatus['status']) {
         $return = array('status' => 0, 'msg' => $filterBodyStatus['data']);
         return $return;
     }
     $post['body'] = $filterBodyStatus['data'];
     // 判断资源是否删除
     if (empty($post['curid'])) {
         $map['feed_id'] = intval($post['sid']);
     } else {
         $map['feed_id'] = intval($post['curid']);
     }
     $map['is_del'] = 0;
     $isExist = model('Feed')->where($map)->count();
     if ($isExist == 0) {
         $return['status'] = 0;
         $return['msg'] = '内容已被删除,转发失败';
         return $return;
     }
     // 进行分享操作
     $res = model('Share')->shareFeed($post, 'share');
     if ($res['status'] == 1) {
         $app_name = $post['app_name'];
         // 添加积分
         if ($app_name == 'public') {
             model('Credit')->setUserCredit($this->uid, 'forward_weibo');
             // 分享被转发
             $suid = model('Feed')->where($map)->getField('uid');
             model('Credit')->setUserCredit($suid, 'forwarded_weibo');
         }
         if ($app_name == 'weiba') {
             model('Credit')->setUserCredit($this->uid, 'forward_topic');
             // 分享被转发
             $suid = D('Feed')->where('feed_id=' . $map['feed_id'])->getField('uid');
             model('Credit')->setUserCredit($suid, 'forwarded_topic');
         }
         $return = array('status' => 1, 'msg' => '转发成功');
         return $return;
     }
     $return = array('status' => 0, 'msg' => $res['data']);
     return $return;
 }
 /**
  * 添加评论的操作
  *
  * @return array 评论添加状态和提示信息
  */
 public function addcomment()
 {
     // 返回结果集默认值
     $return = array('status' => 0, 'data' => L('PUBLIC_CONCENT_IS_ERROR'));
     // 获取接收数据
     $data['app'] = t($_POST['app_name']);
     $data['table'] = t($_POST['table_name']);
     //model ( 'Comment' )->addComment已针对$data['content']转义,请勿重复操作
     //$data ['content'] = h ( $_POST ['content'] );
     $data['content'] = $_POST['content'];
     $data['app_uid'] = intval($_POST['app_uid']);
     $data['app_row_id'] = intval($_POST['app_row_id']);
     $data['app_row_table'] = t($_POST['app_row_table']);
     $data['row_id'] = intval($_POST['row_id']);
     $data['to_comment_id'] = intval($_POST['to_comment_id']);
     $data['to_uid'] = intval($_POST['to_uid']);
     $data['ifShareFeed'] = intval($_POST['ifShareFeed']);
     $data['comment_old'] = intval($_POST['comment_old']);
     $data['app_detail_summary'] = t($_POST['app_detail_summary']);
     $source = model('Source')->getSourceInfo($data['table'], $data['row_id'], false, $data['app']);
     $uid = $source['uid'];
     if ($this->mid != $uid) {
         $userPrivacy = model('UserPrivacy')->getPrivacy($this->mid, $uid);
         if ($userPrivacy['comment_weibo'] == 1) {
             exit(json_encode(array('status' => 0, 'data' => L('PUBLIC_CONCENT_TIPES'))));
         }
     }
     $filterContentStatus = filter_words($data['content']);
     if (!$filterContentStatus['status']) {
         exit(json_encode(array('status' => 0, 'data' => $filterContentStatus['data'])));
     }
     $data['content'] = $filterContentStatus['data'];
     // 判断资源是否被删除
     $dao = M($data['table']);
     $idField = $dao->getPk();
     $map[$idField] = intval($data['row_id']);
     $sourceInfo = $dao->where($map)->find();
     if (!$sourceInfo) {
         $return['status'] = 0;
         $return['data'] = '内容已被删除,评论失败';
         exit(json_encode($return));
     }
     //兼容旧方法
     if (empty($data['app_detail_summary'])) {
         $source = model('Source')->getSourceInfo($data['table'], $data['row_id'], false, $data['app']);
         $data['app_detail_summary'] = $source['source_body'];
         $data['app_detail_url'] = $source['source_url'];
         $data['app_uid'] = $source['source_user_info']['uid'];
     } else {
         $data['app_detail_summary'] = $data['app_detail_summary'] . '<a class="ico-details" href="' . $data['app_detail_url'] . '"></a>';
     }
     // 添加评论操作
     $data['comment_id'] = model('Comment')->addComment($data);
     $return['sql'] = D()->getLastSql();
     if ($data['comment_id']) {
         $talkbox = intval($_POST['talkbox']);
         $return['status'] = 1;
         $return['data'] = $this->parseComment($data, $talkbox);
         // 同步到微吧
         if ($data['app'] == 'weiba') {
             $this->_upateToweiba($data);
         }
         // 去掉回复用户@
         $lessUids = array();
         if (!empty($data['to_uid'])) {
             $lessUids[] = $data['to_uid'];
         }
         if ($_POST['ifShareFeed'] == 1) {
             // 转发到我的分享
             //解锁内容发布
             unlockSubmit();
             $this->_updateToweibo($data, $sourceInfo, $lessUids);
         } else {
             if ($data['comment_old'] != 0) {
                 // 是否评论给原来作者
                 unlockSubmit();
                 $this->_updateToComment($data, $sourceInfo, $lessUids);
             }
         }
     }
     !$data['comment_id'] && ($return['data'] = model('Comment')->getError());
     exit(json_encode($return));
 }
Пример #8
0
 /**
  * 评论一条微博 --using
  *
  * @param
  *        	integer feed_id 微博ID
  * @param
  *        	integer to_comment_id 评论ID
  * @param
  *        	string content 评论内容
  * @param
  *        	integer from 来源(2-android 3-iPhone)
  * @return array 状态+提示
  */
 public function comment_weibo()
 {
     if (!CheckPermission('core_normal', 'feed_comment')) {
         return array('status' => 0, 'msg' => '您没有权限');
     }
     if (!t($this->data['content'])) {
         return array('status' => 0, 'msg' => '评论内容不能为空');
     }
     //检测用户是否被禁言
     if ($isDisabled = model('DisableUser')->isDisableUser($this->mid, 'post')) {
         return array('status' => 0, 'msg' => '您已经被禁言了');
     }
     $feed_detail = model('Feed')->where('feed_id=' . intval($this->data['feed_id']))->find();
     $data['type'] = 1;
     $data['app'] = $feed_detail['app'];
     $data['table'] = 'feed';
     $data['row_id'] = intval($this->data['feed_id']);
     $data['app_uid'] = $feed_detail['uid'];
     $data['content'] = $this->data['content'];
     // $data ['from'] = 'feed';
     /* # 将emoji编码 */
     $data['content'] = formatEmoji(true, $data['content']);
     if ($this->data['to_comment_id']) {
         $data['to_comment_id'] = intval($this->data['to_comment_id']);
         $data['to_uid'] = model('Comment')->where('comment_id=' . intval($this->data['to_comment_id']))->getField('uid');
     }
     if ($data['comment_id'] = model('Comment')->addComment($data, true)) {
         //如果回复的源为微吧,同步评论到相应的帖子
         if ($data['app'] == 'weiba') {
             $weiba_post_detail = M('weiba_post')->where(array('post_id' => $feed_detail['app_row_id']))->find();
             $wr_data['weiba_id'] = intval($weiba_post_detail['weiba_id']);
             $wr_data['post_id'] = intval($weiba_post_detail['post_id']);
             $wr_data['post_uid'] = intval($weiba_post_detail['post_uid']);
             if (!empty($this->data['to_comment_id'])) {
                 $wr_data['to_reply_id'] = intval($this->data['to_comment_id']);
                 $wr_data['to_uid'] = model('Comment')->where('comment_id=' . intval($this->data['to_comment_id']))->getField('uid');
             }
             $wr_data['uid'] = $this->mid;
             $wr_data['ctime'] = time();
             $wr_data['content'] = $data['content'];
             $filterContentStatus = filter_words($wr_data['content']);
             if (!$filterContentStatus['status']) {
                 return array('status' => 0, 'msg' => $filterContentStatus['data']);
             }
             $wr_data['content'] = $filterContentStatus['data'];
             $wr_data['reply_id'] = $data['comment_id'];
             D('weiba_reply')->add($wr_data);
             $wp_up['last_reply_uid'] = $this->mid;
             $wp_up['last_reply_time'] = $wr_data['ctime'];
             $wp_up['reply_count'] = array('exp', 'reply_count+1');
             $wp_up['reply_all_count'] = array('exp', 'reply_all_count+1');
             D('weiba_post', 'weiba')->where('post_id = ' . $feed_detail['app_row_id'])->save($wp_up);
         }
         return array('status' => 1, 'msg' => '评论成功', 'cid' => $data['comment_id']);
     } else {
         return array('status' => 0, 'msg' => '评论失败');
     }
 }
Пример #9
0
 /**
  * 执行发布帖子
  * @return void
  */
 public function doPost()
 {
     if ($_GET['post_type'] == 'index') {
         $type = false;
     } else {
         $type = true;
     }
     $weibaid = intval($_POST['weiba_id']);
     if (!CheckPermission('weiba_normal', 'weiba_post')) {
         $this->error('对不起,您没有权限进行该操作!', $type);
     }
     $is_lock = M('weiba_blacklist')->where('weiba_id=' . $weibaid . ' and uid=' . $this->mid)->find();
     if ($is_lock) {
         $this->error('您是黑名单用户没有发帖权限', $type);
     }
     $weibaid = intval($_POST['weiba_id']);
     if (!$weibaid) {
         $this->error('请选择微吧,等待返回选择微吧', $type);
     }
     $weiba = D('weiba')->where('weiba_id=' . $weibaid)->find();
     //黑名单功能添加
     if (!CheckPermission('core_admin', 'admin_login')) {
         switch ($weiba['who_can_post']) {
             case 1:
                 $map['weiba_id'] = $weibaid;
                 $map['follower_uid'] = $this->mid;
                 $res = D('weiba_follow')->where($map)->find();
                 if (!$res && !CheckPermission('core_admin', 'admin_login')) {
                     $this->error('对不起,您没有发帖权限,请关注该微吧!', $type);
                 }
                 break;
             case 2:
                 $map['weiba_id'] = $weibaid;
                 $map['level'] = array('in', '2,3');
                 $weiba_admin = D('weiba_follow')->where($map)->order('level desc')->field('follower_uid')->findAll();
                 if (!in_array($this->mid, getSubByKey($weiba_admin, 'follower_uid')) && !CheckPermission('core_admin', 'admin_login')) {
                     $this->error('对不起,您没有发帖权限,仅限该吧管理员发帖!', $type);
                 }
                 break;
             case 3:
                 $map['weiba_id'] = $weibaid;
                 $map['level'] = 3;
                 $weiba_admin = D('weiba_follow')->where($map)->order('level desc')->field('follower_uid')->find();
                 if ($this->mid != $weiba_admin['follower_uid'] && !CheckPermission('core_admin', 'admin_login')) {
                     $this->error('对不起,您没有发帖权限,仅限该吧吧主发帖!', $type);
                 }
                 break;
         }
     }
     $checkContent = str_replace('&nbsp;', '', $_POST['content']);
     $checkContent = str_replace('<br />', '', $checkContent);
     $checkContent = str_replace('<p>', '', $checkContent);
     $checkContent = str_replace('</p>', '', $checkContent);
     $checkContents = preg_replace('/<img(.*?)src=/i', 'img', $checkContent);
     $checkContents = preg_replace('/<embed(.*?)src=/i', 'img', $checkContents);
     if (strlen(t($_POST['title'])) == 0) {
         $this->error('帖子标题不能为空,等待返回添加标题', $type);
     }
     if (strlen(t($checkContents)) == 0) {
         $this->error('帖子内容不能为空,等待返回添加内容', $type);
     }
     preg_match_all('/./us', t($_POST['title']), $match);
     if (count($match[0]) > 25) {
         //汉字和字母都为一个字
         $this->error('帖子标题不能超过25个字,等待返回修改标题', $type);
     }
     /* # 帖子内容 */
     $content = h($_POST['content']);
     if (get_str_length($content) >= 20000) {
         $this->error('帖子内容过长!无法发布!');
     }
     unset($content);
     if ($_POST['attach_ids']) {
         $attach = explode('|', $_POST['attach_ids']);
         foreach ($attach as $k => $a) {
             if (!$a) {
                 unset($attach[$k]);
             }
         }
         $attach = array_map('intval', $attach);
         $data['attach'] = serialize($attach);
     }
     $data['weiba_id'] = $weibaid;
     $data['title'] = t($_POST['title']);
     $data['content'] = h($_POST['content']);
     $data['post_uid'] = $this->mid;
     $data['post_time'] = time();
     $data['last_reply_uid'] = $this->mid;
     $data['last_reply_time'] = $data['post_time'];
     $filterTitleStatus = filter_words($data['title']);
     if (!$filterTitleStatus['status']) {
         $this->error($filterTitleStatus['data'], $type);
     }
     $data['title'] = $filterTitleStatus['data'];
     $filterContentStatus = filter_words($data['content']);
     if (!$filterContentStatus['status']) {
         $this->error($filterContentStatus['data'], $type);
     }
     $data['content'] = $filterContentStatus['data'];
     $res = D('weiba_post')->add($data);
     if ($res) {
         D('Weiba')->setNewcount($weibaid);
         D('weiba')->where('weiba_id=' . $data['weiba_id'])->setInc('thread_count');
         //同步到分享
         // $feed_id = D('weibaPost')->syncToFeed($res,$data['title'],t($checkContent),$this->mid);
         $feed_id = model('Feed')->syncToFeed('weiba', $this->mid, $res);
         D('weiba_post')->where('post_id=' . $res)->setField('feed_id', $feed_id);
         //$this->assign('jumpUrl', U('weiba/Index/postDetail',array('post_id'=>$res)));
         //$this->success('发布成功');
         $result['id'] = $res;
         $result['feed_id'] = $feed_id;
         //添加积分
         model('Credit')->setUserCredit($this->mid, 'publish_topic');
         //更新发帖数
         D('UserData')->updateKey('weiba_topic_count', 1);
         if ($_GET['post_type'] == 'index') {
             $this->success("发布成功");
         } else {
             return $this->ajaxReturn($result, '发布成功', 1);
         }
     } else {
         $this->error('发布失败,等待返回修改发布', $type);
     }
 }
Пример #10
0
/**
 * Parse the input, strip stop/non-words, remove accents, lower case and
 * add to the index.
 *
 * @uses filter_words The function that strips the stop/non-words
 * @uses add_to_index The function that adds the filtered words to the index
 * @return void
 */
function strip_words($arr)
{
    global $allowed_chars;
    $words = $arr['title'] . " " . $arr['subtitle'] . " " . $arr['introduction'] . " " . $arr['body'] . " " . $arr['keywords'];
    $words = unentify(strip_tags(str_replace(">", "> ", str_replace("<", " <", $words))));
    $words = transliterate_accents($words);
    $words = strtolower($words);
    $result = preg_split('/[^' . preg_quote($allowed_chars) . ']/', $words);
    $filter = filter_words($result);
    add_to_index($filter, $arr['code']);
}
Пример #11
0
 /**
  * 分享/转发分享操作,需要传入POST的值
  *
  * @return json 分享/转发分享后的结果信息JSON数据
  */
 public function shareFeed()
 {
     // 获取传入的值
     $post = $_POST;
     // 安全过滤
     foreach ($post as $key => $val) {
         $post[$key] = t($post[$key]);
     }
     // 过滤内容值
     // $post['body'] = filter_keyword($post['body']);
     $filterBodyStatus = filter_words($post['body']);
     if (!$filterBodyStatus['status']) {
         $return = array('status' => 0, 'data' => $filterBodyStatus['data']);
         exit(json_encode($return));
     }
     $post['body'] = $filterBodyStatus['data'];
     // 判断资源是否删除
     if (empty($post['curid'])) {
         $map['feed_id'] = intval($post['sid']);
     } else {
         $map['feed_id'] = intval($post['curid']);
     }
     $map['is_del'] = 0;
     $isExist = model('Feed')->where($map)->count();
     if ($isExist == 0) {
         $return['status'] = 0;
         $return['data'] = '内容已被删除,转发失败';
         exit(json_encode($return));
     }
     // 进行分享操作
     $return = model('Share')->shareFeed($post, 'share');
     if ($return['status'] == 1) {
         $app_name = $post['app_name'];
         // 添加积分
         if ($app_name == 'public') {
             model('Credit')->setUserCredit($this->uid, 'forward_weibo');
             // 分享被转发
             $suid = model('Feed')->where($map)->getField('uid');
             model('Credit')->setUserCredit($suid, 'forwarded_weibo');
         }
         if ($app_name == 'weiba') {
             model('Credit')->setUserCredit($this->uid, 'forward_topic');
             // 分享被转发
             $suid = D('Feed')->where('feed_id=' . $map['feed_id'])->getField('uid');
             model('Credit')->setUserCredit($suid, 'forwarded_topic');
         }
         $this->assign($return['data']);
         // 分享配置
         $weiboSet = model('Xdata')->get('admin_Config:feed');
         $this->assign('weibo_premission', $weiboSet['weibo_premission']);
         $return['data'] = $this->fetch('PostFeed');
     }
     if ($post['comment'] == '1') {
     }
     exit(json_encode($return));
 }
Пример #12
0
    $regex = '/^([a-z]*)' . $filter . '$/i';
    $line = sprintf("\nconst char g_prefix_%s[] = \"", $filter);
    foreach ($db as $word) {
        if (preg_match($regex, $word, $res)) {
            $s = '\\0' . ucfirst($res[1]);
            if (strlen($s) > $maxlen) {
                continue;
            }
            if (strlen($line . $s) > 75) {
                echo "{$line}\"\n";
                $line = "\t\"";
            }
            $line .= $s;
        }
    }
    echo "{$line}\";\n";
}
echo "#ifndef __DB_H__\n";
echo "#define __DB_H__\n";
filter_words('cal');
filter_words('matic');
filter_words('meter');
filter_words('ferous');
filter_words('metric');
filter_words('nated');
filter_words('stic');
filter_words('opic');
filter_words('ected');
filter_words('graph');
filter_words('scope');
echo "\n#endif/*__DB_H__*/\n";
Пример #13
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';
     }
     //分享类型合法性验证 - 临时解决方案
     $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;
     }
 }
Пример #14
0
 public function add_post($imgs)
 {
     if (!CheckPermission('weiba_normal', 'weiba_post')) {
         $this->error('对不起,您没有权限进行该操作!');
     }
     $weibaid = intval($this->data['weiba_id']);
     if (!$weibaid) {
         $this->error('请选择微吧!');
     }
     $weiba = D('weiba')->where('weiba_id=' . $weibaid)->find();
     if (!CheckPermission('core_admin', 'admin_login')) {
         switch ($weiba['who_can_post']) {
             case 1:
                 $map['weiba_id'] = $weibaid;
                 $map['follower_uid'] = $this->mid;
                 $res = D('weiba_follow')->where($map)->find();
                 if (!$res && !CheckPermission('core_admin', 'admin_login')) {
                     $this->error('对不起,您没有发帖权限,请关注该微吧!');
                 }
                 break;
             case 2:
                 $map['weiba_id'] = $weibaid;
                 $map['level'] = array('in', '2,3');
                 $weiba_admin = D('weiba_follow')->where($map)->order('level desc')->field('follower_uid')->findAll();
                 if (!in_array($this->mid, getSubByKey($weiba_admin, 'follower_uid')) && !CheckPermission('core_admin', 'admin_login')) {
                     $this->error('对不起,您没有发帖权限,仅限管理员发帖!');
                 }
                 break;
             case 3:
                 $map['weiba_id'] = $weibaid;
                 $map['level'] = 3;
                 $weiba_admin = D('weiba_follow')->where($map)->order('level desc')->field('follower_uid')->find();
                 if ($this->mid != $weiba_admin['follower_uid'] && !CheckPermission('core_admin', 'admin_login')) {
                     $this->error('对不起,您没有发帖权限,仅限吧主发帖!');
                 }
                 break;
         }
     }
     if (!empty($imgs)) {
         foreach ($imgs as $v) {
             $src = getImageUrlByAttachId($v['attach_id'], 320, 1000);
             $src && ($img_arr[] = '<img src="' . $src . '" class="mobile_upload" _src="' . getImageUrlByAttachId($v['attach_id']) . '" />');
         }
         $this->data['content'] = implode(' ', $img_arr) . $this->data['content'];
     }
     $checkContent = str_replace('&nbsp;', '', $this->data['content']);
     $checkContent = str_replace('<br />', '', $checkContent);
     $checkContent = str_replace('<p>', '', $checkContent);
     $checkContent = str_replace('</p>', '', $checkContent);
     $checkContents = preg_replace('/<img(.*?)src=/i', 'img', $checkContent);
     $checkContents = preg_replace('/<embed(.*?)src=/i', 'img', $checkContents);
     if (strlen(t($this->data['title'])) == 0) {
         $this->error('帖子标题不能为空');
     }
     if (strlen(t($checkContents)) == 0) {
         $this->error('帖子内容不能为空');
     }
     preg_match_all('/./us', t($this->data['title']), $match);
     if (count($match[0]) > 20) {
         // 汉字和字母都为一个字
         $this->error('帖子标题不能超过20个字');
     }
     if ($this->data['attach_ids']) {
         $attach = explode('|', $this->data['attach_ids']);
         foreach ($attach as $k => $a) {
             if (!$a) {
                 unset($attach[$k]);
             }
         }
         $attach = array_map('intval', $attach);
         $data['attach'] = serialize($attach);
     }
     $data['weiba_id'] = $weibaid;
     $data['title'] = t($this->data['title']);
     $data['content'] = h($this->data['content']);
     // 格式化emoji
     $data['title'] = formatEmoji(true, $data['title']);
     $data['content'] = formatEmoji(true, $data['content']);
     // 处理换行,临时解决方案
     $br = array("\r\n", "\n", "\r");
     $replace = '<br/>';
     $data['content'] = str_replace($br, $replace, $data['content']);
     $data['post_uid'] = $this->mid;
     $data['post_time'] = time();
     $data['last_reply_uid'] = $this->mid;
     $data['last_reply_time'] = $data['post_time'];
     $filterTitleStatus = filter_words($data['title']);
     if (!$filterTitleStatus['status']) {
         $this->error($filterTitleStatus['data'], true);
     }
     $data['title'] = $filterTitleStatus['data'];
     $filterContentStatus = filter_words($data['content']);
     if (!$filterContentStatus['status']) {
         $this->error($filterContentStatus['data'], true);
     }
     $data['content'] = $filterContentStatus['data'];
     $res = D('weiba_post')->add($data);
     if ($res) {
         D('weiba')->where('weiba_id=' . $data['weiba_id'])->setInc('thread_count');
         // 同步到微博
         // $feed_id = D('weibaPost')->syncToFeed($res,$data['title'],t($checkContent),$this->mid);
         $feed_id = model('Feed')->syncToFeed('weiba', $this->mid, $res);
         D('weiba_post')->where('post_id=' . $res)->setField('feed_id', $feed_id);
         // $this->assign('jumpUrl', U('weiba/Index/postDetail',array('post_id'=>$res)));
         // $this->success('发布成功');
         $result['id'] = $res;
         $result['feed_id'] = $feed_id;
         // 添加积分
         model('Credit')->setUserCredit($this->mid, 'publish_topic');
         return array('status' => 1, 'post_id' => $res, 'msg' => '发布成功');
     } else {
         $this->error('发布失败');
     }
 }
Пример #15
0
 /**
  * 添加帖子回复的操作
  * @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;
 }
Пример #16
0
 function add_post($imgs)
 {
     if (!CheckPermission('weiba_normal', 'weiba_post')) {
         $this->error('对不起,您没有权限进行该操作!');
     }
     $weibaid = intval($this->data['weiba_id']);
     if (!$weibaid) {
         $this->error('请选择微吧!');
     }
     /*if($_FILES['video']) {
           $this->up_file();
       }*/
     //            if ($_SESSION['up_oss_path']) {
     //
     //                $data ['weiba_id'] = $weibaid;
     //                if (isset($this->data ['title']))
     //                    $data ['title'] = t($this->data ['title']);
     //
     //                $info = pathinfo($_SESSION['up_oss_path']);
     //                $extension = $info['extension'];
     //                /*echo '<br/>-------------';
     //                var_dump($extension);echo '----------------<br/>';exit();*/
     //                if (strtolower($extension) == 'mp3') {
     //                    $data['content'] = '<div style="width:145px; height:82px;"><img src="__THEME__/image/video.png" style="width:144px; height:81px;" onclick="playMusic()" tag="1"/></div>';
     //                } else if (strtolower($extension) == 'mp4') {
     //                    $data['content'] = '<div style="width:145px; height:82px;"><img src="__THEME__/image/video.png" style="width:144px; height:81px;" onclick="playVideo()" tag="1"/></div>';
     //                } else {
     //                    $data['content'] = '<div style="width:145px; height:82px;line-height:82px; font-size:16px;text-align:center">文件不存在</div>';
     //                }
     //
     //                $data ['post_uid'] = 1;//$this->mid;
     //                $data ['post_time'] = time();
     //                $data ['last_reply_uid'] = 1;//$this->mid;
     //                $data ['last_reply_time'] = $data ['post_time'];
     //
     //                // $post_id=D('weiba_post')->where($data)->field('post_id')->find();
     //                $post_id = D('weiba_post')->add($data);
     //                if ($_SESSION['videoImage'] && strtolower($extension) == 'mp4') {
     //                    $videoImage = $_SESSION['videoImage'];
     //                    unset($_SESSION['videoImage']);
     //
     //                    /*$flag = $this->multiupload($weibaid, $post_id, $videoImage);
     //                    var_dump($flag);*/
     //
     //                } else
     //                    $videoImage = null;
     //
     //                //$upload=$this->video_path($_REQUEST['uploadFile']);
     //                //var_dump($upload);
     //                //$flag=$this->multiupload($weibaid,$post_id,$upload['video_path'],$videoImage);
     //
     //                if ($_SESSION['up_oss_path']) {
     //                    $upload_path = $_SESSION['up_oss_path'];
     //                    if (file_exists($_SESSION['up_oss_path']))
     //                        unset($_SESSION['up_oss_path']);
     //                } else {
     //                    $upload_path = null;
     //                }
     //
     //
     //                $flag = $this->multiupload($weibaid, $post_id, $upload_path, $videoImage);
     //
     //                if ($flag['status'] == 0) {
     //                    D('weiba_post')->where(array('post_id' => $post_id))->delete();
     //                    $this->error('--上传失败');
     //                } else {
     //
     //                    //var_dump($flag);
     //                    if($flag['videoImage']!=null){
     //                        M('up_oss')->where(array('up_oss_id'=>$flag['up_oss_id']))->save(array('up_oss_image'=>$flag['videoImage']));
     //                        $content = '<div style="width:145px; height:82px;"><img src="'.$flag['videoImage'].'" style="width:144px; height:81px;" onclick="playVideo()" tag="1"/></div>';
     //                        D('weiba_post')->where(array('post_id' => $post_id))->save(array('content'=>$content));
     //                        //echo '========'.var_dump($t);exit();
     //                    }
     //
     //                    unlink($_SESSION['up_oss_path']);//删除文件
     //                    //获得加入圈子的用户id
     //                    $weibaFollows = M('weibaFollow')->where(array('weiba_id' => $data ['weiba_id']))->field('follower_uid')->select();
     //
     //                    foreach ($weibaFollows as $vv) {
     //                        if ($vv['follower_uid'] != $this->mid) {
     //                            $follower_flag = M('user_data')->where(array('uid' => $vv['follower_uid'], 'key' => 'trends' . $data ['weiba_id']))->field('value')->select();
     //                            if (!$follower_flag) {
     //                                $data = array('uid' => $vv['follower_uid'], 'key' => 'trends' . $data ['weiba_id'], 'value' => 1);
     //                                M('user_data')->add($data);
     //
     //                            } else {
     //                                M('user_data')->where(array('uid' => $vv['follower_uid'], 'key' => 'trends' . $data ['weiba_id']))->setInc('value');
     //                            }
     //                        }
     //                    }
     //
     //                    return array(
     //                        'status' => 1,
     //                        'post_id' => $post_id,
     //                        'oss_id' => $flag['up_oss_id'],
     //                        'oss_image_url'=>$flag['videoImage'],
     //                        'oss_url' => $flag['url'],
     //                        'msg' => '上传成功'
     //                    );
     //                }
     //            }
     $weiba = D('weiba')->where('weiba_id=' . $weibaid)->find();
     if (!CheckPermission('core_admin', 'admin_login')) {
         switch ($weiba['who_can_post']) {
             case 1:
                 $map['weiba_id'] = $weibaid;
                 $map['follower_uid'] = $this->mid;
                 $res = D('weiba_follow')->where($map)->find();
                 if (!$res && !CheckPermission('core_admin', 'admin_login')) {
                     $this->error('对不起,您没有发帖权限,请关注该微吧!');
                 }
                 break;
             case 2:
                 $map['weiba_id'] = $weibaid;
                 $map['level'] = array('in', '2,3');
                 $weiba_admin = D('weiba_follow')->where($map)->order('level desc')->field('follower_uid')->findAll();
                 if (!in_array($this->mid, getSubByKey($weiba_admin, 'follower_uid')) && !CheckPermission('core_admin', 'admin_login')) {
                     $this->error('对不起,您没有发帖权限,仅限管理员发帖!');
                 }
                 break;
             case 3:
                 $map['weiba_id'] = $weibaid;
                 $map['level'] = 3;
                 $weiba_admin = D('weiba_follow')->where($map)->order('level desc')->field('follower_uid')->find();
                 if ($this->mid != $weiba_admin['follower_uid'] && !CheckPermission('core_admin', 'admin_login')) {
                     $this->error('对不起,您没有发帖权限,仅限吧主发帖!');
                 }
                 break;
         }
     }
     if (!empty($imgs)) {
         foreach ($imgs as $v) {
             $src = getImageUrlByAttachId($v['attach_id']);
             $src && ($img_arr[] = '<img src="' . $src . '" class="mobile_upload" />');
         }
         $this->data['content'] = $this->data['content'] . '<br/>' . implode(' ', $img_arr);
     }
     $checkContent = str_replace('&nbsp;', '', $this->data['content']);
     $checkContent = str_replace('<br />', '', $checkContent);
     $checkContent = str_replace('<p>', '', $checkContent);
     $checkContent = str_replace('</p>', '', $checkContent);
     $checkContents = preg_replace('/<img(.*?)src=/i', 'img', $checkContent);
     $checkContents = preg_replace('/<embed(.*?)src=/i', 'img', $checkContents);
     if (strlen(t($this->data['title'])) == 0) {
         $this->error('帖子标题不能为空');
     }
     if (strlen(t($checkContents)) == 0) {
         $this->error('帖子内容不能为空');
     }
     preg_match_all('/./us', t($this->data['title']), $match);
     if (count($match[0]) > 20) {
         // 汉字和字母都为一个字
         $this->error('帖子标题不能超过20个字');
     }
     if ($this->data['attach_ids']) {
         $attach = explode('|', $this->data['attach_ids']);
         foreach ($attach as $k => $a) {
             if (!$a) {
                 unset($attach[$k]);
             }
         }
         $attach = array_map('intval', $attach);
         $data['attach'] = serialize($attach);
     }
     $data['weiba_id'] = $weibaid;
     $data['title'] = t($this->data['title']);
     $data['content'] = h($this->data['content']);
     $data['post_uid'] = $this->mid;
     $data['post_time'] = time();
     $data['last_reply_uid'] = $this->mid;
     $data['last_reply_time'] = $data['post_time'];
     $filterTitleStatus = filter_words($data['title']);
     if (!$filterTitleStatus['status']) {
         $this->error($filterTitleStatus['data'], true);
     }
     $data['title'] = $filterTitleStatus['data'];
     $filterContentStatus = filter_words($data['content']);
     if (!$filterContentStatus['status']) {
         $this->error($filterContentStatus['data'], true);
     }
     $data['content'] = $filterContentStatus['data'];
     //$res = D ( 'weiba_post' )->add ( $data );
     /*echo '<pre>';
       print_r($data);
       var_dump($res);*/
     /*if($_FILES['video']) {
           $this->up_file();
       }*/
     if ($_SESSION['up_oss_path']) {
         $data['weiba_id'] = $weibaid;
         if (isset($this->data['title'])) {
             $data['title'] = t($this->data['title']);
         }
         $info = pathinfo($_SESSION['up_oss_path']);
         $extension = $info['extension'];
         /*echo '<br/>-------------';
           var_dump($extension);echo '----------------<br/>';exit();*/
         if (strtolower($extension) == 'mp3') {
             $data['content'] .= '<div style="width:145px; height:82px;"><img src="__THEME__/image/video.png" style="width:144px; height:81px;" onclick="playMusic()" tag="1"/></div>';
         } else {
             if (strtolower($extension) == 'mp4') {
                 $data['content'] .= '<div style="width:145px; height:82px;"><img src="__THEME__/image/video.png" style="width:144px; height:81px;" onclick="playVideo()" tag="1"/></div>';
             } else {
                 $data['content'] .= '<div style="width:145px; height:82px;line-height:82px; font-size:16px;text-align:center">文件不存在</div>';
             }
         }
         // $data ['post_uid'] = 1;//$this->mid;
         $data['post_time'] = time();
         //$data ['last_reply_uid'] = 1;//$this->mid;
         $data['last_reply_time'] = $data['post_time'];
         // $post_id=D('weiba_post')->where($data)->field('post_id')->find();
         $res = D('weiba_post')->add($data);
         if ($_SESSION['videoImage'] && strtolower($extension) == 'mp4') {
             $videoImage = $_SESSION['videoImage'];
             unset($_SESSION['videoImage']);
             /*$flag = $this->multiupload($weibaid, $post_id, $videoImage);
               var_dump($flag);*/
         } else {
             $videoImage = null;
         }
         //$upload=$this->video_path($_REQUEST['uploadFile']);
         //var_dump($upload);
         //$flag=$this->multiupload($weibaid,$post_id,$upload['video_path'],$videoImage);
         if ($_SESSION['up_oss_path']) {
             $upload_path = $_SESSION['up_oss_path'];
             if (file_exists($_SESSION['up_oss_path'])) {
                 unset($_SESSION['up_oss_path']);
             }
         } else {
             $upload_path = null;
         }
         $flag = $this->multiupload($weibaid, $res, $upload_path, $videoImage);
         if ($flag['status'] == 0) {
             D('weiba_post')->where(array('post_id' => $res))->delete();
             $this->error($flag['message']);
         } else {
             //var_dump($flag);
             if ($flag['videoImage'] != null) {
                 M('up_oss')->where(array('up_oss_id' => $flag['up_oss_id']))->save(array('up_oss_image' => $flag['videoImage']));
                 $content = str_replace('<img src="__THEME__/image/video.png" style="width:144px; height:81px;" onclick="playVideo()" tag="1"/>', '<img src="' . $flag['videoImage'] . '" style="width:144px; height:81px;" onclick="playVideo()" tag="1"/>', $data['content']);
                 D('weiba_post')->where(array('post_id' => $res))->save(array('content' => $content));
                 //echo '========'.var_dump($t);exit();
             }
             unlink($_SESSION['up_oss_path']);
             //删除文件
             /*return array(
                   'status' => 1,
                   'post_id' => $post_id,
                   'oss_id' => $flag['up_oss_id'],
                   'oss_image_url'=>$flag['videoImage'],
                   'oss_url' => $flag['url'],
                   'msg' => '上传成功'
               );*/
         }
     } else {
         print_r($data);
         $res = D('weiba_post')->add($data);
         if (!$res) {
             $this->error('发布失败');
         }
     }
     if ($res) {
         D('weiba')->where('weiba_id=' . $data['weiba_id'])->setInc('thread_count');
         // 同步到微博
         // $feed_id = D('weibaPost')->syncToFeed($res,$data['title'],t($checkContent),$this->mid);
         $feed_id = model('Feed')->syncToFeed('weiba', $this->mid, $res);
         D('weiba_post')->where('post_id=' . $res)->setField('feed_id', $feed_id);
         // $this->assign('jumpUrl', U('weiba/Index/postDetail',array('post_id'=>$res)));
         // $this->success('发布成功');
         $result['id'] = $res;
         $result['feed_id'] = $feed_id;
         // 添加积分
         model('Credit')->setUserCredit($this->mid, 'publish_topic');
         //获得加入圈子的用户id
         $weibaFollows = M('weibaFollow')->where(array('weiba_id' => $data['weiba_id']))->field('follower_uid')->select();
         foreach ($weibaFollows as $vv) {
             if ($vv['follower_uid'] != $this->mid) {
                 $flag = M('user_data')->where(array('uid' => $vv['follower_uid'], 'key' => 'trends' . $data['weiba_id']))->field('value')->select();
                 if (!$flag) {
                     $data = array('uid' => $vv['follower_uid'], 'key' => 'trends' . $data['weiba_id'], 'value' => 1);
                     M('user_data')->add($data);
                 } else {
                     M('user_data')->where(array('uid' => $vv['follower_uid'], 'key' => 'trends' . $data['weiba_id']))->setInc('value');
                 }
             }
         }
         return array('status' => 1, 'post_id' => $res, 'msg' => '发布成功');
     } else {
         $this->error('发布失败');
     }
 }