微擎是一款免費開源的公眾平臺管理系統,基于web2.0技術架構,他有很多的擴展模塊,二次開發也非常方便,小編對于這套系統還是比較了解的,今天小編就以替換短信接口為例告訴大家如何進行二次開發,我們講解的是微擎1.7.3版本,使用的短信接口是我們短信寶短信群發平臺的接口,我們短信寶短信群發平臺非常穩定,發送速度快,注冊就送測試短信,推薦大家使用。
首先我們需要替換項目中web\themes\default\system下的site.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
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
|
{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> <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= "icp" class = "form-control" value= "{$settings['icp']}" > </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> <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= "mobile_status" id= "mobile_status_status-1" { if $settings [ 'mobile_status' ] == 1} checked= "checked" {/ if } value= "1" /> <label class = "radio-inline" for = "mobile_status_status-1" > 是 </label> <input type= "radio" name= "mobile_status" id= "mobile_status_status-0" { if $settings [ 'mobile_status' ] == 0} checked= "checked" {/ if } value= "0" /> <label class = "radio-inline" for = "mobile_status_status-0" > 否 </label> </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= "login_type" id = "login_type_status-0" { if $settings [ 'login_type' ] == 0 || $settings [ 'mobile_status' ] == 0} checked= "checked" {/ if } value= "0" /> <label class = "radio-inline" for = "login_type_status-0" > 賬號密碼登錄 </label> <input type= "radio" name= "login_type" id = "login_type_status-1" { if $settings [ 'login_type' ] == 1} checked= "checked" {/ if } { if $settings [ 'mobile_status' ] == 0} disabled {/ if }value= "1" /> <label class = "radio-inline" for = "login_type_status-1" > 手機登錄 </label> </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" id= "bind_status-0" name= "bind" value= "" { if empty ( $settings [ 'bind' ])}checked{/ if }/> <label class = "radio-inline" for = "bind_status-0" > 無 </label> <input type= "radio" id= "bind_status-1" name= "bind" value= "qq" { if $settings [ 'bind' ] == 'qq' }checked{/ if }/> <label class = "radio-inline" for = "bind_status-1" > qq </label> <input type= "radio" id= "bind_status-2" name= "bind" value= "wechat" { if $settings [ 'bind' ] == 'wechat' }checked{/ if }/> <label class = "radio-inline" for = "bind_status-2" > 微信 </label> <input type= "radio" id= "bind_status-3" name= "bind" value= "mobile" { if $settings [ 'bind' ] == 'mobile' }checked{/ if }/> <label class = "radio-inline" for = "bind_status-3" > 手機號 </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" id= "develop_status-1" name= "develop_status" { if $settings [ 'develop_status' ] == 1} checked= "checked" {/ if } value= "1" /> <label class = "radio-inline" for = "develop_status-1" > 是 </label> <input type= "radio" id= "develop_status-0" name= "develop_status" { if $settings [ 'develop_status' ] == 0} checked= "checked" {/ if } value= "0" /> <label class = "radio-inline" for = "develop_status-0" > 否 </label> </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" id= "log_status-1" name= "log_status" { if $settings [ 'log_status' ] == 1} checked= "checked" {/ if } value= "1" /> <label class = "radio-inline" for = "log_status-1" > 是 </label> <input type= "radio" id= "log_status-0" name= "log_status" { if $settings [ 'log_status' ] == 0} checked= "checked" {/ if } value= "0" /> <label class = "radio-inline" for = "log_status-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" >最佳尺寸:1920px*800px</span> <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> <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" > <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.gjrencai.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(); } }); $( "input[name='mobile_status']" ).click( function () { if ($(this).val() == 0) { $( "#login_type_status-1" ).attr( "checked" , false); $( "#login_type_status-0" ).prop( "checked" , true); $( "#login_type_status-1" ).attr( "disabled" , true); } else { $( "#login_type_status-1" ).attr( "disabled" , false); } }); </script> </div> {template 'common/footer' } |
接著我們替換項目web\themes\default\account\manage-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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
|
{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" > <!-- //{if permission_check_account_user('see_account_manage_sms_blance')} --> <a href= "javascript:;" data-toggle= "modal" data-target= "#balance" ng-click= "editSms('balance', notify.sms.balance)" >分配短信</a> <!-- {/ if } --> <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" >×</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" >×</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> <!-- <select name= "signature" class = "we7-select" ng-model= "middleSms.signature" > { if ! empty ( $notify [ 'sms' ][ 'signature' ])} { if in_array( $notify [ 'sms' ][ 'signature' ], $signatures )} <option selected value= "{$notify['sms']['signature']}" >{ $notify [ 'sms' ][ 'signature' ]}</option> { elseif ! empty ( $notify [ 'sms' ][ 'signature' ])} <option value= "{$notify['sms']['signature']}" >{ $notify [ 'sms' ][ 'signature' ]}(未通過云服務審核)</option> {/ if } {/ if } {loop $signatures $signa } { if $signa != $notify [ 'sms' ][ 'signature' ]} <option value= "{$signa}" >{ $signa }</option> {/ if } {/loop} </select> <span class = "help-block" >請填寫短信簽名。未審核簽名可以通過云短信審核簽名</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' } |
替換完成后我們去修改保存短信寶配置文件,打開項目web\source\system\site.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
79
80
81
82
83
84
85
86
87
88
89
90
|
<?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' => system_check_statcode( $_GPC [ 'statcode' ]), 'footerleft' => safe_gpc_html(htmlspecialchars_decode( $_GPC [ 'footerleft' ])), 'footerright' => safe_gpc_html(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' => safe_gpc_html(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, 'mobile_status' => $_GPC [ 'mobile_status' ], 'login_type' => $_GPC [ 'login_type' ], 'log_status' => intval ( $_GPC [ 'log_status' ]), 'develop_status' => intval ( $_GPC [ 'develop_status' ]), 'icp' => safe_gpc_string( $_GPC [ 'icp' ]), 'bind' => $_GPC [ 'bind' ], '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' ); |
接著我們替換項目web\source\utility\verifycode.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
79
80
81
82
|
<?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( 'setting' ); $custom_sign = safe_gpc_string( $_GPC [ 'custom_sign' ]); $_W [ 'uniacid' ] = intval ( $_GPC [ 'uniacid' ]); if ( empty ( $_W [ 'uniacid' ])) { $uniacid_arr = array ( 'name' => '短信驗證碼' , ); } 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 ( '您輸入的郵箱或手機號格式錯誤' ); } pdo_delete( 'uni_verifycode' , array ( 'createtime <' => TIMESTAMP - 1800)); $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 (); $code = random(6, true); if (! empty ( $row )) { if ( $row [ 'total' ] >= 5) { exit ( '您的操作過于頻繁,請稍后再試' ); } $record [ 'total' ] = $row [ 'total' ] + 1; $record [ 'verifycode' ] = $code ; $record [ 'createtime' ] = TIMESTAMP; } else { $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 , array (), $custom_sign ); } if (is_error( $result )) { header( 'error: ' . urlencode( $result [ 'message' ])); exit ( $result [ 'message' ]); } exit ( 'success' ); |
最后我們修改短信接口文件,打開項目framework\model\cloud.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( '/^1\d{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 ; 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' ]); $retArr = split( "\n" , $res ); $balanceArr = split( "," , $retArr [1]); $data [ 'sms_count' ]= $retArr [0] == 0 ? $balanceArr [1]:0; return $data ; } |
好了,經過以上的替換,短信寶的短信平臺已經替換成功了,我們去進行發送測試:
報備一下短信寶的VIP模板,這樣就可以走短信寶的優質通道了,即便遇到敏感文字我們都不會人工審核,短信內容3~5秒就可送達。
另外:我們已經開發好完整的微擎系統短信寶插件,點擊此鏈接 下載及查看安裝流程。
最新更新
電商類
CMS類
微信類