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


待發(fā)短信

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

4001-021-502

工作時(shí)間

9:00-21:00

PbootCMS_V3.2.8新增短信寶短信接口

PbootCMS是全新內(nèi)核且永久開源免費(fèi)的PHP企業(yè)網(wǎng)站開發(fā)建設(shè)管理系統(tǒng),是一套高效、簡潔、 強(qiáng)悍的可免費(fèi)商用的PHP CMS源碼,能夠滿足各類企業(yè)網(wǎng)站開發(fā)建設(shè)的需要。系統(tǒng)采用簡單到想哭的模板標(biāo)簽,只要懂HTML就可快速開發(fā)企業(yè)網(wǎng)站。小編對(duì)他還是比較了解的,今天小編就以新增短信接口為例,給大家講解一下如何進(jìn)行二次開發(fā),我們今天講解的是v3.2.8版本,使用的短信接口是我們短信寶短信群發(fā)平臺(tái)的短信接口,我們短信寶短信群發(fā)平臺(tái)的接口非常穩(wěn)定,發(fā)送速度快,注冊(cè)就送測試短信,推薦大家使用
1:打開項(xiàng)目:apps\admin\view\default\system\config.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
        <ul class="layui-tab-title">
            <li class="layui-this" lay-id="t1">基本配置</li>
            <li  lay-id="t2">郵件通知</li>
            <li  lay-id="t3">百度接口</li>
            <li  lay-id="t4">WebAPI</li>
            <li  lay-id="t5">圖片水印</li>
            <li  lay-id="t6">安全配置</li>
            <li  lay-id="t7">URL規(guī)則</li>
            <li  lay-id="t8">標(biāo)題樣式</li>
            <li  lay-id="t9">會(huì)員配置</li>
            <li  lay-id="t10">短信配置</li>
        </ul>
<div class="layui-tab-item">
                <form action="{url./admin/Config/index}" method="post" class="layui-form">
                    <input type="hidden" name="formcheck" value="{$formcheck}" >
 
                    <div class="layui-form-item">
                        <label class="layui-form-label">是否開啟</label>
                        <div class="layui-input-block">
                            <input type="radio" name="sms_status" value="1" {if([$configs.sms_status.value]==1)} checked="checked" {/if} title="是">
                            <input type="radio" name="sms_status" value="0" {if([$configs.sms_status.value]==0)} checked="checked" {/if} title="否">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">短信寶賬號(hào)</label>
                        <div class="layui-input-inline">
                            <input type="text" name="sms_account"  value="{$configs.sms_account.value}" placeholder="請(qǐng)輸入短信寶賬號(hào)" class="layui-input">
                        </div>
                    </div>
 
                    <div class="layui-form-item">
                        <label class="layui-form-label">短信寶密碼</label>
                        <div class="layui-input-inline">
                            <input type="password" name="sms_pwd" value="{$configs.sms_pwd.value}" placeholder="請(qǐng)輸入短信寶密碼" class="layui-input">
                        </div>
                    </div>
 
                    <div class="layui-form-item">
                        <label class="layui-form-label">短信寶簽名</label>
                        <div class="layui-input-inline">
                            <input type="text" name="sms_signid"  value="{$configs.sms_signid.value}" placeholder="請(qǐng)輸入短信寶簽名" class="layui-input">
                        </div>
                    </div>
 
                    <div class="layui-form-item">
                        <label class="layui-form-label">留言發(fā)送短信</label>
                        <div class="layui-input-block">
                            <input type="radio" name="message_send_sms" value="1" {if([$configs.message_send_sms.value]==1)} checked="checked" {/if} title="啟用">
                            <input type="radio" name="message_send_sms" value="0" {if([$configs.message_send_sms.value]==0)} checked="checked" {/if} title="禁用">
                        </div>
                    </div>
 
                    <div class="layui-form-item">
                        <label class="layui-form-label">表單發(fā)送短信</label>
                        <div class="layui-input-block">
                            <input type="radio" name="form_send_sms" value="1" {if([$configs.form_send_sms.value]==1)} checked="checked" {/if} title="啟用">
                            <input type="radio" name="form_send_sms" value="0" {if([$configs.form_send_sms.value]==0)} checked="checked" {/if} title="禁用">
                        </div>
                    </div>
 
                    <div class="layui-form-item">
                        <label class="layui-form-label">評(píng)論發(fā)送短信</label>
                        <div class="layui-input-block">
                            <input type="radio" name="comment_send_sms" value="1" {if([$configs.comment_send_sms.value]==1)} checked="checked" {/if} title="啟用">
                            <input type="radio" name="comment_send_sms" value="0" {if([$configs.comment_send_sms.value]==0)} checked="checked" {/if} title="禁用">
                        </div>
                    </div>
 
                    <div class="layui-form-item">
                        <label class="layui-form-label">信息接收手機(jī)號(hào)</label>
                        <div class="layui-input-inline">
                            <input type="text" name="sms_send_to"  value="{$configs.sms_send_to.value}" placeholder="請(qǐng)輸入信息接收手機(jī)號(hào)"  class="layui-input">
                        </div>
                    </div>

