123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123 |
- <?php
- // by 请勿倒卖,已申请软著,否则追究法律责任
- include "source/pack/dingxianginc/CaptchaClient.php";
- include "include/function/alisms.function.php";
- header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
- header("Cache-Control: no-cache, must-revalidate");
- header("Pragma: no-cache");
- header("content-type:application/json");
- $ac = SafeRequest("ac", "get");
- if ($ac == "send_sms") {
- if ($_SERVER["REQUEST_METHOD"] == "POST") {
- $mobile = SafeRequest("phone", "post");
- $token = SafeRequest("token", "post");
- if (IN_DXINCAPPID == "") {
- if (strlen($token) > 100) {
- $check = "ok";
- } else {
- $check = "no";
- }
- } else {
- $appId = IN_DXINCAPPID;
- $appSecret = IN_DXINCAPPSECRET;
- $client = new CaptchaClient($appId, $appSecret);
- $client->setTimeOut(5);
- $response = $client->verifyToken($token);
- if ($response->result) {
- $check = "ok";
- } else {
- $check = "no";
- }
- }
- if ($check == 'ok') {
- $code = rand(100000, 999999);
- $ipcount = $GLOBALS["db"]->getone("select count(*) from " . tname("mobile") . " where in_ip='" . getonlineip() . "'");
- $mmcount = $GLOBALS["db"]->getone("select count(*) from " . tname("mobile") . " where in_mobile='" . $mobile . "'");
- if (!preg_match("/0?[1][0-9][0-9]{9}/", $mobile)) {
- exit(json_encode(array("code" => "404", "msg" => "手机号码不正确!")));
- } elseif ($GLOBALS["db"]->getone("select in_userid from " . tname("user") . " where in_mobile='" . $mobile . "'")) {
- exit(json_encode(array("code" => "404", "msg" => "手机号码已存在!")));
- } elseif (9 <= $ipcount) {
- exit(json_encode(array("code" => "404", "msg" => "当前IP超出短信发送限制!")));
- } elseif (9 <= $mmcount) {
- exit(json_encode(array("code" => "404", "msg" => "当前手机超出短信发送限制!")));
- } elseif (!empty($_COOKIE[$cookie])) {
- exit(json_encode(array("code" => "404", "msg" => "发送时间限制,请稍后再次发送!")));
- } else {
- $result = SENDALISMS($mobile, $code);
- if ($result) {
- if ($result == "OK") {
- $setarr = array("in_mobile" => $mobile, "in_code" => $code, "in_ip" => getonlineip(), "in_addtime" => date("Y-m-d H:i:s"), "in_timeout" => strtotime("+10 minute"));
- inserttable("mobile", $setarr, 1);
- exit(json_encode(array("code" => "200", "msg" => "短信验证码发送成功")));
- } else {
- exit(json_encode(array("code" => "404", "msg" => $result)));
- }
- } else {
- exit(json_encode(array("code" => "404", "msg" => "请求发送短信失败")));
- }
- }
- } else {
- exit(json_encode(array("code" => "404", "msg" => "验证码失效,请刷新后重试!")));
- }
- } else {
- exit(json_encode(array("code" => "404", "msg" => "参数错误")));
- }
- } elseif ($ac == "send_lostsms") {
- if ($_SERVER["REQUEST_METHOD"] == "POST") {
- $mobile = SafeRequest("phone", "post");
- $token = SafeRequest("token", "post");
- if (IN_DXINCAPPID == "") {
- if (strlen($token) > 100) {
- $check = "ok";
- } else {
- $check = "no";
- }
- } else {
- $appId = IN_DXINCAPPID;
- $appSecret = IN_DXINCAPPSECRET;
- $client = new CaptchaClient($appId, $appSecret);
- $client->setTimeOut(5);
- $response = $client->verifyToken($token);
- if ($response->result) {
- $check = "ok";
- } else {
- $check = "no";
- }
- }
- if ($check == 'ok') {
- $code = rand(100000, 999999);
- $ipcount = $GLOBALS["db"]->getone("select count(*) from " . tname("mobile") . " where in_ip='" . getonlineip() . "'");
- $mmcount = $GLOBALS["db"]->getone("select count(*) from " . tname("mobile") . " where in_mobile='" . $mobile . "'");
- $uid = $GLOBALS["db"]->getone("select in_userid from " . tname("user") . " where in_mobile='" . $mobile . "'");
- $uid || exit(json_encode(array("code" => "404", "msg" => "手机号码不存在!")));
- if (!preg_match("/0?[1][0-9][0-9]{9}/", $mobile)) {
- exit(json_encode(array("code" => "404", "msg" => "手机号码不正确!")));
- } elseif (9 <= $ipcount) {
- exit(json_encode(array("code" => "404", "msg" => "当前IP超出短信发送限制!")));
- } elseif (9 <= $mmcount) {
- exit(json_encode(array("code" => "404", "msg" => "当前手机超出短信发送限制!")));
- } elseif (!empty($_COOKIE[$cookie])) {
- exit(json_encode(array("code" => "404", "msg" => "发送时间限制,请稍后再次发送!")));
- } else {
- $result = SENDALISMS($mobile, $code);
- if ($result) {
- if ($result == "OK") {
- $setarr = array("in_mobile" => $mobile, "in_code" => $code, "in_uid" => $uid, "in_ip" => getonlineip(), "in_addtime" => date("Y-m-d H:i:s"), "in_timeout" => strtotime("+10 minute"));
- inserttable("mobile", $setarr, 1);
- exit(json_encode(array("code" => "200", "msg" => "短信验证码发送成功")));
- } else {
- exit(json_encode(array("code" => $error_code, "msg" => $result)));
- }
- } else {
- exit(json_encode(array("code" => "404", "msg" => "请求发送短信失败")));
- }
- }
- } else {
- exit(json_encode(array("code" => "404", "msg" => "验证码验证失败!")));
- }
- } else {
- exit(json_encode(array("code" => "404", "msg" => "参数错误")));
- }
- }
|