/** * 修改手机号 */ public function modUsername() { $orgmobile = isset($_POST['orgname']) ? htmlspecialchars($_POST['orgname']) : ''; $orgcode_verify = isset($_POST['orgcode_verify']) ? htmlspecialchars(trim($_POST['orgcode_verify'])) : ''; $username = isset($_POST['username']) ? htmlspecialchars(trim($_POST['username'])) : ''; $now_code_verify = isset($_POST['now_code_verify']) ? htmlspecialchars(trim($_POST['now_code_verify'])) : ''; if (empty($orgmobile)) { $this->jsonUtils->echo_json_msg(1, '第一次手机号码为空'); exit; } $checkMobile = $this->dao->where(array('mobile' => $orgmobile))->getField('id'); if (!$checkMobile) { $this->jsonUtils->echo_json_msg(4, $orgmobile . "该手机号未注册"); exit; } $sms = new \Org\Util\Sms(); if (empty($_POST['session_id'])) { $msg = $sms->send_sms($orgmobile, 2, 2); // Log::write(json_encode($_SESSION),'1'); if ($msg['code'] == 2) { $this->jsonUtils->echo_json_data(0, '第一次成功发送短信,请查收..', $msg['session_id']); exit; } else { $this->jsonUtils->echo_json_msg(3, $msg['msg']); exit; } } else { if (empty($orgcode_verify)) { $this->jsonUtils->echo_json_msg(4, '第一次验证码为空...'); exit; } $code = $sms->getVerifyCode($_POST['session_id'], $orgmobile); if ($code == $orgcode_verify) { if (empty($username)) { $this->jsonUtils->echo_json_msg(5, '第二次手机号码为空'); exit; } // 检测手机号是否已被注册 $checkMobile = $this->dao->where(array('mobile' => $username))->getField('id'); if ($checkMobile) { $this->jsonUtils->echo_json_msg(6, $username . "该手机号已注册"); exit; } if (empty($_POST['now_session_id'])) { $msg = $sms->send_sms($username, 2, 2); // Log::write(json_encode($_SESSION),'2'); if ($msg['code'] == 2) { $this->jsonUtils->echo_json_data(0, '第二次成功发送短信,请查收..', $msg['session_id']); exit; } else { $this->jsonUtils->echo_json_msg(7, $msg['msg']); exit; } } if (empty($now_code_verify)) { $this->jsonUtils->echo_json_msg(8, '第二次验证码为空...'); exit; } $new_code = $sms->getVerifyCode($_POST['now_session_id'], $username); if ($new_code == $now_code_verify) { $rel = $this->dao->where(array('mobile' => $orgmobile))->save(array('mobile' => $username)); if ($rel === false) { $this->jsonUtils->echo_json_msg(9, '修改用户名失败'); exit; } else { $this->jsonUtils->echo_json_msg(0, '修改用户名成功'); exit; } } else { $this->jsonUtils->echo_json_msg(10, "手机号:" . $username . "的验证码失效或者过期"); exit; } } else { $this->jsonUtils->echo_json_msg(11, "手机号:" . $orgmobile . "的验证码失效或者过期"); exit; } } }
/** * 找回密码 */ public function modPassword() { $mobile = isset($_POST['username']) ? htmlspecialchars($_POST['username']) : ''; $code_verify = isset($_POST['code_verify']) ? htmlspecialchars(trim($_POST['code_verify'])) : ''; $password = isset($_POST['password']) ? htmlspecialchars(trim($_POST['password'])) : ''; $repassword = isset($_POST['repassword']) ? htmlspecialchars(trim($_POST['repassword'])) : ''; if (empty($mobile)) { $this->jsonUtils->echo_json_msg(4, '手机号码为空'); exit; } $checkMobile = $this->dao->where(array('mobile' => $mobile))->getField('id'); if (!$checkMobile) { $this->jsonUtils->echo_json_msg(4, '该手机号未注册'); exit; } $sms = new \Org\Util\Sms(); if (empty($_POST['session_id'])) { $msg = $sms->send_sms($mobile, 2, 0); if ($msg['code'] == 2) { $this->jsonUtils->echo_json_data(0, '成功发送短信,请查收..', $msg['session_id']); exit; } else { $this->jsonUtils->echo_json_msg(1, $msg['msg']); exit; } } else { if (empty($code_verify)) { $this->jsonUtils->echo_json_msg(43, '验证码为空...'); exit; } $code = $sms->getVerifyCode($_POST['session_id'], $mobile); if ($code == $code_verify) { if ($password == $repassword) { $dat = $this->dao->where(array('mobile' => $mobile))->save(array('pwd' => md5($password))); if ($dat === false) { $this->jsonUtils->echo_json_msg(4, '修改密码失败'); exit; } else { $this->jsonUtils->echo_json_msg(0, '修改密码成功'); exit; } } else { $this->jsonUtils->echo_json_msg(4, '两次输入密码不一致'); exit; } } else { $this->jsonUtils->echo_json_msg(4, '验证码失效或者过期'); exit; } } }