帝国CMS是基于B/S结构,安全、稳定、强大、灵活的网站管理系统.还提供了系统扩展框架。小编对这款系统还比较了解,今天就以增加手机登录为例为大家讲解一下如何进行二次开发,我们

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

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

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

 

  <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代码
 

 <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行左右新增反馈表单验证方法

 

elseif ($enews=='Backsend')
{
    $tel=$_GET['phone'];
    F_rzms($tel);
}

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

 

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 新增反馈手机验证码发送方法
 

//反馈发送验证码
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("发送失败,请联系管理员!");
        }
    }
}

帝国cms反馈信息手机短信验证码功能 - 小闻网
好了经过以上的添加,短信宝反馈表单增加手机验证就已经安装成功,可以正常使用了

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

 

声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。