zzzphp是一款開源的跨平臺網(wǎng)站內(nèi)容管理系統(tǒng),他是基于PHP+MYSQL開發(fā)的 ,是一套非常適合用做系統(tǒng)建站或者進行二次開發(fā)的程序核心,小編對他還是比較了解的,今天小編就以新增短信接口為例,給大家講解一下如何進行二次開發(fā),我們今天講解的是1.7.0版本,使用的短信接口是我們短信寶短信群發(fā)平臺的短信接口,我們短信寶短信群發(fā)平臺的接口非常穩(wěn)定,發(fā)送速度快,注冊就送測試短信,推薦大家使用。
首先打開項目:\admin\template\systemedit.tpl 修改一下代碼
|
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
|
<div class="show-[c:smsmark]" id="showsms"> <div class="form-group"> <label class="col-sm-2 control-label">短信寶賬號</label> <div class="col-sm-4"> <input type="text" value="[c:smsid]" name="smsid" id="smsid" class="form-control"> </div> <span class="help-block m-b-none"><i class="fa fa-info-circle"></i>還沒有注冊賬號<a href="http://www.gjrencai.com/register.jhtml" style="border-top-color: #d21a31">立即注冊</a> </span> </div> <div class="form-group"> <label class="col-sm-2 control-label">密碼</label> <div class="col-sm-4"> <input type="text" value="[c:smspw]" name="smspw" id="smspw" class="form-control"> </div> <span class="help-block m-b-none"><i class="fa fa-info-circle"></i> 32位字母數(shù)字組合</span> </div> <div class="form-group"> <label class="col-sm-2 control-label">短信寶簽名</label> <div class="col-sm-4"> <input type="text" value="[c:smsing]" name="smsing" id="smsing" class="form-control"> </div> <div class="form-group"> <label class="col-sm-2 control-label">注冊短信驗證</label> <div class="col-sm-1" > <input type="checkbox" name="regsendsms" value="1" class="js-switch" {$check_onoff [c regsendsms],"checked"}> <span class="help-block m-b-none">開啟</span> </div> <label class="col-sm-2 control-label">找回密碼驗證</label> <div class="col-sm-1" > <input type="checkbox" name="forgetsendsms" value="1" class="js-switch" {$check_onoff [c forgetsendsms],"checked"} > <span class="help-block m-b-none">開啟</span> </div> </div> <div class="form-group"> <label class="col-sm-2 control-label">測試短信配置</label> <div class="col-sm-2" > <input type="text" id="testphone" name="testphone" placeholder="手機號" class="form-control"> </div> <div class="col-sm-4"> <button type="button" class="btn btn-info" id="trysms"><i class="fa fa-commenting"></i> 發(fā)送測試短信</button> </div> </div> <div class="form-group"> <label class="col-sm-2 control-label">余額</label> <div class="col-sm-2" > <input type="button" class="btn btn-outline btn-danger" id="smsnum" value="查詢"> </div> </div> <div class="form-group"> <label class="col-sm-2 control-label">發(fā)送記錄</label> <div class="col-sm-2" > <button type="button" onClick="opennew('../plugins/sms/sms_list.php')" class="btn btn-outline btn-success">查看發(fā)送記錄</button> </div> </div> </div></div> |
打開項目:\admin\save.php 修改代碼
|
1
2
3
4
5
6
7
8
9
|
$smsmark=getform('smsmark','post');$smsid=getform('smsid','post');$smspw=getform('smspw','post');$smsing=getform('smsing','post');//if (strlen($smsid)<5 || strlen($smspw)<32) $smsmark=0;'smsmark' => $smsmark , 'smsid' => $smsid , 'smspw' => $smspw , 'smsing' => $smsing , |
打開項目:\inc\zzz_main.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
|
function send_smsBao($mobile,$content){ if ( conf( 'smsmark' ) == 0 )exit; $t0 = time(); $t1 = get_session( 'smstime' ); $t2 = 59 - ( $t0 - $t1 ); $ip = ip(); if ( $t2 > 0 )die( '0請等待' . $t2 . '秒再嘗試' ); if ( empty( $_SESSION[ 'code' ] ) )die( '0警報:正在嘗試刷短信,已通知管理員并將你加入黑名單。' ); $prevtime = strtotime( db_select( 'sms', 'smsaddtime', array( 'smsip' => $ip ), array( 'id' => 'desc' ) ) ); $t3 = $t0 - $prevtime; if ( $t3 < 60 )die( '0請不要嘗試連續(xù)請求!' ); $smsid = conf( 'smsid' ); $smspw = md5(conf( 'smspw' )); $smsing = conf('smsing'); $content = '【'.$smsing.'】'.$content; $sendurl = $url."sms?u=".$smsid."&p=".$smspw."&m=".$mobile."&c=".urlencode($content); $result =file_get_contents($sendurl); switch ( $result ) { case "0": $tempstr = "1發(fā)送成功"; break; case "-1": $tempstr = "0參數(shù)不全"; break; case "-2": $tempstr = "0服務(wù)器空間不支持,請確認支持curl或者fsocket,聯(lián)系您的空間商解決或者更換空間!"; break; case "30": $tempstr = "密碼錯誤"; break; case "40": $tempstr = "0賬號不存在"; break; case "-5": $tempstr = "0內(nèi)容過長"; break; case "41": $tempstr = "0余額不足"; break; case "42": $tempstr = "0帳戶已過期"; break; case "43": $tempstr = "0IP地址限制"; break; case "50": $tempstr = "0內(nèi)容含有敏感詞"; break; default: $tempstr = "0未知錯誤"; } set_session( 'smstime', $t0 ); db_exec( "insert into [dbpre]sms(smsmobile,smscontent,smsip,smsaddtime,smsbackinfo,smsonoff,smsid,smspw)values('" . $mobile . "','" . $content . "','" . $ip . "','" . date( 'Y-m-d H:i:s' ) . "','" . $tempstr . "'," . cleft( $tempstr, 0, 1 ) . ",'" . $smsid . "','" . hidestr( $smspw, 8 ) . "')" ); return $tempstr;} |
打開項目:\plugins\sms\sms.php 修改下其中代碼
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
|
function try_sms(){ $mobile= getform("mobile",'post'); return send_smsBao($mobile,'這是一條測試短信,您的驗證碼是1234。');}function sendcode(){ $smsphone=getform("phonenum","both"); $smscode= randname(4,'num'); $smsdata=send_smsBao($smsphone,"驗證碼為".$smscode.",有效期10分鐘,請不要把驗證碼泄露給其他人。"); set_session("smscode",$smscode); set_session("smsphone",$smsphone); echo $smsdata;} |
打開項目:\plugins\sms\sms.js 修改下其中代碼
|
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
|
function sendCode(obj){ var phonenum = $("#phonenum").val(); if (phonenum.length !=11){ layer.open({content:'請先填寫正確的手機號!'}); $("#phonenum").blur() return false; } if ( $("#imgcode").length > 0 ) { var code = $("#imgcode").val(); if (code.length!=4){ layer.open({content:'請先填寫圖形驗證碼'}); $("#imgcode").blur() return false; }else{ $.post("/zzzphp/plugins/sms/sms.php?act=getcode",function(imgcode){ if (imgcode!=code){ layer.open({content:'請?zhí)顚懻_的驗證碼!'}); $("#imgcode").blur() } }); } } var result = isPhoneNum(); if (result) { $.post("/zzzphp/plugins/sms/sms.php?act=sendcode&phonenum=" + phonenum, function(data) { var act = data.substring(0, 1); var info = data.substring(1); if (act == 1) { addCookie("secondsremained", 60, 60); //添加cookie記錄,有效時間60s settime(obj); //開始倒計時 } else if (act == 0) { layer.open({ content: info }) }; }); }} |
打開項目:\config\zzz_config.php 添加一下短信配置代碼
|
1
2
3
4
5
6
7
8
|
//短信'smsmark'=>'1',//短信開關(guān)'smsid'=>'',//短信接口賬號'smspw'=>'',//短信接口密碼'smsing'=>'','regsendsms'=>'1',//注冊發(fā)送驗證碼'forgetsendsms'=>'1',//忘記密碼發(fā)送驗證碼'plugurl'=>'zzzcms.com', //授權(quán)域名,只填寫主域名即可,不加www |
經(jīng)過上面的替換,短信寶的短信平臺已經(jīng)替換成功了,可以正常使用了。
報備一下短信寶的VIP模板,這樣就可以走短信寶的優(yōu)質(zhì)通道了,即便遇到敏感文字我們都不會人工審核,短信內(nèi)容3~5秒就可送達。
另外:我們已經(jīng)開發(fā)好完整的zzzPhp系統(tǒng)短信寶插件,點擊此鏈接 下載及查看安裝流程。
最新更新
電商類
CMS類
微信類