Lecms 是一款輕量級(jí)網(wǎng)站內(nèi)容管理系統(tǒng),簡(jiǎn)潔精干。程序框架采用懶加載、分布式服務(wù)器的設(shè)計(jì),每張表都可有自己的DB服務(wù)器群和CACHE服務(wù)器(群),單表能承受億級(jí)數(shù)據(jù)。內(nèi)置多種SEO設(shè)置,對(duì)網(wǎng)站URL路徑設(shè)置自由度極高,可自由靈活設(shè)置網(wǎng)站的URL,讓你的網(wǎng)站在搜索引擎中獲得好的收錄排名。小編對(duì)他還是比較了解的,今天小編就以新增短信接口為例,給大家講解一下如何進(jìn)行二次開發(fā),我們今天講解的是v3.0.3版本,使用的短信接口是我們短信寶短信群發(fā)平臺(tái)的短信接口,我們短信寶短信群發(fā)平臺(tái)的接口非常穩(wěn)定,發(fā)送速度快,注冊(cè)就送測(cè)試短信,推薦大家使用
1:打開項(xiàng)目:admin\control\admin_control.class.php 新增短信設(shè)置路由
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
|
$menu['menuInfo']['setting'] = array( 'title' => lang('setting'), 'icon' => 'fa fa-cogs', 'href' => '', 'target' => '_self', 'child' =>array( array('title' => lang('basic_setting'), 'href' => 'index.php?setting-index', 'icon' => 'fa fa-cog', 'target' => '_self'), array('title' => lang('seo_setting'), 'href' => 'index.php?setting-seo', 'icon' => 'fa fa-life-ring', 'target' => '_self'), array('title' => lang('link_setting'), 'href' => 'index.php?setting-link', 'icon' => 'fa fa-link', 'target' => '_self'), array('title' => lang('user_setting'), 'href' => 'index.php?setting-user', 'icon' => 'fa fa-user-circle', 'target' => '_self'), array('title' => lang('attach_setting'), 'href' => 'index.php?setting-attach', 'icon' => 'fa fa-paperclip', 'target' => '_self'), array('title' => lang('image_setting'), 'href' => 'index.php?setting-image', 'icon' => 'fa fa-file-image-o', 'target' => '_self'), array('title' => lang('comment_setting'), 'href' => 'index.php?setting-comment', 'icon' => 'fa fa-comments-o', 'target' => '_self'), array('title' => lang('email_setting'), 'href' => 'index.php?setting-email', 'icon' => 'fa fa-envelope', 'target' => '_self'), array('title' => '短信設(shè)置', 'href' => 'index.php?setting-sms', 'icon' => 'fa fa-envelope', 'target' => '_self'), array('title' => lang('other_setting'), 'href' => 'index.php?setting-other', 'icon' => 'fa fa-info', 'target' => '_self'), ), ); |
2:打開項(xiàng)目:admin\view\default 新增setting_sms.htm短信配置文件
|
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
|
{inc:header.htm}<div class="layui-card"> <div class="layui-card-header">短信設(shè)置</div> <div class="layui-card-body"> <form id="form" class="layui-form" action="index.php?setting-sms-ajax-1" method="post"> <div class="layui-form-item"> <label class="layui-form-label required">短信開關(guān)</label> <div class="layui-input-block"> {$input[open_sms]} </div> </div> <div class="layui-form-item"> <label class="layui-form-label required">短信寶賬號(hào)</label> <div class="layui-input-inline"> {$input[sms_user]} </div> </div> <div class="layui-form-item"> <label class="layui-form-label required">短信寶密碼</label> <div class="layui-input-inline"> {$input[sms_pwd]} </div> </div> <div class="layui-form-item"> <label class="layui-form-label required">短信寶簽名</label> <div class="layui-input-inline"> {$input[sms_sign]} </div> </div> <div class="layui-form-item"> <label class="layui-form-label">短信模板</label> <div class="layui-input-inline"> {$input[sms_template]} </div> </div> {hook:admin_setting_email_after.htm} <div class="layui-form-item"> <div class="layui-input-block"> <button class="layui-btn" lay-submit lay-filter="form">{lang:submit}</button> </div> </div> </form> </div></div><script type="text/javascript"> layui.use('form', function(){ var form = layui.form; //監(jiān)聽提交 form.on('submit(form)', function(){ adminAjax.submit("#form"); }); });</script></body></html> |
3:打開項(xiàng)目:\admin\control\setting_control.class.php 新增短信設(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
|
//短信設(shè)置 public function sms(){ // hook admin_setting_control_email_before.php if(empty($_POST)) { version_compare(PHP_VERSION, '5.5.0', '>') || $this->message(0, lang('php_version_5_5'), '', 1000); $cfg = $this->kv->xget('cfg'); $input = array(); $arr = array(1=>lang('open'), 0=>lang('close')); $input['open_sms'] = form::get_radio_layui('open_sms', $arr, $cfg['open_sms']); $input['sms_user'] = form::get_text('sms_user', $cfg['sms_user'], '', 'lay-verify="required"'); $input['sms_pwd'] = form::get_password('sms_pwd', $cfg['sms_pwd'], '', 'lay-verify="required"'); $input['sms_sign'] = form::get_text('sms_sign', $cfg['sms_sign'], '', 'lay-verify="required"'); $input['sms_template'] = form::get_text('sms_template', $cfg['sms_template']); // hook admin_setting_control_email_after.php $this->assign('input', $input); $this->assign('cfg', $cfg); $this->display(); }else{ $this->kv->xset('open_sms', (int) R('open_sms', 'P'), 'cfg'); $this->kv->xset('sms_user', R('sms_user', 'P'), 'cfg'); $this->kv->xset('sms_pwd', R('sms_pwd', 'P'), 'cfg'); $this->kv->xset('sms_sign', R('sms_sign', 'P'), 'cfg'); $this->kv->xset('sms_template', R('sms_template', 'P'), 'cfg'); // hook admin_setting_control_email_post_after.php $this->kv->save_changed(); $this->runtime->delete('cfg'); E(0, lang('edit_sucessfully')); } } |
4:打開項(xiàng)目:\view\default\user\register.htm 注冊(cè)頁面添加手機(jī)驗(yàn)證
|
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
|
{if:$cfg[open_user_register_vcode]} <div class="form-group"> <label for="vcode" class="col-sm-4 control-label">{lang:vcode}</label> <div class="col-sm-4"> <input class="form-control" id="vcode" type="text" name="vcode" value="" placeholder="{lang:vcode}" autocomplete="off"> </div> <div class="col-sm-4"> <img src="index.php?user-vcode-name-registervcode.html" alt="{lang:vcode}" onclick="this.src='index.php?user-vcode-name-registervcode-r-'+Math.random();" id="vcodeimg" style="width: 100%;" /> </div> </div> {/if} {if:$cfg[open_sms]} <div class="form-group"> <label for="mobile" class="col-sm-4 control-label">手機(jī)號(hào)</label> <div class="col-sm-8"> <input class="form-control" id="mobile" type="text" name="mobile" value="" placeholder="請(qǐng)輸入手機(jī)號(hào)" autocomplete="off"> </div> </div> <div class="form-group"> <label for="smscode" class="col-sm-4 control-label">短信驗(yàn)證碼</label> <div class="col-sm-4"> <input class="form-control" id="smscode" type="text" name="smscode" value="" placeholder="短信驗(yàn)證碼" autocomplete="off"> </div> <div class="col-sm-4"> <input id="sendmobilecode" class="btn btn-primary btn-sm ml-3 " lay-submit lay-filter="sendSms" type="button" value="獲取驗(yàn)證碼"> </div> </div> {/if}<script type="text/javascript"> layui.use(['form'], function () { var form = layui.form, layer = layui.layer, $ = layui.$; form.on('submit(form)', function (data) { data = data.field; if (data.username == '') { layer.msg('{lang:please_input_username}', {icon: 5}); return false; }else if (data.password == '') { layer.msg('{lang:please_input_password}', {icon: 5}); return false; }else if (data.repassword == '') { layer.msg('{lang:please_input_confirm_password}', {icon: 5}); return false; }else if (data.mobile == '') { layer.msg('請(qǐng)?zhí)顚懯謾C(jī)號(hào)', {icon: 5}); return false; }else if (data.smscode == '') { layer.msg('請(qǐng)?zhí)顚懚绦膨?yàn)證碼', {icon: 5}); return false; } else if(data.password != data.repassword){ layer.msg('{lang:pwd_inconsistent}', {icon: 5}); return false; } $.post("index.php?user-register-ajax-1",data,function(res){ if(res.status){ var icon = 1; }else{ var icon = 5; } layer.msg(res.message, {icon: icon}); if(res.status) setTimeout(function(){ location.href="{$_http_referer}"; }, 1000); return false; },'json'); return false; }); $('#sendmobilecode').on('click', function(){ var mobile = $('#mobile').val() var vcode = $('#vcode').val() if (mobile == ''){ layer.msg('請(qǐng)?zhí)顚懯謾C(jī)號(hào)'); return false; } $.post("index.php?user-sendsms-ajax-1",{mobile: mobile,vcode:vcode,type:1},function(res){ if(res.status){ var icon = 1; }else{ var icon = 5; } layer.msg(res.message, {icon: icon}); return false; },'json'); }); }); </script> |
5:打開項(xiàng)目:view\default\user 新增短信忘記密碼頁面
|
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
|
<!DOCTYPE html><html><head> <meta charset="utf-8"> <title>{$cfg[titles]}</title> <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no"> <meta name="renderer" content="webkit"> <link rel="shortcut icon" type="image/x-icon" href= "{$cfg[webdir]}favicon.ico" /> <link rel="stylesheet" href="{$cfg[tpl]}user/css/frontend.min.css" media="all"> <link rel="stylesheet" href="{$cfg[tpl]}user/css/user.css" media="all"> <!-- HTML5 shim, for IE6-8 support of HTML5 elements. All other JS at the end of file. --> <!--[if lt IE 9]> <script src="{$cfg[tpl]}user/js/html5shiv.js"></script> <script src="{$cfg[tpl]}user/js/respond.min.js"></script> <![endif]--> <script src="{$cfg[webdir]}static/js/jquery.js" charset="utf-8"></script><!-- <script src=" </head><body><nav class="navbar navbar-white navbar-fixed-top" role="navigation"> <div class="container"> <div class="navbar-header"> <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#header-navbar"> <span class="sr-only">{lang:toggle}</span> <span class="icon-bar"></span> <span class="icon-bar"></span> <span class="icon-bar"></span> </button> <a class="navbar-brand" href="{$cfg[weburl]}">{$cfg[webname]}</a> </div> <div class="collapse navbar-collapse" id="header-navbar"> <ul class="nav navbar-nav navbar-right"> <li><a href="{$cfg[weburl]}" title="{$cfg[webname]}">{lang:home}</a></li> </ul> </div> </div></nav><main class="content"> <div id="content-container" class="container"> <div class="user-section login-section"> <div class="logon-tab clearfix"> <a class="active" title="{lang:forget_password}" rel="nofollow">{lang:forget_password}</a>{if:$cfg[open_user_login]}<a href="{$login_url}" title="{lang:login}" rel="nofollow">{lang:login}</a>{/if} </div> <div class="login-main"> <form id="login-form" class="form-horizontal layui-form" action="index.php?user-forget.html" method="post"> <input type="hidden" name="FORM_HASH" value="{$C[FORM_HASH]}" /> <div class="form-group"> <label for="username" class="col-sm-4 control-label">{lang:username}</label> <div class="col-sm-8"> <input class="form-control" id="username" type="text" name="username" value="" placeholder="{lang:please_input_username}" autocomplete="off"> </div> </div> <div class="form-group"> <label for="mobile" class="col-sm-4 control-label">手機(jī)號(hào)</label> <div class="col-sm-8"> <input class="form-control" id="mobile" type="text" name="mobile" value="" placeholder="請(qǐng)輸入手機(jī)號(hào)" autocomplete="off"> </div> </div> <div class="form-group"> <label for="smscode" class="col-sm-4 control-label">短信驗(yàn)證碼</label> <div class="col-sm-4"> <input class="form-control" id="smscode" type="text" name="smscode" value="" placeholder="短信驗(yàn)證碼" autocomplete="off"> </div> <div class="col-sm-4"> <input id="sendmobilecode" class="btn btn-primary btn-sm ml-3 " lay-submit lay-filter="sendSms" type="button" value="獲取驗(yàn)證碼"> </div> </div> <div class="form-group"> <label for="vcode" class="col-sm-4 control-label">{lang:vcode}</label> <div class="col-sm-4"> <input class="form-control" id="vcode" type="text" name="vcode" value="" placeholder="{lang:vcode}" autocomplete="off"> </div> <div class="col-sm-4"> <img src="index.php?user-vcode-name-forgetvcode.html" alt="{lang:vcode}" onclick="this.src='index.php?user-vcode-name-forgetvcode-r-'+Math.random();" id="vcodeimg" style="width: 100%;" /> </div> </div> <div class="form-group"> <label for="password" class="col-sm-4 control-label">{lang:new_password}</label> <div class="col-sm-8"> <input class="form-control" id="password" type="text" name="password" value="" placeholder="{lang:new_password}" autocomplete="off"> </div> </div> <div class="form-group"> <label for="repassword" class="col-sm-4 control-label">{lang:confirm_new_password}</label> <div class="col-sm-8"> <input class="form-control" id="repassword" type="text" name="repassword" value="" placeholder="{lang:confirm_new_password}" autocomplete="off"> </div> </div> <div class="form-group"> <label class="col-sm-3 control-label"></label> <div class="col-sm-9"> <button type="submit" class="btn btn-primary btn-lg btn-block" lay-submit lay-filter="form">提交</button> </div> </div> {hook:user_user_forget_after.htm} </form> </div> </div> </div></main><footer class="footer" style="clear:both"> <p class="copyright">Copyright ? {php}echo date('Y');{/php} {$cfg[webname]} All Rights Reserved.</p></footer><script src="{$cfg[webdir]}static/layui/lib/layui-v2.6.3/layui.js" charset="utf-8"></script><script type="text/javascript"> layui.use(['form'], function () { var form = layui.form, layer = layui.layer, $ = layui.$; form.on('submit(form)', function (data) { data = data.field; if (data.username == '') { layer.msg('{lang:please_input_username}', {icon: 5}); return false; }else if (data.mobile == '') { layer.msg('手機(jī)號(hào)為空', {icon: 5}); return false; }else if (data.vcode == '') { layer.msg('{lang:vcode_no_empty}', {icon: 5}); return false; }else{ $.post("index.php?user-mobileforget-ajax-1",data,function(res){ if(res.status){ var icon = 1; }else{ var icon = 5; } layer.msg(res.message, {icon: icon}); if(res.status) setTimeout(function(){ location.href="{$_http_referer}"; }, 1000); return false; },'json'); return false; } }); $('#sendmobilecode').on('click', function(){ var mobile = $('#mobile').val() var vcode = $('#vcode').val() if (mobile == ''){ layer.msg('請(qǐng)?zhí)顚懯謾C(jī)號(hào)'); return false; } $.post("index.php?user-sendsms-ajax-1",{mobile: mobile,vcode:vcode,type:2},function(res){ if(res.status){ var icon = 1; }else{ var icon = 5; } layer.msg(res.message, {icon: icon}); return false; },'json'); }); });</script></body></html> |
6:打開項(xiàng)目:lecms\control\user_control.class.php 大概45行修改忘記密碼跳轉(zhuǎn)鏈接
|
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
|
function __construct() { parent::__construct(); $dis_action = array('login','register','forget','resetpwd'); //登錄后禁止訪問的action // hook user_control_construct_dis_action_after.php if( !isset($this->_cfg['open_user']) || empty($this->_cfg['open_user']) ){//未開啟用戶功能 $this->message(0, lang('open_user_0'), $this->_cfg['weburl']); }elseif ( $this->_uid && in_array($_GET['action'], $dis_action)){ $this->message(0, lang('logged'), $this->cms_content->user_url('index','my')); } //來路 $this->_http_referer = user_http_referer(array(), $this->_cfg['weburl']); $this->assign('_http_referer', $this->_http_referer); //忘記密碼鏈接 if (isset($this->_cfg['open_sms'])){ $forget_pwd_url = $this->cms_content->user_url('mobileforget', 'user'); }else{ $forget_pwd_url = $this->cms_content->user_url('forget', 'user'); } $this->assign('forget_pwd_url', $forget_pwd_url); // hook user_control_construct_after.php } |
7:打開項(xiàng)目:lecms\control\user_control.class.php 修改注冊(cè)用戶注冊(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
90
91
92
93
94
95
96
97
98
99
|
public function register() { if( !isset($this->_cfg['open_user_register']) || empty($this->_cfg['open_user_register']) ){ $this->message(0, lang('register_close'), $this->_cfg['weburl']); } if(empty($_POST)) { $this->_cfg['titles'] = lang('register').'_'.$this->_cfg['webname']; $this->_var['topcid'] = -1; $this->assign('cfg', $this->_cfg); $this->assign('cfg_var', $this->_var); // hook user_control_register_after.php $GLOBALS['run'] = &$this; $_ENV['_theme'] = &$this->_cfg['theme']; $this->display('user/register.htm'); }elseif(form_submit()) { // hook user_control_register_post_before.php $user = &$this->user; $username = R('username', 'P'); $password = R('password', 'P'); $repassword = R('repassword', 'P'); if($message = $user->check_username($username)) { $this->message(0, $message); }elseif($message = $user->check_password($password)){ $this->message(0, $message); }elseif ($password != $repassword){ $this->message(0, lang('pwd_inconsistent')); } //開啟了注冊(cè)驗(yàn)證碼 if( !empty($this->_cfg['open_user_register_vcode']) ){ $vcode = R('vcode', 'P'); empty($vcode) && $this->message(0, lang('vcode_no_empty')); if($vcode != _SESSION('registervcode')){ $this->message(0, lang('vcode_error')); } } //開啟了短信驗(yàn)證碼 if (!empty($this->_cfg['open_sms'])){ $sess_mobile = _SESSION('user_create_mobile'); $sess_code = _SESSION('user_create_code'); $mobile = R('mobile', 'P'); $smscode = R('smscode', 'P'); if(!preg_match('/^1[3-9]\d{9}$/', $mobile)){ $this->message(0, '手機(jī)號(hào)有誤'); } if (empty($sess_code)) $this->message(0, '請(qǐng)點(diǎn)擊獲取驗(yàn)證碼'); if (empty($sess_mobile)) $this->message(0, '請(qǐng)點(diǎn)擊獲取驗(yàn)證碼'); if ($mobile != $sess_mobile) $this->message(0, lang('驗(yàn)證碼不正確')); if ($smscode != $sess_code) $this->message(0, lang('驗(yàn)證碼不正確')); } // hook user_control_register_post_check_after.php if($user->get_user_by_username($username)){ $this->message(0, lang('username_is_exists')); } $salt = random(16, 3, '0123456789abcdefghijklmnopqrstuvwxyz'); // 增加破解難度 $password = md5(md5($password).$salt); $ip = ip2long($_ENV['_ip']); $data = array( 'username'=>$username, 'password'=>$password, 'salt'=>$salt, 'groupid'=>11, //注冊(cè)用戶 'author'=>$username, 'regip'=>$ip, 'regdate'=>$_ENV['_time'], 'mobile'=>isset($mobile) ? $mobile : '', ); // hook user_control_register_post_data_after.php $uid = $user->create($data); if($uid){ // hook user_control_register_post_create_success_after.php // 寫入 cookie $userauth = str_auth("$uid\t$data[username]\t$data[password]\t$data[groupid]", 'ENCODE'); _setcookie('userauth', $userauth, 0, '', '', false, true); // 更新登錄信息 $updata['uid'] = $uid; $updata['loginip'] = ip2long($ip); $updata['logindate'] = $_ENV['_time']; $updata['logins'] = 1; $user->update($updata); $this->message(1, lang('register_successfully'), $this->_http_referer); }else{ $this->message(0, lang('register_failed')); } }else{ $this->message(0, lang('form_invalid')); } } |
8:當(dāng)前項(xià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
|
public function sendsms(){ if (!$_POST){ $this->message(0, 'error'); } if (isset($_SESSION['countdown']) && time()<($_SESSION['countdown']+60)) { $this->message(0, '請(qǐng)求頻繁'); } $mobile = R('mobile','P'); if (empty($this->_cfg['open_sms'])){ $this->message(0, '短信未開啟'); } if (!preg_match('/^1[3-9]\d{9}$/', $mobile)) { $this->message(0, '手機(jī)號(hào)錯(cuò)誤'); } //應(yīng)該都請(qǐng)求 if( !empty($this->_cfg['open_user_register_vcode']) ){ $vcode = R('vcode', 'P'); empty($vcode) && $this->message(0, lang('vcode_no_empty')); $key = (R('type','P')==1)? 'registervcode' : 'forgetvcode'; if($vcode != _SESSION($key)){ $this->message(0, lang('vcode_error')); } } $code = rand(100000, 999999); $_SESSION['user_create_mobile'] = $mobile; $_SESSION['user_create_code'] = $code; $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)容含有敏感詞" ); $user = $this->_cfg['sms_user']; //短信平臺(tái)帳號(hào) $pass = md5($this->_cfg['sms_pwd']); //短信平臺(tái)密碼 $content= '【'.$this->_cfg['sms_sign'].'】'.str_replace('{$code}',$code,$this->_cfg['sms_template']);//要發(fā)送的短信內(nèi)容 $phone = $mobile;//要發(fā)送短信的手機(jī)號(hào)碼 $sendurl = $smsapi."sms?u=".$user."&p=".$pass."&m=".$phone."&c=".urlencode($content); $result =file_get_contents($sendurl) ; if ('0' === $result) { $_SESSION['countdown'] = time(); $this->message(1, '發(fā)送成功'); } else { $this->message(0, '發(fā)送失敗'.$statusStr[$result]); } } |
9:當(dāng)前項(xiàng)目下新增手機(jī)號(hào)找回密碼
|
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
|
//手機(jī)號(hào)找回密碼 public function mobileforget(){ if( !isset($this->_cfg['open_user_reset_password']) || empty($this->_cfg['open_user_reset_password'])){ $this->message(0, lang('password_recovery_disabled')); }elseif(empty($this->_cfg['open_sms']) ){ $this->message(0, '短信未開啟'); } if(empty($_POST)) { $this->_cfg['titles'] = lang('forget_password').'_'.$this->_cfg['webname']; $this->_var['topcid'] = -1; $this->assign('cfg', $this->_cfg); $this->assign('cfg_var', $this->_var); // hook user_control_forget_after.php $GLOBALS['run'] = &$this; $_ENV['_theme'] = &$this->_cfg['theme']; $this->display('user/mobile_forget_password.htm'); } else{ $username = R('username', 'P'); $mobile = R('mobile', 'P'); $vcode = R('vcode', 'P'); // hook user_control_forget_post_data_after.php if(empty($username) || empty($mobile) || empty($vcode)){ $this->message(0, '用戶名和驗(yàn)證碼和手機(jī)號(hào)都不能為空'); } if (!preg_match('/^1[3-9]\d{9}$/', $mobile)) { $this->message(0, '手機(jī)號(hào)錯(cuò)誤'); } if($vcode != _SESSION('forgetvcode')){ $this->message(0, lang('vcode_error')); } $data = $this->user->get_user_by_username($username); if( empty($data) ){ $this->message(0, lang('no_this_user')); }else{ if( $data['mobile'] != $mobile){ $this->message(0, lang('該用戶沒有綁定手機(jī)號(hào)或者手機(jī)號(hào)錯(cuò)誤')); } $sess_mobile = _SESSION('user_create_mobile'); $sess_code = _SESSION('user_create_code'); $mobile = R('mobile', 'P'); $smscode = R('smscode', 'P'); $password = R('password', 'P'); $repassword = R('repassword', 'P'); if (empty($sess_code)) $this->message(0, '請(qǐng)點(diǎn)擊獲取驗(yàn)證碼'); if (empty($sess_mobile)) $this->message(0, '請(qǐng)點(diǎn)擊獲取驗(yàn)證碼'); if ($mobile != $sess_mobile) $this->message(0, lang('驗(yàn)證碼不正確')); if ($smscode != $sess_code) $this->message(0, lang('驗(yàn)證碼不正確')); $user = &$this->user; if($message = $user->check_username($username)) { $this->message(0, $message); }elseif($message = $user->check_password($password)){ $this->message(0, $message); }elseif ($password != $repassword){ $this->message(0, lang('pwd_inconsistent')); } $salt = random(16, 3, '0123456789abcdefghijklmnopqrstuvwxyz'); // 增加破解難度 $password = md5(md5($password).$salt); $updata = array( 'uid'=>$data['uid'], 'password'=>$password, 'salt'=>$salt ); if( $user->update($updata) ){ $this->message(1, lang('reset_password_successfully')); }else{ $this->message(0, lang('reset_password_failed')); } } } } |
經(jīng)過上面的替換,短信寶的短信平臺(tái)已經(jīng)替換成功了,可以正常使用了。進(jìn)行測(cè)試發(fā)送:
報(bào)備一下短信寶的VIP模板,這樣就可以走短信寶的優(yōu)質(zhì)通道了,即便遇到敏感文字我們都不會(huì)人工審核,短信內(nèi)容3~5秒就可送達(dá)。
另外:我們已經(jīng)開發(fā)好完整的LeCMS_V3.0.3系統(tǒng)短信寶插件,點(diǎn)擊此鏈接?下載及查看安裝流
最新更新
電商類
CMS類
微信類