Fas流控短信验证码接口更换腾讯云短信


将Fas流控目录下的api文件(/var/www/html/app_api/api.php)替换为下方代码,注意代码中备注信息填写部分填写为自己的,其他地方不要改动。腾讯云短信选择的是指定模板ID单发短信。Fas流控免费搭建网站:getvpn.cn。

<?php
// 指定模板ID单发短信
    require('../system.php');
    
    $m = explode("_",$_GET['app_key']);
    
    $DID = 0;
    
    if(count($m) == 2){
        if(db("app_daili")->where(["id"=>$m[1]])->find()){
            $DID = $m[1];
        }
    }
    define("DID",$DID);
    
    function get_millisecond(){  
        list($usec, $sec) = explode(" ", microtime());   
        $msec=round($usec*1000);  
        return $msec;
    }
function send_post($url, $post_data) {
    $postdata = http_build_query($post_data);
    $options = array(
        'http' => array(
            'method' => 'POST',
            'header' => 'Content-type:application/x-www-form-urlencoded',
            'content' => $postdata,
            'timeout' => 60 // 超时时间(单位:s)
        )
    );
    $context = stream_context_create($options);
    $result = file_get_contents($url, false, $context);
    return $result;
}


    function senddx($t,$c){//手机号,验证码
 
 ///////////////////////////信息填写////////////////////////////////
//验证码
 $params = $c;//验证码,不能更改
//发送短信的目标手机号
 $phoneNumbers = $t;//手机号,不能更改
//腾讯云短信的appid
 $appid="";// 1400开头
//腾讯云短信的appkey
 $appkey="";//5d55f5626cc7fd9b80f0b7e727e196dc类似这样的一串文本
//腾讯云短信的模板ID
 $templateID="";//纯数字
//腾讯云短信签名
 $smsSign="";//请使用真实的已申请的签名,签名参数使用的是`签名内容`,而不是`签名ID`
///////////////////////////信息填写////////////////////////////////
$post_data = array(
    'params' => $params,
    'phoneNumbers' => $phoneNumbers,
    'appid' => $appid,
    'appkey' => $appkey,
    'templateID' => $templateID,
    'smsSign' => $smsSign,
);
        $result = send_post('https://www.yinjiangbi.cn/duanxin/demo/simple/duanxinapi.php', $post_data);
        curl_close($ch);
        return $result;
    }
    function checkUsername($str)
    {
            $output='';
            $a=preg_match('/['.chr(0xa1).'-'.chr(0xff).']/', $str);
            $b=preg_match('/[0-9]/', $str);
            $c=preg_match('/[a-zA-Z]/', $str);
            if($a && $b && $c){
                $output='汉字数字英文的混合字符串';
            }elseif($a && $b && !$c){
                $output='汉字数字的混合字符串';
            }elseif($a && !$b && $c){
                $output='汉字英文的混合字符串';
            }elseif(!$a && $b && $c){
                $output='数字英文的混合字符串';
                return true;
            }elseif($a && !$b && !$c){
                $output='纯汉字';
            }elseif(!$a && $b && !$c){
                $output='纯数字';
                return true;
            }elseif(!$a && !$b && $c){
                $output='纯英文';
                return true;
            }
            //return $output;
            return false;
    }
    if($_GET['act'] == 'line'){
        include('api_head.php');
        include('mode/line.php');
        include("api_footer.php");
    //=========================================
    }elseif($_GET['act'] == 'app_check'){
        include("shengji.php");
    }elseif($_GET['act'] == 'login_sms'){
        if(trim($_POST['username']) == ''){
            die(json_encode(array('status'=>'error','msg'=>'手机号码尚未填写')));
        }
            $code = rand(1000,9999);
            $_SESSION['code'] = $code;
            $_SESSION['phone'] = $_POST['username'];
            $_SESSION["last_send"] = time();
            $c = senddx($_POST['username'],$code);
            $resp = json_decode($c,true);
            //$resp = $c;
            if($resp== "1"){//正确验证码返回1
                die(json_encode(array('status'=>'success')));
            }else{//其他情况
                die(json_encode(array('status'=>'error','msg'=>"短信发送失败 错误代码:".$resp,'time'=>date("YmdHis",SYSTEM_T))));
                //die(json_encode(array('status'=>'error','msg'=>"短信发送失败")));
            }
    }elseif($_GET['act'] == 'reg_in'){//注册到数据库
        $username = $_POST['username']
        $depart = $_POST['depart'];
        $password = $_POST['password'];
        $code = strtolower($_POST['code']);

        if(strtolower($_SESSION['code']) != $code){
            die(json_encode(array('status'=>'error','msg'=>'验证码错误')));
        }
        $type = @file_get_contents("data/reg_type.txt");
        if($type == "sms"){
            if(trim($_SESSION['phone']) != trim($_POST['username'])){
                die(json_encode(array('status'=>'error','msg'=>'信息不一致')));
            }
        }
        if(trim($username) == '' || trim($password) == '' ){
            die(json_encode(array('status'=>'error','msg'=>'用户密码不能为空')));
        }

        if(!checkUsername($username)){
            die(json_encode(array('status'=>'error','msg'=>'用户名只能是英文和数字')));
        }
        if(!checkUsername($password)){
            die(json_encode(array('status'=>'error','msg'=>'密码只能是英文和数字')));
        }

        $db= db(_openvpn_);
        
        if($db->where(array(_iuser_=>$username))->find()){
            
            die(json_encode(array('status'=>'error','msg'=>'已经注册过了哦')));
        }else{
            $m =  new Map();
            $info["SMS_T"] = $m->type("cfg_app")->getValue("SMS_T",3);
            $info["SMS_L"] = $m->type("cfg_app")->getValue("SMS_L",100);
            $info["SMS_I"] = $m->type("cfg_app")->getValue("SMS_I",0)
            $date[_iuser_] = $username;
            $date[_ipass_] = $password
            $date[_depart_] = $depart;
            $date[_maxll_] = $info["SMS_L"]*1024*1024;
            $date[_isent_] = '0';
            $date[_irecv_] = '0';
            $date["daili"] = DID;
            $date[_i_] = $info["SMS_I"];
            $date[_starttime_] = time();
            $date[_endtime_] = time()+($info["SMS_T"]*24*60*60);
            
            $arr = explode(",",_other_);
            foreach($arr as  $v){
                $date[$v] = "";
            }
            if($db->insert($date,true)){
                $_SESSION['code'] = '';
                die(json_encode(array('status'=>'success','msg'=>'100')));
            
            }else{
                die(json_encode(array('status'=>'error','msg'=>'无法正常注册用户 请检查数据库')));
                
            }
            
        }
    }elseif($_GET['act'] == 'app_reg'){
        include("mode/app_reg.php");
    }elseif($_GET['act'] == 'dx_reg'){
        include("api_head.php");
        
        $m =  new Map();
        $type = $m->type("cfg_app")->getValue("reg_type");
        
        if($type == "sms"){
            include("mode/dx_reg.php");
        }else{
            include("mode/app_reg.php");
        }
        include("api_footer.php");
    }elseif($_GET['act'] == 'info'){
        include("api_head.php");
        include("mode/llog.php");
        include("api_footer.php");
    }elseif($_GET['act'] == 'user_info'){
        header("location:user/index.php?user=".$_GET['username'].'&pass='.$_GET['password']);
    }elseif($_GET['act'] == 'Shop'){
    //流量购买
        include("api_head.php");
        include("mode/ad.php");
        include("api_footer.php");
    }elseif($_GET['act'] == 're_bbs'){
        $u = $_GET['username'];
        $p = $_GET['password'];
        $db = db("app_bbs");
        if($db->insert(array("username"=>$u,"content"=>$_POST["content"],"time"=>time(),"to"=>$_POST["to"]))){
            die(json_encode(array("status"=>"success")));
        }else{
            die(json_encode(array("status"=>"error")));
        }
        
    }elseif($_GET['act'] == 'feedback'){
        $u = $_GET['username'];
        $p = $_GET['password'];
        $user = db(_openvpn_)->where([_iuser_=>$u])->find();
        if($user){
            $db = db("app_feedback");
            $old = $db->where(["user_id"=>$user["id"],"line_id"=>$_POST["line_id"]])->order("id DESC")->find();
            if($old){
                if(time()-$old["time"] < 60*15){
                    die(json_encode(array("status"=>"old")));
                }
            }
            foreach($config["Feedback"]["Field"] as $key=>$vo){
                $data[$key] = $_POST[base64_encode($key)];
            } 
            if($db->insert(array("user_id"=>$user["id"],"content"=>base64_encode(json_encode($data)),"time"=>time(),"line_id"=>$_POST["line_id"]))){
                die(json_encode(array("status"=>"success")));
            }else{
                die(json_encode(array("status"=>"error")));
            }
        }
        
    }elseif($_GET['act'] == 'list_bbs'){
        include('api_head.php');
        include('mode/list_bbs.php');
        include("api_footer.php");
    }elseif($_GET['act'] == 'bbs'){
        include('api_head.php');
        include('mode/bbs_view.php');
        include("api_footer.php");
    }elseif($_GET['act'] == 'list_gg'){
        include('api_head.php');
        //include('list_gg.php');
        $u = $_GET['username'];
        $p = $_GET['password'];
        $db = db('app_gg');
        $list = $db->where(["daili"=>DID])->order('id DESC')->select();
        echo '<div style="margin:10px 10px;">';
            echo '<div class="alert alert-warning">您可以在这看到最近30条消息通知</div>';
        
            echo '</div>';
        if($list){
            echo '<ul class="list-group">';
            foreach($list as $v){
                $is_read = db("app_read")->where(array("readid"=>$v["id"],"username"=>$_GET["username"]))->find();
                $pre = $is_read ? '' :'<span class="badge">未读</span>'; 
                echo '<li class="list-group-item"><a href="?act=gg&id='.$v['id'].'&username='.$_GET['username'].'&app_key='.$_GET['app_key'].'">'.$pre.$v['name'].'</a></li>
                ';
            }
        echo '</ul>';
        }else{
            echo '消息已经删除或者不存在!';
        }
        
        include("api_footer.php");
    }elseif($_GET['act'] == 'gg'){
        include('api_head.php');
        include('mode/gg_view.php');
        include("api_footer.php");
        
    }elseif($_GET['act'] == 'load_gg'){
        $u = $_POST['username'];
        $p = $_POST['password'];
        $db = db('app_gg');
        $vo = $db->where(["daili"=>DID])->order('id DESC')->find();
        $is_read = db("app_read")->where(array("readid"=>$vo["id"],"username"=>$u))->find();
        if($vo && !$is_read){
            die(json_encode(array('status'=>'success','url'=>'http://'.$_SERVER["HTTP_HOST"].'/app_api/api.php?act=gg&id='.$vo['id'].'&username='.$u.'&','title'=>$vo['name'],'content'=>$vo['content'])));
        }else{
            die(json_encode(array('status'=>'error','url'=>'no data','title'=>'no data')));
        }
        
    }elseif($_GET['act'] == 'load_info'){
        $u = @$_POST['username'];
        $p = @$_POST['password'];
        $ud = new U($u,$p,true);
        $u = db(_openvpn_)->where(array(_iuser_=>$u,_ipass_=>$p))->find();
        if($u){
            #$now = getInfo_i($_POST['username']);
            $uinfo = $u;
            
            $count =  printmb($uinfo[_maxll_]);    
            $isuse = printmb($uinfo[_irecv_]+$uinfo[_isent_]);    
            $sy = printmb($uinfo[_maxll_]-($uinfo[_irecv_]+$uinfo[_isent_]));
        
            
            $upload = printmb($uinfo[_irecv_]);
            $download = printmb($uinfo[_isent_]);
            //system("/home/wwwroot/default/res/sha ".$u[_iuser_]);
            if($sy['n'] <= 0 && $sy['p'] == 'M'){
                $t = 'tips_user';
                $s = round($sy['n'],1).$sy['p'];
            }elseif($sy['n'] <= 100 && $sy['p'] == 'M'){
                $t = 'tips_user';
                $s = round($sy['n'],1).$sy['p'];
            }else{
                $t = 'success';
                $s = round($sy['n'],1).$sy['p'];
            }
            $_sy = $ud->getDatadays();
            $_all = $uinfo[_maxll_] >= _MAX_LIMIT_*1024*1024*1024 ? "NO_LIMIT" : $s;
            die(json_encode(array('status'=>$t,'all'=>$uinfo[_maxll_]-($uinfo[_irecv_]+$uinfo[_isent_]),'sy'=>$_all,'stime'=>'2','etime'=>'2','bl'=>$_sy."天")));
            exit;
        }else{
            
            die(json_encode(array('status'=>'success','all'=>'0','sy'=>'未知','stime'=>'2','etime'=>'2','bl'=>$_sy."天")));
            exit;
        }
        
    //=======================================
    }elseif($_GET['act'] == 'top'){
        include('api_head.php');
        include('mode/top.php');
        include("api_footer.php");
    }elseif($_GET['act'] == 'log'){
        include('api_head.php');
        include('mode/log.php');
        include("api_footer.php");
    }elseif($_GET['act'] == 'login_in'){
        
        $u = $_POST['username'];
        $p = $_POST['password'];
        
        $ud = new U($u,$p,true);

        if($ud->isuser){
            $uinfo = $ud->getNative();
            $sydata =$ud->getDatasurplus();
            $_sy = $ud->getDatadays();
            $max = $ud->getDatamax();
            $count =  printmb($max);
            $isuse = printmb($ud->getDataused());
            $sy = printmb($sydata);
            $s = $count>=_MAX_LIMIT_*1024*1024*1024 ? "NO_LIMIT" : round($sy['n'],1)." ".$sy['p'];
            die(json_encode(array(
                'status'=>'success',
                'msg'=>base64_encode($u[_iuser_]."\n".$u[_ipass_]."\n".round($sy['n'],1).$sy['p']."\n".$count."\n".round($_sy,0)),
                'username'=>$uinfo[_iuser_],
                'password'=>$uinfo[_ipass_],
                'liuliang'=>$s,
                'all'=>$sydata,
                'bl'=>$_sy."天"
            )));
            
        }else{
            die(json_encode(array(
                'status'=>'error',
                'msg'=>'用户不存在或者密码错误'
            )));
        }
        
    }elseif($_GET['act'] == 'login_check'){
        $u = $_POST['username'];
        $p = $_POST['pass'];
        //echo "系统紧急调试 请稍等几分钟";
        //    exit;
        $ud = new U($u,$p,true);
        include("Splash.php");
        $yes = $data["status"] == "success" ? "yes" : "no";
        $url = $data["url"];
        if($ud->isuser){
            
            $uinfo = $ud->getNative();
            
            $sydata =$ud->getDatasurplus();
            $_sy = $ud->getDatadays();
            $max = $ud->getDatamax();
            $count =  printmb($max);
            $isuse = printmb($ud->getDataused());
            $sy = printmb($sydata);
            
            
            $s = $max>=_MAX_LIMIT_*1024*1024*1024 ? "NO_LIMIT" : round($sy['n'],1)." ".$sy['p'];
            $data = "success_need_login\n";
            $data .= $uinfo[_iuser_]."\n";
            $data .= $uinfo[_ipass_]."\n";
            $data .= $s."\n";
            $data .= $sydata."\n";
            $data .= $_sy."天\n";
            $data .= $yes."\n";
            $data .= $url;
            
            die($data);
            
            exit;
        }else{
            $data = "error_need_login\n";
            $data .= "0\n";
            $data .= "0\n";
            $data .= "0\n";
            $data .= "0\n";
            $data .= "0\n";
            $data .= $yes."\n";
            $data .= $url;
            
            die($data);
            exit;
        }
        
        
        
    //=======================================
    }elseif($_GET['act'] == 'theme'){
        include('api_head.php');
        include('mode/theme.php');    
        include("api_footer.php");
    }elseif($_GET['act'] == 'help'){
        include('api_head.php');
        include('mode/help.php');    
        include("api_footer.php");
    }elseif($_GET['act'] == 'more'){
        include('api_head.php');
        include('mode/all.php');
        include("api_footer.php");  
    }else{
        include('api_head.php');
        echo "页面走丢啦";
        include("api_footer.php");  
    } ?>



上一篇:腾讯云短信接口api
下一篇:用户手机号验证入库和用户抽奖系统
这家伙太懒了,什么也没留下。
最新回复 (0)
返回