-
Notifications
You must be signed in to change notification settings - Fork 85
/
Copy pathAuthenticate.php
75 lines (62 loc) · 2.36 KB
/
Authenticate.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
<?php
session_start();
header("Content-type:text/html;charset=utf-8");
unset($_SESSION['nick']);
unset($_SESSION['authenticated_user_id']);
unset($_SESSION['app_unique_key']);
unset($_SESSION['topsession']);
require_once('config.php');
require_once('modules/Users/Users.php');
require_once('include/logging.php');
global $mod_strings;
global $app_strings;
$focus = new Users();
// Add in defensive code here.
$focus->column_fields["user_name"] = to_html($_REQUEST['user_name']);
$user_password = $_REQUEST['user_password'];
$theme = $_REQUEST['login_theme'];
$focus->load_user($user_password);
if($focus->is_authenticated()) {
$query = "UPDATE ec_users SET is_online='1', last_ping='".time()."' WHERE user_name='".$focus->column_fields["user_name"]."'";
$adb->query($query);
$usip=$_SERVER['REMOTE_ADDR'];
$intime=date("Y/m/d H:i:s");
require_once('modules/Users/LoginHistory.php');
$loghistory=new LoginHistory();
$Signin = $loghistory->user_login($focus->column_fields["user_name"],$usip,$intime);
unset($_SESSION['login_password']);
unset($_SESSION['login_error']);
unset($_SESSION['login_user_name']);
unset($_SESSION['login_theme']);
$_SESSION['login_company_name'] = $company_name;
$_SESSION['authenticated_user_id'] = $focus->id;
$_SESSION['app_unique_key'] = $application_unique_key;
$_SESSION['nick'] = $_REQUEST['user_name'];
$_SESSION['topsession'] = $application_unique_key;
// store the user's theme in the session
if (isset($_REQUEST['login_theme'])) {
$authenticated_user_theme = $_REQUEST['login_theme'];
}
else {
$authenticated_user_theme = $default_theme;
}
// store the user's language in the session
if (isset($_REQUEST['login_language'])) {
$authenticated_user_language = $_REQUEST['login_language'];
}
else {
$authenticated_user_language = $default_language;
}
$_SESSION['authenticated_user_theme'] = $authenticated_user_theme;
$_SESSION['authenticated_user_language'] = $authenticated_user_language;
redirect("index.php?module=Home&action=index");
} else {
$_SESSION['login_user_name'] = $focus->column_fields["user_name"];
$_SESSION['login_password'] = $user_password;
$_SESSION['login_theme'] = $theme;
//$_SESSION['login_error'] = $mod_strings['ERR_INVALID_PASSWORD'];
// go back to the login screen.
// create an error message for the user.
redirect("Login.php?login_error=".rawurlencode("用户名和密码不对"));
}
?>