大米CMS(又名3gcms)是一个免费开源、快速、简单的PC建站和手机建站集成一体化系统, 致力于为用户提供简单、快捷的PC建站和智能手机建站解决方案。小编对他还是比较了解的,今天小编就以新增短信接口为例,给大家讲解一下如何进行二次开发,我们今天讲解的是V6版本,使用的短信接口是我们短信宝短信群发平台的短信接口,我们短信宝短信群发平台的接口非常稳定,发送速度快,注册就送测试短信,推荐大家使用。
首先打开项目:\Admin\Tpl\default\Config\index.html 在38行增加下代码
1
2
3
4
5
6
7
8
9
|
<ul class = "nav nav-tabs" > <li style= "width:100px;" ><a data-toggle= "tab" ></a></li> <li class = "active" ><a href= "#total_config" data-toggle= "tab" >网站整体配置</a></li> <li><a href= "#home_config" data-toggle= "tab" >首页配置</a></li> <li><a href= "#list_config" data-toggle= "tab" >列表页配置</a></li> <li><a href= "#content_config" data-toggle= "tab" >内容页配置</a></li> <li><a href= "#mail_config" data-toggle= "tab" >邮件发送配置</a></li> <li><a href= "#sms_config" data-toggle= "tab" >短信发送配置</a></li> </ul> |
同时增加下短信配置
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
|
<div class = "tab-pane" id= "sms_config" > <div id= "myTab1_Content3" style= "clear:both;" > <table width= "100%" border= "0" align=center cellpadding= "3" cellspacing= "1" style= "margin:5px 0;background:#FFF" > <tr onMouseOver= "this.style.backgroundColor='#EEFCDD';this.style.color='red'" onMouseOut= "this.style.backgroundColor='';this.style.color=''" > <td width= "40%" align= "right" >短信宝账号: </td> <td align= "center" > </td> <td width= "60%" align= "left" > <input name= "SMS_FROM" type= "text" id= "MAIL_FROM" onFocus= "hSiteTitle.style.color='blue';" onBlur= "hSiteTitle.style.color='#ccc';" value= "" style= "width:300px;" > 还没有注册短信宝账号?<a href= "HTTP://www.smsbao.com/register.jhtml" target= "_blank" style= "color: red;" >立即注册</a> </td> </tr> <tr onMouseOver= "this.style.backgroundColor='#EEFCDD';this.style.color='red'" onMouseOut= "this.style.backgroundColor='';this.style.color=''" > <td width= "40%" align= "right" >短信宝密码: </td> <td align= "center" > </td> <td width= "60%" align= "left" ><input name= "SMS_PASSSWORD" type= "password" id= "MAIL_PASSSWORD" onFocus= "hSiteTitle.style.color='blue';" onBlur= "hSiteTitle.style.color='#ccc';" value= "" style= "width:300px;" ></td> </tr> <tr onMouseOver= "this.style.backgroundColor='#EEFCDD';this.style.color='red'" onMouseOut= "this.style.backgroundColor='';this.style.color=''" > <td width= "40%" align= "right" >短信宝签名: </td> <td align= "center" > </td> <td width= "60%" align= "left" ><input name= "SMS_SING" type= "text" id= "MAIL_PASSSWORD" onFocus= "hSiteTitle.style.color='blue';" onBlur= "hSiteTitle.style.color='#ccc';" value= "" style= "width:300px;" ></td> </tr> <tr class = "css_page_list" > <td height= "30" colspan=3 align= "center" > <input type= "hidden" name= "id" value= "{$list.id}" /> <input name= 'Submit' type= 'submit' class = "btn btn-success" value= ' 保存设置 ' ></td> </tr> </table> </div> </div> |
打开项目:\Admin\Lib\Action\ConfigAction.class.php 新增下代码
1
2
3
|
$configStr = preg_replace( "/'SMS_FROM'=>'.*'/" , "'SMS_FROM'=>'" .htmlspecialchars( $_POST ['SMS_FROM '],ENT_QUOTES)."' ", $configStr ); $configStr = preg_replace( "/'SMS_SING'=>'.*'/" , "'SMS_SING'=>'" .htmlspecialchars( $_POST ['SMS_SING '],ENT_QUOTES)."' ", $configStr ); if (C( 'SMS_PASSSWORD' ) != $_POST [ 'SMS_PASSSWORD' ]){ $configStr = preg_replace( "/'SMS_PASSSWORD'=>'.*'/" , "'SMS_PASSSWORD'=>'" . $_POST ['SMS_PASSSWORD ']."' ", $configStr );} |
打开项目:\Web\Common\common.php 修改发送短信类
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
function send_smsmess( $to_mobile , $content , $isvail =0){ if ( $isvail ==1){ $config = F( 'basic' , '' , './Web/Conf/' ); $mobile_code = mt_rand(1000,9999); $content = "您的验证码是:" . $mobile_code . "。请不要把验证码泄露给其他人。" ; } $user = C( 'SMS_FROM' ); //短信平台帐号 $pass = md5(C( 'SMS_PASSSWORD' )); //短信平台密码 $content = '【' .C( 'SMS_SING' ). '】' . $content ; //要发送的短信内容 $phone = $to_mobile ; //要发送短信的手机号码 $sendurl = $smsapi . "sms?u=" . $user . "&p=" . $pass . "&m=" . $phone . "&c=" .urlencode( $content ); $result = file_get_contents ( $sendurl ) ; //$data = ("account=".C('SMS_FROM')."&password=".C('SMS_PWD')."&mobile=".$to_mobile."&content=".rawurlencode($content));//短信用户名与密码请在这里改 //密码可以使用明文密码或使用32位MD5加密 //$gets = xml_to_array(SPost($data, $target)); //var_dump($gets); if ( $result ==0 && $isvail ==1){ $_SESSION [ 'mobile_verify' ] = md5( $mobile_code ); } return $result ; } |
打开项目:\Public\Config\config.ini.php开启短信配置
1
|
'MOBILE_VERIFY' => '1' , //手机短信验证码 |
经过上面的替换,短信宝的短信平台已经替换成功了,可以正常使用了。
报备一下短信宝的VIP模板,这样就可以走短信宝的优质通道了,即便遇到敏感文字我们都不会人工审核,短信内容3~5秒就可送达。
另外:我们已经开发好完整的大米cms_v6系统短信宝插件,点击此链接 下载及查看安装流程。
最新更新
电商类
CMS类
微信类