//~~~~~~~~~~~ Main artist page ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
//For sorting tags
function compare($X, $Y) {
return($Y['count'] - $X['count']);
}
include(SERVER_ROOT.'/classes/text.class.php'); // Text formatting class
$Text = new TEXT;
// 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);
} else {
if ($RevisionID) {
$sql = "
SELECT
a.Name,
wiki.Image,
wiki.body,
a.VanityHouse
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,
a.VanityHouse
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, $VanityHouseArtist) = $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.Year,
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();
} else {
$Requests = array();
}
$Cache->cache_value("artists_requests_$ArtistID", $Requests);
}
}
$NumRequests = count($Requests);
if (($Importances = $Cache->get_value("artist_groups_$ArtistID")) === false) {
$DB->query("
SELECT
DISTINCTROW ta.GroupID, ta.Importance, tg.VanityHouse, tg.Year
FROM torrents_artists AS ta
JOIN torrents_group AS tg ON tg.ID = ta.GroupID
WHERE ta.ArtistID = '$ArtistID'
ORDER BY tg.Year DESC, tg.Name DESC");
$GroupIDs = $DB->collect('GroupID');
$Importances = $DB->to_array(false, MYSQLI_BOTH, false);
$Cache->cache_value("artist_groups_$ArtistID", $Importances, 0);
} else {
$GroupIDs = array();
foreach ($Importances as $Group) {
$GroupIDs[] = $Group['GroupID'];
}
}
if (count($GroupIDs) > 0) {
$TorrentList = Torrents::get_groups($GroupIDs, true, true);
$TorrentList = $TorrentList['matches'];
} 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';
}
// Get list of used release types
$UsedReleases = array();
foreach ($Importances as $ID => $Group) {
switch ($Importances[$ID]['Importance']) {
case '2':
$Importances[$ID]['ReleaseType'] = 1024;
$GuestAlbums = true;
break;
case '3':
$Importances[$ID]['ReleaseType'] = 1023;
$RemixerAlbums = true;
break;
case '4':
$Importances[$ID]['ReleaseType'] = 1022;
$ComposerAlbums = true;
break;
case '7':
$Importances[$ID]['ReleaseType'] = 1021;
$ProducerAlbums = true;
break;
default:
if (!isset($ReleaseTypes[$TorrentList[$Group['GroupID']]['ReleaseType']])) {
$TorrentList[$Group['GroupID']]['ReleaseType'] = $UnknownRT;
}
$Importances[$ID]['ReleaseType'] = $TorrentList[$Group['GroupID']]['ReleaseType'];
}
if (!isset($UsedReleases[$Importances[$ID]['ReleaseType']])) {
$UsedReleases[$Importances[$ID]['ReleaseType']] = true;
}
$Importances[$ID]['Sort'] = $ID;
}
if (!empty($GuestAlbums)) {
$ReleaseTypes[1024] = 'Guest Appearance';
}
if (!empty($RemixerAlbums)) {
$ReleaseTypes[1023] = 'Remixed By';
}
if (!empty($ComposerAlbums)) {
$ReleaseTypes[1022] = 'Composition';
}
if (!empty($ProducerAlbums)) {
$ReleaseTypes[1021] = 'Produced By';
}
//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;
}
}
uasort($Importances, function ($A, $B) use ($SortOrder) {
if ($SortOrder[$A['ReleaseType']] == $SortOrder[$B['ReleaseType']]) {
return (($A['Sort'] < $B['Sort']) ? -1 : 1);
}
return (($SortOrder[$A['ReleaseType']] < $SortOrder[$B['ReleaseType']]) ? -1 : 1);
});
// Sort the anchors at the top of the page the same way as release types
$UsedReleases = array_flip(array_intersect_key($SortOrder, $UsedReleases));
reset($TorrentList);
if (!empty($UsedReleases)) { ?>
}
$TorrentDisplayList = ob_get_clean();
//----------------- End building list and getting stats
View::show_header($Name, 'browse,requests,bbcode,comments,voting,recommend,subscriptions');
?>
=display_str($Name)?> if ($RevisionID) { ?> (Revision #=$RevisionID?>) } if ($VanityHouseArtist) { ?> [Vanity House] } ?>
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
} ?>
Info
if (defined('LASTFM_API_KEY')) { ?>
Concerts
} ?>
Comments
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);
}
?>