微擎是一款免费开源的公众平台管理系统,基于web2.0技术架构,他有很多的扩展模块,二次开发也非常方便,小编对于这套系统还是比较了解的,今天小编就以替换短信接口为例告诉大家如何进行二次开发,我们讲解的是1.6。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 | {template 'common/header'}<divclass="we7-page-title">站点设置</div><ulclass="we7-page-tab">        <li{if $do == 'copyright'} class="active"{/if}><ahref="{php echo url('system/site');}">站点信息</a></li></ul><divclass="clearfix">        <formaction=""method="post"class="we7-form"role="form"enctype="multipart/form-data"id="form1">                <divclass="form-group">                        <labelclass="col-sm-2 control-label"style="text-align:left;">关闭站点</label>                        <divclass="col-sm-8 form-control-static">                                <inputtype="radio"name="status"id="status-1"{if $settings['status'] == 1} checked="checked"{/if} value="1"/>                                <labelclass="radio-inline"for="status-1">                                         是                                </label>                                <inputtype="radio"name="status"id="status-0"{if $settings['status'] == 0} checked="checked"{/if} value="0"/>                                 <labelclass="radio-inline"for="status-0">                                        否                                </label>                        </div>                </div>                <divclass="form-group reason"{if $settings['status'] == 0} style="display:none;"{/if}>                        <labelclass="col-sm-2 control-label"style="text-align:left;">关闭原因</label>                        <divclass="col-sm-8">                                <textareastyle="height:150px;"class="form-control"cols="70"name="reason"autocomplete="off">{$settings['reason']}</textarea>                                <inputtype="hidden"name="reasons"value="{$settings['reason']}">                        </div>                </div>                <h5class="page-header">登录站点</h5>                <divclass="form-group">                        <labelclass="col-sm-2 control-label"style="text-align:left;">是否开启验证码</label>                        <divclass="col-sm-8 form-control-static">                                <inputtype="radio"id="verifycode-1"name="verifycode"{if $settings['verifycode'] == 1} checked="checked"{/if} value="1"/>                                 <labelclass="radio-inline"for="verifycode-1">                                        是                                </label>                                <inputtype="radio"id="verifycode-0"name="verifycode"{if $settings['verifycode'] == 0} checked="checked"{/if} value="0"/>                                 <labelclass="radio-inline"for="verifycode-0">                                        否                                </label>                        </div>                </div>        <h5class="page-header">版权信息</h5>                <divclass="form-group">                        <labelclass="col-sm-2 control-label"style="text-align:left;">是否显示首页</label>                        <divclass="col-sm-8 form-control-static">                                <inputtype="radio"name="showhomepage"value="1"id="showhomepage_1"{if !empty($settings['showhomepage'])} checked{/if}>                                <labelfor="showhomepage_1"class="radio-inline"> 是</label>                                <inputtype="radio"name="showhomepage"value="0"id="showhomepage_2"{if empty($settings['showhomepage'])} checked{/if}>                                <labelfor="showhomepage_2"class="radio-inline"> 否</label>                                <divclass="help-block">设置“否”后,打开地址时将直接跳转到登录页面,否则会跳转到首页。</div>                        </div>                </div>                <divclass="form-group">                        <labelclass="col-sm-2 control-label"style="text-align:left;">网站名称</label>                        <divclass="col-sm-8">                                <inputtype="text"name="sitename"class="form-control"value="{$settings['sitename']}"/>                        </div>                </div>                <divclass="form-group">                        <labelclass="col-sm-2 control-label"style="text-align:left;">网站URL</label>                        <divclass="col-sm-8">                                <inputtype="text"name="url"class="form-control"value="{$settings['url']}"/>                        </div>                </div>                <divclass="form-group">                        <labelclass="col-sm-2 control-label"style="text-align:left;">keywords</label>                        <divclass="col-sm-8">                                <inputtype="text"name="keywords"class="form-control"value="{$settings['keywords']}"/>                        </div>                </div>                <divclass="form-group">                        <labelclass="col-sm-2 control-label"style="text-align:left;">description</label>                        <divclass="col-sm-8">                                <inputtype="text"name="description"class="form-control"value="{$settings['description']}"/>                        </div>                </div>                <divclass="form-group">                        <labelclass="col-sm-2 control-label"style="text-align:left;">左侧菜单定位</label>                        <divclass="col-sm-8 form-control-static">                                <inputtype="radio"name="leftmenu_fixed"id="leftmenu_fixed_status-1"{if $settings['leftmenufixed'] == 1} checked="checked"{/if} value="1"/>                                <labelclass="radio-inline"for="leftmenu_fixed_status-1">                                         是                                </label>                                <inputtype="radio"name="leftmenu_fixed"id="leftmenu_fixed_status-0"{if $settings['leftmenufixed'] == 0} checked="checked"{/if} value="0"/>                                 <labelclass="radio-inline"for="leftmenu_fixed_status-0">                                        否                                </label>                                <spanclass="help-block">选择“否”并保存后,左侧菜单随页面滚动而上下滚动</span>                        </div>                </div>                <divclass="form-group">                        <labelclass="col-sm-2 control-label"style="text-align:left;">后台风格设置</label>                        <divclass="col-sm-8">                                <selectname="template"class="form-control">                                        {loop $template $tpl}                                        <optionvalue="{$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>                                <spanclass="help-block">favorite icon</span>                        </div>                </div>                <divclass="form-group">                        <labelclass="col-sm-2 control-label"style="text-align:left;">favorite icon</label>                        <divclass="col-sm-8">                                {php echo tpl_form_field_image('icon', $settings['icon'], '', array('global' => true, 'extras' => array('image'=> ' width="32" ')));}                                <spanclass="help-block">favorite icon</span>                        </div>                </div>                <divclass="form-group">                        <labelclass="col-sm-2 control-label"style="text-align:left;">前台LOGO</label>                        <divclass="col-sm-8">                                {php echo tpl_form_field_image('flogo', $settings['flogo'], '', array('global' => true));}                                <spanclass="help-block">最佳尺寸:220px*50px</span>                                <spanclass="help-block">此logo是指首页及登录页面logo。</span>                        </div>                </div>                <divclass="form-group">                        <labelclass="col-sm-2 control-label"style="text-align:left;">背景图片</label>                        <divclass="col-sm-8">                                {php echo tpl_form_field_image('background_img', $settings['background_img'], '', array('global' => true));}                                <spanclass="help-block">此图片是指登录页面的背景图。</span>                        </div>                </div>                <divclass="form-group">                        <labelclass="col-sm-2 control-label"style="text-align:left;">前台幻灯片</label>                        <divclass="col-sm-8">                                {php echo tpl_form_field_multi_image('slides', $settings['slides'], '', array('global' => true, 'thumb' => 0));}                                <spanclass="help-block">设置首页幻灯片。</span>                        </div>                </div>                <divclass="form-group">                        <labelclass="col-sm-2 control-label"style="text-align:left;">前台幻灯片显示文字</label>                        <divclass="col-sm-8">                                <inputtype="text"class="form-control"name="notice"value="{$settings['notice']}"/>                                <spanclass="help-block">该文字显示在幻灯片上。</span>                        </div>                </div>                <divclass="form-group">                        <labelclass="col-sm-2 control-label"style="text-align:left;">后台LOGO</label>                        <divclass="col-sm-8">                                {php echo tpl_form_field_image('blogo', $settings['blogo'], '', $options = array('global' => true));}                                <spanclass="help-block">最佳尺寸:110px*35px</span>                                <spanclass="help-block">此logo是指登录后在本系统左上角显示的logo。</span>                        </div>                </div>                <divclass="form-group">                        <labelclass="col-sm-2  control-label"style="text-align:left;">第三方统计代码</label>                        <divclass="col-sm-8">                                <textareastyle="height:150px;"class="form-control"cols="70"name="statcode"autocomplete="off">{$settings['statcode']}</textarea>                        </div>                </div>                <divclass="form-group">                        <labelclass="col-sm-2 control-label"style="text-align:left;">底部右侧信息(上)</label>                        <divclass="col-sm-8">                                <textareastyle="height:150px;"class="form-control"cols="70"name="footerright"autocomplete="off">{$settings['footerright']}</textarea>                                <spanclass="help-block">自定义底部右侧信息,支持HTML</span>                        </div>                </div>                <divclass="form-group">                        <labelclass="col-sm-2 control-label"style="text-align:left;">底部左侧信息(下)</label>                        <divclass="col-sm-8">                                <textareastyle="height:150px;"class="form-control"cols="70"name="footerleft"autocomplete="off">{$settings['footerleft']}</textarea>                                <spanclass="help-block">自定义底部左侧信息,支持HTML</span>                        </div>                </div>                <divclass="form-group">                        <labelclass="col-sm-2 control-label"style="text-align:left;">联系人</label>                        <divclass="col-sm-8">                                <inputtype="text"name="person"class="form-control"value="{$settings['person']}"/>                        </div>                </div>                <divclass="form-group">                        <labelclass="col-sm-2 control-label"style="text-align:left;">联系电话</label>                        <divclass="col-sm-8">                                <inputtype="text"name="phone"class="form-control"value="{$settings['phone']}"/>                        </div>                </div>                <divclass="form-group">                        <labelclass="col-sm-2 control-label"style="text-align:left;">QQ</label>                        <divclass="col-sm-8">                                <inputtype="text"name="qq"class="form-control"value="{$settings['qq']}"/>                        </div>                </div>                <divclass="form-group">                        <labelclass="col-sm-2 control-label"style="text-align:left;">邮箱</label>                        <divclass="col-sm-8">                                <inputtype="text"name="email"class="form-control"value="{$settings['email']}"/>                        </div>                </div>                <divclass="form-group">                        <labelclass="col-sm-2 control-label"style="text-align:left;">公司名称</label>                        <divclass="col-sm-8">                                <inputtype="text"name="company"value="{$settings['company']}"class="form-control"/>                        </div>                </div>                <divclass="form-group">                        <labelclass="col-sm-2 control-label"style="text-align:left;">关于我们</label>                        <divclass="col-sm-8">                                {php echo tpl_ueditor('companyprofile', $settings['companyprofile']);}                                <spanclass="help-block">该文字显示在个人中心->关于我们中</span>                        </div>                </div>                <divclass="form-group">                        <labelclass="col-sm-2 control-label"style="text-align:left;">详细地址</label>                        <divclass="col-sm-8">                                <inputtype="text"name="address"value="{$settings['address']}"class="form-control"/>                        </div>                </div>                <divclass="form-group">                        <labelclass="col-sm-2 control-label"style="text-align:left;">地理位置</label>                        <divclass="col-sm-8">                                {php echo tpl_form_field_coordinate('baidumap', $settings['baidumap'])}                        </div>                </div>                <divclass="form-group">                        <labelclass="col-sm-2 control-label"style="text-align:left;">短信宝账号</label>                        <divclass="col-sm-8">                                <inputtype="text"name="sms_name"class="form-control"value="{$settings['sms_name']}"/>                                <spanclass="help-block">没有短信宝账号?点击<aclass="btn btn-primary span3"target="_blank"href="http://www.smsbao.com">免费注册</a></span>                        </div>                </div>                <divclass="form-group">                        <labelclass="col-sm-2 control-label"style="text-align:left;">短信宝密码</label>                        <divclass="col-sm-8">                                <inputtype="password"name="sms_password"class="form-control"value="{$settings['sms_password']}"/>                        </div>                </div>                <divclass="form-group">                        <divclass="col-sm-offset-2 col-md-offset-2 col-lg-offset-1 col-xs-12 col-sm-10 col-md-10 col-lg-11">                                <inputname="submit"type="submit"value="提交"class="btn btn-primary span3"/>                                <inputtype="hidden"name="token"value="{$_W['token']}"/>                        </div>                </div>        </form>        <scripttype="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'} | 
接下来替换项目\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 | {template 'common/header'}{template 'account/account-header'}<divid="js-account-manage-sms"ng-controller="AccountManageSms"ng-cloak>        <tableclass="table we7-table table-hover">                <colwidth="200px"/>                <colwidth="230px"/>                <tr>                        <th>剩余条数</th>                        <thclass="text-right">操作</th>                </tr>                <tr>                         <tdng-if="notify.sms"><spanng-bind="notify.sms.balance">{$notify['balance']}</span>条</td>                        <tdng-if="!notify.sms">0条</td>                        <td>                                <divclass="link-group">                                        <ahref="javascript:;"data-toggle="modal"data-target="#balance"ng-click="editSms('balance', notify.sms.balance)">分配短信</a>                                        <ahref="javascript:;"data-toggle="modal"data-target="#signature"ng-click="editSms('signature', notify.sms.signature)">设置短信签名</a>                                </div>                        </td>                </tr>        </table>        <divclass="modal fade"id="balance"tabindex="-1"role="dialog"aria-hidden="true">                <divclass="we7-modal-dialog modal-dialog">                        <divclass="modal-content">                                <divclass="modal-header">                                        <buttontype="button"class="close"data-dismiss="modal"><spanaria-hidden="true">×</span><spanclass="sr-only">Close</span></button>                                        <divclass="modal-title">分配短信</div>                                </div>                                <divclass="modal-body we7-form">                                        <divclass="form-group">                                                <inputtype="number"min="0"ng-model="middleSms.balance"class="form-control"placeholder="请填写短信剩余条数,必须为整数。"/>                                        </div>                                </div>                                <divclass="modal-footer">                                        <buttontype="button"class="btn btn-primary"ng-click="httpChange('balance')">确定</button>                                        <buttontype="button"class="btn btn-default"data-dismiss="modal">取消</button>                                </div>                        </div>                </div>        </div>        <divclass="modal fade"id="signature"tabindex="-1"role="dialog"aria-hidden="true">                <divclass="we7-modal-dialog modal-dialog">                        <divclass="modal-content">                                <divclass="modal-header">                                        <buttontype="button"class="close"data-dismiss="modal"><spanaria-hidden="true">×</span><spanclass="sr-only">Close</span></button>                                        <divclass="modal-title">修改短信签名</div>                                </div>                                <divclass="modal-body">                                        <divclass="form-group">                                                <inputtype="text"ng-model="middleSms.signature"name="signature"value="{$notify['sms']['signature']}"class="form-control"placeholder="请填写短信签名"/>                                                <spanclass="help-block">请填写短信签名,一般为3-8个字符。</span>                                        </div>                                </div>                                <divclass="modal-footer">                                        <buttontype="button"class="btn btn-primary"ng-click="httpChange('signature')">确定</button>                                        <buttontype="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 | <?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') orexit('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'); | 
打开项目\web\source\account\post.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);} | 
打开项目\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 | <?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') orexit('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'); | 
最后我们去修改发送短信接口文件,打开项目\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 | functioncloud_sms_send($mobile, $content, $postdata= array()) {        global$_W;                if(!preg_match('/^1\d{10}$/', $mobile) || empty($content)) {                returnerror(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){                returnerror(-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') {                returnerror($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']);        }        returntrue;}functioncloud_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类
微信类