Exemple #1
0
 /**
  * 回答接口
  */
 public function addAction()
 {
     //取值,参数验证,签名验证
     $vars = ['mem_id', 'mem_mark', 'empty_ans_id', 'mem_relation_id', 'que_id', 'ans_content', 'is_img', 'sign'];
     $this->beforeGetVarExecVerify($vars, 'post');
     //判断是否是图片
     if ($this->data['is_img'] == 1) {
         $this->data['ans_content'] = \Func::touchImg($this->data['ans_content'], 'ans');
         if (!$this->data['ans_content']) {
             $this->throwMessage(ILLEGAL_IMAGE);
         }
     }
     //默认执行回答提问方法
     $func = 'addAnswer';
     //需要的字段
     $field = ['mem_id', 'mem_mark', 'mem_relation_id', 'que_id', 'ans_content'];
     //根据可空回答id,empty_ans_id判断是否执行追问方法
     if ($this->data['empty_ans_id']) {
         array_push($field, $this->data['empty_ans_id']);
         $func = 'addAnswerAsk';
     }
     //转义回答内容
     $this->data['ans_content'] = mb_substr(\Func::escape($this->data['ans_content']), 0, 250, 'utf-8');
     //获取执行状态,执行失败,并且是图片信息,则删除上传的图片
     $add_status = $this->callModelFunc('Answer', $func, $field);
     if ($add_status != OK && $this->data['is_img'] == 1) {
         \FileUtil::getInstance()->unlink(PUBLIC_PATH . $this->data['ans_content']);
     }
     $this->throwMessage($add_status);
 }
Exemple #2
0
 /**
  * 新增提问
  */
 public function addAction()
 {
     //取值,参数验证,签名验证
     $vars = ['mem_id', 'mem_mark', 'que_content', 'que_img', 'que_reward', 'tag_ides', 'sign'];
     $this->beforeGetVarExecVerify($vars, 'post');
     //图片操作
     $this->data['que_img'] = json_decode($this->data['que_img'], true);
     $this->data['que_img'] = is_array($this->data['que_img']) ? $this->data['que_img'] : [];
     $images = [];
     if (!empty($this->data['que_img'])) {
         $i = 1;
         foreach ($this->data['que_img'] as $key => $val) {
             //数组格式不合法
             if (!isset($val['img'])) {
                 \FileUtil::getInstance()->unlink($images, PUBLIC_PATH);
                 $this->throwMessage(ILLEGAL_ARRAY);
             }
             //非法的图片
             if (!($images[] = \Func::touchImg($val['img'], 'que'))) {
                 \FileUtil::getInstance()->unlink($images, PUBLIC_PATH);
                 $this->throwMessage(ILLEGAL_IMAGE);
             }
             //控制提问最多可上传的数量
             $i++;
             if ($i > QUESTION_MAX_IMAGE) {
                 break;
             }
         }
     }
     //处理字段
     $this->data['que_img'] = $images;
     $this->data['que_content'] = \Func::escape($this->data['que_content']);
     //所需字段
     $field = ["mem_id", "mem_mark", "que_content", "que_img", "que_reward", "tag_ides"];
     $add_status = $this->callModelFunc('Question', 'addQuestion', $field);
     if ($add_status != OK) {
         \FileUtil::getInstance()->unlink($images, PUBLIC_PATH);
     }
     $this->throwMessage($add_status);
 }
Exemple #3
0
 /**
  * 修改昵称
  */
 public function setNicknameAction()
 {
     $vars = ['mem_id', 'mem_mark', 'mem_nickname', 'sign'];
     $this->beforeGetVarExecVerify($vars);
     //转义昵称
     $this->data['mem_nickname'] = \Func::escape($this->data['mem_nickname']);
     //修改昵称
     $field = ['mem_id', 'mem_mark', 'mem_nickname'];
     $upd_status = $this->callModelFunc('Member', 'updMemNickname', $field);
     $this->throwMessage($upd_status);
 }