diff --git a/classes/script_start.php b/classes/script_start.php index 65b46af1..44bb9521 100644 --- a/classes/script_start.php +++ b/classes/script_start.php @@ -112,6 +112,7 @@ LastUpdate FROM users_sessions WHERE UserID='$UserID' + AND Active = 1 ORDER BY LastUpdate DESC"); $UserSessions = $DB->to_array('SessionID',MYSQLI_ASSOC); $Cache->cache_value('users_sessions_'.$UserID, $UserSessions, 0); @@ -546,7 +547,10 @@ function logout() { setcookie('keeplogged','',time()-60*60*24*365,'/','',false); setcookie('session','',time()-60*60*24*365,'/','',false); if($SessionID) { + + $DB->query("DELETE FROM users_sessions WHERE UserID='$LoggedUser[ID]' AND SessionID='".db_string($SessionID)."'"); + $Cache->begin_transaction('users_sessions_'.$LoggedUser['ID']); $Cache->delete_row($SessionID); $Cache->commit_transaction(0); @@ -1869,12 +1873,15 @@ function disable_users($UserIDs, $AdminComment, $BanReason = 1) { $Cache->delete_value('user_info_heavy_'.$UserID); $Cache->delete_value('user_stats_'.$UserID); - $DB->query("SELECT SessionID FROM users_sessions WHERE UserID='$UserID'"); + $DB->query("SELECT SessionID FROM users_sessions WHERE UserID='$UserID' AND Active = 1"); while(list($SessionID) = $DB->next_record()) { $Cache->delete_value('session_'.$UserID.'_'.$SessionID); } $Cache->delete_value('users_sessions_'.$UserID); + + $DB->query("DELETE FROM users_sessions WHERE UserID='$UserID'"); + } $DB->query("SELECT torrent_pass FROM users_main WHERE ID in (".implode(", ",$UserIDs).")"); $PassKeys = $DB->collect('torrent_pass'); diff --git a/gazelle.sql b/gazelle.sql index a00d544d..d45d6acf 100644 --- a/gazelle.sql +++ b/gazelle.sql @@ -1260,9 +1260,11 @@ CREATE TABLE `users_sessions` ( `OperatingSystem` varchar(8) DEFAULT NULL, `IP` varchar(15) NOT NULL, `LastUpdate` datetime NOT NULL, + `Active` tinyint(4) NOT NULL DEFAULT '1', PRIMARY KEY (`UserID`,`SessionID`), KEY `UserID` (`UserID`), - KEY `LastUpdate` (`LastUpdate`) + KEY `LastUpdate` (`LastUpdate`), + KEY `Active` (`Active`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1; CREATE TABLE `users_subscriptions` ( diff --git a/sections/login/index.php b/sections/login/index.php index 594d5694..1727bc42 100644 --- a/sections/login/index.php +++ b/sections/login/index.php @@ -139,7 +139,7 @@ while(list($SessionID) = $DB->next_record()) { $Cache->delete_value('session_'.$UserID.'_'.$SessionID); } - $DB->query("DELETE FROM users_sessions WHERE UserID='$UserID'"); + $DB->query("UPDATE users_sessions SET Active = 0 WHERE UserID='$UserID' AND Active = 1"); } else { diff --git a/sections/schedule/index.php b/sections/schedule/index.php index ae70aaa4..2215078a 100644 --- a/sections/schedule/index.php +++ b/sections/schedule/index.php @@ -252,7 +252,10 @@ function next_hour() { $Cache->delete_row($SessionID); $Cache->commit_transaction(0); } - $DB->query("DELETE FROM users_sessions WHERE LastUpdate<'$AgoDays' AND KeepLogged='1'"); + + + $DB->query("DELETE FROM users_sesions WHERE LastUpdate<'$AgoDays' AND KeepLogged='1'"); + $AgoMins = time_minus(60*30); $DB->query("SELECT UserID, SessionID FROM users_sessions WHERE LastUpdate<'$AgoMins' AND KeepLogged='0'"); @@ -261,7 +264,10 @@ function next_hour() { $Cache->delete_row($SessionID); $Cache->commit_transaction(0); } + + $DB->query("DELETE FROM users_sessions WHERE LastUpdate<'$AgoMins' AND KeepLogged='0'"); + //------------- Lower Login Attempts ------------------------------------// diff --git a/sections/user/sessions.php b/sections/user/sessions.php index 15c1be5a..3ab0951a 100644 --- a/sections/user/sessions.php +++ b/sections/user/sessions.php @@ -1,95 +1,96 @@ get_value('users_sessions_'.$UserID); if(!is_array($UserSessions)) { - $DB->query("SELECT - SessionID, - Browser, - OperatingSystem, - IP, - LastUpdate - FROM users_sessions - WHERE UserID='$UserID' - ORDER BY LastUpdate DESC"); - $UserSessions = $DB->to_array('SessionID',MYSQLI_ASSOC); - $Cache->cache_value('users_sessions_'.$UserID, $UserSessions, 0); + $DB->query("SELECT + SessionID, + Browser, + OperatingSystem, + IP, + LastUpdate + FROM users_sessions + WHERE UserID='$UserID' + ORDER BY LastUpdate DESC"); + $UserSessions = $DB->to_array('SessionID',MYSQLI_ASSOC); + $Cache->cache_value('users_sessions_'.$UserID, $UserSessions, 0); } if(isset($_POST['all'])) { - authorize(); + authorize(); - $DB->query("DELETE FROM users_sessions WHERE UserID='$UserID' AND SessionID<>'$SessionID'"); - $UserSessions = array($SessionID=>array('SessionID'=>$SessionID,'Browser'=>$Browser,'OperatingSystem'=>$OperatingSystem,'IP'=>$SessionIP,'LastUpdate'=>sqltime())); - $Cache->cache_value('users_sessions_'.$UserID, $UserSessions, 0); + $DB->query("DELETE FROM users_sessions WHERE UserID='$UserID' AND SessionID<>'$SessionID'"); + $UserSessions = array($SessionID=>array('SessionID'=>$SessionID,'Browser'=>$Browser,'OperatingSystem'=>$OperatingSystem,'IP'=>$SessionIP,'LastUpdate'=>sqltime())); + $Cache->cache_value('users_sessions_'.$UserID, $UserSessions, 0); } if (isset($_POST['session'])) { - authorize(); + authorize(); - $DB->query("DELETE FROM users_sessions WHERE UserID='$UserID' AND SessionID='".db_string($_POST['session'])."'"); - unset($UserSessions[$_POST['session']]); - $Cache->begin_transaction('users_sessions_'.$UserID); - $Cache->delete_row($_POST['session']); - $Cache->commit_transaction(0); + $DB->query("DELETE FROM users_sessions WHERE UserID='$UserID' AND SessionID='".db_string($_POST['session'])."'"); + unset($UserSessions[$_POST['session']]); + $Cache->begin_transaction('users_sessions_'.$UserID); + $Cache->delete_row($_POST['session']); + $Cache->commit_transaction(0); } list($UserID, $Username) = array_values(user_info($UserID)); - show_header($Username.' > Sessions'); ?>

