/** * 忘记密码短信接口 **/ public function forgotPassSMS() { $mobile = input_mobilenum($this->input->post('mobile'), '5001'); $rs = $this->model->get_user_auth_by_mobile($mobile, TRUE); if (!$rs) { response_code('4005'); } $mobile_cache = $this->model->check_mobile_send($mobile); //缓存取数据 if ($mobile_cache && $mobile_cache['sms_sendtime'] < TIME_NOW - 60) { response_code('5008'); } $mobile_identify = make_mobile_identify_code(); $current = array('check_mobile' => $mobile, 'sms_sendtime' => TIME_NOW); $this->set_current_data($current); $mobile_cache = array('mobile_identify' => $mobile_identify, 'sms_sendtime' => TIME_NOW); $this->model->save_mobile_identify($mobile, $mobile_cache); $message = array('type' => 'forgotUser', 'mobile' => $mobile, 'param' => array($mobile_identify, '5')); $rs = $this->sendSMS($message); $rs = json_decode($rs, TRUE); if (isset($rs['respCode'])) { log_message('ERROR', json_encode($rs)); if ($rs['respCode'] == '105122') { response_row(array('code' => '-1', 'msg' => '同一手机每天只能发送8条短信')); } } response_code('1'); }
public function mobileAuth() { $user_id = $this->get_user_id(TRUE); $type = input_string($this->input->post('type'), array('auth', 'band', 'modify'), FALSE, '4001'); $user = $this->model->get_user_detail($user_id); if (!$user) { response_code('4005'); } if ($type == 'auth') { if (!$user['user_mobile']) { response_code('5007'); } $mobile = $user['user_mobile']; if ($this->model->check_mobile_send($mobile)) { response_code('5008'); } } else { if ($type == 'band') { $mobile = input_mobilenum($this->input->post('mobile'), '5001'); $rs = $this->model->search_user_mobile($mobile); if ($rs) { if ($rs['user_id'] != $user_id) { response_code('5009'); } else { response_code('5010'); } } } else { if ($type = 'modify') { $rs = $this->model->check_mobile_send($user['user_mobile']); print_r($rs); exit; if (!$rs) { response_code('5012'); } $mobile = input_mobilenum($this->input->post('mobile'), '5001'); if ($mobile == $user['user_mobile']) { response_code('5008'); } $rs = $this->model->search_user_mobile($mobile); if ($rs) { if ($rs['user_mobile'] == $mobile) { response_code('5009'); } else { response_code('5010'); } } } } } $mobile_identify = make_mobile_identify_code(); $str = array('check_mobile' => $mobile, 'mobile_identify' => $mobile_identify, 'sms_sendtime' => TIME_NOW); $this->set_current_data($str); $str['user_id'] = $user_id; $message = array('type' => 'bondMobile', 'mobile' => $mobile, 'param' => array($mobile_identify, '5')); $this->model->save_mobile_identify($str); $this->sendSMS($str); response_code('1'); }