/** * * @Description 发报料 * @author Kin * @date 2013-5-8 上午09:41:55 * @see outerUpdateBase::create() */ public function create() { $content = addslashes(trim($this->input['content'])); /*********** 验证码 ***********/ if (defined('IS_VERIFYCODE') && IS_VERIFYCODE) { require_once ROOT_PATH . 'lib/class/verifycode.class.php'; $this->mVerifyCode = new verifyCode(); $code = trim($this->input['verify_code']); //验证码 $session_id = $this->input['session_id']; //标识 if (!$code) { $this->errorOutput(NO_VERIFYCODE); } if (!$session_id) { $this->errorOutput(NO_SESSIONID); } $check_result = $this->mVerifyCode->check_verify_code($code, $session_id); //验证验证码 if ($check_result != 'SUCCESS') { $data['error'] = $check_result; $this->addItem($data); $this->output(); } } /***************************/ if (!$content) { $this->errorOutput(NO_INPUT_CONTENT); } $count = count($_FILES['photos']['name']); //判断图片上传数目 $img_num = ''; $img_num = defined('UPLOAD_IMG_NUM') ? UPLOAD_IMG_NUM : 0; if ($img_num && $count && $count > $img_num) { $this->errorOutput('最多上传' . $img_num . '张图片'); } //报料设备标识 $device_token = trim($this->input['device_token']); //判断分类是否允许重复爆料 $sort_id = intval($this->input['sort_id']); if ($sort_id) { $sql = "SELECT repeat_switch FROM " . DB_PREFIX . "sort WHERE id = " . $sort_id; $res = $this->db->query_first($sql); $repeat_switch = $res['repeat_switch']; if ($repeat_switch && $device_token) { $sql = "SELECT id FROM " . DB_PREFIX . "content WHERE sort_id = " . $sort_id . " AND device_token = '" . $device_token . "'"; $res = $this->db->query_first($sql); if ($res['id']) { $this->errorOutput(CONTRIBUTE_LIMIT); } } } $status = defined('CONTRIBUTE_AUDIT') ? CONTRIBUTE_AUDIT : 1; if ($status != 1 && $status != 2) { $status = 1; } if ($this->input['event_time']) { $event_time = strtotime($this->input['event_time']); } $event_time = $event_time ? $event_time : TIMENOW; $data = array('title' => addslashes(trim($this->input['title'])), 'brief' => addslashes(trim($this->input['brief'])), 'appid' => $this->user['appid'], 'client' => $this->user['display_name'], 'audit' => $status, 'sort_id' => $sort_id, 'org_id' => $this->user['org_id'], 'is_m2o' => 0, 'user_id' => $this->input['user_id'] ? $this->input['user_id'] : $this->user['user_id'], 'user_name' => $this->input['user_name'] ? addslashes($this->input['user_name']) : addslashes($this->user['user_name']), 'create_time' => intval($this->input['create_time']) ? intval($this->input['create_time']) : TIMENOW, 'update_time' => intval($this->input['create_time']) ? intval($this->input['create_time']) : TIMENOW, 'ip' => $this->user['ip'], 'event_time' => $event_time, 'event_address' => trim($this->input['event_address']), 'event_suggest' => trim($this->input['event_suggest']), 'event_user_name' => trim($this->input['event_user_name']), 'event_user_tel' => trim($this->input['event_user_tel']), 'is_credits' => IS_EXTRA_CREDITS && $this->input['iscreditsrule'] ? 0 : -1, 'device_token' => $device_token); //过滤敏感词 /*if(defined('IS_BANWORD') && IS_BANWORD && $this->settings['App_banword']) { $banword_content = ''; $banword_content = $data['title'] . '|' . $data['brief'] . '|' . $content; include_once(ROOT_PATH . 'lib/class/banword.class.php'); $this->banword = new banword(); $banword = array(); $replace_content = $this->banword->replace($banword_content,'*'); $banword = $this->banword->exists($banword_content); if(!empty($banword)) { $colation = ''; if(defined('COLATION_TYPE')) { $colation = COLATION_TYPE; } else { $colation = 3; } if($colation == 1)//禁止入库 { $this->errorOutput(BANWORD); } else if($colation == 2) { $data['audit'] = 4;//标识敏感词 } else//默认替换敏感词 { $replace_content = $this->banword->replace($banword_content,'*'); $new_arr = explode('|', $replace_content); $data['title'] = $new_arr[0]; $data['brief'] = $new_arr[1]; $content = $new_arr[3]; $data['audit'] = 1;//待审核 } //记录敏感词 $banwords = array(); if(is_array($banword) && !empty($banword)) { foreach ($banword as $v) { $banwords[] = $v['banname']; } } $data['banwords'] = implode(',', $banwords); } }*/ $longitude = trim($this->input['longitude']); $latitude = trim($this->input['latitude']); if ($this->input['appid'] == '21') { $data['baidu_longitude'] = $longitude; $data['baidu_latitude'] = $latitude; } else { $data['GPS_longitude'] = $longitude; $data['GPS_latitude'] = $latitude; $data['longitude'] = $longitude; $data['latitude'] = $latitude; } //支持单独接收百度坐标 if ($this->input['baidu_latitude'] && $this->input['baidu_longitude']) { $data['baidu_latitude'] = $this->input['baidu_latitude']; $data['baidu_longitude'] = $this->input['baidu_longitude']; } //支持单独接受gps坐标 if ($this->input['GPS_longitude'] && $this->input['GPS_latitude']) { $data['GPS_latitude'] = $this->input['GPS_latitude']; $data['GPS_longitude'] = $this->input['GPS_longitude']; } //分类异常处理 $data['sort_id'] = $this->contribute->sortException($data['sort_id']); if (!$data['title']) { $data['title'] = hg_cutchars($content, 20); } if (!$data['brief']) { $data['brief'] = hg_cutchars($content, 100); } //如果百度坐标存在的话,就转换为GPS坐标也存起来 if ($data['baidu_longitude'] && $data['baidu_latitude'] && !$data['GPS_longitude'] && !$data['GPS_latitude']) { $gps = $this->contribute->FromBaiduToGpsXY($data['baidu_longitude'], $data['baidu_latitude']); $data['GPS_longitude'] = $gps['GPS_x']; $data['GPS_latitude'] = $gps['GPS_y']; $data['longitude'] = $gps['GPS_x']; $data['latitude'] = $gps['GPS_y']; } //如果GPS坐标存在的话,就转换为百度坐标也存起来 if (!$data['baidu_longitude'] && !$data['baidu_latitude'] && $data['GPS_longitude'] && $data['GPS_latitude']) { $baidu = $this->contribute->FromGpsToBaiduXY($data['GPS_longitude'], $data['GPS_latitude']); $data['baidu_longitude'] = $baidu['x']; $data['baidu_latitude'] = $baidu['y']; } if (!$data['title']) { $this->errorOutput(NO_INPUT_TITLE); } $userinfo = array(); if ($this->user['user_id'] && $this->settings['App_members'] && $this->input['new_member'] == 1) { $return = $this->contribute->get_newUserInfo_by_id($this->user['user_id']); if (empty($return)) { $this->errorOutput(NEW_MEMBER_ERROR); } $data['user_name'] = $return['member_name']; $data['new_member'] = 1; } elseif ($this->user['user_id'] && $this->settings['App_member']) { $return = $this->contribute->get_userinfo_by_id($this->user['user_id']); if (empty($return)) { $this->errorOutput(MEMBER_ERROR); } $data['user_name'] = $return['member_name']; } //添加爆料主表 $contributeId = $this->contribute->add_content($data); if (!intval($contributeId)) { $this->errorOutput(CONTRIBUTE_ERROR); } /***********************调用积分规则,给已审核评论增加积分START*****************/ if ($data['new_member'] && $this->input['iscreditsrule']) { if ($this->settings['App_members']) { include ROOT_PATH . 'lib/class/members.class.php'; $Members = new members(); $Members->Setoperation(APP_UNIQUEID); $field = ''; /***未审核增加积分**/ if (IS_CREDITS && $data['user_id']) { $credit_rules = $Members->get_credit_rules($data['user_id'], APP_UNIQUEID); } /***审核增加积分**/ if (IS_EXTRA_CREDITS && $data['audit'] == 2 && $data['user_id']) { $Members->Initoperation(); //初始化 $Members->Setoperation(APP_UNIQUEID, '', '', 'extra'); $credit_rules_extra = $Members->get_credit_rules($data['user_id'], APP_UNIQUEID); $field = 'is_credits=1'; } /**积分文案处理**/ $credit_copy = array(); if ($credit_rules['updatecredit']) { $credit_copy[] = $credit_rules; } if ($credit_rules_extra['updatecredit']) { $credit_copy[] = $credit_rules_extra; } $data['copywriting_credit'] = $Members->copywriting_credit($credit_copy); /**积分文案处理结束**/ /**更新获得积分字段**/ if ($field) { $this->db->query("UPDATE " . DB_PREFIX . "content SET " . $field . " WHERE id=" . $contributeId); } } } /***********************调用积分规则,给已审核评论增加积分END*****************/ //添加内容表 $body = array('id' => $contributeId, 'text' => $content); $this->contribute->add_contentbody($body); if ($this->input['user_name']) { $userinfo['con_id'] = intval($contributeId); $userinfo['tel'] = addslashes($this->input['tel']); $userinfo['email'] = addslashes($this->input['email']); $userinfo['addr'] = addslashes($this->input['addr']); } else { $userinfo['con_id'] = intval($contributeId); $userinfo['tel'] = $this->input['tel'] ? addslashes($this->input['tel']) : addslashes($return['mobile']); $userinfo['email'] = $this->input['email'] ? addslashes($this->input['email']) : addslashes($return['email']); $userinfo['addr'] = $this->input['addr'] ? addslashes($this->input['addr']) : addslashes($return['address']); } if (!empty($userinfo)) { $this->contribute->user_info($userinfo); } //单视频上传 if ($_FILES['videofile']) { $video = array(); //检测视频服务器 if (!$this->settings['App_mediaserver']) { $this->errorOutput(NO_VIDEO_APP); } if ($_FILES['videofile']['error'] > 0) { $this->errorOutput(VIDEO_FILE_ERROR); } //获取视频服务器上传配置 $videoConfig = $this->contribute->getVideoConfig(); if (!$videoConfig) { $this->errorOutput('获取允许上传的视频类型失败!'); } $filetype = strtolower(strrchr($_FILES['videofile']['name'], '.')); if (!in_array($filetype, $videoConfig['type'])) { $this->errorOutput('只允许上传' . $videoConfig['hit'] . '格式的视频'); } //上传视频服务器 $videodata = $this->contribute->uploadToVideoServer($_FILES, $data['title'], $data['brief']); if (!$videodata) { $this->errorOutput(VIDEO_SERVER_ERROR); } //有视频没有图片时,将视频截图上传作为索引图 if (!$indexpic) { $url = $videodata['img']['host'] . $videodata['img']['dir'] . $videodata['img']['filepath'] . $videodata['img']['filename']; $material = $this->contribute->localMaterial($url, $contributeId); //此处可能是音频,视频取截图作为索引图 if ($material) { $arr = array('content_id' => $contributeId, 'mtype' => $material['type'], 'original_id' => $material['id'], 'host' => $material['host'], 'dir' => $material['dir'], 'material_path' => $material['filepath'], 'pic_name' => $material['filename'], 'is_vod_pic' => 1); $indexpic = $this->contribute->upload($arr); $this->contribute->update_indexpic($indexpic, $contributeId); } } //视频入库 $arr = array('content_id' => $contributeId, 'mtype' => $videodata['type'], 'host' => $videodata['protocol'] . $videodata['host'], 'dir' => $videodata['dir'], 'vodid' => $videodata['id'], 'filename' => $videodata['file_name']); $this->contribute->upload($arr); } //多视频上传 if ($_FILES['videofiles']) { $video = array(); //检测视频服务器 if (!$this->settings['App_mediaserver']) { $this->errorOutput('视频服务器未安装!'); } //获取视频服务器上传配置 $videoConfig = $this->contribute->getVideoConfig(); if (!$videoConfig) { $this->errorOutput('获取允许上传的视频类型失败!'); } $count = count($_FILES['videofiles']['name']); for ($i = 0; $i <= $count; $i++) { if ($_FILES['videofiles']['name'][$i]) { if ($_FILES['videofiles']['error'][$i] > 0) { $this->errorOutput('视频异常'); } $filetype = ''; $filetype = strtolower(strrchr($_FILES['videofiles']['name'][$i], '.')); if (!in_array($filetype, $videoConfig['type'])) { $this->errorOutput('只允许上传' . $videoConfig['hit'] . '格式的视频'); } foreach ($_FILES['videofiles'] as $k => $v) { $video['videofiles'][$k] = $_FILES['videofiles'][$k][$i]; } $videos[] = $video; } } if (!empty($videos)) { //循环上传视频 foreach ($videos as $val) { $videodata = ''; //上传视频服务器 $video_file = array(); $video_file['videofile'] = $val['videofiles']; $videodata = $this->contribute->uploadToVideoServer($video_file, $data['title'], $data['brief']); if (!$videodata) { $this->errorOutput('视频服务器错误!'); } $info[] = $videodata; //有视频没有图片时,将视频截图上传作为索引图 if (!$indexpic) { $url = $videodata['img']['host'] . $videodata['img']['dir'] . $videodata['img']['filepath'] . $videodata['img']['filename']; $material = $this->contribute->localMaterial($url, $contributeId); if ($material) { $arr = array('content_id' => $contributeId, 'mtype' => $material['type'], 'original_id' => $material['id'], 'host' => $material['host'], 'dir' => $material['dir'], 'material_path' => $material['filepath'], 'pic_name' => $material['filename'], 'is_vod_pic' => 1); $indexpic = $this->contribute->upload($arr); $this->contribute->update_indexpic($indexpic, $contributeId); } } //视频入库 $arr = array('content_id' => $contributeId, 'mtype' => $videodata['type'], 'host' => $videodata['protocol'] . $videodata['host'], 'dir' => $videodata['dir'], 'vodid' => $videodata['id'], 'filename' => $videodata['file_name']); $this->contribute->upload($arr); } } } //图片上传 if ($_FILES['photos']) { $photos = array(); //检测图片服务器 if (!$this->settings['App_material']) { $this->errorOutput(NO_MATERIAL_APP); } //获取图片服务器上传配置 $PhotoConfig = $this->contribute->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(PICTURE_FILE_ERROR); } if (!in_array($_FILES['photos']['type'][$i], $PhotoConfig['type'])) { // $this->errorOutput('只允许上传'.$PhotoConfig['hint'].'格式的图片'); } if ($_FILES['photos']['size'][$i] > 100000000) { $this->errorOutput(PICTURE_OVER_SIZE); } foreach ($_FILES['photos'] as $k => $v) { $photo['Filedata'][$k] = $_FILES['photos'][$k][$i]; } $photos[] = $photo; } } if (!empty($photos)) { //循环插入图片服务器 foreach ($photos as $val) { $PhotoInfor = $this->contribute->uploadToPicServer($val, $contributeId); if (empty($PhotoInfor)) { $this->errorOutput(MATERIAL_SERVER_ERROR); } $temp = array('content_id' => $contributeId, 'mtype' => $PhotoInfor['type'], 'original_id' => $PhotoInfor['id'], 'host' => $PhotoInfor['host'], 'dir' => $PhotoInfor['dir'], 'material_path' => $PhotoInfor['filepath'], 'pic_name' => $PhotoInfor['filename'], 'imgwidth' => $PhotoInfor['imgwidth'], 'imgheight' => $PhotoInfor['imgheight']); //插入数据库 $PhotoId = $this->contribute->upload($temp); //默认第一张图片为索引图 if (!$indexpic) { $indexpic = $this->contribute->update_indexpic($PhotoId, $contributeId); } } } } else { if ($this->input['local_material']) { $file_array = explode(',', trim($this->input['local_material'])); if (!empty($file_array)) { //循环插入图片服务器 foreach ($file_array as $val) { $PhotoInfor = $this->contribute->localMaterial($val, $contributeId); if (empty($PhotoInfor)) { $this->errorOutput(MATERIAL_SERVER_ERROR); } $temp = array('content_id' => $contributeId, 'mtype' => $PhotoInfor['type'], 'original_id' => $PhotoInfor['id'], 'host' => $PhotoInfor['host'], 'dir' => $PhotoInfor['dir'], 'material_path' => $PhotoInfor['filepath'], 'pic_name' => $PhotoInfor['filename'], 'imgwidth' => $PhotoInfor['imgwidth'], 'imgheight' => $PhotoInfor['imgheight']); //插入数据库 $PhotoId = $this->contribute->upload($temp); //默认第一张图片为索引图 if (!$indexpic) { $indexpic = $this->contribute->update_indexpic($PhotoId, $contributeId); } } } } } $data['id'] = $contributeId; $data['copywriting'] = '爆料成功'; $this->addItem($data); $this->output(); }
public function add_message() { $content = trim($this->input['content']); if (!$content) { $this->errorOutput(NOCONTENT); } if (!get_magic_quotes_gpc()) { $content = addslashes($content); } //根据发布id查询信息 $cmid = intval($this->input['cmid']); if (!$cmid) { //非发布库内容评论要传入应用标识和模块标识 if (!$this->input['app_uniqueid'] || !$this->input['mod_uniqueid']) { $this->errorOutput(NOUNIQUEID); } } //评论设置 $set = $this->comment_set(); $contentid = intval($this->input['contentid']); if (!$contentid) { $this->errorOutput(NOCONTENTID); } $display = $set['display']; //是否审核显示 $max_word = $set['max_word']; //评论最大字数 $login = $set['is_login']; //是否登录评论 $colation = $set['colation']; //是否过滤 $is_open = $set['state']; //评论开启关闭 $rate = $set['rate']; //评论频率限制 $allow_reply = $set['allow_reply']; //回复设置 $verify_mode = $set['verify_mode']; //验证码 $is_credits = $set['is_credits']; //未审核获取积分 $is_credits_extra = $set['is_credits_extra']; //审核获取积分 $is_diy_credits = $set['is_diy_credits']; //自定义积分规则 $same_user_same_record = $set['same_user_same_record']; //评论功能开启/关闭 if (!$is_open) { $this->errorOutput(MESSAGECLOSED); } $fid = intval($this->input['fid']); if ($fid && !$allow_reply) { $this->errorOutput(REPLYCLOSED); } //登陆评论 if ($login) { if ($this->user['user_id'] < 1) { $this->errorOutput(NOTLOGIN); } } if ($max_word) { //评论长度判断 $len = ''; $len = strlen($content); if ($len > $max_word * 3) { $this->errorOutput(MAXNUM); } } //审核显示 $state = $display ? 0 : 1; if ($app_id = $this->input['app_id']) { $appconfig = $this->appconfig->detail($app_id); if ($appconfig['comment_audit'] == 0) { $state = 1; } else { $state = 0; } } //过滤敏感词 if ($colation && $this->settings['App_banword']) { include_once ROOT_PATH . 'lib/class/banword.class.php'; $this->banword = new banword(); $banword = $this->banword->exists($content); if ($banword) { $colation_state = ''; if ($colation == 1) { $this->errorOutput(BANWORD); } elseif ($colation == 2) { $colation_state = 3; } elseif ($colation == 3) { $content = $this->banword->replace($content, '*'); $colation_state = 0; //替换后状态为未审核 } //如果存在敏感词,敏感词的设置高于普通设置 if ($colation_state) { $state = $colation_state; } //记录敏感词 $banwords = array(); foreach ($banword as $v) { $banwords[] = $v['banname']; } $banwords = implode(',', $banwords); } } //验证码开启并且安装验证码 if ($this->settings['App_verifycode'] && $verify_mode) { if (!$this->input['not_need_verifycode']) { include_once ROOT_PATH . 'lib/class/verifycode.class.php'; $this->mVerifyCode = new verifycode(); $verifycode = trim($this->input['verify_code']); $session_id = trim($this->input['session_id']); if (!$verifycode || !$session_id) { $this->errorOutput(VERIFY); } $check_result = $this->mVerifyCode->check_verify_code($verifycode, $session_id); //验证验证码 if ($check_result != 'SUCCESS') { $data['error'] = $check_result; $this->addItem($data); $this->output(); } } } //兼容user_name传递用户昵称 if ($this->input['user_name'] && !$this->input['author']) { $this->input['author'] = $this->input['user_name']; } $data = array('title' => urldecode($this->input['title']), 'username' => $this->user['user_name'], 'author' => trim($this->input['author']), 'member_id' => $this->user['user_id'], 'content' => $content, 'pub_time' => TIMENOW, 'ip' => hg_getip(), 'state' => $state, 'contentid' => $contentid, 'content_title' => $this->input['content_title'], 'content_url' => $this->input['content_url'], 'cmid' => $cmid, 'app_uniqueid' => $this->input['app_uniqueid'], 'mod_uniqueid' => $this->input['mod_uniqueid'], 'site_id' => $this->input['site_id'], 'column_id' => $this->input['column_id'], 'appid' => $this->user['appid'], 'appname' => $this->user['display_name'], 'long' => $this->input['long'], 'lati' => $this->input['lati'], 'banword' => $banwords, 'fid' => $fid, 'member_type' => intval($this->input['member_type']), 'groupid' => intval($this->input['groupid']), 'baidu_longitude' => $this->input['baidu_longitude'], 'baidu_latitude' => $this->input['baidu_latitude'], 'address' => $this->input['address']); //获取ip的地域信息 if (function_exists('hg_getIpInfo')) { $data['ip_info'] = hg_getIpInfo($data['ip']); } //入库 $mes = new Message(); $res = $mes->add_message($data, $rate); if (!$res) { $this->errorOutput(RATE); } $res['pub_time'] = date('Y-m-d H:i:s', $res['pub_time']); /***********************调用积分规则,给已审核评论增加积分START*****************/ if ($this->input['iscreditsrule']) { include ROOT_PATH . 'lib/class/members.class.php'; $Members = new members(); if ($this->settings['App_members']) { if ($res['member_id'] && $same_user_same_record) { $res_total = $mes->return_count(" AND contentid=" . $res['contentid'] . " AND cmid = " . $res['cmid'] . " AND app_uniqueid = '" . $res['app_uniqueid'] . "' AND mod_uniqueid = '" . $res['mod_uniqueid'] . "' AND member_id=" . $res['member_id'], $tableName); } if ($res_total['total'] - 1 < $same_user_same_record || empty($same_user_same_record)) { $Members->Initoperation(); //初始化 $Members->Setoperation(APP_UNIQUEID); /***未审核增加积分**/ if ($is_credits && $this->user['user_id']) { $credit_rules = $Members->get_credit_rules($this->user['user_id'], $data['app_uniqueid'], $data['mod_uniqueid'], $data['column_id'], $data['contentid']); } /***审核增加积分**/ if ($is_credits_extra && $res['state'] == 1 && $this->user['user_id']) { $Members->Initoperation(); //初始化 $Members->Setoperation(APP_UNIQUEID, '', '', 'extra'); $credit_rules_extra = $Members->get_credit_rules($this->user['user_id'], $data['app_uniqueid'], $data['mod_uniqueid'], $data['column_id'], $data['contentid']); $field = 'is_credits=0'; //已经增加积分 } elseif (empty($is_credits_extra)) { $field = 'is_credits=-1'; //禁止增加积分,因为未开启审核增加积分,所以即使审核也不增加 } } else { $field = 'is_credits=-1'; //禁止增加积分,此会员此条记录评论超过限制次数 } } /**积分文案处理**/ $credit_copy = array(); if ($credit_rules['updatecredit']) { $credit_copy[] = $credit_rules; } if ($credit_rules_extra['updatecredit']) { $credit_copy[] = $credit_rules_extra; } $res['copywriting_credit'] = $Members->copywriting_credit($credit_copy); /**积分文案处理结束**/ } else { $field = 'is_credits=-1'; //禁止增加积分,非新会员 } /**更新获得积分字段**/ if ($field) { $this->db->query("UPDATE " . DB_PREFIX . "{$res['tableame']} SET " . $field . " WHERE id=" . $res['id']); } /***********************调用积分规则,给已审核评论增加积分END*****************/ //已审核状态 if ($res['state'] == 1) { /***********************即时更新内容评论计数****************************/ if ($this->settings['App_' . $data['app_uniqueid']]) { $path['host'] = $this->settings['App_' . $data['app_uniqueid']]['host']; $path['dir'] = $this->settings['App_' . $data['app_uniqueid']]['dir'] . 'admin/'; if ($path) { $host = $path['host']; $dir = $path['dir']; $filename = $data['app_uniqueid']; if ($filename == 'livmedia') { $filename = 'vod'; } else { if ($filename == 'cheapbuy') { $filename = 'product'; } } include_once ROOT_PATH . 'lib/class/curl.class.php'; $curl = new curl($host, $dir); $curl->setSubmitType('post'); $curl->initPostData(); $curl->addRequestData('a', 'update_comment_count'); $curl->addRequestData('id', $data['contentid']); $curl->addRequestData('type', 'audit'); $curl->request($filename . '_update.php'); } } /***********************即时更新内容评论计数****************************/ /***********************更新会员我的评论计数****************************/ if ($this->settings['App_members']) { $path['host'] = $this->settings['App_members']['host']; $path['dir'] = $this->settings['App_members']['dir']; if ($path) { include_once ROOT_PATH . 'lib/class/curl.class.php'; $curl = new curl($path['host'], $path['dir']); $curl->setSubmitType('post'); $curl->initPostData(); $curl->addRequestData('a', 'create'); $curl->addRequestData('mark', 'mymessage'); $curl->addRequestData('totalsum', 1); $curl->addRequestData('summath', 1); $curl->addRequestData('access_token', $this->user['token']); $curl->request('member_my_update.php'); } } /***********************更新会员我的评论计数****************************/ } //统计app下面的评论计数 if ($data['appid']) { $sql = "SELECT appid FROM " . DB_PREFIX . "message_appinfo WHERE appid = " . $data['appid']; if ($this->db->query_first($sql)) { $sql = "UPDATE " . DB_PREFIX . "message_appinfo SET appname='" . $data['appname'] . "',comment_num = comment_num+1 WHERE appid=" . $data['appid']; } else { $sql = "INSERT INTO " . DB_PREFIX . "message_appinfo SET appid=" . $data['appid'] . ",appname='" . $data['appname'] . "',comment_num=comment_num+1"; } $this->db->query($sql); } $res['copywriting'] = '评论成功'; $this->addItem($res); $this->output(); }
public function planAudit() { $start_time = intval($this->input['start_time']); $end_time = intval($this->input['end_time']); $status = intval($this->input['status']); $state = ''; if ($start_time && $end_time && $status) { switch ($status) { case 1: $state = 0; break; case 2: $state = 1; break; case 3: $state = 2; break; } $sql = 'SELECT update_time FROM ' . DB_PREFIX . 'comment_index WHERE update_time>' . $start_time . ' AND update_time<' . $end_time; $q = $this->db->query($sql); $year = array(); while ($r = $this->db->fetch_array($q)) { $year[date('Y', $r['update_time'])] = 1; } //只有审核,0->1更新,0->2不做处理 if ($state == 1) { $type = 'audit'; } if (!empty($year)) { foreach ($year as $k => $v) { $tableName = 'message'; if ($k != '2013') { $tableName = 'message_' . $k; } if ($state == 1) { /*******************调用积分规则,给已审核评论增加积分START*****************/ if ($this->settings['App_members']) { include ROOT_PATH . 'lib/class/members.class.php'; $Members = new members(); $sql = 'SELECT id,is_credits,member_id,app_uniqueid,mod_uniqueid,column_id,contentid FROM ' . DB_PREFIX . $tableName . ' WHERE member_type=1 AND is_credits>0 AND state = 0 AND pub_time>' . $start_time . ' AND pub_time<' . $end_time; $q = $this->db->query($sql); $credit_rules_uid = array(); //需增加积分的会员id while ($r = $this->db->fetch_array($q)) { if ($r['member_id']) { $credit_rules_uid[$r['id']] = $r; } } /***审核增加积分**/ if ($credit_rules_uid && is_array($credit_rules_uid)) { foreach ($credit_rules_uid as $key => $val) { $Members->Initoperation(); //初始化 $Members->Setoperation(APP_UNIQUEID, '', '', 'extra'); $Members->get_credit_rules($val['member_id'], $v['app_uniqueid'], $v['mod_uniqueid'], $v['column_id'], $v['contentid']); $this->db->query("UPDATE " . DB_PREFIX . "{$tableName} SET is_credits=0 WHERE id=" . $key); //更新获得积分字段 } } } /********************调用积分规则,给已审核评论增加积分END*****************/ } //更新计数条件 $con = ' AND pub_time>' . $start_time . ' AND pub_time<' . $end_time . " AND state = 0"; $sql = 'UPDATE ' . DB_PREFIX . $tableName . ' SET state = ' . $state . ' WHERE 1 ' . $con; $this->db->query($sql); if ($type) { $this->update_comment_count('', $type, $tableName, $con); } } } } $this->addItem(true); $this->output(); }