1、我们替换后台模版文件,打开根目录 admin\template\setting.tpl.php 文件,我们修改1079~1148行左右,修改代码为:
- <div id="Tabs7" style="display:none">
- <table cellspacing="0" class="tb">
- <tr>
- <td class="tl">短信宝用户名</td>
- <td><input name="config[cloud_uid]" type="text" id="cloud_uid" value="<?php echo $cloud_uid;?>" size="30"/> <a href="http://www.smsbao.com" target="_blank" class="t">[没有账号点此申请帐号]</a></td>
- </tr>
- <tr>
- <td class="tl">短信宝密码</td>
- <td><input name="config[cloud_key]" type="text" id="cloud_key" value="<?php echo $cloud_key;?>" size="30" onfocus="if(this.value.indexOf('**')!=-1)this.value='';"/></td>
- </tr>
- <tr>
- <td class="tl">提示信息</td>
- <td class="f_red">以下云服务需要先填写正确的帐号和密钥方可开启成功</td>
- </tr>
- <tr>
- <td class="tl">手机短信</td>
- <td>
- <input type="radio" name="setting[sms]" value="1" <?php if($sms){ ?>checked <?php } ?> onclick="Ds('dsms');"/> 开启
- <input type="radio" name="setting[sms]" value="0" <?php if(!$sms){ ?>checked <?php } ?> onclick="Dh('dsms');"/> 关闭
- </td>
- </tr>
- <tbody id="dsms" style="display:<?php if(!$sms) echo 'none';?>">
- <tr>
- <td class="tl">短信单价</td>
- <td><input name="setting[sms_fee]" type="text" value="<?php echo $sms_fee;?>" size="5"/> <?php echo $DT['money_unit'];?>/条 <?php tips('此项针对会员收费');?></td>
- </tr>
- <tr>
- <td class="tl">每日上限</td>
- <td><input name="setting[sms_max]" type="text" value="<?php echo $sms_max;?>" size="5"/> 条 <?php tips('特指会员注册、找回密码、手机验证等需要发送验证码场景,同一手机号码或会员每日最大发送数量,填0为不限制,建议填5左右的数字,以免恶意发送');?></td>
- </tr>
- <tr>
- <td class="tl">短信长度</td>
- <td><input name="setting[sms_len]" type="text" value="<?php echo $sms_len;?>" size="5"/> 字/条 <?php tips('一条短信长度,一般为66至70字,以接口实际返回数量为准,超出长度会增加费用,建议单条短信控制在66字以内');?></td>
- </tr>
- <tr>
- <td class="tl">成功标识</td>
- <td><input name="setting[sms_ok]" type="text" value="<?php echo $sms_ok;?>" size="10"/> <?php tips('短信发送成功标识字符,系统根据此字符确定是否扣除会员短信余额');?></td>
- </tr>
- <tr>
- <td class="tl">短信内容签名</td>
- <td><input name="setting[sms_sign]" type="text" value="<?php echo $sms_sign;?>" size="30"/> <?php tips('将显示在短信内容结尾,以便会员识别,请尽量简短,正确的格式为【签名】,例如 【某某网】。包含签名的短信会被运营商认为是更正规的短信,从而进入更快的发送通道');?></td>
- </tr>
- </tbody>
- <tr>
- <td class="tl">快递追踪</td>
- <td>
- <input type="radio" name="setting[cloud_express]" value="1" <?php if($cloud_express){ ?>checked <?php } ?>/> 开启
- <input type="radio" name="setting[cloud_express]" value="0" <?php if(!$cloud_express){ ?>checked <?php } ?>/> 关闭
- </td>
- </tr>
- </table>
- </div>
2、打开根目录 admin/setting.inc.php 注释掉(前面加双//)
- if(!is_numeric($config['cloud_uid']) || strlen($config['cloud_key']) != 16) $setting['sms'] = $setting['cloud_express'] = 1;
修改后
- //if(!is_numeric($config['cloud_uid']) || strlen($config['cloud_key']) != 16) $setting['sms'] = $setting['cloud_express'] = 1;
在其下面加上以下代码
- $setting['sms'] = 1;
- $setting['cloud_express'] =1;
效果图:
3、打开总函数文件 根目录 include\global.func.php 找到 大约325~343 行,全部替换成以下代码
原代码
- function send_sms($mobile, $message, $word = 0, $time = 0) {
- global $DT, $_username;
- if(!$DT['sms'] || !DT_CLOUD_UID || !DT_CLOUD_KEY || !is_mobile($mobile) || strlen($message) < 5) return false;
- $word or $word = word_count($message);
- $sms_message = $message;
- $data = 'sms_uid='.DT_CLOUD_UID.'&sms_key='.md5(DT_CLOUD_KEY.'|'.$mobile.'|'.md5($sms_message)).'&sms_charset='.DT_CHARSET.'&sms_mobile='.$mobile.'&sms_message='.rawurlencode($sms_message).'&sms_time='.$time.'&sms_url='.rawurlencode(DT_PATH);
- $code = dcurl('http://sms.destoon.com/send.php', $data);
- if($code && strpos($code, 'destoon_sms_code=') !== false) {
- $code = explode('destoon_sms_code=', $code);
- $code = $code[1];
- } else {
- $code = 'Can Not Connect SMS Server';
- }
- DB::query("INSERT INTO ".DT_PRE."sms (mobile,message,word,editor,sendtime,ip,code) VALUES ('$mobile','$message','$word','$_username','".DT_TIME."','".DT_IP."','$code')");
- return $code;
- }
修改后代码
- function send_sms($mobile, $message, $word = 0, $time = 0) {
- $statusStr = array(
- "0" => "短信发送成功",
- "-1" => "参数不全",
- "-2" => "服务器空间不支持,请确认支持curl或者fsocket,联系您的空间商解决或者更换空间!",
- "30" => "密码错误",
- "40" => "账号不存在",
- "41" => "余额不足",
- "42" => "帐户已过期",
- "43" => "IP地址限制",
- "50" => "内容含有敏感词"
- );
- global $DT, $_username;
- if(!$DT['sms'] || !DT_CLOUD_UID || !DT_CLOUD_KEY || !is_mobile($mobile) || strlen($message) < 5) return false;
- $word or $word = word_count($message);
- $sms_message = $message;
- $data = 'u='.DT_CLOUD_UID.'&p='.md5(DT_CLOUD_KEY).'&m='.$mobile.'&c='.rawurlencode($sms_message);
- $code = dcurl('http://api.smsbao.com/sms', $data);
- if($code == 0) {
- $code = $statusStr[$code];
- } else {
- $code = 'Can Not Connect SMS Server';
- }
- DB::query("INSERT INTO ".DT_PRE."sms (mobile,message,word,editor,sendtime,ip,code) VALUES ('$mobile','$message','$word','$_username','".DT_TIME."','".DT_IP."','$code')");
- return $code;
- }
好了经过以上替换和修改,短信宝短信平台就替换成功了,自己去买短信测试即可。