//~~~~~~~~~~~ Main artist page ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
//For sorting tags
function compare($X, $Y) {
return($Y['count'] - $X['count']);
}
// Similar Artist Map
include(SERVER_ROOT.'/classes/artists_similar.class.php');
$UserVotes = Votes::get_user_votes($LoggedUser['ID']);
$ArtistID = $_GET['id'];
if (!is_number($ArtistID)) {
error(0);
}
if (!empty($_GET['revisionid'])) { // if they're viewing an old revision
$RevisionID = $_GET['revisionid'];
if (!is_number($RevisionID)) {
error(0);
}
$Data = $Cache->get_value("artist_{$ArtistID}_revision_$RevisionID", true);
} else { // viewing the live version
$Data = $Cache->get_value("artist_$ArtistID", true);
$RevisionID = false;
}
if ($Data) {
#list($K, list($Name, $Image, $Body, $NumSimilar, $SimilarArray, , , $VanityHouseArtist)) = each($Data);
list($K, list($Name, $Image, $Body, $NumSimilar, $SimilarArray)) = each($Data);
} else {
if ($RevisionID) {
$sql = "
SELECT
a.Name,
wiki.Image,
wiki.body
FROM wiki_artists AS wiki
LEFT JOIN artists_group AS a ON wiki.RevisionID = a.RevisionID
WHERE wiki.RevisionID = '$RevisionID' ";
} else {
$sql = "
SELECT
a.Name,
wiki.Image,
wiki.body
FROM artists_group AS a
LEFT JOIN wiki_artists AS wiki ON wiki.RevisionID = a.RevisionID
WHERE a.ArtistID = '$ArtistID' ";
}
$sql .= "
GROUP BY a.ArtistID";
$DB->query($sql);
if (!$DB->has_results()) {
error(404);
}
list($Name, $Image, $Body) = $DB->next_record(MYSQLI_NUM, array(0));
}
//----------------- Build list and get stats
ob_start();
// Requests
$Requests = array();
if (empty($LoggedUser['DisableRequests'])) {
$Requests = $Cache->get_value("artists_requests_$ArtistID");
if (!is_array($Requests)) {
$DB->query("
SELECT
r.ID,
r.CategoryID,
r.Title,
r.TitleRJ,
r.TitleJP,
r.CatalogueNumber,
r.DLSiteID,
r.TimeAdded,
COUNT(rv.UserID) AS Votes,
SUM(rv.Bounty) AS Bounty
FROM requests AS r
LEFT JOIN requests_votes AS rv ON rv.RequestID = r.ID
LEFT JOIN requests_artists AS ra ON r.ID = ra.RequestID
WHERE ra.ArtistID = $ArtistID
AND r.TorrentID = 0
GROUP BY r.ID
ORDER BY Votes DESC");
if ($DB->has_results()) {
$Requests = $DB->to_array('ID', MYSQLI_ASSOC, false);
} else {
$Requests = array();
}
$Cache->cache_value("artists_requests_$ArtistID", $Requests);
}
}
$NumRequests = count($Requests);
if (($GroupIDs = $Cache->get_value("artist_groups_$ArtistID")) === false) {
$DB->query("
SELECT
DISTINCTROW ta.GroupID
FROM torrents_artists AS ta
WHERE ta.ArtistID = '$ArtistID'");
$GroupIDs = $DB->collect('GroupID');
$Cache->cache_value("artist_groups_$ArtistID", $GroupIDs, 0);
}
if (count($GroupIDs) > 0) {
$TorrentList = Torrents::get_groups($GroupIDs, true, true);
} else {
$TorrentList = array();
}
$NumGroups = count($TorrentList);
if (!empty($TorrentList)) {
?>
}
// Deal with torrents without release types, which can end up here
// if they're uploaded with a non-grouping category ID
$UnknownRT = array_search('Unknown', $ReleaseTypes);
if ($UnknownRT === false) {
$UnknownRT = 1025;
$ReleaseTypes[$UnknownRT] = 'Unknown';
}
//Custom sorting for releases
if (!empty($LoggedUser['SortHide'])) {
$SortOrder = array_flip(array_keys($LoggedUser['SortHide']));
} else {
$SortOrder = $ReleaseTypes;
}
// If the $SortOrder array doesn't have all release types, put the missing ones at the end
$MissingTypes = array_diff_key($ReleaseTypes, $SortOrder);
if (!empty($MissingTypes)) {
$MaxOrder = max($SortOrder);
foreach (array_keys($MissingTypes) as $Missing) {
$SortOrder[$Missing] = ++$MaxOrder;
}
}
// Sort the anchors at the top of the page the same way as release types
reset($TorrentList);
$NumTorrents = 0;
$NumSeeders = 0;
$NumLeechers = 0;
$NumSnatches = 0;
foreach ($TorrentList as $GroupID => $Group) {
// $Tags array is for the sidebar on the right.
$TorrentTags = new Tags($Group['TagList'], true);
foreach ($Group['Torrents'] as $TorrentID => $Torrent) {
$NumTorrents++;
$Torrent['Seeders'] = (int)$Torrent['Seeders'];
$Torrent['Leechers'] = (int)$Torrent['Leechers'];
$Torrent['Snatched'] = (int)$Torrent['Snatched'];
$NumSeeders += $Torrent['Seeders'];
$NumLeechers += $Torrent['Leechers'];
$NumSnatches += $Torrent['Snatched'];
}
}
$OpenTable = false;
$ShowGroups = !isset($LoggedUser['TorrentGrouping']) || $LoggedUser['TorrentGrouping'] == 0;
$HideTorrents = ($ShowGroups ? '' : ' hidden');
$OldGroupID = 0;
?>
$TorrentDisplayList = ob_get_clean();
//----------------- End building list and getting stats
// Comments (must be loaded before View::show_header so that subscriptions and quote notifications are handled properly)
list($NumComments, $Page, $Thread, $LastRead) = Comments::load('artist', $ArtistID);
View::show_header($Name, 'browse,requests,bbcode,comments,voting,recommend,subscriptions');
?>
=display_str($Name)?> if ($RevisionID) { ?> (Revision #=$RevisionID?>) } ?>
if (check_perms('site_submit_requests')) { ?>
Add request
}
if (check_perms('site_torrents_notify')) {
if (($Notify = $Cache->get_value('notify_artists_'.$LoggedUser['ID'])) === false) {
$DB->query("
SELECT ID, Artists
FROM users_notify_filters
WHERE UserID = '$LoggedUser[ID]'
AND Label = 'Artist notifications'
LIMIT 1");
$Notify = $DB->next_record(MYSQLI_ASSOC, false);
$Cache->cache_value('notify_artists_'.$LoggedUser['ID'], $Notify, 0);
}
if (stripos($Notify['Artists'], "|$Name|") === false) {
?>
Notify of new uploads
} else { ?>
Do not notify of new uploads
}
}
if (Bookmarks::has_bookmarked('artist', $ArtistID)) {
?>
Remove bookmark
} else { ?>
Bookmark
} ?>
=Subscriptions::has_subscribed_comments('artist', $ArtistID) !== false ? 'Unsubscribe' : 'Subscribe'?>
if (check_perms('site_edit_wiki')) {
?>
Edit
} ?>
View history
if ($RevisionID && check_perms('site_edit_wiki')) { ?>
Revert to this revision
} ?>
InfoComments
if (check_perms('site_delete_artist') && check_perms('torrents_delete')) { ?>
Delete
} ?>
Number of torrents: =number_format($NumTorrents)?>
Number of seeders: =number_format($NumSeeders)?>
Number of leechers: =number_format($NumLeechers)?>
Number of snatches: =number_format($NumSnatches)?>
if (empty($SimilarArray)) {
$DB->query("
SELECT
s2.ArtistID,
a.Name,
ass.Score,
ass.SimilarID
FROM artists_similar AS s1
JOIN artists_similar AS s2 ON s1.SimilarID = s2.SimilarID AND s1.ArtistID != s2.ArtistID
JOIN artists_similar_scores AS ass ON ass.SimilarID = s1.SimilarID
JOIN artists_group AS a ON a.ArtistID = s2.ArtistID
WHERE s1.ArtistID = '$ArtistID'
ORDER BY ass.Score DESC
LIMIT 30
");
$SimilarArray = $DB->to_array();
$NumSimilar = count($SimilarArray);
}
?>