public function index()
 {
     if (isset($_POST['editsubmit'])) {
         $group['name'] = h(t($_POST['name']));
         $group['intro'] = h(t($_POST['intro']));
         $group['cid0'] = intval($_POST['cid0']);
         // intval($_POST['cid1']) > 0	&& $group['cid1']  = intval($_POST['cid1']);
         $cid1 = D('Category')->_digCateNew($_POST);
         intval($cid1) > 0 && ($group['cid1'] = intval($cid1));
         if (!$group['name']) {
             $this->error('群组名称不能为空');
         } else {
             if (get_str_length($group['name']) > 30) {
                 $this->error('群组名称不能超过30个字');
             }
         }
         if (D('Category')->getField('id', 'name=' . $group['name'])) {
             $this->error('请选择群分类');
         }
         if (get_str_length($group['intro']) > 200) {
             $this->error('群组简介请不要超过200个字');
         }
         // 			if (!preg_replace("/[,\s]*/i", '', $_POST['tags']) || count(array_filter(explode(',', $_POST['tags']))) > 5) {
         // 				$this->error('标签不能为空或者不要超过5个');
         // 			}
         if ($_FILES['logo']['size'] > 0 && is_image_file($_FILES['logo']['name'])) {
             // 群组LOGO
             $options['allow_exts'] = 'jpg,gif,png,jpeg,bmp';
             $options['max_size'] = 2 * 1024 * 1024;
             $options['attach_type'] = 'group_logo';
             $data['upload_type'] = 'image';
             $info = model('Attach')->upload($data, $options);
             if ($info['status']) {
                 $group['logo'] = $info['info'][0]['save_path'] . $info['info'][0]['save_name'];
             }
         }
         $res = $this->group->where('id=' . $this->gid)->save($group);
         if ($res !== false) {
             D('Log')->writeLog($this->gid, $this->mid, '修改群组基本信息', 'setting');
             /* 	// 更新群组标签
             				D('GroupTag')->setGroupTag($_POST['tags'], $this->gid); */
             $this->assign('jumUrl', U('group/Manage/index', array('gid' => $this->gid)));
             $this->success('保存成功');
         }
         $this->error('保存失败');
     }
     //dump($this->groupinfo['tags']);exit;
     // 群组标签
     // 		foreach ($this->groupinfo['tags'] as $v) {
     // 			$_group_tags[] = $v['name'];
     // 		}
     // 		$this->assign('group_tags', implode(',', $_group_tags));
     // 		$this->assign('reTags', D('GroupTag')->getHotTags('recommend'));
     $this->assign('current', 'basic');
     $this->display();
 }
 /**
  * 提交反馈信息
  *
  * @reuqest int $uid [null] 可为空,默认从token中读取
  * @reuqest string $content 反馈内容,不能为空
  * @return array
  * @author Medz Seven <*****@*****.**>
  **/
 public function sendFeeedback()
 {
     $uid = intval($_REQUEST['uid']);
     $uid or $uid = $this->mid;
     $content = t($_REQUEST['content']);
     /* # 检查是否有uid */
     if (!$uid) {
         $this->error(array('status' => 0, 'msg' => '缺少用户UID'));
         /* # 检查是否有反馈内容 */
     } elseif (!$content) {
         $this->error(array('status' => -1, 'msg' => '请输入反馈内容'));
         /* # 检查内容是否超出 */
     } elseif (get_str_length($content) > 500) {
         $this->error(array('status' => -2, 'msg' => '反馈长度超出最大小指500字'));
     }
     /* # 添加反馈,和错误提示 */
     model('Feedback')->add(1, $content, $uid) or $this->error(array('status' => -3, 'msg' => '反馈失败!'));
     /* # 反馈成功 */
     return array('status' => 1, 'msg' => '反馈成功');
 }
