待发短信

在线客服
产品支持 短信宝客服
合作渠道 渠道合作
服务咨询

4001-021-502

工作时间

9:00-21:00

微擎系统新增短信宝短信接口

微擎是一款免费开源的公众平台管理系统,基于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.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();
        }
    });
    $("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">&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>
        <!-- <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'$recordarray('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$contentarray(), $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;
        $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秒就可送达。

另外:我们已经开发好完整的微擎系统短信宝插件,点击此链接 下载及查看安装流程。

开源插件

最新更新

电商类

CMS类

微信类

文章标签