待发短信

在线客服
产品支持 短信宝客服
合作渠道 渠道合作
服务咨询

4001-021-502

工作时间

9:00-21:00

帝国CMS_V7.5反馈表单新增手机验证

帝国CMS是基于B/S结构,安全、稳定、强大、灵活的网站管理系统.还提供了系统扩展框架。小编对这款系统还比较了解,今天就以增加手机登录为例为大家讲解一下如何进行二次开发,我们今天讲解的是7.5版本,使用的短信接口是我们短信宝短信群发平台的短信接口,我们短信宝短信群发平台非常稳定,发送速度快,注册就送测试短信,推荐大家使用!

需求介绍:反馈表单新增手机验证码校验手机号的真假

首先打开项目:\e\tool\feedback\temp\feedback1.php 在29行左右新增手机验证页面

?
1
2
3
4
5
6
7
8
9
10
    <tr>
      <td width='16%' height=25 bgcolor='ffffff'><div align="right">联系电话:</div></td>
      <td bgcolor='ffffff'><input name='mycall' id="phone" type='text' size='42'>
        (*)</td>
    </tr>
      <tr>
          <td width='16%' height="25" bgcolor="#FFFFFF"> <div align='right'>验证码</div></td>
          <td height="25" bgcolor="#FFFFFF"> <input name='rzm' type='text' id='rzm' maxlength='30'>
              *<input  type="button" style="font-size: 12px; height: 22px; line-height: 19px;" value="发送验证码" onclick="sendrzm()" id="sendag"  ></td>
      </tr>

在此文件58行左右新增JavaScript代码

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
    <script src="/js/jquery.min-1.7.2.js"></script>
    <SCRIPT language=javascript>
        <!--
        var secs = 60;
        function sendrzm(){
            var tel=$("#phone").val();
            if($.trim(tel)==''||$.trim(tel).length!=11){
                alert('请填写正确的手机号码');
            }else{
                $.getJSON('/e/member/doaction.php?enews=Backsend&phone=' + tel + '',
                    function(data) {
                       console.log(data);
                        if(data.d=='2'){
                            alert(data.n);
                        }else{
                            document.feedback.sendag.disabled=true;
                            for(i=1;i<=secs;i++) {
                                window.setTimeout("update(" + i + ")", i * 1000);
                            }
                        }
 
 
                    });
            }
        }
        function update(num) {
 
 
            if(num == secs) {
                document.feedback.sendag.value ="重新发送验证码";
                document.feedback.sendag.disabled=false;
            }
            else {
                printnr = secs-num;
                document.feedback.sendag.value = "(" + printnr +")重新发送验证码";
            }
        }
        //-->
    </SCRIPT>
<? include("../../data/template/cp_2.php");?>

打开项目:\e\member\doaction.php 在194行左右新增反馈表单验证方法

?
1
2
3
4
5
elseif ($enews=='Backsend')
{
    $tel=$_GET['phone'];
    F_rzms($tel);
}

