diff --git a/app/Torrent.php b/app/Torrent.php index c7cc70847..c142746aa 100644 --- a/app/Torrent.php +++ b/app/Torrent.php @@ -634,7 +634,8 @@ public function peerlistTotal() { public function peerlistPage(int $userId, int $limit, int $offset) { $key = sprintf(self::CACHE_KEY_PEERLIST_PAGE, $this->id, $offset); - if (($list = $this->cache->get_value($key)) === false) { + $list = $this->cache->get_value($key); + if ($list === false) { // force flush the next page of results $this->cache->delete_value(sprintf(self::CACHE_KEY_PEERLIST_PAGE, $this->id, $offset + $limit)); $this->db->prepared_query(" @@ -647,7 +648,9 @@ public function peerlistPage(int $userId, int $limit, int $offset) { xfu.ip AS ipv4addr, xfu.uid AS user_id, t.Size AS size, - sx.name AS seedbox + sx.name AS seedbox, + EXISTS(SELECT 1 FROM users_downloads ud WHERE ud.UserID = xfu.uid AND ud.TorrentID = xfu.fid) AS is_download, + EXISTS(SELECT 1 FROM xbt_snatched xs WHERE xs.uid = xfu.uid AND xs.fid = xfu.fid) AS is_snatched FROM xbt_files_users AS xfu INNER JOIN users_main AS um ON (um.ID = xfu.uid) INNER JOIN torrents AS t ON (t.ID = xfu.fid) @@ -658,9 +661,53 @@ public function peerlistPage(int $userId, int $limit, int $offset) { LIMIT ? OFFSET ? ", $userId, $this->id, $userId, $limit, $offset ); - $list = $this->db->to_array(false, MYSQLI_ASSOC); + $list = $this->db->to_array(false, MYSQLI_ASSOC, false); $this->cache->cache_value($key, $list, 300); } return $list; } + + public function downloadTotal(): int { + return $this->db->scalar(" + SELECT count(*) FROM users_downloads WHERE TorrentID = ? + ", $this->id + ); + } + + public function downloadPage(int $limit, int $offset): array { + $this->db->prepared_query(" + SELECT ud.UserID AS user_id, + ud.Time AS timestamp, + EXISTS(SELECT 1 FROM xbt_snatched xs WHERE xs.uid = ud.UserID AND xs.fid = ud.TorrentID) AS is_snatched, + EXISTS(SELECT 1 FROM xbt_files_users xfu WHERE xfu.uid = ud.UserID AND xfu.fid = ud.TorrentID) AS is_seeding + FROM users_downloads ud + WHERE ud.TorrentID = ? + ORDER BY ud.Time DESC, ud.UserID + LIMIT ? OFFSET ? + ", $this->id, $limit, $offset + ); + return $this->db->to_array(false, MYSQLI_ASSOC, false); + } + + public function snatchTotal(): int { + return $this->db->scalar(" + SELECT count(*) FROM xbt_snatched WHERE fid = ? + ", $this->id + ); + } + + public function snatchPage(int $limit, int $offset): array { + $this->db->prepared_query(" + SELECT xs.uid AS user_id, + from_unixtime(xs.tstamp) AS timestamp, + EXISTS(SELECT 1 FROM users_downloads ud WHERE ud.UserID = xs.uid AND ud.TorrentID = xs.fid) AS is_download, + EXISTS(SELECT 1 FROM xbt_files_users xfu WHERE xfu.uid = xs.uid AND xfu.fid = xs.fid) AS is_seeding + FROM xbt_snatched xs + WHERE xs.fid = ? + ORDER BY xs.tstamp DESC + LIMIT ? OFFSET ? + ", $this->id, $limit, $offset + ); + return $this->db->to_array(false, MYSQLI_ASSOC, false); + } } diff --git a/app/Util/Paginator.php b/app/Util/Paginator.php index 6d0948663..679c4fc17 100644 --- a/app/Util/Paginator.php +++ b/app/Util/Paginator.php @@ -39,6 +39,10 @@ public function total(): int { return $this->total; } + public function pages(): int { + return (int)ceil($this->total / $this->perPage); + } + public function setAnchor(string $anchor) { $this->anchor = '#' . $anchor; return $this; diff --git a/classes/config.template.php b/classes/config.template.php index 35e2ead65..ef1d93f32 100644 --- a/classes/config.template.php +++ b/classes/config.template.php @@ -323,6 +323,7 @@ define('ICON_NONE', "\xf0\x9f\x9a\xab"); define('ICON_TOGGLE', "\xf0\x9f\x94\x81"); define('ICON_PADLOCK', "\xF0\x9F\x94\x92"); +define('ICON_STAR', "\xE2\x98\x85"); define('COLLAGE', [ 0 => 'Personal', diff --git a/sections/reportsv2/report.php b/sections/reportsv2/report.php index f32d6d12c..d3f0bc14b 100644 --- a/sections/reportsv2/report.php +++ b/sections/reportsv2/report.php @@ -161,7 +161,7 @@ "; foreach ($Reports as $Report) { - if (check_perms('admin_reports')) { + if ($Viewer->permitted('admin_reports')) { $ReporterID = $Report['ReporterID']; $ReporterName = $userMan->findById($ReporterID)->username(); $ReportLinks = "$ReporterName reported it"; @@ -187,8 +187,8 @@ $ReportInfo .= "\n\t\t"; } -$CanEdit = (check_perms('torrents_edit') || (($UserID == $Viewer->id() && !$Viewer->disableWiki()) && !($Remastered && !$RemasterYear))); -$RegenLink = check_perms('users_mod') ? ' Regenerate' : ''; +$CanEdit = ($Viewer->permitted('torrents_edit') || (($UserID == $Viewer->id() && !$Viewer->disableWiki()) && !($Remastered && !$RemasterYear))); +$RegenLink = $Viewer->permitted('users_mod') ? ' Regenerate' : ''; $FileTable = ' @@ -296,7 +296,7 @@ 'key' => $Viewer->announceKey(), 't' => $TorrentList, 'edit' => $CanEdit, - 'remove' => check_perms('torrents_delete') || $UserID == $Viewer->id(), + 'remove' => $Viewer->permitted('torrents_delete') || $UserID == $Viewer->id(), 'pl' => true, ]) ?> » @@ -327,18 +327,18 @@ } ?> - +permitted('site_moderate_requests')) { ?>
+ + + + +splitMetaFilename($f); +?> + + +
+
File Names
+
+
+ Size +
+
reported by for the reason:
uploaded by on
Last action: @@ -396,6 +425,7 @@ t.Time, t.Description, t.Filelist, + t.FilePath, t.Remastered, t.RemasterTitle, t.RemasterYear, @@ -421,7 +451,7 @@ ); [$ExtraGroupName, $ExtraGroupID, $ExtraArtistID, $ExtraArtistName, - $ExtraYear, $ExtraTime, $ExtraDescription, $ExtraFileList, $ExtraRemastered, + $ExtraYear, $ExtraTime, $ExtraDescription, $ExtraFileList, $ExtraFilePath, $ExtraRemastered, $ExtraRemasterTitle, $ExtraRemasterYear, $ExtraMedia, $ExtraFormat, $ExtraEncoding, $ExtraSize, $ExtraHasCue, $ExtraHasLog, $ExtraLogScore, $ExtraLastAction, $ExtraUploaderID, $ExtraUploaderName] @@ -446,7 +476,35 @@ ?> ')?> - DL +
DL + Downloaders + Snatchers + Seeders + Contents + + + + +
uploaded by on () @@ -658,6 +716,8 @@ ); } elseif (isset($ReportType['extra_log'])) { $Value = $ReportType['extra_log']; + } else { + $Value = ''; } ?> diff --git a/sections/torrents/details.php b/sections/torrents/details.php index ecffac411..8c62321b9 100644 --- a/sections/torrents/details.php +++ b/sections/torrents/details.php @@ -86,11 +86,11 @@