ini_set('memory_limit', -1);
//~~~~~~~~~~~ Main bookmarks page ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
function compare($X, $Y){
return($Y['count'] - $X['count']);
}
if(!empty($_GET['userid'])) {
if(!check_perms('users_mod')) {
error(403);
}
$UserID = $_GET['userid'];
$Sneaky = true;
if(!is_number($UserID)) { error(404); }
} else {
$UserID = $LoggedUser['ID'];
}
$Data = $Cache->get_value('bookmarks_'.$UserID);
if($Data) {
$Data = unserialize($Data);
list($K, list($Username, $TorrentList, $CollageDataList)) = each($Data);
} else {
$DB->query("SELECT Username FROM users_main WHERE ID='$UserID'");
list($Username) = $DB->next_record();
// Build the data for the collage and the torrent list
$DB->query("SELECT
bt.GroupID,
tg.WikiImage,
tg.CategoryID,
bt.Time
FROM bookmarks_torrents AS bt
JOIN torrents_group AS tg ON tg.ID=bt.GroupID
WHERE bt.UserID='$UserID'
ORDER BY bt.Time");
$GroupIDs = $DB->collect('GroupID');
$CollageDataList=$DB->to_array('GroupID', MYSQLI_ASSOC);
if(count($GroupIDs)>0) {
$TorrentList = get_groups($GroupIDs);
$TorrentList = $TorrentList['matches'];
} else {
$TorrentList = array();
}
}
if(empty($TorrentList)) {
error("You do not have any bookmarks yet!");
}
show_header($Username."'s Bookmarks",'browse');
// Loop through the result set, building up $Collage and $TorrentTable
// Then we print them.
$Collage = array();
$TorrentTable = '';
$NumGroups = 0;
$Artists = array();
$Tags = array();
foreach ($TorrentList as $GroupID=>$Group) {
list($GroupID, $GroupName, $GroupYear, $GroupRecordLabel, $GroupCatalogueNumber, $TagList, $ReleaseType, $Torrents, $GroupArtists) = array_values($Group);
list($GroupID2, $Image, $GroupCategoryID, $AddedTime) = array_values($CollageDataList[$GroupID]);
// Handle stats and stuff
$NumGroups++;
if($GroupArtists) {
foreach($GroupArtists as $Artist) {
if(!isset($Artists[$Artist['id']])) {
$Artists[$Artist['id']] = array('name'=>$Artist['name'], 'count'=>1);
} else {
$Artists[$Artist['id']]['count']++;
}
}
}
$TagList = explode(' ',str_replace('_','.',$TagList));
$TorrentTags = array();
foreach($TagList as $Tag) {
if(!isset($Tags[$Tag])) {
$Tags[$Tag] = array('name'=>$Tag, 'count'=>1);
} else {
$Tags[$Tag]['count']++;
}
$TorrentTags[]=''.$Tag.'';
}
$PrimaryTag = $TagList[0];
$TorrentTags = implode(', ', $TorrentTags);
$TorrentTags='
'.$TorrentTags.'
';
$DisplayName = '';
if(count($GroupArtists)>0) {
$DisplayName = display_artists(array('1'=>$GroupArtists));
}
$DisplayName .= ''.$GroupName.'';
if($GroupYear>0) { $DisplayName = $DisplayName. ' ['. $GroupYear .']';}
// Start an output buffer, so we can store this output in $TorrentTable
ob_start();
if(count($Torrents)>1 || $GroupCategoryID==1) {
// Grouped torrents
?>
|
|
=$DisplayName?>
if(!isset($Sneaky)){ ?>
Remove Bookmark
} ?>
=$TorrentTags?>
=time_diff($AddedTime);?>
|
$LastRemasterYear = '-';
$LastRemasterTitle = '';
$LastRemasterRecordLabel = '';
$LastRemasterCatalogueNumber = '';
foreach ($Torrents as $TorrentID => $Torrent) {
if($Torrent['RemasterTitle'] != $LastRemasterTitle || $Torrent['RemasterYear'] != $LastRemasterYear ||
$Torrent['RemasterRecordLabel'] != $LastRemasterRecordLabel || $Torrent['RemasterCatalogueNumber'] != $LastRemasterCatalogueNumber) {
if($Torrent['RemasterTitle'] || $Torrent['RemasterYear'] || $Torrent['RemasterRecordLabel'] || $Torrent['RemasterCatalogueNumber']) {
$RemasterName = $Torrent['RemasterYear'];
$AddExtra = " - ";
if($Torrent['RemasterRecordLabel']) { $RemasterName .= $AddExtra.display_str($Torrent['RemasterRecordLabel']); $AddExtra=' / '; }
if($Torrent['RemasterCatalogueNumber']) { $RemasterName .= $AddExtra.display_str($Torrent['RemasterCatalogueNumber']); $AddExtra=' / '; }
if($Torrent['RemasterTitle']) { $RemasterName .= $AddExtra.display_str($Torrent['RemasterTitle']); $AddExtra=' / '; }
?>
=$RemasterName?> |
} else {
$MasterName = "Original Release";
$AddExtra = " / ";
if($GroupRecordLabel) { $MasterName .= $AddExtra.$GroupRecordLabel; $AddExtra=' / '; }
if($GroupCatalogueNumber) { $MasterName .= $AddExtra.$GroupCatalogueNumber; $AddExtra=' / '; }
?>
=$MasterName?> |
}
}
$LastRemasterTitle = $Torrent['RemasterTitle'];
$LastRemasterYear = $Torrent['RemasterYear'];
$LastRemasterRecordLabel = $Torrent['RemasterRecordLabel'];
$LastRemasterCatalogueNumber = $Torrent['RemasterCatalogueNumber'];
?>
[DL]
» =torrent_info($Torrent)?>
|
=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.'';
if(!empty($Torrent['FreeTorrent'])) {
$DisplayName .=' Freeleech!';
}
?>
|
|
[DL
| RP]
=$DisplayName?>
=$TorrentTags?>
if(empty($Sneaky)){ ?>
Remove Bookmark
} ?>
=time_diff($AddedTime);?>
|
=get_size($Torrent['Size'])?> |
=number_format($Torrent['Snatched'])?> |
>=number_format($Torrent['Seeders'])?> |
=number_format($Torrent['Leechers'])?> |
}
$TorrentTable.=ob_get_clean();
// Album art
ob_start();
$DisplayName = '';
if(!empty($GroupArtists)) {
$DisplayName.= display_artists(array('1'=>$GroupArtists), false);
}
$DisplayName .= $GroupName;
if($GroupYear>0) { $DisplayName = $DisplayName. ' ['. $GroupYear .']';}
?>
if($Image) { ?>
} else { ?>
=$DisplayName?>
} ?>
$Collage[]=ob_get_clean();
}
?>
=$Username?>'s Bookmarks
if(empty($LoggedUser['HideCollage'])) { ?>
foreach($Collage as $Group) { ?>
=$Group?>
} ?>
} ?>
|
|
Torrents (View) |
Size |
|
|
|
=$TorrentTable?>
show_footer();
$Cache->cache_value('bookmarks_'.$UserID, serialize(array(array($Username, $TorrentList, $CollageDataList))), 3600);
?>