Esempio n. 1
0
 /**
  * 退出登录
  */
 public function loginoutAction()
 {
     $send['state'] = false;
     $params = $this->filterParams($this->_params);
     $model = new MobileModel();
     $patternArr = Application::app()->getConfig()->application->environment;
     $configArr = $patternArr->toArray();
     $pattern = $configArr['mode'];
     // 移动端已修改用户退出方案,这里不论私有云还是公有云,都只退出当前移动终端上的app
     if ($pattern == 'public') {
         $res = $model->loginOutPublicCloud($params);
     } else {
         $res = $model->loginOutPublicCloud($params);
     }
     if (!$res) {
         $send['error'] = 'Loginout failed';
     } else {
         $send['state'] = true;
         $send['data']['message'] = 'success';
     }
     $this->sendOutput($send);
 }
Esempio n. 2
0
 function getMobileCode()
 {
     $mobile = $this->get_valid_param('mobile', 'strval');
     $action = $this->get_valid_param('action', 'intval');
     $um = new UserModel();
     if (!$this->checkMobile($mobile)) {
         $this->_return('MSG_MOBILE_FORMAT_ERROR');
     }
     /*
      *  判断绑定账号
      */
     if ($action == 4 || $action == 1) {
         $user_data = $um->getDataByMobile($mobile, 'user_id');
         if ($user_data !== null) {
             $this->_return('MOBILE_EXISTED_ERROR');
         }
     }
     if ($action == 3 || $action == 2) {
         $user_data = $um->getDataByMobile($mobile, 'user_id');
         if ($user_data == null) {
             $this->_return('MOBILE_NOT_EXISTED');
         }
     }
     $mm = new MobileModel();
     $code_data = $mm->getDataByMobile($mobile, 'update_ts,today_times');
     $flag = 1;
     $now = time();
     $param = array('expire_ts' => $now + 600, 'update_ts' => $now);
     $where = array();
     if (!$code_data) {
         $param['mobile'] = $mobile;
         $param['today_times'] = 1;
     } else {
         $where = array('mobile' => $mobile);
         if ($this->isSameDay($code_data['update_ts'])) {
             if ($code_data['today_times'] >= C('max_msg_code_per_day')) {
                 $this->_return('MSG_MAX_TIMES_PER_DAY');
             } else {
                 $param['today_times'] = $code_data['today_times'] + 1;
             }
         } else {
             $param['today_times'] = 1;
         }
     }
     $code = $this->generateMobileCode();
     $param['code'] = $code;
     $log_param = array('mobile' => $mobile, 'action_type' => $action, 'res_code' => -1, 'res_fee' => -1, 'res_sid' => -1, 'log_ts' => $now);
     try {
         $res = json_decode(send_sms_new(sprintf(C('send_msg_code_content'), $code), $mobile), true);
         if (isset($res['code'])) {
             $log_param['res_code'] = $res['code'];
             $log_param['res_fee'] = $res['result']['fee'];
             $log_param['res_sid'] = $res['result']['sid'];
         }
     } catch (\Exception $e) {
     }
     if ($log_param['res_code'] === 0) {
         //发送成功
         $res = $mm->saveMsgInfo($log_param, $param, $where);
     } else {
         $res = $mm->saveMsgInfo($log_param);
     }
     if (!$res) {
         $this->_return('MSG_MYSQL_ERROR');
     }
     if ($log_param['res_code'] == -1) {
         $this->_return('MSG_SEND_ERROR');
     }
     $this->_return('MSG_SUCCESS');
 }