打开项目:\e\class\q_functions.php 修改反馈信息的方法

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
function AddFeedback($add){
    global $empire,$dbtbpre,$level_r,$public_r;
    CheckCanPostUrl();//验证来源
    if($add['bid'])
    {
        $bid=(int)$add['bid'];
    }
    else
    {
        $bid=(int)getcvar('feedbackbid');
    }
    //验证手机验证码
    $tel=$add['mycall'];
    $rzm=$add['rzm'];
    C_sjrs($tel,$rzm);
    if(empty($bid))
    {
        printerror("EmptyFeedbackname","history.go(-1)",1);
    }
    //验证码
    $keyvname='checkfeedbackkey';
 
 
    if($public_r['fbkey_ok'])
    {
        ecmsCheckShowKey($keyvname,$add['key'],1);
    }
    //版面是否存在
    $br=$empire->fetch1("select bid,enter,mustenter,filef,groupid,checkboxf from {$dbtbpre}enewsfeedbackclass where bid='$bid';");
    if(empty($br['bid']))
    {
        printerror("EmptyFeedback","history.go(-1)",1);
    }
    //权限
    $user=array();
    if($br['groupid'])
    {
        $user=islogin();
        if($level_r[$br[groupid]][level]>$level_r[$user[groupid]][level])
        {
            printerror("HaveNotEnLevel","history.go(-1)",1);
        }
    }
    //实名验证
    eCheckHaveTruename('fb',$user['userid'],$user['username'],$user['isern'],$user['checked'],0);
 
 
    $pr=$empire->fetch1("select feedbacktfile,feedbackfilesize,feedbackfiletype from {$dbtbpre}enewspublic limit 1");
    //必填项
    $mustr=explode(",",$br['mustenter']);
    $count=count($mustr);
    for($i=1;$i<$count-1;$i++)
    {
        $mf=$mustr[$i];
        if(strstr($br['filef'],",".$mf.","))//附件
        {
            if(!$pr['feedbacktfile'])
            {
                printerror("NotOpenFBFile","",1);
            }
            if(!$_FILES[$mf]['name'])
            {
                printerror("EmptyFeedbackname","",1);
            }
        }
        else
        {
            $chmustval=ReturnFBCheckboxAddF($add[$mf],$mf,$br['checkboxf']);
            if(!trim($chmustval))
            {
                printerror("EmptyFeedbackname","",1);
            }
        }
    }
    $saytime=date("Y-m-d H:i:s");
    //字段处理
    $dh="";
    $tranf="";
    $record="<!--record-->";
    $field="<!--field--->";
    $er=explode($record,$br['enter']);
    $count=count($er);
    for($i=0;$i<$count-1;$i++)
    {
        $er1=explode($field,$er[$i]);
        $f=$er1[1];
        //附件
        $add[$f]=str_replace('[!#@-','ecms',$add[$f]);
        if(strstr($br['filef'],",".$f.","))
        {
            if($_FILES[$f]['name'])
            {
                if(!$pr['feedbacktfile'])
                {
                    printerror("NotOpenFBFile","",1);
                }
                $filetype=GetFiletype($_FILES[$f]['name']);//取得文件类型
                if(CheckSaveTranFiletype($filetype))
                {
                    printerror("NotQTranFiletype","",1);
                }
                if(!strstr($pr['feedbackfiletype'],"|".$filetype."|"))
                {
                    printerror("NotQTranFiletype","",1);
                }
                if($_FILES[$f]['size']>$pr['feedbackfilesize']*1024)//文件大小
                {
                    printerror("TooBigQTranFile","",1);
                }
                $tranf.=$dh.$f;
                $dh=",";
                $fval="[!#@-".$f."-@!]";
            }
            else
            {
                $fval="";
            }
        }
        else
        {
            $add[$f]=ReturnFBCheckboxAddF($add[$f],$f,$br['checkboxf']);
            $fval=$add[$f];
        }
        $addf.=",`".$f."`";
        $addval.=",'".addslashes(RepPostStr($fval))."'";
    }
    $type=0;
    $classid=0;
    $filename='';
    $filepath='';
    $userid=(int)getcvar('mluserid');
    $username=RepPostVar(getcvar('mlusername'));
    $filepass=ReturnTranFilepass();
    //上传附件
    if($tranf)
    {
        $dh="";
        $tranr=explode(",",$tranf);
        $count=count($tranr);
        for($i=0;$i<$count;$i++)
        {
            $tf=$tranr[$i];
            $tfr=DoTranFile($_FILES[$tf]['tmp_name'],$_FILES[$tf]['name'],$_FILES[$tf]['type'],$_FILES[$tf]['size'],$classid);
            if($tfr['tran'])
            {
                $filepath=$tfr[filepath];
                //写入数据库
                $filetime=$saytime;
                $filesize=(int)$_FILES[$tf]['size'];
                eInsertFileTable($tfr[filename],$filesize,$tfr[filepath],'[Member]'.$username,$classid,'[FB]'.addslashes(RepPostStr($add[title])),$type,$filepass,$filepass,$public_r[fpath],0,4,0);
                $repfval=($tfr[filepath]?$tfr[filepath].'/':'').$tfr[filename];
                $filename.=$dh.$tfr[filename];
                $dh=",";
            }
            else
            {
                $repfval="";
            }
            $addval=str_replace("[!#@-".$tf."-@!]",$repfval,$addval);
        }
    }
    $filepath=dgdb_tosave($filepath);
    $filename=dgdb_tosave($filename);
    $ip=egetip();
    $eipport=egetipport();
    $sql=$empire->query("insert into {$dbtbpre}enewsfeedback(bid,saytime,ip,filepath,filename,userid,username,haveread,eipport".$addf.") values('$bid','$saytime','$ip','$filepath','$filename','$userid','$username',0,'$eipport'".$addval.");");
    $fid=$empire->lastid();
    //更新附件
    UpdateTheFileOther(4,$fid,$filepass,'other');
    ecmsEmptyShowKey($keyvname);//清空验证码
    if($sql)
    {
        //有新的信息反馈时发送短信
        require("../admin/smsbao/Smsbao.php");
        //取出短信配置信息
        $smsbao_config=file_get_contents("../admin/smsbao/config.txt");
        $jiemi = encrypt($smsbao_config, 'D''a');
        $smsbao_config=explode(",", $jiemi);
        //取出商家手机号配置信息
        $sms_shop_config1=file_get_contents("../admin/smsbao/shop.txt");
        $smsbao=new Sms($smsbao_config[0],$smsbao_config[1]);
        $mobiles=explode(',',trim($sms_shop_config1));
        $mobiles=array_unique($mobiles);
        $content="【".$smsbao_config[2]."】您好,收到来自".$add['title']."的信息反馈,请及时查看处理。";
        foreach($mobiles as $key=>$val){
            $sms_res=$smsbao->sendSms($val,$content);
        }
        //发送短信完毕
        $reurl=DoingReturnUrl("../tool/feedback/?bid=$bid",$add['ecmsfrom']);
        printerror("AddFeedbackSuccess",$reurl,1);
    }
    else
    {printerror("DbError","history.go(-1)",1);}
}  

