//~~~~~~~~~~~ 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.'/classes/class_text.php'); // Text formatting class
$Text = new TEXT;
include(SERVER_ROOT.'/sections/requests/functions.php');
// Similar artist map
include(SERVER_ROOT.'/classes/class_artists_similar.php');
include(SERVER_ROOT.'/classes/class_image_tools.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", true);
} else { // viewing the live version
$Data = $Cache->get_value('artist_'.$ArtistID, true);
$RevisionID = false;
}
if($Data) {
if (!is_array($Data)) {
$Data = unserialize($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->record_count()==0) { error(404); }
list($Name, $Image, $Body, $VanityHouseArtist) = $DB->next_record(MYSQLI_NUM, array(0));
}
//----------------- 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;
$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 IF(ta.Importance IN ('2', '3', '4', '7'),1000 + ta.Importance, tg.ReleaseType) ASC,
tg.Year DESC, tg.Name DESC");
$GroupIDs = $DB->collect('GroupID');
$Importances = $DB->to_array(false, 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)) {
?>
}
$TorrentDisplayList = ob_get_clean();
//----------------- End building list and getting stats
View::show_header($Name, 'browse,requests,bbcode,comments');
?>
=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 (has_bookmarked('artist', $ArtistID)) {
?>
[Remove bookmark]
} else {
?>
[Bookmark]
}
if (check_perms('site_edit_wiki')) {
?>
[Edit]
} ?>
[View history]
if (check_perms('site_delete_artist') && check_perms('torrents_delete')) { ?>
[Delete]
}
if ($RevisionID && check_perms('site_edit_wiki')) {
?>
[Revert to this revision]
} ?>
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);
}
?>
get_value('artist_comments_'.$ArtistID);
if($Results === false) {
$DB->query("SELECT
COUNT(c.ID)
FROM artist_comments as c
WHERE c.ArtistID = '$ArtistID'");
list($Results) = $DB->next_record();
$Cache->cache_value('artist_comments_'.$ArtistID, $Results, 0);
}
if(isset($_GET['postid']) && is_number($_GET['postid']) && $Results > TORRENT_COMMENTS_PER_PAGE) {
$DB->query("SELECT COUNT(ID) FROM artist_comments WHERE ArtistID = $ArtistID AND ID <= $_GET[postid]");
list($PostNum) = $DB->next_record();
list($Page,$Limit) = Format::page_limit(TORRENT_COMMENTS_PER_PAGE,$PostNum);
} else {
list($Page,$Limit) = Format::page_limit(TORRENT_COMMENTS_PER_PAGE,$Results);
}
//Get the cache catalogue
$CatalogueID = floor((TORRENT_COMMENTS_PER_PAGE*$Page-TORRENT_COMMENTS_PER_PAGE)/THREAD_CATALOGUE);
$CatalogueLimit=$CatalogueID*THREAD_CATALOGUE . ', ' . THREAD_CATALOGUE;
//---------- Get some data to start processing
// Cache catalogue from which the page is selected, allows block caches and future ability to specify posts per page
$Catalogue = $Cache->get_value('artist_comments_'.$ArtistID.'_catalogue_'.$CatalogueID);
if($Catalogue === false) {
$DB->query("SELECT
c.ID,
c.AuthorID,
c.AddedTime,
c.Body,
c.EditedUserID,
c.EditedTime,
u.Username
FROM artist_comments as c
LEFT JOIN users_main AS u ON u.ID=c.EditedUserID
WHERE c.ArtistID = '$ArtistID'
ORDER BY c.ID
LIMIT $CatalogueLimit");
$Catalogue = $DB->to_array(false,MYSQLI_ASSOC);
$Cache->cache_value('artist_comments_'.$ArtistID.'_catalogue_'.$CatalogueID, $Catalogue, 0);
}
//This is a hybrid to reduce the catalogue down to the page elements: We use the page limit % catalogue
$Thread = array_slice($Catalogue,((TORRENT_COMMENTS_PER_PAGE*$Page-TORRENT_COMMENTS_PER_PAGE)%THREAD_CATALOGUE),TORRENT_COMMENTS_PER_PAGE,true);
?>