Beispiel #1
0
 /**
  * 设置头像
  */
 public function setHeadAction()
 {
     $vars = ['mem_id', 'mem_head', 'mem_mark', 'sign'];
     //获取数据
     list($mem_id, $mem_head, $mem_mark, $sign) = \Verify::getPost($vars);
     //验证参数
     if (\Verify::getMessage()) {
         $this->throwMessage(PARAMETER_FAIL, \Verify::getMessage());
     }
     //生产图片
     $mem_head = \Func::touchImg($mem_head, 'head');
     if (!$mem_head) {
         $this->throwMessage(ILLEGAL_IMAGE);
     }
     //验证签名
     if (!$this->verifySign($mem_id, $sign)) {
         $this->throwMessage(ILLEGAL_SIGN);
     }
     //修改头像
     $this->throwMessage((new \Member())->updMemHead($mem_id, $mem_mark, $mem_head), ['mem_head' => $mem_head]);
 }
Beispiel #2
0
 /**
  * 获取变量,并执行验证参数,验证签名
  * @param array $vars 包含参数名称的数组
  * @param string $type 获取变量的方式
  * @return array $data
  */
 protected function beforeGetVarExecVerify($vars, $type = 'get')
 {
     //选择取值方式
     $data = [];
     switch ($type) {
         case 'get':
             $data = \Verify::getQuery($vars);
             break;
         case 'post':
             $data = \Verify::getPost($vars);
             break;
         case 'request':
             $data = \Verify::get($vars);
             break;
     }
     //验证参数
     if (\Verify::getMessage()) {
         $this->throwMessage(PARAMETER_FAIL, \Verify::getMessage());
     }
     //赋值
     foreach ($vars as $key => $val) {
         $this->data[$val] = $data[$key];
     }
     //验证签名
     $this->beforeVerify();
     return $this->data;
 }