> Sessions

-
-

Note: Clearing cookies can result in ghost sessions which are automatically removed after 30 days.

-
-
- - - - - - - - +
+

Note: Clearing cookies can result in ghost sessions which are automatically removed after 30 days.

+
+
+
IPBrowserPlatformLast Activity -
- - - - -
-
+ + + + + + + - - - - - - - + + + + + + + -
IPBrowserPlatformLast Activity +
+ + + + +
+
-
- - - - -
-
+
+ + + + +
+
-
+ +
- diff --git a/sections/user/takemoderate.php b/sections/user/takemoderate.php index 135cb714..24190475 100644 --- a/sections/user/takemoderate.php +++ b/sections/user/takemoderate.php @@ -206,7 +206,10 @@ $Cache->delete_value('session_'.$UserID.'_'.$SessionID); } $Cache->delete_value('users_sessions_'.$UserID); - $DB->query("DELETE FROM users_sessions WHERE UserID='$UserID'"); + + + $DB->query("DELETE FROM users_sessions WHERE UserID="'$UserID'"); + } } @@ -497,17 +500,19 @@ disable_users($UserID, '', 1); } elseif($EnableUser == '1') { $Cache->increment('stats_user_count'); + update_tracker('add_user', array('id' => $UserID, 'passkey' => $Cur['torrent_pass'])); if (($Cur['Downloaded'] == 0) || ($Cur['Uploaded']/$Cur['Downloaded'] >= $Cur['RequiredRatio'])) { $UpdateSet[]="i.RatioWatchEnds='0000-00-00 00:00:00'"; $CanLeech = 1; $UpdateSet[]="m.can_leech='1'"; - $UpdateSet[]="i.RatioWatchDownload='0'"; - update_tracker('add_user', array('id' => $UserID, 'passkey' => $Cur['torrent_pass'])); + $UpdateSet[]="i.RatioWatchDownload='0'"; } else { $EnableStr .= ' (Ratio: '.number_format($Cur['Uploaded']/$Cur['Downloaded'],2).', RR: '.number_format($Cur['RequiredRatio'],2).')'; if ($Cur['RatioWatchEnds'] != '0000-00-00 00:00:00') { $UpdateSet[]="i.RatioWatchEnds=NOW()"; + $CanLeech = 0; } + update_tracker('update_user', array('passkey' => $Cur['torrent_pass'], 'can_leech' => '0')); } $UpdateSet[]="Enabled='1'"; $LightUpdates['Enabled'] = 1; @@ -576,7 +581,10 @@ $Cache->delete_value('session_'.$UserID.'_'.$SessionID); } $Cache->delete_value('users_sessions_'.$UserID); - $DB->query("DELETE FROM users_sessions WHERE UserID='$UserID'"); + + + $DB->query("DELETE FROM users_sessions WHERE UserID='$UserID'"); + }