Exemple #3
0
 /**
  * addVote
  * 添加投票
  * @param mixed $data
  * @param mixed $opt
  * @access public
  * @return void
  */
 public function addVote($data, $opt)
 {
     $deadline = $data['deadline'];
     if ($deadline < time()) {
         throw new ThinkException('投票截止时间不能早于发起投票的时间!');
     }
     //检测选项是否重复
     $opt_test = array_filter($opt);
     foreach ($opt as $value) {
         if (get_str_length($value) > 200) {
             throw new ThinkException("投票选项不能超过200个字符");
         }
     }
     $opt_test_count = count(array_unique($opt_test));
     if ($opt_test_count < count($opt_test)) {
         throw new ThinkException('投票不允许有重复项');
     }
     $vote_id = $this->add($data);
     if ($vote_id) {
         $voteUser = D("VoteUser");
         $voteUser->uid = $data['uid'];
         $voteUser->vote_id = $vote_id;
         $voteUser->cTime = time();
         $voteUser->add();
         //选项表
         $optDao = D("VoteOpt");
         foreach ($_POST["opt"] as $v) {
             if (!$v) {
                 continue;
             }
             $data["vote_id"] = $vote_id;
             $data["name"] = t($v);
             $add = $optDao->add($data);
         }
     }
     return $vote_id;
 }
 /**
  * 添加分享
  * @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 = 'group', $type = '', $data = array(), $app_id = 0, $app_table = 'group_feed', $extUid = null, $lessUids = null, $isAtMe = true, $is_repost = 0)
 {
     // 判断数据的正确性
     if (!$uid || $type == '') {
         return false;
     }
     if (strpos($type, 'postvideo') !== false) {
         $type = 'postvideo';
     }
     //分享类型合法性验证 - 临时解决方案
     if (!in_array($type, array('post', 'repost', 'postvideo', 'postfile', 'postimage'))) {
         $type = 'post';
     }
     // //应用类型验证 用于分享框 - 临时解决方案
     // if ( !in_array( $app , array('public','weiba','tipoff') ) ){
     //     $app = 'public';
     //     $type = 'post';
     //     $app_table = 'feed';
     // }
     $app_table = strtolower($app_table);
     // 添加feed表记录
     $data['gid'] = $data['gid'];
     $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 {
         // 拼装数据,如果是评论再转发、回复评论等情况,需要额外叠加对话数据
         $data['body'] = str_replace(SITE_URL, '[SITE_URL]', preg_html($data['body']));
         // 获取用户发送的内容,仅仅以//进行分割
         $scream = explode('//', $data['body']);
         // 截取内容信息为分享内容字数 - 重点
         $feedConf = model('Xdata')->get('admin_Config:feed');
         $feedNums = $feedConf['weibo_nums'];
         $body = array();
         foreach ($scream as $value) {
             $tbody[] = $value;
             $bodyStr = implode('//', $tbody);
             if (get_str_length($bodyStr) > $feedNums) {
                 break;
             }
             $body[] = $value;
             unset($bodyStr);
         }
         $data['body'] = implode('//', $body);
         // 获取用户发布内容
         $data['content'] = trim($scream[0]);
     }
     //分享到分享的应用资源,加入原资源链接
     $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');
     //             }
     //         }
     // 添加关联数据
     $feed_data = D('group_feed_data')->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) {
         //分享发布成功后的钩子
         //             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'];
         }
         // 发送@消息
         D('GroupAtme')->setAppName('group')->setAppTable('group_feed')->addAtme($content, $feed_id, $extUid, $lessUids, $data['gid']);
         $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;
     }
 }
 public function editCategory()
 {
     if (isset($_POST['editSubmit'])) {
         $id = intval($_POST['id']);
         $cate['title'] = trim(t($_POST['title']));
         if (!$this->Category->getField('id', 'id=' . $id)) {
             $this->error('分类不存在!');
         }
         if (empty($cate['title'])) {
             $this->error('名称不能为空!');
         }
         if (get_str_length($cate['title']) > 25) {
             $this->error('名称不能超过25个字!');
         }
         // $pid = $cate ['pid'] = intval ( $_POST ['cid0'] ); //1级分类
         $pid = $this->Category->_digCateNew($_POST);
         $cate['pid'] = intval($pid);
         if ($pid == intval($_POST['id'])) {
             $this->error('不能选择所编辑分类为上级');
         }
         S('Cache_Group_Cate_0', null);
         S('Cache_Group_Cate_' . $pid, null);
         if ($pid != 0 && !$this->Category->getField('id', 'id=' . $pid)) {
             $this->error('父级分类错误!');
         } else {
             if ($pid == $id) {
                 $res = $this->Category->setField('title', $cate['title'], 'id=' . $id);
             } else {
                 $res = $this->Category->where("id={$id}")->save($cate);
             }
         }
         if (false !== $res) {
             S('Cache_Group_Cate_0', null);
             $this->success('操作成功!');
         } else {
             $this->error('操作失败!');
         }
     }
     $id = intval($_GET['id']);
     $category = $this->Category->where("id={$id}")->find();
     $this->assign('category', $category);
     $this->display();
 }
 /**
  * 验证昵称内容的正确性
  * @param  string $name     输入昵称的信息
  * @param  string $old_name 原始昵称的信息
  * @return bool   是否验证成功
  */
 public function isValidName($name, $old_name = null)
 {
     // 默认不准使用的昵称
     $protected_name = array('name', 'uname', 'admin', 'profile', 'space');
     $site_config = model('Xdata')->get('admin_Config:site');
     !empty($site_config['sys_nickname']) && ($protected_name = array_merge($protected_name, explode(',', $site_config['sys_nickname'])));
     if (in_array($name, $protected_name)) {
         $this->_error = L('PUBLIC_NICKNAME_RESERVED');
         // 抱歉,该昵称不允许被使用
         return false;
     }
     //不能为手机号格式
     $phone_reg = preg_match($this->_phone_reg, $name) !== 0;
     if ($phone_reg) {
         $this->_error = '用户名不能为手机号格式';
         return false;
     }
     //其他格式
     $res = preg_match($this->_name_reg, $name) !== 0;
     if ($res) {
         $length = get_str_length($name);
         $res = $length >= 2 && $length <= 10;
         if (!$res) {
             $this->_error = L('PUBLIC_NICKNAME_LIMIT', array('nums' => '2-10'));
             // 昵称长度必须在2-10个汉字之间
             return false;
         }
     } else {
         $this->_error = '昵称仅支持中英文,数字,下划线';
         return false;
     }
     $old_user = \Ts\Models\User::existent()->byUserName($old_name)->first();
     $user = \Ts\Models\User::existent()->byUserName($name)->first();
     if ($name != $old_name && $old_name && $user && $old_user->uid != $user->uid) {
         $this->_error = '该用户名已经存在。';
         return false;
     }
     //敏感词
     if (filter_keyword($name) !== $name) {
         $this->_error = '抱歉,该昵称包含敏感词不允许被使用';
         return false;
     }
     return true;
 }
 /**
  * 验证昵称内容的正确性
  * @param string $name 输入昵称的信息
  * @param string $old_name 原始昵称的信息
  * @return boolean 是否验证成功
  */
 public function isValidName($name, $old_name = null)
 {
     // 默认不准使用的昵称
     $protected_name = array('name', 'uname', 'admin', 'profile', 'space');
     $site_config = model('Xdata')->get('admin_Config:site');
     !empty($site_config['sys_nickname']) && ($protected_name = array_merge($protected_name, explode(',', $site_config['sys_nickname'])));
     $res = preg_match($this->_name_reg, $name) !== 0;
     if ($res) {
         $length = get_str_length($name);
         $res = $length >= 2 && $length <= 10;
     } else {
         $this->_error = '仅支持中英文,数字,下划线';
         $res = false;
         return $res;
     }
     // 预保留昵称
     if (in_array($name, $protected_name)) {
         $this->_error = L('PUBLIC_NICKNAME_RESERVED');
         // 抱歉,该昵称不允许被使用
         $res = false;
         return $res;
     }
     if (!$res) {
         $this->_error = L('PUBLIC_NICKNAME_LIMIT', array('nums' => '2-10'));
         // 昵称长度必须在2-10个汉字之间
         return $res;
     }
     if ($name != $old_name && $this->_user_model->where('`uname`="' . mysql_escape_string($name) . '"')->find()) {
         $this->_error = L('PUBLIC_ACCOUNT_USED');
         // 该用户名已被使用
         $res = false;
     }
     // 敏感词
     if (filter_keyword($name) !== $name) {
         $this->_error = '抱歉,该昵称包含敏感词不允许被使用';
         return false;
     }
     return $res;
 }
 /**
  * 执行发布帖子
  * @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);
     }
 }
Exemple #9
0
/**
 * 标签安全过滤
 * 长度不超过20
 */
