微擎系统短信接口替换

分类栏目:技术分享

144

微擎是一款免费开源的公众平台管理系统,基于web2.0技术架构,他有很多的扩展模块,二次开发也非常方便,小编对于这套系统还是比较了解的,今天小编就以替换短信接口为例告诉大家如何进行二次开发,我们讲解的是1.6。3版本,使用的短信接口是我们短信宝短信群发平台的接口,我们短信宝短信群发平台非常稳定,发送速度快,注册就送测试短信,推荐大家使用。

首先我们需要替换一下模版文件,打开项目webthemesdefaultsystemsite.html 文件,替换为以下代码:

?
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
{template 'common/header'}
< div  class = "we7-page-title" >站点设置</ div >
< ul  class = "we7-page-tab" >
         < li {if $do == 'copyright'}  class = "active" {/if}>< a  href = "{php echo url('system/site');}" >站点信息</ a ></ li >
</ ul >
< div  class = "clearfix" >
         < form  action = ""  method = "post"   class = "we7-form"  role = "form"  enctype = "multipart/form-data"  id = "form1" >
                 < div  class = "form-group" >
                         < label  class = "col-sm-2 control-label"  style = "text-align:left;" >关闭站点</ label >
                         < div  class = "col-sm-8 form-control-static" >
                                 < input  type = "radio"  name = "status"  id = "status-1"  {if $settings['status'] == 1}  checked = "checked"  {/if}  value = "1"  />
                                 < label  class = "radio-inline"  for = "status-1" >
                                         
                                 </ label >
                                 < input  type = "radio"  name = "status"  id = "status-0"  {if $settings['status'] == 0}  checked = "checked"  {/if}  value = "0"  /> 
                                 < label  class = "radio-inline"  for = "status-0" >
                                        
                                 </ label >
                         </ div >
                 </ div >
                 < div  class = "form-group reason"  {if $settings['status'] == 0}  style = "display:none;"  {/if}>
                         < label  class = "col-sm-2 control-label"  style = "text-align:left;" >关闭原因</ label >
                         < div  class = "col-sm-8" >
                                 < textarea  style = "height:150px;"  class = "form-control"  cols = "70"  name = "reason"  autocomplete = "off" >{$settings['reason']}</ textarea >
                                 < input  type = "hidden"  name = "reasons"  value = "{$settings['reason']}" >
                         </ div >
                 </ div >
                 < h5  class = "page-header" >登录站点</ h5 >
                 < div  class = "form-group" >
                         < label  class = "col-sm-2 control-label"  style = "text-align:left;" >是否开启验证码</ label >
                         < div  class = "col-sm-8 form-control-static" >
                                 < input  type = "radio"  id = "verifycode-1"  name = "verifycode"  {if $settings['verifycode'] == 1}  checked = "checked"  {/if}  value = "1"  /> 
                                 < label  class = "radio-inline"  for = "verifycode-1" >
                                        
                                 </ label >
                                 < input  type = "radio"  id = "verifycode-0"  name = "verifycode"  {if $settings['verifycode'] == 0}  checked = "checked"  {/if}  value = "0"  /> 
                                 < label  class = "radio-inline"  for = "verifycode-0" >
                                        
                                 </ label >
                         </ div >
                 </ div >
         < h5  class = "page-header" >版权信息</ h5 >
                 < div  class = "form-group" >
                         < label  class = "col-sm-2 control-label"  style = "text-align:left;" >是否显示首页</ label >
                         < div  class = "col-sm-8 form-control-static" >
                                 < input  type = "radio"  name = "showhomepage"  value = "1"  id = "showhomepage_1"  {if !empty($settings['showhomepage'])} checked{/if}>
                                 < label  for = "showhomepage_1"  class = "radio-inline" > 是</ label >
                                 < input  type = "radio"  name = "showhomepage"  value = "0"  id = "showhomepage_2"  {if empty($settings['showhomepage'])} checked{/if}>
                                 < label  for = "showhomepage_2"  class = "radio-inline" > 否</ label >
                                 < div  class = "help-block" >设置“否”后,打开地址时将直接跳转到登录页面,否则会跳转到首页。</ div >
                         </ div >
                 </ div >
                 < div  class = "form-group" >
                         < label  class = "col-sm-2 control-label"  style = "text-align:left;" >网站名称</ label >
                         < div  class = "col-sm-8" >
                                 < input  type = "text"  name = "sitename"  class = "form-control"  value = "{$settings['sitename']}"  />
                         </ div >
                 </ div >
                 < div  class = "form-group" >
                         < label  class = "col-sm-2 control-label"  style = "text-align:left;" >网站URL</ label >
                         < div  class = "col-sm-8" >
                                 < input  type = "text"  name = "url"  class = "form-control"  value = "{$settings['url']}"  />
                         </ div >
                 </ div >
                 < div  class = "form-group" >
                         < label  class = "col-sm-2 control-label"  style = "text-align:left;" >keywords</ label >
                         < div  class = "col-sm-8" >
                                 < input  type = "text"  name = "keywords"  class = "form-control"  value = "{$settings['keywords']}"  />
                         </ div >
                 </ div >
                 < div  class = "form-group" >
                         < label  class = "col-sm-2 control-label"  style = "text-align:left;" >description</ label >
                         < div  class = "col-sm-8" >
                                 < input  type = "text"  name = "description"  class = "form-control"  value = "{$settings['description']}"  />
                         </ div >
                 </ div >
                 < div  class = "form-group" >
                         < label  class = "col-sm-2 control-label"  style = "text-align:left;" >左侧菜单定位</ label >
                         < div  class = "col-sm-8 form-control-static" >
                                 < input  type = "radio"  name = "leftmenu_fixed"  id = "leftmenu_fixed_status-1"  {if $settings['leftmenufixed'] == 1}  checked = "checked"  {/if}  value = "1"  />
                                 < label  class = "radio-inline"  for = "leftmenu_fixed_status-1" >
                                         
                                 </ label >
                                 < input  type = "radio"  name = "leftmenu_fixed"  id = "leftmenu_fixed_status-0"  {if $settings['leftmenufixed'] == 0}  checked = "checked"  {/if}  value = "0"  /> 
                                 < label  class = "radio-inline"  for = "leftmenu_fixed_status-0" >
                                        
                                 </ label >
                                 < span  class = "help-block" >选择“否”并保存后,左侧菜单随页面滚动而上下滚动</ span >
                         </ div >
                 </ div >
                 < div  class = "form-group" >
                         < label  class = "col-sm-2 control-label"  style = "text-align:left;" >后台风格设置</ label >
                         < div  class = "col-sm-8" >
                                 < select  name = "template"  class = "form-control" >
                                         {loop $template $tpl}
                                         < option  value = "{$tpl}"  {if $_W['setting']['basic']['template'] == $tpl}selected{/if}>
                                                 {if !empty($template_ch_name[$tpl])}{$template_ch_name[$tpl]}{else}{$tpl}{/if}
                                         </ option >
                                         {/loop}
                                 </ select >
                                 < span  class = "help-block" >favorite icon</ span >
                         </ div >
                 </ div >
                 < div  class = "form-group" >
                         < label  class = "col-sm-2 control-label"  style = "text-align:left;" >favorite icon</ label >
                         < div  class = "col-sm-8" >
                                 {php echo tpl_form_field_image('icon', $settings['icon'], '', array('global' => true, 'extras' => array('image'=> ' width="32" ')));}
                                 < span  class = "help-block" >favorite icon</ span >
                         </ div >
                 </ div >
                 < div  class = "form-group" >
                         < label  class = "col-sm-2 control-label"  style = "text-align:left;" >前台LOGO</ label >
                         < div  class = "col-sm-8" >
                                 {php echo tpl_form_field_image('flogo', $settings['flogo'], '', array('global' => true));}
                                 < span  class = "help-block" >最佳尺寸:220px*50px</ span >
                                 < span  class = "help-block" >此logo是指首页及登录页面logo。</ span >
                         </ div >
                 </ div >
                 < div  class = "form-group" >
                         < label  class = "col-sm-2 control-label"  style = "text-align:left;" >背景图片</ label >
                         < div  class = "col-sm-8" >
                                 {php echo tpl_form_field_image('background_img', $settings['background_img'], '', array('global' => true));}
                                 < span  class = "help-block" >此图片是指登录页面的背景图。</ span >
                         </ div >
                 </ div >
                 < div  class = "form-group" >
                         < label  class = "col-sm-2 control-label"  style = "text-align:left;" >前台幻灯片</ label >
                         < div  class = "col-sm-8" >
                                 {php echo tpl_form_field_multi_image('slides', $settings['slides'], '', array('global' => true, 'thumb' => 0));}
                                 < span  class = "help-block" >设置首页幻灯片。</ span >
                         </ div >
                 </ div >
                 < div  class = "form-group" >
                         < label  class = "col-sm-2 control-label"  style = "text-align:left;" >前台幻灯片显示文字</ label >
                         < div  class = "col-sm-8" >
                                 < input  type = "text"  class = "form-control"  name = "notice"  value = "{$settings['notice']}" />
                                 < span  class = "help-block" >该文字显示在幻灯片上。</ span >
                         </ div >
                 </ div >
                 < div  class = "form-group" >
                         < label  class = "col-sm-2 control-label"  style = "text-align:left;" >后台LOGO</ label >
                         < div  class = "col-sm-8" >
                                 {php echo tpl_form_field_image('blogo', $settings['blogo'], '', $options = array('global' => true));}
                                 < span  class = "help-block" >最佳尺寸:110px*35px</ span >
                                 < span  class = "help-block" >此logo是指登录后在本系统左上角显示的logo。</ span >
                         </ div >
                 </ div >
                 < div  class = "form-group" >
                         < label  class = "col-sm-2  control-label"  style = "text-align:left;" >第三方统计代码</ label >
                         < div  class = "col-sm-8" >
                                 < textarea  style = "height:150px;"  class = "form-control"  cols = "70"  name = "statcode"  autocomplete = "off" >{$settings['statcode']}</ textarea >
                         </ div >
                 </ div >
                 < div  class = "form-group" >
                         < label  class = "col-sm-2 control-label"  style = "text-align:left;" >底部右侧信息(上)</ label >
                         < div  class = "col-sm-8" >
                                 < textarea  style = "height:150px;"  class = "form-control"  cols = "70"  name = "footerright"  autocomplete = "off" >{$settings['footerright']}</ textarea >
                                 < span  class = "help-block" >自定义底部右侧信息,支持HTML</ span >
                         </ div >
                 </ div >
                 < div  class = "form-group" >
                         < label  class = "col-sm-2 control-label"  style = "text-align:left;" >底部左侧信息(下)</ label >
                         < div  class = "col-sm-8" >
                                 < textarea  style = "height:150px;"  class = "form-control"  cols = "70"  name = "footerleft"  autocomplete = "off" >{$settings['footerleft']}</ textarea >
                                 < span  class = "help-block" >自定义底部左侧信息,支持HTML</ span >
                         </ div >
                 </ div >
                 < div  class = "form-group" >
                         < label  class = "col-sm-2 control-label"  style = "text-align:left;" >联系人</ label >
                         < div  class = "col-sm-8" >
                                 < input  type = "text"  name = "person"  class = "form-control"  value = "{$settings['person']}"  />
                         </ div >
                 </ div >
                 < div  class = "form-group" >
                         < label  class = "col-sm-2 control-label"  style = "text-align:left;" >联系电话</ label >
                         < div  class = "col-sm-8" >
                                 < input  type = "text"  name = "phone"  class = "form-control"  value = "{$settings['phone']}"  />
                         </ div >
                 </ div >
                 < div  class = "form-group" >
                         < label  class = "col-sm-2 control-label"  style = "text-align:left;" >QQ</ label >
                         < div  class = "col-sm-8" >
                                 < input  type = "text"  name = "qq"  class = "form-control"  value = "{$settings['qq']}"  />
                         </ div >
                 </ div >
                 < div  class = "form-group" >
                         < label  class = "col-sm-2 control-label"  style = "text-align:left;" >邮箱</ label >
                         < div  class = "col-sm-8" >
                                 < input  type = "text"  name = "email"  class = "form-control"  value = "{$settings['email']}"  />
                         </ div >
                 </ div >
                 < div  class = "form-group" >
                         < label  class = "col-sm-2 control-label"  style = "text-align:left;" >公司名称</ label >
                         < div  class = "col-sm-8" >
                                 < input  type = "text"  name = "company"  value = "{$settings['company']}"   class = "form-control"  />
                         </ div >
                 </ div >
                 < div  class = "form-group" >
                         < label  class = "col-sm-2 control-label"  style = "text-align:left;" >关于我们</ label >
                         < div  class = "col-sm-8" >
                                 {php echo tpl_ueditor('companyprofile', $settings['companyprofile']);}
                                 < span  class = "help-block" >该文字显示在个人中心->关于我们中</ span >
                         </ div >
                 </ div >
                 < div  class = "form-group" >
                         < label  class = "col-sm-2 control-label"  style = "text-align:left;" >详细地址</ label >
                         < div  class = "col-sm-8" >
                                 < input  type = "text"  name = "address"  value = "{$settings['address']}"   class = "form-control"  />
                         </ div >
                 </ div >
                 < div  class = "form-group" >
                         < label  class = "col-sm-2 control-label"  style = "text-align:left;" >地理位置</ label >
                         < div  class = "col-sm-8" >
                                 {php echo tpl_form_field_coordinate('baidumap', $settings['baidumap'])}
                         </ div >
                 </ div >
                 < div  class = "form-group" >
                         < label  class = "col-sm-2 control-label"  style = "text-align:left;" >短信宝账号</ label >
                         < div  class = "col-sm-8" >
                                 < input  type = "text"  name = "sms_name"  class = "form-control"  value = "{$settings['sms_name']}"  />
                                 < span  class = "help-block" >没有短信宝账号?点击< a  class = "btn btn-primary span3"  target = "_blank"  href = "http://www.smsbao.com" >免费注册</ a ></ span >
                         </ div >
                 </ div >
                 < div  class = "form-group" >
                         < label  class = "col-sm-2 control-label"  style = "text-align:left;" >短信宝密码</ label >
                         < div  class = "col-sm-8" >
                                 < input  type = "password"  name = "sms_password"  class = "form-control"  value = "{$settings['sms_password']}"  />
                         </ div >
                 </ div >
                 < div  class = "form-group" >
                         < div  class = "col-sm-offset-2 col-md-offset-2 col-lg-offset-1 col-xs-12 col-sm-10 col-md-10 col-lg-11" >
                                 < input  name = "submit"  type = "submit"  value = "提交"  class = "btn btn-primary span3"  />
                                 < input  type = "hidden"  name = "token"  value = "{$_W['token']}"  />
                         </ div >
                 </ div >
         </ form >
         < script  type = "text/javascript" >
                         $("#form1").submit(function() {
                                 if ($("input[name='status']:checked").val() == 1) {
                                         if ($("textarea[name='reason']").val() == '') {
                                                 util.message('请填写站点关闭原因');
                                                 return false;
                                         }
                                 }
                         });
                         $("input[name='status']").click(function() {
                                 if ($(this).val() == 1) {
                                         $(".reason").show();
                                         var reason = $("input[name='reasons']").val();
                                         $("textarea[name='reason']").text(reason);
                                 } else {
                                         $(".reason").hide();
                                 }
                         });
         </ script >
