File tree Expand file tree Collapse file tree 1 file changed +10
-2
lines changed Expand file tree Collapse file tree 1 file changed +10
-2
lines changed Original file line number Diff line number Diff line change @@ -76,10 +76,17 @@ function LoginCheck($uid)
76
76
function preventMultipleLogin ($ userId )
77
77
{
78
78
$ table = Database::get_main_table (TABLE_STATISTIC_TRACK_E_ONLINE );
79
- $ userId = intval ( $ userId) ;
79
+ $ userId = ( int ) $ userId ;
80
80
if (api_get_setting ('prevent_multiple_simultaneous_login ' ) === 'true ' ) {
81
81
if (!empty ($ userId ) && !api_is_anonymous ()) {
82
82
$ isFirstLogin = Session::read ('first_user_login ' );
83
+ $ currentIp = Session::read ('current_ip ' );
84
+ $ differentIp = false ;
85
+ if (!empty ($ currentIp ) && api_get_real_ip () !== $ currentIp ) {
86
+ $ isFirstLogin = null ;
87
+ $ differentIp = true ;
88
+ }
89
+
83
90
if (empty ($ isFirstLogin )) {
84
91
$ sql = "SELECT login_id FROM $ table
85
92
WHERE login_user_id = $ userId
@@ -94,14 +101,15 @@ function preventMultipleLogin($userId)
94
101
$ userIsReallyOnline = user_is_online ($ userId );
95
102
96
103
// Trying double login.
97
- if (!empty ($ loginData ) && $ userIsReallyOnline == true ) {
104
+ if (( !empty ($ loginData ) && $ userIsReallyOnline) || $ differentIp ) {
98
105
session_regenerate_id ();
99
106
Session::destroy ();
100
107
header ('Location: ' .api_get_path (WEB_PATH ).'index.php?loginFailed=1&error=multiple_connection_not_allowed ' );
101
108
exit ;
102
109
} else {
103
110
// First time
104
111
Session::write ('first_user_login ' , 1 );
112
+ Session::write ('current_ip ' , api_get_real_ip ());
105
113
}
106
114
}
107
115
}
You can’t perform that action at this time.
0 commit comments