function tags_filter($tag)
{
    //过滤敏感词  纯文本  限制汉字8个  英文16个
    //过滤标点符号(除了-与&)
    static $filter_symbol = null;
    if ($filter_symbol == null) {
        //第一次
        $filter_symbol = array('~', '!', '@', '#', '$', '%', '^', '*', '(', ')', '_', '+', '{', '}', '|', ':', '"', '<', '>', '?', '.', '`', '=', '[', ']', '\\', ';', '\'', ',', '.', '/', '!', '¥', '……', '…', ':', '“', '”', '《', '》', '?', ',', '。', ';', '‘', '’', '【', '】');
    }
    $tag = t($tag);
    $tag = str_replace($filter_symbol, '', $tag);
    $tag = filter_keyword(t($tag));
    return get_str_length($tag) > 8 ? getShort($tag, 8) : $tag;
}
Exemple #10
0
 /**
  * 截取微博内容,将微博中的URL替换成{ts_urlX}进行字符数目统计
  * @param string $content 微博内容
  * @param string $weiboNums 微博截取数目,默认为0
  * @return array 格式化后的微博内容,body与content
  */
 public function formatFeedContent($content, $weiboNums = 0)
 {
     // 拼装数据,如果是评论再转发、回复评论等情况,需要额外叠加对话数据
     $content = str_replace(SITE_URL, '[SITE_URL]', preg_html($content));
     // 格式化微博信息 - URL
     $content = preg_replace_callback('/((?:https?|mailto|ftp):\\/\\/([^\\x{2e80}-\\x{9fff}\\s<\'\\"“”‘’,。}]*)?)/u', '_format_feed_content_url_length', $content);
     $replaceHash = $GLOBALS['replaceHash'];
     unset($GLOBALS['replaceHash']);
     // 获取用户发送的内容,仅仅以//进行分割
     $scream = explode('//', $content);
     // 截取内容信息为微博内容字数 - 重点
     $feedNums = 0;
     if (empty($weiboNums)) {
         $feedConf = model('Xdata')->get('admin_Config:feed');
         $feedNums = $feedConf['weibo_nums'];
     } else {
         $feedNums = $weiboNums;
     }
     $body = array();
     // 还原URL操作
     $patterns = array_keys($replaceHash);
     $replacements = array_values($replaceHash);
     foreach ($scream as $value) {
         $tbody[] = $value;
         $bodyStr = implode('//', $tbody);
         if (get_str_length(ltrim($bodyStr)) > $feedNums) {
             break;
         }
         $body[] = str_replace($patterns, $replacements, $value);
         unset($bodyStr);
     }
     $data['body'] = implode('//', $body);
     // 获取用户发布内容
     $scream[0] = str_replace($patterns, $replacements, $scream[0]);
     $data['content'] = trim($scream[0]);
     return $data;
 }
 /**
  * 保存基本信息操作
  *
  * @return json 返回操作后的JSON信息数据
  */
 public function doSaveProfile()
 {
     $res = true;
     // 保存用户表信息
     if (!empty($_POST['sex'])) {
         $save['sex'] = 1 == intval($_POST['sex']) ? 1 : 2;
         // $save['lang'] = t($_POST['lang']);
         $save['intro'] = t($_POST['intro']);
         /* # 检查用户简介是否超出字数限制 */
         if (get_str_length($save['intro']) > 150) {
             $this->ajaxReturn(null, '个人简介不得超过150字', 0);
         }
         // 添加地区信息
         $save['location'] = t($_POST['city_names']);
         $cityIds = t($_POST['city_ids']);
         $cityIds = explode(',', $cityIds);
         /* if (! $cityIds [0] || ! $cityIds [1] || ! $cityIds [2])
            $this->error ( '请选择完整地区' ); */
         isset($cityIds[0]) && ($save['province'] = intval($cityIds[0]));
         if ($_POST['input_city'] != '') {
             $save['input_city'] = t($_POST['input_city']);
             $save['city'] = 0;
             $save['area'] = 0;
         } else {
             isset($cityIds[1]) && ($save['city'] = intval($cityIds[1]));
             isset($cityIds[2]) && ($save['area'] = intval($cityIds[2]));
         }
         // 修改用户昵称
         $uname = t($_POST['uname']);
         $oldName = t($_POST['old_name']);
         $save['uname'] = filter_keyword($uname);
         $res = model('Register')->isValidName($uname, $oldName);
         if (!$res) {
             $error = model('Register')->getLastError();
             return $this->ajaxReturn(null, model('Register')->getLastError(), $res);
         }
         // 如果包含中文将中文翻译成拼音
         if (preg_match('/[\\x7f-\\xff]+/', $save['uname'])) {
             // 昵称和呢称拼音保存到搜索字段
             $save['search_key'] = $save['uname'] . ' ' . model('PinYin')->Pinyin($save['uname']);
         } else {
             $save['search_key'] = $save['uname'];
         }
         /* 用户首字母 */
         $save['first_letter'] = getShortPinyin($save['uname']);
         $res = model('User')->where("`uid`={$this->mid}")->save($save);
         $res && model('User')->cleanCache($this->mid);
         $user_feeds = model('Feed')->where('uid=' . $this->mid)->field('feed_id')->findAll();
         if ($user_feeds) {
             $feed_ids = getSubByKey($user_feeds, 'feed_id');
             model('Feed')->cleanCache($feed_ids, $this->mid);
         }
     }
     // 保存用户资料配置字段
     false !== $res && ($res = $this->_profile_model->saveUserProfile($this->mid, $_POST));
     // 保存用户标签信息
     $tagIds = t($_REQUEST['user_tags']);
     // 注册配置信息
     $this->_config = model('Xdata')->get('admin_Config:register');
     if (!empty($tagIds)) {
         $tagIds = explode(',', $tagIds);
         $rowId = intval($this->mid);
         if (!empty($rowId)) {
             $registerConfig = model('Xdata')->get('admin_Config:register');
             if (count($tagIds) > $registerConfig['tag_num']) {
                 return $this->ajaxReturn(null, '最多只能设置' . $registerConfig['tag_num'] . '个标签', false);
             }
             model('Tag')->setAppName('public')->setAppTable('user')->updateTagData($rowId, $tagIds);
         }
     } else {
         if (empty($tagIds) && isset($_REQUEST['user_tags'])) {
             return $this->ajaxReturn(null, '请至少选择一个标签', false);
         }
     }
     $result = $this->ajaxReturn(null, $this->_profile_model->getError(), $res);
     return $this->ajaxReturn(null, $this->_profile_model->getError(), $res);
 }
 /**
  * 执行发布帖子
  * @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);
     }
 }
&nbsp;&nbsp;发表在 <a href="<?php 
    echo $sourceInfo['weiba_url'];
    ?>
" target="_blank" class=""><?php 
    echo $sourceInfo['weiba_name'];
    ?>
</a><!--来自网站--></em></span>
  			<p class="txt-mt" onclick="core.weibo.clickRepost(this);" href="<?php 
    echo $sourceInfo['source_url'];
    ?>
"><a target="_blank" href="<?php 
    echo $sourceInfo['source_url'];
    ?>
">帖子&nbsp;|&nbsp;<?php 
    echo $sourceInfo['title'];
    ?>
</a>&nbsp;<?php 
    echo getShort($sourceInfo['content'], intval(($sourceInfo['pic_url_small'] ? 100 : 130) - get_str_length($sourceInfo['title'])), '...');
    ?>
</p>
  		</div>
    </dd>
    <?php 
} else {
    ?>
    <dd class="name">内容已被删除</dd>
    <?php 
}
?>
  </dl>
</div>
<span class="title-from-source hidden"><i class="ico-weiba"></i>发表在 <a href="<?php 
echo $sourceInfo['weiba_url'];
?>
" target="_blank"><?php 
echo $sourceInfo['weiba_name'];
?>
</a></span>
<div class="contents clearfix">
		<p><a target="_blank" href="<?php 
echo $sourceInfo['source_url'];
?>
">帖子&nbsp;|&nbsp;<?php 
echo $sourceInfo['title'];
?>
</a>&nbsp;<?php 
echo getShort($sourceInfo['content'], intval(110 - get_str_length($sourceInfo['title'])), '...');
?>
</a></p>
    <?php 
if (!empty($sourceInfo['pic_url'])) {
    ?>
    <div class="feed_img_lists">
    	<ul class="small">
        	<li style="width: 205px; height: auto;">
            	<a target="_blank" href="<?php 
    echo $sourceInfo['source_url'];
    ?>
"><img onload="/*仅标签上有效,待改进*/;var li=$(this).parents('li');if(li.height()>300){li.css('height','300px');li.find('.pic-btm').show();}" class="imgicon" src="<?php 
    echo $sourceInfo['pic_url_medium'];
    ?>
