Gazelle/sections/torrents/downloadlist.php

92 lines
2.0 KiB
PHP
Raw Normal View History

2012-03-28 08:00:20 +00:00
<?
2013-04-24 08:00:23 +00:00
if (!isset($_GET['torrentid']) || !is_number($_GET['torrentid']) || !check_perms('site_view_torrent_snatchlist')) {
error(404);
}
2012-03-28 08:00:20 +00:00
$TorrentID = $_GET['torrentid'];
2013-04-24 08:00:23 +00:00
if (!empty($_GET['page']) && is_number($_GET['page'])) {
2012-03-28 08:00:20 +00:00
$Page = $_GET['page'];
2013-04-24 08:00:23 +00:00
$Limit = (string)(($Page - 1) * 100) .', 100';
2012-03-28 08:00:20 +00:00
} else {
$Page = 1;
$Limit = 100;
}
2013-04-24 08:00:23 +00:00
$DB->query("
2013-05-29 08:00:51 +00:00
SELECT
SQL_CALC_FOUND_ROWS
2013-11-17 08:00:47 +00:00
UserID,
Time
FROM users_downloads
WHERE TorrentID = '$TorrentID'
ORDER BY Time DESC
2013-04-24 08:00:23 +00:00
LIMIT $Limit");
2012-03-28 08:00:20 +00:00
$UserIDs = $DB->collect('UserID');
$Results = $DB->to_array('UserID', MYSQLI_ASSOC);
2013-04-24 08:00:23 +00:00
$DB->query('SELECT FOUND_ROWS()');
2012-03-28 08:00:20 +00:00
list($NumResults) = $DB->next_record();
2013-04-24 08:00:23 +00:00
if (count($UserIDs) > 0) {
2013-08-28 23:08:41 +00:00
$UserIDs = implode(',', $UserIDs);
2013-05-29 08:00:51 +00:00
$DB->query("
SELECT uid
FROM xbt_snatched
2013-08-28 23:08:41 +00:00
WHERE fid = '$TorrentID'
2013-05-29 08:00:51 +00:00
AND uid IN($UserIDs)");
2012-03-28 08:00:20 +00:00
$Snatched = $DB->to_array('uid');
2013-02-22 08:00:24 +00:00
2013-05-29 08:00:51 +00:00
$DB->query("
SELECT uid
FROM xbt_files_users
2013-08-28 23:08:41 +00:00
WHERE fid = '$TorrentID'
AND Remaining = 0
2013-05-29 08:00:51 +00:00
AND uid IN($UserIDs)");
2012-03-28 08:00:20 +00:00
$Seeding = $DB->to_array('uid');
}
?>
2013-08-28 23:08:41 +00:00
<h4 class="tooltip" title="List of users that have clicked the &quot;DL&quot; button">List of Downloaders</h4>
2013-04-24 08:00:23 +00:00
<? if ($NumResults > 100) { ?>
2012-03-28 08:00:20 +00:00
<div class="linkbox"><?=js_pages('show_downloads', $_GET['torrentid'], $NumResults, $Page)?></div>
<? } ?>
<table>
<tr class="colhead_dark" style="font-weight: bold;">
<td>User</td>
<td>Time</td>
<td>User</td>
<td>Time</td>
</tr>
<tr>
<?
$i = 0;
2013-04-24 08:00:23 +00:00
foreach ($Results as $ID=>$Data) {
2012-03-28 08:00:20 +00:00
list($SnatcherID, $Timestamp) = array_values($Data);
2013-02-22 08:00:24 +00:00
2012-10-11 08:00:15 +00:00
$User = Users::format_username($SnatcherID, true, true, true, true);
2013-02-22 08:00:24 +00:00
2013-04-24 08:00:23 +00:00
if (!array_key_exists($SnatcherID, $Snatched) && $SnatcherID != $UserID) {
2012-10-05 08:00:20 +00:00
$User = '<span style="font-style: italic;">'.$User.'</span>';
2013-04-24 08:00:23 +00:00
if (array_key_exists($SnatcherID, $Seeding)) {
2012-03-28 08:00:20 +00:00
$User = '<strong>'.$User.'</strong>';
}
}
2013-04-24 08:00:23 +00:00
if ($i % 2 == 0 && $i > 0) { ?>
2012-03-28 08:00:20 +00:00
</tr>
2013-02-22 08:00:24 +00:00
<tr>
2012-03-28 08:00:20 +00:00
<?
}
2013-02-22 08:00:24 +00:00
?>
2012-03-28 08:00:20 +00:00
<td><?=$User?></td>
<td><?=time_diff($Timestamp)?></td>
<?
$i++;
}
?>
</tr>
</table>
2013-04-24 08:00:23 +00:00
<? if ($NumResults > 100) { ?>
2012-03-28 08:00:20 +00:00
<div class="linkbox"><?=js_pages('show_downloads', $_GET['torrentid'], $NumResults, $Page)?></div>
2012-10-05 08:00:20 +00:00
<? } ?>