Z-Blog有著豐富和強大的可定制性,是一款友好的后臺管理系統,支持多種數據庫格式,自帶多款簡約而不簡單的主題模板。小編對這款系統還比較了解,Z-Blog有許多第三方開發的免費模板,安裝方式簡單易用。今天就為大家介紹其中的一款插件,短信寶短信插件。
插件目錄結構如下
├─smsbao插件目錄
│ ├─include.php 核心發送短信
│ ├─main.php 短信寶設置頁面
│ ├─plugin.xml 短信寶插件信息描述
│ ├─logo.png 圖標
下面具體給大家說一下每個文件的作用及代碼,include.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
|
<?php #注冊插件 RegisterPlugin( "smsbao" , "ActivePlugin_smsbao" ); function ActivePlugin_smsbao() {} function InstallPlugin_smsbao() {} function UninstallPlugin_smsbao() {} function sendSms($SignName,$Smsparam,$tomobile,$Template){ global $zbp; if ((int)$zbp->Config( 'smsbao' )->istop){ if (!empty($SignName) && !empty($Smsparam) && !empty($tomobile) && !empty($Template)){ $params = json_decode($Smsparam, true ); $user = $zbp->Config( 'smsbao' )->appkey; //短信平臺帳號 $pass = md5($zbp->Config( 'smsbao' )->secret); //短信平臺密碼 $content = str_replace( '${code}' ,$params[ 'code' ],$Template); $content= '【' .$SignName. '】' .$content; //要發送的短信內容 $phone = $tomobile; //要發送短信的手機號碼 $apiurl = $smsapi. "sms?u=" .$user. "&p=" .$pass. "&m=" .$phone. "&c=" .urlencode($content); $ajax = Network::Create(); if (!$ajax) { return null ; } $ajax->open( 'GET' , $apiurl); $ajax->enableGzip(); $ajax->setTimeOuts(60, 60, 0, 0); $ajax->send(); return $ajax->getBody(); } else { return '任何一項都不能為空' ; } } else { return '沒有開啟短信發送' ; } } |
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
57
58
59
60
61
|
<?php require '../../../zb_system/function/c_system_base.php' ; require '../../../zb_system/function/c_system_admin.php' ; $zbp->Load(); $action= 'root' ; if (!$zbp->CheckRights($action)) {$zbp->ShowError(6);die();} if (!$zbp->CheckPlugin( 'smsbao' )) {$zbp->ShowError(48);die();} $blogtitle= 'smsbao' ; if (count($_POST)>0){ $zbp->Config( 'smsbao' )->istop=$_POST[ 'istop' ]; $zbp->Config( 'smsbao' )->appkey=$_POST[ 'appkey' ]; $zbp->Config( 'smsbao' )->secret=$_POST[ 'secret' ]; $zbp->SaveConfig( 'smsbao' ); $zbp->SetHint( 'good' ); Redirect( './main.php' ); } require $blogpath . 'zb_system/admin/admin_header.php' ; require $blogpath . 'zb_system/admin/admin_top.php' ; ?> <div id= "divMain" > <div class= "divHeader" ><?php echo $blogtitle;?></div> <div class= "SubMenu" ></div> <div id= "divMain2" > <form id= "edit" name= "edit" method= "post" action= "#" > <input id= "reset" name= "reset" type= "hidden" value= "" /> <table border= "1" class= "tableFull tableBorder" > <tr> <td class= "td30" ><p align= 'left' ><b>是否開啟</b></p></td> <td><input type= "text" name= "istop" value= "<?php echo $zbp->Config('smsbao')->istop;?>" style= "width:89%;" class= "checkbox" /></td> </tr> <tr> <td class= "td30" ><p align= 'left' ><b>短信寶賬號</b></p></td> <td><input type= "text" name= "appkey" value= "<?php echo $zbp->Config('smsbao')->appkey;?>" style= "width:89%;" /></td> </tr> <tr> <td class= "td30" ><p align= 'left' ><b>短信寶密碼</b></p></td> <td><input type= "text" name= "secret" value= "<?php echo htmlspecialchars($zbp->Config('smsbao')->secret);?>" style= "width:89%;" /></td> </tr> </table> 使用說明:<br> 3、申請簽名<br> 4、申請短信模板。<br> 5、調用格式:<br> Sendsms(短信簽名,傳遞參數,手機號,短信模板);<br> 案例:Sendsms( '短信寶' , '{"code":"1234"}' , '12345678923' , '您的驗證碼為${code}' );<br> 模板案例:您的驗證碼是${code},請不要把驗證碼泄漏給其他人,10分鐘內有效,如非本人請勿操作 <br> <hr/> <p> <input type= "submit" class= "button" value= "<?php echo $lang['msg']['submit']?>" /> </form> <script type= "text/javascript" >ActiveLeftMenu( "aPluginMng" );</script> <script type= "text/javascript" >AddHeaderIcon( "<?php echo $bloghost . 'zb_users/plugin/smsbao/logo.png';?>" );</script> </div> </div> <?php require $blogpath . 'zb_system/admin/admin_footer.php' ; RunTime(); ?> |
plugin.xml 文件是短信寶信息描述文件,代碼如下:
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
|
<?xml version= "1.0" encoding= "utf-8" ?> <plugin version= "php" > <id>smsbao</id> <name>短信寶SMS短信接口</name> <url>https: //www.gjrencai.com/</url> <note>SMS短信接口</note> <description></description> <path>main.php</path> <include>include.php</include> <level>1</level> <author> <name>短信寶</name> <url>https: //www.gjrencai.com/</url> </author> <source> <name></name> <url></url> </source> <adapted>151935</adapted> <version>1.0</version> <pubdate>2023-06-10</pubdate> <modified>2023-06-10</modified> <price>0</price> <phpver>5.2</phpver> <advanced> <dependency></dependency> <rewritefunctions></rewritefunctions> <existsfunctions></existsfunctions> <conflict></conflict> </advanced> <sidebars> <sidebar1></sidebar1> <sidebar2></sidebar2> <sidebar3></sidebar3> <sidebar4></sidebar4> <sidebar5></sidebar5> </sidebars> </plugin> |
經過上面的替換,短信寶的短信平臺已經替換成功了,可以正常使用了。進行測試發送:
報備一下短信寶的VIP模板,這樣就可以走短信寶的優質通道了,即便遇到敏感文字我們都不會人工審核,短信內容3~5秒就可送達。
另外:我們已經開發好完整的Z-BlogPHP1.7.3系統短信寶插件,點擊此鏈接?下載及查看安裝流程。
最新更新
電商類
CMS類
微信類