打开项目:\e\class\connect.php 新增反馈手机验证码发送方法

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
//反馈发送验证码
function F_rzms($tel){
    global $empire,$dbtbpre,$public_r;
    $ism=is_mobile($tel);
    if($ism == 2)
    {
        G_return("手机号码为空或者错误!");
    }
    $time=time();
    //识别码
    $gzwc=RepPostVar(getcvar('banksend'));
    $zr=$empire->fetch1("select * from {$dbtbpre}rz where bsm='$gzwc' and sj='$tel'  limit 1");
    if($zr['id']){
        //验证次数
        if($zr['c']>10)
        {
            G_return("该号码已多次接收不了验证码,建议更换手机重新注册!");
        }
        //验证间隔时间
        $gtime2=$zr['t']+60*2;
        if($time<$gtime2)
        {
            G_return("发送过程中,手机接收验证码需要1-2分钟,请耐心等待!");
        }
        $rm=no_make_password(6);
        $content=$rm;
        $fh=api_sendsms($tel,$content);
        if($fh){
            $sql=$empire->query("update {$dbtbpre}rz set t='$time',rzm='$rm',c=c+1 where id='$zr[id]'");
            $logincookie=$time+3600*2;
            $set1=esetcookie("gzwrz",$gzwc,$logincookie);
            G_return("验证码已发送成功,请查收!",1);
        }else{
            G_return("发送失败,请联系管理员!");
        }
    }else{
        $rm=no_make_password(6);
        $content=$rm;
        $fh=api_sendsms($tel,$content);
        if($fh){
            $gzwc=make_password(20);
            $sql=$empire->query("insert into {$dbtbpre}rz(bsm,rzm,sj,t,c) values('$gzwc','$rm','$tel','$time','1');");
            $logincookie=$time+3600*2;
            $set1=esetcookie("banksend",$gzwc,$logincookie);
            G_return("验证码已发送成功,请查收!",1);
        }else{
            G_return("发送失败,请联系管理员!");
        }
    }
}

好了经过以上的添加,短信宝反馈表单增加手机验证就已经安装成功,可以正常使用了

报备一下短信宝的VIP模板,这样就可以走短信宝的优质通道了,即便遇到敏感文字我们都不会人工审核,短信内容3~5秒就可送达。

另外:我们已经开发好完整的帝国CMS系统短信宝插件,点击此链接 下载及查看安装流程。

开源插件

最新更新

电商类

CMS类

微信类

文章标签