待发短信

在线客服
产品支持 短信宝客服
合作渠道 渠道合作
服务咨询

400-716-3021

工作时间

9:00-18:00

YZMCMS内容管理系统新增短信宝短信接口

YzmCMS是一款轻量级开源内容管理系统,它采用OOP(面向对象)方式自主开发的框架。可运行在Linux、Windows、MacOSX、Solaris等各种平台上。便于进行二次开发,小编对这款软件还是比较了解的,小编今天就以YZMCMS_3.8版本新增短信接口为例为大家讲解一下如何进行二次开发,我们使用的短信接口是我们短信宝短信群发平台的短信接口,我们短信宝短信群发平台非常稳定,发送速度快,注册就送测试短信,推荐大家使用。(注:本次开发与3.6版本的开发在代码修改中还是有区别的。)

接下来我们进行开发,首先我们需要在后台增加配置短信信息的地方,打开项目\application\admin\view\system_set.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
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
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
<?php include $this->admin_tpl('meta');?>
<title>系统设置 - YzmCMS内容管理系统</title>
</head>
<body>
<nav class="breadcrumb"><i class="Hui-iconfont">&#xe67f;</i> 首页 <span class="c-gray en">&gt;</span> 系统管理 <span class="c-gray en">&gt;</span> 系统设置 <a class="btn btn-success radius r" style="line-height:1.6em;margin-top:3px" href="javascript:location.replace(location.href);" title="刷新" ><i class="Hui-iconfont">&#xe68f;</i></a></nav>
<div class="page-container">
<form class="form form-horizontal" method="post" action="<?php echo U('save');?>" onsubmit="return check_all()">
<div id="tab_system" class="HuiTab">
<div class="tabBar cl"><span>基本设置</span><span>附加设置</span><span>安全设置</span><span>邮件设置</span><span>短信设置</span></div>
<div class="tabCon">
    <div class="row cl">
    <label class="form-label col-xs-4 col-sm-2"><span class="c-red">*</span>站点名称:</label>
    <div class="formControls col-xs-8 col-sm-9">
        <input type="text" placeholder="控制在25个字、50个字节以内" name="site_name" value="<?php echo $data["site_name"];?>" class="input-text" style="width:50%">
    </div>
</div>
<div class="row cl">
    <label class="form-label col-xs-4 col-sm-2"><span class="c-red">*</span>站点根网址:</label>
<div class="formControls col-xs-8 col-sm-9">
<input type="text" placeholder="格式如:http://www.yzmcms.com/" name="site_url" value="<?php echo $data["site_url"];?>" class="input-text" style="width:50%"> <a href="<?php echo SITE_URL;?>index.php?m=mobile" target="_blank" style="font-size:12px;text-decoration:none;line-height:22px"  title="手机站点"><i class="Hui-iconfont">&#xe696;</i>WAP</a>
</div>
    </div>
    <div class="row cl">
        <label class="form-label col-xs-4 col-sm-2">站点关键词:</label>
        <div class="formControls col-xs-8 col-sm-9">
<input type="text" placeholder="5个左右,8汉字以内,用英文,隔开" name="site_keyword" value="<?php echo $data["site_keyword"];?>" class="input-text" style="width:50%">
        </div>
    </div>
    <div class="row cl">
        <label class="form-label col-xs-4 col-sm-2">网站版权信息:</label>
        <div class="formControls col-xs-8 col-sm-9">
<input type="text" placeholder="&copy; 2014-2018 www.yzmcms.com" name="site_copyright" value="<?php echo $data["site_copyright"];?>" class="input-text" style="width:50%">
        </div>
    </div>
    <div class="row cl">
<label class="form-label col-xs-4 col-sm-2">网站备案号:</label>
<div class="formControls col-xs-8 col-sm-9">
    <input type="text" placeholder="如京ICP备00000000号" name="site_filing" value="<?php echo $data["site_filing"];?>" class="input-text" style="width:50%">
</div>
</div>        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-2">站点描述:</label>
            <div class="formControls col-xs-8 col-sm-9">
                <textarea class="textarea" name="site_description" style="width:80%"><?php echo $data["site_description"];?></textarea>
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-2">统计代码:</label>
            <div class="formControls col-xs-8 col-sm-9">
        <textarea class="textarea" name="site_code" style="width:80%"><?php echo $data["site_code"];?></textarea>
            </div>
        </div>
    </div>
    <div class="tabCon">
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-2">模板风格:</label>
            <div class="formControls col-xs-8 col-sm-9">
                <span class="select-box" style="width:120px;"><select name="site_theme" class="select">
                  <?php
                      foreach($theme_list as $val){
                            $str $data["site_theme"]==$val ' selected="selected" ' '';
                            echo '<option value="'.$val.'" '.$str.'>'.$val.'</option>';                      }
                  ?>
                </select>
                </span>
            </div>
        </div>
        <div class="row cl">
    <label class="form-label col-xs-4 col-sm-2"><span class="c-red">*</span>缩略图默认宽度(px):</label>
            <div class="formControls col-xs-8 col-sm-9">
  <input type="text" placeholder="280" name="pic_wid" value="<?php echo $data["pic_wid"];?>"  class="input-text w_120">
            </div>
                </div>   
        <div class="row cl">
  <label class="form-label col-xs-4 col-sm-2"><span class="c-red">*</span>缩略图默认高度(px):</label>
    <div class="formControls col-xs-8 col-sm-9">
                <input type="text" placeholder="220" name="pic_hei" value="<?php echo $data["pic_hei"];?>"  class="input-text w_120">
            </div>
        </div>   
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-2">前端URL规则:</label>
            <div class="formControls col-xs-8 col-sm-9">
                <label class="label_radio"><input name="url_rule" type="radio" <?php echo $data["url_rule"]? '' 'checked' ?> value="0"> 兼容模式</label>
                <label class="label_radio"><input name="url_rule" type="radio" <?php echo $data["url_rule"]? 'checked' '' ?> value="1"> 伪静态模式</label>
            </div>
        </div>       
                <div class="row cl">
                    <label class="form-label col-xs-4 col-sm-2"><span class="c-red">*</span>允许上传附件大小(KB)</label>
            <div class="formControls col-xs-8 col-sm-9">
          <input type="text" name="upload_maxsize" value="<?php echo $data["upload_maxsize"];?>"  class="input-text w_120">
                <span style="color:#888">[最大限制不能超过服务器“upload_max_filesize”配置]</span>
            </div>
        </div>   
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-2">是否开启图片水印:</label>
            <div class="formControls col-xs-8 col-sm-9">
  <label class="label_radio"><input name="watermark_enable" type="radio" <?php echo $data["watermark_enable"]? 'checked' '' ?> value="1"> 开启</label>
 <label class="label_radio"><input name="watermark_enable" type="radio" <?php echo $data["watermark_enable"]? '' 'checked' ?> value="0"> 关闭</label>
            </div>
        </div>   
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-2"><span class="c-red">*</span>水印图片名称:</label>
            <div class="formControls col-xs-8 col-sm-9">
