正在显示
3 个修改的文件
包含
46 行增加
和
4 行删除
@@ -429,3 +429,28 @@ if(!function_exists('tranTime')) { | @@ -429,3 +429,28 @@ if(!function_exists('tranTime')) { | ||
429 | return $str; | 429 | return $str; |
430 | } | 430 | } |
431 | } | 431 | } |
432 | + | ||
433 | +if(!function_exists('httpPost')){ | ||
434 | + function httpPost($url, $date) { // 模拟提交数据函数 | ||
435 | + $curl = curl_init(); // 启动一个CURL会话 | ||
436 | + curl_setopt($curl, CURLOPT_URL, $url); // 要访问的地址 | ||
437 | + curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); // 对认证证书来源的检查 | ||
438 | + curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false); // 从证书中检查SSL加密算法是否存在 | ||
439 | + curl_setopt($curl, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']); // 模拟用户使用的浏览器 | ||
440 | + curl_setopt($curl, CURLOPT_POST, true); // 发送一个常规的Post请求 | ||
441 | + curl_setopt($curl, CURLOPT_POSTFIELDS, json_encode($date)); // Post提交的数据包 | ||
442 | + curl_setopt($curl, CURLOPT_TIMEOUT, 30); // 设置超时限制防止死循环 | ||
443 | + curl_setopt($curl, CURLOPT_HEADER, false); // 显示返回的Header区域内容 | ||
444 | + curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); // 获取的信息以文件流的形式返回 | ||
445 | + curl_setopt($curl, CURLOPT_HEADER, false); //开启header | ||
446 | + curl_setopt($curl, CURLOPT_HTTPHEADER, array( | ||
447 | + 'Content-Type: application/json; charset=utf-8' | ||
448 | + )); //类型为json | ||
449 | + $result = curl_exec($curl); // 执行操作 | ||
450 | + if (curl_errno($curl)) { | ||
451 | + echo 'Error POST' . curl_error($curl); | ||
452 | + } | ||
453 | + curl_close($curl); // 关键CURL会话 | ||
454 | + return json_decode($result,true); // 返回数据 | ||
455 | + } | ||
456 | +} |
@@ -53,11 +53,23 @@ class Sms | @@ -53,11 +53,23 @@ class Sms | ||
53 | $time = time(); | 53 | $time = time(); |
54 | $ip = request()->ip(); | 54 | $ip = request()->ip(); |
55 | $sms = \app\common\model\Sms::create(['event' => $event, 'mobile' => $mobile, 'code' => $code, 'ip' => $ip, 'createtime' => $time]); | 55 | $sms = \app\common\model\Sms::create(['event' => $event, 'mobile' => $mobile, 'code' => $code, 'ip' => $ip, 'createtime' => $time]); |
56 | + $sms_config = config('option.sms'); | ||
57 | + $tKey = time(); | ||
58 | + $password = md5(md5($sms_config['sms_pwd']) . $tKey); | ||
59 | + $date = array( | ||
60 | + 'username' => $sms_config['sms_user'], //用户名 | ||
61 | + 'password' => $password, //密码 | ||
62 | + 'tKey' => $tKey, //tKey | ||
63 | + 'signature' => '【小区焦点】', | ||
64 | + 'mobile' => config('site.customer'), | ||
65 | + 'content' => '提醒您,您的验证码是:' .$code.',十分钟之内有效,请勿向他人泄漏您的验证码', | ||
66 | + ); | ||
67 | + $result = httpPost($sms_config['url'], $date); | ||
56 | // $result = Hook::listen('sms_send', $sms, null, true); | 68 | // $result = Hook::listen('sms_send', $sms, null, true); |
57 | -// if (!$result) { | ||
58 | -// $sms->delete(); | ||
59 | -// return false; | ||
60 | -// } | 69 | + if ($result['code'] != 200) { |
70 | + $sms->delete(); | ||
71 | + return false; | ||
72 | + } | ||
61 | return $code; | 73 | return $code; |
62 | } | 74 | } |
63 | 75 |
@@ -10,5 +10,10 @@ return [ | @@ -10,5 +10,10 @@ return [ | ||
10 | 'vue_url' => 'http://shequ.h.brofirst.cn', | 10 | 'vue_url' => 'http://shequ.h.brofirst.cn', |
11 | 'template' => [ | 11 | 'template' => [ |
12 | 'msg' => 'OnPAh4RbKvgZn9asTsUkF3pb_SixqccsSxbZBILqfQM' | 12 | 'msg' => 'OnPAh4RbKvgZn9asTsUkF3pb_SixqccsSxbZBILqfQM' |
13 | + ], | ||
14 | + 'sms' => [ | ||
15 | + 'url' => 'http://api.mix2.zthysms.com/v2/sendSms', | ||
16 | + 'sms_user' => 'shequ', | ||
17 | + 'sms_pwd' => 'cxz307311', | ||
13 | ] | 18 | ] |
14 | ]; | 19 | ]; |
-
请 注册 或 登录 后发表评论