91成人在线播放_欧美一区二区视频在线观看_91精品国产高清久久久久久_国产精品久久亚洲不卡4k岛国


待發(fā)短信

在線客服
產(chǎn)品支持 短信寶客服
合作渠道 渠道合作
服務(wù)咨詢

4001-021-502

工作時間

9:00-21:00

Yuncart開源網(wǎng)店系統(tǒng)短信接口替換

Yuncart是一套易與企業(yè)內(nèi)部系統(tǒng)CRM、ERP等集成的php商城系統(tǒng)。開源,永久免費,適合多人同時進行二次開發(fā),小編對這套系統(tǒng)還是比較了解的,今天小編就以替換短信接口為例,為大家講解一下如何進行二次開發(fā),我們今天講解的1.0版本,使用的接口是我們短信寶短信群發(fā)平臺的短信接口,我們短信寶短信群發(fā)平臺非常穩(wěn)定,發(fā)送速度快,注冊就送測試短信,推薦大家使用。

我們首先替換后臺顯示界面,打開項目\data\dwoocompiled\admin\message_index.html.d20121219.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
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
<?php
/* template head */
/* end template head */ ob_start(); /* template body */ ;
echo Dwoo_Plugin_include($this, 'head.html', array (
));?>
 
<div id="wrap">
        <?php echo Dwoo_Plugin_include($this, 'left.html', array (
));?>
 
        <div id="maincont">
                <b class="b1"></b><b class="b2"></b><b class="b3"></b><b class="b4"></b>
                <form action="<?php echo url('admin', 'message', 'messagesave');?>" method="post" name="submitform" id="submitform">
                <div id="main_c">
                        <div id="infotab">
                                <ul>
                                        <li class="cur"><a href="javascript:void(0)" id="a_email" onclick="$.oper.jstab('a_email');return false;">郵件</a></li>
                                        <li><a href="javascript:void(0)" id="a_sms" onclick="$.oper.jstab('a_sms');return false;">短信</a></li>
                                </ul>
                        </div>
                        <ul class="bk" id="foremail">
                                <li>
                                        <label><em>*</em>服務(wù)器IP:</label>
                                        <p>
                                                <input class="input_tx" value="<?php echo def((isset($this->scope["messageset"]["smtphost"]) ? $this->scope["messageset"]["smtphost"]:null));?>" name="smtphost" id="smtphost" type="text"/>
                                        </p>
                                </li>
                                <li>
                                        <label><em>*</em>服務(wù)器端口:</label>
                                        <p>
                                                <input class="input_tx" value="<?php echo def((isset($this->scope["messageset"]["smtpport"]) ? $this->scope["messageset"]["smtpport"]:null));?>" name="smtpport" id="smtpport" type="text"/>
                                        </p>
                                </li>
 
                                <li>
                                        <label><em>*</em>發(fā)件人郵箱:</label>
                                        <p>
                                                <input class="input_tx" value="<?php echo def((isset($this->scope["messageset"]["smtpuser"]) ? $this->scope["messageset"]["smtpuser"]:null));?>" name="smtpuser" id="smtpuser" type="text"/>
                                        </p>
                                </li>
 
                                <li>
                                        <label><em>*</em>發(fā)件人密碼:</label>
                                        <p>
                                                <input class="input_tx" value="<?php echo def((isset($this->scope["messageset"]["smtppass"]) ? $this->scope["messageset"]["smtppass"]:null));?>" name="smtppass" id="smtppass" type="text"/>
                                        </p>
                                </li>
 
                                <li>
                                        <label>測試郵箱:</label>
                                        <p>
                                                <input class="input_tx" value="" name="testemail" id="testemail" type="text"/>
                                                <a href="javascript:void(0);" onclick="jscheck('email');return false;" class="bt_style2">檢測</a>
                                        </p>
                                </li>
 
                        </ul>
 
                        <ul class="bk none" id="forsms">
                         <li>
                                        <label><em>*</em>短信寶用戶名:</label>
                                        <p>
                                                <input class="input_tx" value="<?php echo def((isset($this->scope["messageset"]["smsphone"]) ? $this->scope["messageset"]["smsphone"]:null));?>" name="smsphone"  id="smsphone" type="text" />
                                                (<a href="http://www.gjrencai.com/reg" target="_blank">立即申請</a>)
                                        </p>
                                </li>
                                <li>
                                        <label><em>*</em>短信寶密碼:</label>
                                        <p>
                                                <input class="input_tx" value="<?php echo def((isset($this->scope["messageset"]["smspass"]) ? $this->scope["messageset"]["smspass"]:null));?>" name="smspass" id="smspass" type="text" />
                                        </p>
                                </li>
                                <li>
                                        <label><em>*</em>短信簽名:</label>
                                        <p>
                                                <input class="input_tx" value="<?php echo def((isset($this->scope["messageset"]["smssign"]) ? $this->scope["messageset"]["smssign"]:null));?>" name="smssign" id="smssign" type="text" />
                                        </p>
                                </li>
                                <li>
                                        <label>測試手機:</label>
                                        <p>
                                                <input class="input_tx" value="" name="testsms" id="testsms" type="text"/>
                                                <a href="javascript:void(0);" onclick="jscheck('sms');return false;" class="bt_style2">檢測</a>
                                        </p>
                                </li>
                                <?php if ((isset($this->scope["messageset"]["smsphone"]) ? $this->scope["messageset"]["smsphone"]:null) && (isset($this->scope["messageset"]["smspass"]) ? $this->scope["messageset"]["smspass"]:null) && ! (isset($this->scope["user"]) ? $this->scope["user"] : null)) {
?>
                                <li>
                                        <label>提示:</label>
                                        <p>
                                                該用戶不合法,或短信服務(wù)器出錯
                                        </p>
                                </li>
                                <?php
}?>
 
                                <?php if ((isset($this->scope["user"]) ? $this->scope["user"] : null)) {
?>
                                <li>
                                        <label>統(tǒng)計:</label>
                                        <p>剩余短信:<?php echo $this->scope["user"];?> 條</p>
                                </li>
                                <?php
}?>
 
                        </ul>
                        <div class="bt_bk2">
                                <a href="javascript:void(0);" class="btn" onclick="jssubmit();return false;"><span>保存</span></a>
                        </div>
                </div>
                </form>
                <b class="b4b"></b><b class="b3b"></b><b class="b2b"></b><b class="b1b"></b>
        </div>
