齐博CMS系统是国内领先的开源内容管理系统之一,采用核心+插件+频道模块的系统架构,同时再结合独创的可视化标签技术,你可以演变成各种企业、政府、教育、单位、学校网站,便于二次开发,今天小编就以新增短信接口为例,一步步教大家如何进行二次开发,我们使用的短信接口是我们短信宝短信群发平台的短信接口,我们短信宝短信群发平台非常稳定,短信发送速度快,注册就送测试短信,推荐大家使用。
下面我们进行开发,首先我们需要在后台增加我们短信宝配置信息,修改后台显示界面,打开项目\admin\template\center\sms.htm文件,将以下代码进行覆盖替换:
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
|
< table width = "100%" border = "0" cellspacing = "1" cellpadding = "3" class = "tablewidth" style = 'TABLE-LAYOUT: fixed;WORD-WRAP: break-word' > < form name = "form_work" method = "post" action = "index.php?lfj=$lfj&action=config" > < tr class = "head" > < td colspan = "2" align = "center" >手机短信接口资料配置</ td > </ tr > < tr bgcolor = "#FFFFFF" > < td align = "left" width = "18%" >手机短信接口提供商:</ td > < td align = "left" width = "82%" > < a href = "index.php?lfj=$lfj&action=delete_admin_logs&iddb[{$rs[id]}]=1" ></ a > < input type = "radio" name = "webdbs[sms_type]" value = "smsbao" onclick = "choose_sms('smsbao')" $sms_type[smsbao]>短信宝短信平台(< a href = "http://www.smsbao.com/" target = "_blank" >< u >官网</ u ></ a >) </ td > </ tr > < tr bgcolor = "#FFFFFF" id = "smsbao_1" style = "display: none;" > < td align = "left" width = "18%" >短信宝用户名:</ td > < td align = "left" width = "82%" > < input type = "text" name = "webdbs[sms_smsbao_user]" value = "$webdb[sms_smsbao_user]" > </ td > </ tr > < tr bgcolor = "#FFFFFF" id = "smsbao_2" style = "display: none;" > < td align = "left" width = "18%" >短信宝密码:</ td > < td align = "left" width = "82%" > < input type = "text" name = "webdbs[sms_smsbao_pass]" value = "$webdb[sms_smsbao_pass]" > </ td > </ tr > < tr bgcolor = "#FFFFFF" id = "smsbao_3" style = "display: none;" > < td align = "left" width = "18%" >短信宝签名:</ td > < td align = "left" width = "82%" > < input type = "text" name = "webdbs[sms_smsbao_sign]" value = "$webdb[sms_smsbao_sign]" > </ td > </ tr > < tr bgcolor = "#FFFFFF" > < td align = "left" width = "18%" > </ td > < td align = "left" width = "82%" > < input type = "submit" name = "Submit" value = "提交" > < script language = "JavaScript" > function choose_sms(type){ if(type == 'smsbao'){ get_obj('smsbao_1').style.display=""; get_obj('smsbao_2').style.display=""; get_obj('smsbao_3').style.display=""; get_obj('eshang8_1').style.display="none"; get_obj('eshang8_2').style.display="none"; get_obj('ccell_1').style.display="none"; get_obj('ccell_2').style.display="none"; get_obj('winic_1').style.display="none"; get_obj('winic_2').style.display="none"; } } choose_sms('$webdb[sms_type]'); </ script > </ td > </ tr > </ form > </ table > < table width = "100%" border = "0" cellspacing = "1" cellpadding = "3" class = "tablewidth" style = 'TABLE-LAYOUT: fixed;WORD-WRAP: break-word' > < tr class = "head" > < td align = "left" >帮助说明</ td > </ tr > < tr bgcolor = "#FFFFFF" > < td align = "left" >要使用手机短信功能,你必须选择一个短信接口平台提供商,选择之后,你需要去对应的提供商官方网站注册一个帐号,然后他会分配给你帐号与密码.然后把他填入到以上表格里,最后再给相应的接口平台充值,才能成功的发送短信.</ td > </ tr > </ table > |
接下来我们需要修改调用短信接口的文件,打开项目\inc\job\regsendnum.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
|
<?php !function_exists( 'html' ) && exit ( 'ERR' ); //当前文件是注册时通过手机或邮箱获取注册码的功能 if (!is_table( "{$pre}regnum" )){ $db ->query("CREATE TABLE `{ $pre }regnum` ( `sid` varchar( 8 ) NOT NULL default '' , `num` varchar( 6 ) NOT NULL default '' , `posttime` int( 10 ) NOT NULL default '0' , UNIQUE KEY `sid` ( `sid` ) , KEY `posttime` ( `num` , `posttime` ) ) ENGINE = HEAP"); } if (! $webdb [yzNumReg]){ showerr( '系统没开放这个功能!' ); } $time = $timestamp -60; if ( $db ->get_one( "SELECT * FROM {$pre}regnum WHERE sid='$usr_sid' AND posttime>$time" )){ showerr( "如果你的注册码还没有收到的话?请一分钟后再重发!" ); } $randNum = rands(2). substr (mymd5( $num ),0,2); $content = $webdb [ 'webname' ]. "提供给您的注册码是:(" . $randNum . ")这四位数" ; if ( $webdb [ 'yzNumReg' ]==2){ if (! ereg ( "^1([0-9]{10})$" , $num )){ showerr( '手机号码有误!' . $num ); } if (sms_send( $num , $content )){ $db ->query( "REPLACE INTO `{$pre}regnum` ( `sid` , `num` , `posttime` ) VALUES ('$usr_sid', '$randNum', '$timestamp')" ); showerr( "信息已经成功发送到您指定的手机号码中,请注意查收,有可能会延迟几分钟,请耐心等待!" ,1); } else { showerr( "信息发送失败,可能是手机短信接口有问题!" ); } } elseif ( $webdb [ 'yzNumReg' ]==1){ $email = $num ; $title = $webdb [ 'webname' ]. "提供给你的注册码信息" ; if (send_mail( $email , $title , $content , $ifcheck =1)){ $db ->query( "REPLACE INTO `{$pre}regnum` ( `sid` , `num` , `posttime` ) VALUES ('$usr_sid', '$randNum', '$timestamp')" ); showerr( "注册码信息已经成功发送到您的邮箱中,请注意查收" ,1); } else { showerr( "信息发送失败,可能是邮件发送功能配置有误!" ); } } ?> |
最后我们去修改发送短信接口,打开项目\inc\function.inc.php文件,修改sms_send方法,将下列代码进行替换:
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
|
//发送手机短信 function sms_send( $mob , $content ){ global $webdb ; if ( $webdb [sms_type] == 'smsbao' ){ if (WEB_LANG!= 'utf-8' ){ $content = gbk2utf8( $content ); } $url = "http://api.smsbao.com/sms?u=$webdb[sms_smsbao_user]&p=" .md5( $webdb [sms_smsbao_pass]). "&m=$mob&c=【$webdb[sms_smsbao_sign]】$content" ; if (function_exists( 'file_get_contents' )) { $ret = file_get_contents ( $url ); } else { $curl = curl_init(); curl_setopt( $curl , CURLOPT_URL, $url ); curl_setopt( $curl , CURLOPT_SSL_VERIFYPEER, false); curl_setopt( $curl , CURLOPT_SSL_VERIFYHOST, false); curl_setopt( $curl , CURLOPT_RETURNTRANSFER, 1); $ret = curl_exec( $curl ); curl_close( $curl ); } if ( $ret == 0) { return 1; } else { return $ret ; } } else { showerr( "系统没有选择短信接口平台!" ); } } |
好了经过以上的替换,短信宝短信平台已经新增完成了,我们去进行测试发送:
报备一下短信宝的VIP模板,这样就可以走短信宝的优质通道了,并且免审核了,短信内容3~5秒就可送达。
另外:我们已经开发好完整的齐博整站cms短信宝插件,点击此链接 下载及查看安装流程。
最新更新
电商类
CMS类
微信类