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


待發短信

在線客服
產品支持 短信寶客服
合作渠道 渠道合作
服務咨詢

4001-021-502

工作時間

9:00-21:00

五指cms網站管理系統新增短信寶短信接口

五指CMS是國內新一代、能夠實現跨屏管理的網站內容管理系統,是國內家后臺管理界面全部采用HTML5+CSS3技術的內容管理系統(CMS),該系統采用了PHP5+MYSQL做為技術基礎進行開發。采用了面向對象的編程方式,多層架構設計,模塊化的開發方式。系統功能易于擴展,易于二次開發,支持站群。今天小編就已替換短信接口為例為大家講解一下如何進行二次開發,我們講解的是v4.1.0版本,使用的短信接口是我們短信寶短信群發平臺的接口,我們短信寶短信群發平臺非常穩定,發送速度快,注冊就送測試短信,推薦大家使用。

首先我們更換后臺顯示界面,打開項目\coreframe\app\sms\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
50
51
52
53
<?php defined('IN_WZ') or exit('No direct script access allowed');?>
<?php
include $this->template('header','core');
?>
<body class="body pxgridsbody">
<section class="wrapper">
    <div class="row">
        <div class="col-lg-12">
            <section class="panel">
                <?php echo $this->menu($GLOBALS['_menuid']);?>
                <div class="panel-body">
                    <form class="form-horizontal tasi-form" method="post" action="">
                        <div class="form-group">
                            <label class="col-sm-2 col-xs-4 control-label">短信寶用戶名</label>
                            <div class="col-lg-3 col-sm-4 col-xs-4 input-group">
                                <input type="text" class="form-control" name="form[sms_uid]"  value="<?php echo output($setting,'sms_uid');?>" placeholder="">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 col-xs-4 control-label">短信寶密碼</label>
                            <div class="col-lg-3 col-sm-4 col-xs-4 input-group">
                                <input type="password" class="form-control" name="form[sms_pid]" value="<?php echo output($setting,'sms_pid');?>">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 col-xs-4 control-label">短信簽名</label>
                            <div class="col-lg-3 col-sm-4 col-xs-4 input-group">
                                <input type="text" class="form-control" name="form[sms_passwd]" value="<?php echo output($setting,'sms_passwd');?>">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 col-xs-4 control-label"></label>
                                <div class="col-lg-3 col-sm-4 col-xs-4 input-group">
                                    <input class="btn btn-info col-sm-12 col-xs-12" type="submit" name="submit" value="提交">
                                </div>
                        </div>
                    </form>
                </div>
 
            </section>
        </div>
    </div>
    <!-- page end--><div class="alert alert-success fade in">
        <strong>短信購買:</strong> 支持全國電信、移動、聯通手機用戶。購買地址 <a href="http://www.gjrencai.com" target="_blank">http://www.gjrencai.com</a>    </div>
</section>
<script src="<?php echo R;?>js/bootstrap.min.js"></script>
<script src="<?php echo R;?>js/jquery.nicescroll.js" type="text/javascript"></script>
<script src="<?php echo R;?>js/pxgrids-scripts.js"></script>

