ask2问答系统是一款基于php+mysql进行开发的问答系统,它使用的是thinkphp框架进行开发,二次开发非常简单,今天小编就以新增短信接口为例,一步一步带着大家进行二次开发,我们使用的短信接口是我们短信宝短信群发平台的短信接口,我们短信宝短信平台非常稳定,发送速度快,注册就送测试短信,推荐大家使用。
下面我们进行开发,首先我们需要增加和修改后台短信配置,打开项目\application\view\admin\horize_menu.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
|
< style > .main-header .nav { padding-left: 0; margin-bottom: 0; list-style: none; margin-top:5px; display: inline-block; } .main-header .nav-secondary>li>a { border-bottom: none; } .main-header .nav-secondary>li.active>a, .main-header .nav-secondary>li.active>a:focus,.main-header .nav-secondary>li.active>a:hover { color: #000000; border-bottom:none; } </ style > < ul class = "nav nav-secondary" > <!--{template chajian,admin}--> < li > < a class = "dropdown-toggle" data-toggle = "dropdown" href = "###" >系统设置 < span class = "caret" ></ span ></ a > < ul class = "dropdown-menu" > < li >< a href = "{SITE_URL}index.php?admin_setting/base{$setting['seo_suffix']}" target = "main" >< i class = "fa fa-genderless text-success" ></ i >站点设置</ a ></ li > < li >< a href = "{SITE_URL}index.php?admin_sitelog{$setting['seo_suffix']}" target = "main" >< i class = "fa fa-genderless text-success" ></ i >站点日志查看</ a ></ li > < li >< a href = "{SITE_URL}index.php?admin_setting/time{$setting['seo_suffix']}" target = "main" >< i class = "fa fa-genderless text-success" ></ i >时间设置</ a > </ li > < li >< a href = "{SITE_URL}index.php?admin_setting/list{$setting['seo_suffix']}" target = "main" >< i class = "fa fa-genderless text-success" ></ i >首页设置</ a > </ li > < li >< a href = "{SITE_URL}index.php?admin_setting/search{$setting['seo_suffix']}" target = "main" >< i class = "fa fa-genderless text-success" ></ i >搜索管理</ a ></ li > < li >< a href = "{SITE_URL}index.php?admin_setting/register{$setting['seo_suffix']}" target = "main" >< i class = "fa fa-genderless text-success" ></ i >注册设置</ a ></ li > < li >< a href = "{SITE_URL}index.php?admin_nav{$setting['seo_suffix']}" target = "main" >< i class = "fa fa-genderless text-success" ></ i >导航管理</ a > </ li > < li >< a href = "{SITE_URL}index.php?admin_link{$setting['seo_suffix']}" target = "main" >< i class = "fa fa-genderless text-success" ></ i >友情链接</ a > </ li > </ ul > </ li > < li > < a class = "dropdown-toggle" data-toggle = "dropdown" href = "###" >高级管理 < span class = "caret" ></ span ></ a > < ul class = "dropdown-menu" > < li >< a href = "{SITE_URL}index.php?admin_setting/caiji{$setting['seo_suffix']}" target = "main" >< i class = "fa fa-genderless text-success" ></ i >数据采集设置</ a > </ li > < li >< a href = "{SITE_URL}index.php?admin_setting/mail{$setting['seo_suffix']}" target = "main" >< i class = "fa fa-genderless text-success" ></ i >邮件设置</ a > </ li > < li >< a href = "{SITE_URL}index.php?admin_setting/sms{$setting['seo_suffix']}" target = "main" >< i class = "fa fa-genderless text-success" ></ i >短信设置</ a > </ li > < li >< a href = "{SITE_URL}index.php?admin_setting/msgtpl{$setting['seo_suffix']}" target = "main" >< i class = "fa fa-genderless text-success" ></ i >消息模板</ a > </ li > < li >< a href = "{SITE_URL}index.php?admin_setting/credit{$setting['seo_suffix']}" target = "main" >< i class = "fa fa-genderless text-success" ></ i >积分设置</ a > </ li > < li >< a href = "{SITE_URL}index.php?admin_setting/seo{$setting['seo_suffix']}" target = "main" >< i class = "fa fa-genderless text-success" ></ i >seo设置</ a > </ li > < li >< a href = "{SITE_URL}index.php?admin_setting/stopcopy{$setting['seo_suffix']}" target = "main" >< i class = "fa fa-genderless text-success" ></ i >防采集设置</ a > </ li > < li >< a href = "{SITE_URL}index.php?admin_editor/setting{$setting['seo_suffix']}" target = "main" >< i class = "fa fa-genderless text-success" ></ i >编辑器设置</ a > </ li > < li >< a href = "{SITE_URL}index.php?admin_setting/qqlogin{$setting['seo_suffix']}" target = "main" >< i class = "fa fa-genderless text-success" ></ i >qq互联设置</ a > </ li > < li >< a href = "{SITE_URL}index.php?admin_setting/sinalogin{$setting['seo_suffix']}" target = "main" >< i class = "fa fa-genderless text-success" ></ i >sina互联设置</ a > </ li > </ ul > </ li > < li > < a class = "dropdown-toggle" data-toggle = "dropdown" href = "###" >内容管理 < span class = "caret" ></ span ></ a > < ul class = "dropdown-menu" > < li >< a href = "{SITE_URL}index.php?admin_question/examine{$setting['seo_suffix']}" target = "main" >< i class = "fa fa-genderless text-success" ></ i >问答审核</ a ></ li > < li >< a href = "{SITE_URL}index.php?admin_question{$setting['seo_suffix']}" target = "main" >< i class = "fa fa-genderless text-success" ></ i >问题管理</ a ></ li > < li >< a href = "{SITE_URL}index.php?admin_question/searchanswer{$setting['seo_suffix']}" target = "main" >< i class = "fa fa-genderless text-success" ></ i >回答管理</ a ></ li > < li >< a href = "{SITE_URL}index.php?admin_category{$setting['seo_suffix']}" target = "main" >< i class = "fa fa-genderless text-success" ></ i >分类管理</ a ></ li > < li >< a href = "{SITE_URL}index.php?admin_topic{$setting['seo_suffix']}" target = "main" >< i class = "fa fa-genderless text-success" ></ i >博客管理</ a ></ li > < li >< a href = "{SITE_URL}index.php?admin_tag{$setting['seo_suffix']}" target = "main" >< i class = "fa fa-genderless text-success" ></ i >标签管理</ a ></ li > < li >< a href = "{SITE_URL}index.php?admin_keywords{$setting['seo_suffix']}" target = "main" >< i class = "fa fa-genderless text-success" ></ i >关键词库</ a ></ li > < li >< a href = "{SITE_URL}index.php?admin_word{$setting['seo_suffix']}" target = "main" >< i class = "fa fa-genderless text-success" ></ i >词语过滤</ a ></ li > < li >< a href = "{SITE_URL}index.php?admin_inform{$setting['seo_suffix']}" target = "main" >< i class = "fa fa-genderless text-success" ></ i >举报管理</ a ></ li > < li >< a href = "{SITE_URL}index.php?admin_note{$setting['seo_suffix']}" target = "main" >< i class = "fa fa-genderless text-success" ></ i >公告管理</ a ></ li > < li >< a href = "{SITE_URL}index.php?admin_ad{$setting['seo_suffix']}" target = "main" >< i class = "fa fa-genderless text-success" ></ i >广告管理</ a ></ li > </ ul > </ li > < li > < a class = "dropdown-toggle" data-toggle = "dropdown" href = "###" >用户管理< span class = "caret" ></ span ></ a > < ul class = "dropdown-menu" > < li >< a href = "{SITE_URL}index.php?admin_user/add{$setting['seo_suffix']}" target = "main" >< i class = "fa fa-genderless text-success" ></ i >添加用户</ a > </ li > < li >< a href = "{SITE_URL}index.php?admin_user{$setting['seo_suffix']}" target = "main" >< i class = "fa fa-genderless text-success" ></ i >用户管理</ a > </ li > < li >< a href = "{SITE_URL}index.php?admin_banned/add{$setting['seo_suffix']}" target = "main" >< i class = "fa fa-genderless text-success" ></ i >禁止IP</ a > </ li > < li >< a href = "{SITE_URL}index.php?admin_expert{$setting['seo_suffix']}" target = "main" >< i class = "fa fa-genderless text-success" ></ i >专家管理</ a > </ li > < li >< a href = "{SITE_URL}index.php?admin_usergroup{$setting['seo_suffix']}" target = "main" >< i class = "fa fa-genderless text-success" ></ i >用户组</ a ></ li > < li >< a href = "{SITE_URL}index.php?admin_usergroup/system{$setting['seo_suffix']}" target = "main" >< i class = "fa fa-genderless text-success" ></ i >系统用户组</ a ></ li > </ ul > </ li > < li > < a class = "dropdown-toggle" data-toggle = "dropdown" href = "###" >模板管理 < span class = "caret" ></ span ></ a > < ul class = "dropdown-menu" > < li >< a href = "{SITE_URL}index.php?admin_template/default/pc{$setting['seo_suffix']}" target = "main" >< i class = "fa fa-genderless text-success" ></ i >PC模板</ a > </ li > < li >< a href = "{SITE_URL}index.php?admin_template/default/wap{$setting['seo_suffix']}" target = "main" >< i class = "fa fa-genderless text-success" ></ i >手机Wap模板</ a > </ li > </ ul > </ li > < li > < a class = "dropdown-toggle" data-toggle = "dropdown" href = "###" >系统工具 < span class = "caret" ></ span ></ a > < ul class = "dropdown-menu" > < li >< a href = "{SITE_URL}index.php?admin_setting/cache{$setting['seo_suffix']}" target = "main" >< i class = "fa fa-genderless text-success" ></ i >更新缓存</ a > </ li > < li >< a href = "{SITE_URL}index.php?admin_datacall/default{$setting['seo_suffix']}" target = "main" >< i class = "fa fa-genderless text-success" ></ i >js数据调用</ a > </ li > < li >< a href = "{SITE_URL}index.php?admin_main/regulate{$setting['seo_suffix']}" target = "main" >< i class = "fa fa-genderless text-success" ></ i >数据校正</ a > </ li > < li >< a href = "{SITE_URL}index.php?admin_db/backup{$setting['seo_suffix']}" target = "main" >< i class = "fa fa-genderless text-success" ></ i >数据库备份</ a > </ li > < li >< a href = "{SITE_URL}index.php?admin_db/tablelist{$setting['seo_suffix']}" target = "main" >< i class = "fa fa-genderless text-success" ></ i >数据库优化</ a > </ li > < li >< a href = "{SITE_URL}index.php?admin_setting/ucenter{$setting['seo_suffix']}" target = "main" >< i class = "fa fa-genderless text-success" ></ i >UCenter</ a > </ li > < li >< a href = "{SITE_URL}index.php?admin_cms/setting{$setting['seo_suffix']}" target = "main" >< i class = "fa fa-genderless text-success" ></ i >CMS系统</ a > </ li > </ ul > </ li > < li > < a class = "dropdown-toggle" data-toggle = "dropdown" href = "###" >常用菜单 < span class = "caret" ></ span ></ a > < ul class = "dropdown-menu" > < li >< a href = "{SITE_URL}" target = "_blank" >< i class = "fa fa-genderless text-success" ></ i > < span >网站首页</ span ></ a ></ li > < li >< a href = "{SITE_URL}?update" target = "main" >< i class = "fa fa-genderless text-yellow" ></ i > < span >更新数据表</ span ></ a > </ li > < li >< a href = "{SITE_URL}index.php?admin_setting/cache{$setting['seo_suffix']}" target = "main" >< i class = "fa fa-genderless text-yellow" ></ i > < span >更新缓存</ span ></ a > </ li > < li >< a href = "http://www.ask2.cn" target = "_blank" >< i class = "fa fa-genderless text-yellow" ></ i > < span >官方求助</ span ></ a ></ li > </ ul > </ li > < li > < a class = "dropdown-toggle" data-toggle = "dropdown" href = "###" >名站统计 < span class = "caret" ></ span ></ a > < ul class = "dropdown-menu" > < li >< a href = "https://tongji.baidu.com/web/welcome/login" target = "main" >< i class = "fa fa-genderless text-success" ></ i > < span >百度统计</ span ></ a ></ li > < li >< a href = "https://i.umeng.com/?" target = "main" >< i class = "fa fa-genderless text-yellow" ></ i > < span >CNZZ统计</ span ></ a > </ li > < li >< a href = "http://zhanzhang.baidu.com/" target = "_blank" >< i class = "fa fa-genderless text-yellow" ></ i > < span >百度站长平台</ span ></ a ></ li > < li >< a href = "http://zhanzhang.so.com/" target = "_blank" >< i class = "fa fa-genderless text-yellow" ></ i > < span >360站长平台</ span ></ a ></ li > </ ul > </ li > </ ul > |
接下来打开项目\application\view\admin\public_menu.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
|
{eval $regular=$this->regular;} < ul class = "sidebar-menu" id = "root_menu" > < li class = "header" >管理菜单</ li > < li >< a href = "{SITE_URL}index.php?admin_main/stat{$setting['seo_suffix']}" >< i class = "fa fa-dashboard" ></ i > < span >首页</ span > </ a ></ li > < li class = "treeview" > < a href = "#" > < i class = "fa fa-certificate" ></ i > < span >系统设置</ span > < i class = "fa fa-angle-left pull-right" ></ i > </ a > < ul class = "treeview-menu" id = "manage_user" > < li >< a href = "{SITE_URL}index.php?admin_setting/base{$setting['seo_suffix']}" target = "main" >< i class = "fa fa-genderless text-success" ></ i >站点设置</ a ></ li > < li >< a href = "{SITE_URL}index.php?admin_totalset/index{$setting['seo_suffix']}" target = "main" >< i class = "fa fa-genderless text-success" ></ i >全局设置</ a ></ li > < li >< a href = "{SITE_URL}index.php?admin_sitelog{$setting['seo_suffix']}" target = "main" >< i class = "fa fa-genderless text-success" ></ i >站点日志查看</ a ></ li > < li >< a href = "{SITE_URL}index.php?admin_setting/time{$setting['seo_suffix']}" target = "main" >< i class = "fa fa-genderless text-success" ></ i >时间设置</ a > </ li > < li >< a href = "{SITE_URL}index.php?admin_setting/list{$setting['seo_suffix']}" target = "main" >< i class = "fa fa-genderless text-success" ></ i >首页设置</ a > </ li > < li >< a href = "{SITE_URL}index.php?admin_setting/search{$setting['seo_suffix']}" target = "main" >< i class = "fa fa-genderless text-success" ></ i >搜索管理</ a ></ li > < li >< a href = "{SITE_URL}index.php?admin_setting/register{$setting['seo_suffix']}" target = "main" >< i class = "fa fa-genderless text-success" ></ i >注册设置</ a ></ li > < li >< a href = "{SITE_URL}index.php?admin_nav{$setting['seo_suffix']}" target = "main" >< i class = "fa fa-genderless text-success" ></ i >导航管理</ a > </ li > < li >< a href = "{SITE_URL}index.php?admin_link{$setting['seo_suffix']}" target = "main" >< i class = "fa fa-genderless text-success" ></ i >友情链接</ a > </ li > </ ul > </ li > < li class = "treeview" > < a href = "#" > < i class = "fa fa-cutlery" ></ i > < span >高级管理</ span > < i class = "fa fa-angle-left pull-right" ></ i > </ a > < ul class = "treeview-menu" id = "operations" > < li >< a href = "{SITE_URL}index.php?admin_setting/caiji{$setting['seo_suffix']}" target = "main" >< i class = "fa fa-genderless text-success" ></ i >数据采集设置</ a > </ li > < li >< a href = "{SITE_URL}index.php?admin_setting/mail{$setting['seo_suffix']}" target = "main" >< i class = "fa fa-genderless text-success" ></ i >邮件设置</ a > </ li > < li >< a href = "{SITE_URL}index.php?admin_setting/sms{$setting['seo_suffix']}" target = "main" >< i class = "fa fa-genderless text-success" ></ i >短信设置</ a > </ li > < li >< a href = "{SITE_URL}index.php?admin_setting/msgtpl{$setting['seo_suffix']}" target = "main" >< i class = "fa fa-genderless text-success" ></ i >消息模板</ a > </ li > < li >< a href = "{SITE_URL}index.php?admin_setting/credit{$setting['seo_suffix']}" target = "main" >< i class = "fa fa-genderless text-success" ></ i >积分设置</ a > </ li > < li >< a href = "{SITE_URL}index.php?admin_setting/seo{$setting['seo_suffix']}" target = "main" >< i class = "fa fa-genderless text-success" ></ i >seo设置</ a > </ li > < li >< a href = "{SITE_URL}index.php?admin_setting/stopcopy{$setting['seo_suffix']}" target = "main" >< i class = "fa fa-genderless text-success" ></ i >防采集设置</ a > </ li > < li >< a href = "{SITE_URL}index.php?admin_editor/setting{$setting['seo_suffix']}" target = "main" >< i class = "fa fa-genderless text-success" ></ i >编辑器设置</ a > </ li > < li >< a href = "{SITE_URL}index.php?admin_setting/qqlogin{$setting['seo_suffix']}" target = "main" >< i class = "fa fa-genderless text-success" ></ i >qq互联设置</ a > </ li > < li >< a href = "{SITE_URL}index.php?admin_setting/sinalogin{$setting['seo_suffix']}" target = "main" >< i class = "fa fa-genderless text-success" ></ i >sina互联设置</ a > </ li > </ ul > </ li > < li class = "treeview" > < a href = "#" > < i class = "fa fa-comments-o" ></ i > < span >内容管理</ span > < i class = "fa fa-angle-left pull-right" ></ i > </ a > < ul class = "treeview-menu" id = "manage_content" > < li >< a href = "{SITE_URL}index.php?admin_question/examine{$setting['seo_suffix']}" target = "main" >< i class = "fa fa-genderless text-success" ></ i >问答审核</ a ></ li > < li >< a href = "{SITE_URL}index.php?admin_question{$setting['seo_suffix']}" target = "main" >< i class = "fa fa-genderless text-success" ></ i >问题管理</ a ></ li > < li >< a href = "{SITE_URL}index.php?admin_question/searchanswer{$setting['seo_suffix']}" target = "main" >< i class = "fa fa-genderless text-success" ></ i >回答管理</ a ></ li > < li >< a href = "{SITE_URL}index.php?admin_category{$setting['seo_suffix']}" target = "main" >< i class = "fa fa-genderless text-success" ></ i >分类管理</ a ></ li > < li >< a href = "{SITE_URL}index.php?admin_topic{$setting['seo_suffix']}" target = "main" >< i class = "fa fa-genderless text-success" ></ i >博客管理</ a ></ li > < li >< a href = "{SITE_URL}index.php?admin_tag{$setting['seo_suffix']}" target = "main" >< i class = "fa fa-genderless text-success" ></ i >标签管理</ a ></ li > < li >< a href = "{SITE_URL}index.php?admin_keywords{$setting['seo_suffix']}" target = "main" >< i class = "fa fa-genderless text-success" ></ i >关键词库</ a ></ li > < li >< a href = "{SITE_URL}index.php?admin_word{$setting['seo_suffix']}" target = "main" >< i class = "fa fa-genderless text-success" ></ i >词语过滤</ a ></ li > < li >< a href = "{SITE_URL}index.php?admin_inform{$setting['seo_suffix']}" target = "main" >< i class = "fa fa-genderless text-success" ></ i >举报管理</ a ></ li > < li >< a href = "{SITE_URL}index.php?admin_note{$setting['seo_suffix']}" target = "main" >< i class = "fa fa-genderless text-success" ></ i >公告管理</ a ></ li > < li >< a href = "{SITE_URL}index.php?admin_ad{$setting['seo_suffix']}" target = "main" >< i class = "fa fa-genderless text-success" ></ i >广告管理</ a ></ li > </ ul > </ li > < li class = "treeview" > < a href = "#" > < i class = "fa fa-user" ></ i > < span >用户管理</ span > < i class = "fa fa-angle-left pull-right" ></ i > </ a > < ul class = "treeview-menu" id = "manage_user" > < li >< a href = "{SITE_URL}index.php?admin_user/add{$setting['seo_suffix']}" target = "main" >< i class = "fa fa-genderless text-success" ></ i >添加用户</ a > </ li > < li >< a href = "{SITE_URL}index.php?admin_user{$setting['seo_suffix']}" target = "main" >< i class = "fa fa-genderless text-success" ></ i >用户管理</ a > </ li > < li >< a href = "{SITE_URL}index.php?admin_banned/add{$setting['seo_suffix']}" target = "main" >< i class = "fa fa-genderless text-success" ></ i >禁止IP</ a > </ li > < li >< a href = "{SITE_URL}index.php?admin_expert{$setting['seo_suffix']}" target = "main" >< i class = "fa fa-genderless text-success" ></ i >专家管理</ a > </ li > < li >< a href = "{SITE_URL}index.php?admin_usergroup{$setting['seo_suffix']}" target = "main" >< i class = "fa fa-genderless text-success" ></ i >用户组</ a ></ li > < li >< a href = "{SITE_URL}index.php?admin_usergroup/system{$setting['seo_suffix']}" target = "main" >< i class = "fa fa-genderless text-success" ></ i >系统用户组</ a ></ li > </ ul > </ li > < li class = "treeview" > < a href = "#" > < i class = "fa fa-archive" ></ i > < span >模板管理</ span > < i class = "fa fa-angle-left pull-right" ></ i > </ a > < ul class = "treeview-menu" id = "operations" > < li >< a href = "{SITE_URL}index.php?admin_template/default/pc{$setting['seo_suffix']}" target = "main" >< i class = "fa fa-genderless text-success" ></ i >PC模板</ a > </ li > < li >< a href = "{SITE_URL}index.php?admin_template/default/wap{$setting['seo_suffix']}" target = "main" >< i class = "fa fa-genderless text-success" ></ i >手机Wap模板</ a > </ li > </ ul > </ li > < li class = "treeview" > < a href = "#" > < i class = "fa fa-recycle" ></ i > < span >系统工具</ span > < i class = "fa fa-angle-left pull-right" ></ i > </ a > < ul class = "treeview-menu" id = "third_part" > < li >< a href = "{SITE_URL}index.php?admin_setting/cache{$setting['seo_suffix']}" target = "main" >< i class = "fa fa-genderless text-success" ></ i >更新缓存</ a > </ li > < li >< a href = "{SITE_URL}index.php?admin_datacall/default{$setting['seo_suffix']}" target = "main" >< i class = "fa fa-genderless text-success" ></ i >js数据调用</ a > </ li > < li >< a href = "{SITE_URL}index.php?admin_main/regulate{$setting['seo_suffix']}" target = "main" >< i class = "fa fa-genderless text-success" ></ i >数据校正</ a > </ li > < li >< a href = "{SITE_URL}index.php?admin_db/backup{$setting['seo_suffix']}" target = "main" >< i class = "fa fa-genderless text-success" ></ i >数据库备份</ a > </ li > < li >< a href = "{SITE_URL}index.php?admin_db/tablelist{$setting['seo_suffix']}" target = "main" >< i class = "fa fa-genderless text-success" ></ i >数据库优化</ a > </ li > < li >< a href = "{SITE_URL}index.php?admin_setting/ucenter{$setting['seo_suffix']}" target = "main" >< i class = "fa fa-genderless text-success" ></ i >UCenter</ a > </ li > < li >< a href = "{SITE_URL}index.php?admin_cms/setting{$setting['seo_suffix']}" target = "main" >< i class = "fa fa-genderless text-success" ></ i >CMS系统</ a > </ li > </ ul > </ li > < li class = "treeview" > < a href = "#" > < i class = "fa fa-shopping-cart" ></ i > < span >礼品商店</ span > < i class = "fa fa-angle-left pull-right" ></ i > </ a > < ul class = "treeview-menu" id = "operations" > < li >< a href = "{SITE_URL}index.php?admin_gift{$setting['seo_suffix']}" target = "main" >< i class = "fa fa-genderless text-success" ></ i >礼品列表</ a ></ li > < li >< a href = "{SITE_URL}index.php?admin_gift/add{$setting['seo_suffix']}" target = "main" >< i class = "fa fa-genderless text-success" ></ i >添加礼品</ a ></ li > < li >< a href = "{SITE_URL}index.php?admin_gift/note{$setting['seo_suffix']}" target = "main" >< i class = "fa fa-genderless text-success" ></ i >礼品公告</ a ></ li > < li >< a href = "{SITE_URL}index.php?admin_gift/addrange{$setting['seo_suffix']}" target = "main" >< i class = "fa fa-genderless text-success" ></ i >礼品价格区间</ a ></ li > < li >< a href = "{SITE_URL}index.php?admin_gift/log{$setting['seo_suffix']}" target = "main" >< i class = "fa fa-genderless text-success" ></ i >礼品兑换日志</ a ></ li > </ ul > </ li > < li class = "header" >常用菜单</ li > < li >< a href = "{SITE_URL}" target = "_blank" >< i class = "fa fa-genderless text-success" ></ i > < span >网站首页</ span ></ a ></ li > < li >< a href = "{SITE_URL}?update" target = "main" >< i class = "fa fa-genderless text-yellow" ></ i > < span >更新数据表</ span ></ a > </ li > < li >< a href = "{SITE_URL}index.php?admin_setting/cache{$setting['seo_suffix']}" target = "main" >< i class = "fa fa-genderless text-yellow" ></ i > < span >更新缓存</ span ></ a > </ li > < li >< a href = "http://www.ask2.cn" target = "_blank" >< i class = "fa fa-genderless text-yellow" ></ i > < span >官方求助</ span ></ a ></ li > </ ul > < script > var url='{$regular}'; if(url.indexOf('default')>=0){ var tmp_urls=url.split('/'); url=tmp_urls[0]+".html"; } $(".treeview-menu li").each(function(){ var tmp_a=$(this).find("a").attr("href"); if(tmp_a.indexOf(url)>=0){ console.log(tmp_a); $(this).addClass("current"); $(this).find("a").css("color","#ffffff"); $(this).parent().parent().addClass("active"); } }); </ script > |
接下来打开项目\application\view\admin\setting_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
|
<!--{template header,admin}--> < div style = "width:100%; height:15px;color:#000;margin:0px 0px 10px;" > < div style = "float:left;" >< a href = "index.php?admin_main/stat{$setting['seo_suffix']}" target = "main" >< b >控制面板首页</ b ></ a > » 注册设置</ div > </ div > <!--{if isset($message)}--> <!--{eval $type=isset($type)?$type:'correctmsg'; }--> < table class = "table" > < tr > < td class = "{$type}" >{$message}</ td > </ tr > </ table > <!--{/if}--> < table class = "table" > < tbody >< tr class = "header" >< td >设置说明</ td ></ tr > < tr class = "altbg1" >< td >允许/禁止的 Email 地址只需填写 Email 的域名部分,每行一个域名,例如 @hotmail.com</ td ></ tr > </ tbody ></ table > < br /> < form action = "index.php?admin_setting/register{$setting['seo_suffix']}" method = "post" > < a name = "基本设置" ></ a > < table class = "table" > < tr class = "header" > < td colspan = "2" >参数设置</ td > </ tr > < tr > < td class = "altbg1" width = "45%" >< b >允许新用户注册:</ b >< br >< span class = "smalltxt" >若不需要新用户注册,可以到用户管理里面手动添加用户</ span ></ td > < td class = "altbg2" > < input class = "radio inline" type = "radio" {if 1==$setting['allow_register'] }checked{/if} value = "1" name = "allow_register" >< label for = "yes" >是</ label > < input class = "radio inline" type = "radio" {if 0==$setting['allow_register'] }checked{/if} value = "0" name = "allow_register" >< label for = "no" >否</ label ></ td > </ tr > < tr > < td class = "altbg1" width = "45%" >< b >注册用户必须邮箱验证:</ b >< br >< span class = "smalltxt" >开启后没有邮箱验证的用户除了管理员外都不能进行一切操作</ span ></ td > < td class = "altbg2" > < input class = "radio inline" type = "radio" {if 1==$setting['register_on'] }checked{/if} value = "1" name = "register_on" >< label for = "yes" >是</ label > < input class = "radio inline" type = "radio" {if 0==$setting['register_on'] }checked{/if} value = "0" name = "register_on" >< label for = "no" >否</ label ></ td > </ tr > < tr > < td class = "altbg1" width = "45%" >< b >开启手机注册:</ b >< br >< span class = "smalltxt" ></ span ></ td > < td class = "altbg2" > < input class = "radio inline" type = "radio" {if 1==$setting['mobile_on'] }checked{/if} value = "1" name = "mobile_on" >< label for = "yes" >是</ label > < input class = "radio inline" type = "radio" {if 0==$setting['mobile_on'] }checked{/if} value = "0" name = "mobile_on" >< label for = "no" >否</ label ></ td > </ tr > < tr > < td class = "altbg1" width = "45%" >< b >24小时内同一IP的最大注册用户数目:</ b >< br >< span class = "smalltxt" >限制ip灌水注册</ span ></ td > < td class = "altbg2" >< input class = "form-control shortinput" name = "max_register_num" type = "text" value = "{$setting['max_register_num']}" /></ td > </ tr > < tr > < td class = "altbg1" width = "45%" >< b >允许的 Email 地址:</ b >< br >< span class = "smalltxt" >只允许使用这些域名结尾的 Email 地址注册</ span ></ td > < td class = "altbg2" >< textarea row = "5" class = " form-control shortinput" name = "access_email" >{$setting['access_email']}</ textarea ></ td > </ tr > < tr > < td class = "altbg1" width = "45%" >< b >禁止的用户名:</ b >< br >< span class = "smalltxt" >可以设置通配符,每个关键字一行,可使用通配符 "*" 如 "*版主*"(不含引号)</ span ></ td > < td class = "altbg2" >< textarea row = "5" class = " form-control shortinput" name = "censor_username" >{$setting['censor_username']}</ textarea ></ td > </ tr > </ table > < br > < center >< input type = "submit" class = "btn btn-info" name = "submit" value = "提 交" ></ center >< br > </ form > < br > <!--{template footer,admin}--> |
打开项目\application\view\admin,新建一个文件setting_sms.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
|
<!--{template header,admin}--> < div style = "width:100%; height:15px;color:#000;margin:0px 0px 10px;" > < div style = "float:left;" >< a href = "index.php?admin_main/stat{$setting['seo_suffix']}" target = "main" >< b >控制面板首页</ b ></ a > » 短信设置</ div > </ div > <!--{if isset($message)}--> <!--{eval $type=isset($type)?$type:'correctmsg'; }--> < div class = "alert alert-warning" >{$message}</ div > <!--{/if}--> < form action = "index.php?admin_setting/sms{$setting['seo_suffix']}" method = "post" > < table class = "table" > < tr class = "header" > < td colspan = "2" >参数设置</ td > </ tr > < tr > < td class = "altbg1" width = "45%" >< b >短信宝用户名:</ b >< br >< span class = "smalltxt" >还没有短信宝帐号?请点击< a href = "http://www.smsbao.com/reg" >注册</ a ></ span ></ td > < td class = "altbg2" >< input class = "form-control shortinput" type = "text" value = "{$setting['smsbao_user']}" name = "smsbao_user" /></ td > </ tr > < tbody > < tr > < td class = "altbg1" width = "45%" >< b >短信宝密码:</ b >< br >< span class = "smalltxt" >填写短信宝密码</ span ></ td > < td class = "altbg2" >< input class = "form-control shortinput" type = "text" value = "{$setting['smsbao_pass']}" name = "smsbao_pass" /></ td > </ tr > < tr > < td class = "altbg1" width = "45%" >< b >短信签名:</ b >< br >< span class = "smalltxt" >填写短信签名 3-8个字符</ span ></ td > < td class = "altbg2" >< input class = "form-control shortinput" value = "{$setting['smsbao_sign']}" name = "smsbao_sign" ></ td > </ tr > </ tbody > </ table > < br /> < center >< input type = "submit" class = "btn btn-success" name = "submit" value = "提 交" ></ center >< br > </ form > < br /> < hr > < h4 >测试短信发送</ h4 > < form class = "form-horizontal" role = "form" method = "post" action = "index.php?admin_setting/testsms{$setting['seo_suffix']}" > < div class = "form-group" > < label class = "col-md-2 control-label" >手机号</ label > < div class = "col-md-4" > < input type = "text" name = "mobile" id = "tousername" value = "" placeholder = "手机号码" class = "form-control" > </ div > </ div > < div class = "form-group" > < label class = "col-md-2 control-label" >短信内容</ label > < div class = "col-md-4" > < textarea name = "content" id = "message" rows = "2" placeholder = "" class = "form-control" ></ textarea > </ div > </ div > < div class = "form-group" > < div class = "col-md-offset-2 col-md-10" > < input type = "submit" name = "submit" id = "submit" class = "btn btn-danger" value = "保存" data-loading = "稍候..." > < input type = "hidden" name = "type" id = "type" value = "article" > </ div > </ div > </ form > < style > html,body{ overflow:scroll; } </ style > <!--{template footer,admin}--> |
接下来修改配置短信文件,打开项目\application\control\admin\setting.php文件,新增两个方法,onsms、ontestsms,代码为:
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
|
/* 短信设置 */ function onsms() { if (isset( $this ->post[ 'submit' ])) { $this ->setting[ 'smsbao_user' ] = $this ->post[ 'smsbao_user' ]; $this ->setting[ 'smsbao_pass' ] = $this ->post[ 'smsbao_pass' ]; $this ->setting[ 'smsbao_sign' ] = $this ->post[ 'smsbao_sign' ]; $_ENV [ 'setting' ]->update( $this ->setting); $message = '短信设置更新成功!' ; } include template( 'setting_sms' , 'admin' ); } /* 测试发送短信 */ function ontestsms(){ if (isset( $this ->post[ 'submit' ])) { if (! empty ( $this ->setting[ 'smsbao_user' ]) && ! empty ( $this ->setting[ 'smsbao_pass' ]) && ! empty ( $this ->setting[ 'smsbao_sign' ])) { if (isset( $this ->post[ 'mobile' ]) && isset( $this ->post[ 'content' ])) { $mobile = $this ->post[ 'mobile' ]; $content = $this ->post[ 'content' ]; $state = sendsmsto( $mobile , $content ); if ( $state == 0) { $message = '短信发送成功!' ; } else { $message = $state ; } } } else { $message = '请填写短信宝相关配置后在进行测试~' ; } } include template( 'setting_sms' , 'admin' ); } |
接下来我们去修改前台注册界面,打开项目\application\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
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
|
<!--{template meta}--> < link rel = "stylesheet" media = "all" href = "{SITE_URL}static/css/bianping/css/login.css" /> < body class = "no-padding reader-black-font" > < div class = "sign" > < div class = "logo" >< a href = "/" >< img src = "{$setting['site_logo']}" alt = "Logo" ></ a ></ div > < div class = "main" > < h4 class = "title" > < div class = "normal-title" > < a class = "" href = "{url user/login}" >登录</ a > < b >·</ b > < a id = "js-sign-up-btn" class = "active" href = "{url user/register}" >注册</ a > </ div > </ h4 > < div class = "js-sign-up-container" > < form class = "new_user" method = "post" > < input type = "hidden" name = "usersid" value = '{$_SESSION["userid"]}' /> < input type = "hidden" id = "apikey" name = "apikey" value = '{$_SESSION["apikey"]}' /> < div class = "input-prepend " > < input placeholder = "你的昵称" type = "text" value = "" id = "username" name = "user_name" > < i class = "fa fa-user" ></ i > </ div > < div class = "input-prepend " > < input placeholder = "你的邮箱" type = "text" value = "" id = "email" name = "email" > < i class = "fa fa-envelope" ></ i > </ div > {if $setting['mobile_on'] == 1} < div class = "input-prepend " > < input placeholder = "你的手机号" type = "text" value = "" id = "mobile" name = "mobile" > < i class = "fa fa-envelope" ></ i > </ div > < div class = "input-prepend" > < b class = "button" style = "display:inline;position:absolute;top:10px;right:10px;cursor:pointer;font-size:16px;" id = "btno" >获取验证码</ b > < input type = "text" name = "mobile_code" value = "" id = "mobile_code" placeholder = "短信验证码" > </ div > {/if} < div class = "input-prepend no-radius js-normal " > < img src = "{url user/code}" onclick = "javascript:updatecode();" id = "verifycode" > < input type = "text" class = "form-control" id = "seccode_verify" name = "seccode_verify" placeholder = "验证码" > < i class = "fa fa fa-get-pocket" ></ i > </ div > < div class = "input-prepend " > < input placeholder = "设置密码" type = "password" id = "password" name = "password" autocomplete = "off" maxlength = "20" > < i class = "fa fa-lock" ></ i > </ div > < div class = "input-prepend" > < input placeholder = "确认密码" type = "password" id = "repassword" name = "repassword" autocomplete = "off" maxlength = "20" > < i class = "fa fa-lock" ></ i > </ div > < input type = "button" id = "regsubmit" onclick = "cheklogin()" value = "注册" class = "sign-up-button" > < p class = "sign-up-msg" >点击 “注册” 即表示您同意并愿意遵守协议< br > < a target = "_blank" href = "#" >用户协议</ a > 和 < a target = "_blank" href = "#" >隐私政策</ a > 。</ p > </ form > <!--{template openlogin}--> </ div > </ div > </ div > < script type = "text/javascript" > var time = 0; var res = null; function sendTime(){ clearTimeout(res); // 先清空一下倒计时资源。 time--; // 倒计时时间递减。 // 如果倒计时到达0时,则恢复按钮原来的内容 if (time <= 0) { time = "获取验证码"; $('#btno').text(time); clearTimeout(res); time = 0; return; } // 倒计时的内容写到按钮里面 $('#btno').text("剩余" + time + "秒"); res = setTimeout("sendTime()", 1000); } $(function(){ var flg = true; $('#btno').on('click',function(){ var mobile = $("#mobile").val(); var code = $("#seccode_verify").val(); var reg = /^1[3,4,5,7,8]\d{9}$/; var ret = false; if (code == '') {alert('请填写验证码'); return ret;} if (!reg.test(mobile)) {alert('手机号码不正确');return ret;} if (0 == time) { var _data = {"code" : code, "mobile" : mobile}; if (flg == true) { flg = false; // ajax提交请求 $.ajax({ //提交数据的类型 POST GET type:"POST", //提交的网址 url:"{SITE_URL}?api_user/mobilesms", //提交的数据 data:_data, //返回数据的格式 datatype: "text",//"xml", "html", "script", "json", "jsonp", "text". beforeSend: function () { ajaxloading("提交中..."); }, //成功返回之后调用的函数 success:function(data){ if (data == 'ok') { time = 60; sendTime(); alert('短信发送成功'); }else{ alert(data); } } , complete: function () { removeajaxloading(); }, //调用出错执行的函数 error: function(){ //请求出错处理 } }); } $('.codeimg').click(); return ret; } }) }) </ script > < script type = "text/javascript" > var usernameok = 1; var password = 1; var repasswdok = 1; var emailok = 1; var codeok = 1; function listerphone(){ var _phone=$("#userphone").val(); if(_phone.length>0){ $(".js-security-number").removeClass("hide"); }else{ $(".js-security-number").addClass("hide"); } } function cheklogin(){ var _uname=$("#username").val(); var _upwd=$("#password").val(); var _rupwd=$("#repassword").val(); var _code=$("#seccode_verify").val(); var _email=$("#email").val(); var _mobile = $('#mobile').val(); var _mobile_code = $('#mobile_code').val(); var _apikey=$("#apikey").val(); var _data={uname:_uname,upwd:_upwd,rupwd:_rupwd,email:_email,apikey:_apikey,seccode_verify:_code,mobile:_mobile,mobile_code:_mobile_code}; $.ajax({ //提交数据的类型 POST GET type:"POST", //提交的网址 url:"{SITE_URL}?api_user/registerapi", //提交的数据 data:_data, //返回数据的格式 datatype: "text",//"xml", "html", "script", "json", "jsonp", "text". beforeSend: function () { ajaxloading("提交中..."); }, //成功返回之后调用的函数 success:function(data){ data=$.trim(data); if(data=='reguser_ok'){ window.location.href="{SITE_URL}?user/default"; }else if(data=='reguser_ok1'){ alert("注册成功,系统已发送注册邮件,24小时之内请进行邮箱验证,在您没激活邮件之前你不能发布问题和文章等操作!"); window.location.href="{SITE_URL}?user/default"; }else{ switch(data){ case 'reguser_cant_null': alert("用户名或者密码不能为空"); break; case 'regemail_Illegal': alert("注册邮箱不合法"); break; case 'regemail_has_exits': alert("邮箱已注册"); break; case 'regemail_cant_use': alert("此邮箱不能注册使用"); break; case 'reguser_has_exits': alert("注册用户名已经存在"); break; case 'Illegal': alert("用户名或者密码包含特殊字符"); break; default: alert(data); break; } } } , complete: function () { removeajaxloading(); }, //调用出错执行的函数 error: function(){ //请求出错处理 } }); } </ script > <!--{template footer}--> |
接下来去修改注册验证文件,打开项目\application\control\api\user.php文件,修改onregisterapi方法和新增onmobilesms,代码为:
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
|
function onregisterapi(){ // $this->check_apikey();//判断是否为正确的http请求 if (trim( $this ->post[ 'seccode_verify' ])== '' ){ exit ( '验证码不能为空' ); } if ( strtolower (trim( $this ->post[ 'seccode_verify' ])) != $_ENV [ 'user' ]->get_code()) { exit ( '验证码错误' ); } if (isset( $this ->setting[ 'mobile_on' ])&& $this ->setting[ 'mobile_on' ]== '1' ) { if ( strtolower (trim( $this ->post[ 'mobile_code' ])) != $_COOKIE [ 'smscode' ]) { exit ( '短信验证码错误' ); } if (trim( $this ->post[ 'mobile' ]) == '' ) { exit ( '手机号不能为空' ); } $phone = $this ->post[ 'mobile' ]; } if (! $this ->setting[ 'allow_register' ]) { exit ( "系统注册功能暂时处于关闭状态!" ); } if (isset( $this ->setting[ 'max_register_num' ]) && $this ->setting[ 'max_register_num' ] && ! $_ENV [ 'user' ]->is_allowed_register()) { exit ( "您的当前的IP已经超过当日最大注册数目,如有疑问请联系管理员!" ); } $username = strip_tags (trim( $this ->post[ 'uname' ])); //用户注册名字,strip_tags第一层过滤 $password = trim( $this ->post[ 'upwd' ]); //用户注册密码 $repassword = trim( $this ->post[ 'rupwd' ]); //用户注册密码 $this ->checkdeepstring( $username ); $usernamecensor = $_ENV [ 'user' ]->check_usernamecensor( $username ); if (FALSE == $usernamecensor ) exit ( '用户包含敏感词' ); $this ->checkstring( $password ); $this ->checkstring( $repassword ); $email = $this ->post[ 'email' ]; //用户邮箱 $emailaccess = $_ENV [ 'user' ]->check_emailaccess( $email ); if (FALSE == $emailaccess ){ exit ( "邮件地址被禁止注册" ); } $groupid =7; //角色ID if ( $repassword != $password ){ exit ( "两次输入密码不一样" ); //用户密码不能为空 } if ( '' == $username || '' == $password ) { exit ( "reguser_cant_null" ); //用户密码不能为空 } else if (!preg_match( "/^[a-z'0-9]+([._-][a-z'0-9]+)*@([a-z0-9]+([._-][a-z0-9]+))+$/" , $email )) { exit ( "regemail_Illegal" ); //注册邮箱不合法 } else if ( $this ->db->fetch_total( 'user' , " email='$email' " )) { exit ( "regemail_has_exits" ); //注册邮箱已经存在 } else if (! $_ENV [ 'user' ]->check_usernamecensor( $username )) { exit ( "regemail_cant_use" ); //注册邮箱不能使用 } $user = $_ENV [ 'user' ]->get_by_username( $username ); $user && exit ( "reguser_has_exits" ); //注册用户已经存在 //ucenter注册。 if ( $this ->setting[ "ucenter_open" ]) { $this ->load( 'ucenter' ); $msg = $_ENV [ 'ucenter' ]->ajaxregister( $username , $password , $email ); if ( $msg == 'ok' ){ // $uid = $_ENV['user']->adduserapi($username, $password, $email,$groupid);//插入model/user.class.php里adduserapi函数里 $user = $_ENV [ 'user' ]->get_by_username( $username ); $uid = $user [ 'uid' ]; $_ENV [ 'user' ]->refresh( $uid ); $sitename = $this ->setting[ 'site_name' ]; $this ->load( "doing" ); $_ENV [ 'doing' ]->add( $uid , $username , 12, $uid , "欢迎您注册了$sitename" ); $this ->credit( $uid , $this ->setting[ 'credit1_register' ], $this ->setting[ 'credit2_register' ]); //注册增加积分 if (isset( $this ->setting[ 'register_on' ])&& $this ->setting[ 'register_on' ]== '1' ){ $activecode =md5(rand(10000,50000)); $url =SITE_URL. 'index.php?user/checkemail/' . $this ->user[ 'uid' ]. '/' . $activecode ; $message = "这是一封来自$sitename邮箱验证,<a target='_blank' href='$url'>请点击此处验证邮箱邮箱账号</a>" ; $v =md5( "yanzhengask2email" ); $v1 =md5( "yanzhengask2time" ); setcookie( "emailsend" ); setcookie( "useremailcheck" ); $expire1 = time() + 60; // 设置1分钟的有效期 setcookie ( "emailsend" , $v1 , $expire1 ); // 设置一个名字为var_name的cookie,并制定了有效期 $expire = time() + 86400; // 设置24小时的有效期 setcookie ( "useremailcheck" , $v , $expire ); // 设置一个名字为var_name的cookie,并制定了有效期 $_ENV [ 'user' ]->update_emailandactive( $email , $activecode , $this ->user[ 'uid' ]); $_ENV [ 'user' ]->refresh( $this ->user[ 'uid' ],1); sendmailto( $email , "邮箱验证提醒-$sitename" , $message , $this ->user[ 'username' ]); } //$this->credit($this->user['uid'], $this->setting['credit1_register'], $this->setting['credit2_register']); //注册增加积分 if (isset( $this ->setting[ 'register_on' ])&& $this ->setting[ 'register_on' ]== '1' ){ exit ( "reguser_ok1" ); // exit("注册成功,系统已发送注册邮件,24小时之内请进行邮箱验证,在您没激活邮件之前你不能发布问题和文章等操作!");//注册成功 } else { exit ( "reguser_ok" ); } } else { exit ( $msg ); } } $uid =0; $uid = $_ENV [ 'user' ]->adduserapi( $username , $password , $email , $groupid , '' , $phone ); $_ENV [ 'user' ]->refresh( $uid ); $sitename = $this ->setting[ 'site_name' ]; $this ->load( "doing" ); $_ENV [ 'doing' ]->add( $uid , $username , 12, $uid , "欢迎您注册了$sitename" ); $this ->credit( $uid , $this ->setting[ 'credit1_register' ], $this ->setting[ 'credit2_register' ]); //注册增加积分 if (isset( $this ->setting[ 'register_on' ])&& $this ->setting[ 'register_on' ]== '1' ){ $activecode =md5(rand(10000,50000)); $url =SITE_URL. 'index.php?user/checkemail/' . $this ->user[ 'uid' ]. '/' . $activecode ; $message = "这是一封来自$sitename邮箱验证,<a target='_blank' href='$url'>请点击此处验证邮箱邮箱账号</a>" ; $v =md5( "yanzhengask2email" ); $v1 =md5( "yanzhengask2time" ); setcookie( "emailsend" ); setcookie( "useremailcheck" ); $expire1 = time() + 60; // 设置1分钟的有效期 setcookie ( "emailsend" , $v1 , $expire1 ); // 设置一个名字为var_name的cookie,并制定了有效期 $expire = time() + 86400; // 设置24小时的有效期 setcookie ( "useremailcheck" , $v , $expire ); // 设置一个名字为var_name的cookie,并制定了有效期 $_ENV [ 'user' ]->update_emailandactive( $email , $activecode , $this ->user[ 'uid' ]); $_ENV [ 'user' ]->refresh( $this ->user[ 'uid' ],1); sendmailto( $email , "邮箱验证提醒-$sitename" , $message , $this ->user[ 'username' ]); } if (isset( $this ->setting[ 'register_on' ])&& $this ->setting[ 'register_on' ]== '1' ){ exit ( "reguser_ok1" ); // exit("注册成功,系统已发送注册邮件,24小时之内请进行邮箱验证,在您没激活邮件之前你不能发布问题和文章等操作!");//注册成功 } else { exit ( "reguser_ok" ); } } function onmobilesms(){ if ( strtolower (trim( $this ->post[ 'code' ])) != $_ENV [ 'user' ]->get_code()) { exit ( '验证码错误' ); } $mobile = $this ->post[ 'mobile' ]; $code = rand(10000,50000); $content = '您的验证码为' . $code . '请妥善保存!' ; setcookie( 'smscode' , $code ,time()+600); $sta = sendsmsto( $mobile , $content ); if ( $sta == 0) { exit ( 'ok' ); } else { exit ( $sta ); } } |
最后我们增加发送接口,打开项目\lib\global.func.php文件,将下面代码进行写入即可:
1
2
3
4
5
6
7
|
/* 发送短信 */ function sendsmsto( $mobile , $content ){ global $setting ; $url = 'http://api.smsbao.com/sms?u=' . $setting [ 'smsbao_user' ]. '&p=' .md5( $setting [ 'smsbao_pass' ]). '&m=' . $mobile . '&c=【' . $setting [ 'smsbao_sign' ]. '】' . $content ; $ret = file_get_contents ( $url ); return $ret ; } |
好了,经过以上的替换,短信宝的短信平台已经替换成功了,我们去进行发送测试:
报备一下短信宝的VIP模板,这样就可以走短信宝的优质通道了,并且免审核了,短信内容3~5秒就可送达。
最新更新
电商类
CMS类
微信类