-
Notifications
You must be signed in to change notification settings - Fork 160
/
page-lostpassword.php
159 lines (140 loc) · 4.61 KB
/
page-lostpassword.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
<?php
// TEMPLATE NAME: CorrPress自定义忘记密码页面
if (islogin()) {
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']['repasswordimg'] != null) {
echo '#app{background-image:url('.$set['user']['repasswordimg'].');}';
}
?>
</style>
<main class="container">
<?php
if (isset($_GET['action']) && isset($_GET['key']) && isset($_GET['id']) && $_GET['action'] == 'resetpwd') {
$userid = $_GET['id'];
$key = $_GET['key'];
$userObj = get_user_by('ID', $userid);
$activation_key = $userObj->user_activation_key;
if ($activation_key != null && strpos($activation_key, ":") == true) {
$arr = explode(":", $activation_key);
$time = $arr[0];
$activation_key = $arr[1];
$nowtime = time();
if ($nowtime - $time > 86400 || $nowtime - $time < -86400) {
$msg = '验证过期';
showlostpasshtml(0, $msg);
} else {
if ($key == $activation_key) {
$msg = '验证成功';
showlostpasshtml(1, $msg);
} else {
$msg = '验证失败';
showlostpasshtml(0, $msg);
}
}
} else {
showresetpwdhtml();
}
} else {
showresetpwdhtml();
}
?>
</main>
<script>
$('#btn-getlostpass').click(() => {
getlostpass();
})
$('#btn-resetpwd').click(() => {
var pwd = $('input[name="pwd"]').val();
var repwd = $('input[name="repwd"]').val();
if (pwd == '' || repwd == '') {
addarelt('请输入完整内容', 'erro');
return;
}
if (pwd !== repwd) {
addarelt('两次密码不一致', 'erro');
return;
} else {
$('#login-note').css('visibility', 'visible');
$('#login-note').text('验证中,请稍后');
$.post(
'<?php echo AJAX_URL?>', {
<?php
$userid = $_GET['id'];
$key = $_GET['key'];
echo 'action:"corepress_resetpwd",userid:"' . $userid . '",key:"' . $key . '",pwd:pwd';
?>
}, (data) => {
var obj = JSON.parse(data);
if (obj.code === 1) {
$('#login-note').text(obj.msg);
} else {
$('#login-note').text(obj.msg);
}
});
}
});
function getlostpass() {
var user = $('input[name="user"]').val();
var key = $('input[name="code"]').val();
$('#login-note').text('检测中,请稍后');
$('#login-note').css('visibility', 'visible');
$.post('<?php echo AJAX_URL?>', {
action: 'corepress_lostpass',
user: user,
key: key
}, (data) => {
var obj = JSON.parse(data);
if (obj) {
if (obj.code === 1) {
$('#login-note').css('visibility', 'visible');
$('#login-note').text(obj.msg);
} else {
$('#login-note').css('visibility', 'visible');
$('#login-note').text(obj.msg);
recodeimg();
}
} else {
}
})
}
$('.img-code').click(() => {
recodeimg();
});
function recodeimg() {
$('.img-code').attr('src', '<?php echo FRAMEWORK_URI . "/VerificationCode.php?t=" . time() ?>');
}
</script>
<footer>
<?php
wp_footer();
get_footer(); ?>
</footer>
</div>
</body>
</html>