其次我們修改短信發送類,打開項目\coreframe\app\sms\libs\class\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
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
<?php
defined('IN_WZ'or exit('No direct script access allowed');
/**
 * 短信API
 */
class WUZHI_sms {
    public $uid;
    public $statuscode;
    private $sms_uid,$sms_pid,$sms_key,$smsapi_url;
    
    /**
     
     * 初始化接口類
     * @param int $uid 用戶id
     * @param int $sms_pid 產品id
     * @param string $sms_key 密鑰
     */
    public function __construct() {
        $this->smsapi_url = 'http://api.smsbao.com/sms?';
        $sms_config = get_cache('sms_config','sms');
        $this->sms_uid = $sms_config['sms_uid'];
        $this->sms_pid = $sms_config['sms_pid'];
        $this->sms_key = $sms_config['sms_passwd'];
    }
        
    /**
     
     * 獲取短信產品列表信息
     */
    public function get_price() {
        return [];
    }
    
    /**
     
     * 獲取短信產品購買地址
     */
    public function get_buyurl($productid = 0) {
        return [];
    }
 
    /**
     * 獲取短信剩余條數和限制短信發送ip
     */
    public function get_smsinfo() {
        return [];
    }  
 
    /**
     * 獲取充值記錄
     */
    public function get_buyhistory() {
        return [];        
    }
 
    /**
     * 獲取消費記錄
     * @param int $page 頁碼
     */
    public function get_payhistory($page=1) {
        return [];    
    }
 
    /**
     * 發送短信
     *
     * @param string $mobile
     * @param string $content
     * @param string $tplid
     * @param string $send_time
     * @param int $return_code
     * @return mixed
     */
    public function send_sms($mobile=''$content='',$tplid ''$send_time =''$return_code = 0) {
        //短信發送狀態
        $status $this->_sms_status();
        if(is_array($mobile)){
            $mobile = implode(","$mobile);
        }
        /*if(strtolower(CHARSET)=='utf-8') {
            $send_content = iconv('utf-8','gbk',$content);
        }else{
            $send_content = $content;
        }*/
        //$send_content = $content;
        //$send_time = strtotime($send_time);
        //短信模板
        $sitelist = get_cache('sitelist');
        $siteid intval($GLOBALS['siteid']);
        $sms_param=explode('||'$content);
        if($tplid==269){
            //發送優惠券信息,尊敬的用戶,五指CMS優惠券為:sss,截止日期為:2016-12-1,請登錄www.h1jk.cn及時使用!
            $tpl="尊敬的用戶您好,恭喜你獲得優惠券,卡號為:%s,截止日期為:%s,請及時使用,請登錄".$sitelist[$siteid]['url']s;
            $sms_content=sprintf($tpl,$sms_param[0],$sms_param[1]);
        }elseif($tplid==222){
            //您的預約卡信息如下:<br>卡號:{$r['card_no']} <br> 密碼:{$card_password}<br>
            $tpl="您的預約卡信息如下:卡號:%s, 密碼:%s!";
            $sms_content=sprintf($tpl,$content);
        }else{
            //驗證碼
            $tpl="您的驗證碼為:%s,請不要告訴他人。";
            $sms_content=sprintf($tpl,$sms_param[0],$sms_param[1]);
        }
        $data array(
            'u' => $this->sms_uid,
            'p' => md5($this->sms_pid),
            'c' => "【".$this->sms_key."】".$sms_content,
            'm' => $mobile,
        );
        $send_res=file_get_contents($this->smsapi_url.http_build_query($data));
        
        //echo $this->smsapi_url.http_build_query($data);
        return $send_res;
    }
        
    /**
     
     * 獲取遠程內容
     * @param $timeout 超時時間
     */
    public function getinfo($timeout=30) {
        
        $this->setting = array(
                            'sms_uid'=>$this->sms_uid,
                            'sms_pid'=>$this->sms_pid,
                            'sms_passwd'=>$this->sms_key,
                            );
                                    
        $this->param = array_merge($this->param, $this->setting);
        
        $url $this->smsapi_url.http_build_query($this->param);
        $stream = stream_context_create(array('http' => array('timeout' => $timeout)));
        return @file_get_contents($url, 0, $stream);
    }
    
    /**
     *  post數據
     *  @param string $url     post的url
     *  @param int $limit      返回的數據的長度
     *  @param string $post        post數據,字符串形式username='dalarge'&password='123456'
     *  @param string $cookie  模擬 cookie,字符串形式username='dalarge'&password='123456'
     *  @param string $ip      ip地址
     *  @param int $timeout        連接超時時間
     *  @param bool $block     是否為阻塞模式
     *  @return string          返回字符串
     */
    
    private function _post($url$limit = 0, $post ''$cookie ''$ip ''$timeout = 30, $block = true) {
        $return '';
        $matches parse_url($url);
        $host $matches['host'];
        $path $matches['path'] ? $matches['path'].($matches['query'] ? '?'.$matches['query'] : '') : '/';
        $port = !empty($matches['port']) ? $matches['port'] : 80;
        $siteurl = URL();
        if($post) {
            $out "POST $path HTTP/1.1\r\n";
            $out .= "Accept: */*\r\n";
            $out .= "Referer: ".$siteurl."\r\n";
            $out .= "Accept-Language: zh-cn\r\n";
            $out .= "Content-Type: application/x-www-form-urlencoded\r\n";
            $out .= "User-Agent: $_SERVER[HTTP_USER_AGENT]\r\n";
            $out .= "Host: $host\r\n" ;
            $out .= 'Content-Length: '.strlen($post)."\r\n" ;
            $out .= "Connection: Close\r\n" ;
            $out .= "Cache-Control: no-cache\r\n" ;
            $out .= "Cookie: $cookie\r\n\r\n" ;
            $out .= $post ;
        else {
            $out "GET $path HTTP/1.1\r\n";
            $out .= "Accept: */*\r\n";
            $out .= "Referer: ".$siteurl."\r\n";
            $out .= "Accept-Language: zh-cn\r\n";
            $out .= "User-Agent: $_SERVER[HTTP_USER_AGENT]\r\n";
            $out .= "Host: $host\r\n";
            $out .= "Connection: Close\r\n";
            $out .= "Cookie: $cookie\r\n\r\n";
        }
        $fp = @fsockopen(($ip $ip $host), $port$errno$errstr$timeout);
        if(!$fpreturn '';
    
        stream_set_blocking($fp$block);
        stream_set_timeout($fp$timeout);
        @fwrite($fp$out);
        $status = stream_get_meta_data($fp);
    
        if($status['timed_out']) return '';  
        while (!feof($fp)) {
            if(($header = @fgets($fp)) && ($header == "\r\n" ||  $header == "\n"))  break;            
        }
        
        $stop = false;
        while(!feof($fp) && !$stop) {
            $data fread($fp, ($limit == 0 || $limit > 8192 ? 8192 : $limit));
            $return .= $data;
            if($limit) {
                $limit -= strlen($data);
                $stop $limit <= 0;
            }
        }
        @fclose($fp);
        
        //部分虛擬主機返回數值有誤,暫不確定原因,過濾返回數據格式
        $return_arr explode("\n"$return);
        if(isset($return_arr[1])) {
            $return = trim($return_arr[1]);
        }
        unset($return_arr);
        
        return $return;
    }
 
    /**
     
     * 接口短信狀態
     */
    private function _sms_status() {
        $array array(
            '0'=>'發送成功',
            "-1" => "參數不全",
            "-2" => "服務器空間不支持,請確認支持curl或者fsocket,聯系您的空間商解決或者更換空間!",
            "30" => "密碼錯誤",
            "40" => "賬號不存在",
            "41" => "余額不足",
            "42" => "帳戶已過期",
            "43" => "IP地址限制",
            "50" => "內容含有敏感詞",
        );
        return $array;
    }
    
}
?>

最后修改發送短信文件,打開項目\coreframe\app\sms\sms.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
<?php
defined('IN_WZ'or exit('No direct script access allowed');
/**
 * 發送短信驗證碼
 */
class sms{
    public function __construct() {
        $this->db = load_class('db');
    }
 
    /**
     * 發送短信(手機短信驗證碼、圖片驗證碼)
     */
    public function sendsms() {
        //驗證 頁面驗證碼是否正確
        //插入相關信息
        /**
        1、使用安全圖片驗證碼(網站)
        2、單IP的請求次數限定 (網站)(APP)
        3、單用戶動態短信請求間隔時長限制(網站)(APP)
        4、  同一手機號次數限定 (網站)(APP)
         */
        $config = get_cache('sms_config','sms');
        $uid = get_cookie('_uid');
        $mobile $GLOBALS['mobile'];
        if(!preg_match('/^(?:13\d{9}|15[0|1|2|3|5|6|7|8|9]\d{8}|17[0|1|2|3|5|6|7|8|9]\d{8}|18[0|1|2|3|5|6|7|8|9]\d{8}|14[5|7]\d{8})$/',$mobile)) {
            exit('201');
        }
        $checkcode $GLOBALS['checkcode'];
        if($checkcode==''exit('202');
        load_class('session');
        if(strtolower($_SESSION['code']) != strtolower($checkcode)) exit('202');
        $_SESSION['code'] = '';
 
        $endtime = SYS_TIME-120;
 
        if($_SESSION['et'] && $_SESSION['et']>$endtime) {
            if($config['sms_uid']!='test') {
                exit('204');
            }
        else {
            $_SESSION['et'] = SYS_TIME;
        }
        if(isset($GLOBALS['isreg']) && $GLOBALS['isreg']) {//是否為注冊,驗證手機是否已注冊
            $reg_data $this->db->get_one('member'array('mobile' => $mobile),'uid');
            if($reg_data) {
                exit('206');
            }
        }
        $posttime = SYS_TIME-86400;
        $ip = get_ip();
        $where "`ip`='$ip' AND `posttime`>$posttime";
        $num $this->db->count_result('sms_checkcode',$where);
        if($num>200 && $config['sms_uid']!='test') {//單IP 24小時內最大請求次數限定
            exit('203');
        }
 
        //單用戶動態短信請求間隔時長限制 ,根據手機號碼判斷是否為一個用戶
        $where "`mobile`='$mobile'";
        $r $this->db->get_one('sms_checkcode',$where'*', 0,'id DESC' );
 
        if($r['posttime']>$endtime && $config['sms_uid']!='test') {//120 秒之內連續請求
            exit('204');
        }
 
 
        //同一手機號次數限定
        $where "`mobile`='$mobile' AND `posttime`>=$posttime";
        $num $this->db->count_result('sms_checkcode',$where);
        if($num>200 && $config['sms_uid']!='test') {//同一手機號次數限定 24小時內最大請求次數限定
            exit('205');
        }
//驗證通過
 
        $sendsms = load_class('sms','sms');
        if($config['sms_uid']!='test') {
            $code = rand(1000,9999);
        else {
            $code = 1111;
        }
 
        $formdata array();
        $formdata['mobile'] = $mobile;
        $formdata['uid'] = $uid;
        $formdata['posttime'] = SYS_TIME;
        $formdata['code'] = $code;
        $formdata['ip'] = $ip;
        $this->db->insert('sms_checkcode'$formdata);
        if($config['sms_uid']!='test') {
            $returnstr $sendsms->send_sms($mobile$code, 1); //發送短信
            if($returnstr==0) {
                exit('0');
            else {
                echo $returnstr;
            }
        else {
            exit('0');
        }
    }
}
?>

好了,經過以上的替換,短信寶的短信平臺已經替換成功了,我們去進行發送測試:

報備一下短信寶的VIP模板,這樣就可以走短信寶的優質通道了,并且免審核了,短信內容3~5秒就可送達。

另外:我們已經開發好完整的五指cms網站管理系統短信寶插件,點擊此鏈接 下載及查看安裝流程。

開源插件

最新更新

電商類

CMS類

微信類

文章標簽