DESTOON是一款B2B网站管理系统他是基于PHP+MYSQL,二次开发及后期维护方便,小编对这款系统还比较了解,今天就以替换短信接口为例为大家讲解一下如何进行二次开发,我们今天讲解的是9.0版本,使用的短信接口是我们短信宝短信群发平头的短信接口,我们短信宝短信群发平台非常稳定,发送速度快,注册就送测试短信,推荐大家使用。
1:打开项目:\module\destoon\admin\template\setting.tpl.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
|
<?php $select = '' ; $apis = glob(DT_ROOT. '/api/sms/*.php' ); $nms = array(); $nms[ 'smsbao' ] = '短信宝' ; $nms[ 'aliyun' ] = '阿里云' ; $nms[ 'gyytz' ] = '杭州国阳' ; $nms[ 'juhe' ] = '聚合数据' ; foreach($apis as $v) { $v = basename($v, '.php' ); if (strpos($v, '.' ) !== false ) continue ; $selected = $v == $sms_api ? 'selected' : '' ; $select .= "<option value='" .$v. "' " .$selected. ">" .(isset($nms[$v]) ? $nms[$v] : $v). "</option>" ; } $select = '<select name="setting[sms_api]" id="sms_api" onchange="SmsApi();"><option value="">选择接口</option>' .$select. '</select>' ; echo $select; ?> function SmsApi() { var api = $( '#sms_api' ).val(); if (api == 'juhe' ) { $( '#nm_sms_appid' ).html( 'Key' ); $( '#tr_sms_appsecret' ).hide(); $( '#nm_sms_par' ).html( '备用参数' ); $( '#tr_sms_template' ).show(); } else if (api == 'gyytz' ) { $( '#sms_link' ).attr( 'href' , '<?php echo gourl("https://market.aliyun.com/apimarket/detail/cmapi00037415");?>' ); $( '#nm_sms_appid' ).html( 'AppCode' ); $( '#tr_sms_appsecret' ).hide(); $( '#nm_sms_par' ).html( '签名ID' ); $( '#tr_sms_template' ).show(); } else if (api == 'smsbao' ) { $( '#nm_sms_appid' ).html( '短信宝账号' ); $( '#nm_sms_appsecret' ).html( '短信宝密码' ); $( '#tr_sms_template' ).hide(); } else { $( '#sms_link' ).attr( 'href' , '<?php echo gourl("https://market.aliyun.com/apimarket/detail/cmapi00066996");?>' ); $( '#nm_sms_appid' ).html( 'APP ID' ); $( '#tr_sms_appsecret' ).show(); $( '#nm_sms_appsecret' ).html( 'APP Secret' ); $( '#nm_sms_par' ).html( '备用参数' ); $( '#tr_sms_template' ).show(); } } |
2:打开项目\module\destoon\admin\setting.inc.php ,修改代码大概95行
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
$setting[ 'gano' ] = $setting[ 'wano' ] ? cutstr($setting[ 'wano' ], '备' , '号' ) : '' ; $setting[ 'smtp_pass' ] = pass_decode($setting[ 'smtp_pass' ], $DT[ 'smtp_pass' ]); $setting[ 'ftp_pass' ] = pass_decode($setting[ 'ftp_pass' ], $DT[ 'ftp_pass' ]); $setting[ 'admin_week' ] = is_array($setting[ 'admin_week' ]) ? implode( ',' , $setting[ 'admin_week' ]) : '' ; $setting[ 'check_week' ] = is_array($setting[ 'check_week' ]) ? implode( ',' , $setting[ 'check_week' ]) : '' ; if ($setting[ 'logo' ] != $DT[ 'logo' ]) clear_upload($setting[ 'logo' ], $_userid, 'setting' ); $setting[ 'thumb_max' ] = intval($setting[ 'thumb_max' ]); if ($setting[ 'thumb_max' ] > 99 || $setting[ 'thumb_max' ] < 5) $setting[ 'thumb_max' ] = 10; in_array($setting[ 'file_ext' ], array( 'html' , 'htm' , 'shtml' , 'shtm' )) or $setting[ 'file_ext' ] = 'html' ; $setting[ 'color_pc' ] = strlen($css[ 'home_menu' ]) == 7 ? $css[ 'home_menu' ] : '#0679D4' ; $setting[ 'color_mb' ] = strlen($css[ 'mobile_head' ]) == 7 ? $css[ 'mobile_head' ] : '#F7F7F7' ; $setting[ 'color_mw' ] = strtoupper($css[ 'mobile_text' ]) == '#FFFFFF' ? 1 : 0; if (substr($config[ 'url' ], -1) != '/' ) $config[ 'url' ] = $config[ 'url' ]. '/' ; if ($config[ 'cookie_domain' ] && substr($config[ 'cookie_domain' ], 0, 1) != '.' ) $config[ 'cookie_domain' ] = '.' .$config[ 'cookie_domain' ]; if ($config[ 'cookie_domain' ] != $CFG[ 'cookie_domain' ]) $config[ 'cookie_pre' ] = 'D' .random(2). '_' ; // if(!is_numeric($config['cloud_uid']) || strlen($config['cloud_key']) != 16) $setting['sms'] = $setting['cloud_express'] = 0; $setting[ 'sms' ] = 1; $setting[ 'cloud_express' ] =1; $config[ 'cloud_key' ] = pass_decode($config[ 'cloud_key' ], DT_CLOUD_KEY); $setting[ 'biz' ] = is_file(DT_ROOT. '/license.php' ) ? 1 : 0; $setting[ 'file_register_bak' ] = $setting[ 'file_register' ]; $setting[ 'file_login_bak' ] = $setting[ 'file_login' ]; $setting[ 'file_my_bak' ] = $setting[ 'file_my' ]; |
3:打开项目\include\global.func.php,修改send_sms方法
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
function send_sms($mobile, $message, $word = 0, $cron = 0) { global $DT, $_username; if (!$DT[ 'sms' ] || !$DT[ 'sms_sign' ] || !is_mobile($mobile)) return 0; $message = preg_replace( "/&([a-z]{1,});/" , '' , trim(strip_tags($message))); if (strlen($message) < 5) return 0; if (strpos($message, substr($DT[ 'sms_sign' ], 0, 3)) === false ) $message = $DT[ 'sms_sign' ].$message; if ($DT[ 'sms_api' ] && $DT[ 'sms_appid' ] && $DT[ 'sms_template' ] && $DT[ 'sms_code' ] && strpos($message, $DT[ 'sms_code' ]) !== false ) { $code = dcurl(DT_PATH. 'api/sms/' .$DT[ 'sms_api' ]. '.php' , 'auth=' .encrypt($mobile. '|' .$message, DT_KEY. 'SMS' , 600)); } else { $data = 'sms_uid=' .DT_CLOUD_UID. '&sms_key=' .md5(DT_CLOUD_KEY. '|' .DT_TIME. '|' .$mobile. '|' .md5($message)). '&sms_charset=' .DT_CHARSET. '&sms_mobile=' .$mobile. '&sms_time=' .DT_TIME. '&sms_cron=' .$cron. '&sms_message=' .rawurlencode($message). '&sms_url=' .rawurlencode(DT_PATH); $code = dcurl((DT_CLOUD_SSL ? 'https' : 'http' ). '://sms.destoon.com/send.php' , $data); if ($code && strpos($code, 'destoon_sms_code=' ) !== false ) { $code = cutstr($code, 'destoon_sms_code=' , '' ); } else { $code = 'Can Not Connect SMS Server' ; } } $word or $word = word_count($message); $status = strpos($code, $DT[ 'sms_ok' ]) !== false ? 3 : 2; $code = addslashes($code); DB::query( "INSERT INTO " .DT_PRE. "sms (mobile,message,word,editor,sendtime,ip,status,code) VALUES ('$mobile','$message','$word','$_username','" .DT_TIME. "','" .DT_IP. "','$status','$code')" ); return $code; } |
4:打开项目\api\sms目录,新增smsbao.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
|
<?php require '../../common.inc.php' ; $DT[ 'sms_api' ] == 'smsbao' or exit( 'ko.api' ); $DT[ 'sms_code' ] or exit( 'ko.code' ); $DT[ 'sms_template' ] or exit( 'ko.template' ); $DT[ 'sms_appid' ] or exit( 'ko.appid' ); $DT[ 'sms_appsecret' ] or exit( 'ko.appsecret' ); $statusStr = array( "0" => "短信发送成功" , "-1" => "参数不全" , "-2" => "服务器空间不支持,请确认支持curl或者fsocket,联系您的空间商解决或者更换空间!" , "30" => "密码错误" , "40" => "账号不存在" , "41" => "余额不足" , "42" => "帐户已过期" , "43" => "IP地址限制" , "50" => "内容含有敏感词" ); $auth = isset($auth) ? decrypt($auth, DT_KEY. 'SMS' ) : '' ; if (strpos($auth, '|' ) === false ) exit( 'ko.auth' ); list($mobile, $message) = explode( '|' , $auth); is_mobile($mobile) or exit( 'ko.mobile' ); strpos($message, $DT[ 'sms_code' ]) !== false or exit( 'ko.code' ); $code = preg_match( "/[0-9]{4,6}/" , $message, $matches) ? $matches[0] : '' ; $code or exit( 'ko.code' ); $data = 'u=' .$DT[ 'sms_appid' ]. '&p=' .md5($DT[ 'sms_appsecret' ]). '&m=' .$mobile. '&c=' .urlencode($message); if ($res == 0) { $res = $DT[ 'sms_ok' ]. '/' .$DT[ 'sms_api' ]; } else { $res = $statusStr[$res]; } echo $res; ?> |
好了经过以上的添加,短信宝DESTOON_v9.0系统增加手机验证就已经安装成功,可以正常使用了
报备一下短信宝的VIP模板,这样就可以走短信宝的优质通道了,即便遇到敏感文字我们都不会人工审核,短信内容3~5秒就可送达。
另外:我们已经开发好完整的DESTOON_v9.0系统短信宝插件,点击此链接 下载及查看安装流程。
最新更新
电商类
CMS类
微信类