Beispiel #1
0
 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();
 }
Beispiel #2
0
 /**
  * 投票接口
  * @param $id int 投票ID
  * @param $option_id string 选项id (1,2,3)
  * @param $verify_code string 验证码
  * @param $other_title string 用户提交过来的其他选项
  * 
  */
 public function vote_add()
 {
     $id = intval($this->input['id']);
     $option_id = trim($this->input['option_id']);
     $verify_code = trim($this->input['verify_code']);
     $other_title = trim($this->input['other_title']);
     $ip = hg_getip();
     $appid = intval($this->user['appid']);
     $appname = $this->user['display_name'];
     $user_id = intval($this->user['user_id']);
     $verifycode = trim($this->input['verify_code']);
     $session_id = trim($this->input['session_id']);
     $device_token = trim($this->input['device_token']);
     $uuid = $this->input['uuid'];
     if (!$id) {
         $this->errorOutput('NO_ID');
     }
     if (!$option_id) {
         $this->errorOutput('NO_OPTION_ID');
     }
     //取投票数据
     $vote = $this->mVote->get_vote_by_id($id);
     $vote = $vote[0];
     if (empty($vote)) {
         $this->errorOutput('该投票不存在或删除');
     }
     //审核状态
     if (!$vote['status']) {
         $this->errorOutput('该投票未审核');
     }
     //开启状态
     if (!$vote['is_open']) {
         $this->errorOutput('该投票已关闭');
     }
     //有效期验证
     if ($vote['end_time'] && strtotime($vote['end_time']) < TIMENOW) {
         $this->errorOutput('该投票已过期');
     }
     //有效期验证
     if ($vote['start_time'] && strtotime($vote['start_time']) > TIMENOW) {
         $this->errorOutput('该投票未开始');
     }
     //选项数目
     $option_ids = explode(',', $option_id);
     $option_count = count(array_filter($option_ids));
     //单选
     if ($vote['option_type'] == 1 && $option_count != 1) {
         $this->errorOutput('只能选择一个选项');
     }
     //多选
     if ($vote['option_type'] == 2) {
         if ($option_count > $vote['max_option'] && $vote['max_option']) {
             $this->errorOutput('投票选项已超过' . $vote['max_option'] . '个');
         }
         if ($option_count < $vote['min_option']) {
             $this->errorOutput('投票选项不能少于' . $vote['min_option'] . '个');
         }
     }
     //验证码
     if ($this->settings['App_verifycode'] && $vote['is_verify_code']) {
         $is_dipartite = $vote['is_verify_dipartite'] ? $vote['is_verify_dipartite'] : 0;
         //验证码是否区分大小写
         $check_result = $this->mVerifyCode->check_verify_code($verifycode, $session_id, $is_dipartite);
         //验证验证码
         if ($check_result != 'SUCCESS') {
             $this->errorOutput($check_result);
         }
     }
     //用户登陆
     if ($vote['is_user_login'] && $user_id <= 0) {
         $this->errorOutput('会员未登录');
     }
     if (defined("RESERVED_IP_LIMIT") && RESERVED_IP_LIMIT) {
         if (is_reserverd_ip($ip)) {
             $this->errorOutput(RESERVED_IP_NOT_ALLOWED);
         }
     }
     //同一用户投票时间限制
     if ($vote['is_userid']) {
         $user_toff = $vote['userid_limit_time'] * 3600;
         $user_time = TIMENOW - $user_toff;
         $sql = "SELECT  count(vote_question_id) as total  FROM " . DB_PREFIX . "question_person ";
         $sql .= " WHERE vote_question_id = " . $id . " AND user_id = " . $user_id;
         if ($vote['userid_limit_time']) {
             $sql .= " AND create_time > " . $user_time;
         }
         $user_vote = $this->db->query_first($sql);
         if ($user_vote['total'] >= $vote['userid_limit_num']) {
             $error5 = '同一用户在' . $vote['userid_limit_time'] . '小时内最多投' . $vote['userid_limit_num'] . '票!';
             $error6 = '同一用户最多投' . $vote['userid_limit_num'] . '票!';
             $data['error'] = $vote['userid_limit_time'] ? $error5 : $error6;
             $this->errorOutput($data['error']);
         }
     }
     if (!$device_token && $vote['is_device'] && defined('NO_DEVICE_VOTE') && NO_DEVICE_VOTE) {
         $error = defined('NO_DEVICE_TIPS') && NO_DEVICE_TIPS ? NO_DEVICE_TIPS : '您的客户端版本太低,请先升级';
         $this->errorOutput($error);
     }
     if ($device_token && $vote['is_device']) {
         if ($this->settings['App_mobile']) {
             require_once ROOT_DIR . 'lib/class/curl.class.php';
             $this->curl = new curl($this->settings['App_mobile']['host'], $this->settings['App_mobile']['dir']);
             $this->curl->setReturnFormat('json');
             $this->curl->initPostData();
             $this->curl->addRequestData('device_token', $device_token);
             $this->curl->addRequestData('uuid', $uuid);
             $ret = $this->curl->request('mobile_device.php');
             if (!$ret[0]) {
                 $this->errorOutput(ERROR_DEVICE_TOKEN);
             }
         }
         $device_user_toff = $vote['device_limit_time'] * 3600;
         $device_user_time = TIMENOW - $device_user_toff;
         $sql = "SELECT count(vote_question_id) as total FROM " . DB_PREFIX . "question_person WHERE 1 ";
         $sql .= " AND  vote_question_id = " . $id . " AND device_token = '" . md5($device_token) . "'";
         if ($vote['device_limit_time']) {
             $sql .= " AND create_time > " . $device_user_time;
         }
         $device_vote = $this->db->query_first($sql);
         if ($device_vote['total'] >= $vote['device_limit_num']) {
             $error1 = '同一设备在' . $vote['device_limit_time'] . '小时内最多投' . $vote['device_limit_num'] . '票!';
             $error2 = '同一设备最多投' . $vote['device_limit_num'] . '票!';
             $data['error'] = $vote['device_limit_time'] ? $error1 : $error2;
             $this->errorOutput($data['error']);
         }
     }
     //ip投票时间限制
     if ($vote['is_ip'] && (!$device_token || !$vote['is_device'])) {
         $ip_toff = $vote['ip_limit_time'] * 3600;
         $ip_time = TIMENOW - $ip_toff;
         $sql = "SELECT count(vote_question_id) as iptotal FROM " . DB_PREFIX . "question_person WHERE 1 ";
         $sql .= " AND vote_question_id = " . $id . " AND ip = '" . $ip . "'";
         if ($vote['ip_limit_time']) {
             $sql .= " AND create_time > " . $ip_time;
         }
         $ip_question_preson = $this->db->query_first($sql);
         if ($ip_question_preson['iptotal'] >= $vote['ip_limit_num']) {
             $error3 = '同一IP在' . $vote['ip_limit_time'] . '小时内最多投' . $vote['ip_limit_num'] . '票!';
             $error4 = '同一IP多投' . $vote['ip_limit_num'] . '票!';
             $data['error'] = $vote['ip_limit_time'] ? $error3 : $error4;
             $this->errorOutput($data['error']);
         }
     }
     //记录数据
     foreach ($option_ids as $k => $_option_id) {
         //更新选项 投票数
         $sql = "UPDATE " . DB_PREFIX . "question_option SET single_total=(single_total+1) WHERE id = " . $_option_id;
         $this->db->query($sql);
         //记录选项 投票
         $question_record_data = array('question_option_id' => $_option_id, 'vote_question_id' => $id, 'ip' => $ip, 'num' => 1, 'start_time' => TIMENOW, 'appid' => $appid, 'appname' => $appname);
         $this->mVote->create_data('question_record', $question_record_data);
     }
     //更新主表 total 字段
     $sql = "UPDATE " . DB_PREFIX . "vote_question SET total = (total+" . $option_count . ") WHERE id = " . $id;
     $this->db->query($sql);
     //记录其他 投票
     if (isset($this->input['other_title']) && $other_title) {
         $question_option_data = array('vote_question_id' => $id, 'other_option' => $other_title, 'user_id' => $user_id, 'create_time' => TIMENOW);
         $ret_other_data = $this->mVote->create_data('question_other_option', $question_option_data, true);
         $other_option_id = $ret_other_data['id'];
         if ($other_option_id) {
             //记录选项 投票
             $question_record_data = array('question_option_id' => $other_option_id, 'vote_question_id' => $id, 'ip' => $ip, 'num' => 1, 'start_time' => TIMENOW, 'appid' => $appid, 'appname' => $appname);
             $this->mVote->create_data('question_record', $question_record_data);
             //更新主表 total 字段
             $sql = "UPDATE " . DB_PREFIX . "vote_question SET total = (total+1) WHERE id = " . $id;
             $this->db->query($sql);
         }
     }
     //记录参与人数 所投选项
     $question_person_info_data = array('vote_question_id' => $id, 'user_id' => $user_id, 'option_ids' => $option_id);
     $question_person_info = $this->mVote->create_data('question_person_info', $question_person_info_data, true);
     $pid = $question_person_info['id'];
     $user_name = $this->user['user_name'];
     //记录参与人数
     $question_person_data = array('vote_question_id' => $id, 'user_id' => $user_id, 'user_name' => $user_name, 'app_id' => $appid, 'app_name' => $appname, 'create_time' => TIMENOW, 'ip' => $ip, 'pid' => $pid, 'device_token' => md5($device_token), 'uuid' => $uuid, 'agent' => $_SERVER['HTTP_USER_AGENT'], 'referer' => $_SERVER['HTTP_REFERER']);
     $this->mVote->create_data('question_person', $question_person_data);
     //统计参与人数
     $sql = "SELECT vote_question_id FROM " . DB_PREFIX . "question_count WHERE vote_question_id=" . $id . " AND app_id = " . $appid;
     $question_count = $this->db->query_first($sql);
     if (empty($question_count)) {
         $question_count_data = array('vote_question_id' => $id, 'app_id' => $appid, 'app_name' => $appname, 'counts' => 1);
         $this->mVote->create_data('question_count', $question_count_data);
     } else {
         $sql = "UPDATE " . DB_PREFIX . "question_count SET counts=(counts+1) WHERE vote_question_id=" . $id . " AND app_id = " . $appid;
         $this->db->query($sql);
     }
     /***********************调用积分规则,给已审核评论增加积分START*****************/
     $data = $vote;
     if ($this->settings['App_members'] && $this->user['user_id'] && $this->input['iscreditsrule']) {
         $sql = "SELECT count(vote_question_id) as vote_num FROM " . DB_PREFIX . "question_person WHERE 1 ";
         $sql .= " AND vote_question_id = " . $id . " AND user_id = '" . $this->user['user_id'] . "'";
         $vote_num = $this->db->query_first($sql);
         if ($vote_num['vote_num'] < CREDIT_NUM + 1) {
             include ROOT_PATH . 'lib/class/members.class.php';
             $Members = new members();
             $Members->Setoperation(APP_UNIQUEID, MOD_UNIQUEID, 'vote_add');
             /***增加积分**/
             if (IS_CREDITS && $this->user['user_id']) {
                 $credit_rules = $Members->get_credit_rules($this->user['user_id'], APP_UNIQUEID, MOD_UNIQUEID, 0, $id);
             }
             /**积分文案处理**/
             $credit_copy = array();
             if ($credit_rules['updatecredit']) {
                 $credit_copy[] = $credit_rules;
             }
             $data['copywriting_credit'] = $Members->copywriting_credit($credit_copy);
         }
         /**积分文案处理结束**/
     }
     /***********************调用积分规则,给已审核评论增加积分END*****************/
     if (!trim($this->input['app_version'])) {
         $this->addItem('success');
     } else {
         $data['vote_status'] = 'success';
         $this->addItem($data);
     }
     $this->output();
 }