<input type="text" name="watermark_name" value="<?php echo $data["watermark_name"];?>"  class="input-text w_420"> <span style="color:#888">[水印存放路径:/common/data/water]</span>
            </div>
    </div>
    <div class="row cl">
        <label class="form-label col-xs-4 col-sm-2">水印的位置:</label>
        <div class="formControls col-xs-8 col-sm-9">
            <label class="label_radio"><input type="radio" value="0" <?php echo $data["watermark_position"]==0 ? 'checked' '' ?> name="watermark_position">随机</label>
            <label class="label_radio"><input type="radio" value="1" <?php echo $data["watermark_position"]==1 ? 'checked' '' ?> name="watermark_position">顶部居左</label>
            <label class="label_radio"><input type="radio" value="2" <?php echo $data["watermark_position"]==2 ? 'checked' '' ?> name="watermark_position">顶部居中</label>
            <label class="label_radio"><input type="radio" value="3" <?php echo $data["watermark_position"]==3 ? 'checked' '' ?> name="watermark_position">顶部居右</label>
            <label class="label_radio"><input type="radio" value="4" <?php echo $data["watermark_position"]==4 ? 'checked' '' ?> name="watermark_position">中部居左</label>
            <label class="label_radio"><input type="radio" value="5" <?php echo $data["watermark_position"]==5 ? 'checked' '' ?> name="watermark_position">中部居中</label>
            <label class="label_radio"><input type="radio" value="6" <?php echo $data["watermark_position"]==6 ? 'checked' '' ?> name="watermark_position">中部居右</label>
            <label class="label_radio"><input type="radio" value="7" <?php echo $data["watermark_position"]==7 ? 'checked' '' ?> name="watermark_position">底部居左</label>
            <label class="label_radio"><input type="radio" value="8" <?php echo $data["watermark_position"]==8 ? 'checked' '' ?> name="watermark_position">底部居中</label>
            <label class="label_radio"><input type="radio" value="9" <?php echo $data["watermark_position"]==9 ? 'checked' '' ?> name="watermark_position">底部居右</label>
        </div>
    </div>               
</div>
<div class="tabCon">
<div class="row cl">
    <label class="form-label col-xs-4 col-sm-2">禁止登录后台的IP列表:<br><span style="color:#888">匹配IP段用“*”占位<br>多个IP用“,”分割</span></label>
    <div class="formControls col-xs-8 col-sm-9">
<textarea class="textarea" name="admin_prohibit_ip" placeholder="匹配IP段用“*”占位,如192.168.*.*,多个IP地址请用英文逗号“,”分割"><?php echo $data["admin_prohibit_ip"];?></textarea>
    </div>
</div>
<div class="row cl">
    <label class="form-label col-xs-4 col-sm-2">启用后台管理操作日志:</label>
    <div class="formControls col-xs-8 col-sm-9">
        <label class="label_radio"><input name="admin_log" type="radio" <?php echo $data["admin_log"]? 'checked' '' ?> value="1"> 开启</label>
        <label class="label_radio"><input name="admin_log" type="radio" <?php echo $data["admin_log"]? '' 'checked' ?> value="0"> 关闭</label>
    </div>
</div>
<div class="row cl">
    <label class="form-label col-xs-4 col-sm-2">是否开启前端留言功能:</label>
    <div class="formControls col-xs-8 col-sm-9">
        <label class="label_radio"><input name="is_words" type="radio" <?php echo $data["is_words"]? 'checked' '' ?> value="1"> 开启</label>
        <label class="label_radio"><input name="is_words" type="radio" <?php echo $data["is_words"]? '' 'checked' ?> value="0"> 关闭</label>
    </div>
</div>
<div class="row cl">
    <label class="form-label col-xs-4 col-sm-2">允许用户申请友情链接:</label>
    <div class="formControls col-xs-8 col-sm-9">
        <label class="label_radio"><input name="is_link" type="radio" <?php echo $data["is_link"]? 'checked' '' ?> value="1"> 开启</label>
        <label class="label_radio"><input name="is_link" type="radio" <?php echo $data["is_link"]? '' 'checked' ?> value="0"> 关闭</label>
    </div>
</div>
<div class="row cl">
    <label class="form-label col-xs-4 col-sm-2">是否开启评论审核:</label>
    <div class="formControls col-xs-8 col-sm-9">
        <label class="label_radio"><input name="comment_check" type="radio" <?php echo $data["comment_check"]? 'checked' '' ?> value="1"> 开启</label>
        <label class="label_radio"><input name="comment_check" type="radio" <?php echo $data["comment_check"]? '' 'checked' ?> value="0"> 关闭</label>
    </div>
</div>
<div class="row cl">
    <label class="form-label col-xs-4 col-sm-2">是否允许游客评论:</label>
    <div class="formControls col-xs-8 col-sm-9">
        <label class="label_radio"><input name="comment_tourist" type="radio" <?php echo $data["comment_tourist"]? 'checked' '' ?> value="1"> 开启</label>
        <label class="label_radio"><input name="comment_tourist" type="radio" <?php echo $data["comment_tourist"]? '' 'checked' ?> value="0"> 关闭</label>
    </div>
</div>
</div>
<div class="tabCon">
<div class="row cl">
    <label class="form-label col-xs-4 col-sm-2">SMTP服务器:</label>
    <div class="formControls col-xs-8 col-sm-9">
 <input type="text" name="mail_server" value="<?php echo $data["mail_server"];?>"  class="input-text" style="width:50%">
    </div>
</div>
<div class="row cl">
    <label class="form-label col-xs-4 col-sm-2">SMTP 端口:</label>
    <div class="formControls col-xs-8 col-sm-9">
        <input type="text" class="input-text" name="mail_port" value="<?php echo $data["mail_port"];?>" style="width:100px">
    </div>
</div>
<div class="row cl">
 
    <label class="form-label col-xs-4 col-sm-2">发件人地址:</label>
    <div class="formControls col-xs-8 col-sm-9">
        <input type="text" class="input-text" name="mail_from" value="<?php echo $data["mail_from"];?>" style="width:50%">
    </div>
</div>
    <div class="row cl">
        <label class="form-label col-xs-4 col-sm-2">AUTH LOGIN验证:</label>
        <div class="formControls col-xs-8 col-sm-9">
            <label class="label_radio"><input name="mail_auth" type="radio" <?php echo $data["mail_auth"]? 'checked' '' ?> value="1"> 开启</label>
            <label class="label_radio"><input name="mail_auth" type="radio" <?php echo $data["mail_auth"]? '' 'checked' ?> value="0"> 关闭</label>
        </div>
    </div>
    <div class="row cl">
        <label class="form-label col-xs-4 col-sm-2">验证用户名:</label>
        <div class="formControls col-xs-8 col-sm-9">
            <input type="text" name="mail_user" value="<?php echo $data["mail_user"];?>"  class="input-text" style="width:50%">
        </div>
    </div>
    <div class="row cl">
        <label class="form-label col-xs-4 col-sm-2">验证密码:</label>
        <div class="formControls col-xs-8 col-sm-9">

 
<input type="password" name="mail_pass" value="<?php echo $data["mail_pass"];?>" readonly onfocus="this.removeAttribute('readonly');" class="input-text" style="width:50%">
        </div>
    </div>
    <div class="row cl">
        <label class="form-label col-xs-4 col-sm-2">站点默认邮箱:</label>
        <div class="formControls col-xs-8 col-sm-9">
        <input type="email" name="mail_inbox" value="<?php echo $data["mail_inbox"];?>"  class="input-text" style="width:50%"> [用于接收“用户留言”等消息通知]
        </div>
</div>
    <div class="row cl">
        <label class="form-label col-xs-4 col-sm-2">邮件设置测试:</label>
        <div class="formControls col-xs-8 col-sm-9">
            <input type="email" name="mail_to" value=""  class="input-text" style="width:50%">
  <input type="button" class="btn btn-primary radius" value="测试发送" onclick="test_mail()"> [先保存,在发送]
        </div>
    </div>