</ div >
{template 'common/footer'}

接下来替换项目webthemesdefaultaccountmanage.sms.html文件,替换为以下代码:

?
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
66
67
68
69
70
71
72
{template 'common/header'}
{template 'account/account-header'}
< div  id = "js-account-manage-sms"  ng-controller = "AccountManageSms"  ng-cloak>
         < table  class = "table we7-table table-hover" >
                 < col  width = "200px" />
                 < col  width = "230px" />
                 < tr >
                         < th >剩余条数</ th >
                         < th  class = "text-right" >操作</ th >
                 </ tr >
                 < tr
                         < td  ng-if = "notify.sms" >< span  ng-bind = "notify.sms.balance" >{$notify['balance']}</ span >条</ td >
                         < td  ng-if = "!notify.sms" >0条</ td >
                         < td >
                                 < div  class = "link-group" >
                                         < a  href = "javascript:;"  data-toggle = "modal"  data-target = "#balance"  ng-click = "editSms('balance', notify.sms.balance)" >分配短信</ a >
                                         < a  href = "javascript:;"  data-toggle = "modal"  data-target = "#signature"  ng-click = "editSms('signature', notify.sms.signature)" >设置短信签名</ a >
                                 </ div >
                         </ td >
                 </ tr >
         </ table >
         < div  class = "modal fade"  id = "balance"  tabindex = "-1"  role = "dialog"  aria-hidden = "true" >
                 < div  class = "we7-modal-dialog modal-dialog" >
                         < div  class = "modal-content" >
                                 < div  class = "modal-header" >
                                         < button  type = "button"  class = "close"  data-dismiss = "modal" >< span  aria-hidden = "true" >&times;</ span >< span  class = "sr-only" >Close</ span ></ button >
                                         < div  class = "modal-title" >分配短信</ div >
                                 </ div >
                                 < div  class = "modal-body we7-form" >
                                         < div  class = "form-group" >
                                                 < input  type = "number"  min = "0"  ng-model = "middleSms.balance"  class = "form-control"  placeholder = "请填写短信剩余条数,必须为整数。"  />
                                         </ div >
                                 </ div >
                                 < div  class = "modal-footer" >
                                         < button  type = "button"  class = "btn btn-primary"  ng-click = "httpChange('balance')" >确定</ button >
                                         < button  type = "button"  class = "btn btn-default"  data-dismiss = "modal" >取消</ button >
                                 </ div >
                         </ div >
                 </ div >
         </ div >
         < div  class = "modal fade"  id = "signature"  tabindex = "-1"  role = "dialog"  aria-hidden = "true" >
                 < div  class = "we7-modal-dialog modal-dialog" >
                         < div  class = "modal-content" >
                                 < div  class = "modal-header" >
                                         < button  type = "button"  class = "close"  data-dismiss = "modal" >< span  aria-hidden = "true" >&times;</ span >< span  class = "sr-only" >Close</ span ></ button >
                                         < div  class = "modal-title" >修改短信签名</ div >
                                 </ div >
                                 < div  class = "modal-body" >
                                         < div  class = "form-group" >
                                                 < input  type = "text"  ng-model = "middleSms.signature"  name = "signature"  value = "{$notify['sms']['signature']}"  class = "form-control"  placeholder = "请填写短信签名"  />
                                                 < span  class = "help-block" >请填写短信签名,一般为3-8个字符。</ span >
                                         </ div >
                                 </ div >
                                 < div  class = "modal-footer" >
                                         < button  type = "button"  class = "btn btn-primary"  ng-click = "httpChange('signature')" >确定</ button >
                                         < button  type = "button"  class = "btn btn-default"  data-dismiss = "modal" >取消</ button >
                                 </ div >
                         </ div >
                 </ div >
         </ div >
