-
Notifications
You must be signed in to change notification settings - Fork 160
/
page-reg.php
194 lines (180 loc) · 7.4 KB
/
page-reg.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
<?php
// TEMPLATE NAME: CorrPress自定义注册页面
if (islogin()) {
header("Location: " . get_bloginfo('url'));
exit();
}
if (!get_option('users_can_register')) {
header("Location: " . get_bloginfo('url'));
exit();
}
global $set;
?>
<!doctype html>
<html lang="zh">
<head>
<?php get_header(); ?>
</head>
<body>
<?php
file_load_css('login-plane.css');
?>
<div id="app" class="login-background">
<header>
<div class="header-main-plane">
<div class="header-main container">
<?php
get_template_part('component/nav-header');
?>
</div>
</div>
</header>
<div class="header-zhanwei" style="min-height: 80px;width: 100%;"></div>
<style>
<?php
if ($set['user']['regpageimg'] != null) {
echo '#app{background-image:url('.$set['user']['regpageimg'].');}';
}
?>
</style>
<main class="container">
<div id="login-plane">
<div class="login-main">
<div id="login-note">
提示
</div>
<div class="login-form">
<div class="login-title"><h3>注册用户</h3></div>
<i class="fas fa-user ico-login" aria-hidden="true"></i><input class="input-login input-user"
name="user"
type="text"
placeholder="用户名(只能英文)">
<i class="far fa-envelope ico-login" aria-hidden="true"></i><input class="input-login input-pass"
name="mail"
type="text"
placeholder="电子邮箱">
<i class="fas fa-key ico-login" aria-hidden="true"></i><input class="input-login input-pass"
name="pass"
type="text"
placeholder="密码">
<i class="fas fa-key ico-login" aria-hidden="true"></i><input
class="input-login input-pass"
name="repass"
type="text"
placeholder="重复密码">
<?php
if ($set['user']['regpageVerificationCode'] == 1) {
?>
<div class="code-plane"><img class="img-code"
src="<?php echo FRAMEWORK_URI . "/VerificationCode.php" ?>"
alt=""><input class="input-login input-code"
name="code"
type="text"
placeholder="验证码"></div>
<?php
}
?>
<div class="login-title">
<div>已有账户?</div>
<a href="<?php echo wp_login_url() ?>">立即登录</a>
</div>
<div>
<button class="login-button" id="btn-login">注册账户</button>
</div>
<div class="usercenter-info-text">
<p><b>注册须知:</b></p>
<p>用户名只支持英文用户名</p>
<p>密码不能包含中文,长度8位以上,并且必须包含中英文和数字</p>
</div>
</div>
</div>
</div>
</main>
<script>
$('.img-code').click(() => {
recodeimg();
});
function recodeimg() {
$('.img-code').attr('src', '<?php echo FRAMEWORK_URI . "/VerificationCode.php?t=" . time() ?>');
}
$('input[name="repass"],input[name="user"],input[name="mail"]').click(function () {
$(this).removeClass('input-warning');
});
$('#btn-login').click(() => {
var user = $('input[name="user"]').val();
var mail = $('input[name="mail"]').val();
var pass = $('input[name="pass"]').val();
var repass = $('input[name="repass"]').val();
var code = $('input[name="code"]').val();
if (pass != repass) {
$('input[name="repass"]').addClass('input-warning')
$('#login-note').text('两次密码输入不一致');
$('#login-note').css('visibility', 'visible');
setTimeout(function () {
$('#login-note').css('visibility', 'hidden');
}, 3000);
return;
}
if (user == '' || pass == '' || repass == '' || mail == '') {
return;
}
if (!checkEmail(mail)) {
$('#login-note').text('邮箱格式不正确');
$('#login-note').css('visibility', 'visible');
$('input[name="mail"]').addClass('input-warning')
setTimeout(function () {
$('#login-note').css('visibility', 'hidden');
}, 3000);
return;
}
if (isChinese(pass) || isChinese(user)) {
addarelt('密码和用户名不支持中文', 'erro');
return;
}
if (!haveNumandLetter(pass)) {
addarelt('密码必须包含字母和数字', 'erro');
return;
}
if (pass.length < 8) {
addarelt('密码必须大于8位', 'erro');
return;
}
$('#login-note').text('正在注册,请稍后');
$('#login-note').css('visibility', 'visible');
$.post('<?php echo AJAX_URL?>', {
action: 'corepress_reguser',
user: user,
mail: mail,
pass: pass,
code: code
}, (data) => {
var obj = JSON.parse(data);
if (obj) {
if (obj.code === 1) {
$('#login-note').text('注册成功,跳转登陆页面');
window.location.href = '<?php echo wp_login_url()?>';
} else if (obj.code === 2) {
$('#login-note').text(obj.msg);
} else if (obj.code === 0) {
$('#login-note').text(obj.msg);
recodeimg();
}
}
});
});
function checkEmail(email) {
var myreg = /^(\w-*\.*)+@(\w-?)+(\.\w{2,})+$/;
if (!myreg.test(email)) {
return false;
} else {
return true;
}
}
</script>
<footer>
<?php
get_footer(); ?>
</footer>
</div>
</body>
</html>