forked from jat001/youbbs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
forgot.php
executable file
·63 lines (55 loc) · 2.42 KB
/
forgot.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
<?php
define('IN_SAESPOT', 1);
define('ROOT', dirname(__FILE__));
include_once(ROOT . '/config.php');
include_once(ROOT . '/common.php');
if ($cur_user && $cur_user['flag'] == 0) {
$error_code = 4032;
include_once(ROOT . '/error/403.php');
exit;
}
$errors = array();
if($_SERVER['REQUEST_METHOD'] == 'POST'){
$name = addslashes(trim($_POST["name"]));
$email = addslashes(trim($_POST["email"]));
if($name && $email){
if(strlen($name)<21 && strlen($email)<32){
if(preg_match('/^[\w\d\x{4e00}-\x{9fa5}]{4,20}$/iu', $name)){
if(preg_match('/^\d{4,20}$/', $name)){
$errors[] = '名字不能全为数字';
}else{
if(isemail($email)){
$db_user = $DBS->fetch_one_array("SELECT * FROM yunbbs_users WHERE name='".$name."' LIMIT 1");
if($db_user){
if($db_user['flag'] != 0 || $db_user['flag'] != 1){
if($email == $db_user['email']){
header("Content-Type: text/html; charset=UTF-8");
exit('请用该邮箱:'.$db_user['email'].' 给管理员(管理员信箱:'.$options['admin_email'].')发送一封密码重设请求,内容只需包含您的用户名“'.$name.'”');
}else{
$errors[] = '填写的邮箱 与 个人设置里的邮箱 不一致';
}
}else{
$errors[] = '该账户 已禁用 或 还在审核中,不允许找回密码';
}
}else{
$errors[] = '用户名 错误';
}
}else{
$errors[] = '邮箱 格式错误';
}
}
}else{
$errors[] = '名字 太长 或 太短 或 包含非法字符';
}
}else{
$errors[] = '用户名 或 邮箱 太长了';
}
}else{
$errors[] = '用户名 和 邮箱 必填';
}
}
// 页面变量
$title = '找回密码 - '.$options['name'];
$pagefile = ROOT . '/templates/default/'.$tpl.'forgot.php';
include_once(ROOT . '/templates/default/'.$tpl.'layout.php');
?>