/** * * @Description * @author Kin * @date 2013-6-6 下午03:50:51 * @see outerUpdateBase::create() */ public function create() { //检测社区黑名单 $this->check_black(); if (!intval($this->input['sort_id'])) { $this->errorOutput(NO_SORT_ID); } //限制发帖时间 if ($this->user['user_id']) { $condition = ' AND member_id=' . $this->user['user_id'] . ''; $latest_info = $this->sh->getSeekhelplist($condition, ' ORDER BY order_id DESC', 0, 1, $this->input['sort_id']); if ($latest_info[0]) { if ($latest_info[0]['create_time'] + LIMIT_POSTING_TIME >= TIMENOW) { $this->errorOutput(POSTING_FAST); } if ($latest_info[0]['content'] == trim($this->input['content'])) { $this->errorOutput(CONTENT_EXIST); } } } $data = array('title' => trim($this->input['title']), 'status' => 0, 'appid' => $this->user['appid'], 'appname' => $this->user['display_name'], 'baidu_longitude' => trim($this->input['baidu_longitude']), 'baidu_latitude' => trim($this->input['baidu_latitude']), 'GPS_longitude' => trim($this->input['GPS_longitude']), 'GPS_latitude' => trim($this->input['GPS_latitude']), 'location' => trim($this->input['location']), 'sort_id' => intval($this->input['sort_id']), 'section_id' => intval($this->input['section_id']), 'account_id' => intval($this->input['account_id']), 'org_id' => $this->user['org_id'], 'member_id' => $this->user['user_id'], 'tel' => trim($this->input['tel']), 'create_time' => TIMENOW, 'comment_latest_time' => TIMENOW, 'ip' => $this->user['ip']); $content = trim($this->input['content']); if (empty($content)) { $this->errorOutput(NO_CONTENT); } if ($data['section_id']) { $sectionInfo = $this->section->detail($data['section_id']); if (!$sectionInfo) { $this->errorOutput(NO_SECTION); } } //会员黑名单验证 if ($data['member_id']) { include_once ROOT_PATH . 'lib/class/members.class.php'; $obj = new members(); $res = $obj->check_blacklist($data['member_id']); if ($res[$data['member_id']]['isblack']) { //$this->addItem_withkey('error', "您的评论被屏蔽,请联系管理员!"); //$this->addItem_withkey('msg', "您的评论被屏蔽,请联系管理员!"); //$this->output(); $this->errorOutput(IS_BLACK_MEMBER); } } //分类异常处理 $data['sort_id'] = $this->sh->sortException($data['sort_id']); if (defined('SEEKHELP_STATUS') && SEEKHELP_STATUS && !$_FILES['photos'] && !$_FILES['video']) { $data['status'] = 1; } if (defined('SEEKHELP_MATERIAL_STATUS') && SEEKHELP_MATERIAL_STATUS && ($_FILES['photos'] || $_FILES['video'])) { $data['status'] = 1; } if ($this->input['app_id']) { $app_id = $this->input['app_id']; $appconfig = $this->appconfig->detail($app_id); if ($appconfig['seekhelp_audit'] == 0) { $data['status'] = 1; } else { $data['status'] = 0; } } //屏蔽字验证 if ($this->settings['App_banword'] && defined('IS_BANWORD') && IS_BANWORD) { require_once ROOT_PATH . 'lib/class/banword.class.php'; $this->banword = new banword(); $str = $data['title'] . $content; $banword = $this->banword->exists($str); if ($banword && is_array($banword)) { $banword_title = ''; $banword_content = ''; foreach ($banword as $key => $val) { if (strstr($data['title'], $val['banname'])) { $banword_title .= $val['banname'] . ','; } if (strstr($content, $val['banname'])) { $banword_content .= $val['banname'] . ','; } } $banword_title = $banword_title ? rtrim($banword_title, ',') : ''; $banword_content = $banword_content ? rtrim($banword_content, ',') : ''; if ($banword_title || $banword_content) { $banwords = array('title' => $banword_title, 'content' => $banword_content); $data['status'] = 0; //含有屏蔽字直接未审 $data['banword'] = serialize($banwords); } } } //如果百度坐标存在的话,就转换为GPS坐标也存起来 if ($data['baidu_longitude'] && $data['baidu_latitude'] && !$data['GPS_longitude'] && !$data['GPS_latitude']) { $gps = $this->sh->FromBaiduToGpsXY($data['baidu_longitude'], $data['baidu_latitude']); $data['GPS_longitude'] = $gps['GPS_x']; $data['GPS_latitude'] = $gps['GPS_y']; } //如果GPS坐标存在的话,就转换为百度坐标也存起来 if (!$data['baidu_longitude'] && !$data['baidu_latitude'] && $data['GPS_longitude'] && $data['GPS_latitude']) { $baidu = $this->sh->FromGpsToBaiduXY($data['GPS_longitude'], $data['GPS_latitude']); $data['baidu_longitude'] = $baidu['x']; $data['baidu_latitude'] = $baidu['y']; } if (!$data['title']) { $data['title'] = hg_cutchars($content, 100); } if (!$data['title']) { $this->errorOutput('请输入内容'); } //初始化的数据 $is_img = 0; $is_video = 0; $is_reply = 0; //添加求助信息 $seekhelpInfor = $this->sh->add_seekhelp($data); if (!$seekhelpInfor['id']) { $this->errorOutput('数据库插入失败'); } $id = $seekhelpInfor['id']; //添加描述 if ($content) { $contentInfor = $this->sh->add_content($content, $id); if (!$contentInfor) { $this->errorOutput('数据库插入失败'); } $data['content'] = $contentInfor; } //图片上传 if ($_FILES['photos']) { $photos = array(); //检测图片服务器 if (!$this->settings['App_material']) { $this->errorOutput('图片服务器未安装!'); } //获取图片服务器上传配置 // $PhotoConfig = $this->sh->getPhotoConfig(); // if (!$PhotoConfig) // { // $this->errorOutput('获取允许上传的图片类型失败!'); // } $count = count($_FILES['photos']['name']); for ($i = 0; $i < $count; $i++) { if ($_FILES['photos']['name'][$i]) { if ($_FILES['photos']['error'][$i] > 0) { $this->errorOutput('图片上传异常'); } /* if (!in_array($_FILES['photos']['type'][$i], $PhotoConfig['type'])) { $this->errorOutput('只允许上传'.$PhotoConfig['hit'].'格式的图片'); } */ if ($_FILES['photos']['size'][$i] > 100000000) { $this->errorOutput('只允许上传100M以下的图片!'); } foreach ($_FILES['photos'] as $k => $v) { $photo['Filedata'][$k] = $_FILES['photos'][$k][$i]; } $photos[] = $photo; } } if (!empty($photos)) { //循环插入图片服务器 foreach ($photos as $val) { $PhotoInfor = $this->sh->uploadToPicServer($val, $id); if (empty($PhotoInfor)) { $this->errorOutput('图片服务器错误!'); } $temp = array('cid' => $id, 'type' => $PhotoInfor['type'], 'original_id' => $PhotoInfor['id'], 'host' => $PhotoInfor['host'], 'dir' => $PhotoInfor['dir'], 'filepath' => $PhotoInfor['filepath'], 'filename' => $PhotoInfor['filename'], 'imgwidth' => $PhotoInfor['imgwidth'], 'imgheight' => $PhotoInfor['imgheight'], 'mark' => 'img'); //插入数据库 $ret_pic = $this->sh->upload_pic($temp); if ($ret_pic) { $data['pic'][] = $ret_pic; } else { $this->errorOutput('图片入库失败'); } } $is_img = 1; } } //视频上传 if ($_FILES['video']) { $videos = array(); //检测视频服务器 if (!$this->settings['App_mediaserver']) { $this->errorOutput('视频服务器未安装!'); } //获取视频服务器上传配置 $videoConfig = $this->sh->getVideoConfig(); if (!$videoConfig) { $this->errorOutput('获取允许上传的视频类型失败!'); } $count = count($_FILES['video']['name']); for ($i = 0; $i < $count; $i++) { if ($_FILES['video']['name'][$i]) { if ($_FILES['video']['error'][$i] > 0) { $this->errorOutput('视频上传异常'); } /* $filetype = strtolower(strrchr($_FILES['video']['name'][$i], '.')); if (!in_array($filetype, $videoConfig['type'])) { $this->errorOutput('只允许上传'.$videoConfig['hit'].'格式的视频'); } */ foreach ($_FILES['video'] as $k => $v) { $video['videofile'][$k] = $_FILES['video'][$k][$i]; } $videos[] = $video; } } if (!empty($videos)) { foreach ($videos as $videoInfor) { //上传视频服务器 $videodata = $this->sh->uploadToVideoServer($videoInfor, $data['title'], '', 2); if (!$videodata) { $this->errorOutput('视频服务器错误!'); } //视频入库 $arr = array('cid' => $id, 'type' => $videodata['type'], 'host' => $videodata['protocol'] . $videodata['host'], 'dir' => $videodata['dir'], 'original_id' => $videodata['id'], 'filename' => $videodata['file_name'], 'mark' => 'video'); $ret_vod = $this->sh->upload_vod($arr); if ($ret_vod) { $data['video'][] = $ret_vod; } else { $this->errorOutput('视频入库失败'); } } $is_video = 1; } } //更新主表回复,图片,视频纪录 $status = array('is_reply' => 0, 'is_img' => $is_img, 'is_video' => $is_video); $ret_status = $this->sh->update_status($status, $id); if ($ret_status) { $data['is_reply'] = $ret_status['is_reply']; $data['is_img'] = $ret_status['is_img']; $data['is_video'] = $ret_status['is_video']; } if ($data['status']) { $this->SetTimeline($id); //更新会员统计 $this->updateMemberCount($data['member_id'], 'create'); } $data['id'] = $id; $this->addItem($data); $this->output(); }
/** * 创建评论 * cid * @see outerUpdateBase::create() */ public function create() { if ($this->input['app_id']) { //检查社区黑名单 $blackInfo = $this->blacklist->check_blackByappId($this->input['app_id']); if ($blackInfo && $blackInfo['deadline'] == -1) { $this->errorOutput(SEEKHELP_IS_BLACK); } } $data = array('cid' => intval($this->input['cid']), 'member_id' => intval($this->user['user_id']), 'comment_type' => trim($this->input['comment_type']), 'comment_fid' => intval($this->input['comment_fid']), 'location' => trim($this->input['location']), 'status' => 0, 'content' => $this->input['content'], 'create_time' => TIMENOW, 'ip' => $this->user['ip']); //comment_type默认值 此处兼容老社区 if (!$this->input['comment_type']) { $data['comment_type'] = 'main'; } if (defined('SEEKHELP_COMMENT_STATUS') && SEEKHELP_COMMENT_STATUS) { $data['status'] = 1; } if ($this->input['app_id'] && $data['comment_type'] == 'main') { $app_id = $this->input['app_id']; $appconfig = $this->appconfig->detail($app_id); if ($appconfig['comment_audit'] == 0) { $data['status'] = 1; } else { $data['status'] = 0; } } if (!$data['cid'] || !$data['member_id'] || !$data['content']) { $this->errorOutput(NOID); } // if(!$data['comment_type']) // { // $this->errorOutput(NO_COMMENT_TYPE); // } //会员黑名单验证 include_once ROOT_PATH . 'lib/class/members.class.php'; $obj = new members(); $res = $obj->check_blacklist($data['member_id']); if ($res[$data['member_id']]['isblack']) { //$this->addItem_withkey('error', "您的评论被屏蔽,请联系管理员!"); //$this->addItem_withkey('msg', "您的评论被屏蔽,请联系管理员!"); //$this->output(); $this->errorOutput(IS_BLACK_MEMBER); } $sql = "SELECT * FROM " . DB_PREFIX . "seekhelp WHERE id = " . $data['cid']; $seekhelp = $this->db->query_first($sql); $sort_id = $seekhelp['sort_id']; $data['sort_id'] = $sort_id; //屏蔽字验证 if ($this->settings['App_banword']) { require_once ROOT_PATH . 'lib/class/banword.class.php'; $this->banword = new banword(); $str = $data['content']; $banword = $this->banword->exists($str); if ($banword && is_array($banword)) { $banword_content = ''; foreach ($banword as $key => $val) { $banword_content .= $val['banname'] . ','; } $data['banword'] = $banword_content ? rtrim($banword_content, ',') : ''; $data['status'] = 0; } } $data['content'] = urlencode($data['content']); $ret = $this->comment->create($data); if ($ret) { if ($data['status']) { if ($data['comment_type'] == 'vice') { $sql = "SELECT * FROM " . DB_PREFIX . "comment WHERE id = " . $data['comment_fid']; $comment = $this->db->query_first($sql); $this->SetCommentNum($data['comment_type'], $ret); $this->SetTimeline($ret['id'], $comment, 'comment'); $this->SetMemberInfo($comment); } else { $this->SetCommentNum($data['comment_type'], $ret); $this->SetTimeline($ret['id'], $seekhelp, 'seekhelp'); $this->SetMemberInfo($seekhelp); } //更新会员统计 if ($data['comment_type'] == 'main') { $this->updateMemberCount($data['member_id'], 'create'); } } } if ($this->settings['App_members']) { $memberInfo = $this->members->get_newUserInfo_by_ids($data['member_id']); } $ret['member_avatar'] = $memberInfo[0]['avatar']; $ret['member_name'] = IS_HIDE_MOBILE ? hg_hide_mobile($memberInfo[0]['nick_name']) : $memberInfo[0]['nick_name']; $ret['content'] = seekhelp_clean_value(stripcslashes(urldecode($ret['content']))); $this->addItem($ret); $this->output(); }