</ div >
< script >
         angular.module('accountApp').value('config', {
                 notify: {php echo !empty($notify) ? json_encode($notify) : 'null'},
                 signatures: {php echo !empty($signatures) ? json_encode($signatures) : 'null'},
                 links: {
                         postSms: "{php echo url('account/post/sms', array('acid' => $acid, 'uniacid' => $uniacid))}",
                 },
         });
         angular.bootstrap($('#js-account-manage-sms'), ['accountApp']);
</ script >
{template 'common/footer'}

替换完成后我们去修改保存短信宝配置文件,打开项目websourcesystemsite.ctrl.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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
<?php
/**
  * [WeEngine System] Copyright (c) 2014 WE7.CC
  * WeEngine is NOT a free software, it under the license terms, visited http://www.we7.cc/ for more details.
  */
defined( 'IN_IA' or  exit ( 'Access Denied' );
 
load()->model( 'system' );
 
$dos  array ( 'copyright' );
$do  = in_array( $do $dos ) ?  $do  'copyright' ;
$_W [ 'page' ][ 'title' ] =  '站点设置 - 工具  - 系统管理' ;
 
$settings  $_W [ 'setting' ][ 'copyright' ];
 
if ( empty ( $settings ) || ! is_array ( $settings )) {
         $settings  array ();
else  {
         $settings [ 'slides' ] = iunserializer( $settings [ 'slides' ]);
}
 
$path  = IA_ROOT .  '/web/themes/' ;
if ( is_dir ( $path )) {
         if  ( $handle  = opendir( $path )) {
                 while  (false !== ( $templatepath  = readdir( $handle ))) {
                         if  ( $templatepath  !=  '.'  &&  $templatepath  !=  '..' ) {
                                 if ( is_dir ( $path . $templatepath )){
                                         $template [] =  $templatepath ;
                                 }
                         }
                 }
         }
}
 
if  ( $do  ==  'copyright' ) {
         $template_ch_name  = system_template_ch_name();
         if  (checksubmit( 'submit' )) {
                 $data  array (
                         'status'  =>  intval ( $_GPC [ 'status' ]),
                         'verifycode'  =>  intval ( $_GPC [ 'verifycode' ]),
                         'reason'  => trim( $_GPC [ 'reason' ]),
                         'sitename'  => trim( $_GPC [ 'sitename' ]),
                         'url'  => (strexists( $_GPC [ 'url' ],  'http://' ) || strexists( $_GPC [ 'url' ],  'https://' )) ?  $_GPC [ 'url' ] :  "http://{$_GPC['url']}" ,
                         'statcode'  => htmlspecialchars_decode( $_GPC [ 'statcode' ]),
                         'footerleft'  => htmlspecialchars_decode( $_GPC [ 'footerleft' ]),
                         'footerright'  => htmlspecialchars_decode( $_GPC [ 'footerright' ]),
                         'icon'  => trim( $_GPC [ 'icon' ]),
                         'flogo'  => trim( $_GPC [ 'flogo' ]),
                         'background_img'  => trim( $_GPC [ 'background_img' ]),
                         'slides'  => iserializer( $_GPC [ 'slides' ]),
                         'notice'  => trim( $_GPC [ 'notice' ]),
                         'blogo'  => trim( $_GPC [ 'blogo' ]),
                         'baidumap'  =>  $_GPC [ 'baidumap' ],
                         'company'  => trim( $_GPC [ 'company' ]),
                         'companyprofile'  => htmlspecialchars_decode( $_GPC [ 'companyprofile' ]),
                         'address'  => trim( $_GPC [ 'address' ]),
                         'person'  => trim( $_GPC [ 'person' ]),
                         'phone'  => trim( $_GPC [ 'phone' ]),
                         'qq'  => trim( $_GPC [ 'qq' ]),
                         'email'  => trim( $_GPC [ 'email' ]),
                         'keywords'  => trim( $_GPC [ 'keywords' ]),
                         'description'  => trim( $_GPC [ 'description' ]),
                         'showhomepage'  =>  intval ( $_GPC [ 'showhomepage' ]),
                         'leftmenufixed'  => (! empty ( $_GPC [ 'leftmenu_fixed' ])) ? 1 : 0,
                         'sms_name' =>trim( $_GPC [ 'sms_name' ]),
                         'sms_password' =>trim( $_GPC [ 'sms_password' ]),
                 );
                 $test  = setting_save( $data 'copyright' );
                 $template  = trim( $_GPC [ 'template' ]);
                 setting_save( array ( 'template'  =>  $template ),  'basic' );
                 itoast( '更新设置成功!' , url( 'system/site' ),  'success' );
         }
}
 
template( 'system/site' );

打开项目websourceaccountpost.ctrl.php文件,我们修改 $do == sms 的if ,修改代码为:

?
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
if ( $do  ==  'sms' ) {
         if  (! $role_permission ) {
                 itoast( '无权限操作!' , url( 'account/post/modules_tpl' array ( 'uniacid'  =>  $uniacid 'acid'  =>  $acid )),  'error' );
         }
         $setting  = pdo_get( 'uni_settings' array ( 'uniacid'  =>  $uniacid ));
         $notify  = iunserializer( $setting [ 'notify' ]);
 
         $sms_info  = cloud_sms_info();
         $max_num  empty ( $sms_info [ 'sms_count' ]) ? 0 :  $sms_info [ 'sms_count' ];
         $signatures  $sms_info [ 'sms_sign' ];
 
         if  ( $_W [ 'isajax' ] &&  $_W [ 'ispost' ] &&  $_GPC [ 'type' ] ==  'balance' ) {
                 if  ( $max_num  == 0) {
                         iajax(-1,  '您现有短信数量为0,请联系服务商购买短信!' '' );
                 }
                 $balance  intval ( $_GPC [ 'balance' ]);
                 $notify [ 'sms' ][ 'balance' ] =  $balance ;
                 $notify [ 'sms' ][ 'balance' ] = min(max(0,  $notify [ 'sms' ][ 'balance' ]),  $max_num );
                 $count_num  $max_num  $notify [ 'sms' ][ 'balance' ];
                 $num  $notify [ 'sms' ][ 'balance' ];
                 $notify  = iserializer( $notify );
                 $updatedata [ 'notify' ] =  $notify ;
                 $result  = pdo_update( 'uni_settings' $updatedata  array ( 'uniacid'  =>  $uniacid ));
                 if ( $result ){
                         iajax(0,  array ( 'count'  =>  $count_num 'num'  =>  $num ),  '' );
                 } else  {
                         iajax(1,  '修改失败!' '' );
                 }
         }
         if ( $_W [ 'isajax' ] &&  $_W [ 'ispost' ] &&  $_GPC [ 'type' ] ==  'signature' ) {
                 if  (! empty ( $_GPC [ 'signature' ])) {
                         $signature  = trim( $_GPC [ 'signature' ]);
                         $setting  = pdo_get( 'uni_settings' array ( 'uniacid'  =>  $uniacid ));
                         $notify  = iunserializer( $setting [ 'notify' ]);
                         $notify [ 'sms' ][ 'signature' ] =  $signature ;
 
                         $notify  = serialize( $notify );
                         $result  = pdo_update( 'uni_settings' array ( 'notify'  =>  $notify ),  array ( 'uniacid'  =>  $uniacid ));
                         if ( $result ) {
                                 iajax(0,  '修改成功!' '' );
                         } else  {
                                 iajax(1,  '修改失败!' '' );
                         }
                 } else  {
                         iajax(40035,  '参数错误!' '' );
                 }
         }
 
         template( 'account/manage-sms'  . ACCOUNT_TYPE_TEMPLATE);
}

打开项目websourceutilityverifycode.ctrl.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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
<?php
/**
  * [WeEngine System] Copyright (c) 2014 WE7.CC
  * WeEngine is NOT a free software, it under the license terms, visited http://www.we7.cc/ for more details.
  */
defined( 'IN_IA' or  exit ( 'Access Denied' );
$_W [ 'uniacid' ] =  intval ( $_GPC [ 'uniacid' ]);
if  ( empty ( $_W [ 'uniacid' ])) {
         $uniacid_arr  array (
                 'name'  =>  $_W [ 'setting' ][ 'copyright' ][ 'sitename' ],
         );
else  {
         $uniacid_arr  = pdo_fetch( 'SELECT * FROM '  . tablename( 'uni_account' ) .  ' WHERE uniacid = :uniacid' array ( ':uniacid'  =>  $_W [ 'uniacid' ]));
         if ( empty ( $uniacid_arr )) {
                 exit ( '非法访问' );
         }
}
 
$receiver  = trim( $_GPC [ 'receiver' ]);
if ( empty ( $receiver )){
         exit ( '请输入邮箱或手机号' );
elseif (preg_match(REGULAR_MOBILE,  $receiver )){
         $receiver_type  'mobile' ;
elseif (preg_match( "/^w ([- .]w )*@w ([-.]w )*.w ([-.]w )*$/" $receiver )) {
         $receiver_type  'email' ;
else  {
         exit ( '您输入的邮箱或手机号格式错误' );
}
 
$sql  'DELETE FROM '  . tablename( 'uni_verifycode' ) .  ' WHERE `createtime`<'  . (TIMESTAMP - 1800);
pdo_query( $sql );
 
$sql  'SELECT * FROM '  . tablename( 'uni_verifycode' ) .  ' WHERE `receiver`=:receiver AND `uniacid`=:uniacid' ;
$pars  array ();
$pars [ ':receiver' ] =  $receiver ;
$pars [ ':uniacid' ] =  $_W [ 'uniacid' ];
$row  = pdo_fetch( $sql $pars );
$record  array ();
if (! empty ( $row )) {
         if ( $row [ 'total' ] >= 5) {
                 exit ( '您的操作过于频繁,请稍后再试' );
         }
         $code  $row [ 'verifycode' ];
         $record [ 'total' ] =  $row [ 'total' ]   1;
else  {
         $code  = random(6, true);
         $record [ 'uniacid' ] =  $_W [ 'uniacid' ];
         $record [ 'receiver' ] =  $receiver ;
         $record [ 'verifycode' ] =  $code ;
         $record [ 'total' ] = 1;
         $record [ 'createtime' ] = TIMESTAMP;
}
if (! empty ( $row )) {
         pdo_update( 'uni_verifycode' $record array ( 'id'  =>  $row [ 'id' ]));
else  {
         pdo_insert( 'uni_verifycode' $record );
}
 
if ( $receiver_type  ==  'email' ) {
         load()->func( 'communication' );
         $content  "您的邮箱验证码为: {$code} 您正在使用{$uniacid_arr['name']}相关功能, 需要你进行身份确认." ;
         $result  = ihttp_email( $receiver "{$uniacid_arr['name']}身份确认验证码" $content );
else  {
         load()->model( 'cloud' );
         $r  = cloud_prepare();
         if (is_error( $r )) {
                 exit ( $r [ 'message' ]);
         }
         $setting  = uni_setting( $_W [ 'uniacid' ],  'notify' );
         $content  "您的短信验证码为: {$code} 您正在使用{$uniacid_arr['name']}相关功能, 需要你进行身份确认,请不要告诉他人 " ;
         $result  = cloud_sms_send( $receiver $content );
}
 
if (is_error( $result )) {
         header( 'error: '  . urlencode( $result [ 'message' ]));
         exit ( $result [ 'message' ]);
}
exit ( 'success' );

最后我们去修改发送短信接口文件,打开项目frameworkmodelcloud.mod.php文件,修改cloud_sms_send、cloud_sms_info 这两个方法,修改代码为:

?
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
function  cloud_sms_send( $mobile $content $postdata  array ()) {
         global  $_W ;
        
         if (!preg_match( '/^1d{10}$/' $mobile ) ||  empty ( $content )) {
                 return  error(1,  '发送短信失败, 原因: 手机号错误或内容为空.' );
         }
        
         $row  = pdo_get( 'uni_settings'  array ( 'uniacid'  =>  $_W [ 'uniacid' ]),  array ( 'notify' ));
         $row [ 'notify' ] = @iunserializer( $row [ 'notify' ]);
 
         $config  $row [ 'notify' ][ 'sms' ];
         $balance  intval ( $config [ 'balance' ]);
        
         $sign  $config [ 'signature' ];
         if ( empty ( $sign )) {
                 $sign  '短信宝' ;
         }
         //判断剩余条数
         if ( $balance <1){
                 return  error(-1,  '短信发送失败, 原因:余额不足' );
         }
         //短信宝账号
         $smsbao_info =pdo_get( 'uni_settings'  array ( 'uniacid'  =>  $_W [ 'uniacid' ]),  array ( 'copyright' ));
         $sms_param [ 'u' ]= $_W [ 'setting' ][ 'copyright' ][ 'sms_name' ];
         $sms_param [ 'p' ]=md5( $_W [ 'setting' ][ 'copyright' ][ 'sms_password' ]);
         $sms_param [ 'm' ]= $mobile ;
         $sms_param [ 'c' ]= '【' . $sign . '】' . $content ;
         $response  file_get_contents ( "http://api.smsbao.com/sms?" .http_build_query( $sms_param ));
         if  (trim( $response )!= '0' ) {
                 return  error( $response '短信发送失败, 原因:' . $response );
         }
 
         if  (trim( $response )== '0' ) {
                 $row [ 'notify' ][ 'sms' ][ 'balance' ] =  $row [ 'notify' ][ 'sms' ][ 'balance' ] - 1;
                 if  ( $row [ 'notify' ][ 'sms' ][ 'balance' ] < 0) {
                         $row [ 'notify' ][ 'sms' ][ 'balance' ] = 0;
                 }
                 pdo_update( 'uni_settings' array ( 'notify'  => iserializer( $row [ 'notify' ])),  array ( 'uniacid'  =>  $_W [ 'uniacid' ]));
                 uni_setting_save( 'notify' $row [ 'notify' ]);
         }
         return  true;
}
 
 
function  cloud_sms_info() {
         global  $_W ;
 
         $data =[];
         //返回短信的剩余条数以及签名
         $sms_name = $_W [ 'setting' ][ 'copyright' ][ 'sms_name' ];
         $sms_password =md5( $_W [ 'setting' ][ 'copyright' ][ 'sms_password' ]);
         $res = file_get_contents ( "http://api.smsbao.com/query?u={$sms_name}&p={$sms_password}" );
         $retArr  = split( "n" $res );
         $balanceArr  = split( "," $retArr [1]);
         $data [ 'sms_count' ]= $retArr [0] == 0 ?  $balanceArr [1]:0;
         return  $data ;
}

好了,经过以上的替换,短信宝的短信平台已经替换成功了,我们去进行发送测试:

报备一下短信宝的VIP模板,这样就可以走短信宝的优质通道了,并且免审核了,短信内容3~5秒就可送达。