</div>
<?php echo Dwoo_Plugin_include($this, 'foot.html', array (
));?>
 
<script type="text/javascript">
$(function(){
        <?php if ((isset($this->scope["refer"]) ? $this->scope["refer"] : null) == "sms") {
?>
        $("#a_sms").click();
        <?php
}?>
 
});
function jscheck(type) {
        var postdata = {};
        if(type == 'sms') {
                var smsphone        = $.trim($("#smsphone").val()),
                        smspass                = $.trim($("#smspass").val()),
                        smssign                = $.trim($("#smssign").val()),
                        testsms                = $.trim($("#testsms").val());
                if(!smspass || !smspass || !testsms) {
                        jAlert("檢測條件不合法");
                        return ;
                }
                postdata = {type:type,smsphone:smsphone,smspass:smspass,testsms:testsms,smssign:smssign};
        } else if(type == "email") {
                var smtphost = $.trim($("#smtphost").val()),
                        smtpport = $.trim($("#smtpport").val()),
                        smtpuser = $.trim($("#smtpuser").val()),
                        smtppass = $.trim($("#smtppass").val()),
                        testemail = $.trim($("#testemail").val());
                if(!smtphost || !smtpport || !smtpuser || !smtppass || !testemail) {
                        jAlert("檢測條件不合法");
                        return false;
                }
                postdata = {type:type,smtphost:smtphost,smtpport:smtpport,smtpuser:smtpuser,smtppass:smtppass,testemail:testemail};
        }
        $.util.show();
        $.post("<?php echo url('admin', 'message', 'check');?>",postdata,function(data) {
                $.util.hide();
                if(data == "success") {
                        jAlert("已經(jīng)發(fā)送");
                } else {
                        jAlert(data);
                }
        });
}
</script><?php  /* end template body */
return $this->buffer . ob_get_clean();
?>

