YzmCMS是一款輕量級開源內容管理系統,它采用OOP(面向對象)方式自主開發的框架?;赑HP+Mysql架構,并采用MVC框架式開發的一款高效開源的內容管理系統,便于進行二次開發,小編對這款軟件還是比較了解的,小編今天就給大家講解一下YzmCMS_v5.1版本的短信寶接口替換流程,我們使用的短信接口是我們短信寶短信群發平臺的短信接口,我們短信寶短信群發平臺非常穩定,發送速度快,注冊就送測試短信,推薦大家使用。
首先我們打開項目:application\admin\view\system_set.html文件,替換227~307行代碼:
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
|
< 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= " 保存 " > <input type= "reset" class = "btn btn-default radius" value= " 取消 " > </ 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())){ 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> |
接著我們打開項目: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" ></ i > 首頁 < span class = "c-gray en" >></ span > 會員管理 < span class = "c-gray en" >></ 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" ></ 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 = " 保存 " > < input type = "reset" class = "btn btn-default radius" value = " 取消 " > </ 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_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. 確認賬號 > 2.安全驗證 > 3. 重置密碼 > 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文件,替換register方法
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
|
/** * 會員注冊 */ 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 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 ; } |
接著打開項目:application\member\controller\reset.class.php文件,增加reset_mobile方法
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文件中增加sendsms發送短信方法
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 . '請妥善保存!' ; $result = file_get_contents ( $url ); if ( $result == 0) { $_SESSION [ 'mobile_code' ] = $code ; return '0' ; } else { return $result ; } } |
最后我們在項目根目錄下創建smsbao_install.php文件及smsbao.sql文件,來安裝短信寶信息
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 ( $fp , filesize ( $filename )); @fclose( $fp ); } } return $content ; } |
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`; |
經過上面的替換,短信寶的短信平臺已經替換成功了,可以正常使用了。進行測試發送:
報備一下短信寶的VIP模板,這樣就可以走短信寶的優質通道了,即便遇到敏感文字我們都不會人工審核,短信內容3~5秒就可送達。
另外:我們已經開發好完整的yzmCMS短信寶插件,點擊此鏈接 下載及查看安裝流程。
最新更新
電商類
CMS類
微信類