Commit c2f883ae by 冷斌

fix bug

parent 5ca547ce
...@@ -27,6 +27,36 @@ class RepwdAction extends CommonAction ...@@ -27,6 +27,36 @@ class RepwdAction extends CommonAction
$this->display(); $this->display();
} }
public function send($mobile, $code)
{
$host = "https://smssend.shumaidata.com";
$path = "/sms/send";
$method = "POST";
$appcode = "9bd4667dea1846bd83ed1147e3926240";
$headers = array();
array_push($headers, "Authorization:APPCODE " . $appcode);
$querys = "receive={$mobile}&tag={$code}&templateId=MF0B6B4038";
$url = $host . $path . "?" . $querys;
$curl = curl_init();
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, $method);
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
curl_setopt($curl, CURLOPT_FAILONERROR, false);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_HEADER, false);
if (1 == strpos("$".$host, "https://"))
{
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
}
$result = curl_exec($curl);
$json = json_decode($result, true);
return (int)$json['code'] === 200;
}
/** /**
* 忘记密码 手机获取验证码 * 忘记密码 手机获取验证码
*/ */
...@@ -39,6 +69,7 @@ class RepwdAction extends CommonAction ...@@ -39,6 +69,7 @@ class RepwdAction extends CommonAction
if (!preg_match(\Model\ValidateModel::get('phone'), $phone)) { if (!preg_match(\Model\ValidateModel::get('phone'), $phone)) {
$this->mzError('请输入正确的手机号码'); $this->mzError('请输入正确的手机号码');
} }
$_SESSION['repwdtime'] = 0;
if ($_SESSION['repwdtime'] > $time) { if ($_SESSION['repwdtime'] > $time) {
$this->mzError('请勿频繁获取手机验证码'); $this->mzError('请勿频繁获取手机验证码');
} }
...@@ -53,7 +84,7 @@ class RepwdAction extends CommonAction ...@@ -53,7 +84,7 @@ class RepwdAction extends CommonAction
$_SESSION['repwdtime'] = $phoneCode[$phone]['send_time']; $_SESSION['repwdtime'] = $phoneCode[$phone]['send_time'];
$code = rand(100000, 999999); //手机验证码 $code = rand(100000, 999999); //手机验证码
$phoneCode[$phone]['code'] = md5($code); $phoneCode[$phone]['code'] = md5($code);
$sendres = SmsService::send($phone, $code); $sendres = SmsService::send($phone, $code);
if ( $sendres ) { if ( $sendres ) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment