public function verify_code() { if ($this->get_method() != 'POST') { $this->send_response(405, NULL, '请求的方法不存在'); } $data = $this->get_data(); $zone_code = isset($data['zone_code']) ? $data['zone_code'] : ''; $mobile = isset($data['mobile']) ? $data['mobile'] : ''; if (!international::check_is_valid($zone_code, $mobile)) { $this->send_response(400, NULL, Kohana::lang('authorization.mobile_invalid')); } $username = $this->model->get_full_mobile($zone_code, $mobile); $is_test_mobile = $this->is_test_mobile($mobile); if (!$is_test_mobile and !$this->check_verify_rate($username)) { $this->send_response(400, NULL, Kohana::lang('authorization.get_code_exceed_rate')); } $code = $this->model->create_verify_code(); $this->model->set_verify_code($username, $code); if ($is_test_mobile) { $this->send_response(200, array('code' => $code, 'zone_code' => $zone_code, 'mobile' => $mobile)); } $is_super = $this->is_super_mobile($mobile); if ($is_super) { $this->send_response(200, array('code' => $code, 'zone_code' => $zone_code, 'mobile' => $mobile)); } if (!$this->model->send_message($zone_code, $mobile, $code)) { $this->send_response(400, NULL, Kohana::lang('authorization.send_fail')); } // 正式时不能返回code if (IN_PRODUCTION === TRUE) { $this->send_response(200, array('zone_code' => $zone_code, 'mobile' => $mobile)); } else { $this->send_response(200, array('code' => $code, 'zone_code' => $zone_code, 'mobile' => $mobile)); } }