</div>
<div class="tabCon">
    <div class="row cl">
        <label class="form-label col-xs-4 col-sm-2">短信宝用户名:</label>

 
        <div class="formControls col-xs-8 col-sm-9">
       <input type="text" name="smsbao_user" value="<?php echo $data["smsbao_user"];?>"  class="input-text" style="width:50%">
        </div>
    </div>
    <div class="row cl">
        <label class="form-label col-xs-4 col-sm-2">短信宝密码:</label>
        <div class="formControls col-xs-8 col-sm-9">
       <input type="text" name="smsbao_pass" value="<?php echo $data["smsbao_pass"];?>"  class="input-text" style="width:50%">
        </div>
    </div>
    <div class="row cl">
        <label class="form-label col-xs-4 col-sm-2">短信签名:</label>
        <div class="formControls col-xs-8 col-sm-9">
      <input type="text" name="smsbao_sign" value="<?php echo $data["smsbao_sign"];?>"  class="input-text" style="width:50%">
        </div>
    </div>
</div>
</div>
        <div class="row cl">
    <div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-2">                
        <input type="submit" class="btn btn-primary radius" name="dosubmit" value="&nbsp;&nbsp;保存&nbsp;&nbsp;">
        <input type="reset" class="btn btn-default radius" value="&nbsp;&nbsp;取消&nbsp;&nbsp;">
    </div>
</div>
</form>

 
</div>
<?php include $this->admin_tpl('footer');?>

 
<script type="text/javascript">
function check_all(){
    var reg = /^http(.+)\/$/;
    if($("input[name='site_name']").val()==''){
        layer.alert('站点名称不能为空!');
        return false;
    }
    if(!reg.test($("input[name='site_url']").val())){
        layer.alert('站点根网址格式为:http://www.yzmcms.com/,请以“/”结尾!');
        return false;
    }
    if($("input[name='pic_wid']").val()=='' || isNaN($("input[name='pic_wid']").val())){
        layer.alert('缩略图宽度只能为数字!');
        return false;
    }
    if($("input[name='pic_hei']").val()=='' || isNaN($("input[name='pic_hei']").val())){
        layer.alert('缩略图高度只能为数字!');
        return false;
    }
    if($("input[name='upload_maxsize']").val()=='' || isNaN($("input[name='upload_maxsize']").val())){
        layer.alert('允许上传附件大小只能为数字!');
        return false;
    }
    if($("input[name='watermark_name']").val()==''){
        layer.alert('水印图片名称不能为空!');
        return false;
    }
    return true;          
}
function test_mail() {
    var mail_to = $("input[name='mail_to']").val();
    if(mail_to == ''){
        layer.alert('请输入邮件测试地址!');
        return false;
    }
    $.ajax({
        type: 'POST',
        url: '<?php echo U('public_test_mail');?>'
        data: "mail_to="+mail_to,
        success: function (msg) {
            layer.alert(msg);
        }
    })
}
$(function(){
    $.Huitab("#tab_system .tabBar span","#tab_system .tabCon","current","click","<?php echo isset($_GET['tab']) ? intval($_GET['tab']) : '0'?>");
});
</script>
 
</body>
</html>


 

接下来我们需要增加开启短信功能的地方,打开项目\application\member\view\member_set.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
<?php include $this->admin_tpl('meta', 'admin');?>
<title>会员中心设置 - YzmCMS内容管理系统</title>
</head>
<body>
<nav class="breadcrumb"><i class="Hui-iconfont">&#xe67f;</i> 首页 <span class="c-gray en">&gt;</span> 会员管理 <span class="c-gray en">&gt;</span> 会员中心设置 <a class="btn btn-success radius r" style="line-height:1.6em;margin-top:3px" href="javascript:location.replace(location.href);" title="刷新" ><i class="Hui-iconfont">&#xe68f;</i></a></nav>
<div class="page-container">
    <form class="form form-horizontal" method="post" action="<?php echo U('admin/system_manage/save');?>" onsubmit="return check_all()">
        <div id="tab_system" class="HuiTab">
            <div class="tabBar cl"><span>基本设置</span><span>其他设置</span></div>
            <div class="tabCon">
                <div class="row cl">
                    <label class="form-label col-xs-4 col-sm-2">是否开启会员注册:</label>
                    <div class="formControls col-xs-8 col-sm-9">
                    <label class="label_radio"><input name="member_register" type="radio" <?php echo $data["member_register"]? 'checked' : '' ?> value="1"> 开启</label>
                  <label class="label_radio"><input name="member_register" type="radio" <?php echo $data["member_register"]? '' : 'checked' ?> value="0"> 关闭</label>
                    </div>             </div>
                <div class="row cl">
                    <label class="form-label col-xs-4 col-sm-2">新会员注册邮件验证:</label>
                    <div class="formControls col-xs-8 col-sm-9">
                  <label class="label_radio"><input name="member_email" type="radio" <?php echo $data["member_email"]? 'checked' : '' ?> value="1"> 开启</label>
                   <label class="label_radio"><input name="member_email" type="radio" <?php echo $data["member_email"]? '' : 'checked' ?> value="0"> 关闭</label>
                   <span style="color:#888"> [需填写邮箱配置,且开启后会员注册审核功能无效]</span>
                    </div>       
                </div>                <div class="row cl">
                    <label class="form-label col-xs-4 col-sm-2">新会员注册短信验证:</label>
                    <div class="formControls col-xs-8 col-sm-9">
             <label class="label_radio"><input name="member_mobile" type="radio" <?php echo $data["member_mobile"]? 'checked' : '' ?> value="1"> 开启</label>
             <label class="label_radio"><input name="member_mobile" type="radio" <?php echo $data["member_mobile"]? '' : 'checked' ?> value="0"> 关闭</label>
                      <span style="color:#888"> [需填写短信配置,且开启后会员注册审核功能无效]</span>
                    </div>       
                </div>
                <div class="row cl">
                    <label class="form-label col-xs-4 col-sm-2">会员注册需要管理员审核:</label>
                    <div class="formControls col-xs-8 col-sm-9">
   <label class="label_radio"><input name="member_check" type="radio" <?php echo $data["member_check"]? 'checked' : '' ?> value="1"> 开启</label>
   <label class="label_radio"><input name="member_check" type="radio" <?php echo $data["member_check"]? '' : 'checked' ?> value="0"> 关闭</label>
                    </div>
                </div>
                <div class="row cl">
                  <label class="form-label col-xs-4 col-sm-2">是否开启会员登录验证码:</label>
                  <div class="formControls col-xs-8 col-sm-9">
   <label class="label_radio"><input name="member_yzm" type="radio" <?php echo $data["member_yzm"]? 'checked' : '' ?> value="1"> 开启</label>
   <label class="label_radio"><input name="member_yzm" type="radio" <?php echo $data["member_yzm"]? '' : 'checked' ?> value="0"> 关闭</label>
                 </div>                </div>
                <div class="row cl">
                    <label class="form-label col-xs-4 col-sm-2">新会员默认积分:</label>
                    <div class="formControls col-xs-8 col-sm-9">
                    <input type="text" name="member_point" value="<?php echo $data["member_point"];?>" class="input-text" style="width:30%">
                    <span style="color:red"> [积分=经验,区别在于积分可以通过消费减少,经验只增不减,下同]</span>
                    </div>
                </div>
                <div class="row cl">
                    <label class="form-label col-xs-4 col-sm-2">每日登陆奖励积分:</label>
                    <div class="formControls col-xs-8 col-sm-9">
                        <input type="text"  name="login_point" value="<?php echo $data["login_point"];?>" class="input-text" style="width:30%">
                    </div>
                </div>
                <div class="row cl">
                    <label class="form-label col-xs-4 col-sm-2">发布评论奖励积分:</label>
                    <div class="formControls col-xs-8 col-sm-9">
    <input type="text"  name="comment_point" value="<?php echo $data["comment_point"];?>" class="input-text" style="width:30%">
                    </div>
                </div>
                <div class="row cl">
                    <label class="form-label col-xs-4 col-sm-2">投稿奖励积分:</label>
                    <div class="formControls col-xs-8 col-sm-9">
   <input type="text"  name="publish_point" value="<?php echo $data["publish_point"];?>" class="input-text" style="width:30%">
                    </div>
                </div>
            </div>
            <div class="tabCon">
                <div class="row cl">
                    <label class="form-label col-xs-4 col-sm-2">QQ登录 App ID:</label>
                    <div class="formControls col-xs-8 col-sm-9">
                        <input type="text" name="qq_app_id" value="<?php echo $data["qq_app_id"];?>" class="input-text" style="width:50%">
                    </div>
                </div>
                <div class="row cl">
                    <label class="form-label col-xs-4 col-sm-2">QQ登录 App key:</label>
                    <div class="formControls col-xs-8 col-sm-9">
                        <input type="text" name="qq_app_key" value="<?php echo $data["qq_app_key"];?>" class="input-text" style="width:50%">
                    </div>
                </div>
                <div class="row cl">
                    <label class="form-label col-xs-4 col-sm-2">QQ登录 回调地址:</label>
                    <div class="formControls col-xs-8 col-sm-9">
              <input type="text" name="callback" readonly value="<?php echo U('member/other/qq_login');?>" class="input-text" style="width:50%">
                    </div>
                </div>
            </div>
        </div>
        <div class="row cl">
            <div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-2">               
                <input type="submit" class="btn btn-primary radius" name="dosubmit" value="&nbsp;&nbsp;保存&nbsp;&nbsp;">
                <input type="reset" class="btn btn-default radius" value="&nbsp;&nbsp;取消&nbsp;&nbsp;">
            </div>
        </div>
    </form>