Beispiel #3
0
 /**
  *
  * @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();
 }
Beispiel #4
0
    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 = 1;
                    break;
                case 2:
                    $state = 2;
                    break;
                case 3:
                    $state = 3;
                    break;
            }
            if ($state == 2) {
                /*******************调用积分规则,给已审核评论增加积分START*****************/
                if ($this->settings['App_members']) {
                    include ROOT_PATH . 'lib/class/members.class.php';
                    $Members = new members();
                    $sql = 'SELECT id,user_id FROM ' . DB_PREFIX . 'content WHERE 1 AND create_time>' . $start_time . ' AND create_time<' . $end_time . ' AND audit = 1 AND is_m2o = 0 AND new_member =1 AND is_credits=0';
                    $q = $this->db->query($sql);
                    $credit_rules_uid = array();
                    //需增加积分的会员id
                    while ($r = $this->db->fetch_array($q)) {
                        if ($r['user_id']) {
                            $credit_rules_uid[$r['id']] = $r['user_id'];
                        }
                    }
                    /***审核增加积分**/
                    if ($credit_rules_uid) {
                        $Members->Setoperation(APP_UNIQUEID, '', '', 'extra');
                        if (is_array($credit_rules_uid)) {
                            foreach ($credit_rules_uid as $key => $member_id) {
                                $Members->get_credit_rules($member_id, APP_UNIQUEID);
                                $this->db->query("UPDATE " . DB_PREFIX . "content SET is_credits=1 WHERE id=" . $key);
                                //更新获得积分字段
                            }
                        }
                    }
                }
                /********************调用积分规则,给已审核评论增加积分END*****************/
            }
            $sql = 'UPDATE ' . DB_PREFIX . 'content SET audit = ' . $state . '
					WHERE audit = 1 
					AND create_time>' . $start_time . ' AND create_time<' . $end_time;
            $this->db->query($sql);
        }
        $this->addItem(true);
        $this->output();
    }
Beispiel #5
0
    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();
    }