好了顯示的界面已經(jīng)是我們短信寶的了,我們?nèi)バ薷谋4娼涌谂渲梦募蜷_項目\include\admin\message.class.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
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
<?php
defined('IN_CART'or die;
/**
 *
 * 郵件短信設(shè)置
 
 */
class Message extends Base{
        /**
         *
         * 郵件短信設(shè)置
         
         */
        public function index() {
                $this->data["refer"]          = isset($_GET["refer"])?trim($_GET["refer"]):'email';
                $this->data["messageset"] = DB::getDB()->selectkv("config","key","val","type='messageset'");
                if(!empty($this->data["messageset"]["smsphone"]) && !empty($this->data["messageset"]["smspass"])) {
                        include_once COMMONPATH .  "/sms.class.php";
                        $sms new Sms($this->data["messageset"]["smsphone"],$this->data["messageset"]["smspass"]);
                        $this->data['user'] = $sms->getUser();
                }
                $this->output("message_index");
        }
 
        /**
         *
         * 保存郵件 對應(yīng)messageset
         
         */
        public function messagesave() {
                //接受參數(shù)
                $data["smtphost"]                = trim($_POST["smtphost"]);
                $data["smtpport"]                = trim($_POST["smtpport"]);
                $data["smtpuser"]                = trim($_POST["smtpuser"]);
                $data["smtppass"]                = trim($_POST["smtppass"]);
                $data["smsphone"]                = trim($_POST["smsphone"]);
                $data["smspass"]                = trim($_POST["smspass"]);
                $data["smssign"]                = trim($_POST["smssign"]);
                
                //替換配置
                $replacedata array();
                foreach($data as $key=>$val) {
                        $replacedata[] = array("key"=>$key,"val"=>$val,"type"=>'messageset');
                }
                $this->adminlog("al_message");
                if($replacedata) DB::getDB()->replaceMulti("config",$replacedata);
 
                $this->setHint(__("set_success",__('messageset')));
        }
 
        /**
         *
         * 檢測短信是否正確
         
         */
        public function check() {
                $type          = trim($_POST["type"]);
                $ret          = false;
                if($type == "email") {
                        $smtphost  = trim($_POST["smtphost"]);
                        $smtpport  = trim($_POST["smtpport"]);
                        $smtpuser  = trim($_POST["smtpuser"]);
                        $smtppass  = trim($_POST["smtppass"]);
                        $testemail = trim($_POST["testemail"]);
                        require COMMONPATH. "/send.class.php";
                        $sendmail         new SendEmail($smtphost,$smtpport,$smtpuser,$smtppass);
                        $subject         = __("testemail");
                        $content         = __("testemail");
                        $ret                 $sendmail->send($testemail,$subject,$content);
                        exit($ret?"success":$sendmail->getError());
 
                else if($type == "sms") {
                        $smsphone = trim($_POST["smsphone"]);
                        $smspass  = trim($_POST["smspass"]);
                        $smssign  = trim($_POST["smssign"]);
                        $testsms  = trim($_POST["testsms"]);
 
                        include_once COMMONPATH . "/sms.class.php";
                        $sms                new Sms($smsphone,$smspass,$smssign);
                        $content        = __("testsms");
                        $ret                $sms->send($testsms,$content);
                        exit($ret?"success":$sms->getError());
                }
        }
        
        /**
         *
         * 模版設(shè)置 
         
         */
        public function tplset() {
                $this->data["message_list"] = DB::getDB()->select("message_set","*");
                $this->output("messagetpl_index");
        }
 
        /**
         *
         * 保存模版設(shè)置 
         
         */
        public function tplsetsave() {
                $codes                $_POST["code"];
                $emails                = isset($_POST["email"])?$_POST["email"]:array();
                $mobiles        = isset($_POST["mobile"])?$_POST["mobile"]:array();
                $letters        = isset($_POST["letter"])?$_POST["letter"]:array();
                
                foreach($codes as $code) {
                        $email        = isset($emails[$code]) ? intval($emails[$code]) : 0;
                        $mobile        = isset($mobiles[$code]) ? intval($mobiles[$code]) : 0;
                        $letter = isset($letters[$code]) ? intval($letters[$code]) : 0;
                        DB::getDB()->update("message_set",array("email"=>$email,"mobile"=>$mobile,"letter"=>$letter),"code='$code'");
                }
                $this->adminlog("al_message_tpl");
                $this->setHint(__("set_success",__('messagetpl')),"message_tplset");
        }
 
        /**
         *
         * 修改模版 
         
         */
         public function tpledit() {
                if(ispostreq()) {
                        $code                = trim($_POST["code"]);
                        $content        str_replace(array("{","}"),array("{","}"),trim($_POST["content"]));
                        $method                = trim($_POST["method"]);
                        !in_array($method,array("mobile","email","letter")) && $method 'mobile';
                        
                        $this->adminlog("al_message_tpl2",array("code"=>$code,"method"=>__($method)));
                        DB::getDB()->update("message_set","{$method}cont='$content'","code='$code'");
                        $this->setHint(__("set_success",__('tpl')),"message_tplset");
                else {
                        $method                        = trim($_GET["method"]);
                        $code                        = trim($_GET["code"]);
                        !in_array($method,array('mobile','email','letter')) && $method 'mobile';
                        
                        $field $method."cont";
                        $this->data['tpl']                = DB::getDB()->selectrow("message_set","text,$field","code='$code'"); //如果模版不存在
                        $this->data['code']                = $code;
                        $this->data['field']        = $field;
                        $this->data['method']        = $method;
 
                        $this->data['leftcur']        = "message_tplset";
                        $this->output("messagetpl_oper");
                }
         }
}

接下來我們?nèi)バ薷恼{(diào)用短信接口的文件,打開項目\include\common\send.class.php 文件,修改SendSms類,修改代碼為:

?
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
class SendSms {
        
        
        var $sms;
        
        /**
         *
         * 構(gòu)造函數(shù),確定smtp信息
         
         */
        public function __construct() {
                $smsphone = getConfig('smsphone');
                $smspass  = getConfig('smspass');
                $smssign  = getConfig('smssign');
                include_once COMMONPATH."/sms.class.php";
                $this->sms = new Sms($smsphone,$smspass,$smssign);
        }
        
        /**
         *
         * 發(fā)送
         
         */
        public function send($phone,$content) {
                return $this->sms->send($phone,$content,$smssign);
        }
 
        public function getError() {
                return $this->sms->getError();
        }
}

最后我們?nèi)バ薷亩绦沤涌谖募蜷_項目\include\common\sms.class.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
 
defined('IN_CART'or die;
 
require_once COMMONPATH . "/http.class.php";
 
/**
 *
 *
 * 短信發(fā)送類
 *
 */
class Sms {
        
        protected $http;        //http訪問類
        
        protected $url                "http://api.smsbao.com"; //sms短信接口
        
        protected $smsphone        ""//sms登錄手機號
 
        protected $smspass        "";//sms登錄密碼
 
        protected $smssign        "";//sms簽名
        
        protected $error                "";
        /**
         *
         *
         * 構(gòu)造函數(shù)
         *
         */
        public function __construct($smsphone "",$smspass "",$smssign "") {
                $this->http = new Http();
                $this->smsphone = $smsphone;
                $this->smspass  = md5($smspass);
                $this->smssign  = $smssign;
        }
        
        /**
         *
         *
         * 驗證用戶是否正確,如果正確,返回用戶信息,
         *
         */
        public function getUser() {
                if(!$this->smsphone || !$this->smspass) return null;
                $ret $this->http->post($this->url ."/query",array("u"=>$this->smsphone,"p"=>$this->smspass));
                $ret explode(','$ret);
                return $ret['1'];
        }
        
        /**
         *
         *
         * 發(fā)送短信
         *
         */
        public function send($phone,$content) {
                if(!$this->smsphone || !$this->smspass) return null;
                $ret $this->http->post($this->url."/sms",array("u"=>$this->smsphone,"p"=>$this->smspass,"m"=>$phone,"c"=>"【".$this->smssign."】".$content));
                if($ret == 0) {
                        return true;
                }else{
                        $this->error = $ret;
                }
                return false;
        }
        
        /**
         *
         *
         * 發(fā)送短信
         *
         */
        public function getError() {
                return $this->error;
        
}

好了,經(jīng)過以上的替換,短信寶的短信平臺已經(jīng)替換成功了,我們?nèi)ミM行發(fā)送測試:

報備一下短信寶的VIP模板,這樣就可以走短信寶的優(yōu)質(zhì)通道了,并且免審核了,短信內(nèi)容3~5秒就可送達。
開源插件

最新更新

電商類

CMS類

微信類

文章標簽