</div>
<?php include $this->admin_tpl('footer', 'admin');?>
<script type="text/javascript">
function check_all(){
    if($("input[name='member_point']").val()=='' || isNaN($("input[name='member_point']").val())){
        layer.msg('新会员默认积分只能为数字!');
        return false;
    }
    if($("input[name='login_point']").val()=='' || isNaN($("input[name='login_point']").val())){
        layer.msg('每日登陆奖励积分只能为数字!');
        return false;
    }
    if($("input[name='comment_point']").val()=='' || isNaN($("input[name='comment_point']").val())){
        layer.msg('发布评论奖励积分只能为数字!');
        return false;
    }
    if($("input[name='login_point']").val()=='' || isNaN($("input[name='login_point']").val())){
        layer.msg('投稿奖励积分只能为数字!');
        return false;
    }
    return true;          
}
$(function(){
    $.Huitab("#tab_system .tabBar span","#tab_system .tabCon","current","click","<?php echo isset($_GET['tab']) ? intval($_GET['tab']) : '0'?>");
});
</script>
</body>
</html>

接下来我们需要修改会员注册页面,打开项目\application\member\view\default\register.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
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
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
  <head>
      <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
      <title>会员注册</title>
      <link href="{STATIC_URL}css/member_login.css" rel="stylesheet" type="text/css" />
      <script type="text/javascript" src="{STATIC_URL}js/jquery-1.8.2.min.js"></script>
      <script type="text/javascript" src="{STATIC_URL}plugin/layer/3.0.1/layer.js"></script>
      <script type="text/javascript" src="{STATIC_URL}js/register.js"></script>
      <meta name="description" content="yzmcms会员注册" />
  </head>
  <body>
        <div class="w880 main">
          <div class="main_left">
            <p class="logo"><a href="{SITE_URL}"><img src="{STATIC_URL}images/logo.png"></a></p>
            <p>已经有帐号?<a href="{U('login')}">点击登录</a></p>
            <p>使用合作网站登录</p>
            <p><a href="{U('member/other/qq_login')}" target="_blank" class="qq_login">腾讯QQ登陆</a></p>
          </div>          
          <div class="main_right">
           <div class="login">会员注册</div>           
            <div class="form2">
            <form action="" method="post" onsubmit="return checkall()">
                <ul>
                <li><label>用户名</label><input type="text" class="input" name="username" id="username" placeholder="请输入用户名" value=""></li>
                <li><label>电子邮箱</label><input type="text" class="input"  name="email" id="email" placeholder="请输入电子邮箱" value=""></li>               
                <li><label>密码</label><input type="password" class="input"  name="password" id="password" placeholder="请输入密码" value=""></li>
                <li><label>确认密码</label><input type="password" class="input"  name="password2" id="password2" placeholder="请输入确认密码" value=""></li>
                <li><label>验证码</label><input type="text" class="input code"  name="code" id="code" placeholder="请输入验证码"><img src="{U('api/index/code')}" onclick="this.src=this.src+'?'" class="codeimg" title="看不清,换一张"></li>          
                <li><label>手机号码:</label><input type="text" class="input" name="mobile" id="mobile" value=""></li>   
                {if $config['member_mobile'] == 1}
                <li><label>手机验证:</label><input type="text" class="input code" name="mobile_code" value="" id="mobile_code"> <b class="huoqu" style="height: 28px; width: 120px;cursor: pointer;">获取验证码</b></li
                  {/if}
                <li><input type="submit" class="submit" name="dosubmit" value="同意以下协议并注册"></li>
                <li><input type="checkbox" checked="checked" value="1" id="agree" name="agree"/> <a onclick="show_protocol()" href="javascript:void(0);">点击阅读注册协议</a></li>                </ul>
            </form>
            </div>            
          </div>
        </div>
        <div class='clearfix'></div>
        <div class="footer">
        <p>Powered by <a href="http://www.yzmcms.com" target="_blank">{YZMCMS_SOFTNAME}</a> © 2014-2018  版权所有</p>
        </div>        
        <script type="text/javascript">
        function checkname(){
            var res = false;
            if($("#username").val() != ''){
                $.ajax({   
                    type: "post",   
                    url: "{U('public_checkname')}",   
                    dataType: "html",
                    async: false, 
                    data: "username="+$('#username').val(), 
                    beforeSend: function(){
                        $("#dosubmit").attr({ disabled: "disabled" });
                    },             
                    success: function(msg){  
                    if(msg == '1'){
                        $("#dosubmit").removeAttr("disabled");
                        res = true;                 
                    }else if(msg == '-1'){
                        layer.msg('用户名已存在', {icon:2,time: 1000});
                    }else if(msg == '0'){
                        layer.msg('用户名格式不正确', {icon:2,time: 1000});
                    }else{
                        layer.msg('未知错误', {icon:2,time: 1000});
                    }                
                    
                });
                return res;
            }else{
                layer.msg('用户名不能为空', {icon:2,time: 1000});
                return res;
            }          
        }
        function checkemail(){
            var reg = /^([a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+(.[a-zA-Z0-9_-])+/; 
            var res = false;
            if(reg.test($("#email").val())){
              $.ajax({   
                type: "post",   
                url: "{U('public_checkemail')}",   
                dataType: "html",
                async: false, 
                data: "email="+$('#email').val(), 
                beforeSend: function(){
                    $("#dosubmit").attr({ disabled: "disabled" });
                },             
                success: function(msg){  
                if(msg == '1'){
                      $("#dosubmit").removeAttr("disabled");
                      res = true;                      
                }else if(msg == '-1'){
                      layer.msg('电子邮箱已存在', {icon:2,time: 1000});
                }else if(msg == '0'){
                      layer.msg('电子邮箱格式不正确', {icon:2,time: 1000});  
                }else{
                      layer.msg('未知错误', {icon:2,time: 1000});
                }                
                
              });
               return res;
            }else{
                  layer.msg('电子邮箱格式不正确', {icon:2,time: 1000});
                  return res;
            }          
        }       
        function show_protocol(){
           layer.open({
              type: 1,
              title: '会员注册协议',
              skin: 'layui-layer-rim', 
              area: ['550px', '320px'], 
              content: '<div style="margin:15px 20px"><p >1、在本站注册的会员,必须遵守《互联网电子公告服务管理规定》,不得在本站发表诽谤他人,侵犯他人隐私,侵犯他人知识产权,传播病毒,政治言论,商业讯息等信息。</p><br><p>2、在所有在本站发表的文章,本站都具有最终编辑权,并且保留用于印刷或向第三方发表的权利,如果你的资料不齐全,我们将有权不作任何通知使用你在本站发布的作品。</p><br><p>3、在登记过程中,您将选择注册名和密码。注册名的选择应遵守法律法规及社会公德。您必须对您的密码保密,您将对您注册名和密码下发生的所有活动承担责任。</p></div>'
            });
        }
        </script>    
<script type="text/javascript">
    var time = 0;
    var res = null;
 
    function sendTime(){
        clearTimeout(res); // 先清空一下倒计时资源。
        time--; // 倒计时时间递减。
 
        // 如果倒计时到达0时,则恢复按钮原来的内容
        if (time <= 0) {
            time = "获取验证码";
            $('.huoqu').text(time);
            clearTimeout(res);
            time = 0;
            return;
        }
        // 倒计时的内容写到按钮里面
        $('.huoqu').text("剩余" + time + "秒");
        res = setTimeout("sendTime()", 1000);
    }
    $(function(){
        var flg = true;
        $('.huoqu').on('click',function(){
            console.log(123);
                var mobile = $("#mobile").val();
                var code = $("#code").val();
                var reg = /^1[3,4,5,7,8]\d{9}$/;
                var ret = false;
                if (code == '') {layer.msg('请填写验证码'); return ret;}
                if (!reg.test(mobile)) {layer.msg('手机号码不正确');return ret;}
            if (0 == time) {
                var data = {"code" : code, "mobile" : mobile};
                var err = "";
 
                if (flg == true) {
                    flg = false;
                    // ajax提交请求
                  $.ajax({   
                    type: "post",   
                    url: "{U('public_checksms')}",   
                    dataType: "html",
                    async: false, 
                    data: data, 
                    beforeSend: function(){
                        $("#dosubmit").attr({ disabled: "disabled" });
                    },             
                    success: function(msg){  
                    if(msg == '0'){
                          time = 60;
                          sendTime();
                          layer.msg('短信发送成功!');                         
                          ret = true;                      
                    }else if(msg == '1'){
                          layer.msg('验证码不正确');              
                    }else if(msg == '2'){
                          layer.msg('短信配置不正确');             
                    }else{
                          layer.msg(msg);
                    }                
                    
                  });
                }
                $('.codeimg').click();
                return ret;
            }
        })
 
    })
</script>
  </body>
</html>

继续修改找回密码界面,打开项目\application\member\view\default\reset_type.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
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
  <head>
      <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
      <title>会员中心-选择密码找回方式</title>
      <link href="{STATIC_URL}css/member_reset.css" rel="stylesheet" type="text/css" />
      <meta name="description" content="yzmcms,找回密码,选择密码找回方式" />
  </head>
  <body>        <div class="w1">
            <div class="w880 head">
              <div class="right"><a href="{SITE_URL}">回到首页</a></div>
              <a href="{U('member/index/register')}" class="current">注册</a> 欢迎登录
            </div>
        </div>
        <!--主要内容-->
        <div class="main">
          <h1>请选择密码找回方式</h1>
          <div class="main_left">
                <div class="reset_type">
                    <span>1.</span>通过手机找回密码
                    <a href="{U('reset_mobile')}">立即找回</a>
                </div>   
                <div class="reset_type">
                <span>2.</span>通过电子邮箱找回密码
                <a href="{U('reset_email')}">立即找回</a>
                </div>
                <div class="reset_type">
                <span>3.</span>通过安全问题找回密码
                <a href="{U('reset_problem')}">立即找回</a>
                </div>               
          </div>
          <div class="main_right">
            <p>已经有了账号?</p>  
            <p>请直接登录</p
            <br>         
            <p><a href="{U('member/index/login')}" class="button">登录</a></p>  
          </div>
        </div>
        <!--网站底部-->
        <div class="footer">
          <p>Powered by <a href="http://www.yzmcms.com" target="_blank">{YZMCMS_SOFTNAME}</a> © 2014-2018  版权所有</p>
        </div>
  </body>
</html>

然后我们需要新建一个短信找回密码的文件,打开项目\application\member\view\default下新建一个reset_mobile.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
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
  <head>
      <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
      <title>会员中心-通过手机找回密码</title>
      <link href="{STATIC_URL}css/member_reset.css" rel="stylesheet" type="text/css" />
      <meta name="description" content="通过手机找回密码" />
  </head>
  <body>
        <div class="w1">
            <div class="w980 head">
              <div class="right"><a href="{SITE_URL}">回到首页</a></div>
              <a href="{U('member/index/register')}" class="current">注册</a> 欢迎登录
            </div>
        </div>
        <!--主要内容-->
        <div class="main">
          <h1>通过手机找回密码</h1>
          <div class="main_left">
                <div class="title">
 <span>步骤:1. 确认账号 &nbsp;&nbsp;>&nbsp;&nbsp; 2.安全验证 &nbsp;&nbsp;>&nbsp;&nbsp; 3. 重置密码&nbsp;&nbsp;>&nbsp;&nbsp; 4. 成功</span>
          </div>        <div class="form">                
                {if $_SESSION['step'] == 1}
                <form method="post" action=""
                  <ul>               
         <li>用户名:<input type="text" placeholder="用户名" required name="username" class="input"/></li>
 <li>验证码:
<
input type="text" placeholder="验证码" required name="code" class="input code"/>
<
img src="{U('api/index/code')}" onclick="this.src=this.src+'?'" class="codeimg" title="看不清,换一张"></li>
                  <li>
<
input type="submit" name="dosubmit" value="下一步"  class="submit"> <a href="{U('init')}">重新选择验证方式</a></li>
   </ul>           </form>
                  {elseif $_SESSION['step'] == 2}
     <form method="post" action=""                  <ul>               
        <li><span class="red">我们已将校验码发送至您绑定的手机号<strong style="color:#333;">{$_SESSION['mobile']} </strong>,请在下方输入完成验证</span></li>
       <li>短信校验码:<input type="text" placeholder="短信校验码" required name="mobile_code" class="input code"/></li>
                  <li><input type="submit" name="dosubmit" value="下一步"  class="submit"> <a onclick="history.go(-1)" href="javascript:void(0)">上一步</a></li>
   </ul>                </form>
                {else}
                 <form method="post" action="" onsubmit="return checkall()">
   <ul>        
     <li><span class="red">验证成功,请重新设定您的密码:</span></li>
          <li>  新密码:<input type="password" placeholder="新密码" required name="password" id="password" class="input"/></li>
       <li>确认新密码:<input type="password" placeholder="确认新密码" required name="password2" id="password2" class="input"/></li>
                  <li><input type="submit" name="dosubmit" value="下一步"  class="submit"></li>
      </ul>                </form>                 
                {/if}               
                </div>            
          </div>          <div class="main_right">
            <p>已经有了账号?</p>  
            <p>请直接登录</p            <br>         
            <p><a href="{U('member/index/login')}" class="button">登录</a></p
          </div>        </div>
          <script>
           function checkall(){
            var password = document.getElementById("password").value;
            var password2 = document.getElementById("password2").value;
            if(password.length < 6){
               alert('密码不能低于6位!');
               return false;
            }
            if(password != password2){
              alert('两次密码不一致!');
              return false;
            }
           }
          </script>
        <!--网站底部-->
        <div class="footer">
  <p>Powered by <a href="http://www.yzmcms.com" target="_blank">{YZMCMS_SOFTNAME}</a> © 2014-2018  版权所有</p>        </div>
  </body>
</html>

下面我们去修改注册使用短信的后端文件,打开项目\application\member\controller\index.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
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
<?php
/**
 * 会员中心操作类
 * @author           袁志蒙  
 * @license          http://www.yzmcms.com
 * @lastmodify       2017-01-15
 */
 
defined('IN_YZMPHP'or exit('Access Denied'); 
yzm_base::load_controller('common''member', 0);
 
class index extends common{
    
    function __construct() {
        parent::__construct();
    }   
    /**
    * 会员中心
    */
    public function init(){ 
        $memberinfo $this->memberinfo;
        extract($memberinfo);
        $groupinfo = get_groupinfo($groupid);
        include template('member''index');
    }
    
    /**
    * 会员登录
    */
    public function login(){     
        
        if(isset($_POST['dosubmit'])){     
            
            //检查是否开启验证码
            if(get_config('member_yzm')){
                if(empty($_SESSION['code']) || strtolower($_POST['code'])!=$_SESSION['code']){
                    $_SESSION['code'] = '';
                    showmsg(L('code_error'));
                }
                $_SESSION['code'] = '';
            }
            $member = D('member');
            $username = isset($_POST['username']) && is_username($_POST['username']) ? trim($_POST['username']) : showmsg(L('user_name_format_error'));
            $password = password($_POST['password']);
            
            $data $member->where(array('username'=>$username))->find();
            if(!$data) showmsg(L('user_does_not_exist'));
            $data $member->where(array('username'=>$username'password'=>$password))->find();
            if(!$data) showmsg('用户名或密码错误!');
            if($data['status'] == '0'
                showmsg('用户未通过审核!''stop');      
            else if($data['status'] == '2'
                showmsg('用户已锁定!''stop');    
            else if($data['status'] == '3'
                showmsg('用户已被管理员拒绝!''stop');
            
            $_SESSION['_userid'] = $data['userid'];
            $_SESSION['_username'] = $data['username'];
            set_cookie('_userid'$data['userid']);
            set_cookie('_username'$data['username']);
            set_cookie('_nickname'$data['username']);
            set_cookie('_groupid'$data['groupid']);         
            
            //每日登录,增加积分和经验,并更新新用户组
            $last_day date('d'$data['lastdate']);
            if($last_day != date('d')  &&  SYS_TIME>$data['lastdate'] && get_config('login_point')>0){
                M('point')->point_add('1',get_config('login_point'),'0',$data['userid'],$data['username'],$data['experience']);     
            }
            
            $where '';
            if($data['vip'] && $data['overduedate']<SYS_TIME)  $where .= '`vip`=0,';   //如果用户是vip用户,检查vip是否过期
            
            $where .= '`lastip`="'.getip().'",`lastdate`="'.SYS_TIME.'",`loginnum`=`loginnum`+1';
            $member->update($wherearray('userid'=>$data['userid']));
            $referer = isset($_POST['referer']) && !empty($_POST['referer']) ? urldecode($_POST['referer']) : U('member/index/init');
            showmsg(L('login_success'), $referer, 1);
        }
 
        $referer = isset($_GET['referer']) && trim($_GET['referer']) ? urlencode($_GET['referer']) : '';
        include template('member''login');
    }

 
    /**
    * 会员注册
    */
    public function register(){ 
        $config = get_config();
        //检查是否允许新会员注册
        if($config['member_register'] == 0) showmsg('管理员关闭了新会员注册!''stop');
        
        if(isset($_SESSION['_userid']) && $_SESSION['_userid']){
            showmsg(L('login_success'), U('member/index/init'), 1);
        }
            
            
        if(isset($_POST['dosubmit'])){
            
            if(empty($_SESSION['code']) || strtolower($_POST['code']) != $_SESSION['code']){
                $_SESSION['code'] = '';
                showmsg(L('code_error'), '', 1);
            }
            if (empty($_SESSION['mobile_code']) || strtolower($_POST['mobile_code']) != $_SESSION['mobile_code']) {
                $_SESSION['mobile_code'] = '';
                showmsg(L('手机验证码不正确'),'',1);
            }
            $_SESSION['code'] = '';
            
            $member = D('member');
            $data array();
            $data['username'] = isset($_POST['username']) && is_username($_POST['username']) ? trim($_POST['username']) : showmsg(L('user_name_format_error'));    
            $data['password'] = isset($_POST['password']) && is_password($_POST['password']) ? trim($_POST['password']) : showmsg(L('password_format_error')); 
            $data['email'] = isset($_POST['email']) && is_email($_POST['email']) ? trim($_POST['email']) : showmsg(L('mail_format_error'));            
            $data['mobile'] = isset($_POST['mobile']) && is_mobile($_POST['mobile']) ? trim($_POST['mobile']) : showmsg(L('手机号不正确'));
            $result $member->where(array('username'=>$_POST['username']))->find();
            if($result) showmsg(L('user_already_exists'));
            $result $member->where(array('email'=>$_POST['email']))->find();
            if($result) showmsg("邮箱已存在!");
            $result $member->where(array('mobile'=>$_POST['mobile']))->find();
            if($result) showmsg("手机已存在");
            $data['nickname'] = $data['username'];
            $data["password"] = password($data['password']);
            $data['regdate'] = $data['lastdate'] = SYS_TIME;
            $data['regip'] = $data['lastip'] = getip();
            $data['groupid'] = '1';
            $data['amount'] = '0.00';
            $data['point'] = $data['experience'] = $config['member_point']; //经验和积分
            $data['status'] = ($config['member_check'] || $config['member_email']) ? 0 : 1;    
            $data['userid'] = $member->insert($data, true);      
            if(!$data['userid']) showmsg("注册失败!");
            
            D('member_detail')->insert($data, true, false); //插入附表
            
            if($config['member_email']){  //是否需要邮件验证
                $mail_code $_SESSION['mail_code'] = md5(microtime(true).$data['userid']);
                $_SESSION['userid'] = $data['userid'];
                $url = SITE_URL."index.php?m=member&c=index&a=register&mail_code=$mail_code&userid={$data['userid']}&verify=1";
                $message '请点击邮箱验证地址:<a href="'$url .'">'$url .'</a>';
                $res = sendmail($data['email'], '会员邮箱验证'$message);
                if(!$res) showmsg('邮件发送失败,请联系网站管理员!''stop');
                showmsg('我们已将邮件发送到您的邮箱,请尽快完成验证!');
            }elseif($config['member_check']){  //是否需要管理员审核
                showmsg('注册成功,由于管理员开启审核机制,请耐心等待!');
            }
            
            $_SESSION['_userid'] = $data['userid'];
            $_SESSION['_username'] = $data['username'];
            set_cookie('_userid'$data['userid']);
            set_cookie('_username'$data['username']);
            set_cookie('_nickname'$data['username']);
            set_cookie('_groupid'$data['groupid']);     
            showmsg('注册成功!', U('member/index/init'), 1);         
            
        }else{
            if(!empty($_GET['verify'])) {
                $mail_code = isset($_GET['mail_code']) ? trim($_GET['mail_code']) : showmsg(L('illegal_operation'));
                $userid = isset($_GET['userid']) ? intval($_GET['userid']) : showmsg(L('illegal_operation'));
                if(isset($_SESSION['mail_code']) && $mail_code==$_SESSION['mail_code'] && $userid==$_SESSION['userid']){
                    unset($_SESSION['mail_code'], $_SESSION['userid']);
                    D('member')->update(array('status' => 1, 'email_status' => 1),array('userid'=>$userid));
                    showmsg('邮箱验证成功!', U('member/index/login'), 2);
                }else{
                    showmsg('验证失败,可能是验证时间已过期!', U('member/index/register'));
                }
            }
            include template('member''register');
        }      
        
     
  
    /**
    * 会员退出
    */
    public function logout(){ 
        unset($_SESSION['_userid']);
        unset($_SESSION['_username']);
        del_cookie('_userid');
        del_cookie('_username');
        del_cookie('_nickname');
        del_cookie('_groupid');
        showmsg(L('you_have_safe_exit'), U('member/index/login'), 2);
    }  

 
    
    /**
    * ajax检查用户名是否存在
    * @param string $username    用户名
    * @return $status {0:用户名格式不正确;-1:用户名已经存在 ;1:成功}  
    */
    public function public_checkname(){ 
        $username = isset($_POST['username']) && is_username($_POST['username']) ? trim($_POST['username']) : exit('0');
        $result = D('member')->where(array('username' => $username))->find();
        $result exit('-1') : exit('1');
    }

 
    
    
    /**
    * ajax检查邮箱是否存在
    * @param string $email   邮箱
    * @return $status {0:邮箱格式不正确;-1:邮箱已经存在 ;1:成功}    
    */
    public function public_checkemail(){ 
        $email = isset($_POST['email']) && is_email($_POST['email']) ? trim($_POST['email']) : exit('0');
        $result = D('member')->where(array('email' => $email))->find();
        $result exit('-1') : exit('1');
    }
    
    public function public_checksms(){
        if(empty($_SESSION['code']) || strtolower($_POST['code']) != $_SESSION['code']){
            $_SESSION['code'] = '';
            echo 1;
            exit;
        }
        $_SESSION['code'] = '';
        
        $mobile $_POST['mobile'];
 
        $result = sendsms($mobile);
        echo $result;
 
    }

 
    
    /**
    * 用户修改资料
    */
    public function account(){
        
        if(isset($_POST['dosubmit'])){
            if(!is_mobile($_POST['mobile'])) showmsg('手机号不正确!');
            unset($_POST['userpic'], $_POST['guest'], $_POST['fans']);
            $res = D('member_detail')->update($_POSTarray('userid'=>$this->userid), true);
            if($res){ 
                showmsg('更新资料成功!','',1);
            }else{
                showmsg(L('data_not_modified'));
            }
        }
 
        yzm_base::load_sys_class('form','',0);
        $memberinfo $this->memberinfo;
        extract($memberinfo);
        if($area){
            list($cmbProvince,$cmbCity,$cmbArea) = explode('|',$area); //分配地区
        }else{
            $cmbProvince $cmbCity $cmbArea ='';
        }      
        include template('member''account');
    }
        
    
    
    /**
    * 用户修改头像
    */
    public function user_pic(){
        $memberinfo $this->memberinfo;
        extract($memberinfo);
        if(isset($_POST['dosubmit'])){
            $filename $_FILES['user_pic']['name'];
            if($filename == '') showmsg('请上传头像!');
            $upload = yzm_base::load_sys_class('upload');
            if($upload->uploadfile('user_pic')){
                $fileinfo $upload->getnewfileinfo();
                $picname $fileinfo['filepath'].$fileinfo['filename'];
                D('member_detail')->update(array('userpic'=>$picname),array('userid'=>$this->userid));
                $userpic = YZMPHP_PATH.ltrim($userpic, SITE_PATH);
                if(is_file($userpic)) @unlink($userpic);    //删除原来的头像
                showmsg('更新头像成功!','',1);
            }else{
                showmsg($upload->geterrormsg());
            }
        }
    
        include template('member''user_pic');
    }
    
        
    
    /**
    * 用户修改密码
    */
    public function password(){
 
        if(isset($_POST['dosubmit'])){
            if(strtolower($_POST['code']) != $_SESSION['code']) showmsg(L('code_error'));
            if($_POST['oldpass'] == '') showmsg("原密码不能为空!");
            if(!$this->db->where(array('userid'=>$this->userid, 'password'=>password($_POST['oldpass'])))->find()) showmsg('原密码错误!');
            if(!is_password($_POST['password'])) showmsg('新密码不符合规范!');
            if($this->db->update(array('password'=>password($_POST['password'])), array('userid'=>$this->userid))){
                showmsg(L('operation_success'),'',1);
            }else{
                showmsg(L('operation_failure'));
            }
        }
        
        $memberinfo $this->memberinfo;
        extract($memberinfo);  
        include template('member''password');
    } 
    
    /**
    * 用户修改邮箱/安全问题
    */
    public function email(){
        $memberinfo $this->memberinfo;
        extract($memberinfo);
        
        if(isset($_POST['dosubmit'])){
            if(strtolower($_POST['code']) != $_SESSION['code']) showmsg(L('code_error'));
            if(!$this->db->where(array('userid'=>$this->userid, 'password'=>password($_POST['password'])))->find()) showmsg(L('password_error'));
            
            $data array();
            if(!$email_status){
                if(!isset($_POST['email']) || !is_email($_POST['email'])) showmsg(L('mail_format_error'));
                $data['email'] = $_POST['email'];
            }
            
            $problem = new_html_special_chars(strip_tags(trim($_POST['problem'])));
            $answer = new_html_special_chars(strip_tags(trim($_POST['answer'])));
            if($problem != '0' && $answer != ''){ 
                $data['problem'] = $problem;  //安全问题
                $data['answer'] = $answer;  //安全答案
            }  
                
            if(!empty($data) && $this->db->update($dataarray('userid'=>$this->userid))){
                showmsg(L('operation_success'),'',1);
            }else{
                showmsg(L('data_not_modified'));
            }
        }
        
        $problemarr array('你最喜欢的格言什么?','你家乡的名称是什么?','你读的小学叫什么?','你的父亲叫什么名字?','你的母亲叫什么名字?','你的配偶叫什么名字?','你最喜欢的歌曲是什么?'); 
        include template('member''email');
    }
    
    
    /**
    * ajax会员加关注/取消关注
    * @param int userid  用户ID
    * @return $status {-3:不能关注自己 ;-2:用户ID不合法 ;-1:用户名不存在 ;0:用户未登录 ;1:关注成功 ;2:取消关注成功}
    */
    public function public_follow(){ 
        $this->userid = intval(get_cookie('_userid'));
        if(!isset($_SESSION['_userid']) || !$_SESSION['_userid'] || $this->userid != $_SESSION['_userid']) exit('0');
        $userid = isset($_POST['userid']) ? intval($_POST['userid']) : exit('-2');
        if($this->userid == $useridexit('-3');
        
        $memberinfo = D('member')->field('username')->where(array('userid'=>$userid))->find();
        if(!$memberinfo)  exit('-1');
    
        $member_follow = D('member_follow');
        $r $member_follow->where(array('userid'=>$this->userid, 'followid'=>$userid))->find();
        if($r){
            $member_follow->delete(array('userid'=>$this->userid, 'followid'=>$userid));
            D('member_detail')->update('`fans`=`fans`-1'array('userid'=>$userid));  //减少粉丝数
            exit('2');
        }else{
            $member_follow->insert(array('userid'=>$this->userid,'followid'=>$userid,'followname'=>$memberinfo['username'],'inputtime'=>SYS_TIME));
            D('member_detail')->update('`fans`=`fans`+1'array('userid'=>$userid));  //增加粉丝数
            exit('1'); 
        }
    }
    
    
    /**
    * 我的关注
    */
    public function follow(){
        $memberinfo $this->memberinfo;
        extract($memberinfo);
        
        $member_follow = D('member_follow');
        
        if(isset($_GET['followid'])){
            $followid intval($_GET['followid']);
            if($member_follow->delete(array('userid'=>$userid'followid'=>$followid))){
                D('member_detail')->update('`fans`=`fans`-1'array('userid'=>$followid));  //减少粉丝数
                showmsg(L('operation_success'),'',1);
            }else{
                showmsg(L('data_not_modified'));
            }
        }
        yzm_base::load_sys_class('page','',0);
        $total $member_follow->where(array('userid'=>$userid))->total();
        $page new page($total, 10);
        $data $member_follow->where(array('userid'=>$userid))->order('id DESC')->limit($page->limit())->select();   
        $pages '<span class="pageinfo">共'.$total.'条记录</span>'.$page->getfull();
        include template('member''follow');
    }
    
    
    /**
    * TA的动态
    */
    public function follow_dynamic(){
        $memberinfo $this->memberinfo;
        extract($memberinfo);
        
        $member_content = D('member_content');
        yzm_base::load_sys_class('page','',0);
        $total $member_content->join('yzmcms_member_follow ON yzmcms_member_follow.followid = yzmcms_member_content.userid''RIGHT')->where("yzmcms_member_follow.userid=$userid AND status=1")->total();
        $page new page($total, 10);
        $res $member_content->field('yzmcms_member_content.checkid,yzmcms_member_content.catid,yzmcms_member_content.username,yzmcms_member_content.title,yzmcms_member_content.inputtime')->join('yzmcms_member_follow ON yzmcms_member_follow.followid = yzmcms_member_content.userid''RIGHT')->where("yzmcms_member_follow.userid=$userid AND status=1")->order('inputtime DESC')->limit($page->limit())->select();  
        $data array();
        foreach($res as $val) {
            list($val['modelid'], $val['id']) = explode('_'$val['checkid']);
            $val['url'] = SITE_URL.'index.php?m=index&c=index&a=show&catid='.$val['catid'].'&id='.$val['id'];
            $val['event'] = $val['username'].' 发布了《<a href="'.$val['url'].'" target="_blank">'.$val['title'].'</a>》';
            $data[] = $val;
        }
        $pages '<span class="pageinfo">共'.$total.'条记录</span>'.$page->getfull();
        include template('member''follow_dynamic');
    }
    
}

然后我们去修改使用短信找回密码的后端文件,打开项目\application\member\controller\reset.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
public function reset_mobile(){
        session_start();
        $_SESSION['step'] = isset($_SESSION['step']) ? $_SESSION['step'] : 1;
 
        if ($_SESSION['step']==1 && isset($_POST['dosubmit'])) {
            if(empty($_SESSION['code']) || strtolower($_POST['code']) != $_SESSION['code']){
                $_SESSION['code'] = '';
                showmsg(L('code_error'), '', 1);
        }
 
        $data $this->_check($_POST['username']);
        if(empty($data['mobile'])) showmsg('您没有绑定手机,请选择其他方式找回密码!''stop');
        $ret = sendsms($data['mobile']);
        if ($ret != 0) {
            showmsg('短信发送失败,请联系网站管理员!');
        }
        $_SESSION['mobile'] = $data['mobile'];
        $_SESSION['userid'] = $data['userid'];
        $_SESSION['emc_times'] = 5;
        $_SESSION['step'] = 2;
        }elseif($_SESSION['step'] ==2 && isset($_POST['dosubmit'])){
            if($_SESSION['emc_times']=='' || $_SESSION['emc_times']<=0){
                $_SESSION['step'] = 1;
                showmsg("验证次数超过5次,请重新获取短信验证码!");
            }
            if(!empty($_SESSION['mobile_code']) && strtolower($_POST['mobile_code']) == strtolower($_SESSION['mobile_code'])){
                unset($_SESSION['emc_times']);
                $_SESSION['step'] = 3;
            }else{
                $_SESSION['emc_times'] = $_SESSION['emc_times']-1;
                showmsg('短信校验码错误!','',1);
            }
 
        }else if($_SESSION['step']==3 && isset($_POST['dosubmit'])){
            
            if(!isset($_POST['password']) || !is_password($_POST['password'])) showmsg(L('password_format_error'));
            
            D('member')->update(array('password' => password($_POST['password'])),array('userid'=>$_SESSION['userid']));
            unset($_SESSION['step'], $_SESSION['code'], $_SESSION['mobile_code'], $_SESSION['mobile'], $_SESSION['userid']);
            showmsg('更新密码成功!', U('member/index/login'));
            
        }
 
        include template('member''reset_mobile');
    }

接下来我们去增加短信接口,打开项目\common\function\system.func.php文件,新增一个方法,代码如下:

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
function sendsms($mobile)
{
    $config = get_config();
    $user $config['smsbao_user'];
    $pass $config['smsbao_pass'];
    $sign $config['smsbao_sign'];
    if (empty($user) && empty($pass) && empty($sign)) {
        return 2;
    }
    $code = rand(1000,9999);
    $content '【'.$sign.'】您的验证码为:'.$code.'请妥善保存!';
    $url 'http://api.smsbao.com/sms?u='.$user.'&p='.md5($pass).'&m='.$mobile.'&c='.$content;
    $result file_get_contents($url);
    if ($result == 0) {
        $_SESSION['mobile_code'] = $code;
        return '0';
    }else{
        return $result;
    }
 
}

最后我们需要在数据库中增加我们短信宝的配置信息,首先我们在根目录新建两个文件,smsbao_install.php和smsbao.sql,打开smsbao.sql文件,将下列代码进行复制保存:

?
1
2
3
4
5
INSERT INTO `yzm_config` (`id`, `name`, `type`, `title`,`value`,`status`) VALUES ('''smsbao_user''1''短信宝用户名','0','1');
INSERT INTO `yzm_config` (`id`, `name`, `type`, `title`,`value`,`status`) VALUES ('''smsbao_pass''1''短信宝密码','0','1');
INSERT INTO `yzm_config` (`id`, `name`, `type`, `title`,`value`,`status`) VALUES ('''smsbao_sign''1''短信宝用户名','0','1');
INSERT INTO `yzm_config` (`id`, `name`, `type`, `title`,`value`,`status`) VALUES ('''member_mobile''3''新会员注册是否需要短信验证','0','1');
ALTER TABLE `yzm_member` ADD COLUMN `mobile`  char(11) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL COMMENT '手机号码' AFTER `loginnum`;

然后我们打开smsbao_install/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
<?php
header("Content-type:text/html;charset=utf-8");
$config include('./common/config/config.php');
 
$conn = mysqli_connect($config['db_host'],$config['db_user'],$config['db_pwd'],$config['db_name']);
 
 
$newsql = sreadfile("smsbao.sql");
$sqls explode(";"$newsql);
 
foreach ($sqls as $sql) {
    if (empty($sql)) {
        continue;
    }
    if (!$con $con = mysqli_query($conn,$sql)) {
        echo "执行sql语句成功".mysqli_error($conn);
        exit();
    }
 
}
 
echo "<h4>YzmCMS短信宝短信插件安装成功,请删除此文件。</h4>";
 
function sreadfile($filename){
    $content '';
    if(function_exists('file_get_contents')) {
        @$content file_get_contents($filename);
    else {
        if(@$fp fopen($filename'r')) {
            @$content fread($fpfilesize($filename));
            @fclose($fp);
        }
    }
    return $content;
}

好了,经过以上的替换,短信宝的短信平台已经替换成功了,我们去进行发送测试:

 

报备一下短信宝的VIP模板,这样就可以走短信宝的优质通道了,即便遇到敏感文字我们都不会人工审核,短信内容3~5秒就可送达。

另外:我们已经开发好完整的YZMCMS内容管理系统短信宝插件,点击此链接 下载及查看安装流程。

 
开源插件
文章标签