-
+permitted('site_moderate_requests')) { ?>
Mass PM snatchers
-
View peer list
View log
-
View download list
-
View snatch list
+ if ($Viewer->permitted('site_view_torrent_snatchlist')) { ?>
+
View downloaders
+
View snatchers
-
View file list
+
View seeders
+
View contents
View report information
@@ -762,7 +762,7 @@ function filelist($Str) {
=$FormatString?> / =$BitrateString?> / =$MediaString?> |
=count($RequestVotes['Voters'])?>
-
+permitted('site_vote')) { ?>
+
|
diff --git a/sections/torrents/downloadlist.php b/sections/torrents/downloadlist.php
index d4094a6ec..94fd432e1 100644
--- a/sections/torrents/downloadlist.php
+++ b/sections/torrents/downloadlist.php
@@ -1,86 +1,19 @@
permitted('site_view_torrent_snatchlist')) {
+ error(403);
}
-
-$NumResults = $DB->scalar("SELECT count(*) FROM users_downloads WHERE TorrentID = ?", $TorrentID);
-$DB->prepared_query("
- SELECT UserID,
- Time
- FROM users_downloads
- WHERE TorrentID = ?
- ORDER BY Time DESC
- LIMIT $Limit
- ", $TorrentID
-);
-$Results = $DB->to_array('UserID', MYSQLI_ASSOC);
-if (empty($Results)) {
- $Snatched = [];
- $Seeding = [];
-} else {
- $DB->prepared_query("
- SELECT xs.uid
- FROM xbt_snatched xs
- INNER JOIN users_downloads ud ON (ud.UserID = xs.uid)
- WHERE xs.fid = ?
- ", $TorrentID
- );
- $Snatched = $DB->to_array('uid');
- $DB->prepared_query("
- SELECT xfu.uid
- FROM xbt_files_users xfu
- INNER JOIN users_downloads ud ON (ud.UserID = xfu.uid)
- WHERE xfu.Remaining = 0 AND xfu.fid = ?
- ", $TorrentID
- );
- $Seeding = $DB->to_array('uid');
+$torrent = (new Gazelle\Manager\Torrent)->findById((int)$_GET['torrentid']);
+if (is_null($torrent)) {
+ error(404);
}
-?>
-
- 100) { ?>
-
=js_pages('show_downloads', $_GET['torrentid'], $NumResults, $Page)?>
-
-
-
- User |
- Time |
- User |
- Time |
-
-
- $Data) {
- [$SnatcherID, $Timestamp] = array_values($Data);
+$paginator = new Gazelle\Util\Paginator(PEERS_PER_PAGE, (int)($_GET['page'] ?? 1));
+$paginator->setTotal($torrent->downloadTotal());
- $User = Users::format_username($SnatcherID, true, true, true, true);
- if (!array_key_exists($SnatcherID, $Snatched) && $SnatcherID != $UserID) {
- $User = '' . $User . '';
- if (array_key_exists($SnatcherID, $Seeding)) {
- $User = '' . $User . '';
- }
- }
- if ($i % 2 == 0 && $i > 0) { ?>
-
-
-
- =$User?> |
- =time_diff($Timestamp)?> |
-
-
-
- 100) { ?>
-
=js_pages('show_downloads', $_GET['torrentid'], $NumResults, $Page)?>
-
+echo $Twig->render('torrent/downloadlist.twig', [
+ 'page' => $torrent->downloadPage($paginator->limit(), $paginator->offset()),
+ 'paginator' => $paginator,
+ 'torrent_id' => $torrent->id(),
+ 'url_stem' => STATIC_SERVER . '/styles/' . $Viewer->stylesheetName() . '/images/',
+ 'viewer_id' => $Viewer->id(),
+]);
diff --git a/sections/torrents/index.php b/sections/torrents/index.php
index 02258e15e..bc798c46e 100644
--- a/sections/torrents/index.php
+++ b/sections/torrents/index.php
@@ -1,19 +1,5 @@
$i";
- }
- }
- return implode(' | ', $PageLinks);
-}
-
if (!empty($_REQUEST['action'])) {
switch ($_REQUEST['action']) {
case 'editlog':
diff --git a/sections/torrents/peerlist.php b/sections/torrents/peerlist.php
index f4651f8cf..6d7173fb8 100644
--- a/sections/torrents/peerlist.php
+++ b/sections/torrents/peerlist.php
@@ -9,9 +9,10 @@
$paginator->setTotal($torrent->peerlistTotal());
echo $Twig->render('torrent/peerlist.twig', [
- 'is_admin' => check_perms('users_mod'),
- 'linkbox' => $paginator->linkboxJS('show_peers', $torrent->id()),
+ 'is_admin' => $Viewer->permitted('users_mod'),
'list' => $torrent->peerlistPage($Viewer->id(), $paginator->limit(), $paginator->offset()),
+ 'paginator' => $paginator,
'torrent_id' => $torrent->id(),
+ 'url_stem' => STATIC_SERVER . '/styles/' . $Viewer->stylesheetName() . '/images/',
'user_id' => $Viewer->id(),
]);
diff --git a/sections/torrents/snatchlist.php b/sections/torrents/snatchlist.php
index 9c10f1ff0..f5d1a8d5d 100644
--- a/sections/torrents/snatchlist.php
+++ b/sections/torrents/snatchlist.php
@@ -1,63 +1,20 @@
permitted('site_view_torrent_snatchlist')) {
+ error(403);
+}
+$torrent = (new Gazelle\Manager\Torrent)->findById((int)$_GET['torrentid']);
+if (is_null($torrent)) {
+ error(404);
}
-$NumResults = $DB->scalar("
- SELECT count(*) FROM xbt_snatched WHERE fid = ?
- ", $TorrentID
-);
-$DB->prepared_query("
- SELECT uid,
- tstamp
- FROM xbt_snatched
- WHERE fid = ?
- ORDER BY tstamp DESC
- LIMIT $Limit
- ", $TorrentID
-);
-$Results = $DB->to_array('uid', MYSQLI_ASSOC);
-?>
-
-
- 100) { ?>
-
=js_pages('show_snatches', $_GET['torrentid'], $NumResults, $Page)?>
-
+$paginator = new Gazelle\Util\Paginator(PEERS_PER_PAGE, (int)($_GET['page'] ?? 1));
+$paginator->setTotal($torrent->snatchTotal());
-
-
- User |
- Time |
- User |
- Time |
-
-
-$Data) {
- [$SnatcherID, $Timestamp] = array_values($Data);
- if ($i % 2 == 0 && $i > 0) {
-?>
-
-
-
- =Users::format_username($SnatcherID, true, true, true, true)?> |
- =time_diff($Timestamp)?> |
-
-
-
- 100) { ?>
-
=js_pages('show_snatches', $_GET['torrentid'], $NumResults, $Page)?>
-
+echo $Twig->render('torrent/snatchlist.twig', [
+ 'page' => $torrent->snatchPage($paginator->limit(), $paginator->offset()),
+ 'paginator' => $paginator,
+ 'torrent_id' => $torrent->id(),
+ 'url_stem' => STATIC_SERVER . '/styles/' . $Viewer->stylesheetName() . '/images/',
+ 'viewer_id' => $Viewer->id(),
+]);
diff --git a/templates/macro/paginator.twig b/templates/macro/paginator.twig
new file mode 100644
index 000000000..54e878438
--- /dev/null
+++ b/templates/macro/paginator.twig
@@ -0,0 +1,12 @@
+{% macro pager(action, torrent_id, page, pages) %}
+ {% if pages > 1 %}
+ {% for p in 1 .. pages %}
+ {% if not loop.first %} | {% endif %}
+ {% if page == p %}
+ {{ p }}
+ {% else %}
+
{{ p }}
+ {% endif %}
+ {% endfor %}
+ {% endif %}
+{% endmacro %}
diff --git a/templates/torrent/downloadlist.twig b/templates/torrent/downloadlist.twig
new file mode 100644
index 000000000..206bfd4fe
--- /dev/null
+++ b/templates/torrent/downloadlist.twig
@@ -0,0 +1,31 @@
+{% from 'macro/paginator.twig' import pager %}
+{% for download in page %}
+ {% if loop.first %}
+
+
{{ pager('show_downloads', torrent_id, paginator.page, paginator.pages)|raw }}
+
+
+ {% for n in range(1, 2) %}
+ User |
+ Time |
+  |
+  |
+ {% endfor %}
+
+
+ {% elseif loop.index0 % 2 == 0 %}
+
+
+ {% endif %}
+ {{ download.user_id|user_full }} |
+ {{ download.timestamp|time_diff }} |
+ {% if download.is_snatched %}{{ constant('ICON_STAR') }} {% else %} {% endif %} |
+ {% if download.is_seeding %}{{ constant('ICON_STAR') }} {% else %} {% endif %} |
+ {% if loop.last %}
+
+
+
{{ pager('show_downloads', torrent_id, paginator.page, paginator.pages)|raw }}
+ {% endif %}
+{% else %}
+
No downloads recorded
+{% endfor %}
diff --git a/templates/torrent/peerlist.twig b/templates/torrent/peerlist.twig
index b1bddaa2b..698f63345 100644
--- a/templates/torrent/peerlist.twig
+++ b/templates/torrent/peerlist.twig
@@ -1,5 +1,8 @@
-
Peer List
-{{ linkbox|raw }}
+{% from 'macro/paginator.twig' import pager %}
+{% for peer in list %}
+ {% if loop.first %}
+
List of Seeders
+
{{ pager('show_peers', torrent_id, paginator.page, paginator.pages)|raw }}
User |
@@ -9,8 +12,12 @@
Available % |
IP Address |
Useragent |
+ {% if is_admin %}
+  |
+  |
+ {% endif %}
-{% for peer in list %}
+ {% endif %}
{% if is_admin or peer.user_id == user_id %}
{{ peer.user_id|user_url }} |
@@ -35,7 +42,15 @@
— |
{{ peer.useragent }} |
{% endif %}
+ {% if is_admin %}
+ {% if peer.is_download %}{{ constant('ICON_STAR') }} {% else %} {% endif %} |
+ {% if peer.is_snatched %}{{ constant('ICON_STAR') }} {% else %} {% endif %} |
+ {% endif %}
-{% endfor %}
+ {% if loop.last %}
-{{ linkbox|raw }}
+
{{ pager('show_peers', torrent_id, paginator.page, paginator.pages)|raw }}
+ {% endif %}
+{% else %}
+
No current seeders
+{% endfor %}
diff --git a/templates/torrent/snatchlist.twig b/templates/torrent/snatchlist.twig
new file mode 100644
index 000000000..8e89de4cb
--- /dev/null
+++ b/templates/torrent/snatchlist.twig
@@ -0,0 +1,31 @@
+{% from 'macro/paginator.twig' import pager %}
+{% for snatch in page %}
+ {% if loop.first %}
+
+
{{ pager('show_snatches', torrent_id, paginator.page, paginator.pages)|raw }}
+
+
+ {% for n in range(1, 2) %}
+ User |
+ Time |
+  |
+  |
+ {% endfor %}
+
+
+ {% elseif loop.index0 % 2 == 0 %}
+
+
+ {% endif %}
+ {{ snatch.user_id|user_full }} |
+ {{ snatch.timestamp|time_diff }} |
+ {% if snatch.is_download %}{{ constant('ICON_STAR') }} {% else %} {% endif %} |
+ {% if snatch.is_seeding %}{{ constant('ICON_STAR') }} {% else %} {% endif %} |
+ {% if loop.last %}
+
+
+
{{ pager('show_snatches', torrent_id, paginator.page, paginator.pages)|raw }}
+ {% endif %}
+{% else %}
+
No snatches recorded
+{% endfor %}