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)
7676function preventMultipleLogin ($ userId )
7777{
7878 $ table = Database::get_main_table (TABLE_STATISTIC_TRACK_E_ONLINE );
79- $ userId = intval ( $ userId) ;
79+ $ userId = ( int ) $ userId ;
8080 if (api_get_setting ('prevent_multiple_simultaneous_login ' ) === 'true ' ) {
8181 if (!empty ($ userId ) && !api_is_anonymous ()) {
8282 $ 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+
8390 if (empty ($ isFirstLogin )) {
8491 $ sql = "SELECT login_id FROM $ table
8592 WHERE login_user_id = $ userId
@@ -94,14 +101,15 @@ function preventMultipleLogin($userId)
94101 $ userIsReallyOnline = user_is_online ($ userId );
95102
96103 // Trying double login.
97- if (!empty ($ loginData ) && $ userIsReallyOnline == true ) {
104+ if (( !empty ($ loginData ) && $ userIsReallyOnline) || $ differentIp ) {
98105 session_regenerate_id ();
99106 Session::destroy ();
100107 header ('Location: ' .api_get_path (WEB_PATH ).'index.php?loginFailed=1&error=multiple_connection_not_allowed ' );
101108 exit ;
102109 } else {
103110 // First time
104111 Session::write ('first_user_login ' , 1 );
112+ Session::write ('current_ip ' , api_get_real_ip ());
105113 }
106114 }
107115 }
You can’t perform that action at this time.
0 commit comments