Empty commit

This commit is contained in:
Git 2011-10-20 08:00:12 +00:00
parent fb327c7dda
commit 3e13a8e412
6 changed files with 97 additions and 73 deletions

View File

@ -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');

View File

@ -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` (

View File

@ -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 {

View File

@ -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 ------------------------------------//

View File

@ -1,95 +1,96 @@
<?
//TODO: restrict to viewing bellow class, username in h2
if(isset($_GET['userid']) && check_perms('users_view_ips') && check_perms('users_logout')) {
if(!is_number($_GET['userid'])) { error(404); }
$UserID = $_GET['userid'];
if(!is_number($_GET['userid'])) { error(404); }
$UserID = $_GET['userid'];
} else {
$UserID = $LoggedUser['ID'];
$UserID = $LoggedUser['ID'];
}
$UserSessions = $Cache->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.' &gt; Sessions');
?>
<div class="thin">
<h2><?=format_username($UserID,$Username)?> &gt; Sessions</h2>
<div class="box pad">
<p>Note: Clearing cookies can result in ghost sessions which are automatically removed after 30 days.</p>
</div>
<div class="box pad">
<table cellpadding="5" cellspacing="1" border="0" class="border" width="100%">
<tr class="colhead">
<td><strong>IP</strong></td>
<td><strong>Browser</strong></td>
<td><strong>Platform</strong></td>
<td><strong>Last Activity</strong></td>
<td>
<form action="" method="post">
<input type="hidden" name="action" value="sessions" />
<input type="hidden" name="auth" value="<?=$LoggedUser['AuthKey']?>" />
<input type="hidden" name="all" value="1" />
<input type="submit" value="Logout All" />
</form>
</td>
</tr>
<div class="box pad">
<p>Note: Clearing cookies can result in ghost sessions which are automatically removed after 30 days.</p>
</div>
<div class="box pad">
<table cellpadding="5" cellspacing="1" border="0" class="border" width="100%">
<tr class="colhead">
<td><strong>IP</strong></td>
<td><strong>Browser</strong></td>
<td><strong>Platform</strong></td>
<td><strong>Last Activity</strong></td>
<td>
<form action="" method="post">
<input type="hidden" name="action" value="sessions" />
<input type="hidden" name="auth" value="<?=$LoggedUser['AuthKey']?>" />
<input type="hidden" name="all" value="1" />
<input type="submit" value="Logout All" />
</form>
</td>
</tr>
<?
$Row = 'a';
foreach($UserSessions as $Session) {
list($ThisSessionID,$Browser,$OperatingSystem,$IP,$LastUpdate) = array_values($Session);
$Row = ($Row == 'a') ? 'b' : 'a';
$Row = 'a';
foreach($UserSessions as $Session) {
list($ThisSessionID,$Browser,$OperatingSystem,$IP,$LastUpdate) = array_values($Session);
$Row = ($Row == 'a') ? 'b' : 'a';
?>
<tr class="row<?=$Row?>">
<td><?=$IP?></td>
<td><?=$Browser?></td>
<td><?=$OperatingSystem?></td>
<td><?=time_diff($LastUpdate)?></td>
<td>
<form action="" method="post">
<input type="hidden" name="action" value="sessions" />
<input type="hidden" name="auth" value="<?=$LoggedUser['AuthKey']?>" />
<input type="hidden" name="session" value="<?=$ThisSessionID?>" />
<input type="submit" value="<?=(($ThisSessionID == $SessionID)?'Current" disabled="disabled':'Logout')?>" />
</form>
</td>
</tr>
<tr class="row<?=$Row?>">
<td><?=$IP?></td>
<td><?=$Browser?></td>
<td><?=$OperatingSystem?></td>
<td><?=time_diff($LastUpdate)?></td>
<td>
<form action="" method="post">
<input type="hidden" name="action" value="sessions" />
<input type="hidden" name="auth" value="<?=$LoggedUser['AuthKey']?>" />
<input type="hidden" name="session" value="<?=$ThisSessionID?>" />
<input type="submit" value="<?=(($ThisSessionID == $SessionID)?'Current" disabled="disabled':'Logout')?>" />
</form>
</td>
</tr>
<? } ?>
</table>
</div>
</table>
</div>
</div>
<?
show_footer();
?>

View File

@ -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'");
}