2:在當(dāng)前頁面同時(shí)增加短信注冊(cè)驗(yàn)證碼 大概在707行

1
2
3
4
5
6
7
8
9
<div class="layui-form-item">
        <label class="layui-form-label">會(huì)員注冊(cè)驗(yàn)證碼</label>
        <div class="layui-input-block">
            <input type="radio" name="register_check_code" value="0" {if([$configs.register_check_code.value]=='0')} checked="checked" {/if} title="禁用">
            <input type="radio" name="register_check_code" value="1" {if([$configs.register_check_code.value]=='1'||[$configs.register_check_code.value]=='')} checked="checked" {/if} title="普通驗(yàn)證碼">
            <input type="radio" name="register_check_code" value="2" {if([$configs.register_check_code.value]=='2')} checked="checked" {/if} title="郵箱驗(yàn)證碼">
             <input type="radio" name="register_check_code" value="3" {if([$configs.register_check_code.value]=='3')} checked="checked" {/if} title="短信驗(yàn)證碼">
        </div>
    </div>

3:打開項(xiàng)目:apps\admin\controller\system\ConfigController.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
       if ($_POST) {
            unset($_POST['upload']); // 去除上傳組件
            if (isset($_POST['sn'])) {
                $_POST['licensecode'] = base64_encode(post('sn') . '/' . post('sn_user')) . substr(post('sn'), 1, 1);
            }
            foreach ($_POST as $key => $value) {
                if (! preg_match('/^[\w\-]+$/', $key)) {
                    continue;
                }
                $config = array(
                    'debug',
                    // 'sn',
                    // 'sn_user',
                    'pagenum',
                    'tpl_html_cache',
                    'tpl_html_cache_time',
                    'session_in_sitepath'
                );
                if (in_array($key, $config)) {
                    if ($key == 'tpl_html_cache_time' && ! $value) {
                        $value = 900;
                    else {
                        $value = post($key);
                    }
                    $this->modConfig($key, $value);
                else {
                    $this->modDbConfig($key);
                }
            }
             
            $this->log('修改參數(shù)配置成功!');
            path_delete(RUN_PATH . '/config'); // 清理緩存的配置文件
             
            switch (post('submit')) {
                case 'email':
                    success('修改成功!', url('/admin/Config/index' . get_tab('t2'), false));
                    break;
                case 'baidu':
                    success('修改成功!', url('/admin/Config/index' . get_tab('t3'), false));
                    break;
                case 'api':
                    success('修改成功!', url('/admin/Config/index' . get_tab('t4'), false));
                    break;
                case 'watermark':
                    success('修改成功!', url('/admin/Config/index' . get_tab('t5'), false));
                    break;
                case 'security':
                    success('修改成功!', url('/admin/Config/index' . get_tab('t6'), false));
                    break;
                case 'urlrule':
                    success('修改成功!', url('/admin/Config/index' . get_tab('t7'), false));
                    break;
                case 'pagetitle':
                    success('修改成功!', url('/admin/Config/index' . get_tab('t8'), false));
                    break;
                case 'member':
                    success('修改成功!', url('/admin/Config/index' . get_tab('t9'), false));
                    break;
                case 'upgrade':
                    success('修改成功!', url('/admin/Upgrade/index' . get_tab('t2'), false));
                    break;
                case 'sms':
                    success('修改成功!', url('/admin/Config/index' . get_tab('t10'), false));
                    break;
                default:
                    success('修改成功!', url('/admin/Config/index'false));
            }
        }

4:打開項(xiàng)目:template\default\html\member\register.html 修改注冊(cè)頁面

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
<div class="container pages">
 
    {include file=comm/position.html}
 
    <!-- 用戶注冊(cè) -->
    <div class="row">
        <div class="col-lg-3"></div>
        <div class="col-12 col-lg-6">
            <form class="my-4" onsubmit="return register(this);">
                {pboot:if({pboot:registercodestatus}==3)}
                <div class="form-group">
                    <label for="username">手機(jī)號(hào)</label>
                    <input type="text" name="username" required id="username" onblur="isRegister()" class="form-control" placeholder="請(qǐng)輸入登錄賬號(hào)">
                    <div id="usernote"></div>
                </div>
                {else}
                <div class="form-group">
                    <label for="username">賬 號(hào)</label>
                    <input type="text" name="username" required id="username" onblur="isRegister()" class="form-control" placeholder="請(qǐng)輸入登錄賬號(hào)">
                    <div id="usernote"></div>
                </div>
                {/pboot:if}
 
                 
                <div class="form-group">
                    <label for="nickname">昵 稱</label>
                    <input type="text" name="nickname" required id="nickname" class="form-control" placeholder="請(qǐng)輸入賬號(hào)昵稱">
                </div>
                 
                <div class="form-group">
                    <label for="password">密 碼</label>
                    <input type="password" name="password" required id="password" class="form-control" placeholder="請(qǐng)輸入登錄密碼">
                </div>
                 
                <div class="form-group">
                    <label for="rpassword">確認(rèn)密碼</label>
                    <input type="password" name="rpassword" required id="rpassword" class="form-control" placeholder="請(qǐng)?jiān)俅屋斎氲卿浢艽a">
                </div>
                 
                {pboot:if({pboot:registercodestatus}==1)}
                <div class="form-group">
                    <label for="checkcode">驗(yàn)證碼</label>
                    <div class="row">
                        <div class="col-6">
                            <input type="text" name="checkcode" required id="checkcode" class="form-control" placeholder="請(qǐng)輸入驗(yàn)證碼">
                        </div>
                        <div class="col-6">
                            <img title="點(diǎn)擊刷新" style="height:33px;" id="codeimg" src="{pboot:checkcode}" onclick="this.src='{pboot:checkcode}?'+Math.round(Math.random()*10);" />
                        </div>
                    </div>
                </div>
                {/pboot:if}
                 
                {pboot:if({pboot:registercodestatus}==2)}
                <div class="form-group">
                    <label for="checkcode">郵箱驗(yàn)證碼</label>
                    <div class="row">
                        <div class="col-6">
                            <input type="text" name="checkcode" required id="checkcode" class="form-control" placeholder="請(qǐng)輸入驗(yàn)證碼">
                        </div>
                        <div class="col-6">
                            <span  class="btn btn-info mb-2" onclick="sendEmail();">發(fā)送</span>
                        </div>
                    </div>
                </div>
                {/pboot:if}
 
                {pboot:if({pboot:registercodestatus}==3)}
                <div class="form-group">
                    <label for="checkcode">手機(jī)驗(yàn)證碼</label>
                    <div class="row">
                        <div class="col-6">
                            <input type="text" name="checkcode" required id="checkcode" class="form-control" placeholder="請(qǐng)輸入驗(yàn)證碼">
                        </div>
                        <div class="col-6">
                            <span  class="btn btn-info mb-2" onclick="sendSms();">發(fā)送</span>
                        </div>
                    </div>
                </div>
                {/pboot:if}
                <div class="form-group">
                   <button type="submit" class="btn btn-info mb-2">立即注冊(cè)</button>
                   <span class="text-secondary ml-3">已有賬號(hào)?<a href="{pboot:login}">馬上登錄</a></span>
                </div>
            </form>
        </div>
        <div class="col-lg-3"></div>
    </div> 
</div>

5:打開項(xiàng)目:template\default\html\member\retrieve.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
{include file=comm/head.html}
 
{include file=comm/top.html}
 
<div class="container pages">
 
  {include file=comm/position.html}
 
  <!-- 用戶密碼找回 -->
  <div class="row">
    <div class="col-lg-3"></div>
    <div class="col-12 col-lg-6">
      <form class="my-4" onsubmit="return retrieve(this);">
        {pboot:if({pboot:registercodestatus}==3)}
        <div class="form-group">
          <label for="username">手機(jī)號(hào)</label>
          <input type="text" name="username" required id="username" onblur="isRegister()" class="form-control" placeholder="請(qǐng)輸入已注冊(cè)賬號(hào)">
          <div id="usernote"></div>
        </div>
        {else}
        <div class="form-group">
          <label for="username">賬  號(hào)</label>
          <input type="text" name="username" required id="username" class="form-control" placeholder="請(qǐng)輸入已注冊(cè)賬號(hào)">
        </div>
        <div class="form-group">
          <label for="email">郵 箱</label>
          <input type="text" name="email" required id="email" class="form-control" placeholder="請(qǐng)輸入已注冊(cè)郵箱">
          <div id="emailnote"></div>
        </div>
        {/pboot:if}
        {pboot:if({pboot:registercodestatus}==3)}
        <div class="form-group">
          <label for="checkcode">手機(jī)驗(yàn)證碼</label>
          <div class="row">
            <div class="col-6">
              <input type="text" name="checkcode" required id="checkcode" class="form-control" placeholder="請(qǐng)輸入驗(yàn)證碼">
            </div>
            <div class="col-6">
              <span  class="btn btn-info mb-2" onclick="sendSms();">發(fā)送</span>
            </div>
          </div>
        </div>
        {else}
        <div class="form-group">
          <label for="checkcode">郵箱驗(yàn)證碼</label>
          <div class="row">
            <div class="col-6">
              <input type="text" name="checkcode" required id="checkcode" class="form-control" placeholder="請(qǐng)輸入驗(yàn)證碼">
            </div>
            <div class="col-6">
              <span  class="btn btn-info mb-2" onclick="sendEmail();">發(fā)送</span>
            </div>
          </div>
        </div>
        {/pboot:if}
        <div class="form-group">
          <label for="password">新密碼</label>
          <div class="row">
            <div class="col-6">
              <input type="password" name="password" required id="password" class="form-control" placeholder="請(qǐng)輸入新的密碼">
            </div>
          </div>
        </div>
        <div class="form-group">
          <button type="submit" class="btn btn-info mb-2">確認(rèn)</button>
        </div>
      </form>
    </div>
    <div class="col-lg-3"></div>
  </div>
</div>
 
<script>
 
  //找回密碼
  function retrieve(obj){
    var url='{pboot:retrieve}';
    var username = $(obj).find("#username").val();
    var email=$(obj).find("#email").val();
    var checkcode=$(obj).find("#checkcode").val();
    var password=$(obj).find("#password").val();
 
    $.ajax({
      type: 'POST',
      url: url,
      dataType: 'json',
      data: {
        username:username,
        email: email,
        checkcode: checkcode,
        password: password,
      },
      success: function (response, status) {
        if(response.code){
          alert("密碼設(shè)置成功!");
          location.href= response.tourl;
        }else{
          $('#codeimg').click();
          alert(response.data);
        }
      },
      error:function(xhr,status,error){
        alert('返回?cái)?shù)據(jù)異常!');
      }
    });
    return false;
  }
 
  //發(fā)送郵件驗(yàn)證碼
  function sendEmail(){
    var url='{pboot:sendemail}';
    var email=$("#email").val();
    if(!email){
      $("#emailnote").removeClass("valid-feedback");
      $("#emailnote").text("請(qǐng)輸入注冊(cè)郵箱!");
      return false;
    }
    $.ajax({
      type: 'POST',
      url: url,
      dataType: 'json',
      data: {
        retrieve:1,
        to: email
      },
      success: function (response, status) {
        if(response.code){
          alert(response.data);
        }else{
          alert(response.data);
        }
      },
      error:function(xhr,status,error){
        alert('返回?cái)?shù)據(jù)異常!');
      }
    });
    return false;
  }
  //發(fā)送短信驗(yàn)證碼
  function sendSms(){
    var url='{pboot:retrievesms}';
    var username=$("#username").val();
    if(!username){
      $("#username").addClass("is-invalid");
      $("#usernote").addClass("invalid-feedback");
      $("#username").removeClass("is-valid");
      $("#usernote").removeClass("valid-feedback");
      $("#usernote").text("請(qǐng)輸入需要注冊(cè)的賬號(hào)!");
      return false;
    }
    $.ajax({
      type: 'POST',
      url: url,
      dataType: 'json',
      data: {
        to: username
      },
      success: function (response, status) {
        if(response.code){
          alert(response.data);
        }else{
          alert(response.data);
        }
      },
      error:function(xhr,status,error){
        alert('返回?cái)?shù)據(jù)異常!');
      }
    });
    return false;
  }
</script>
 
{include file=comm/foot.html}

6:打開項(xiàng)目:apps\home\controller\MemberController.php 增加注冊(cè)修改密碼模塊短信發(fā)送函數(shù)

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
    public function sendSms()
    {
        $to = post('to');
 
        if ($this->config('register_check_code') != 3) {
            json(0, '發(fā)送失敗,后臺(tái)配置非短信驗(yàn)證碼模式!');
        }
        if (! preg_match('/^1[0-9]{10}$/', $to)) {
            json(0, '賬號(hào)格式不正確,請(qǐng)輸入正確的手機(jī)號(hào)碼!');
        }
 
        if (! session('sendsms')) {
            json(0, '非法提交發(fā)送短信!');
        }
        if (time() - session('lastsendsms') < 60) {
            json(0, '您提交太頻繁了,請(qǐng)稍后再試!');
        }
 
        // 檢查手機(jī)注冊(cè)
        if ($this->model->checkUsername("usermobile='$to' OR username='$to'")) {
            json(0, '您輸入的手機(jī)號(hào)已被注冊(cè)!');
        }
        $rs = false;
        if ($to) {
            $code = create_code(4);
            session('checkcode', strtolower($code));
            $mail_body = "您的驗(yàn)證碼為:" . $code;
            $rs = sendsms($this->config(), $to, $mail_body);
        }
        if ($rs === true) {
            session('lastsendsms', time()); // 記錄最后提交時(shí)間
            json(1, '發(fā)送成功!');
        else {
            json(0, '發(fā)送失敗,' . $rs);
        }
    }
        //找回密碼發(fā)送短信
    public function retrieveSms()
    {
        $to = post('to');
 
        if ($this->config('register_check_code') != 3) {
            json(0, '發(fā)送失敗,后臺(tái)配置非短信驗(yàn)證碼模式!');
        }
        if (! preg_match('/^1[0-9]{10}$/', $to)) {
            json(0, '賬號(hào)格式不正確,請(qǐng)輸入正確的手機(jī)號(hào)碼!');
        }
 
        if (! session('retrievesms')) {
            json(0, '非法提交發(fā)送短信!');
        }
        if (time() - session('lastsendsms') < 60) {
            json(0, '您提交太頻繁了,請(qǐng)稍后再試!');
        }
 
        $rs = false;
        if ($to) {
            $code = create_code(4);
            session('checkcode', strtolower($code));
            $mail_body = "您的驗(yàn)證碼為:" . $code;
            $rs = sendsms($this->config(), $to, $mail_body);
        }
        if ($rs === true) {
            session('lastsendsms', time()); // 記錄最后提交時(shí)間
            json(1, '發(fā)送成功!');
        else {
            json(0, '發(fā)送失敗,' . $rs);
        }
    }
 }

7:打開項(xiàng)目:apps\home\controller\ParserController.php 修改大概143行

1
2
3
4
5
6
7
8
9
10
11
12
13
        if (strpos($content, '{pboot:sendsms}')) {
            session('sendsms'true); // 避免非法外部提交
            $content = str_replace('{pboot:sendsms}', Url::home('member/sendSms'), $content); // 發(fā)送短信
        else {
            session('sendsms'false);
        }
 
        if (strpos($content, '{pboot:retrievesms}')) {
            session('retrievesms'true); // 避免非法外部提交
            $content = str_replace('{pboot:retrievesms}', Url::home('member/retrieveSms'), $content); // 發(fā)送短信
        else {
            session('retrievesms'false);
        }

8:打開項(xiàng)目:apps\home\controller\CommentController.php 修改評(píng)論短信發(fā)送

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
public function add()
    {
        if ($_POST) {
             
            if ($this->config('comment_status') === '0') {
                error('系統(tǒng)已經(jīng)關(guān)閉評(píng)論功能,請(qǐng)到后臺(tái)開啟再試!');
            }
             
            if (time() - session('lastsub') < 10) {
                alert_back('您提交太頻繁了,請(qǐng)稍后再試!');
            }
             
            if (! session('pboot_uid') && ! $this->config('comment_anonymous')) {
                if (! ! $backurl = $_SERVER['HTTP_REFERER']) {
                    alert_location("請(qǐng)先注冊(cè)登錄后再評(píng)論!", Url::home('member/login'null"backurl=" . urlencode($backurl)));
                else {
                    alert_location("請(qǐng)先注冊(cè)登錄后再評(píng)論!", Url::home('member/login'));
                }
            }
             
            // 驗(yàn)證碼驗(yàn)證
            $checkcode = strtolower(post('checkcode''var'));
            if ($this->config('comment_check_code') !== '0') {
                if (! $checkcode) {
                    alert_back('驗(yàn)證碼不能為空!');
                }
                 
                if ($checkcode != session('checkcode')) {
                    alert_back('驗(yàn)證碼錯(cuò)誤!');
                }
            }
             
            // 接收數(shù)據(jù)
             
            $status = $this->config('comment_verify') === '0' ? 1 : 0;
            if (! $contentid = request('contentid''int')) {
                alert_back('文章ID未能正常獲取,請(qǐng)使用POST或URL參數(shù)傳遞!');
            }
             
            $comment = post('comment');
             
            $data = array(
                'pid' => request('pid''int') ?: 0,
                'contentid' => $contentid,
                'comment' => $comment,
                'uid' => session('pboot_uid'),
                'puid' => request('puid''int'),
                'likes' => 0,
                'oppose' => 0,
                'status' => $status,
                'user_ip' => ip2long(get_user_ip()),
                'user_os' => get_user_os(),
                'user_bs' => get_user_bs(),
                'create_time' => get_datetime(),
                'update_user' => '',
                'update_time' => ''
            );
             
            if ($this->model->addComment($data)) {
                session('lastsub', time()); // 記錄最后提交時(shí)間
                $this->log('文章' . $contentid . '評(píng)論提交成功!');
 
                if ($this->config('sms_status')) {
                    if ($this->config('comment_send_sms') && $this->config('sms_send_to')) {
                        $sms_subject = "您有新的文章評(píng)論信息,請(qǐng)注意查收!";
                        sendsms($this->config(), $this->config('sms_send_to'), $sms_subject);
                    }
                }else{
                    if ($this->config('comment_send_mail') && $this->config('message_send_to')) {
                        $mail_subject = "【" . CMSNAME . "】您有新的文章評(píng)論信息,請(qǐng)注意查收!";
                        $mail_body = '評(píng)論內(nèi)容:' . $comment . '<br>';
                        $mail_body .= '<br>來自網(wǎng)站 ' . get_http_url() . ' (' . date('Y-m-d H:i:s') . ')';
                        sendmail($this->config(), $this->config('message_send_to'), $mail_subject, $mail_body);
                    }
                }
                if ($status) {
                    alert_location('評(píng)論提交成功!''-1', 1);
                else {
                    alert_location('評(píng)論提交成功,請(qǐng)等待管理員審核!''-1', 1);
                }
            else {
                $this->log('文章評(píng)論提交失敗!');
                alert_back('提交失敗!');
            }
        else {
            alert_back('提交失敗,請(qǐng)使用POST方式提交!');
        }
    }

9:打開項(xiàng)目:\apps\home\controller\FormController.php 修改表單短信發(fā)送

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
 public function index()
    {
        // 在非兼容模式接受地址第二參數(shù)值
        if (defined('RVAR')) {
            $_GET['fcode'] = RVAR;
        }
         
        if ($_POST) {
             
            if ($this->config('form_status') === '0') {
                error('系統(tǒng)已經(jīng)關(guān)閉表單功能,請(qǐng)到后臺(tái)開啟再試!');
            }
             
            if (time() - session('lastsub') < 10) {
                alert_back('您提交太頻繁了,請(qǐng)稍后再試!');
            }
             
            if (! $fcode = get('fcode''var')) {
                alert_back('傳遞的表單編碼有誤!');
            }
             
            if ($fcode == 1) {
                alert_back('表單提交地址有誤,留言提交請(qǐng)使用留言專用地址!');
            }
             
            // 驗(yàn)證碼驗(yàn)證
            $checkcode = strtolower(post('checkcode''var'));
            if ($this->config('form_check_code') !== '0') {
                if (! $checkcode) {
                    alert_back('驗(yàn)證碼不能為空!');
                }
                if ($checkcode != session('checkcode')) {
                    alert_back('驗(yàn)證碼錯(cuò)誤!');
                }
            }
             
            // 讀取字段
            if (! $form = $this->model->getFormField($fcode)) {
                alert_back('接收表單不存在任何字段,請(qǐng)核對(duì)后重試!');
            }
             
            // 接收數(shù)據(jù)
            $mail_body = '';
            foreach ($form as $value) {
                $field_data = post($value->name);
                if (is_array($field_data)) { // 如果是多選等情況時(shí)轉(zhuǎn)換
                    $field_data = implode(',', $field_data);
                }
                $field_data = preg_replace_r('/pboot:if/i''', $field_data);
                if ($value->required && ! $field_data) {
                    alert_back($value->description . '不能為空!');
                else {
                    $data[$value->name] = $field_data;
                    $mail_body .= $value->description . ':' . $field_data . '<br>';
                }
            }
             
            // 設(shè)置創(chuàng)建時(shí)間
            if ($data) {
                $data['create_time'] = get_datetime();
            }
             
            // 寫入數(shù)據(jù)
            if ($this->model->addForm($value->table_name, $data)) {
                session('lastsub', time()); // 記錄最后提交時(shí)間
                $this->log('提交表單數(shù)據(jù)成功!');
                if ($this->config('sms_status')) {
                    if ($this->config('form_send_sms') && $this->config('sms_send_to')) {
                        $sms_subject = "您有新的" . $value->form_name . "信息,請(qǐng)注意查收!";
                        sendsms($this->config(), $this->config('sms_send_to'), $sms_subject);
                    }
                }else{
                    if ($this->config('form_send_mail') && $this->config('message_send_to')) {
                        $mail_subject = "【" . CMSNAME . "】您有新的" . $value->form_name . "信息,請(qǐng)注意查收!";
                        $mail_body .= '<br>來自網(wǎng)站' . get_http_url() . '(' . date('Y-m-d H:i:s') . ')';
                        sendmail($this->config(), $this->config('message_send_to'), $mail_subject, $mail_body);
                    }
                }
                alert_location('提交成功!''-1', 1);
            else {
                $this->log('提交表單數(shù)據(jù)失敗!');
                alert_back('提交失敗!');
            }
        else {
            alert_back('提交失敗,請(qǐng)使用POST方式提交!');
        }
    }

10:打開項(xiàng)目:apps\home\controller\MessageController.php 修改留言短信發(fā)送

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
public function index()
    {
        if ($_POST) {
             
            if ($this->config('message_status') === '0') {
                error('系統(tǒng)已經(jīng)關(guān)閉留言功能,請(qǐng)到后臺(tái)開啟再試!');
            }
             
            if (time() - session('lastsub') < 10) {
                alert_back('您提交太頻繁了,請(qǐng)稍后再試!');
            }
             
            // 需登錄
            if ($this->config('message_rqlogin') && ! session('pboot_uid')) {
                if (! ! $backurl = $_SERVER['HTTP_REFERER']) {
                    alert_location("請(qǐng)先注冊(cè)登錄后再留言!", Url::home('member/login'null"backurl=" . urlencode($backurl)));
                else {
                    alert_location("請(qǐng)先注冊(cè)登錄后再留言!", Url::home('member/login'));
                }
            }
             
            // 驗(yàn)證碼驗(yàn)證
            $checkcode = strtolower(post('checkcode''var'));
            if ($this->config('message_check_code') !== '0') {
                if (! $checkcode) {
                    alert_back('驗(yàn)證碼不能為空!');
                }
                 
                if ($checkcode != session('checkcode')) {
                    alert_back('驗(yàn)證碼錯(cuò)誤!');
                }
            }
             
            // 讀取字段
            if (! $form = $this->model->getFormField(1)) {
                alert_back('留言表單不存在任何字段,請(qǐng)核對(duì)后重試!');
            }
             
            // 接收數(shù)據(jù)
            $mail_body = '';
            foreach ($form as $value) {
                $field_data = post($value->name);
                if (is_array($field_data)) { // 如果是多選等情況時(shí)轉(zhuǎn)換
                    $field_data = implode(',', $field_data);
                }
                $field_data = preg_replace_r('/pboot:if/i''', $field_data);
                if ($value->required && ! $field_data) {
                    alert_back($value->description . '不能為空!');
                else {
                    $data[$value->name] = $field_data;
                    $mail_body .= $value->description . ':' . $field_data . '<br>';
                }
            }
             
            $status = $this->config('message_verify') === '0' ? 1 : 0;
             
            // 設(shè)置額外數(shù)據(jù)
            if ($data) {
                $data['acode'] = get_lg();
                $data['user_ip'] = ip2long(get_user_ip());
                $data['user_os'] = get_user_os();
                $data['user_bs'] = get_user_bs();
                $data['recontent'] = '';
                $data['status'] = $status;
                $data['create_user'] = 'guest';
                $data['update_user'] = 'guest';
                $data['uid'] = session('pboot_uid');
            }
             
            if ($this->model->addMessage($data)) {
                session('lastsub', time()); // 記錄最后提交時(shí)間
                $this->log('留言提交成功!');
                if ($this->config('sms_status')) {
                    if ($this->config('message_send_sms') && $this->config('sms_send_to')) {
                        $sms_subject = "您有新的" . $value->form_name . "信息,請(qǐng)注意查收!";
                        sendsms($this->config(), $this->config('sms_send_to'), $sms_subject);
                    }
                else {
                    if ($this->config('message_send_mail') && $this->config('message_send_to')) {
                        $mail_subject = "【" . CMSNAME . "】您有新的" . $value->form_name . "信息,請(qǐng)注意查收!";
                        $mail_body .= '<br>來自網(wǎng)站 ' . get_http_url() . ' (' . date('Y-m-d H:i:s') . ')';
                        sendmail($this->config(), $this->config('message_send_to'), $mail_subject, $mail_body);
                    }
                }
                alert_location('提交成功!''-1', 1);
            else {
                $this->log('留言提交失敗!');
                alert_back('提交失敗!');
            }
        else {
            alert_back('提交失敗,請(qǐng)使用POST方式提交!');
        }
    }

11:打開項(xiàng)目:core\function\helper.php 增加短信寶發(fā)送接口

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
function sendsms(array $config, $to, $content)
{
    $statusStr = array(
        "0" => "短信發(fā)送成功",
        "-1" => "參數(shù)不全",
        "-2" => "服務(wù)器空間不支持,請(qǐng)確認(rèn)支持curl或者fsocket,聯(lián)系您的空間商解決或者更換空間!",
        "30" => "密碼錯(cuò)誤",
        "40" => "賬號(hào)不存在",
        "41" => "余額不足",
        "42" => "帳戶已過期",
        "43" => "IP地址限制",
        "50" => "內(nèi)容含有敏感詞"
    );
    if (! $to || ! $content) {
        return false;
    }
 
    if ($config['sms_status'] == 0){
        alert_back('短信暫未開啟');
    }
 
    if (! isset($config['sms_status']) || ! isset($config['sms_pwd']) || ! isset($config['sms_signid'])) {
        alert_back('短信發(fā)送參數(shù)配置有誤');
    }
 
    $user = $config['sms_account'];
    $pass = md5($config['sms_pwd']);
    $content = "【" . $config['sms_signid'] . "】".$content;
    $phone = $to; // 替換空格
    $smsapi = ";
    $sendurl = $smsapi."sms?u=".$user."&p=".$pass."&m=".$phone."&c=".urlencode($content);
    $res =file_get_contents($sendurl) ;
     if ($res == 0) {
         return true;
        else {
         error('短信發(fā)送失敗,' . $statusStr[$res]);
     }
}

經(jīng)過上面的替換,短信寶的短信平臺(tái)已經(jīng)替換成功了,可以正常使用了。進(jìn)行測試發(fā)送:

報(bào)備一下短信寶的VIP模板,這樣就可以走短信寶的優(yōu)質(zhì)通道了,即便遇到敏感文字我們都不會(huì)人工審核,短信內(nèi)容3~5秒就可送達(dá)。

另外:我們已經(jīng)開發(fā)好完整的PbootCMS_V3.2.8系統(tǒng)短信寶插件,點(diǎn)擊此鏈接?下載及查看安裝流

開源插件

最新更新

電商類

CMS類

微信類

文章標(biāo)簽