//~~~~~~~~~~~ Main artist page ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
//For sorting tags
function compare($X, $Y){
return($Y['count'] - $X['count']);
}
include(SERVER_ROOT.'/sections/bookmarks/functions.php'); // has_bookmarked()
include(SERVER_ROOT.'/sections/requests/functions.php');
include(SERVER_ROOT.'/classes/class_text.php'); // Text formatting class
$Text = new TEXT;
// Similar artist map
include(SERVER_ROOT.'/classes/class_artists_similar.php');
$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");
} else { // viewing the live version
$Data = $Cache->get_value('artist_'.$ArtistID);
$RevisionID = false;
}
if($Data) {
$Data = unserialize($Data);
list($K, list($Name, $Image, $Body, $NumSimilar, $SimilarArray, $TorrentList, $GroupMeta)) = each($Data);
} 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 ";
if($RevisionID){
$sql.=" wiki.RevisionID='$RevisionID' ";
} else {
$sql.=" a.ArtistID='$ArtistID' ";
}
$sql .= " GROUP BY a.ArtistID";
$DB->query($sql, MYSQLI_NUM, true);
if($DB->record_count()==0) { error(404); }
list($Name, $Image, $Body, $VanityHouseArtist) = $DB->next_record();
}
//----------------- Build list and get stats
ob_start();
// Requests
$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->record_count() > 0) {
$Requests = $DB->to_array();
} else {
$Requests = array();
}
$Cache->cache_value('artists_requests_'.$ArtistID, $Requests);
}
$NumRequests = count($Requests);
$LastReleaseType = 0;
if(empty($GroupMeta) || empty($TorrentList)) {
$DB->query("SELECT
DISTINCT ta.GroupID, ta.Importance, tg.VanityHouse
FROM torrents_artists AS ta
JOIN torrents_group AS tg ON tg.ID=ta.GroupID
WHERE ta.ArtistID='$ArtistID'
ORDER BY ta.Importance, tg.ReleaseType ASC, tg.Year DESC");
$GroupIDs = $DB->collect('GroupID');
$GroupMeta = $DB->to_array('GroupID', MYSQLI_BOTH, false);
if(count($GroupIDs)>0) {
$TorrentList = Torrents::get_groups($GroupIDs, true, true);
$TorrentList = $TorrentList['matches'];
} else {
$TorrentList = array();
}
}
$NumGroups = count($TorrentList);
if(!empty($TorrentList)) {
?>
}
// Get list of used release types
$UsedReleases = array();
$TorrentListByReleaseType = array();
// Check if user has preferences for ordering/showing
if (isset($LoggedUser['ArtistOptions']) && is_array($LoggedUser['ArtistOptions'])) {
$ReleaseTypesOrder = $LoggedUser['ArtistOptions'];
$HasShown = in_array(1, $ReleaseTypesOrder);
// Add releasetypes from default order, useful when new types are added
foreach($ReleaseTypesDefaultOrder as $Key => $ReleaseType) {
if(!array_key_exists($ReleaseType, $ReleaseTypesOrder)) {
$ReleaseTypesOrder[$ReleaseType] = $HasShown ? 1 : 0; // If no releasetype is open by default assume (s)he wants them all closed
}
}
} else {
// Load defaults
$ReleaseTypesOrder = array_flip($ReleaseTypesDefaultOrder);
}
foreach($ReleaseTypesOrder as $ReleaseType => $ReleaseTypeName) {
$TorrentListByReleaseType[$ReleaseType] = array();
}
//Names for releasetypes that are not uploadable but exist in the defaultordering
$ReleaseTypes[1023] = "Remixed By";
$ReleaseTypes[1024] = "Guest Appearance";
foreach($TorrentList as $GroupID=>$Group) {
if($GroupMeta[$GroupID]['Importance'] == '2') {
$TorrentList[$GroupID]['ReleaseType'] = 1024;
}
if($GroupMeta[$GroupID]['Importance'] == '3') {
$TorrentList[$GroupID]['ReleaseType'] = 1023;
}
if(!in_array($TorrentList[$GroupID]['ReleaseType'], $UsedReleases)) {
$UsedReleases[] = $TorrentList[$GroupID]['ReleaseType'];
}
$TorrentListByReleaseType[$TorrentList[$GroupID]['ReleaseType']][$GroupID] = $Group;
}
reset($TorrentList);
if(!empty($UsedReleases)) { ?>
}
$NumTorrents = 0;
$NumSeeders = 0;
$NumLeechers = 0;
$NumSnatches = 0;
function display_name($ReleaseType) {
global $ReleaseTypes;
return $DisplayName;
}
?>
$OpenTable = false;
foreach ($TorrentListByReleaseType as $ReleaseType => $TorrentListForReleaseType) {
$NumTorrentsReleaseType = count($TorrentListForReleaseType);
if($OpenTable) {
?>
$OpenTable = false;
}
switch($ReleaseTypes[$ReleaseType]) {
case "Remix" :
$DisplayName = "Remixes";
break;
case "Anthology" :
$DisplayName = "Anthologies";
break;
default :
$DisplayName = $ReleaseTypes[$ReleaseType]."s";
break;
}
$ReleaseTypeLabel = strtolower(str_replace(' ','_',$ReleaseTypes[$ReleaseType]));
if ((isset($LoggedUser['ArtistOptions']) && array_key_exists($ReleaseType, $LoggedUser['ArtistOptions'])) && $LoggedUser['ArtistOptions'][$ReleaseType] == 0) {
$HideDiscog = " hidden";
$HideDiscogDefault = true;
}
else {
$HideDiscog = "";
$HideDiscogDefault = false;
}
?>
" id="torrents_=$ReleaseTypeLabel?>">
if($NumTorrentsReleaseType > 0) { ?>
↑
} ?>
=$DisplayName?>
if($NumTorrentsReleaseType > 0) { ?>
( id="releases_=$ReleaseType?>_viewlink" onclick="setShow('=$ReleaseType?>',true);return false;">View id="releases_=$ReleaseType?>_hidelink" onclick="setShow('=$ReleaseType?>',false);return false;">Hide )
} ?>
Size
id="releases_=$ReleaseType?>_openlink" onclick="setDefaultShow('=$ReleaseType?>',true);return false;">[default closed]
id="releases_=$ReleaseType?>_closedlink" onclick="setDefaultShow('=$ReleaseType?>',false);return false;">[default open]
type="checkbox" title="Show" />
☰
$OpenTable = true;
foreach($TorrentListForReleaseType as $GroupID => $Group) {
list($GroupID, $GroupName, $GroupYear, $GroupRecordLabel, $GroupCatalogueNumber, $TagList, $NewReleaseType, $GroupVanityHouse, $Torrents, $GroupArtists) = array_values($Group);
$GroupVanityHouse = $GroupMeta[$GroupID]['VanityHouse'];
$TagList = explode(' ',str_replace('_','.',$TagList));
$TorrentTags = array();
// $Tags array is for the sidebar on the right
foreach($TagList as $Tag) {
if(!isset($Tags[$Tag])) {
$Tags[$Tag] = array('name'=>$Tag, 'count'=>1);
} else {
$Tags[$Tag]['count']++;
}
$TorrentTags[]=''.$Tag.' ';
}
$TorrentTags = implode(', ', $TorrentTags);
$TorrentTags = ''.$TorrentTags.'
';
if (($ReleaseType == 1023) || ($ReleaseType == 1024)) {
$ArtistPrefix = Artists::display_artists(array(1 => $GroupArtists));
} else {
$ArtistPrefix = '';
}
$DisplayName = $ArtistPrefix . ''.$GroupName.' ';
if($GroupYear>0) { $DisplayName = $GroupYear. ' - '.$DisplayName; }
if($GroupVanityHouse) { $DisplayName .= ' [VH ]'; }
?>
=$DisplayName?>
=$TorrentTags?>
$LastRemasterYear = '-';
$LastRemasterTitle = '';
$LastRemasterRecordLabel = '';
$LastRemasterCatalogueNumber = '';
$LastMedia = '';
$EditionID = 0;
foreach ($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'];
if($Torrent['RemasterTitle'] != $LastRemasterTitle || $Torrent['RemasterYear'] != $LastRemasterYear ||
$Torrent['RemasterRecordLabel'] != $LastRemasterRecordLabel || $Torrent['RemasterCatalogueNumber'] != $LastRemasterCatalogueNumber || $Torrent['Media'] != $LastMedia) {
$EditionID++;
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 .= $AddExtra.display_str($Torrent['Media']);
?>
− =$RemasterName?>
} else {
$MasterName = "Original Release";
$AddExtra = " / ";
if($GroupRecordLabel) { $MasterName .= $AddExtra.$GroupRecordLabel; $AddExtra=' / '; }
if($GroupCatalogueNumber) { $MasterName .= $AddExtra.$GroupCatalogueNumber; $AddExtra=' / '; }
$MasterName .= $AddExtra.display_str($Torrent['Media']);
?>
− =$MasterName?>
}
}
$LastRemasterTitle = $Torrent['RemasterTitle'];
$LastRemasterYear = $Torrent['RemasterYear'];
$LastRemasterRecordLabel = $Torrent['RemasterRecordLabel'];
$LastRemasterCatalogueNumber = $Torrent['RemasterCatalogueNumber'];
$LastMedia = $Torrent['Media'];
?>
[ DL ]
» =Torrents::torrent_info($Torrent)?>
=Format::get_size($Torrent['Size'])?>
=number_format($Torrent['Snatched'])?>
=number_format($Torrent['Seeders'])?>
=number_format($Torrent['Leechers'])?>
}
}
}
if(!empty($TorrentList)) { ?>
}
?>
$TorrentDisplayList = ob_get_clean();
//----------------- End building list and getting stats
View::show_header($Name, 'browse,requests,artists,bbcode');
?>
echo $TorrentDisplayList;
if($NumRequests > 0) {
?>
↑
Request Name
Vote
Bounty
Added
foreach($Requests as $Request) {
list($RequestID, $CategoryID, $Title, $Year, $TimeAdded, $Votes, $Bounty) = $Request;
$CategoryName = $Categories[$CategoryID - 1];
if($CategoryName == "Music") {
$ArtistForm = get_request_artists($RequestID);
$ArtistLink = Artists::display_artists($ArtistForm, true, true);
$FullName = $ArtistLink."".$Title." [".$Year."] ";
} else if($CategoryName == "Audiobooks" || $CategoryName == "Comedy") {
$FullName = "".$Title." [".$Year."] ";
} else {
$FullName ="".$Title." ";
}
$Row = ($Row == 'a') ? 'b' : 'a';
$Tags = get_request_tags($RequestID);
?>
=$FullName?>
=$Votes?>
if(check_perms('site_vote')){ ?>
(+)
} ?>
=Format::get_size($Bounty)?>
=time_diff($TimeAdded)?>
} ?>
}
// Similar artist map
if($NumSimilar>0) {
$SimilarData = $Cache->get_value('similar_positions_'.$ArtistID);
if(!$Data) {
include(SERVER_ROOT.'/classes/class_image.php');
$Img = new IMAGE;
$Img->create(WIDTH, HEIGHT);
$Img->color(255,255,255, 127);
$Similar = new ARTISTS_SIMILAR($ArtistID, $Name);
$Similar->set_up();
$Similar->set_positions();
$Similar->background_image();
$SimilarData = $Similar->dump_data();
$Cache->cache_value('similar_positions_'.$ArtistID, $SimilarData, 3600*24);
} else {
$Similar = new ARTISTS_SIMILAR($ArtistID);
$Similar->load_data($SimilarData);
}
?>
Similar artist map
$Similar->write_artists();
?>
} // if $NumSimilar>0 ?>
Artist info
=$Text->full_format($Body)?>
View::show_footer();
// Cache page for later use
if($RevisionID) {
$Key = "artist_$ArtistID"."_revision_$RevisionID";
} else {
$Key = 'artist_'.$ArtistID;
}
$Data = serialize(array(array($Name, $Image, $Body, $NumSimilar, $SimilarArray, $TorrentList, $GroupMeta)));
$Cache->cache_value($Key, $Data, 3600);
?>