forked from sillycross/dts
/
login.php
executable file
·63 lines (51 loc) · 1.67 KB
/
login.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('CURSCRIPT', 'login');
define('LOAD_CORE_ONLY', TRUE);
require './include/common.inc.php';
if($mode == 'quit') {//退出指令最优先
gsetcookie('user','');
gsetcookie('pass','');
header("Location: index.php");
exit();
}
if(!isset($username) && empty($cuser)) {//如果用户名为空则显示一个登陆用的界面
include template('login_page');
exit();
}
//其他情况下验证登陆,出错则显示错误页面,通过则跳转首页
include './gamedata/banlist.list';
$name_check = name_check($username);
$pass_check = pass_check($password,$password);
if($name_check!='name_ok'){
gexit($_ERROR[$name_check],__file__,__line__);
}elseif($pass_check!='pass_ok'){
gexit($_ERROR[$pass_check],__file__,__line__);
}
$onlineip = real_ip();
if(preg_match($iplimit,$onlineip)){
gexit($_ERROR['ip_banned'],__file__,__line__);
}
$password = create_cookiepass($password);
$groupid = 1;
$credits = 0;
$gender = 0;
$userdata = fetch_udata_by_username($username);
if(empty($userdata)) {
gexit($_ERROR['user_not_exists'],__file__,__line__);
} else {
if($userdata['groupid'] <= 0){
gexit($_ERROR['user_ban'],__file__,__line__);
} elseif(!pass_compare($userdata['username'], $password, $userdata['password'])) {
gexit($_ERROR['wrong_pw'],__file__,__line__);
}
}
//重设IP和登陆时间
update_udata_by_username(array('ip' => $onlineip, 'lastvisit' => $now), $username);
gsetcookie('user',$userdata['username'],86400*15);
gsetcookie('pass',$password,86400*15);
//重新登陆之后房间设为0
set_current_roomid(0);
Header("Location: index.php");
exit();
/* End of file login.php */
/* Location: /login.php */