/*
User collage subscription page
*/
if (!check_perms('site_collages_subscribe')) {
error(403);
}
View::show_header('Subscribed collections','browse,collage');
$ShowAll = !empty($_GET['showall']);
if (!$ShowAll) {
$sql = "
SELECT
c.ID,
c.Name,
c.NumTorrents,
s.LastVisit
FROM collages AS c
JOIN users_collage_subs AS s ON s.CollageID = c.ID
JOIN collages_torrents AS ct ON ct.CollageID = c.ID
WHERE s.UserID = $LoggedUser[ID] AND c.Deleted = '0'
AND ct.AddedOn > s.LastVisit
GROUP BY c.ID";
} else {
$sql = "
SELECT
c.ID,
c.Name,
c.NumTorrents,
s.LastVisit
FROM collages AS c
JOIN users_collage_subs AS s ON s.CollageID = c.ID
LEFT JOIN collages_torrents AS ct ON ct.CollageID = c.ID
WHERE s.UserID = $LoggedUser[ID] AND c.Deleted = '0'
GROUP BY c.ID";
}
$DB->query($sql);
$NumResults = $DB->record_count();
$CollageSubs = $DB->to_array();
?>
if (!$NumResults) {
?>
No subscribed collections=($ShowAll ? '' : ' with new additions')?>
} else {
$HideGroup = '';
$ActionTitle = 'Hide';
$ActionURL = 'hide';
$ShowGroups = 0;
foreach ($CollageSubs as $Collage) {
unset($TorrentTable);
list($CollageID, $CollageName, $CollageSize, $LastVisit) = $Collage;
$RS = $DB->query("
SELECT GroupID
FROM collages_torrents
WHERE CollageID = $CollageID
AND AddedOn > '" . db_string($LastVisit) . "'
ORDER BY AddedOn");
$NewTorrentCount = $DB->record_count();
$GroupIDs = $DB->collect('GroupID', false);
if (count($GroupIDs) > 0) {
$TorrentList = Torrents::get_groups($GroupIDs);
} else {
$TorrentList = [];
}
$Artists = Artists::get_artists($GroupIDs);
$Number = 0;
foreach ($GroupIDs as $GroupID) {
if (!isset($TorrentList[$GroupID])) {
continue;
}
$Group = $TorrentList[$GroupID];
extract(Torrents::array_group($Group));
$DisplayName = '';
$TorrentTags = new Tags($TagList);
if (!empty($ExtendedArtists[1]) || !empty($ExtendedArtists[4]) || !empty($ExtendedArtists[5]) || !empty($ExtendedArtists[6])) {
unset($ExtendedArtists[2]);
unset($ExtendedArtists[3]);
$DisplayName .= Artists::display_artists($ExtendedArtists);
} elseif (count($Artists) > 0) {
$DisplayName .= Artists::display_artists(array('1' => $Artists));
}
$DisplayName .= "
".($GroupName ? $GroupName : ($GroupNameRJ ? $GroupNameRJ : $GroupNameJP))." ";
if ($GroupYear > 0) {
$DisplayName = "$DisplayName [$GroupYear]";
}
$SnatchedGroupClass = $GroupFlags['IsSnatched'] ? ' snatched_group' : '';
// Start an output buffer, so we can store this output in $TorrentTable
ob_start();
if (count($Torrents) > 1 || $GroupCategoryID == 1) {
?>
=$DisplayName?>
=$TorrentTags->format()?>
foreach ($Torrents as $TorrentID => $Torrent) {
$SnatchedTorrentClass = $Torrent['IsSnatched'] ? ' snatched_torrent' : '';
?>
DL
» =Torrents::torrent_info($Torrent)?>
=Format::get_size($Torrent['Size'])?>
=number_format($Torrent['Snatched'])?>
=number_format($Torrent['Seeders'])?>
=number_format($Torrent['Leechers'])?>
}
} else {
// Viewing a type that does not require grouping
list($TorrentID, $Torrent) = each($Torrents);
$DisplayName = "
".($GroupName ? $GroupName : ($GroupNameRJ ? $GroupNameRJ : $GroupNameJP))." ";
if ($Torrent['IsSnatched']) {
$DisplayName .= ' ' . Format::torrent_label('Snatched!');
}
if (!empty($Torrent['FreeTorrent'])) {
$DisplayName .= ' ' . Format::torrent_label('Freeleech!');
}
$SnatchedTorrentClass = $Torrent['IsSnatched'] ? ' snatched_torrent' : '';
?>
[ DL
| RP ]
=$DisplayName?>
=$TorrentTags->format()?>
=Format::get_size($Torrent['Size'])?>
=number_format($Torrent['Snatched'])?>
=number_format($Torrent['Seeders'])?>
=number_format($Torrent['Leechers'])?>
}
$TorrentTable .= ob_get_clean();
} ?>
Torrents
Size
=$TorrentTable?>
} // foreach ()
} // else -- if (empty($NumResults))
?>
View::show_footer();
?>