예제 #1
0
 public function registerAction()
 {
     $this->view->setVar('pageTitle', '注册');
     if ($this->request->isPost() == true) {
         if (!$this->validFlag) {
             echo json_encode(array('ret' => 0, 'msg' => $this->warnMsg));
             exit;
         } else {
             $user = new Users();
             if ($mobiRes = $user->existTel($this->_sanReq['mobile'])) {
                 if ($mobiRes == 1) {
                     echo json_encode(array('ret' => 0, 'msg' => array('mobile' => array('msg' => $this->di['sysconfig']['flagMsg']['10002']))));
                     $this->view->disable();
                     return;
                 }
             }
             $res = $user->isEmailExist($this->_sanReq['email']);
             if ($res['u_email']) {
                 echo json_encode(array('ret' => 0, 'msg' => array('email' => array('msg' => $this->di['sysconfig']['flagMsg']['10015']))));
                 $this->view->disable();
                 return;
             }
             $objCaptcha = new Captcha();
             $key = 'reg:' . $this->_sanReq['mobile'];
             $data = $objCaptcha->checkAllCaptcha($this->_sanReq['mobile'], $this->_sanReq['codeImg'], $key, $this->_sanReq['regtype'], $this->_sanReq['captcha']);
             if ($data == 1) {
                 $res = $user->register($this->_sanReq['passwd'], $this->_sanReq['mobile'], $this->_sanReq['email']);
                 if ($res == 1) {
                     $objCaptcha->delCaptchaRedisKey($key);
                     echo json_encode(array('ret' => 1));
                 } elseif ($res == 10002) {
                     echo json_encode(array('ret' => 0, 'msg' => array('mobile' => array('msg' => $this->di['sysconfig']['flagMsg']['10002']))));
                 } else {
                     echo json_encode(array('ret' => 0, 'msg' => array('service' => array('msg' => $this->di['sysconfig']['flagMsg']['10000']))));
                 }
                 $this->view->disable();
                 return;
             } else {
                 echo json_encode(array('ret' => 0, 'msg' => $data));
                 $this->view->disable();
                 return;
             }
         }
     }
 }