" style="cursor:pointer" /></a>		
 private function __checkContent($content, $mix = 5, $max = 5000)
 {
     $content_length = get_str_length($content, true);
     if (0 == $content_length) {
         $this->error('内容不能为空');
     } else {
         if ($content_length < $mix) {
             $this->error('内容不能少于' . $mix . '个字');
         } else {
             if ($content_length > $max) {
                 $this->error('内容不能超过' . $max . '个字');
             }
         }
     }
 }
Exemple #16
0
 public function doAdd()
 {
     if (0 == $this->config['createGroup']) {
         // 系统后台配置关闭创建
         $this->error('圈子创已经关闭');
     } else {
         if ($this->config['createMaxGroup'] <= $this->group->where('is_del=0 AND uid=' . $this->mid)->count()) {
             //系统后台配置要求,如果超过,则不可以创建
             $this->error('你不可以再创建了,超过系统规定数目');
         }
     }
     if (trim($_POST['dosubmit'])) {
         //检查验证码
         if (md5(strtoupper($_POST['verify'])) != $_SESSION['verify']) {
             $this->error('验证码错误');
         }
         $group['uid'] = $this->mid;
         $group['name'] = h(t($_POST['name']));
         $group['intro'] = h(t($_POST['intro']));
         $group['cid0'] = intval($_POST['cid0']);
         // intval($_POST['cid1']) > 0	&& $group['cid1']  = intval($_POST['cid1']);
         $cid1 = D('Category', 'group')->_digCateNew($_POST);
         intval($cid1) > 0 && ($group['cid1'] = intval($cid1));
         if (!$group['name']) {
             $this->error('圈子名称不能为空');
         } else {
             if (get_str_length($_POST['name']) > 30) {
                 $this->error('圈子名称不能超过30个字');
             }
         }
         if (D('Group', 'group')->where(array('name' => $group['name']))->find()) {
             $this->error('这个圈子名称已被占用');
         }
         if (get_str_length($_POST['intro']) > 200) {
             $this->error('圈子简介请不要超过200个字');
         }
         // 			if (!preg_replace("/[,\s]*/i", '' ,$_POST['tags']) || count(array_filter(explode(',', $_POST['tags']))) > 5) {
         // 				$this->error('标签不能为空或者不要超过五个');
         // 			}
         $group['type'] = $_POST['type'] == 'open' ? 'open' : 'close';
         $group['need_invite'] = intval($this->config[$group['type'] . '_invite']);
         //是否需要邀请
         $group['brower_level'] = $_POST['type'] == 'open' ? '-1' : '1';
         //浏览权限
         $group['openWeibo'] = intval($this->config['openWeibo']);
         $group['openUploadFile'] = intval($this->config['openUploadFile']);
         $group['openBlog'] = intval($this->config['openBlog']);
         $group['whoUploadFile'] = intval($this->config['whoUploadFile']);
         $group['whoDownloadFile'] = intval($this->config['whoDownloadFile']);
         $group['openAlbum'] = intval($this->config['openAlbum']);
         $group['whoCreateAlbum'] = intval($this->config['whoCreateAlbum']);
         $group['whoUploadPic'] = intval($this->config['whoUploadPic']);
         $group['anno'] = intval($_POST['anno']);
         $group['ctime'] = time();
         if (1 == $this->config['createAudit']) {
             $group['status'] = 0;
         }
         // 圈子LOGO
         $options['allow_exts'] = 'jpg,gif,png,jpeg,bmp';
         $options['max_size'] = 2 * 1024 * 1024;
         $options['attach_type'] = 'group_logo';
         $data['upload_type'] = 'image';
         $info = model('Attach')->upload($data, $options);
         if ($info['status']) {
             $group['logo'] = $info['info'][0]['save_path'] . $info['info'][0]['save_name'];
         } else {
             $group['logo'] = 'default.gif';
         }
         $gid = $this->group->add($group);
         if ($gid) {
             // 积分操作
             X('Credit')->setUserCredit($this->mid, 'add_group');
             // 把自己添加到成员里面
             $this->group->joingroup($this->mid, $gid, 1, $incMemberCount = true);
             // 添加圈子标签
             D('GroupTag')->setGroupTag($_POST['tags'], $gid);
             S('Cache_MyGroup_' . $this->mid, null);
             if (1 == $this->config['createAudit']) {
                 $this->assign('jumpUrl', U('group/SomeOne/index', array('uid' => $this->mid, 'type' => 'manage')));
                 $this->success('创建成功,请等待审核');
             } else {
                 $this->assign('jumpUrl', U('group/Invite/create', array('gid' => $gid, 'from' => 'create')));
                 $this->success('创建成功');
             }
         } else {
             $this->error('创建失败');
         }
     } else {
         $this->error('创建失败');
     }
 }
 function add()
 {
     $this->need_login();
     $this->group = D('Group', 'group');
     if (0 == $this->config['createGroup']) {
         // 系统后台配置关闭创建
         $this->error('微吧创建已关闭');
     } else {
         if ($this->config['createMaxGroup'] <= $this->group->where('is_del=0 AND uid=' . $this->mid)->count()) {
             // 系统后台配置要求,如果超过,则不可以创建
             $this->error('你不可以再创建了,超过系统规定数目');
         }
     }
     if (IS_POST) {
         // 检查验证码
         if (md5(strtoupper($_POST['verify'])) != $_SESSION['verify']) {
             $this->error('验证码错误');
         }
         $group['uid'] = $this->mid;
         $group['name'] = h(t($_POST['name']));
         $group['intro'] = h(t($_POST['intro']));
         $group['cid0'] = intval($_POST['cid0']);
         // intval($_POST['cid1']) > 0 && $group['cid1'] = intval($_POST['cid1']);
         $cid1 = D('Category', 'group')->_digCateNew($_POST);
         intval($cid1) > 0 && ($group['cid1'] = intval($cid1));
         if (!$group['name']) {
             $this->error('微吧名称不能为空');
         } else {
             if (get_str_length($_POST['name']) > 30) {
                 $this->error('微吧名称不能超过30个字');
             }
         }
         if (D('Group', 'group')->where(array('name' => $group['name']))->find()) {
             $this->error('这个微吧名称已被占用');
         }
         if (get_str_length($_POST['intro']) > 200) {
             $this->error('微吧简介请不要超过200个字');
         }
         // if (!preg_replace("/[,\s]*/i", '' ,$_POST['tags']) || count(array_filter(explode(',', $_POST['tags']))) > 5) {
         // $this->error('标签不能为空或者不要超过五个');
         // }
         $group['type'] = $_POST['type'] == 'open' ? 'open' : 'close';
         $group['need_invite'] = intval($this->config[$group['type'] . '_invite']);
         // 是否需要邀请
         $group['brower_level'] = $_POST['type'] == 'open' ? '-1' : '1';
         // 浏览权限
         $group['openWeibo'] = intval($this->config['openWeibo']);
         $group['openUploadFile'] = intval($this->config['openUploadFile']);
         $group['openBlog'] = intval($this->config['openBlog']);
         $group['whoUploadFile'] = intval($this->config['whoUploadFile']);
         $group['whoDownloadFile'] = intval($this->config['whoDownloadFile']);
         $group['openAlbum'] = intval($this->config['openAlbum']);
         $group['whoCreateAlbum'] = intval($this->config['whoCreateAlbum']);
         $group['whoUploadPic'] = intval($this->config['whoUploadPic']);
         $group['anno'] = intval($_POST['anno']);
         $group['ctime'] = time();
         if (1 == $this->config['createAudit']) {
             $group['status'] = 0;
         }
         // 微吧LOGO
         $group['logo'] = 'default.gif';
         if (!empty($_POST['image_ids'])) {
             $_POST['image_ids'] = implode(',', array_filter(explode('|', $_POST['image_ids'])));
             $attachInfo = model('Attach')->getAttachById($_POST['image_ids']);
             $group['logo'] = $attachInfo['save_path'] . $attachInfo['save_name'];
         }
         $gid = $this->group->add($group);
         if ($gid) {
             // 把自己添加到成员里面
             $res = $this->group->joingroup($this->mid, $gid, 1, $incMemberCount = true);
             // 积分操作
             X('Credit')->setUserCredit($this->mid, 'add_group');
             // 添加微吧标签
             D('GroupTag', 'group')->setGroupTag($_POST['tags'], $gid);
             S('Cache_MyGroup_' . $this->mid, null);
             model('UserData')->setKeyValue($this->mid, 'group_count', D('group_member')->where('level>0 and uid=' . $this->mid)->count());
             if (1 == $this->config['createAudit']) {
                 $this->success('创建成功,请等待审核', 3, U('w3g/Group/my'));
             } else {
                 $jumpUrl = U('w3g/Group/detail', array('gid' => $gid));
                 $this->success('创建成功', 3, $jumpUrl);
             }
         } else {
             $this->error('创建失败');
         }
     } else {
         $this->_getSearchKey();
         $attachConf = model('Xdata')->get('admin_Config:attachimage');
         $this->assign($attachConf);
         $this->assign('reTags', D('GroupTag', 'group')->getHotTags('recommend'));
         $this->setTitle("创建微吧");
         $this->display();
     }
 }
 public function doAddPoster()
 {
     $map['title'] = t(h($_POST['title']));
     $map['type'] = intval($_POST['type']);
     $map['pid'] = intval($_POST['pid']);
     $map['content'] = h($_POST['explain']);
     $map['contact'] = t($_POST['contact']);
     $map['uid'] = $this->mid;
     $map['cTime'] = time();
     if ($_POST['deadline']) {
         $map['deadline'] = $deadline = $this->_paramDate($_POST['deadline']);
         $deadline < time() && $this->error("结束时间不得小于发布时间");
     } else {
         $map['deadline'] = NULL;
     }
     //$address = explode(',',$_POST['areaid']);
     // $map['address_province'] = $address[0];
     //$map['address_city'] = $address[1];
     //$map['address_area'] = $address[2];
     //
     $map['area'] = h($_POST['area']);
     // 检查详细介绍
     if (get_str_length($map['content']) <= 0) {
         $this->error('详细介绍不能为空');
     }
     $map = $this->_extraField($map, $_POST);
     //得到上传的图片
     $option = array();
     if ($_FILES['cover']['size'] > 0) {
         $options['userId'] = $this->mid;
         $options['max_size'] = 2 * 1024 * 1024;
         //2MB
         $options['allow_exts'] = 'jpg,gif,png,jpeg,bmp';
         $options['attach_type'] = 'poster_cover';
         $data['upload_type'] = 'image';
         $cover = model('Attach')->upload($data, $options);
         if ($cover['status']) {
             $map['cover'] = $cover['info'][0]['save_path'] . $cover['info'][0]['save_name'];
             $map['attach_id'] = $cover['info'][0]['attach_id'];
         } else {
             $this->error($cover['info']);
         }
     }
     //$map['private'] = isset($_POST['friend'])?$_POST['friend']:0;
     $dao = D('Poster');
     $rs = $dao->add($map);
     if ($rs) {
         //发微薄
         //$_SESSION['new_poster'] = $cover['info'] ? $cover['info'][0]['attach_id'] : 1;
         //积分
         X('Credit')->setUserCredit($this->mid, 'add_poster');
         // $this->success("发布成功,继续发布!");
         // 分享并 @关注的人
         //autoShare 自动发布微博 user_to_share 自动弹分享框
         $this->redirect('poster/Index/posterDetail', array('id' => $rs, 'autoShare' => true, 'user_to_share' => false, 'auto_to_sendMessage' => true), 0, '发布成功');
     } else {
         $this->error("发布失败");
     }
 }