YzmCMS是一款輕量級開源內容管理系統,它采用OOP(面向對象)方式自主開發的框架。基于PHP+Mysql架構,并采用MVC框架式開發的一款高效開源的內容管理系統,可運行在Linux、Windows、MacOSX、Solaris等各種平臺上。便于進行二次開發,小編對這款軟件還是比較了解的,小編今天就以新增短信接口為例為大家講解一下如何進行二次開發,我們使用的短信接口是我們短信寶短信群發平臺的短信接口,我們短信寶短信群發平臺非常穩定,發送速度快,注冊就送測試短信,推薦大家使用。
打開項目:\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
|
<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>??? |
打開項目:\application\member\view\member_set.html 在18行增加以下代碼
|
1
2
3
4
5
6
7
8
|
<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> |
打開項目:\application\member\view\member_add.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
|
<form?method="post"?onsubmit="return?dosub(this)">????<ul>?????????<li><label><span?class="c-red">*</span>用戶名:</label><input?type="text"?class="input"?name="username"?value=""?onblur="get_nickname()"></li>?????????<li><label><span?class="c-red">*</span>密碼:</label><input?type="text"?class="input"?name="password"?value=""></li>?????????<li><label>昵稱:</label><input?type="text"?class="input"?name="nickname"?value=""></li>?????????<li><label><span?class="c-red">*</span>郵箱:</label><input?type="email"?class="input"?name="email"?value="">><span?class="c-red">*</span>手機號碼:</label><input?type="mobile"?class="input"?name="mobile"?value=""></li>?????????<li><label><span?class="c-red">*</span>會員組:</label>?????????<span?class="span_input"><select??name="groupid"?style="margin-left:0px;">??????????<?php?????????????foreach($member_group?as?$val){????????????????echo?'<option?value="'.$val['groupid'].'">'.$val['name'].'</option>';????????????}????????????>???????? ?????????</select>?<span?class="c-red">*會員組別影響到經驗</span></span>?????????</li>?????????<li><label><span?class="c-red">*</span>積分:</label><input?type="text"?class="input"?name="point"?value="0"></li>?????????<li><label>vip會員:</label>?????????<span?class="span_input"?title="vip會員可以免積分查看付費內容">是否為vip會員?<input?name="vip"?value="1"?type="checkbox"> ?????????過期時間?<input?type="text"?class="input-text?laydate-icon"?style="width:175px;height:30px;"?name="overduedate"?value=""?onclick="laydate({istime:?true,?format:?'YYYY-MM-DD?hh:mm:ss'})"></span>?????????</li>?????????<li><input?type="hidden"?name="dosubmit"?value="1">?????????<input?class="dosubmit?w_120?btn-primary?radius"?type="submit"?value="提交">?????????<input?class="btn?w_120?btn-default?radius"?type="button"?value="取消"?onclick="yzmcms_close()">?????????</li>????</ul></form> |
打開項目:\application\member\view\default\register.html 注冊頁面添加手機號
|
1
2
3
4
|
????????????????????<li><label>手機號碼:</label><input?type="text"?class="input"?name="mobile"?id="mobile"?value=""></li>????????????????????{if?$config['member_mobile']?==?1}????????????????????<li><input?type="text"?class="input?code"?name="mobile_code"?value=""?id="mobile_code">?<b?class="huoqu"?style="height:?28px;?width:?120px;cursor:?pointer;display:?inline-block;margin-top:?10px;">獲取驗證碼</b></li>????????????????????{/if} |
打開項目:\application\member\view\default\register.html 同時最后也添加js代碼、
|
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
|
????<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(){????????????????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};????????????????????console.log(data);????????????????????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(data){????????????????????????????????data?=?JSON.parse(data)????????????????????????????????if(data.status?===?1){????????????????????????????????????time?=?60;????????????????????????????????????sendTime();????????????????????????????????????layer.msg('短信發送成功!');????????????????????????????????????ret?=?true;????????????????????????????????}else{????????????????????????????????????layer.msg(data.message);????????????????????????????????????window.location.reload();????????????????????????????????}????????????????????????????}????????????????????????});????????????????????}????????????????????$('.codeimg').click();????????????????????return?ret;????????????????}????????????})????????})????</script> |
打開項目:\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
|
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(is_ajax()){//????????? $this->_check_code($_POST['code']);????????????if?(empty($_SESSION['mobile_code'])?||?strtolower($_POST['mobile_code'])?!=?$_SESSION['mobile_code'])?{????????????????$_SESSION['mobile_code']?=?'';????????????????return_json(array('status'=>0,?'message'=>'手機驗證碼不正確'));????????????}????????????$member?=?D('member');????????????$data?=?array();????????????$data['username']?=?isset($_POST['username'])?&&?is_username($_POST['username'])???trim($_POST['username'])?:?return_json(array('status'=>0,?'message'=>L('user_name_format_error')));?? ????????????$data['password']?=?isset($_POST['password'])?&&?is_password($_POST['password'])???trim($_POST['password'])?:?return_json(array('status'=>0,?'message'=>L('password_format_error')));??? ????????????$data['email']?=?isset($_POST['email'])?&&?is_email($_POST['email'])???trim($_POST['email'])?:?return_json(array('status'=>0,?'message'=>L('mail_format_error')));????????????$data['mobile']?=?isset($_POST['mobile'])?&&?is_mobile($_POST['mobile'])???trim($_POST['mobile'])?:?return_json(array('status'=>0,?'message'=>'手機號不正確'));????????????$result?=?$member->field('userid')->where(array('username'=>$_POST['username']))->find();????????????if($result)?return_json(array('status'=>0,?'message'=>'該用戶名已注冊!'));???? ????????????$result?=?$member->field('userid')->where(array('email'=>$_POST['email']))->find();????????????if($result)?return_json(array('status'=>0,?'message'=>'該郵箱已注冊!'));????? ????????????????????????$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'])?return_json(array('status'=>0,?'message'=>'注冊失敗!'));?????? ????????????????????????D('member_detail')->insert($data,?true,?false);?//插入附表????????????????????????if($config['member_email']){????????????????//需要郵件驗證????????????????$mail_code?=?string_auth($data['userid'].'|'.SYS_TIME,?'ENCODE',?make_auth_key('email'));????????????????$url?=?U('member/index/register',?array('mail_code'=>$mail_code,?'verify'=>1));????????????????$email_tpl?=?APP_PATH.ROUTE_M.DIRECTORY_SEPARATOR.'view'.DIRECTORY_SEPARATOR.(defined('MODULE_THEME')???MODULE_THEME?:?C('site_theme')).DIRECTORY_SEPARATOR.'email_register_message.html'?;????????????????$message?=?is_file($email_tpl)???file_get_contents($email_tpl)?:?return_json(array('status'=>0,?'message'=>'郵件模板不存在,請聯系網站管理員!'));????? ????????????????$message?=?str_replace(array('{site_name}','{url}','{username}','{email}'),?array(get_config('site_name'),$url,$data['username'],$data['email']),?$message);????????????????$res?=?sendmail($data['email'],?'會員注冊郵箱驗證',?$message);????????????????if(!$res)?return_json(array('status'=>0,?'message'=>'郵件發送失敗,請聯系網站管理員!'));????????????????return_json(array('status'=>1,?'message'=>'我們已將郵件發送到您的郵箱,請盡快完成驗證!',?'url'=>U('member/index/login')));????????????}elseif($config['member_check']){??????????????????//需要管理員審核????????????????return_json(array('status'=>1,?'message'=>'注冊成功,由于管理員開啟審核機制,請耐心等待!',?'url'=>U('member/index/login')));????????????}????????????????????????$_SESSION['_userid']?=?$data['userid'];????????????$_SESSION['_username']?=?$data['username'];????????????set_cookie('_userid',?$data['userid'],?0,?true);????????????set_cookie('_username',?$data['username'],?0,?true);????????????set_cookie('_groupid',?$data['groupid'],?0,?true);?????? ????????????set_cookie('_nickname',?$data['username']);????????????return_json(array('status'=>1,?'message'=>'注冊成功!',?'url'=>U('member/index/init')));????? ????????????????????}else{????????????if(!empty($_GET['verify']))?{????????????????$mail_code?=?isset($_GET['mail_code'])???trim($_GET['mail_code'])?:?showmsg(L('illegal_operation'),?'stop');????????????????$code_res?=?string_auth($mail_code,?'DECODE',?make_auth_key('email'));????????????????$code_arr?=?explode('|',?$code_res);????????????????$userid?=?isset($code_arr[0])???intval($code_arr[0])?:?showmsg(L('illegal_operation'),?'stop');????????????????$time?=?isset($code_arr[1])???$code_arr[1]?:?showmsg(L('illegal_operation'),?'stop');????????????????if($time+1800?>?SYS_TIME){????????????????????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');????????}?????? ????????????}?? |
打開項目:\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
49
50
51
52
53
54
55
|
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
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
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_json(array('status'=>0,?'message'=>'短信配置錯誤'));????}????$code?=?rand(1000,9999);????$content?=?'【'.$sign.'】您的驗證碼為:'.$code.'請妥善保存!';????$result?=?file_get_contents($url);????if?($result?==?0)?{????????$_SESSION['mobile_code']?=?$code;????????setcache($mobile,?time(),60);????????return_json(array('status'=>1,?'message'=>'發送成功'));????}else{????????return_json(array('status'=>0,?'message'=>'發送失敗'));????}}function?resetsms($mobile){????$config?=?get_config();????$user?=?$config['smsbao_user'];????$pass?=?$config['smsbao_pass'];????$sign?=?$config['smsbao_sign'];????if?(empty($user)?&&?empty($pass)?&&?empty($sign))?{????????return?1;????}????$code?=?rand(1000,9999);????$content?=?'【'.$sign.'】您的驗證碼為:'.$code.'請妥善保存!';????$result?=?file_get_contents($url);????if?($result?==?0)?{????????$_SESSION['mobile_code']?=?$code;????????return?0;????}else{????????return?1;????} |
打開項目:\application\member\view\default\reset_type.html 增加手機找回密碼的方式
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
|
????????<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>1.</span>通過電子郵箱找回密碼????????????????<a?href="{U('reset_email')}">立即找回</a>????????????????</div>????????????????<div?class="reset_type">????????????????<span>2.</span>通過安全問題找回密碼????????????????<a?href="{U('reset_problem')}">立即找回</a>????????????????</div>??????????? ?????????????</div> |
好了,經過以上的替換,短信寶的短信平臺已經替換成功了,可以正常使用了。我們進行測試發送。
報備一下短信寶的VIP模板,這樣就可以走短信寶的優質通道了,即便遇到敏感文字我們都不會人工審核,短信內容3~5秒就可送達。
另外:我們已經開發好完整的YzmCMS_V6.9系統短信寶插件,點擊此鏈接?下載及查看安裝流程。
最新更新
電商類
CMS類
微信類